From 396536c31280e33a89bd6cf9a4748fc15d63d2c6 Mon Sep 17 00:00:00 2001 From: Andrew Martinez Date: Wed, 23 Jun 2021 11:06:02 -0400 Subject: [PATCH] add list parameters to authenticators --- .../list_authenticators_parameters.go | 95 ++++++++++++++++++ rest_management_api_server/embedded_spec.go | 34 +++++++ .../list_authenticators_parameters.go | 96 +++++++++++++++++++ .../list_authenticators_urlbuilder.go | 36 +++++++ specs/management.yml | 10 ++ specs/source/management/authenticators.yml | 5 +- 6 files changed, 275 insertions(+), 1 deletion(-) diff --git a/rest_management_api_client/authenticator/list_authenticators_parameters.go b/rest_management_api_client/authenticator/list_authenticators_parameters.go index 8dd7ddc11..b94c0ae10 100644 --- a/rest_management_api_client/authenticator/list_authenticators_parameters.go +++ b/rest_management_api_client/authenticator/list_authenticators_parameters.go @@ -38,6 +38,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewListAuthenticatorsParams creates a new ListAuthenticatorsParams object, @@ -82,6 +83,16 @@ func NewListAuthenticatorsParamsWithHTTPClient(client *http.Client) *ListAuthent Typically these are written to a http.Request. */ type ListAuthenticatorsParams struct { + + // Filter. + Filter *string + + // Limit. + Limit *int64 + + // Offset. + Offset *int64 + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -135,6 +146,39 @@ func (o *ListAuthenticatorsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithFilter adds the filter to the list authenticators params +func (o *ListAuthenticatorsParams) WithFilter(filter *string) *ListAuthenticatorsParams { + o.SetFilter(filter) + return o +} + +// SetFilter adds the filter to the list authenticators params +func (o *ListAuthenticatorsParams) SetFilter(filter *string) { + o.Filter = filter +} + +// WithLimit adds the limit to the list authenticators params +func (o *ListAuthenticatorsParams) WithLimit(limit *int64) *ListAuthenticatorsParams { + o.SetLimit(limit) + return o +} + +// SetLimit adds the limit to the list authenticators params +func (o *ListAuthenticatorsParams) SetLimit(limit *int64) { + o.Limit = limit +} + +// WithOffset adds the offset to the list authenticators params +func (o *ListAuthenticatorsParams) WithOffset(offset *int64) *ListAuthenticatorsParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list authenticators params +func (o *ListAuthenticatorsParams) SetOffset(offset *int64) { + o.Offset = offset +} + // WriteToRequest writes these params to a swagger request func (o *ListAuthenticatorsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -143,6 +187,57 @@ func (o *ListAuthenticatorsParams) WriteToRequest(r runtime.ClientRequest, reg s } var res []error + if o.Filter != nil { + + // query param filter + var qrFilter string + + if o.Filter != nil { + qrFilter = *o.Filter + } + qFilter := qrFilter + if qFilter != "" { + + if err := r.SetQueryParam("filter", qFilter); err != nil { + return err + } + } + } + + if o.Limit != nil { + + // query param limit + var qrLimit int64 + + if o.Limit != nil { + qrLimit = *o.Limit + } + qLimit := swag.FormatInt64(qrLimit) + if qLimit != "" { + + if err := r.SetQueryParam("limit", qLimit); err != nil { + return err + } + } + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/rest_management_api_server/embedded_spec.go b/rest_management_api_server/embedded_spec.go index 87ecdcfdd..79a02eb26 100644 --- a/rest_management_api_server/embedded_spec.go +++ b/rest_management_api_server/embedded_spec.go @@ -465,6 +465,23 @@ func init() { ], "summary": "List authenticators", "operationId": "listAuthenticators", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], "responses": { "200": { "description": "A list of authenticators", @@ -19055,6 +19072,23 @@ func init() { ], "summary": "List authenticators", "operationId": "listAuthenticators", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], "responses": { "200": { "description": "A list of authenticators", diff --git a/rest_management_api_server/operations/authenticator/list_authenticators_parameters.go b/rest_management_api_server/operations/authenticator/list_authenticators_parameters.go index 7aafd7e03..687151c1a 100644 --- a/rest_management_api_server/operations/authenticator/list_authenticators_parameters.go +++ b/rest_management_api_server/operations/authenticator/list_authenticators_parameters.go @@ -33,7 +33,10 @@ import ( "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" ) // NewListAuthenticatorsParams creates a new ListAuthenticatorsParams object @@ -52,6 +55,19 @@ type ListAuthenticatorsParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -63,8 +79,88 @@ func (o *ListAuthenticatorsParams) BindRequest(r *http.Request, route *middlewar o.HTTPRequest = r + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } + +// bindFilter binds and validates parameter Filter from query. +func (o *ListAuthenticatorsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListAuthenticatorsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListAuthenticatorsParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/rest_management_api_server/operations/authenticator/list_authenticators_urlbuilder.go b/rest_management_api_server/operations/authenticator/list_authenticators_urlbuilder.go index 0f121cd32..eed02efe2 100644 --- a/rest_management_api_server/operations/authenticator/list_authenticators_urlbuilder.go +++ b/rest_management_api_server/operations/authenticator/list_authenticators_urlbuilder.go @@ -33,11 +33,19 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // ListAuthenticatorsURL generates an URL for the list authenticators operation type ListAuthenticatorsURL struct { + Filter *string + Limit *int64 + Offset *int64 + _basePath string + // avoid unkeyed usage + _ struct{} } // WithBasePath sets the base path for this url builder, only required when it's different from the @@ -67,6 +75,34 @@ func (o *ListAuthenticatorsURL) Build() (*url.URL, error) { } _result.Path = golangswaggerpaths.Join(_basePath, _path) + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + return &_result, nil } diff --git a/specs/management.yml b/specs/management.yml index 4f5a774dc..60286a2fe 100644 --- a/specs/management.yml +++ b/specs/management.yml @@ -296,6 +296,16 @@ paths: - Authenticator summary: List authenticators operationId: listAuthenticators + parameters: + - type: integer + name: limit + in: query + - type: integer + name: offset + in: query + - type: string + name: filter + in: query responses: "200": description: A list of authenticators diff --git a/specs/source/management/authenticators.yml b/specs/source/management/authenticators.yml index bd6192f04..518f30cd9 100644 --- a/specs/source/management/authenticators.yml +++ b/specs/source/management/authenticators.yml @@ -12,7 +12,10 @@ paths: tags: - Authenticator operationId: listAuthenticators - + parameters: + - $ref: '../shared/parameters.yml#/limit' + - $ref: '../shared/parameters.yml#/offset' + - $ref: '../shared/parameters.yml#/filter' responses: '200': $ref: '../shared/authenticators.yml#/responses/listAuthenticators'