From 0e1ca7082e937e1b4fca27cd97d95b4471ce9063 Mon Sep 17 00:00:00 2001 From: Vasil Averyanau Date: Fri, 8 Nov 2024 17:06:08 +0100 Subject: [PATCH] feat(swagger): scylla, add read barier endpoint This adds scylla read barier api [endpoint](https://github.com/scylladb/scylladb/blob/6efde20939d072406b6e80a7ece1026134b0268a/api/api-doc/raft.json#L66-L97) which will be used in a backup process. --- .../v1/client/operations/operations_client.go | 37 ++++ .../raft_read_barrier_post_parameters.go | 180 ++++++++++++++++++ .../raft_read_barrier_post_responses.go | 104 ++++++++++ v3/swagger/scylla_v1.json | 41 ++++ 4 files changed, 362 insertions(+) create mode 100644 v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_parameters.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_responses.go diff --git a/v3/swagger/gen/scylla/v1/client/operations/operations_client.go b/v3/swagger/gen/scylla/v1/client/operations/operations_client.go index 0e9a09324d..f3ca6792a7 100644 --- a/v3/swagger/gen/scylla/v1/client/operations/operations_client.go +++ b/v3/swagger/gen/scylla/v1/client/operations/operations_client.go @@ -469,6 +469,8 @@ type ClientService interface { MessagingServiceVersionGet(params *MessagingServiceVersionGetParams) (*MessagingServiceVersionGetOK, error) + RaftReadBarrierPost(params *RaftReadBarrierPostParams) (*RaftReadBarrierPostOK, error) + SnitchDatacenterGet(params *SnitchDatacenterGetParams) (*SnitchDatacenterGetOK, error) SnitchNameGet(params *SnitchNameGetParams) (*SnitchNameGetOK, error) @@ -8594,6 +8596,41 @@ func (a *Client) MessagingServiceVersionGet(params *MessagingServiceVersionGetPa return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +RaftReadBarrierPost reads barrier + +Triggers read barrier for the given Raft group to wait for previously committed commands in this group to be applied locally. For example, can be used on group 0 to wait for the node to obtain latest schema changes. +*/ +func (a *Client) RaftReadBarrierPost(params *RaftReadBarrierPostParams) (*RaftReadBarrierPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewRaftReadBarrierPostParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "RaftReadBarrierPost", + Method: "POST", + PathPattern: "/raft/read_barrier", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &RaftReadBarrierPostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*RaftReadBarrierPostOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*RaftReadBarrierPostDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* SnitchDatacenterGet gets datacenter diff --git a/v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_parameters.go b/v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_parameters.go new file mode 100644 index 0000000000..a6204e93ae --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_parameters.go @@ -0,0 +1,180 @@ +// 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" +) + +// NewRaftReadBarrierPostParams creates a new RaftReadBarrierPostParams object +// with the default values initialized. +func NewRaftReadBarrierPostParams() *RaftReadBarrierPostParams { + var () + return &RaftReadBarrierPostParams{ + + requestTimeout: cr.DefaultTimeout, + } +} + +// NewRaftReadBarrierPostParamsWithTimeout creates a new RaftReadBarrierPostParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewRaftReadBarrierPostParamsWithTimeout(timeout time.Duration) *RaftReadBarrierPostParams { + var () + return &RaftReadBarrierPostParams{ + + requestTimeout: timeout, + } +} + +// NewRaftReadBarrierPostParamsWithContext creates a new RaftReadBarrierPostParams object +// with the default values initialized, and the ability to set a context for a request +func NewRaftReadBarrierPostParamsWithContext(ctx context.Context) *RaftReadBarrierPostParams { + var () + return &RaftReadBarrierPostParams{ + + Context: ctx, + } +} + +// NewRaftReadBarrierPostParamsWithHTTPClient creates a new RaftReadBarrierPostParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewRaftReadBarrierPostParamsWithHTTPClient(client *http.Client) *RaftReadBarrierPostParams { + var () + return &RaftReadBarrierPostParams{ + HTTPClient: client, + } +} + +/* +RaftReadBarrierPostParams contains all the parameters to send to the API endpoint +for the raft read barrier post operation typically these are written to a http.Request +*/ +type RaftReadBarrierPostParams struct { + + /*GroupID + The ID of the group. When absent, group0 is used. + + */ + GroupID *string + /*Timeout + Timeout in seconds after which the endpoint returns a failure. If not provided, 60s is used. + + */ + Timeout *int64 + + requestTimeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithRequestTimeout adds the timeout to the raft read barrier post params +func (o *RaftReadBarrierPostParams) WithRequestTimeout(timeout time.Duration) *RaftReadBarrierPostParams { + o.SetRequestTimeout(timeout) + return o +} + +// SetRequestTimeout adds the timeout to the raft read barrier post params +func (o *RaftReadBarrierPostParams) SetRequestTimeout(timeout time.Duration) { + o.requestTimeout = timeout +} + +// WithContext adds the context to the raft read barrier post params +func (o *RaftReadBarrierPostParams) WithContext(ctx context.Context) *RaftReadBarrierPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the raft read barrier post params +func (o *RaftReadBarrierPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the raft read barrier post params +func (o *RaftReadBarrierPostParams) WithHTTPClient(client *http.Client) *RaftReadBarrierPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the raft read barrier post params +func (o *RaftReadBarrierPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithGroupID adds the groupID to the raft read barrier post params +func (o *RaftReadBarrierPostParams) WithGroupID(groupID *string) *RaftReadBarrierPostParams { + o.SetGroupID(groupID) + return o +} + +// SetGroupID adds the groupId to the raft read barrier post params +func (o *RaftReadBarrierPostParams) SetGroupID(groupID *string) { + o.GroupID = groupID +} + +// WithTimeout adds the timeout to the raft read barrier post params +func (o *RaftReadBarrierPostParams) WithTimeout(timeout *int64) *RaftReadBarrierPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the raft read barrier post params +func (o *RaftReadBarrierPostParams) SetTimeout(timeout *int64) { + o.Timeout = timeout +} + +// WriteToRequest writes these params to a swagger request +func (o *RaftReadBarrierPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.requestTimeout); err != nil { + return err + } + var res []error + + if o.GroupID != nil { + + // query param group_id + var qrGroupID string + if o.GroupID != nil { + qrGroupID = *o.GroupID + } + qGroupID := qrGroupID + if qGroupID != "" { + if err := r.SetQueryParam("group_id", qGroupID); err != nil { + return err + } + } + + } + + if o.Timeout != nil { + + // query param timeout + var qrTimeout int64 + if o.Timeout != nil { + qrTimeout = *o.Timeout + } + qTimeout := swag.FormatInt64(qrTimeout) + if qTimeout != "" { + if err := r.SetQueryParam("timeout", qTimeout); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_responses.go b/v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_post_responses.go new file mode 100644 index 0000000000..3fb1b9e3fb --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/raft_read_barrier_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" +) + +// RaftReadBarrierPostReader is a Reader for the RaftReadBarrierPost structure. +type RaftReadBarrierPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *RaftReadBarrierPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewRaftReadBarrierPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewRaftReadBarrierPostDefault(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 + } +} + +// NewRaftReadBarrierPostOK creates a RaftReadBarrierPostOK with default headers values +func NewRaftReadBarrierPostOK() *RaftReadBarrierPostOK { + return &RaftReadBarrierPostOK{} +} + +/* +RaftReadBarrierPostOK handles this case with default header values. + +Success +*/ +type RaftReadBarrierPostOK struct { +} + +func (o *RaftReadBarrierPostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRaftReadBarrierPostDefault creates a RaftReadBarrierPostDefault with default headers values +func NewRaftReadBarrierPostDefault(code int) *RaftReadBarrierPostDefault { + return &RaftReadBarrierPostDefault{ + _statusCode: code, + } +} + +/* +RaftReadBarrierPostDefault handles this case with default header values. + +internal server error +*/ +type RaftReadBarrierPostDefault struct { + _statusCode int + + Payload *models.ErrorModel +} + +// Code gets the status code for the raft read barrier post default response +func (o *RaftReadBarrierPostDefault) Code() int { + return o._statusCode +} + +func (o *RaftReadBarrierPostDefault) GetPayload() *models.ErrorModel { + return o.Payload +} + +func (o *RaftReadBarrierPostDefault) 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 *RaftReadBarrierPostDefault) Error() string { + return fmt.Sprintf("agent [HTTP %d] %s", o._statusCode, strings.TrimRight(o.Payload.Message, ".")) +} diff --git a/v3/swagger/scylla_v1.json b/v3/swagger/scylla_v1.json index 574e8c2333..741aeb3c20 100644 --- a/v3/swagger/scylla_v1.json +++ b/v3/swagger/scylla_v1.json @@ -12862,6 +12862,47 @@ }, "security": [] } + }, + "/raft/read_barrier": { + "post": { + "description": "Triggers read barrier for the given Raft group to wait for previously committed commands in this group to be applied locally. For example, can be used on group 0 to wait for the node to obtain latest schema changes.", + "summary": "read_barrier", + "operationId": "RaftReadBarrierPost", + "deprecated": false, + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "group_id", + "in": "query", + "required": false, + "type": "string", + "description": "The ID of the group. When absent, group0 is used." + }, + { + "name": "timeout", + "in": "query", + "required": false, + "type": "integer", + "format": "int64", + "description": "Timeout in seconds after which the endpoint returns a failure. If not provided, 60s is used." + } + ], + "responses": { + "200": { + "description": "Success", + "headers": {} + }, + "default": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + }, + "security": [] + } } }, "definitions": {