From 6ce79fb259314b5fdb1d8e44b48c680f0b283571 Mon Sep 17 00:00:00 2001 From: Gerrit91 Date: Mon, 8 Jan 2024 15:59:17 +0100 Subject: [PATCH] Update. --- .../size/list_size_reservations_parameters.go | 128 ++++++++++++ .../size/list_size_reservations_responses.go | 181 +++++++++++++++++ api/client/size/size_client.go | 40 ++++ api/models/v1_size_reservation_response.go | 190 ++++++++++++++++++ metal-api.json | 81 ++++++++ 5 files changed, 620 insertions(+) create mode 100644 api/client/size/list_size_reservations_parameters.go create mode 100644 api/client/size/list_size_reservations_responses.go create mode 100644 api/models/v1_size_reservation_response.go diff --git a/api/client/size/list_size_reservations_parameters.go b/api/client/size/list_size_reservations_parameters.go new file mode 100644 index 0000000..4bc31a9 --- /dev/null +++ b/api/client/size/list_size_reservations_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package size + +// 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" +) + +// NewListSizeReservationsParams creates a new ListSizeReservationsParams 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 NewListSizeReservationsParams() *ListSizeReservationsParams { + return &ListSizeReservationsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListSizeReservationsParamsWithTimeout creates a new ListSizeReservationsParams object +// with the ability to set a timeout on a request. +func NewListSizeReservationsParamsWithTimeout(timeout time.Duration) *ListSizeReservationsParams { + return &ListSizeReservationsParams{ + timeout: timeout, + } +} + +// NewListSizeReservationsParamsWithContext creates a new ListSizeReservationsParams object +// with the ability to set a context for a request. +func NewListSizeReservationsParamsWithContext(ctx context.Context) *ListSizeReservationsParams { + return &ListSizeReservationsParams{ + Context: ctx, + } +} + +// NewListSizeReservationsParamsWithHTTPClient creates a new ListSizeReservationsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListSizeReservationsParamsWithHTTPClient(client *http.Client) *ListSizeReservationsParams { + return &ListSizeReservationsParams{ + HTTPClient: client, + } +} + +/* +ListSizeReservationsParams contains all the parameters to send to the API endpoint + + for the list size reservations operation. + + Typically these are written to a http.Request. +*/ +type ListSizeReservationsParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list size reservations params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListSizeReservationsParams) WithDefaults() *ListSizeReservationsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list size reservations params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListSizeReservationsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list size reservations params +func (o *ListSizeReservationsParams) WithTimeout(timeout time.Duration) *ListSizeReservationsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list size reservations params +func (o *ListSizeReservationsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list size reservations params +func (o *ListSizeReservationsParams) WithContext(ctx context.Context) *ListSizeReservationsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list size reservations params +func (o *ListSizeReservationsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list size reservations params +func (o *ListSizeReservationsParams) WithHTTPClient(client *http.Client) *ListSizeReservationsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list size reservations params +func (o *ListSizeReservationsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *ListSizeReservationsParams) 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/api/client/size/list_size_reservations_responses.go b/api/client/size/list_size_reservations_responses.go new file mode 100644 index 0000000..33be496 --- /dev/null +++ b/api/client/size/list_size_reservations_responses.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package size + +// 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" + + "github.com/metal-stack/metal-go/api/models" + "github.com/metal-stack/metal-lib/httperrors" +) + +// ListSizeReservationsReader is a Reader for the ListSizeReservations structure. +type ListSizeReservationsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListSizeReservationsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListSizeReservationsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListSizeReservationsDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListSizeReservationsOK creates a ListSizeReservationsOK with default headers values +func NewListSizeReservationsOK() *ListSizeReservationsOK { + return &ListSizeReservationsOK{} +} + +/* +ListSizeReservationsOK describes a response with status code 200, with default header values. + +OK +*/ +type ListSizeReservationsOK struct { + Payload []*models.V1SizeReservationResponse +} + +// IsSuccess returns true when this list size reservations o k response has a 2xx status code +func (o *ListSizeReservationsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this list size reservations o k response has a 3xx status code +func (o *ListSizeReservationsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this list size reservations o k response has a 4xx status code +func (o *ListSizeReservationsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this list size reservations o k response has a 5xx status code +func (o *ListSizeReservationsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this list size reservations o k response a status code equal to that given +func (o *ListSizeReservationsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the list size reservations o k response +func (o *ListSizeReservationsOK) Code() int { + return 200 +} + +func (o *ListSizeReservationsOK) Error() string { + return fmt.Sprintf("[GET /v1/size/reservations][%d] listSizeReservationsOK %+v", 200, o.Payload) +} + +func (o *ListSizeReservationsOK) String() string { + return fmt.Sprintf("[GET /v1/size/reservations][%d] listSizeReservationsOK %+v", 200, o.Payload) +} + +func (o *ListSizeReservationsOK) GetPayload() []*models.V1SizeReservationResponse { + return o.Payload +} + +func (o *ListSizeReservationsOK) 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 +} + +// NewListSizeReservationsDefault creates a ListSizeReservationsDefault with default headers values +func NewListSizeReservationsDefault(code int) *ListSizeReservationsDefault { + return &ListSizeReservationsDefault{ + _statusCode: code, + } +} + +/* +ListSizeReservationsDefault describes a response with status code -1, with default header values. + +Error +*/ +type ListSizeReservationsDefault struct { + _statusCode int + + Payload *httperrors.HTTPErrorResponse +} + +// IsSuccess returns true when this list size reservations default response has a 2xx status code +func (o *ListSizeReservationsDefault) IsSuccess() bool { + return o._statusCode/100 == 2 +} + +// IsRedirect returns true when this list size reservations default response has a 3xx status code +func (o *ListSizeReservationsDefault) IsRedirect() bool { + return o._statusCode/100 == 3 +} + +// IsClientError returns true when this list size reservations default response has a 4xx status code +func (o *ListSizeReservationsDefault) IsClientError() bool { + return o._statusCode/100 == 4 +} + +// IsServerError returns true when this list size reservations default response has a 5xx status code +func (o *ListSizeReservationsDefault) IsServerError() bool { + return o._statusCode/100 == 5 +} + +// IsCode returns true when this list size reservations default response a status code equal to that given +func (o *ListSizeReservationsDefault) IsCode(code int) bool { + return o._statusCode == code +} + +// Code gets the status code for the list size reservations default response +func (o *ListSizeReservationsDefault) Code() int { + return o._statusCode +} + +func (o *ListSizeReservationsDefault) Error() string { + return fmt.Sprintf("[GET /v1/size/reservations][%d] listSizeReservations default %+v", o._statusCode, o.Payload) +} + +func (o *ListSizeReservationsDefault) String() string { + return fmt.Sprintf("[GET /v1/size/reservations][%d] listSizeReservations default %+v", o._statusCode, o.Payload) +} + +func (o *ListSizeReservationsDefault) GetPayload() *httperrors.HTTPErrorResponse { + return o.Payload +} + +func (o *ListSizeReservationsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(httperrors.HTTPErrorResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/client/size/size_client.go b/api/client/size/size_client.go index 729c42b..ee9f211 100644 --- a/api/client/size/size_client.go +++ b/api/client/size/size_client.go @@ -36,6 +36,8 @@ type ClientService interface { FromHardware(params *FromHardwareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*FromHardwareOK, error) + ListSizeReservations(params *ListSizeReservationsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListSizeReservationsOK, error) + ListSizes(params *ListSizesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListSizesOK, error) Suggest(params *SuggestParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SuggestOK, error) @@ -197,6 +199,44 @@ func (a *Client) FromHardware(params *FromHardwareParams, authInfo runtime.Clien return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +ListSizeReservations gets all size reservations +*/ +func (a *Client) ListSizeReservations(params *ListSizeReservationsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListSizeReservationsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListSizeReservationsParams() + } + op := &runtime.ClientOperation{ + ID: "listSizeReservations", + Method: "GET", + PathPattern: "/v1/size/reservations", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &ListSizeReservationsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListSizeReservationsOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListSizeReservationsDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* ListSizes gets all sizes */ diff --git a/api/models/v1_size_reservation_response.go b/api/models/v1_size_reservation_response.go new file mode 100644 index 0000000..c7795bf --- /dev/null +++ b/api/models/v1_size_reservation_response.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// V1SizeReservationResponse v1 size reservation response +// +// swagger:model v1.SizeReservationResponse +type V1SizeReservationResponse struct { + + // the partition id of this size reservation + // Required: true + Partitionid *string `json:"partitionid" yaml:"partitionid"` + + // the amount of allocations of this project referenced by this size reservation + // Required: true + Projectallocations *int32 `json:"projectallocations" yaml:"projectallocations"` + + // the project id of this size reservation + // Required: true + Projectid *string `json:"projectid" yaml:"projectid"` + + // the project name of this size reservation + // Required: true + Projectname *string `json:"projectname" yaml:"projectname"` + + // the amount of reservations of this size reservation + // Required: true + Reservations *int32 `json:"reservations" yaml:"reservations"` + + // the size id of this size reservation + // Required: true + Sizeid *string `json:"sizeid" yaml:"sizeid"` + + // the tenant of this size reservation + // Required: true + Tenant *string `json:"tenant" yaml:"tenant"` + + // the used amount of reservations of this size reservation + // Required: true + Usedreservations *int32 `json:"usedreservations" yaml:"usedreservations"` +} + +// Validate validates this v1 size reservation response +func (m *V1SizeReservationResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePartitionid(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProjectallocations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProjectid(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProjectname(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReservations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSizeid(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTenant(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsedreservations(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *V1SizeReservationResponse) validatePartitionid(formats strfmt.Registry) error { + + if err := validate.Required("partitionid", "body", m.Partitionid); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateProjectallocations(formats strfmt.Registry) error { + + if err := validate.Required("projectallocations", "body", m.Projectallocations); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateProjectid(formats strfmt.Registry) error { + + if err := validate.Required("projectid", "body", m.Projectid); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateProjectname(formats strfmt.Registry) error { + + if err := validate.Required("projectname", "body", m.Projectname); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateReservations(formats strfmt.Registry) error { + + if err := validate.Required("reservations", "body", m.Reservations); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateSizeid(formats strfmt.Registry) error { + + if err := validate.Required("sizeid", "body", m.Sizeid); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateTenant(formats strfmt.Registry) error { + + if err := validate.Required("tenant", "body", m.Tenant); err != nil { + return err + } + + return nil +} + +func (m *V1SizeReservationResponse) validateUsedreservations(formats strfmt.Registry) error { + + if err := validate.Required("usedreservations", "body", m.Usedreservations); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this v1 size reservation response based on context it is used +func (m *V1SizeReservationResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *V1SizeReservationResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *V1SizeReservationResponse) UnmarshalBinary(b []byte) error { + var res V1SizeReservationResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/metal-api.json b/metal-api.json index e1dec32..9b4f4a9 100644 --- a/metal-api.json +++ b/metal-api.json @@ -4528,6 +4528,55 @@ "projectid" ] }, + "v1.SizeReservationResponse": { + "properties": { + "partitionid": { + "description": "the partition id of this size reservation", + "type": "string" + }, + "projectallocations": { + "description": "the amount of allocations of this project referenced by this size reservation", + "format": "int32", + "type": "integer" + }, + "projectid": { + "description": "the project id of this size reservation", + "type": "string" + }, + "projectname": { + "description": "the project name of this size reservation", + "type": "string" + }, + "reservations": { + "description": "the amount of reservations of this size reservation", + "format": "int32", + "type": "integer" + }, + "sizeid": { + "description": "the size id of this size reservation", + "type": "string" + }, + "tenant": { + "description": "the tenant of this size reservation", + "type": "string" + }, + "usedreservations": { + "description": "the used amount of reservations of this size reservation", + "format": "int32", + "type": "integer" + } + }, + "required": [ + "partitionid", + "projectallocations", + "projectid", + "projectname", + "reservations", + "sizeid", + "tenant", + "usedreservations" + ] + }, "v1.SizeResponse": { "properties": { "changed": { @@ -8885,6 +8934,38 @@ ] } }, + "/v1/size/reservations": { + "get": { + "consumes": [ + "application/json" + ], + "operationId": "listSizeReservations", + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "items": { + "$ref": "#/definitions/v1.SizeReservationResponse" + }, + "type": "array" + } + }, + "default": { + "description": "Error", + "schema": { + "$ref": "#/definitions/httperrors.HTTPErrorResponse" + } + } + }, + "summary": "get all size reservations", + "tags": [ + "size" + ] + } + }, "/v1/size/suggest": { "post": { "consumes": [