github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/backups/backups_restore_parameters.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  // Code generated by go-swagger; DO NOT EDIT.
    13  
    14  package backups
    15  
    16  // This file was generated by the swagger tool.
    17  // Editing this file might prove futile when you re-run the swagger generate command
    18  
    19  import (
    20  	"io"
    21  	"net/http"
    22  
    23  	"github.com/go-openapi/errors"
    24  	"github.com/go-openapi/runtime"
    25  	"github.com/go-openapi/runtime/middleware"
    26  	"github.com/go-openapi/strfmt"
    27  	"github.com/go-openapi/validate"
    28  
    29  	"github.com/weaviate/weaviate/entities/models"
    30  )
    31  
    32  // NewBackupsRestoreParams creates a new BackupsRestoreParams object
    33  //
    34  // There are no default values defined in the spec.
    35  func NewBackupsRestoreParams() BackupsRestoreParams {
    36  
    37  	return BackupsRestoreParams{}
    38  }
    39  
    40  // BackupsRestoreParams contains all the bound params for the backups restore operation
    41  // typically these are obtained from a http.Request
    42  //
    43  // swagger:parameters backups.restore
    44  type BackupsRestoreParams struct {
    45  
    46  	// HTTP Request Object
    47  	HTTPRequest *http.Request `json:"-"`
    48  
    49  	/*Backup backend name e.g. filesystem, gcs, s3.
    50  	  Required: true
    51  	  In: path
    52  	*/
    53  	Backend string
    54  	/*
    55  	  Required: true
    56  	  In: body
    57  	*/
    58  	Body *models.BackupRestoreRequest
    59  	/*The ID of a backup. Must be URL-safe and work as a filesystem path, only lowercase, numbers, underscore, minus characters allowed.
    60  	  Required: true
    61  	  In: path
    62  	*/
    63  	ID string
    64  }
    65  
    66  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    67  // for simple values it will use straight method calls.
    68  //
    69  // To ensure default values, the struct must have been initialized with NewBackupsRestoreParams() beforehand.
    70  func (o *BackupsRestoreParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    71  	var res []error
    72  
    73  	o.HTTPRequest = r
    74  
    75  	rBackend, rhkBackend, _ := route.Params.GetOK("backend")
    76  	if err := o.bindBackend(rBackend, rhkBackend, route.Formats); err != nil {
    77  		res = append(res, err)
    78  	}
    79  
    80  	if runtime.HasBody(r) {
    81  		defer r.Body.Close()
    82  		var body models.BackupRestoreRequest
    83  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    84  			if err == io.EOF {
    85  				res = append(res, errors.Required("body", "body", ""))
    86  			} else {
    87  				res = append(res, errors.NewParseError("body", "body", "", err))
    88  			}
    89  		} else {
    90  			// validate body object
    91  			if err := body.Validate(route.Formats); err != nil {
    92  				res = append(res, err)
    93  			}
    94  
    95  			ctx := validate.WithOperationRequest(r.Context())
    96  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    97  				res = append(res, err)
    98  			}
    99  
   100  			if len(res) == 0 {
   101  				o.Body = &body
   102  			}
   103  		}
   104  	} else {
   105  		res = append(res, errors.Required("body", "body", ""))
   106  	}
   107  
   108  	rID, rhkID, _ := route.Params.GetOK("id")
   109  	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
   110  		res = append(res, err)
   111  	}
   112  	if len(res) > 0 {
   113  		return errors.CompositeValidationError(res...)
   114  	}
   115  	return nil
   116  }
   117  
   118  // bindBackend binds and validates parameter Backend from path.
   119  func (o *BackupsRestoreParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error {
   120  	var raw string
   121  	if len(rawData) > 0 {
   122  		raw = rawData[len(rawData)-1]
   123  	}
   124  
   125  	// Required: true
   126  	// Parameter is provided by construction from the route
   127  	o.Backend = raw
   128  
   129  	return nil
   130  }
   131  
   132  // bindID binds and validates parameter ID from path.
   133  func (o *BackupsRestoreParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
   134  	var raw string
   135  	if len(rawData) > 0 {
   136  		raw = rawData[len(rawData)-1]
   137  	}
   138  
   139  	// Required: true
   140  	// Parameter is provided by construction from the route
   141  	o.ID = raw
   142  
   143  	return nil
   144  }