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
This commit is contained in:
Andrew Depke
2022-06-22 14:08:55 -06:00
committed by GitHub
parent a68106ee88
commit 760f07ed9e
31 changed files with 3207 additions and 337 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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)

View File

@ -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"

View File

@ -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'

View File

@ -0,0 +1,4 @@
type: object
properties:
params:
type: object

View File

@ -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
}

383
api/model_script.gen.go Normal file
View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

113
api/model_scripts.gen.go Normal file
View File

@ -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)
}

172
clients/script/script.go Normal file
View File

@ -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: &params.Name,
Description: &params.Description,
Script: &params.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: &params.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)
}

View File

@ -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(), &params))
}
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(), &params))
}
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))
}

View File

@ -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)

277
cmd/influx/scripts.go Normal file
View File

@ -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: &params.Limit,
},
&cli.IntFlag{
Name: "offset, o",
Usage: "The offset for pagination",
Destination: &params.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), &params)
},
}
}
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: &params.Description,
},
&cli.StringFlag{
Name: "language, l",
Usage: "What language the script is written in",
Destination: &params.Language,
},
&cli.StringFlag{
Name: "name, n",
Usage: "Name of the script",
Destination: &params.Name,
},
&cli.StringFlag{
Name: "script, s",
Usage: "Contents of the script to be executed",
Destination: &params.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), &params)
},
}
}
func newScriptsDeleteCmd() cli.Command {
var params script.DeleteParams
flags := []cli.Flag{
&cli.StringFlag{
Name: "scriptID, i",
Usage: "Script identifier",
Destination: &params.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), &params)
},
}
}
func newScriptsRetrieveCmd() cli.Command {
var params script.RetrieveParams
flags := []cli.Flag{
&cli.StringFlag{
Name: "scriptID, i",
Usage: "Script identifier",
Destination: &params.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), &params)
},
}
}
func newScriptsUpdateCmd() cli.Command {
var params script.UpdateParams
flags := []cli.Flag{
&cli.StringFlag{
Name: "scriptID, i",
Usage: "Script identifier",
Destination: &params.ScriptID,
},
&cli.StringFlag{
Name: "description, d",
Usage: "New script description",
Destination: &params.Description,
},
&cli.StringFlag{
Name: "name, n",
Usage: "New script name",
Destination: &params.Name,
},
&cli.StringFlag{
Name: "script, s",
Usage: "New script contents",
Destination: &params.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), &params)
},
}
}
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: &params.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(&params.Params); err != nil {
return err
}
}
return client.Invoke(getContext(ctx), &params)
},
}
}

View File

@ -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))
}

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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))
}

View File

@ -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)
}

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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