github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/backups/backups_create_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 // NewBackupsCreateParams creates a new BackupsCreateParams object 33 // 34 // There are no default values defined in the spec. 35 func NewBackupsCreateParams() BackupsCreateParams { 36 37 return BackupsCreateParams{} 38 } 39 40 // BackupsCreateParams contains all the bound params for the backups create operation 41 // typically these are obtained from a http.Request 42 // 43 // swagger:parameters backups.create 44 type BackupsCreateParams 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.BackupCreateRequest 59 } 60 61 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 62 // for simple values it will use straight method calls. 63 // 64 // To ensure default values, the struct must have been initialized with NewBackupsCreateParams() beforehand. 65 func (o *BackupsCreateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 66 var res []error 67 68 o.HTTPRequest = r 69 70 rBackend, rhkBackend, _ := route.Params.GetOK("backend") 71 if err := o.bindBackend(rBackend, rhkBackend, route.Formats); err != nil { 72 res = append(res, err) 73 } 74 75 if runtime.HasBody(r) { 76 defer r.Body.Close() 77 var body models.BackupCreateRequest 78 if err := route.Consumer.Consume(r.Body, &body); err != nil { 79 if err == io.EOF { 80 res = append(res, errors.Required("body", "body", "")) 81 } else { 82 res = append(res, errors.NewParseError("body", "body", "", err)) 83 } 84 } else { 85 // validate body object 86 if err := body.Validate(route.Formats); err != nil { 87 res = append(res, err) 88 } 89 90 ctx := validate.WithOperationRequest(r.Context()) 91 if err := body.ContextValidate(ctx, route.Formats); err != nil { 92 res = append(res, err) 93 } 94 95 if len(res) == 0 { 96 o.Body = &body 97 } 98 } 99 } else { 100 res = append(res, errors.Required("body", "body", "")) 101 } 102 if len(res) > 0 { 103 return errors.CompositeValidationError(res...) 104 } 105 return nil 106 } 107 108 // bindBackend binds and validates parameter Backend from path. 109 func (o *BackupsCreateParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { 110 var raw string 111 if len(rawData) > 0 { 112 raw = rawData[len(rawData)-1] 113 } 114 115 // Required: true 116 // Parameter is provided by construction from the route 117 o.Backend = raw 118 119 return nil 120 }