diff --git a/apiserver/controllers/controllers.go b/apiserver/controllers/controllers.go index a089db54..651b072a 100644 --- a/apiserver/controllers/controllers.go +++ b/apiserver/controllers/controllers.go @@ -202,7 +202,7 @@ func (a *APIController) NotFoundHandler(w http.ResponseWriter, r *http.Request) } } -// swagger:route GET /metrics-token metrics-token MetricsToken +// swagger:route GET /metrics-token metrics-token GetMetricsToken // // Returns a JWT token that can be used to access the metrics endpoint. // diff --git a/apiserver/swagger.yaml b/apiserver/swagger.yaml index b557a716..73dd5ced 100644 --- a/apiserver/swagger.yaml +++ b/apiserver/swagger.yaml @@ -324,7 +324,7 @@ paths: - jobs /metrics-token: get: - operationId: MetricsToken + operationId: GetMetricsToken responses: "200": description: JWTResponse diff --git a/client/metrics_token/get_metrics_token_parameters.go b/client/metrics_token/get_metrics_token_parameters.go new file mode 100644 index 00000000..5099e113 --- /dev/null +++ b/client/metrics_token/get_metrics_token_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics_token + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetMetricsTokenParams creates a new GetMetricsTokenParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetMetricsTokenParams() *GetMetricsTokenParams { + return &GetMetricsTokenParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetMetricsTokenParamsWithTimeout creates a new GetMetricsTokenParams object +// with the ability to set a timeout on a request. +func NewGetMetricsTokenParamsWithTimeout(timeout time.Duration) *GetMetricsTokenParams { + return &GetMetricsTokenParams{ + timeout: timeout, + } +} + +// NewGetMetricsTokenParamsWithContext creates a new GetMetricsTokenParams object +// with the ability to set a context for a request. +func NewGetMetricsTokenParamsWithContext(ctx context.Context) *GetMetricsTokenParams { + return &GetMetricsTokenParams{ + Context: ctx, + } +} + +// NewGetMetricsTokenParamsWithHTTPClient creates a new GetMetricsTokenParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetMetricsTokenParamsWithHTTPClient(client *http.Client) *GetMetricsTokenParams { + return &GetMetricsTokenParams{ + HTTPClient: client, + } +} + +/* +GetMetricsTokenParams contains all the parameters to send to the API endpoint + + for the get metrics token operation. + + Typically these are written to a http.Request. +*/ +type GetMetricsTokenParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get metrics token params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetMetricsTokenParams) WithDefaults() *GetMetricsTokenParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get metrics token params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetMetricsTokenParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get metrics token params +func (o *GetMetricsTokenParams) WithTimeout(timeout time.Duration) *GetMetricsTokenParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get metrics token params +func (o *GetMetricsTokenParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get metrics token params +func (o *GetMetricsTokenParams) WithContext(ctx context.Context) *GetMetricsTokenParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get metrics token params +func (o *GetMetricsTokenParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get metrics token params +func (o *GetMetricsTokenParams) WithHTTPClient(client *http.Client) *GetMetricsTokenParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get metrics token params +func (o *GetMetricsTokenParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetMetricsTokenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/metrics_token/get_metrics_token_responses.go b/client/metrics_token/get_metrics_token_responses.go new file mode 100644 index 00000000..0625afb0 --- /dev/null +++ b/client/metrics_token/get_metrics_token_responses.go @@ -0,0 +1,174 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics_token + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + apiserver_params "github.com/cloudbase/garm/apiserver/params" + garm_params "github.com/cloudbase/garm/params" +) + +// GetMetricsTokenReader is a Reader for the GetMetricsToken structure. +type GetMetricsTokenReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetMetricsTokenReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetMetricsTokenOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetMetricsTokenUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /metrics-token] GetMetricsToken", response, response.Code()) + } +} + +// NewGetMetricsTokenOK creates a GetMetricsTokenOK with default headers values +func NewGetMetricsTokenOK() *GetMetricsTokenOK { + return &GetMetricsTokenOK{} +} + +/* +GetMetricsTokenOK describes a response with status code 200, with default header values. + +JWTResponse +*/ +type GetMetricsTokenOK struct { + Payload garm_params.JWTResponse +} + +// IsSuccess returns true when this get metrics token o k response has a 2xx status code +func (o *GetMetricsTokenOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get metrics token o k response has a 3xx status code +func (o *GetMetricsTokenOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get metrics token o k response has a 4xx status code +func (o *GetMetricsTokenOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get metrics token o k response has a 5xx status code +func (o *GetMetricsTokenOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get metrics token o k response a status code equal to that given +func (o *GetMetricsTokenOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get metrics token o k response +func (o *GetMetricsTokenOK) Code() int { + return 200 +} + +func (o *GetMetricsTokenOK) Error() string { + return fmt.Sprintf("[GET /metrics-token][%d] getMetricsTokenOK %+v", 200, o.Payload) +} + +func (o *GetMetricsTokenOK) String() string { + return fmt.Sprintf("[GET /metrics-token][%d] getMetricsTokenOK %+v", 200, o.Payload) +} + +func (o *GetMetricsTokenOK) GetPayload() garm_params.JWTResponse { + return o.Payload +} + +func (o *GetMetricsTokenOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetMetricsTokenUnauthorized creates a GetMetricsTokenUnauthorized with default headers values +func NewGetMetricsTokenUnauthorized() *GetMetricsTokenUnauthorized { + return &GetMetricsTokenUnauthorized{} +} + +/* +GetMetricsTokenUnauthorized describes a response with status code 401, with default header values. + +APIErrorResponse +*/ +type GetMetricsTokenUnauthorized struct { + Payload apiserver_params.APIErrorResponse +} + +// IsSuccess returns true when this get metrics token unauthorized response has a 2xx status code +func (o *GetMetricsTokenUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get metrics token unauthorized response has a 3xx status code +func (o *GetMetricsTokenUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get metrics token unauthorized response has a 4xx status code +func (o *GetMetricsTokenUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get metrics token unauthorized response has a 5xx status code +func (o *GetMetricsTokenUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get metrics token unauthorized response a status code equal to that given +func (o *GetMetricsTokenUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the get metrics token unauthorized response +func (o *GetMetricsTokenUnauthorized) Code() int { + return 401 +} + +func (o *GetMetricsTokenUnauthorized) Error() string { + return fmt.Sprintf("[GET /metrics-token][%d] getMetricsTokenUnauthorized %+v", 401, o.Payload) +} + +func (o *GetMetricsTokenUnauthorized) String() string { + return fmt.Sprintf("[GET /metrics-token][%d] getMetricsTokenUnauthorized %+v", 401, o.Payload) +} + +func (o *GetMetricsTokenUnauthorized) GetPayload() apiserver_params.APIErrorResponse { + return o.Payload +} + +func (o *GetMetricsTokenUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/metrics_token/metrics_token_client.go b/client/metrics_token/metrics_token_client.go index 8f7b6fd3..60baae75 100644 --- a/client/metrics_token/metrics_token_client.go +++ b/client/metrics_token/metrics_token_client.go @@ -30,28 +30,28 @@ type ClientOption func(*runtime.ClientOperation) // ClientService is the interface for Client methods type ClientService interface { - MetricsToken(params *MetricsTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*MetricsTokenOK, error) + GetMetricsToken(params *GetMetricsTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetMetricsTokenOK, error) SetTransport(transport runtime.ClientTransport) } /* -MetricsToken returns a j w t token that can be used to access the metrics endpoint +GetMetricsToken returns a j w t token that can be used to access the metrics endpoint */ -func (a *Client) MetricsToken(params *MetricsTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*MetricsTokenOK, error) { +func (a *Client) GetMetricsToken(params *GetMetricsTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetMetricsTokenOK, error) { // TODO: Validate the params before sending if params == nil { - params = NewMetricsTokenParams() + params = NewGetMetricsTokenParams() } op := &runtime.ClientOperation{ - ID: "MetricsToken", + ID: "GetMetricsToken", Method: "GET", PathPattern: "/metrics-token", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, - Reader: &MetricsTokenReader{formats: a.formats}, + Reader: &GetMetricsTokenReader{formats: a.formats}, AuthInfo: authInfo, Context: params.Context, Client: params.HTTPClient, @@ -64,13 +64,13 @@ func (a *Client) MetricsToken(params *MetricsTokenParams, authInfo runtime.Clien if err != nil { return nil, err } - success, ok := result.(*MetricsTokenOK) + success, ok := result.(*GetMetricsTokenOK) if ok { return success, nil } // unexpected success response // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for MetricsToken: API contract not enforced by server. Client expected to get an error, but got: %T", result) + msg := fmt.Sprintf("unexpected success response for GetMetricsToken: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } diff --git a/client/metrics_token/metrics_token_parameters.go b/client/metrics_token/metrics_token_parameters.go deleted file mode 100644 index dd92d05e..00000000 --- a/client/metrics_token/metrics_token_parameters.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package metrics_token - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewMetricsTokenParams creates a new MetricsTokenParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewMetricsTokenParams() *MetricsTokenParams { - return &MetricsTokenParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewMetricsTokenParamsWithTimeout creates a new MetricsTokenParams object -// with the ability to set a timeout on a request. -func NewMetricsTokenParamsWithTimeout(timeout time.Duration) *MetricsTokenParams { - return &MetricsTokenParams{ - timeout: timeout, - } -} - -// NewMetricsTokenParamsWithContext creates a new MetricsTokenParams object -// with the ability to set a context for a request. -func NewMetricsTokenParamsWithContext(ctx context.Context) *MetricsTokenParams { - return &MetricsTokenParams{ - Context: ctx, - } -} - -// NewMetricsTokenParamsWithHTTPClient creates a new MetricsTokenParams object -// with the ability to set a custom HTTPClient for a request. -func NewMetricsTokenParamsWithHTTPClient(client *http.Client) *MetricsTokenParams { - return &MetricsTokenParams{ - HTTPClient: client, - } -} - -/* -MetricsTokenParams contains all the parameters to send to the API endpoint - - for the metrics token operation. - - Typically these are written to a http.Request. -*/ -type MetricsTokenParams struct { - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the metrics token params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *MetricsTokenParams) WithDefaults() *MetricsTokenParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the metrics token params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *MetricsTokenParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the metrics token params -func (o *MetricsTokenParams) WithTimeout(timeout time.Duration) *MetricsTokenParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the metrics token params -func (o *MetricsTokenParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the metrics token params -func (o *MetricsTokenParams) WithContext(ctx context.Context) *MetricsTokenParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the metrics token params -func (o *MetricsTokenParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the metrics token params -func (o *MetricsTokenParams) WithHTTPClient(client *http.Client) *MetricsTokenParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the metrics token params -func (o *MetricsTokenParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WriteToRequest writes these params to a swagger request -func (o *MetricsTokenParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/client/metrics_token/metrics_token_responses.go b/client/metrics_token/metrics_token_responses.go deleted file mode 100644 index 90e3aa5a..00000000 --- a/client/metrics_token/metrics_token_responses.go +++ /dev/null @@ -1,174 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package metrics_token - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - apiserver_params "github.com/cloudbase/garm/apiserver/params" - garm_params "github.com/cloudbase/garm/params" -) - -// MetricsTokenReader is a Reader for the MetricsToken structure. -type MetricsTokenReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *MetricsTokenReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewMetricsTokenOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewMetricsTokenUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("[GET /metrics-token] MetricsToken", response, response.Code()) - } -} - -// NewMetricsTokenOK creates a MetricsTokenOK with default headers values -func NewMetricsTokenOK() *MetricsTokenOK { - return &MetricsTokenOK{} -} - -/* -MetricsTokenOK describes a response with status code 200, with default header values. - -JWTResponse -*/ -type MetricsTokenOK struct { - Payload garm_params.JWTResponse -} - -// IsSuccess returns true when this metrics token o k response has a 2xx status code -func (o *MetricsTokenOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this metrics token o k response has a 3xx status code -func (o *MetricsTokenOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this metrics token o k response has a 4xx status code -func (o *MetricsTokenOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this metrics token o k response has a 5xx status code -func (o *MetricsTokenOK) IsServerError() bool { - return false -} - -// IsCode returns true when this metrics token o k response a status code equal to that given -func (o *MetricsTokenOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the metrics token o k response -func (o *MetricsTokenOK) Code() int { - return 200 -} - -func (o *MetricsTokenOK) Error() string { - return fmt.Sprintf("[GET /metrics-token][%d] metricsTokenOK %+v", 200, o.Payload) -} - -func (o *MetricsTokenOK) String() string { - return fmt.Sprintf("[GET /metrics-token][%d] metricsTokenOK %+v", 200, o.Payload) -} - -func (o *MetricsTokenOK) GetPayload() garm_params.JWTResponse { - return o.Payload -} - -func (o *MetricsTokenOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewMetricsTokenUnauthorized creates a MetricsTokenUnauthorized with default headers values -func NewMetricsTokenUnauthorized() *MetricsTokenUnauthorized { - return &MetricsTokenUnauthorized{} -} - -/* -MetricsTokenUnauthorized describes a response with status code 401, with default header values. - -APIErrorResponse -*/ -type MetricsTokenUnauthorized struct { - Payload apiserver_params.APIErrorResponse -} - -// IsSuccess returns true when this metrics token unauthorized response has a 2xx status code -func (o *MetricsTokenUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this metrics token unauthorized response has a 3xx status code -func (o *MetricsTokenUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this metrics token unauthorized response has a 4xx status code -func (o *MetricsTokenUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this metrics token unauthorized response has a 5xx status code -func (o *MetricsTokenUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this metrics token unauthorized response a status code equal to that given -func (o *MetricsTokenUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the metrics token unauthorized response -func (o *MetricsTokenUnauthorized) Code() int { - return 401 -} - -func (o *MetricsTokenUnauthorized) Error() string { - return fmt.Sprintf("[GET /metrics-token][%d] metricsTokenUnauthorized %+v", 401, o.Payload) -} - -func (o *MetricsTokenUnauthorized) String() string { - return fmt.Sprintf("[GET /metrics-token][%d] metricsTokenUnauthorized %+v", 401, o.Payload) -} - -func (o *MetricsTokenUnauthorized) GetPayload() apiserver_params.APIErrorResponse { - return o.Payload -} - -func (o *MetricsTokenUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -}