From b501137e8681f6ee8f29bbeadf7558011c585543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Wed, 11 Dec 2024 11:55:54 +0100 Subject: [PATCH] chore(swagger): scylla, add /task_manager/user_ttl endpoint This endpoint was introduced in: https://github.com/scylladb/scylladb/pull/21505 In order to separate TTL values for internal and user Scylla tasks. --- .../v1/client/operations/operations_client.go | 74 +++++++++ .../task_manager_ttl_post_parameters.go | 2 +- .../task_manager_user_ttl_get_parameters.go | 113 ++++++++++++++ .../task_manager_user_ttl_get_responses.go | 114 ++++++++++++++ .../task_manager_user_ttl_post_parameters.go | 141 ++++++++++++++++++ .../task_manager_user_ttl_post_responses.go | 114 ++++++++++++++ v3/swagger/scylla_v1.json | 62 +++++++- 7 files changed, 618 insertions(+), 2 deletions(-) create mode 100644 v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_parameters.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_responses.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_post_parameters.go create mode 100644 v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_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 cea2dd1b8..bf0593584 100644 --- a/v3/swagger/gen/scylla/v1/client/operations/operations_client.go +++ b/v3/swagger/gen/scylla/v1/client/operations/operations_client.go @@ -841,6 +841,10 @@ type ClientService interface { TaskManagerTTLPost(params *TaskManagerTTLPostParams) (*TaskManagerTTLPostOK, error) + TaskManagerUserTTLGet(params *TaskManagerUserTTLGetParams) (*TaskManagerUserTTLGetOK, error) + + TaskManagerUserTTLPost(params *TaskManagerUserTTLPostParams) (*TaskManagerUserTTLPostOK, error) + TaskManagerWaitTaskTaskIDGet(params *TaskManagerWaitTaskTaskIDGetParams) (*TaskManagerWaitTaskTaskIDGetOK, error) SetTransport(transport runtime.ClientTransport) @@ -15116,6 +15120,76 @@ func (a *Client) TaskManagerTTLPost(params *TaskManagerTTLPostParams) (*TaskMana return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +TaskManagerUserTTLGet gets user ttl + +Get current user task ttl value +*/ +func (a *Client) TaskManagerUserTTLGet(params *TaskManagerUserTTLGetParams) (*TaskManagerUserTTLGetOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewTaskManagerUserTTLGetParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "TaskManagerUserTtlGet", + Method: "GET", + PathPattern: "/task_manager/user_ttl", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &TaskManagerUserTTLGetReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*TaskManagerUserTTLGetOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*TaskManagerUserTTLGetDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +TaskManagerUserTTLPost gets and update user ttl + +Set user task ttl in seconds and get last value +*/ +func (a *Client) TaskManagerUserTTLPost(params *TaskManagerUserTTLPostParams) (*TaskManagerUserTTLPostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewTaskManagerUserTTLPostParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "TaskManagerUserTtlPost", + Method: "POST", + PathPattern: "/task_manager/user_ttl", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &TaskManagerUserTTLPostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*TaskManagerUserTTLPostOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*TaskManagerUserTTLPostDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* TaskManagerWaitTaskTaskIDGet waits task diff --git a/v3/swagger/gen/scylla/v1/client/operations/task_manager_ttl_post_parameters.go b/v3/swagger/gen/scylla/v1/client/operations/task_manager_ttl_post_parameters.go index fa6b2326a..1cc0c2323 100644 --- a/v3/swagger/gen/scylla/v1/client/operations/task_manager_ttl_post_parameters.go +++ b/v3/swagger/gen/scylla/v1/client/operations/task_manager_ttl_post_parameters.go @@ -63,7 +63,7 @@ for the task manager Ttl post operation typically these are written to a http.Re type TaskManagerTTLPostParams struct { /*TTL - The number of seconds for which the tasks will be kept in memory after it finishes + The number of seconds for which the task started internally will be kept in memory after it finishes */ TTL int64 diff --git a/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_parameters.go b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_parameters.go new file mode 100644 index 000000000..e7cee5769 --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_parameters.go @@ -0,0 +1,113 @@ +// 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" +) + +// NewTaskManagerUserTTLGetParams creates a new TaskManagerUserTTLGetParams object +// with the default values initialized. +func NewTaskManagerUserTTLGetParams() *TaskManagerUserTTLGetParams { + + return &TaskManagerUserTTLGetParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewTaskManagerUserTTLGetParamsWithTimeout creates a new TaskManagerUserTTLGetParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewTaskManagerUserTTLGetParamsWithTimeout(timeout time.Duration) *TaskManagerUserTTLGetParams { + + return &TaskManagerUserTTLGetParams{ + + timeout: timeout, + } +} + +// NewTaskManagerUserTTLGetParamsWithContext creates a new TaskManagerUserTTLGetParams object +// with the default values initialized, and the ability to set a context for a request +func NewTaskManagerUserTTLGetParamsWithContext(ctx context.Context) *TaskManagerUserTTLGetParams { + + return &TaskManagerUserTTLGetParams{ + + Context: ctx, + } +} + +// NewTaskManagerUserTTLGetParamsWithHTTPClient creates a new TaskManagerUserTTLGetParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewTaskManagerUserTTLGetParamsWithHTTPClient(client *http.Client) *TaskManagerUserTTLGetParams { + + return &TaskManagerUserTTLGetParams{ + HTTPClient: client, + } +} + +/* +TaskManagerUserTTLGetParams contains all the parameters to send to the API endpoint +for the task manager user Ttl get operation typically these are written to a http.Request +*/ +type TaskManagerUserTTLGetParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the task manager user Ttl get params +func (o *TaskManagerUserTTLGetParams) WithTimeout(timeout time.Duration) *TaskManagerUserTTLGetParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the task manager user Ttl get params +func (o *TaskManagerUserTTLGetParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the task manager user Ttl get params +func (o *TaskManagerUserTTLGetParams) WithContext(ctx context.Context) *TaskManagerUserTTLGetParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the task manager user Ttl get params +func (o *TaskManagerUserTTLGetParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the task manager user Ttl get params +func (o *TaskManagerUserTTLGetParams) WithHTTPClient(client *http.Client) *TaskManagerUserTTLGetParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the task manager user Ttl get params +func (o *TaskManagerUserTTLGetParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *TaskManagerUserTTLGetParams) 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/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_responses.go b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_responses.go new file mode 100644 index 000000000..0a18a610a --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_get_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" +) + +// TaskManagerUserTTLGetReader is a Reader for the TaskManagerUserTTLGet structure. +type TaskManagerUserTTLGetReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *TaskManagerUserTTLGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewTaskManagerUserTTLGetOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewTaskManagerUserTTLGetDefault(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 + } +} + +// NewTaskManagerUserTTLGetOK creates a TaskManagerUserTTLGetOK with default headers values +func NewTaskManagerUserTTLGetOK() *TaskManagerUserTTLGetOK { + return &TaskManagerUserTTLGetOK{} +} + +/* +TaskManagerUserTTLGetOK handles this case with default header values. + +Success +*/ +type TaskManagerUserTTLGetOK struct { + Payload int64 +} + +func (o *TaskManagerUserTTLGetOK) GetPayload() int64 { + return o.Payload +} + +func (o *TaskManagerUserTTLGetOK) 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 +} + +// NewTaskManagerUserTTLGetDefault creates a TaskManagerUserTTLGetDefault with default headers values +func NewTaskManagerUserTTLGetDefault(code int) *TaskManagerUserTTLGetDefault { + return &TaskManagerUserTTLGetDefault{ + _statusCode: code, + } +} + +/* +TaskManagerUserTTLGetDefault handles this case with default header values. + +internal server error +*/ +type TaskManagerUserTTLGetDefault struct { + _statusCode int + + Payload *models.ErrorModel +} + +// Code gets the status code for the task manager user Ttl get default response +func (o *TaskManagerUserTTLGetDefault) Code() int { + return o._statusCode +} + +func (o *TaskManagerUserTTLGetDefault) GetPayload() *models.ErrorModel { + return o.Payload +} + +func (o *TaskManagerUserTTLGetDefault) 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 *TaskManagerUserTTLGetDefault) 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/task_manager_user_ttl_post_parameters.go b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_post_parameters.go new file mode 100644 index 000000000..bb1fe813b --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_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" +) + +// NewTaskManagerUserTTLPostParams creates a new TaskManagerUserTTLPostParams object +// with the default values initialized. +func NewTaskManagerUserTTLPostParams() *TaskManagerUserTTLPostParams { + var () + return &TaskManagerUserTTLPostParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewTaskManagerUserTTLPostParamsWithTimeout creates a new TaskManagerUserTTLPostParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewTaskManagerUserTTLPostParamsWithTimeout(timeout time.Duration) *TaskManagerUserTTLPostParams { + var () + return &TaskManagerUserTTLPostParams{ + + timeout: timeout, + } +} + +// NewTaskManagerUserTTLPostParamsWithContext creates a new TaskManagerUserTTLPostParams object +// with the default values initialized, and the ability to set a context for a request +func NewTaskManagerUserTTLPostParamsWithContext(ctx context.Context) *TaskManagerUserTTLPostParams { + var () + return &TaskManagerUserTTLPostParams{ + + Context: ctx, + } +} + +// NewTaskManagerUserTTLPostParamsWithHTTPClient creates a new TaskManagerUserTTLPostParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewTaskManagerUserTTLPostParamsWithHTTPClient(client *http.Client) *TaskManagerUserTTLPostParams { + var () + return &TaskManagerUserTTLPostParams{ + HTTPClient: client, + } +} + +/* +TaskManagerUserTTLPostParams contains all the parameters to send to the API endpoint +for the task manager user Ttl post operation typically these are written to a http.Request +*/ +type TaskManagerUserTTLPostParams struct { + + /*UserTTL + The number of seconds for which the task started by user will be kept in memory after it finishes + + */ + UserTTL int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) WithTimeout(timeout time.Duration) *TaskManagerUserTTLPostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) WithContext(ctx context.Context) *TaskManagerUserTTLPostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) WithHTTPClient(client *http.Client) *TaskManagerUserTTLPostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithUserTTL adds the userTTL to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) WithUserTTL(userTTL int64) *TaskManagerUserTTLPostParams { + o.SetUserTTL(userTTL) + return o +} + +// SetUserTTL adds the userTtl to the task manager user Ttl post params +func (o *TaskManagerUserTTLPostParams) SetUserTTL(userTTL int64) { + o.UserTTL = userTTL +} + +// WriteToRequest writes these params to a swagger request +func (o *TaskManagerUserTTLPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param user_ttl + qrUserTTL := o.UserTTL + qUserTTL := swag.FormatInt64(qrUserTTL) + if qUserTTL != "" { + if err := r.SetQueryParam("user_ttl", qUserTTL); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_post_responses.go b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_post_responses.go new file mode 100644 index 000000000..3b902ad8d --- /dev/null +++ b/v3/swagger/gen/scylla/v1/client/operations/task_manager_user_ttl_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" +) + +// TaskManagerUserTTLPostReader is a Reader for the TaskManagerUserTTLPost structure. +type TaskManagerUserTTLPostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *TaskManagerUserTTLPostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewTaskManagerUserTTLPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewTaskManagerUserTTLPostDefault(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 + } +} + +// NewTaskManagerUserTTLPostOK creates a TaskManagerUserTTLPostOK with default headers values +func NewTaskManagerUserTTLPostOK() *TaskManagerUserTTLPostOK { + return &TaskManagerUserTTLPostOK{} +} + +/* +TaskManagerUserTTLPostOK handles this case with default header values. + +Success +*/ +type TaskManagerUserTTLPostOK struct { + Payload int64 +} + +func (o *TaskManagerUserTTLPostOK) GetPayload() int64 { + return o.Payload +} + +func (o *TaskManagerUserTTLPostOK) 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 +} + +// NewTaskManagerUserTTLPostDefault creates a TaskManagerUserTTLPostDefault with default headers values +func NewTaskManagerUserTTLPostDefault(code int) *TaskManagerUserTTLPostDefault { + return &TaskManagerUserTTLPostDefault{ + _statusCode: code, + } +} + +/* +TaskManagerUserTTLPostDefault handles this case with default header values. + +internal server error +*/ +type TaskManagerUserTTLPostDefault struct { + _statusCode int + + Payload *models.ErrorModel +} + +// Code gets the status code for the task manager user Ttl post default response +func (o *TaskManagerUserTTLPostDefault) Code() int { + return o._statusCode +} + +func (o *TaskManagerUserTTLPostDefault) GetPayload() *models.ErrorModel { + return o.Payload +} + +func (o *TaskManagerUserTTLPostDefault) 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 *TaskManagerUserTTLPostDefault) 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 c097326b0..f97a966fd 100644 --- a/v3/swagger/scylla_v1.json +++ b/v3/swagger/scylla_v1.json @@ -12934,7 +12934,67 @@ "required": true, "type": "integer", "format": "int64", - "description": "The number of seconds for which the tasks will be kept in memory after it finishes" + "description": "The number of seconds for which the task started internally will be kept in memory after it finishes" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "integer", + "format": "int64" + } + }, + "default": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + } + } + }, + "/task_manager/user_ttl": { + "get": { + "description": "Get current user task ttl value", + "summary": "get_user_ttl", + "operationId": "TaskManagerUserTtlGet", + "deprecated": false, + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "integer", + "format": "int64" + } + }, + "default": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/ErrorModel" + } + } + } + }, + "post": { + "description":"Set user task ttl in seconds and get last value", + "summary":"get_and_update_user_ttl", + "operationId": "TaskManagerUserTtlPost", + "deprecated": false, + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "user_ttl", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "description": "The number of seconds for which the task started by user will be kept in memory after it finishes" } ], "responses": {