From 346edaa4c88cb1064faecca55ca64ac7e311c1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Wed, 20 Mar 2024 13:09:13 +0100 Subject: [PATCH] feat(swagger): scylla_v1, add /storage_service/tablets/balancing endpoint --- .../v1/client/operations/operations_client.go | 37 +++++ ...rvice_tablets_balancing_post_parameters.go | 141 ++++++++++++++++++ ...ervice_tablets_balancing_post_responses.go | 104 +++++++++++++ swagger/scylla_v1.json | 33 ++++ 4 files changed, 315 insertions(+) create mode 100644 swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_parameters.go create mode 100644 swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_responses.go diff --git a/swagger/gen/scylla/v1/client/operations/operations_client.go b/swagger/gen/scylla/v1/client/operations/operations_client.go index 08e45b6337..0e9a09324d 100644 --- a/swagger/gen/scylla/v1/client/operations/operations_client.go +++ b/swagger/gen/scylla/v1/client/operations/operations_client.go @@ -775,6 +775,8 @@ type ClientService interface { StorageServiceStreamThroughputPost(params *StorageServiceStreamThroughputPostParams) (*StorageServiceStreamThroughputPostOK, error) + StorageServiceTabletsBalancingPost(params *StorageServiceTabletsBalancingPostParams) (*StorageServiceTabletsBalancingPostOK, error) + StorageServiceTokensByEndpointGet(params *StorageServiceTokensByEndpointGetParams) (*StorageServiceTokensByEndpointGetOK, error) StorageServiceTokensEndpointGet(params *StorageServiceTokensEndpointGetParams) (*StorageServiceTokensEndpointGetOK, error) @@ -13941,6 +13943,41 @@ func (a *Client) StorageServiceStreamThroughputPost(params *StorageServiceStream return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +StorageServiceTabletsBalancingPost tablets balancing enable + +Controls tablet load-balancing +*/ +func (a *Client) StorageServiceTabletsBalancingPost(params *StorageServiceTabletsBalancingPostParams) (*StorageServiceTabletsBalancingPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewStorageServiceTabletsBalancingPostParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "StorageServiceTabletsBalancingPost", + Method: "POST", + PathPattern: "/storage_service/tablets/balancing", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &StorageServiceTabletsBalancingPostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*StorageServiceTabletsBalancingPostOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*StorageServiceTabletsBalancingPostDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* StorageServiceTokensByEndpointGet gets node tokens diff --git a/swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_parameters.go b/swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_parameters.go new file mode 100644 index 0000000000..6e2e1948e0 --- /dev/null +++ b/swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_parameters.go @@ -0,0 +1,141 @@ +// 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" + "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" + "github.com/go-openapi/swag" +) + +// NewStorageServiceTabletsBalancingPostParams creates a new StorageServiceTabletsBalancingPostParams object +// with the default values initialized. +func NewStorageServiceTabletsBalancingPostParams() *StorageServiceTabletsBalancingPostParams { + var () + return &StorageServiceTabletsBalancingPostParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewStorageServiceTabletsBalancingPostParamsWithTimeout creates a new StorageServiceTabletsBalancingPostParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewStorageServiceTabletsBalancingPostParamsWithTimeout(timeout time.Duration) *StorageServiceTabletsBalancingPostParams { + var () + return &StorageServiceTabletsBalancingPostParams{ + + timeout: timeout, + } +} + +// NewStorageServiceTabletsBalancingPostParamsWithContext creates a new StorageServiceTabletsBalancingPostParams object +// with the default values initialized, and the ability to set a context for a request +func NewStorageServiceTabletsBalancingPostParamsWithContext(ctx context.Context) *StorageServiceTabletsBalancingPostParams { + var () + return &StorageServiceTabletsBalancingPostParams{ + + Context: ctx, + } +} + +// NewStorageServiceTabletsBalancingPostParamsWithHTTPClient creates a new StorageServiceTabletsBalancingPostParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewStorageServiceTabletsBalancingPostParamsWithHTTPClient(client *http.Client) *StorageServiceTabletsBalancingPostParams { + var () + return &StorageServiceTabletsBalancingPostParams{ + HTTPClient: client, + } +} + +/* +StorageServiceTabletsBalancingPostParams contains all the parameters to send to the API endpoint +for the storage service tablets balancing post operation typically these are written to a http.Request +*/ +type StorageServiceTabletsBalancingPostParams struct { + + /*Enabled + When set to false, tablet load balancing is disabled + + */ + Enabled bool + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) WithTimeout(timeout time.Duration) *StorageServiceTabletsBalancingPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) WithContext(ctx context.Context) *StorageServiceTabletsBalancingPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) WithHTTPClient(client *http.Client) *StorageServiceTabletsBalancingPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnabled adds the enabled to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) WithEnabled(enabled bool) *StorageServiceTabletsBalancingPostParams { + o.SetEnabled(enabled) + return o +} + +// SetEnabled adds the enabled to the storage service tablets balancing post params +func (o *StorageServiceTabletsBalancingPostParams) SetEnabled(enabled bool) { + o.Enabled = enabled +} + +// WriteToRequest writes these params to a swagger request +func (o *StorageServiceTabletsBalancingPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param enabled + qrEnabled := o.Enabled + qEnabled := swag.FormatBool(qrEnabled) + if qEnabled != "" { + if err := r.SetQueryParam("enabled", qEnabled); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_responses.go b/swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_responses.go new file mode 100644 index 0000000000..0426d4b6c6 --- /dev/null +++ b/swagger/gen/scylla/v1/client/operations/storage_service_tablets_balancing_post_responses.go @@ -0,0 +1,104 @@ +// 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 ( + "fmt" + "io" + "strings" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/scylladb/scylla-manager/v3/swagger/gen/scylla/v1/models" +) + +// StorageServiceTabletsBalancingPostReader is a Reader for the StorageServiceTabletsBalancingPost structure. +type StorageServiceTabletsBalancingPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StorageServiceTabletsBalancingPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStorageServiceTabletsBalancingPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewStorageServiceTabletsBalancingPostDefault(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 + } +} + +// NewStorageServiceTabletsBalancingPostOK creates a StorageServiceTabletsBalancingPostOK with default headers values +func NewStorageServiceTabletsBalancingPostOK() *StorageServiceTabletsBalancingPostOK { + return &StorageServiceTabletsBalancingPostOK{} +} + +/* +StorageServiceTabletsBalancingPostOK handles this case with default header values. + +Success +*/ +type StorageServiceTabletsBalancingPostOK struct { +} + +func (o *StorageServiceTabletsBalancingPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewStorageServiceTabletsBalancingPostDefault creates a StorageServiceTabletsBalancingPostDefault with default headers values +func NewStorageServiceTabletsBalancingPostDefault(code int) *StorageServiceTabletsBalancingPostDefault { + return &StorageServiceTabletsBalancingPostDefault{ + _statusCode: code, + } +} + +/* +StorageServiceTabletsBalancingPostDefault handles this case with default header values. + +internal server error +*/ +type StorageServiceTabletsBalancingPostDefault struct { + _statusCode int + + Payload *models.ErrorModel +} + +// Code gets the status code for the storage service tablets balancing post default response +func (o *StorageServiceTabletsBalancingPostDefault) Code() int { + return o._statusCode +} + +func (o *StorageServiceTabletsBalancingPostDefault) GetPayload() *models.ErrorModel { + return o.Payload +} + +func (o *StorageServiceTabletsBalancingPostDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ErrorModel) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +func (o *StorageServiceTabletsBalancingPostDefault) Error() string { + return fmt.Sprintf("agent [HTTP %d] %s", o._statusCode, strings.TrimRight(o.Payload.Message, ".")) +} diff --git a/swagger/scylla_v1.json b/swagger/scylla_v1.json index ccec3709ba..4458e2c92c 100644 --- a/swagger/scylla_v1.json +++ b/swagger/scylla_v1.json @@ -12467,6 +12467,39 @@ "security": [] } }, + "/storage_service/tablets/balancing": { + "post": { + "description": "Controls tablet load-balancing", + "summary": "tablet_balancing_enable", + "operationId": "StorageServiceTabletsBalancingPost", + "deprecated": false, + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "enabled", + "in": "query", + "required": true, + "type": "boolean", + "description": "When set to false, tablet load balancing is disabled" + } + ], + "responses": { + "200": { + "description": "Success", + "headers": {} + }, + "default": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + }, + "security": [] + } + }, "/stream_manager/": { "get": { "description": "Returns the current state of all ongoing streams.",