From 760f07ed9e7e220be93dfb1b4d20cea2f9262609 Mon Sep 17 00:00:00 2001 From: Andrew Depke Date: Wed, 22 Jun 2022 14:08:55 -0600 Subject: [PATCH] feat: invokable scripts (#387) * basic list, create, and invoke working * all commands working * added support for create script body from file and invoke params from file * linter cleanup * update defaults to existing parameters if not provided * updated generated mock files, added mock files for scripts, added basic script create test * added mock script list * cleanup pass, fixed not using params in list call * added update mock test * fixed mock tests requiring go 1.18 * updated openapi, integrated overrides upstream, added new override to fix codegen bug * added nil check * fixed routes --- api/api_invokable_scripts.gen.go | 1081 +++++++++++++++++ api/client.gen.go | 3 + api/contract/cli.yml | 20 + api/contract/openapi | 2 +- .../paths/scripts_scriptID_invoke.yml | 27 + .../schemas/ScriptInvocationParams.yml | 4 + api/model_run.gen.go | 37 + api/model_script.gen.go | 383 ++++++ api/model_script_create_request.gen.go | 195 +++ api/model_script_invocation_params.gen.go | 113 ++ api/model_script_language.gen.go | 86 ++ api/model_script_update_request.gen.go | 186 +++ api/model_scripts.gen.go | 113 ++ clients/script/script.go | 172 +++ clients/script/script_test.go | 202 +++ cmd/influx/main.go | 1 + cmd/influx/scripts.go | 277 +++++ internal/mock/api_backup.gen.go | 28 - internal/mock/api_bucket_schemas.gen.go | 28 - internal/mock/api_buckets.gen.go | 28 - internal/mock/api_delete.gen.go | 28 - internal/mock/api_health.gen.go | 28 - internal/mock/api_invocable_scripts.gen.go | 305 +++++ internal/mock/api_organizations.gen.go | 28 - internal/mock/api_query.gen.go | 28 - internal/mock/api_secret.gen.go | 28 - internal/mock/api_setup.gen.go | 28 - internal/mock/api_users.gen.go | 28 - internal/mock/api_v1dbrps.gen.go | 28 - internal/mock/api_write.gen.go | 28 - internal/mock/gen.go | 1 + 31 files changed, 3207 insertions(+), 337 deletions(-) create mode 100644 api/api_invokable_scripts.gen.go create mode 100644 api/contract/overrides/paths/scripts_scriptID_invoke.yml create mode 100644 api/contract/overrides/schemas/ScriptInvocationParams.yml create mode 100644 api/model_script.gen.go create mode 100644 api/model_script_create_request.gen.go create mode 100644 api/model_script_invocation_params.gen.go create mode 100644 api/model_script_language.gen.go create mode 100644 api/model_script_update_request.gen.go create mode 100644 api/model_scripts.gen.go create mode 100644 clients/script/script.go create mode 100644 clients/script/script_test.go create mode 100644 cmd/influx/scripts.go create mode 100644 internal/mock/api_invocable_scripts.gen.go diff --git a/api/api_invokable_scripts.gen.go b/api/api_invokable_scripts.gen.go new file mode 100644 index 0000000..42e6731 --- /dev/null +++ b/api/api_invokable_scripts.gen.go @@ -0,0 +1,1081 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + _context "context" + _fmt "fmt" + _io "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +type InvokableScriptsApi interface { + + /* + * DeleteScriptsID Delete a script + * Deletes a script and all associated records. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID The ID of the script to delete. + * @return ApiDeleteScriptsIDRequest + */ + DeleteScriptsID(ctx _context.Context, scriptID string) ApiDeleteScriptsIDRequest + + /* + * DeleteScriptsIDExecute executes the request + */ + DeleteScriptsIDExecute(r ApiDeleteScriptsIDRequest) error + + /* + * DeleteScriptsIDExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not + * available on the returned HTTP response as it will have already been read and closed; access to the response body + * content should be achieved through the returned response model if applicable. + */ + DeleteScriptsIDExecuteWithHttpInfo(r ApiDeleteScriptsIDRequest) (*_nethttp.Response, error) + + /* + * GetScripts List scripts + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiGetScriptsRequest + */ + GetScripts(ctx _context.Context) ApiGetScriptsRequest + + /* + * GetScriptsExecute executes the request + * @return Scripts + */ + GetScriptsExecute(r ApiGetScriptsRequest) (Scripts, error) + + /* + * GetScriptsExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not + * available on the returned HTTP response as it will have already been read and closed; access to the response body + * content should be achieved through the returned response model if applicable. + * @return Scripts + */ + GetScriptsExecuteWithHttpInfo(r ApiGetScriptsRequest) (Scripts, *_nethttp.Response, error) + + /* + * GetScriptsID Retrieve a script + * Uses script ID to retrieve details of an invokable script. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID The script ID. + * @return ApiGetScriptsIDRequest + */ + GetScriptsID(ctx _context.Context, scriptID string) ApiGetScriptsIDRequest + + /* + * GetScriptsIDExecute executes the request + * @return Script + */ + GetScriptsIDExecute(r ApiGetScriptsIDRequest) (Script, error) + + /* + * GetScriptsIDExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not + * available on the returned HTTP response as it will have already been read and closed; access to the response body + * content should be achieved through the returned response model if applicable. + * @return Script + */ + GetScriptsIDExecuteWithHttpInfo(r ApiGetScriptsIDRequest) (Script, *_nethttp.Response, error) + + /* + * PatchScriptsID Update a script + * Updates properties (`name`, `description`, and `script`) of an invokable script. + + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID The script ID. + * @return ApiPatchScriptsIDRequest + */ + PatchScriptsID(ctx _context.Context, scriptID string) ApiPatchScriptsIDRequest + + /* + * PatchScriptsIDExecute executes the request + * @return Script + */ + PatchScriptsIDExecute(r ApiPatchScriptsIDRequest) (Script, error) + + /* + * PatchScriptsIDExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not + * available on the returned HTTP response as it will have already been read and closed; access to the response body + * content should be achieved through the returned response model if applicable. + * @return Script + */ + PatchScriptsIDExecuteWithHttpInfo(r ApiPatchScriptsIDRequest) (Script, *_nethttp.Response, error) + + /* + * PostScripts Create a script + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiPostScriptsRequest + */ + PostScripts(ctx _context.Context) ApiPostScriptsRequest + + /* + * PostScriptsExecute executes the request + * @return Script + */ + PostScriptsExecute(r ApiPostScriptsRequest) (Script, error) + + /* + * PostScriptsExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not + * available on the returned HTTP response as it will have already been read and closed; access to the response body + * content should be achieved through the returned response model if applicable. + * @return Script + */ + PostScriptsExecuteWithHttpInfo(r ApiPostScriptsRequest) (Script, *_nethttp.Response, error) + + /* + * PostScriptsIDInvoke Invoke a script + * Invokes a script and substitutes `params` keys referenced in the script with `params` key-values sent in the request body. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID + * @return ApiPostScriptsIDInvokeRequest + */ + PostScriptsIDInvoke(ctx _context.Context, scriptID string) ApiPostScriptsIDInvokeRequest + + /* + * PostScriptsIDInvokeExecute executes the request + * @return *os.File + */ + PostScriptsIDInvokeExecute(r ApiPostScriptsIDInvokeRequest) (*_nethttp.Response, error) + + /* + * PostScriptsIDInvokeExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not + * available on the returned HTTP response as it will have already been read and closed; access to the response body + * content should be achieved through the returned response model if applicable. + * @return *os.File + */ + PostScriptsIDInvokeExecuteWithHttpInfo(r ApiPostScriptsIDInvokeRequest) (*_nethttp.Response, *_nethttp.Response, error) +} + +// InvokableScriptsApiService InvokableScriptsApi service +type InvokableScriptsApiService service + +type ApiDeleteScriptsIDRequest struct { + ctx _context.Context + ApiService InvokableScriptsApi + scriptID string +} + +func (r ApiDeleteScriptsIDRequest) ScriptID(scriptID string) ApiDeleteScriptsIDRequest { + r.scriptID = scriptID + return r +} +func (r ApiDeleteScriptsIDRequest) GetScriptID() string { + return r.scriptID +} + +func (r ApiDeleteScriptsIDRequest) Execute() error { + return r.ApiService.DeleteScriptsIDExecute(r) +} + +func (r ApiDeleteScriptsIDRequest) ExecuteWithHttpInfo() (*_nethttp.Response, error) { + return r.ApiService.DeleteScriptsIDExecuteWithHttpInfo(r) +} + +/* + * DeleteScriptsID Delete a script + * Deletes a script and all associated records. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID The ID of the script to delete. + * @return ApiDeleteScriptsIDRequest + */ +func (a *InvokableScriptsApiService) DeleteScriptsID(ctx _context.Context, scriptID string) ApiDeleteScriptsIDRequest { + return ApiDeleteScriptsIDRequest{ + ApiService: a, + ctx: ctx, + scriptID: scriptID, + } +} + +/* + * Execute executes the request + */ +func (a *InvokableScriptsApiService) DeleteScriptsIDExecute(r ApiDeleteScriptsIDRequest) error { + _, err := a.DeleteScriptsIDExecuteWithHttpInfo(r) + return err +} + +/* + * ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the + * returned HTTP response as it will have already been read and closed; access to the response body content should be + * achieved through the returned response model if applicable. + */ +func (a *InvokableScriptsApiService) DeleteScriptsIDExecuteWithHttpInfo(r ApiDeleteScriptsIDRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "InvokableScriptsApiService.DeleteScriptsID") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/scripts/{scriptID}" + localVarPath = strings.Replace(localVarPath, "{"+"scriptID"+"}", _neturl.PathEscape(parameterToString(r.scriptID, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + newErr := GenericOpenAPIError{ + buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"), + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.body = localVarBody + newErr.error = localVarHTTPResponse.Status + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarHTTPResponse, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiGetScriptsRequest struct { + ctx _context.Context + ApiService InvokableScriptsApi + limit *int32 + offset *int32 +} + +func (r ApiGetScriptsRequest) Limit(limit int32) ApiGetScriptsRequest { + r.limit = &limit + return r +} +func (r ApiGetScriptsRequest) GetLimit() *int32 { + return r.limit +} + +func (r ApiGetScriptsRequest) Offset(offset int32) ApiGetScriptsRequest { + r.offset = &offset + return r +} +func (r ApiGetScriptsRequest) GetOffset() *int32 { + return r.offset +} + +func (r ApiGetScriptsRequest) Execute() (Scripts, error) { + return r.ApiService.GetScriptsExecute(r) +} + +func (r ApiGetScriptsRequest) ExecuteWithHttpInfo() (Scripts, *_nethttp.Response, error) { + return r.ApiService.GetScriptsExecuteWithHttpInfo(r) +} + +/* + * GetScripts List scripts + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiGetScriptsRequest + */ +func (a *InvokableScriptsApiService) GetScripts(ctx _context.Context) ApiGetScriptsRequest { + return ApiGetScriptsRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return Scripts + */ +func (a *InvokableScriptsApiService) GetScriptsExecute(r ApiGetScriptsRequest) (Scripts, error) { + returnVal, _, err := a.GetScriptsExecuteWithHttpInfo(r) + return returnVal, err +} + +/* + * ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the + * returned HTTP response as it will have already been read and closed; access to the response body content should be + * achieved through the returned response model if applicable. + * @return Scripts + */ +func (a *InvokableScriptsApiService) GetScriptsExecuteWithHttpInfo(r ApiGetScriptsRequest) (Scripts, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Scripts + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "InvokableScriptsApiService.GetScripts") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/scripts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.limit != nil { + localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) + } + if r.offset != nil { + localVarQueryParams.Add("offset", parameterToString(*r.offset, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + newErr := GenericOpenAPIError{ + buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"), + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + newErr.error = localVarHTTPResponse.Status + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, localVarHTTPResponse, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiGetScriptsIDRequest struct { + ctx _context.Context + ApiService InvokableScriptsApi + scriptID string +} + +func (r ApiGetScriptsIDRequest) ScriptID(scriptID string) ApiGetScriptsIDRequest { + r.scriptID = scriptID + return r +} +func (r ApiGetScriptsIDRequest) GetScriptID() string { + return r.scriptID +} + +func (r ApiGetScriptsIDRequest) Execute() (Script, error) { + return r.ApiService.GetScriptsIDExecute(r) +} + +func (r ApiGetScriptsIDRequest) ExecuteWithHttpInfo() (Script, *_nethttp.Response, error) { + return r.ApiService.GetScriptsIDExecuteWithHttpInfo(r) +} + +/* + * GetScriptsID Retrieve a script + * Uses script ID to retrieve details of an invokable script. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID The script ID. + * @return ApiGetScriptsIDRequest + */ +func (a *InvokableScriptsApiService) GetScriptsID(ctx _context.Context, scriptID string) ApiGetScriptsIDRequest { + return ApiGetScriptsIDRequest{ + ApiService: a, + ctx: ctx, + scriptID: scriptID, + } +} + +/* + * Execute executes the request + * @return Script + */ +func (a *InvokableScriptsApiService) GetScriptsIDExecute(r ApiGetScriptsIDRequest) (Script, error) { + returnVal, _, err := a.GetScriptsIDExecuteWithHttpInfo(r) + return returnVal, err +} + +/* + * ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the + * returned HTTP response as it will have already been read and closed; access to the response body content should be + * achieved through the returned response model if applicable. + * @return Script + */ +func (a *InvokableScriptsApiService) GetScriptsIDExecuteWithHttpInfo(r ApiGetScriptsIDRequest) (Script, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Script + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "InvokableScriptsApiService.GetScriptsID") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/scripts/{scriptID}" + localVarPath = strings.Replace(localVarPath, "{"+"scriptID"+"}", _neturl.PathEscape(parameterToString(r.scriptID, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + newErr := GenericOpenAPIError{ + buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"), + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + newErr.error = localVarHTTPResponse.Status + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, localVarHTTPResponse, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiPatchScriptsIDRequest struct { + ctx _context.Context + ApiService InvokableScriptsApi + scriptID string + scriptUpdateRequest *ScriptUpdateRequest +} + +func (r ApiPatchScriptsIDRequest) ScriptID(scriptID string) ApiPatchScriptsIDRequest { + r.scriptID = scriptID + return r +} +func (r ApiPatchScriptsIDRequest) GetScriptID() string { + return r.scriptID +} + +func (r ApiPatchScriptsIDRequest) ScriptUpdateRequest(scriptUpdateRequest ScriptUpdateRequest) ApiPatchScriptsIDRequest { + r.scriptUpdateRequest = &scriptUpdateRequest + return r +} +func (r ApiPatchScriptsIDRequest) GetScriptUpdateRequest() *ScriptUpdateRequest { + return r.scriptUpdateRequest +} + +func (r ApiPatchScriptsIDRequest) Execute() (Script, error) { + return r.ApiService.PatchScriptsIDExecute(r) +} + +func (r ApiPatchScriptsIDRequest) ExecuteWithHttpInfo() (Script, *_nethttp.Response, error) { + return r.ApiService.PatchScriptsIDExecuteWithHttpInfo(r) +} + +/* + * PatchScriptsID Update a script + * Updates properties (`name`, `description`, and `script`) of an invokable script. + + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID The script ID. + * @return ApiPatchScriptsIDRequest + */ +func (a *InvokableScriptsApiService) PatchScriptsID(ctx _context.Context, scriptID string) ApiPatchScriptsIDRequest { + return ApiPatchScriptsIDRequest{ + ApiService: a, + ctx: ctx, + scriptID: scriptID, + } +} + +/* + * Execute executes the request + * @return Script + */ +func (a *InvokableScriptsApiService) PatchScriptsIDExecute(r ApiPatchScriptsIDRequest) (Script, error) { + returnVal, _, err := a.PatchScriptsIDExecuteWithHttpInfo(r) + return returnVal, err +} + +/* + * ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the + * returned HTTP response as it will have already been read and closed; access to the response body content should be + * achieved through the returned response model if applicable. + * @return Script + */ +func (a *InvokableScriptsApiService) PatchScriptsIDExecuteWithHttpInfo(r ApiPatchScriptsIDRequest) (Script, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Script + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "InvokableScriptsApiService.PatchScriptsID") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/scripts/{scriptID}" + localVarPath = strings.Replace(localVarPath, "{"+"scriptID"+"}", _neturl.PathEscape(parameterToString(r.scriptID, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.scriptUpdateRequest == nil { + return localVarReturnValue, nil, reportError("scriptUpdateRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.scriptUpdateRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + newErr := GenericOpenAPIError{ + buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"), + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + newErr.error = localVarHTTPResponse.Status + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, localVarHTTPResponse, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiPostScriptsRequest struct { + ctx _context.Context + ApiService InvokableScriptsApi + scriptCreateRequest *ScriptCreateRequest +} + +func (r ApiPostScriptsRequest) ScriptCreateRequest(scriptCreateRequest ScriptCreateRequest) ApiPostScriptsRequest { + r.scriptCreateRequest = &scriptCreateRequest + return r +} +func (r ApiPostScriptsRequest) GetScriptCreateRequest() *ScriptCreateRequest { + return r.scriptCreateRequest +} + +func (r ApiPostScriptsRequest) Execute() (Script, error) { + return r.ApiService.PostScriptsExecute(r) +} + +func (r ApiPostScriptsRequest) ExecuteWithHttpInfo() (Script, *_nethttp.Response, error) { + return r.ApiService.PostScriptsExecuteWithHttpInfo(r) +} + +/* + * PostScripts Create a script + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiPostScriptsRequest + */ +func (a *InvokableScriptsApiService) PostScripts(ctx _context.Context) ApiPostScriptsRequest { + return ApiPostScriptsRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return Script + */ +func (a *InvokableScriptsApiService) PostScriptsExecute(r ApiPostScriptsRequest) (Script, error) { + returnVal, _, err := a.PostScriptsExecuteWithHttpInfo(r) + return returnVal, err +} + +/* + * ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the + * returned HTTP response as it will have already been read and closed; access to the response body content should be + * achieved through the returned response model if applicable. + * @return Script + */ +func (a *InvokableScriptsApiService) PostScriptsExecuteWithHttpInfo(r ApiPostScriptsRequest) (Script, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue Script + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "InvokableScriptsApiService.PostScripts") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/scripts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.scriptCreateRequest == nil { + return localVarReturnValue, nil, reportError("scriptCreateRequest is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.scriptCreateRequest + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + newErr := GenericOpenAPIError{ + buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"), + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + newErr.error = localVarHTTPResponse.Status + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, localVarHTTPResponse, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiPostScriptsIDInvokeRequest struct { + ctx _context.Context + ApiService InvokableScriptsApi + scriptID string + scriptInvocationParams *ScriptInvocationParams +} + +func (r ApiPostScriptsIDInvokeRequest) ScriptID(scriptID string) ApiPostScriptsIDInvokeRequest { + r.scriptID = scriptID + return r +} +func (r ApiPostScriptsIDInvokeRequest) GetScriptID() string { + return r.scriptID +} + +func (r ApiPostScriptsIDInvokeRequest) ScriptInvocationParams(scriptInvocationParams ScriptInvocationParams) ApiPostScriptsIDInvokeRequest { + r.scriptInvocationParams = &scriptInvocationParams + return r +} +func (r ApiPostScriptsIDInvokeRequest) GetScriptInvocationParams() *ScriptInvocationParams { + return r.scriptInvocationParams +} + +func (r ApiPostScriptsIDInvokeRequest) Execute() (*_nethttp.Response, error) { + return r.ApiService.PostScriptsIDInvokeExecute(r) +} + +func (r ApiPostScriptsIDInvokeRequest) ExecuteWithHttpInfo() (*_nethttp.Response, *_nethttp.Response, error) { + return r.ApiService.PostScriptsIDInvokeExecuteWithHttpInfo(r) +} + +/* + * PostScriptsIDInvoke Invoke a script + * Invokes a script and substitutes `params` keys referenced in the script with `params` key-values sent in the request body. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param scriptID + * @return ApiPostScriptsIDInvokeRequest + */ +func (a *InvokableScriptsApiService) PostScriptsIDInvoke(ctx _context.Context, scriptID string) ApiPostScriptsIDInvokeRequest { + return ApiPostScriptsIDInvokeRequest{ + ApiService: a, + ctx: ctx, + scriptID: scriptID, + } +} + +/* + * Execute executes the request + * @return *os.File + */ +func (a *InvokableScriptsApiService) PostScriptsIDInvokeExecute(r ApiPostScriptsIDInvokeRequest) (*_nethttp.Response, error) { + returnVal, _, err := a.PostScriptsIDInvokeExecuteWithHttpInfo(r) + return returnVal, err +} + +/* + * ExecuteWithHttpInfo executes the request with HTTP response info returned. The response body is not available on the + * returned HTTP response as it will have already been read and closed; access to the response body content should be + * achieved through the returned response model if applicable. + * @return *os.File + */ +func (a *InvokableScriptsApiService) PostScriptsIDInvokeExecuteWithHttpInfo(r ApiPostScriptsIDInvokeRequest) (*_nethttp.Response, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue *_nethttp.Response + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "InvokableScriptsApiService.PostScriptsIDInvoke") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/scripts/{scriptID}/invoke" + localVarPath = strings.Replace(localVarPath, "{"+"scriptID"+"}", _neturl.PathEscape(parameterToString(r.scriptID, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.scriptInvocationParams + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + newErr := GenericOpenAPIError{ + buildHeader: localVarHTTPResponse.Header.Get("X-Influxdb-Build"), + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.body = localVarBody + newErr.error = localVarHTTPResponse.Status + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, localVarHTTPResponse, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + localVarReturnValue = localVarHTTPResponse + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/api/client.gen.go b/api/client.gen.go index 170f5a3..964d554 100644 --- a/api/client.gen.go +++ b/api/client.gen.go @@ -64,6 +64,8 @@ type APIClient struct { HealthApi HealthApi + InvokableScriptsApi InvokableScriptsApi + LegacyAuthorizationsApi LegacyAuthorizationsApi LegacyQueryApi LegacyQueryApi @@ -128,6 +130,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.DashboardsApi = (*DashboardsApiService)(&c.common) c.DeleteApi = (*DeleteApiService)(&c.common) c.HealthApi = (*HealthApiService)(&c.common) + c.InvokableScriptsApi = (*InvokableScriptsApiService)(&c.common) c.LegacyAuthorizationsApi = (*LegacyAuthorizationsApiService)(&c.common) c.LegacyQueryApi = (*LegacyQueryApiService)(&c.common) c.LegacyWriteApi = (*LegacyWriteApiService)(&c.common) diff --git a/api/contract/cli.yml b/api/contract/cli.yml index b5fd205..c3c1196 100644 --- a/api/contract/cli.yml +++ b/api/contract/cli.yml @@ -119,6 +119,12 @@ paths: $ref: "./openapi/src/oss/paths/replications_replicationID_validate.yml" /api/v2/config: $ref: "./openapi/src/oss/paths/config.yml" + /api/v2/scripts: + $ref: "./openapi/src/svc/invocable-scripts/paths/scripts.yml" + /api/v2/scripts/{scriptID}: + $ref: "./openapi/src/svc/invocable-scripts/paths/scripts_scriptID.yml" + /api/v2/scripts/{scriptID}/invoke: + $ref: "./overrides/paths/scripts_scriptID_invoke.yml" components: parameters: TraceSpan: @@ -457,3 +463,17 @@ components: $ref: "./openapi/src/oss/schemas/Replications.yml" Config: $ref: "./openapi/src/oss/schemas/Config.yml" + Script: + $ref: "./openapi/src/svc/invocable-scripts/schemas/Script.yml" + Scripts: + $ref: "./openapi/src/svc/invocable-scripts/schemas/Scripts.yml" + ScriptCreateRequest: + $ref: "./openapi/src/svc/invocable-scripts/schemas/ScriptCreateRequest.yml" + ScriptUpdateRequest: + $ref: "./openapi/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml" + ScriptInvocationParams: + $ref: "./overrides/schemas/ScriptInvocationParams.yml" + ScriptHTTPResponseData: + $ref: "./openapi/src/svc/invocable-scripts/schemas/ScriptHTTPResponseData.yml" + ScriptLanguage: + $ref: "./openapi/src/svc/invocable-scripts/schemas/ScriptLanguage.yml" \ No newline at end of file diff --git a/api/contract/openapi b/api/contract/openapi index 920d508..2e5d005 160000 --- a/api/contract/openapi +++ b/api/contract/openapi @@ -1 +1 @@ -Subproject commit 920d508ef5bb61e09885bd625c6e81734fc5cc99 +Subproject commit 2e5d005615b4dc9e04490336ff4bc3eb09ffc2b0 diff --git a/api/contract/overrides/paths/scripts_scriptID_invoke.yml b/api/contract/overrides/paths/scripts_scriptID_invoke.yml new file mode 100644 index 0000000..2a96192 --- /dev/null +++ b/api/contract/overrides/paths/scripts_scriptID_invoke.yml @@ -0,0 +1,27 @@ +post: + operationId: PostScriptsIDInvoke + tags: + - Invokable Scripts + summary: Invoke a script + description: Invokes a script and substitutes `params` keys referenced in the script with `params` key-values sent in the request body. + parameters: + - in: path + name: scriptID + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: '../schemas/ScriptInvocationParams.yml' + responses: + '200': + description: The result of the script execution. + content: + application/json: + schema: + $ref: '../../openapi/src/svc/invocable-scripts/schemas/ScriptHTTPResponseData.yml' + default: + description: Unexpected error + $ref: '../../openapi/src/common/responses/ServerError.yml' diff --git a/api/contract/overrides/schemas/ScriptInvocationParams.yml b/api/contract/overrides/schemas/ScriptInvocationParams.yml new file mode 100644 index 0000000..457ea4f --- /dev/null +++ b/api/contract/overrides/schemas/ScriptInvocationParams.yml @@ -0,0 +1,4 @@ +type: object +properties: + params: + type: object diff --git a/api/model_run.gen.go b/api/model_run.gen.go index 3511957..6646907 100644 --- a/api/model_run.gen.go +++ b/api/model_run.gen.go @@ -24,6 +24,8 @@ type Run struct { ScheduledFor *time.Time `json:"scheduledFor,omitempty" yaml:"scheduledFor,omitempty"` // An array of logs associated with the run. Log *[]LogEvent `json:"log,omitempty" yaml:"log,omitempty"` + // Flux used for the task + Flux *string `json:"flux,omitempty" yaml:"flux,omitempty"` // Time run started executing, RFC3339Nano. StartedAt *time.Time `json:"startedAt,omitempty" yaml:"startedAt,omitempty"` // Time run finished executing, RFC3339Nano. @@ -210,6 +212,38 @@ func (o *Run) SetLog(v []LogEvent) { o.Log = &v } +// GetFlux returns the Flux field value if set, zero value otherwise. +func (o *Run) GetFlux() string { + if o == nil || o.Flux == nil { + var ret string + return ret + } + return *o.Flux +} + +// GetFluxOk returns a tuple with the Flux field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Run) GetFluxOk() (*string, bool) { + if o == nil || o.Flux == nil { + return nil, false + } + return o.Flux, true +} + +// HasFlux returns a boolean if a field has been set. +func (o *Run) HasFlux() bool { + if o != nil && o.Flux != nil { + return true + } + + return false +} + +// SetFlux gets a reference to the given string and assigns it to the Flux field. +func (o *Run) SetFlux(v string) { + o.Flux = &v +} + // GetStartedAt returns the StartedAt field value if set, zero value otherwise. func (o *Run) GetStartedAt() time.Time { if o == nil || o.StartedAt == nil { @@ -355,6 +389,9 @@ func (o Run) MarshalJSON() ([]byte, error) { if o.Log != nil { toSerialize["log"] = o.Log } + if o.Flux != nil { + toSerialize["flux"] = o.Flux + } if o.StartedAt != nil { toSerialize["startedAt"] = o.StartedAt } diff --git a/api/model_script.gen.go b/api/model_script.gen.go new file mode 100644 index 0000000..26d6482 --- /dev/null +++ b/api/model_script.gen.go @@ -0,0 +1,383 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" + "time" +) + +// Script struct for Script +type Script struct { + Id *string `json:"id,omitempty" yaml:"id,omitempty"` + Name string `json:"name" yaml:"name"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + OrgID string `json:"orgID" yaml:"orgID"` + // script to be executed + Script string `json:"script" yaml:"script"` + Language *ScriptLanguage `json:"language,omitempty" yaml:"language,omitempty"` + // invocation endpoint address + Url *string `json:"url,omitempty" yaml:"url,omitempty"` + CreatedAt *time.Time `json:"createdAt,omitempty" yaml:"createdAt,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"` +} + +// NewScript instantiates a new Script object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewScript(name string, orgID string, script string) *Script { + this := Script{} + this.Name = name + this.OrgID = orgID + this.Script = script + return &this +} + +// NewScriptWithDefaults instantiates a new Script object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewScriptWithDefaults() *Script { + this := Script{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *Script) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Script) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *Script) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *Script) SetId(v string) { + o.Id = &v +} + +// GetName returns the Name field value +func (o *Script) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *Script) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *Script) SetName(v string) { + o.Name = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *Script) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Script) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *Script) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *Script) SetDescription(v string) { + o.Description = &v +} + +// GetOrgID returns the OrgID field value +func (o *Script) GetOrgID() string { + if o == nil { + var ret string + return ret + } + + return o.OrgID +} + +// GetOrgIDOk returns a tuple with the OrgID field value +// and a boolean to check if the value has been set. +func (o *Script) GetOrgIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.OrgID, true +} + +// SetOrgID sets field value +func (o *Script) SetOrgID(v string) { + o.OrgID = v +} + +// GetScript returns the Script field value +func (o *Script) GetScript() string { + if o == nil { + var ret string + return ret + } + + return o.Script +} + +// GetScriptOk returns a tuple with the Script field value +// and a boolean to check if the value has been set. +func (o *Script) GetScriptOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Script, true +} + +// SetScript sets field value +func (o *Script) SetScript(v string) { + o.Script = v +} + +// GetLanguage returns the Language field value if set, zero value otherwise. +func (o *Script) GetLanguage() ScriptLanguage { + if o == nil || o.Language == nil { + var ret ScriptLanguage + return ret + } + return *o.Language +} + +// GetLanguageOk returns a tuple with the Language field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Script) GetLanguageOk() (*ScriptLanguage, bool) { + if o == nil || o.Language == nil { + return nil, false + } + return o.Language, true +} + +// HasLanguage returns a boolean if a field has been set. +func (o *Script) HasLanguage() bool { + if o != nil && o.Language != nil { + return true + } + + return false +} + +// SetLanguage gets a reference to the given ScriptLanguage and assigns it to the Language field. +func (o *Script) SetLanguage(v ScriptLanguage) { + o.Language = &v +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *Script) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Script) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *Script) HasUrl() bool { + if o != nil && o.Url != nil { + return true + } + + return false +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *Script) SetUrl(v string) { + o.Url = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *Script) GetCreatedAt() time.Time { + if o == nil || o.CreatedAt == nil { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Script) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *Script) HasCreatedAt() bool { + if o != nil && o.CreatedAt != nil { + return true + } + + return false +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *Script) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *Script) GetUpdatedAt() time.Time { + if o == nil || o.UpdatedAt == nil { + var ret time.Time + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Script) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil || o.UpdatedAt == nil { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *Script) HasUpdatedAt() bool { + if o != nil && o.UpdatedAt != nil { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. +func (o *Script) SetUpdatedAt(v time.Time) { + o.UpdatedAt = &v +} + +func (o Script) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Id != nil { + toSerialize["id"] = o.Id + } + if true { + toSerialize["name"] = o.Name + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if true { + toSerialize["orgID"] = o.OrgID + } + if true { + toSerialize["script"] = o.Script + } + if o.Language != nil { + toSerialize["language"] = o.Language + } + if o.Url != nil { + toSerialize["url"] = o.Url + } + if o.CreatedAt != nil { + toSerialize["createdAt"] = o.CreatedAt + } + if o.UpdatedAt != nil { + toSerialize["updatedAt"] = o.UpdatedAt + } + return json.Marshal(toSerialize) +} + +type NullableScript struct { + value *Script + isSet bool +} + +func (v NullableScript) Get() *Script { + return v.value +} + +func (v *NullableScript) Set(val *Script) { + v.value = val + v.isSet = true +} + +func (v NullableScript) IsSet() bool { + return v.isSet +} + +func (v *NullableScript) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableScript(val *Script) *NullableScript { + return &NullableScript{value: val, isSet: true} +} + +func (v NullableScript) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableScript) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_script_create_request.gen.go b/api/model_script_create_request.gen.go new file mode 100644 index 0000000..96c2ad7 --- /dev/null +++ b/api/model_script_create_request.gen.go @@ -0,0 +1,195 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" +) + +// ScriptCreateRequest struct for ScriptCreateRequest +type ScriptCreateRequest struct { + // The name of the script. The name must be unique within the organization. + Name string `json:"name" yaml:"name"` + Description string `json:"description" yaml:"description"` + // The script to execute. + Script string `json:"script" yaml:"script"` + Language ScriptLanguage `json:"language" yaml:"language"` +} + +// NewScriptCreateRequest instantiates a new ScriptCreateRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewScriptCreateRequest(name string, description string, script string, language ScriptLanguage) *ScriptCreateRequest { + this := ScriptCreateRequest{} + this.Name = name + this.Description = description + this.Script = script + this.Language = language + return &this +} + +// NewScriptCreateRequestWithDefaults instantiates a new ScriptCreateRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewScriptCreateRequestWithDefaults() *ScriptCreateRequest { + this := ScriptCreateRequest{} + return &this +} + +// GetName returns the Name field value +func (o *ScriptCreateRequest) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ScriptCreateRequest) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *ScriptCreateRequest) SetName(v string) { + o.Name = v +} + +// GetDescription returns the Description field value +func (o *ScriptCreateRequest) GetDescription() string { + if o == nil { + var ret string + return ret + } + + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *ScriptCreateRequest) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value +func (o *ScriptCreateRequest) SetDescription(v string) { + o.Description = v +} + +// GetScript returns the Script field value +func (o *ScriptCreateRequest) GetScript() string { + if o == nil { + var ret string + return ret + } + + return o.Script +} + +// GetScriptOk returns a tuple with the Script field value +// and a boolean to check if the value has been set. +func (o *ScriptCreateRequest) GetScriptOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Script, true +} + +// SetScript sets field value +func (o *ScriptCreateRequest) SetScript(v string) { + o.Script = v +} + +// GetLanguage returns the Language field value +func (o *ScriptCreateRequest) GetLanguage() ScriptLanguage { + if o == nil { + var ret ScriptLanguage + return ret + } + + return o.Language +} + +// GetLanguageOk returns a tuple with the Language field value +// and a boolean to check if the value has been set. +func (o *ScriptCreateRequest) GetLanguageOk() (*ScriptLanguage, bool) { + if o == nil { + return nil, false + } + return &o.Language, true +} + +// SetLanguage sets field value +func (o *ScriptCreateRequest) SetLanguage(v ScriptLanguage) { + o.Language = v +} + +func (o ScriptCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["name"] = o.Name + } + if true { + toSerialize["description"] = o.Description + } + if true { + toSerialize["script"] = o.Script + } + if true { + toSerialize["language"] = o.Language + } + return json.Marshal(toSerialize) +} + +type NullableScriptCreateRequest struct { + value *ScriptCreateRequest + isSet bool +} + +func (v NullableScriptCreateRequest) Get() *ScriptCreateRequest { + return v.value +} + +func (v *NullableScriptCreateRequest) Set(val *ScriptCreateRequest) { + v.value = val + v.isSet = true +} + +func (v NullableScriptCreateRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableScriptCreateRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableScriptCreateRequest(val *ScriptCreateRequest) *NullableScriptCreateRequest { + return &NullableScriptCreateRequest{value: val, isSet: true} +} + +func (v NullableScriptCreateRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableScriptCreateRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_script_invocation_params.gen.go b/api/model_script_invocation_params.gen.go new file mode 100644 index 0000000..6ac1464 --- /dev/null +++ b/api/model_script_invocation_params.gen.go @@ -0,0 +1,113 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" +) + +// ScriptInvocationParams struct for ScriptInvocationParams +type ScriptInvocationParams struct { + Params *map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty"` +} + +// NewScriptInvocationParams instantiates a new ScriptInvocationParams object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewScriptInvocationParams() *ScriptInvocationParams { + this := ScriptInvocationParams{} + return &this +} + +// NewScriptInvocationParamsWithDefaults instantiates a new ScriptInvocationParams object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewScriptInvocationParamsWithDefaults() *ScriptInvocationParams { + this := ScriptInvocationParams{} + return &this +} + +// GetParams returns the Params field value if set, zero value otherwise. +func (o *ScriptInvocationParams) GetParams() map[string]interface{} { + if o == nil || o.Params == nil { + var ret map[string]interface{} + return ret + } + return *o.Params +} + +// GetParamsOk returns a tuple with the Params field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScriptInvocationParams) GetParamsOk() (*map[string]interface{}, bool) { + if o == nil || o.Params == nil { + return nil, false + } + return o.Params, true +} + +// HasParams returns a boolean if a field has been set. +func (o *ScriptInvocationParams) HasParams() bool { + if o != nil && o.Params != nil { + return true + } + + return false +} + +// SetParams gets a reference to the given map[string]interface{} and assigns it to the Params field. +func (o *ScriptInvocationParams) SetParams(v map[string]interface{}) { + o.Params = &v +} + +func (o ScriptInvocationParams) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Params != nil { + toSerialize["params"] = o.Params + } + return json.Marshal(toSerialize) +} + +type NullableScriptInvocationParams struct { + value *ScriptInvocationParams + isSet bool +} + +func (v NullableScriptInvocationParams) Get() *ScriptInvocationParams { + return v.value +} + +func (v *NullableScriptInvocationParams) Set(val *ScriptInvocationParams) { + v.value = val + v.isSet = true +} + +func (v NullableScriptInvocationParams) IsSet() bool { + return v.isSet +} + +func (v *NullableScriptInvocationParams) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableScriptInvocationParams(val *ScriptInvocationParams) *NullableScriptInvocationParams { + return &NullableScriptInvocationParams{value: val, isSet: true} +} + +func (v NullableScriptInvocationParams) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableScriptInvocationParams) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_script_language.gen.go b/api/model_script_language.gen.go new file mode 100644 index 0000000..5bcc654 --- /dev/null +++ b/api/model_script_language.gen.go @@ -0,0 +1,86 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" + "fmt" +) + +// ScriptLanguage the model 'ScriptLanguage' +type ScriptLanguage string + +// List of ScriptLanguage +const ( + SCRIPTLANGUAGE_FLUX ScriptLanguage = "flux" +) + +func ScriptLanguageValues() []ScriptLanguage { + return []ScriptLanguage{"flux"} +} + +func (v *ScriptLanguage) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := ScriptLanguage(value) + for _, existing := range []ScriptLanguage{"flux"} { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid ScriptLanguage", value) +} + +// Ptr returns reference to ScriptLanguage value +func (v ScriptLanguage) Ptr() *ScriptLanguage { + return &v +} + +type NullableScriptLanguage struct { + value *ScriptLanguage + isSet bool +} + +func (v NullableScriptLanguage) Get() *ScriptLanguage { + return v.value +} + +func (v *NullableScriptLanguage) Set(val *ScriptLanguage) { + v.value = val + v.isSet = true +} + +func (v NullableScriptLanguage) IsSet() bool { + return v.isSet +} + +func (v *NullableScriptLanguage) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableScriptLanguage(val *ScriptLanguage) *NullableScriptLanguage { + return &NullableScriptLanguage{value: val, isSet: true} +} + +func (v NullableScriptLanguage) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableScriptLanguage) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_script_update_request.gen.go b/api/model_script_update_request.gen.go new file mode 100644 index 0000000..1d9b556 --- /dev/null +++ b/api/model_script_update_request.gen.go @@ -0,0 +1,186 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" +) + +// ScriptUpdateRequest struct for ScriptUpdateRequest +type ScriptUpdateRequest struct { + Name *string `json:"name,omitempty" yaml:"name,omitempty"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + // script is script to be executed + Script *string `json:"script,omitempty" yaml:"script,omitempty"` +} + +// NewScriptUpdateRequest instantiates a new ScriptUpdateRequest object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewScriptUpdateRequest() *ScriptUpdateRequest { + this := ScriptUpdateRequest{} + return &this +} + +// NewScriptUpdateRequestWithDefaults instantiates a new ScriptUpdateRequest object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewScriptUpdateRequestWithDefaults() *ScriptUpdateRequest { + this := ScriptUpdateRequest{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ScriptUpdateRequest) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScriptUpdateRequest) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ScriptUpdateRequest) HasName() bool { + if o != nil && o.Name != nil { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ScriptUpdateRequest) SetName(v string) { + o.Name = &v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *ScriptUpdateRequest) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScriptUpdateRequest) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *ScriptUpdateRequest) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *ScriptUpdateRequest) SetDescription(v string) { + o.Description = &v +} + +// GetScript returns the Script field value if set, zero value otherwise. +func (o *ScriptUpdateRequest) GetScript() string { + if o == nil || o.Script == nil { + var ret string + return ret + } + return *o.Script +} + +// GetScriptOk returns a tuple with the Script field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScriptUpdateRequest) GetScriptOk() (*string, bool) { + if o == nil || o.Script == nil { + return nil, false + } + return o.Script, true +} + +// HasScript returns a boolean if a field has been set. +func (o *ScriptUpdateRequest) HasScript() bool { + if o != nil && o.Script != nil { + return true + } + + return false +} + +// SetScript gets a reference to the given string and assigns it to the Script field. +func (o *ScriptUpdateRequest) SetScript(v string) { + o.Script = &v +} + +func (o ScriptUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.Script != nil { + toSerialize["script"] = o.Script + } + return json.Marshal(toSerialize) +} + +type NullableScriptUpdateRequest struct { + value *ScriptUpdateRequest + isSet bool +} + +func (v NullableScriptUpdateRequest) Get() *ScriptUpdateRequest { + return v.value +} + +func (v *NullableScriptUpdateRequest) Set(val *ScriptUpdateRequest) { + v.value = val + v.isSet = true +} + +func (v NullableScriptUpdateRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableScriptUpdateRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableScriptUpdateRequest(val *ScriptUpdateRequest) *NullableScriptUpdateRequest { + return &NullableScriptUpdateRequest{value: val, isSet: true} +} + +func (v NullableScriptUpdateRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableScriptUpdateRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_scripts.gen.go b/api/model_scripts.gen.go new file mode 100644 index 0000000..f31045a --- /dev/null +++ b/api/model_scripts.gen.go @@ -0,0 +1,113 @@ +/* + * Subset of Influx API covered by Influx CLI + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * API version: 2.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" +) + +// Scripts struct for Scripts +type Scripts struct { + Scripts *[]Script `json:"scripts,omitempty" yaml:"scripts,omitempty"` +} + +// NewScripts instantiates a new Scripts object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewScripts() *Scripts { + this := Scripts{} + return &this +} + +// NewScriptsWithDefaults instantiates a new Scripts object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewScriptsWithDefaults() *Scripts { + this := Scripts{} + return &this +} + +// GetScripts returns the Scripts field value if set, zero value otherwise. +func (o *Scripts) GetScripts() []Script { + if o == nil || o.Scripts == nil { + var ret []Script + return ret + } + return *o.Scripts +} + +// GetScriptsOk returns a tuple with the Scripts field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Scripts) GetScriptsOk() (*[]Script, bool) { + if o == nil || o.Scripts == nil { + return nil, false + } + return o.Scripts, true +} + +// HasScripts returns a boolean if a field has been set. +func (o *Scripts) HasScripts() bool { + if o != nil && o.Scripts != nil { + return true + } + + return false +} + +// SetScripts gets a reference to the given []Script and assigns it to the Scripts field. +func (o *Scripts) SetScripts(v []Script) { + o.Scripts = &v +} + +func (o Scripts) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Scripts != nil { + toSerialize["scripts"] = o.Scripts + } + return json.Marshal(toSerialize) +} + +type NullableScripts struct { + value *Scripts + isSet bool +} + +func (v NullableScripts) Get() *Scripts { + return v.value +} + +func (v *NullableScripts) Set(val *Scripts) { + v.value = val + v.isSet = true +} + +func (v NullableScripts) IsSet() bool { + return v.isSet +} + +func (v *NullableScripts) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableScripts(val *Scripts) *NullableScripts { + return &NullableScripts{value: val, isSet: true} +} + +func (v NullableScripts) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableScripts) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/clients/script/script.go b/clients/script/script.go new file mode 100644 index 0000000..e962038 --- /dev/null +++ b/clients/script/script.go @@ -0,0 +1,172 @@ +package script + +import ( + "context" + "errors" + "fmt" + + "github.com/influxdata/influx-cli/v2/api" + "github.com/influxdata/influx-cli/v2/clients" + "github.com/influxdata/influx-cli/v2/clients/query" +) + +type Client struct { + clients.CLI + api.InvokableScriptsApi +} + +func (c Client) printScripts(scripts []api.Script) error { + if c.PrintAsJSON { + return c.PrintJSON(scripts) + } + + headers := []string{ + "ID", + "Name", + "Description", + "Organization ID", + "Language", + } + + var rows []map[string]interface{} + for _, s := range scripts { + row := map[string]interface{}{ + "ID": *s.Id, + "Name": s.Name, + "Description": *s.Description, + "Organization ID": s.OrgID, + "Language": *s.Language, + } + + rows = append(rows, row) + } + + return c.PrintTable(headers, rows...) +} + +type ListParams struct { + Limit int + Offset int +} + +func (c Client) List(ctx context.Context, params *ListParams) error { + req := c.GetScripts(ctx) + if params != nil { + req = req.Limit(int32(params.Limit)).Offset(int32(params.Offset)) + } + res, err := req.Execute() + if err != nil { + return fmt.Errorf("failed to list scripts: %v", err) + } + + return c.printScripts(*res.Scripts) +} + +type CreateParams struct { + Description string + Language string + Name string + Script string +} + +func (c Client) Create(ctx context.Context, params *CreateParams) error { + if params == nil { + return errors.New("failed to create script: no parameters provided") + } + + req := api.ScriptCreateRequest{ + Name: params.Name, + Description: params.Description, + Script: params.Script, + Language: api.ScriptLanguage(params.Language), + } + + script, err := c.PostScripts(ctx).ScriptCreateRequest(req).Execute() + if err != nil { + return fmt.Errorf("failed to create script: %v", err) + } + + return c.printScripts([]api.Script{script}) +} + +type DeleteParams struct { + ScriptID string +} + +func (c Client) Delete(ctx context.Context, params *DeleteParams) error { + err := c.DeleteScriptsID(ctx, params.ScriptID).Execute() + if err != nil { + return fmt.Errorf("failed to delete script: %v", err) + } + return nil +} + +type RetrieveParams struct { + ScriptID string +} + +func (c Client) Retrieve(ctx context.Context, params *RetrieveParams) error { + script, err := c.GetScriptsID(ctx, params.ScriptID).Execute() + if err != nil { + return fmt.Errorf("failed to retrieve script: %v", err) + } + + return c.printScripts([]api.Script{script}) +} + +type UpdateParams struct { + ScriptID string + Description string + Name string + Script string +} + +func (c Client) Update(ctx context.Context, params *UpdateParams) error { + // Retrieve the original since we might carry over some unchanged details. + oldScript, err := c.GetScriptsID(ctx, params.ScriptID).Execute() + if err != nil { + return fmt.Errorf("failed to update script: %v", err) + } + + if len(params.Description) == 0 { + params.Description = *oldScript.Description + } + if len(params.Name) == 0 { + params.Name = oldScript.Name + } + if len(params.Script) == 0 { + params.Script = oldScript.Script + } + + req := api.ScriptUpdateRequest{ + Name: ¶ms.Name, + Description: ¶ms.Description, + Script: ¶ms.Script, + } + + script, err := c.PatchScriptsID(ctx, params.ScriptID).ScriptUpdateRequest(req).Execute() + if err != nil { + return fmt.Errorf("failed to update script: %v", err) + } + + return c.printScripts([]api.Script{script}) +} + +type InvokeParams struct { + ScriptID string + Params map[string]interface{} +} + +func (c Client) Invoke(ctx context.Context, params *InvokeParams) error { + req := api.ScriptInvocationParams{ + Params: ¶ms.Params, + } + + resp, err := c.PostScriptsIDInvoke(ctx, params.ScriptID).ScriptInvocationParams(req).Execute() + if err != nil { + return fmt.Errorf("failed to invoke script: %v", err) + } + defer resp.Body.Close() + + return query.RawResultPrinter.PrintQueryResults(resp.Body, c.StdIO) +} diff --git a/clients/script/script_test.go b/clients/script/script_test.go new file mode 100644 index 0000000..6b81ce5 --- /dev/null +++ b/clients/script/script_test.go @@ -0,0 +1,202 @@ +package script_test + +import ( + "context" + "strings" + "testing" + + "github.com/golang/mock/gomock" + "github.com/influxdata/influx-cli/v2/api" + "github.com/influxdata/influx-cli/v2/clients" + "github.com/influxdata/influx-cli/v2/clients/script" + "github.com/influxdata/influx-cli/v2/internal/mock" + tmock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func Test_SimpleCreate(t *testing.T) { + t.Parallel() + + ctrl := gomock.NewController(t) + scriptsApi := mock.NewMockInvocableScriptsApi(ctrl) + + var ( + scriptId = "123456789" + scriptName = "simple" + scriptDesc = "A basic script to be created" + scriptOrgId = "1111111111111" + scriptContent = `from(bucket: "sample_data") |> range(start: -10h)` + scriptLanguage = api.SCRIPTLANGUAGE_FLUX + ) + + scriptsApi.EXPECT().PostScripts(gomock.Any()).Return(api.ApiPostScriptsRequest{ + ApiService: scriptsApi, + }) + + scriptsApi.EXPECT().PostScriptsExecute(gomock.Any()).Return(api.Script{ + Id: &scriptId, + Name: scriptName, + Description: &scriptDesc, + OrgID: scriptOrgId, + Script: scriptContent, + Language: &scriptLanguage, + }, nil) + + stdio := mock.NewMockStdIO(ctrl) + client := script.Client{ + CLI: clients.CLI{StdIO: stdio, PrintAsJSON: true}, + InvokableScriptsApi: scriptsApi, + } + + stdio.EXPECT().Write(tmock.MatchedBy(func(in []byte) bool { + t.Logf("Stdio output: %s", in) + inStr := string(in) + // Verify we print the basic details of the script in some form. + return strings.Contains(inStr, scriptId) && + strings.Contains(inStr, scriptName) && + strings.Contains(inStr, scriptOrgId) + })) + + params := script.CreateParams{ + Description: scriptDesc, + Language: string(scriptLanguage), + Name: scriptName, + Script: scriptContent, + } + + require.NoError(t, client.Create(context.Background(), ¶ms)) +} + +func strFactory(arg interface{}) *string { + val := (arg.(string)) // Docker image runs Go 1.17, so we can't use generics here. + return &val +} + +func Test_SimpleList(t *testing.T) { + t.Parallel() + + ctrl := gomock.NewController(t) + scriptsApi := mock.NewMockInvocableScriptsApi(ctrl) + + language := api.SCRIPTLANGUAGE_FLUX + scripts := []api.Script{{ + Id: strFactory("123456789"), + Name: "simple", + Description: strFactory("First script"), + OrgID: "1111111111111", + Script: `from(bucket: "sample_data") |> range(start: -10h)`, + Language: &language, + }, { + Id: strFactory("000000001"), + Name: "another", + Description: strFactory("Second script"), + OrgID: "9111111111119", + Script: `from(bucket: "sample_data") |> range(start: -5h)`, + Language: &language, + }, + } + + scriptsApi.EXPECT().GetScripts(gomock.Any()).Return(api.ApiGetScriptsRequest{ + ApiService: scriptsApi, + }) + + scriptsApi.EXPECT().GetScriptsExecute(gomock.Any()).Return(api.Scripts{ + Scripts: &scripts, + }, nil) + + stdio := mock.NewMockStdIO(ctrl) + client := script.Client{ + CLI: clients.CLI{StdIO: stdio, PrintAsJSON: true}, + InvokableScriptsApi: scriptsApi, + } + + stdio.EXPECT().Write(tmock.MatchedBy(func(in []byte) bool { + t.Logf("Stdio output: %s", in) + inStr := string(in) + // Verify we print the basic details of all scripts in some form. + success := true + for _, script := range scripts { + success = success && strings.Contains(inStr, *script.Id) + success = success && strings.Contains(inStr, script.Name) + success = success && strings.Contains(inStr, script.OrgID) + } + return success + })) + + params := script.ListParams{ + Limit: 10, + Offset: 0, + } + + require.NoError(t, client.List(context.Background(), ¶ms)) +} + +func Test_Update(t *testing.T) { + t.Parallel() + + ctrl := gomock.NewController(t) + scriptsApi := mock.NewMockInvocableScriptsApi(ctrl) + + var ( + scriptId = "123456789" + scriptName = "simple" + scriptDescOld = "A basic script to be created" + scriptDescNew = "An updated script" + scriptOrgId = "1111111111111" + scriptContentOld = `from(bucket: "sample_data") |> range(start: -10h)` + scriptContentNew = `from(bucket: "devbucket") |> range(start: -100h)` + scriptLanguage = api.SCRIPTLANGUAGE_FLUX + ) + + // If we change the logic for handling parameter defaulting, the GetScriptsID calls need to be removed. + scriptsApi.EXPECT().GetScriptsID(gomock.Any(), scriptId).Return(api.ApiGetScriptsIDRequest{ + ApiService: scriptsApi, + }) + + scriptsApi.EXPECT().GetScriptsIDExecute(gomock.Any()).Return(api.Script{ + Id: &scriptId, + Name: scriptName, + Description: &scriptDescOld, + OrgID: scriptOrgId, + Script: scriptContentOld, + Language: &scriptLanguage, + }, nil) + + scriptsApi.EXPECT().PatchScriptsID(gomock.Any(), scriptId).Return(api.ApiPatchScriptsIDRequest{ + ApiService: scriptsApi, + }) + + scriptsApi.EXPECT().PatchScriptsIDExecute(gomock.Any()).Return(api.Script{ + Id: &scriptId, + Name: scriptName, + Description: &scriptDescNew, + OrgID: scriptOrgId, + Script: scriptContentNew, + Language: &scriptLanguage, + }, nil) + + stdio := mock.NewMockStdIO(ctrl) + client := script.Client{ + CLI: clients.CLI{StdIO: stdio, PrintAsJSON: true}, + InvokableScriptsApi: scriptsApi, + } + + stdio.EXPECT().Write(tmock.MatchedBy(func(in []byte) bool { + t.Logf("Stdio output: %s", in) + inStr := string(in) + // Verify we print the updated script's details. + return strings.Contains(inStr, scriptId) && + strings.Contains(inStr, scriptName) && + strings.Contains(inStr, scriptDescNew) && + strings.Contains(inStr, scriptOrgId) + })) + + updateParams := script.UpdateParams{ + ScriptID: scriptId, + Description: scriptDescNew, + Name: scriptName, + Script: scriptContentNew, + } + + require.NoError(t, client.Update(context.Background(), &updateParams)) +} diff --git a/cmd/influx/main.go b/cmd/influx/main.go index dd97834..a53266b 100644 --- a/cmd/influx/main.go +++ b/cmd/influx/main.go @@ -31,6 +31,7 @@ func cloudOnlyCommands() []cli.Command { // will be returned if these commands are run on an InfluxDB OSS host. cmds := []cli.Command{ newBucketSchemaCmd(), + newScriptsCmd(), } return middleware.AddMWToCmds(cmds, middleware.CloudOnly) diff --git a/cmd/influx/scripts.go b/cmd/influx/scripts.go new file mode 100644 index 0000000..fd7f78f --- /dev/null +++ b/cmd/influx/scripts.go @@ -0,0 +1,277 @@ +package main + +import ( + "encoding/json" + "errors" + "fmt" + "os" + "strings" + + "github.com/influxdata/influx-cli/v2/clients/script" + "github.com/influxdata/influx-cli/v2/pkg/cli/middleware" + "github.com/urfave/cli" +) + +func newScriptsCmd() cli.Command { + return cli.Command{ + Name: "scripts", + Usage: "Scripts management commands", + Before: middleware.NoArgs, + Subcommands: []cli.Command{ + newScriptsListCmd(), + newScriptsCreateCmd(), + newScriptsDeleteCmd(), + newScriptsRetrieveCmd(), + newScriptsUpdateCmd(), + newScriptsInvokeCmd(), + }, + } +} + +func newScriptsListCmd() cli.Command { + var params script.ListParams + flags := []cli.Flag{ + &cli.IntFlag{ + Name: "limit, l", + Usage: "The number of scripts to return", + Destination: ¶ms.Limit, + }, + &cli.IntFlag{ + Name: "offset, o", + Usage: "The offset for pagination", + Destination: ¶ms.Offset, + }} + flags = append(flags, commonFlags()...) + + return cli.Command{ + Name: "list", + Usage: "Lists scripts", + Flags: flags, + Before: middleware.WithBeforeFns(withCli(), withApi(true)), + Action: func(ctx *cli.Context) error { + api := getAPI(ctx) + client := script.Client{ + CLI: getCLI(ctx), + InvokableScriptsApi: api.InvokableScriptsApi, + } + + return client.List(getContext(ctx), ¶ms) + }, + } +} + +func newScriptsCreateCmd() cli.Command { + var params script.CreateParams + var scriptFile string + flags := []cli.Flag{ + &cli.StringFlag{ + Name: "description, d", + Usage: "The purpose or functionality of the script", + Destination: ¶ms.Description, + }, + &cli.StringFlag{ + Name: "language, l", + Usage: "What language the script is written in", + Destination: ¶ms.Language, + }, + &cli.StringFlag{ + Name: "name, n", + Usage: "Name of the script", + Destination: ¶ms.Name, + }, + &cli.StringFlag{ + Name: "script, s", + Usage: "Contents of the script to be executed", + Destination: ¶ms.Script, + }, + &cli.StringFlag{ + Name: "file, f", + Usage: "File name containing the contents of the script to be executed", + Destination: &scriptFile, + }, + } + flags = append(flags, commonFlags()...) + + return cli.Command{ + Name: "create", + Usage: "Creates a new script", + Flags: flags, + Before: middleware.WithBeforeFns(withCli(), withApi(true)), + Action: func(ctx *cli.Context) error { + if len(params.Script) > 0 && len(scriptFile) > 0 { + return errors.New("cannot specify both a script string and a file") + } + + if len(scriptFile) > 0 { + data, err := os.ReadFile(scriptFile) + if err != nil { + return fmt.Errorf("failed to create script: %v", err) + } + params.Script = string(data) + } + + api := getAPI(ctx) + client := script.Client{ + CLI: getCLI(ctx), + InvokableScriptsApi: api.InvokableScriptsApi, + } + + return client.Create(getContext(ctx), ¶ms) + }, + } +} + +func newScriptsDeleteCmd() cli.Command { + var params script.DeleteParams + flags := []cli.Flag{ + &cli.StringFlag{ + Name: "scriptID, i", + Usage: "Script identifier", + Destination: ¶ms.ScriptID, + }} + flags = append(flags, commonFlags()...) + + return cli.Command{ + Name: "delete", + Usage: "Deletes a script", + Flags: flags, + Before: middleware.WithBeforeFns(withCli(), withApi(true)), + Action: func(ctx *cli.Context) error { + api := getAPI(ctx) + client := script.Client{ + CLI: getCLI(ctx), + InvokableScriptsApi: api.InvokableScriptsApi, + } + + return client.Delete(getContext(ctx), ¶ms) + }, + } +} + +func newScriptsRetrieveCmd() cli.Command { + var params script.RetrieveParams + flags := []cli.Flag{ + &cli.StringFlag{ + Name: "scriptID, i", + Usage: "Script identifier", + Destination: ¶ms.ScriptID, + }} + flags = append(flags, commonFlags()...) + + return cli.Command{ + Name: "retrieve", + Usage: "Retrieves a script", + Flags: flags, + Before: middleware.WithBeforeFns(withCli(), withApi(true)), + Action: func(ctx *cli.Context) error { + api := getAPI(ctx) + client := script.Client{ + CLI: getCLI(ctx), + InvokableScriptsApi: api.InvokableScriptsApi, + } + + return client.Retrieve(getContext(ctx), ¶ms) + }, + } +} + +func newScriptsUpdateCmd() cli.Command { + var params script.UpdateParams + flags := []cli.Flag{ + &cli.StringFlag{ + Name: "scriptID, i", + Usage: "Script identifier", + Destination: ¶ms.ScriptID, + }, + &cli.StringFlag{ + Name: "description, d", + Usage: "New script description", + Destination: ¶ms.Description, + }, + &cli.StringFlag{ + Name: "name, n", + Usage: "New script name", + Destination: ¶ms.Name, + }, + &cli.StringFlag{ + Name: "script, s", + Usage: "New script contents", + Destination: ¶ms.Script, + }} + flags = append(flags, commonFlags()...) + + return cli.Command{ + Name: "update", + Usage: "Updates a script", + Flags: flags, + Before: middleware.WithBeforeFns(withCli(), withApi(true)), + Action: func(ctx *cli.Context) error { + api := getAPI(ctx) + client := script.Client{ + CLI: getCLI(ctx), + InvokableScriptsApi: api.InvokableScriptsApi, + } + + return client.Update(getContext(ctx), ¶ms) + }, + } +} + +func newScriptsInvokeCmd() cli.Command { + var params script.InvokeParams + var jsonParams string + var jsonFile string + flags := []cli.Flag{ + &cli.StringFlag{ + Name: "scriptID, i", + Usage: "Script identifier", + Destination: ¶ms.ScriptID, + }, + &cli.StringFlag{ + Name: "params, p", + Usage: "JSON string containing the parameters", + Destination: &jsonParams, + }, + &cli.StringFlag{ + Name: "file, f", + Usage: "File name containing the script parameters, in JSON", + Destination: &jsonFile, + }, + } + flags = append(flags, commonFlags()...) + + return cli.Command{ + Name: "invoke", + Usage: "Invokes a script", + Flags: flags, + Before: middleware.WithBeforeFns(withCli(), withApi(true)), + Action: func(ctx *cli.Context) error { + if len(jsonParams) > 0 && len(jsonFile) > 0 { + return errors.New("cannot specify both a parameter string and a file") + } + + if len(jsonFile) > 0 { + data, err := os.ReadFile(jsonFile) + if err != nil { + return fmt.Errorf("failed to invoke script: %v", err) + } + jsonParams = string(data) + } + + api := getAPI(ctx) + client := script.Client{ + CLI: getCLI(ctx), + InvokableScriptsApi: api.InvokableScriptsApi, + } + + params.Params = make(map[string]interface{}) + if len(jsonParams) > 0 { + if err := json.NewDecoder(strings.NewReader(jsonParams)).Decode(¶ms.Params); err != nil { + return err + } + } + + return client.Invoke(getContext(ctx), ¶ms) + }, + } +} diff --git a/internal/mock/api_backup.gen.go b/internal/mock/api_backup.gen.go index e3dcee4..0beb9d6 100644 --- a/internal/mock/api_backup.gen.go +++ b/internal/mock/api_backup.gen.go @@ -170,31 +170,3 @@ func (mr *MockBackupApiMockRecorder) GetBackupShardIdExecuteWithHttpInfo(arg0 in mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBackupShardIdExecuteWithHttpInfo", reflect.TypeOf((*MockBackupApi)(nil).GetBackupShardIdExecuteWithHttpInfo), arg0) } - -// OnlyCloud mocks base method. -func (m *MockBackupApi) OnlyCloud() api.BackupApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.BackupApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockBackupApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockBackupApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockBackupApi) OnlyOSS() api.BackupApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.BackupApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockBackupApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockBackupApi)(nil).OnlyOSS)) -} diff --git a/internal/mock/api_bucket_schemas.gen.go b/internal/mock/api_bucket_schemas.gen.go index 699c680..eff2d17 100644 --- a/internal/mock/api_bucket_schemas.gen.go +++ b/internal/mock/api_bucket_schemas.gen.go @@ -171,34 +171,6 @@ func (mr *MockBucketSchemasApiMockRecorder) GetMeasurementSchemasExecuteWithHttp return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMeasurementSchemasExecuteWithHttpInfo", reflect.TypeOf((*MockBucketSchemasApi)(nil).GetMeasurementSchemasExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockBucketSchemasApi) OnlyCloud() api.BucketSchemasApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.BucketSchemasApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockBucketSchemasApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockBucketSchemasApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockBucketSchemasApi) OnlyOSS() api.BucketSchemasApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.BucketSchemasApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockBucketSchemasApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockBucketSchemasApi)(nil).OnlyOSS)) -} - // UpdateMeasurementSchema mocks base method. func (m *MockBucketSchemasApi) UpdateMeasurementSchema(arg0 context.Context, arg1, arg2 string) api.ApiUpdateMeasurementSchemaRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_buckets.gen.go b/internal/mock/api_buckets.gen.go index 0d9b3a0..fc518f4 100644 --- a/internal/mock/api_buckets.gen.go +++ b/internal/mock/api_buckets.gen.go @@ -169,34 +169,6 @@ func (mr *MockBucketsApiMockRecorder) GetBucketsIDExecuteWithHttpInfo(arg0 inter return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBucketsIDExecuteWithHttpInfo", reflect.TypeOf((*MockBucketsApi)(nil).GetBucketsIDExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockBucketsApi) OnlyCloud() api.BucketsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.BucketsApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockBucketsApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockBucketsApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockBucketsApi) OnlyOSS() api.BucketsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.BucketsApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockBucketsApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockBucketsApi)(nil).OnlyOSS)) -} - // PatchBucketsID mocks base method. func (m *MockBucketsApi) PatchBucketsID(arg0 context.Context, arg1 string) api.ApiPatchBucketsIDRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_delete.gen.go b/internal/mock/api_delete.gen.go index c1202c4..0b00895 100644 --- a/internal/mock/api_delete.gen.go +++ b/internal/mock/api_delete.gen.go @@ -36,34 +36,6 @@ func (m *MockDeleteApi) EXPECT() *MockDeleteApiMockRecorder { return m.recorder } -// OnlyCloud mocks base method. -func (m *MockDeleteApi) OnlyCloud() api.DeleteApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.DeleteApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockDeleteApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockDeleteApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockDeleteApi) OnlyOSS() api.DeleteApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.DeleteApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockDeleteApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockDeleteApi)(nil).OnlyOSS)) -} - // PostDelete mocks base method. func (m *MockDeleteApi) PostDelete(arg0 context.Context) api.ApiPostDeleteRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_health.gen.go b/internal/mock/api_health.gen.go index f34d7f6..b44b7db 100644 --- a/internal/mock/api_health.gen.go +++ b/internal/mock/api_health.gen.go @@ -80,31 +80,3 @@ func (mr *MockHealthApiMockRecorder) GetHealthExecuteWithHttpInfo(arg0 interface mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHealthExecuteWithHttpInfo", reflect.TypeOf((*MockHealthApi)(nil).GetHealthExecuteWithHttpInfo), arg0) } - -// OnlyCloud mocks base method. -func (m *MockHealthApi) OnlyCloud() api.HealthApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.HealthApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockHealthApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockHealthApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockHealthApi) OnlyOSS() api.HealthApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.HealthApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockHealthApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockHealthApi)(nil).OnlyOSS)) -} diff --git a/internal/mock/api_invocable_scripts.gen.go b/internal/mock/api_invocable_scripts.gen.go new file mode 100644 index 0000000..948cd01 --- /dev/null +++ b/internal/mock/api_invocable_scripts.gen.go @@ -0,0 +1,305 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/influxdata/influx-cli/v2/api (interfaces: InvocableScriptsApi) + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + http "net/http" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + api "github.com/influxdata/influx-cli/v2/api" +) + +// MockInvocableScriptsApi is a mock of InvocableScriptsApi interface. +type MockInvocableScriptsApi struct { + ctrl *gomock.Controller + recorder *MockInvocableScriptsApiMockRecorder +} + +// MockInvocableScriptsApiMockRecorder is the mock recorder for MockInvocableScriptsApi. +type MockInvocableScriptsApiMockRecorder struct { + mock *MockInvocableScriptsApi +} + +// NewMockInvocableScriptsApi creates a new mock instance. +func NewMockInvocableScriptsApi(ctrl *gomock.Controller) *MockInvocableScriptsApi { + mock := &MockInvocableScriptsApi{ctrl: ctrl} + mock.recorder = &MockInvocableScriptsApiMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockInvocableScriptsApi) EXPECT() *MockInvocableScriptsApiMockRecorder { + return m.recorder +} + +// DeleteScriptsID mocks base method. +func (m *MockInvocableScriptsApi) DeleteScriptsID(arg0 context.Context, arg1 string) api.ApiDeleteScriptsIDRequest { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteScriptsID", arg0, arg1) + ret0, _ := ret[0].(api.ApiDeleteScriptsIDRequest) + return ret0 +} + +// DeleteScriptsID indicates an expected call of DeleteScriptsID. +func (mr *MockInvocableScriptsApiMockRecorder) DeleteScriptsID(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteScriptsID", reflect.TypeOf((*MockInvocableScriptsApi)(nil).DeleteScriptsID), arg0, arg1) +} + +// DeleteScriptsIDExecute mocks base method. +func (m *MockInvocableScriptsApi) DeleteScriptsIDExecute(arg0 api.ApiDeleteScriptsIDRequest) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteScriptsIDExecute", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteScriptsIDExecute indicates an expected call of DeleteScriptsIDExecute. +func (mr *MockInvocableScriptsApiMockRecorder) DeleteScriptsIDExecute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteScriptsIDExecute", reflect.TypeOf((*MockInvocableScriptsApi)(nil).DeleteScriptsIDExecute), arg0) +} + +// DeleteScriptsIDExecuteWithHttpInfo mocks base method. +func (m *MockInvocableScriptsApi) DeleteScriptsIDExecuteWithHttpInfo(arg0 api.ApiDeleteScriptsIDRequest) (*http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteScriptsIDExecuteWithHttpInfo", arg0) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteScriptsIDExecuteWithHttpInfo indicates an expected call of DeleteScriptsIDExecuteWithHttpInfo. +func (mr *MockInvocableScriptsApiMockRecorder) DeleteScriptsIDExecuteWithHttpInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteScriptsIDExecuteWithHttpInfo", reflect.TypeOf((*MockInvocableScriptsApi)(nil).DeleteScriptsIDExecuteWithHttpInfo), arg0) +} + +// GetScripts mocks base method. +func (m *MockInvocableScriptsApi) GetScripts(arg0 context.Context) api.ApiGetScriptsRequest { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetScripts", arg0) + ret0, _ := ret[0].(api.ApiGetScriptsRequest) + return ret0 +} + +// GetScripts indicates an expected call of GetScripts. +func (mr *MockInvocableScriptsApiMockRecorder) GetScripts(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScripts", reflect.TypeOf((*MockInvocableScriptsApi)(nil).GetScripts), arg0) +} + +// GetScriptsExecute mocks base method. +func (m *MockInvocableScriptsApi) GetScriptsExecute(arg0 api.ApiGetScriptsRequest) (api.Scripts, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetScriptsExecute", arg0) + ret0, _ := ret[0].(api.Scripts) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetScriptsExecute indicates an expected call of GetScriptsExecute. +func (mr *MockInvocableScriptsApiMockRecorder) GetScriptsExecute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScriptsExecute", reflect.TypeOf((*MockInvocableScriptsApi)(nil).GetScriptsExecute), arg0) +} + +// GetScriptsExecuteWithHttpInfo mocks base method. +func (m *MockInvocableScriptsApi) GetScriptsExecuteWithHttpInfo(arg0 api.ApiGetScriptsRequest) (api.Scripts, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetScriptsExecuteWithHttpInfo", arg0) + ret0, _ := ret[0].(api.Scripts) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetScriptsExecuteWithHttpInfo indicates an expected call of GetScriptsExecuteWithHttpInfo. +func (mr *MockInvocableScriptsApiMockRecorder) GetScriptsExecuteWithHttpInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScriptsExecuteWithHttpInfo", reflect.TypeOf((*MockInvocableScriptsApi)(nil).GetScriptsExecuteWithHttpInfo), arg0) +} + +// GetScriptsID mocks base method. +func (m *MockInvocableScriptsApi) GetScriptsID(arg0 context.Context, arg1 string) api.ApiGetScriptsIDRequest { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetScriptsID", arg0, arg1) + ret0, _ := ret[0].(api.ApiGetScriptsIDRequest) + return ret0 +} + +// GetScriptsID indicates an expected call of GetScriptsID. +func (mr *MockInvocableScriptsApiMockRecorder) GetScriptsID(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScriptsID", reflect.TypeOf((*MockInvocableScriptsApi)(nil).GetScriptsID), arg0, arg1) +} + +// GetScriptsIDExecute mocks base method. +func (m *MockInvocableScriptsApi) GetScriptsIDExecute(arg0 api.ApiGetScriptsIDRequest) (api.Script, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetScriptsIDExecute", arg0) + ret0, _ := ret[0].(api.Script) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetScriptsIDExecute indicates an expected call of GetScriptsIDExecute. +func (mr *MockInvocableScriptsApiMockRecorder) GetScriptsIDExecute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScriptsIDExecute", reflect.TypeOf((*MockInvocableScriptsApi)(nil).GetScriptsIDExecute), arg0) +} + +// GetScriptsIDExecuteWithHttpInfo mocks base method. +func (m *MockInvocableScriptsApi) GetScriptsIDExecuteWithHttpInfo(arg0 api.ApiGetScriptsIDRequest) (api.Script, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetScriptsIDExecuteWithHttpInfo", arg0) + ret0, _ := ret[0].(api.Script) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetScriptsIDExecuteWithHttpInfo indicates an expected call of GetScriptsIDExecuteWithHttpInfo. +func (mr *MockInvocableScriptsApiMockRecorder) GetScriptsIDExecuteWithHttpInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScriptsIDExecuteWithHttpInfo", reflect.TypeOf((*MockInvocableScriptsApi)(nil).GetScriptsIDExecuteWithHttpInfo), arg0) +} + +// PatchScriptsID mocks base method. +func (m *MockInvocableScriptsApi) PatchScriptsID(arg0 context.Context, arg1 string) api.ApiPatchScriptsIDRequest { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PatchScriptsID", arg0, arg1) + ret0, _ := ret[0].(api.ApiPatchScriptsIDRequest) + return ret0 +} + +// PatchScriptsID indicates an expected call of PatchScriptsID. +func (mr *MockInvocableScriptsApiMockRecorder) PatchScriptsID(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchScriptsID", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PatchScriptsID), arg0, arg1) +} + +// PatchScriptsIDExecute mocks base method. +func (m *MockInvocableScriptsApi) PatchScriptsIDExecute(arg0 api.ApiPatchScriptsIDRequest) (api.Script, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PatchScriptsIDExecute", arg0) + ret0, _ := ret[0].(api.Script) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PatchScriptsIDExecute indicates an expected call of PatchScriptsIDExecute. +func (mr *MockInvocableScriptsApiMockRecorder) PatchScriptsIDExecute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchScriptsIDExecute", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PatchScriptsIDExecute), arg0) +} + +// PatchScriptsIDExecuteWithHttpInfo mocks base method. +func (m *MockInvocableScriptsApi) PatchScriptsIDExecuteWithHttpInfo(arg0 api.ApiPatchScriptsIDRequest) (api.Script, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PatchScriptsIDExecuteWithHttpInfo", arg0) + ret0, _ := ret[0].(api.Script) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// PatchScriptsIDExecuteWithHttpInfo indicates an expected call of PatchScriptsIDExecuteWithHttpInfo. +func (mr *MockInvocableScriptsApiMockRecorder) PatchScriptsIDExecuteWithHttpInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PatchScriptsIDExecuteWithHttpInfo", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PatchScriptsIDExecuteWithHttpInfo), arg0) +} + +// PostScripts mocks base method. +func (m *MockInvocableScriptsApi) PostScripts(arg0 context.Context) api.ApiPostScriptsRequest { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostScripts", arg0) + ret0, _ := ret[0].(api.ApiPostScriptsRequest) + return ret0 +} + +// PostScripts indicates an expected call of PostScripts. +func (mr *MockInvocableScriptsApiMockRecorder) PostScripts(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostScripts", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PostScripts), arg0) +} + +// PostScriptsExecute mocks base method. +func (m *MockInvocableScriptsApi) PostScriptsExecute(arg0 api.ApiPostScriptsRequest) (api.Script, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostScriptsExecute", arg0) + ret0, _ := ret[0].(api.Script) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PostScriptsExecute indicates an expected call of PostScriptsExecute. +func (mr *MockInvocableScriptsApiMockRecorder) PostScriptsExecute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostScriptsExecute", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PostScriptsExecute), arg0) +} + +// PostScriptsExecuteWithHttpInfo mocks base method. +func (m *MockInvocableScriptsApi) PostScriptsExecuteWithHttpInfo(arg0 api.ApiPostScriptsRequest) (api.Script, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostScriptsExecuteWithHttpInfo", arg0) + ret0, _ := ret[0].(api.Script) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// PostScriptsExecuteWithHttpInfo indicates an expected call of PostScriptsExecuteWithHttpInfo. +func (mr *MockInvocableScriptsApiMockRecorder) PostScriptsExecuteWithHttpInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostScriptsExecuteWithHttpInfo", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PostScriptsExecuteWithHttpInfo), arg0) +} + +// PostScriptsIDInvoke mocks base method. +func (m *MockInvocableScriptsApi) PostScriptsIDInvoke(arg0 context.Context, arg1 string) api.ApiPostScriptsIDInvokeRequest { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostScriptsIDInvoke", arg0, arg1) + ret0, _ := ret[0].(api.ApiPostScriptsIDInvokeRequest) + return ret0 +} + +// PostScriptsIDInvoke indicates an expected call of PostScriptsIDInvoke. +func (mr *MockInvocableScriptsApiMockRecorder) PostScriptsIDInvoke(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostScriptsIDInvoke", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PostScriptsIDInvoke), arg0, arg1) +} + +// PostScriptsIDInvokeExecute mocks base method. +func (m *MockInvocableScriptsApi) PostScriptsIDInvokeExecute(arg0 api.ApiPostScriptsIDInvokeRequest) (*http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostScriptsIDInvokeExecute", arg0) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PostScriptsIDInvokeExecute indicates an expected call of PostScriptsIDInvokeExecute. +func (mr *MockInvocableScriptsApiMockRecorder) PostScriptsIDInvokeExecute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostScriptsIDInvokeExecute", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PostScriptsIDInvokeExecute), arg0) +} + +// PostScriptsIDInvokeExecuteWithHttpInfo mocks base method. +func (m *MockInvocableScriptsApi) PostScriptsIDInvokeExecuteWithHttpInfo(arg0 api.ApiPostScriptsIDInvokeRequest) (*http.Response, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostScriptsIDInvokeExecuteWithHttpInfo", arg0) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// PostScriptsIDInvokeExecuteWithHttpInfo indicates an expected call of PostScriptsIDInvokeExecuteWithHttpInfo. +func (mr *MockInvocableScriptsApiMockRecorder) PostScriptsIDInvokeExecuteWithHttpInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostScriptsIDInvokeExecuteWithHttpInfo", reflect.TypeOf((*MockInvocableScriptsApi)(nil).PostScriptsIDInvokeExecuteWithHttpInfo), arg0) +} diff --git a/internal/mock/api_organizations.gen.go b/internal/mock/api_organizations.gen.go index c0cfa74..0daf328 100644 --- a/internal/mock/api_organizations.gen.go +++ b/internal/mock/api_organizations.gen.go @@ -257,34 +257,6 @@ func (mr *MockOrganizationsApiMockRecorder) GetOrgsIDMembersExecuteWithHttpInfo( return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrgsIDMembersExecuteWithHttpInfo", reflect.TypeOf((*MockOrganizationsApi)(nil).GetOrgsIDMembersExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockOrganizationsApi) OnlyCloud() api.OrganizationsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.OrganizationsApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockOrganizationsApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockOrganizationsApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockOrganizationsApi) OnlyOSS() api.OrganizationsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.OrganizationsApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockOrganizationsApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockOrganizationsApi)(nil).OnlyOSS)) -} - // PatchOrgsID mocks base method. func (m *MockOrganizationsApi) PatchOrgsID(arg0 context.Context, arg1 string) api.ApiPatchOrgsIDRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_query.gen.go b/internal/mock/api_query.gen.go index 46f46cd..07ad316 100644 --- a/internal/mock/api_query.gen.go +++ b/internal/mock/api_query.gen.go @@ -36,34 +36,6 @@ func (m *MockQueryApi) EXPECT() *MockQueryApiMockRecorder { return m.recorder } -// OnlyCloud mocks base method. -func (m *MockQueryApi) OnlyCloud() api.QueryApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.QueryApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockQueryApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockQueryApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockQueryApi) OnlyOSS() api.QueryApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.QueryApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockQueryApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockQueryApi)(nil).OnlyOSS)) -} - // PostQuery mocks base method. func (m *MockQueryApi) PostQuery(arg0 context.Context) api.ApiPostQueryRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_secret.gen.go b/internal/mock/api_secret.gen.go index f12c49c..38659f9 100644 --- a/internal/mock/api_secret.gen.go +++ b/internal/mock/api_secret.gen.go @@ -81,34 +81,6 @@ func (mr *MockSecretsApiMockRecorder) GetOrgsIDSecretsExecuteWithHttpInfo(arg0 i return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrgsIDSecretsExecuteWithHttpInfo", reflect.TypeOf((*MockSecretsApi)(nil).GetOrgsIDSecretsExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockSecretsApi) OnlyCloud() api.SecretsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.SecretsApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockSecretsApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockSecretsApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockSecretsApi) OnlyOSS() api.SecretsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.SecretsApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockSecretsApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockSecretsApi)(nil).OnlyOSS)) -} - // PatchOrgsIDSecrets mocks base method. func (m *MockSecretsApi) PatchOrgsIDSecrets(arg0 context.Context, arg1 string) api.ApiPatchOrgsIDSecretsRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_setup.gen.go b/internal/mock/api_setup.gen.go index 789c0a0..b4960d7 100644 --- a/internal/mock/api_setup.gen.go +++ b/internal/mock/api_setup.gen.go @@ -81,34 +81,6 @@ func (mr *MockSetupApiMockRecorder) GetSetupExecuteWithHttpInfo(arg0 interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSetupExecuteWithHttpInfo", reflect.TypeOf((*MockSetupApi)(nil).GetSetupExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockSetupApi) OnlyCloud() api.SetupApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.SetupApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockSetupApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockSetupApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockSetupApi) OnlyOSS() api.SetupApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.SetupApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockSetupApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockSetupApi)(nil).OnlyOSS)) -} - // PostSetup mocks base method. func (m *MockSetupApi) PostSetup(arg0 context.Context) api.ApiPostSetupRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_users.gen.go b/internal/mock/api_users.gen.go index f3172e2..de562b7 100644 --- a/internal/mock/api_users.gen.go +++ b/internal/mock/api_users.gen.go @@ -169,34 +169,6 @@ func (mr *MockUsersApiMockRecorder) GetUsersIDExecuteWithHttpInfo(arg0 interface return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUsersIDExecuteWithHttpInfo", reflect.TypeOf((*MockUsersApi)(nil).GetUsersIDExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockUsersApi) OnlyCloud() api.UsersApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.UsersApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockUsersApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockUsersApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockUsersApi) OnlyOSS() api.UsersApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.UsersApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockUsersApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockUsersApi)(nil).OnlyOSS)) -} - // PatchUsersID mocks base method. func (m *MockUsersApi) PatchUsersID(arg0 context.Context, arg1 string) api.ApiPatchUsersIDRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_v1dbrps.gen.go b/internal/mock/api_v1dbrps.gen.go index 4996aad..5209e9d 100644 --- a/internal/mock/api_v1dbrps.gen.go +++ b/internal/mock/api_v1dbrps.gen.go @@ -169,34 +169,6 @@ func (mr *MockDBRPsApiMockRecorder) GetDBRPsIDExecuteWithHttpInfo(arg0 interface return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDBRPsIDExecuteWithHttpInfo", reflect.TypeOf((*MockDBRPsApi)(nil).GetDBRPsIDExecuteWithHttpInfo), arg0) } -// OnlyCloud mocks base method. -func (m *MockDBRPsApi) OnlyCloud() api.DBRPsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.DBRPsApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockDBRPsApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockDBRPsApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockDBRPsApi) OnlyOSS() api.DBRPsApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.DBRPsApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockDBRPsApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockDBRPsApi)(nil).OnlyOSS)) -} - // PatchDBRPID mocks base method. func (m *MockDBRPsApi) PatchDBRPID(arg0 context.Context, arg1 string) api.ApiPatchDBRPIDRequest { m.ctrl.T.Helper() diff --git a/internal/mock/api_write.gen.go b/internal/mock/api_write.gen.go index f94110c..885c589 100644 --- a/internal/mock/api_write.gen.go +++ b/internal/mock/api_write.gen.go @@ -36,34 +36,6 @@ func (m *MockWriteApi) EXPECT() *MockWriteApiMockRecorder { return m.recorder } -// OnlyCloud mocks base method. -func (m *MockWriteApi) OnlyCloud() api.WriteApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyCloud") - ret0, _ := ret[0].(api.WriteApi) - return ret0 -} - -// OnlyCloud indicates an expected call of OnlyCloud. -func (mr *MockWriteApiMockRecorder) OnlyCloud() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyCloud", reflect.TypeOf((*MockWriteApi)(nil).OnlyCloud)) -} - -// OnlyOSS mocks base method. -func (m *MockWriteApi) OnlyOSS() api.WriteApi { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnlyOSS") - ret0, _ := ret[0].(api.WriteApi) - return ret0 -} - -// OnlyOSS indicates an expected call of OnlyOSS. -func (mr *MockWriteApiMockRecorder) OnlyOSS() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnlyOSS", reflect.TypeOf((*MockWriteApi)(nil).OnlyOSS)) -} - // PostWrite mocks base method. func (m *MockWriteApi) PostWrite(arg0 context.Context) api.ApiPostWriteRequest { m.ctrl.T.Helper() diff --git a/internal/mock/gen.go b/internal/mock/gen.go index f259318..b413644 100644 --- a/internal/mock/gen.go +++ b/internal/mock/gen.go @@ -13,6 +13,7 @@ package mock //go:generate go run github.com/golang/mock/mockgen -package mock -destination api_backup.gen.go github.com/influxdata/influx-cli/v2/api BackupApi //go:generate go run github.com/golang/mock/mockgen -package mock -destination api_secret.gen.go github.com/influxdata/influx-cli/v2/api SecretsApi //go:generate go run github.com/golang/mock/mockgen -package mock -destination api_v1dbrps.gen.go github.com/influxdata/influx-cli/v2/api DBRPsApi +//go:generate go run github.com/golang/mock/mockgen -package mock -destination api_invocable_scripts.gen.go github.com/influxdata/influx-cli/v2/api InvocableScriptsApi // Other mocks //go:generate go run github.com/golang/mock/mockgen -package mock -destination config.gen.go -mock_names Service=MockConfigService github.com/influxdata/influx-cli/v2/config Service