// Code generated by go-swagger; DO NOT EDIT. package operations // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "context" "io" "net/http" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" "github.com/nspcc-dev/neofs-rest-gw/gen/models" ) // NewAuthParams creates a new AuthParams object // with the default values initialized. func NewAuthParams() AuthParams { var ( // initialize parameters with default values xBearerLifetimeDefault = int64(100) ) return AuthParams{ XBearerLifetime: &xBearerLifetimeDefault, } } // AuthParams contains all the bound params for the auth operation // typically these are obtained from a http.Request // // swagger:parameters auth type AuthParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` /*Token lifetime in epoch In: header Default: 100 */ XBearerLifetime *int64 /*Owner Id (wallet address) that will sign the token Required: true In: header */ XBearerOwnerID string /*Supported operation scope for token Required: true In: header */ XBearerScope string /*Bearer token Required: true In: body */ Token *models.Bearer } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // // To ensure default values, the struct must have been initialized with NewAuthParams() beforehand. func (o *AuthParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r if err := o.bindXBearerLifetime(r.Header[http.CanonicalHeaderKey("X-Bearer-Lifetime")], true, route.Formats); err != nil { res = append(res, err) } if err := o.bindXBearerOwnerID(r.Header[http.CanonicalHeaderKey("X-Bearer-Owner-Id")], true, route.Formats); err != nil { res = append(res, err) } if err := o.bindXBearerScope(r.Header[http.CanonicalHeaderKey("X-Bearer-Scope")], true, route.Formats); err != nil { res = append(res, err) } if runtime.HasBody(r) { defer r.Body.Close() var body models.Bearer if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { res = append(res, errors.Required("token", "body", "")) } else { res = append(res, errors.NewParseError("token", "body", "", err)) } } else { // validate body object if err := body.Validate(route.Formats); err != nil { res = append(res, err) } ctx := validate.WithOperationRequest(context.Background()) if err := body.ContextValidate(ctx, route.Formats); err != nil { res = append(res, err) } if len(res) == 0 { o.Token = &body } } } else { res = append(res, errors.Required("token", "body", "")) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } // bindXBearerLifetime binds and validates parameter XBearerLifetime from header. func (o *AuthParams) bindXBearerLifetime(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewAuthParams() return nil } value, err := swag.ConvertInt64(raw) if err != nil { return errors.InvalidType("X-Bearer-Lifetime", "header", "int64", raw) } o.XBearerLifetime = &value return nil } // bindXBearerOwnerID binds and validates parameter XBearerOwnerID from header. func (o *AuthParams) bindXBearerOwnerID(rawData []string, hasKey bool, formats strfmt.Registry) error { if !hasKey { return errors.Required("X-Bearer-Owner-Id", "header", rawData) } var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true if err := validate.RequiredString("X-Bearer-Owner-Id", "header", raw); err != nil { return err } o.XBearerOwnerID = raw return nil } // bindXBearerScope binds and validates parameter XBearerScope from header. func (o *AuthParams) bindXBearerScope(rawData []string, hasKey bool, formats strfmt.Registry) error { if !hasKey { return errors.Required("X-Bearer-Scope", "header", rawData) } var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true if err := validate.RequiredString("X-Bearer-Scope", "header", raw); err != nil { return err } o.XBearerScope = raw if err := o.validateXBearerScope(formats); err != nil { return err } return nil } // validateXBearerScope carries on validations for parameter XBearerScope func (o *AuthParams) validateXBearerScope(formats strfmt.Registry) error { if err := validate.EnumCase("X-Bearer-Scope", "header", o.XBearerScope, []interface{}{"object", "container"}, true); err != nil { return err } return nil }