From e511fb201478f7eceb50874cd6848ae66e9fdb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Tue, 5 Nov 2024 11:48:48 +0100 Subject: [PATCH] feat(swagger): scylla, add backup and restore endpoints They will eventually be used to replace currently used rclone server. Definitions were taken from: https://github.com/scylladb/scylladb/blob/ee92784098689125708f88fa9441ccd8e68b6ae9/api/api-doc/storage_service.json#L758 --- .../v1/client/operations/operations_client.go | 74 +++++ .../storage_service_backup_post_parameters.go | 272 ++++++++++++++++++ .../storage_service_backup_post_responses.go | 114 ++++++++ ...storage_service_restore_post_parameters.go | 262 +++++++++++++++++ .../storage_service_restore_post_responses.go | 114 ++++++++ v3/swagger/scylla_v1.json | 143 +++++++++ 6 files changed, 979 insertions(+) create mode 100644 v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_parameters.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_responses.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_parameters.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_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 e329c35a6..012554805 100644 --- a/v3/swagger/gen/scylla/v1/client/operations/operations_client.go +++ b/v3/swagger/gen/scylla/v1/client/operations/operations_client.go @@ -607,6 +607,8 @@ type ClientService interface { StorageServiceAutoCompactionByKeyspacePost(params *StorageServiceAutoCompactionByKeyspacePostParams) (*StorageServiceAutoCompactionByKeyspacePostOK, error) + StorageServiceBackupPost(params *StorageServiceBackupPostParams) (*StorageServiceBackupPostOK, error) + StorageServiceBatchSizeFailureThresholdGet(params *StorageServiceBatchSizeFailureThresholdGetParams) (*StorageServiceBatchSizeFailureThresholdGetOK, error) StorageServiceBatchSizeFailureThresholdPost(params *StorageServiceBatchSizeFailureThresholdPostParams) (*StorageServiceBatchSizeFailureThresholdPostOK, error) @@ -741,6 +743,8 @@ type ClientService interface { StorageServiceRescheduleFailedDeletionsPost(params *StorageServiceRescheduleFailedDeletionsPostParams) (*StorageServiceRescheduleFailedDeletionsPostOK, error) + StorageServiceRestorePost(params *StorageServiceRestorePostParams) (*StorageServiceRestorePostOK, error) + StorageServiceRPCServerDelete(params *StorageServiceRPCServerDeleteParams) (*StorageServiceRPCServerDeleteOK, error) StorageServiceRPCServerGet(params *StorageServiceRPCServerGetParams) (*StorageServiceRPCServerGetOK, error) @@ -11025,6 +11029,41 @@ func (a *Client) StorageServiceAutoCompactionByKeyspacePost(params *StorageServi return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +StorageServiceBackupPost starts backup + +Starts copying SSTables from a specified keyspace to a designated bucket in object storage +*/ +func (a *Client) StorageServiceBackupPost(params *StorageServiceBackupPostParams) (*StorageServiceBackupPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewStorageServiceBackupPostParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "StorageServiceBackupPost", + Method: "POST", + PathPattern: "/storage_service/backup", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &StorageServiceBackupPostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*StorageServiceBackupPostOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*StorageServiceBackupPostDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* StorageServiceBatchSizeFailureThresholdGet gets batch size failure threshold @@ -13364,6 +13403,41 @@ func (a *Client) StorageServiceRescheduleFailedDeletionsPost(params *StorageServ return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +StorageServiceRestorePost starts restore + +Starts copying SSTables from a designated bucket in object storage to a specified keyspace +*/ +func (a *Client) StorageServiceRestorePost(params *StorageServiceRestorePostParams) (*StorageServiceRestorePostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewStorageServiceRestorePostParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "StorageServiceRestorePost", + Method: "POST", + PathPattern: "/storage_service/restore", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &StorageServiceRestorePostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*StorageServiceRestorePostOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*StorageServiceRestorePostDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* StorageServiceRPCServerDelete stops rpc server diff --git a/v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_parameters.go b/v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_parameters.go new file mode 100644 index 000000000..97afbd527 --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_parameters.go @@ -0,0 +1,272 @@ +// 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" +) + +// NewStorageServiceBackupPostParams creates a new StorageServiceBackupPostParams object +// with the default values initialized. +func NewStorageServiceBackupPostParams() *StorageServiceBackupPostParams { + var () + return &StorageServiceBackupPostParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewStorageServiceBackupPostParamsWithTimeout creates a new StorageServiceBackupPostParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewStorageServiceBackupPostParamsWithTimeout(timeout time.Duration) *StorageServiceBackupPostParams { + var () + return &StorageServiceBackupPostParams{ + + timeout: timeout, + } +} + +// NewStorageServiceBackupPostParamsWithContext creates a new StorageServiceBackupPostParams object +// with the default values initialized, and the ability to set a context for a request +func NewStorageServiceBackupPostParamsWithContext(ctx context.Context) *StorageServiceBackupPostParams { + var () + return &StorageServiceBackupPostParams{ + + Context: ctx, + } +} + +// NewStorageServiceBackupPostParamsWithHTTPClient creates a new StorageServiceBackupPostParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewStorageServiceBackupPostParamsWithHTTPClient(client *http.Client) *StorageServiceBackupPostParams { + var () + return &StorageServiceBackupPostParams{ + HTTPClient: client, + } +} + +/* +StorageServiceBackupPostParams contains all the parameters to send to the API endpoint +for the storage service backup post operation typically these are written to a http.Request +*/ +type StorageServiceBackupPostParams struct { + + /*Bucket + Name of the bucket to backup sstables to + + */ + Bucket string + /*Endpoint + ID of the configured object storage endpoint to copy sstables to + + */ + Endpoint string + /*Keyspace + Name of a keyspace to copy sstables from + + */ + Keyspace string + /*Prefix + The prefix of the objects for the backuped sstables + + */ + Prefix string + /*Snapshot + Name of a snapshot to copy sstables from + + */ + Snapshot *string + /*Table + Name of a table to copy sstables from + + */ + Table string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithTimeout(timeout time.Duration) *StorageServiceBackupPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithContext(ctx context.Context) *StorageServiceBackupPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithHTTPClient(client *http.Client) *StorageServiceBackupPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBucket adds the bucket to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithBucket(bucket string) *StorageServiceBackupPostParams { + o.SetBucket(bucket) + return o +} + +// SetBucket adds the bucket to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetBucket(bucket string) { + o.Bucket = bucket +} + +// WithEndpoint adds the endpoint to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithEndpoint(endpoint string) *StorageServiceBackupPostParams { + o.SetEndpoint(endpoint) + return o +} + +// SetEndpoint adds the endpoint to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetEndpoint(endpoint string) { + o.Endpoint = endpoint +} + +// WithKeyspace adds the keyspace to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithKeyspace(keyspace string) *StorageServiceBackupPostParams { + o.SetKeyspace(keyspace) + return o +} + +// SetKeyspace adds the keyspace to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetKeyspace(keyspace string) { + o.Keyspace = keyspace +} + +// WithPrefix adds the prefix to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithPrefix(prefix string) *StorageServiceBackupPostParams { + o.SetPrefix(prefix) + return o +} + +// SetPrefix adds the prefix to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetPrefix(prefix string) { + o.Prefix = prefix +} + +// WithSnapshot adds the snapshot to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithSnapshot(snapshot *string) *StorageServiceBackupPostParams { + o.SetSnapshot(snapshot) + return o +} + +// SetSnapshot adds the snapshot to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetSnapshot(snapshot *string) { + o.Snapshot = snapshot +} + +// WithTable adds the table to the storage service backup post params +func (o *StorageServiceBackupPostParams) WithTable(table string) *StorageServiceBackupPostParams { + o.SetTable(table) + return o +} + +// SetTable adds the table to the storage service backup post params +func (o *StorageServiceBackupPostParams) SetTable(table string) { + o.Table = table +} + +// WriteToRequest writes these params to a swagger request +func (o *StorageServiceBackupPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param bucket + qrBucket := o.Bucket + qBucket := qrBucket + if qBucket != "" { + if err := r.SetQueryParam("bucket", qBucket); err != nil { + return err + } + } + + // query param endpoint + qrEndpoint := o.Endpoint + qEndpoint := qrEndpoint + if qEndpoint != "" { + if err := r.SetQueryParam("endpoint", qEndpoint); err != nil { + return err + } + } + + // query param keyspace + qrKeyspace := o.Keyspace + qKeyspace := qrKeyspace + if qKeyspace != "" { + if err := r.SetQueryParam("keyspace", qKeyspace); err != nil { + return err + } + } + + // query param prefix + qrPrefix := o.Prefix + qPrefix := qrPrefix + if qPrefix != "" { + if err := r.SetQueryParam("prefix", qPrefix); err != nil { + return err + } + } + + if o.Snapshot != nil { + + // query param snapshot + var qrSnapshot string + if o.Snapshot != nil { + qrSnapshot = *o.Snapshot + } + qSnapshot := qrSnapshot + if qSnapshot != "" { + if err := r.SetQueryParam("snapshot", qSnapshot); err != nil { + return err + } + } + + } + + // query param table + qrTable := o.Table + qTable := qrTable + if qTable != "" { + if err := r.SetQueryParam("table", qTable); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_responses.go b/v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_responses.go new file mode 100644 index 000000000..4b82870cf --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/storage_service_backup_post_responses.go @@ -0,0 +1,114 @@ +// 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" +) + +// StorageServiceBackupPostReader is a Reader for the StorageServiceBackupPost structure. +type StorageServiceBackupPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StorageServiceBackupPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStorageServiceBackupPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewStorageServiceBackupPostDefault(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 + } +} + +// NewStorageServiceBackupPostOK creates a StorageServiceBackupPostOK with default headers values +func NewStorageServiceBackupPostOK() *StorageServiceBackupPostOK { + return &StorageServiceBackupPostOK{} +} + +/* +StorageServiceBackupPostOK handles this case with default header values. + +Task ID that can be used with Task Manager service +*/ +type StorageServiceBackupPostOK struct { + Payload string +} + +func (o *StorageServiceBackupPostOK) GetPayload() string { + return o.Payload +} + +func (o *StorageServiceBackupPostOK) 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 +} + +// NewStorageServiceBackupPostDefault creates a StorageServiceBackupPostDefault with default headers values +func NewStorageServiceBackupPostDefault(code int) *StorageServiceBackupPostDefault { + return &StorageServiceBackupPostDefault{ + _statusCode: code, + } +} + +/* +StorageServiceBackupPostDefault handles this case with default header values. + +internal server error +*/ +type StorageServiceBackupPostDefault struct { + _statusCode int + + Payload *models.ErrorModel +} + +// Code gets the status code for the storage service backup post default response +func (o *StorageServiceBackupPostDefault) Code() int { + return o._statusCode +} + +func (o *StorageServiceBackupPostDefault) GetPayload() *models.ErrorModel { + return o.Payload +} + +func (o *StorageServiceBackupPostDefault) 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 *StorageServiceBackupPostDefault) Error() string { + return fmt.Sprintf("agent [HTTP %d] %s", o._statusCode, strings.TrimRight(o.Payload.Message, ".")) +} diff --git a/v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_parameters.go b/v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_parameters.go new file mode 100644 index 000000000..9f82be72e --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_parameters.go @@ -0,0 +1,262 @@ +// 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" +) + +// NewStorageServiceRestorePostParams creates a new StorageServiceRestorePostParams object +// with the default values initialized. +func NewStorageServiceRestorePostParams() *StorageServiceRestorePostParams { + var () + return &StorageServiceRestorePostParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewStorageServiceRestorePostParamsWithTimeout creates a new StorageServiceRestorePostParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewStorageServiceRestorePostParamsWithTimeout(timeout time.Duration) *StorageServiceRestorePostParams { + var () + return &StorageServiceRestorePostParams{ + + timeout: timeout, + } +} + +// NewStorageServiceRestorePostParamsWithContext creates a new StorageServiceRestorePostParams object +// with the default values initialized, and the ability to set a context for a request +func NewStorageServiceRestorePostParamsWithContext(ctx context.Context) *StorageServiceRestorePostParams { + var () + return &StorageServiceRestorePostParams{ + + Context: ctx, + } +} + +// NewStorageServiceRestorePostParamsWithHTTPClient creates a new StorageServiceRestorePostParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewStorageServiceRestorePostParamsWithHTTPClient(client *http.Client) *StorageServiceRestorePostParams { + var () + return &StorageServiceRestorePostParams{ + HTTPClient: client, + } +} + +/* +StorageServiceRestorePostParams contains all the parameters to send to the API endpoint +for the storage service restore post operation typically these are written to a http.Request +*/ +type StorageServiceRestorePostParams struct { + + /*Bucket + Name of the bucket to read SSTables from + + */ + Bucket string + /*Endpoint + ID of the configured object storage endpoint to copy SSTables from + + */ + Endpoint string + /*Keyspace + Name of a keyspace to copy SSTables to + + */ + Keyspace string + /*Prefix + The prefix of the object keys for the backuped SSTables + + */ + Prefix string + /*Sstables + The list of the object keys of the TOC component of the SSTables to be restored + + */ + Sstables []string + /*Table + Name of a table to copy SSTables to + + */ + Table string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithTimeout(timeout time.Duration) *StorageServiceRestorePostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithContext(ctx context.Context) *StorageServiceRestorePostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithHTTPClient(client *http.Client) *StorageServiceRestorePostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBucket adds the bucket to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithBucket(bucket string) *StorageServiceRestorePostParams { + o.SetBucket(bucket) + return o +} + +// SetBucket adds the bucket to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetBucket(bucket string) { + o.Bucket = bucket +} + +// WithEndpoint adds the endpoint to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithEndpoint(endpoint string) *StorageServiceRestorePostParams { + o.SetEndpoint(endpoint) + return o +} + +// SetEndpoint adds the endpoint to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetEndpoint(endpoint string) { + o.Endpoint = endpoint +} + +// WithKeyspace adds the keyspace to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithKeyspace(keyspace string) *StorageServiceRestorePostParams { + o.SetKeyspace(keyspace) + return o +} + +// SetKeyspace adds the keyspace to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetKeyspace(keyspace string) { + o.Keyspace = keyspace +} + +// WithPrefix adds the prefix to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithPrefix(prefix string) *StorageServiceRestorePostParams { + o.SetPrefix(prefix) + return o +} + +// SetPrefix adds the prefix to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetPrefix(prefix string) { + o.Prefix = prefix +} + +// WithSstables adds the sstables to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithSstables(sstables []string) *StorageServiceRestorePostParams { + o.SetSstables(sstables) + return o +} + +// SetSstables adds the sstables to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetSstables(sstables []string) { + o.Sstables = sstables +} + +// WithTable adds the table to the storage service restore post params +func (o *StorageServiceRestorePostParams) WithTable(table string) *StorageServiceRestorePostParams { + o.SetTable(table) + return o +} + +// SetTable adds the table to the storage service restore post params +func (o *StorageServiceRestorePostParams) SetTable(table string) { + o.Table = table +} + +// WriteToRequest writes these params to a swagger request +func (o *StorageServiceRestorePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param bucket + qrBucket := o.Bucket + qBucket := qrBucket + if qBucket != "" { + if err := r.SetQueryParam("bucket", qBucket); err != nil { + return err + } + } + + // query param endpoint + qrEndpoint := o.Endpoint + qEndpoint := qrEndpoint + if qEndpoint != "" { + if err := r.SetQueryParam("endpoint", qEndpoint); err != nil { + return err + } + } + + // query param keyspace + qrKeyspace := o.Keyspace + qKeyspace := qrKeyspace + if qKeyspace != "" { + if err := r.SetQueryParam("keyspace", qKeyspace); err != nil { + return err + } + } + + // query param prefix + qrPrefix := o.Prefix + qPrefix := qrPrefix + if qPrefix != "" { + if err := r.SetQueryParam("prefix", qPrefix); err != nil { + return err + } + } + + if o.Sstables != nil { + if err := r.SetBodyParam(o.Sstables); err != nil { + return err + } + } + + // query param table + qrTable := o.Table + qTable := qrTable + if qTable != "" { + if err := r.SetQueryParam("table", qTable); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_responses.go b/v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_responses.go new file mode 100644 index 000000000..10edb2f60 --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/storage_service_restore_post_responses.go @@ -0,0 +1,114 @@ +// 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" +) + +// StorageServiceRestorePostReader is a Reader for the StorageServiceRestorePost structure. +type StorageServiceRestorePostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StorageServiceRestorePostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStorageServiceRestorePostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewStorageServiceRestorePostDefault(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 + } +} + +// NewStorageServiceRestorePostOK creates a StorageServiceRestorePostOK with default headers values +func NewStorageServiceRestorePostOK() *StorageServiceRestorePostOK { + return &StorageServiceRestorePostOK{} +} + +/* +StorageServiceRestorePostOK handles this case with default header values. + +Task ID that can be used with Task Manager service +*/ +type StorageServiceRestorePostOK struct { + Payload string +} + +func (o *StorageServiceRestorePostOK) GetPayload() string { + return o.Payload +} + +func (o *StorageServiceRestorePostOK) 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 +} + +// NewStorageServiceRestorePostDefault creates a StorageServiceRestorePostDefault with default headers values +func NewStorageServiceRestorePostDefault(code int) *StorageServiceRestorePostDefault { + return &StorageServiceRestorePostDefault{ + _statusCode: code, + } +} + +/* +StorageServiceRestorePostDefault handles this case with default header values. + +internal server error +*/ +type StorageServiceRestorePostDefault struct { + _statusCode int + + Payload *models.ErrorModel +} + +// Code gets the status code for the storage service restore post default response +func (o *StorageServiceRestorePostDefault) Code() int { + return o._statusCode +} + +func (o *StorageServiceRestorePostDefault) GetPayload() *models.ErrorModel { + return o.Payload +} + +func (o *StorageServiceRestorePostDefault) 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 *StorageServiceRestorePostDefault) 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 73e40cfb2..27cd5aaf2 100644 --- a/v3/swagger/scylla_v1.json +++ b/v3/swagger/scylla_v1.json @@ -10037,6 +10037,149 @@ "security": [] } }, + "/storage_service/backup": { + "post": { + "description": "Starts copying SSTables from a specified keyspace to a designated bucket in object storage", + "summary": "start_backup", + "operationId": "StorageServiceBackupPost", + "deprecated": false, + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "endpoint", + "in": "query", + "type": "string", + "required": true, + "description": "ID of the configured object storage endpoint to copy sstables to" + }, + { + "name": "bucket", + "in": "query", + "required": true, + "type": "string", + "description": "Name of the bucket to backup sstables to" + }, + { + "name": "prefix", + "in": "query", + "required": true, + "type": "string", + "description": "The prefix of the objects for the backuped sstables" + }, + { + "name": "keyspace", + "in": "query", + "required": true, + "type": "string", + "description": "Name of a keyspace to copy sstables from" + }, + { + "name": "table", + "in": "query", + "required": true, + "type": "string", + "description": "Name of a table to copy sstables from" + }, + { + "name": "snapshot", + "in": "query", + "required": false, + "type": "string", + "description": "Name of a snapshot to copy sstables from" + } + ], + "responses": { + "200": { + "description": "Task ID that can be used with Task Manager service", + "schema": { + "type": "string" + } + }, + "default": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + } + } + }, + "/storage_service/restore": { + "post": { + "description": "Starts copying SSTables from a designated bucket in object storage to a specified keyspace", + "summary": "start_restore", + "operationId": "StorageServiceRestorePost", + "deprecated": false, + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "endpoint", + "in": "query", + "required": true, + "type": "string", + "description": "ID of the configured object storage endpoint to copy SSTables from" + }, + { + "name": "bucket", + "in": "query", + "required": true, + "type": "string", + "description": "Name of the bucket to read SSTables from" + }, + { + "name": "prefix", + "in": "query", + "required": true, + "type": "string", + "description": "The prefix of the object keys for the backuped SSTables" + }, + { + "name": "sstables", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "description": "The list of the object keys of the TOC component of the SSTables to be restored" + }, + { + "name": "keyspace", + "in": "query", + "required": true, + "type": "string", + "description": "Name of a keyspace to copy SSTables to" + }, + { + "name": "table", + "in": "query", + "required": true, + "type": "string", + "description": "Name of a table to copy SSTables to" + } + ], + "responses": { + "200": { + "description": "Task ID that can be used with Task Manager service", + "schema": { + "type": "string" + } + }, + "default": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + } + } + }, "/storage_service/keyspace_compaction/{keyspace}": { "post": { "description": "Forces major compaction of a single keyspace",