feat: updated openapi to support tasks containing scripts (#430)

This commit is contained in:
Andrew Depke
2022-07-27 15:21:11 -06:00
committed by GitHub
parent d470527e43
commit 0de05ed3e4
14 changed files with 802 additions and 228 deletions

View File

@ -49,6 +49,26 @@ type InvokableScriptsApi interface {
/* /*
* GetScripts List scripts * GetScripts List scripts
* Retrieves a list of [scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/).
#### Limitations
- Paging with an `offset` greater than the number of records will result in
an empty response--for example:
The following request is paging to the 50th record, but the user has only
created two scripts.
```sh
$ curl --request GET "INFLUX_URL/api/v2/scripts?limit=1&offset=50"
$ {"scripts":[]}
```
#### Related Guides
- [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetScriptsRequest * @return ApiGetScriptsRequest
*/ */
@ -117,6 +137,14 @@ type InvokableScriptsApi interface {
/* /*
* PostScripts Create a script * PostScripts Create a script
* Creates an [invokable script](https://docs.influxdata.com/resources/videos/api-invokable-scripts/)
and returns the created script.
#### Related Guides
- [Invokable scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/).
- [Creating custom InfluxDB endpoints](https://docs.influxdata.com/resources/videos/api-invokable-scripts/).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostScriptsRequest * @return ApiPostScriptsRequest
*/ */
@ -327,9 +355,29 @@ func (r ApiGetScriptsRequest) ExecuteWithHttpInfo() (Scripts, *_nethttp.Response
/* /*
* GetScripts List scripts * GetScripts List scripts
* Retrieves a list of [scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/).
#### Limitations
- Paging with an `offset` greater than the number of records will result in
an empty response--for example:
The following request is paging to the 50th record, but the user has only
created two scripts.
```sh
$ curl --request GET "INFLUX_URL/api/v2/scripts?limit=1&offset=50"
$ {"scripts":[]}
```
#### Related Guides
- [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetScriptsRequest * @return ApiGetScriptsRequest
*/ */
func (a *InvokableScriptsApiService) GetScripts(ctx _context.Context) ApiGetScriptsRequest { func (a *InvokableScriptsApiService) GetScripts(ctx _context.Context) ApiGetScriptsRequest {
return ApiGetScriptsRequest{ return ApiGetScriptsRequest{
ApiService: a, ApiService: a,
@ -425,6 +473,17 @@ func (a *InvokableScriptsApiService) GetScriptsExecuteWithHttpInfo(r ApiGetScrip
} }
newErr.body = localVarBody newErr.body = localVarBody
newErr.error = localVarHTTPResponse.Status newErr.error = localVarHTTPResponse.Status
if localVarHTTPResponse.StatusCode == 400 {
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
}
var v Error var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil { if err != nil {
@ -803,9 +862,17 @@ func (r ApiPostScriptsRequest) ExecuteWithHttpInfo() (Script, *_nethttp.Response
/* /*
* PostScripts Create a script * PostScripts Create a script
* Creates an [invokable script](https://docs.influxdata.com/resources/videos/api-invokable-scripts/)
and returns the created script.
#### Related Guides
- [Invokable scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/).
- [Creating custom InfluxDB endpoints](https://docs.influxdata.com/resources/videos/api-invokable-scripts/).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostScriptsRequest * @return ApiPostScriptsRequest
*/ */
func (a *InvokableScriptsApiService) PostScripts(ctx _context.Context) ApiPostScriptsRequest { func (a *InvokableScriptsApiService) PostScripts(ctx _context.Context) ApiPostScriptsRequest {
return ApiPostScriptsRequest{ return ApiPostScriptsRequest{
ApiService: a, ApiService: a,
@ -900,6 +967,28 @@ func (a *InvokableScriptsApiService) PostScriptsExecuteWithHttpInfo(r ApiPostScr
} }
newErr.body = localVarBody newErr.body = localVarBody
newErr.error = localVarHTTPResponse.Status newErr.error = localVarHTTPResponse.Status
if localVarHTTPResponse.StatusCode == 400 {
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
}
if localVarHTTPResponse.StatusCode == 422 {
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
}
var v Error var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil { if err != nil {

View File

@ -29,7 +29,13 @@ type TasksApi interface {
/* /*
* DeleteTasksID Delete a task * DeleteTasksID Delete a task
* Deletes a task and all associated records * Deletes a task and associated records.
Use this endpoint to delete a task and all associated records (task runs, logs, and labels).
Once the task is deleted, InfluxDB cancels all scheduled runs of the task.
If you want to disable a task instead of delete it, [update the task status to `inactive`](#operation/PatchTasksID).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The ID of the task to delete. * @param taskID The ID of the task to delete.
* @return ApiDeleteTasksIDRequest * @return ApiDeleteTasksIDRequest
@ -49,10 +55,18 @@ type TasksApi interface {
DeleteTasksIDExecuteWithHttpInfo(r ApiDeleteTasksIDRequest) (*_nethttp.Response, error) DeleteTasksIDExecuteWithHttpInfo(r ApiDeleteTasksIDRequest) (*_nethttp.Response, error)
/* /*
* DeleteTasksIDRunsID Cancel a running task. #### InfluxDB Cloud - Doesn't support this operation. * DeleteTasksIDRunsID Cancel a running task
* Cancels a running [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task).
Use this endpoint with InfluxDB OSS to cancel a running task.
#### InfluxDB Cloud
- Doesn't support this operation.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @param runID The run ID. * @param runID The ID of the task run to cancel.
* @return ApiDeleteTasksIDRunsIDRequest * @return ApiDeleteTasksIDRunsIDRequest
*/ */
DeleteTasksIDRunsID(ctx _context.Context, taskID string, runID string) ApiDeleteTasksIDRunsIDRequest DeleteTasksIDRunsID(ctx _context.Context, taskID string, runID string) ApiDeleteTasksIDRunsIDRequest
@ -71,6 +85,11 @@ type TasksApi interface {
/* /*
* GetTasks List all tasks * GetTasks List all tasks
* Retrieves a list of [tasks]({{% INFLUXDB_DOCS_URL %}}/process-data/).
To limit which tasks are returned, pass query parameters in your request.
If no query parameters are passed, InfluxDB returns all tasks up to the default `limit`.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetTasksRequest * @return ApiGetTasksRequest
*/ */
@ -92,6 +111,9 @@ type TasksApi interface {
/* /*
* GetTasksID Retrieve a task * GetTasksID Retrieve a task
* Retrieves a [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task)
by task ID.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @return ApiGetTasksIDRequest * @return ApiGetTasksIDRequest
@ -114,6 +136,14 @@ type TasksApi interface {
/* /*
* GetTasksIDLogs Retrieve all logs for a task * GetTasksIDLogs Retrieve all logs for a task
* Retrieves a list of all logs for a [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task).
When an InfluxDB task runs, a “run” record is created in the task’s history.
Logs associated with each run provide relevant log messages, timestamps, and the exit status of the run attempt.
Use this endpoint to retrieve only the log events for a task,
without additional task metadata.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @return ApiGetTasksIDLogsRequest * @return ApiGetTasksIDLogsRequest
@ -157,7 +187,11 @@ type TasksApi interface {
GetTasksIDRunsExecuteWithHttpInfo(r ApiGetTasksIDRunsRequest) (Runs, *_nethttp.Response, error) GetTasksIDRunsExecuteWithHttpInfo(r ApiGetTasksIDRunsRequest) (Runs, *_nethttp.Response, error)
/* /*
* GetTasksIDRunsID Retrieve a single run for a task. * GetTasksIDRunsID Retrieve a run for a task.
* Retrieves a specific run for a [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task).
Use this endpoint to retrieve detail and logs for a specific task run.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @param runID The run ID. * @param runID The run ID.
@ -204,7 +238,15 @@ type TasksApi interface {
/* /*
* PatchTasksID Update a task * PatchTasksID Update a task
* Update a task. This will cancel all queued runs. * Updates a task and then cancels all scheduled runs of the task.
Use this endpoint to modify task properties (for example: `cron`, `name`, `flux`, `status`).
Once InfluxDB applies the update, it cancels all scheduled runs of the task.
To update a task, pass an object that contains the updated key-value pairs.
To activate or inactivate a task, set the `status` property.
_`"status": "inactive"`_ cancels scheduled runs and prevents manual runs of the task.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @return ApiPatchTasksIDRequest * @return ApiPatchTasksIDRequest
@ -226,7 +268,25 @@ type TasksApi interface {
PatchTasksIDExecuteWithHttpInfo(r ApiPatchTasksIDRequest) (Task, *_nethttp.Response, error) PatchTasksIDExecuteWithHttpInfo(r ApiPatchTasksIDRequest) (Task, *_nethttp.Response, error)
/* /*
* PostTasks Create a new task * PostTasks Create a task
* Creates a [task]({{% INFLUXDB_DOCS_URL %}}/process-data/) and returns the created task.
Use this endpoint to create a scheduled task that runs a Flux script.
In your task, provide one of the following:
- _`flux`_ property with an inline Flux script
- _`scriptID`_ property with an [invokable script](#tag/Invokable-Scripts) ID
#### InfluxDB Cloud
- Requires either _`flux`_ (Flux query) or _`scriptID`_ (invokable script ID) in the task.
#### Related guides
- [Create a task]({{% INFLUXDB_DOCS_URL %}}/process-data/manage-tasks/create-task/).
- [Common tasks]({{% INFLUXDB_DOCS_URL %}}/process-data/common-tasks/)
- [Task configuration options]({{% INFLUXDB_DOCS_URL %}}/process-data/task-options/)
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostTasksRequest * @return ApiPostTasksRequest
*/ */
@ -328,11 +388,17 @@ func (r ApiDeleteTasksIDRequest) ExecuteWithHttpInfo() (*_nethttp.Response, erro
/* /*
* DeleteTasksID Delete a task * DeleteTasksID Delete a task
* Deletes a task and all associated records * Deletes a task and associated records.
Use this endpoint to delete a task and all associated records (task runs, logs, and labels).
Once the task is deleted, InfluxDB cancels all scheduled runs of the task.
If you want to disable a task instead of delete it, [update the task status to `inactive`](#operation/PatchTasksID).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The ID of the task to delete. * @param taskID The ID of the task to delete.
* @return ApiDeleteTasksIDRequest * @return ApiDeleteTasksIDRequest
*/ */
func (a *TasksApiService) DeleteTasksID(ctx _context.Context, taskID string) ApiDeleteTasksIDRequest { func (a *TasksApiService) DeleteTasksID(ctx _context.Context, taskID string) ApiDeleteTasksIDRequest {
return ApiDeleteTasksIDRequest{ return ApiDeleteTasksIDRequest{
ApiService: a, ApiService: a,
@ -479,12 +545,20 @@ func (r ApiDeleteTasksIDRunsIDRequest) ExecuteWithHttpInfo() (*_nethttp.Response
} }
/* /*
* DeleteTasksIDRunsID Cancel a running task. #### InfluxDB Cloud - Doesn't support this operation. * DeleteTasksIDRunsID Cancel a running task
* Cancels a running [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task).
Use this endpoint with InfluxDB OSS to cancel a running task.
#### InfluxDB Cloud
- Doesn't support this operation.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @param runID The run ID. * @param runID The ID of the task run to cancel.
* @return ApiDeleteTasksIDRunsIDRequest * @return ApiDeleteTasksIDRunsIDRequest
*/ */
func (a *TasksApiService) DeleteTasksIDRunsID(ctx _context.Context, taskID string, runID string) ApiDeleteTasksIDRunsIDRequest { func (a *TasksApiService) DeleteTasksIDRunsID(ctx _context.Context, taskID string, runID string) ApiDeleteTasksIDRunsIDRequest {
return ApiDeleteTasksIDRunsIDRequest{ return ApiDeleteTasksIDRunsIDRequest{
ApiService: a, ApiService: a,
@ -614,6 +688,8 @@ type ApiGetTasksRequest struct {
orgID *string orgID *string
status *string status *string
limit *int32 limit *int32
offset *int32
sortBy *string
type_ *string type_ *string
} }
@ -681,6 +757,22 @@ func (r ApiGetTasksRequest) GetLimit() *int32 {
return r.limit return r.limit
} }
func (r ApiGetTasksRequest) Offset(offset int32) ApiGetTasksRequest {
r.offset = &offset
return r
}
func (r ApiGetTasksRequest) GetOffset() *int32 {
return r.offset
}
func (r ApiGetTasksRequest) SortBy(sortBy string) ApiGetTasksRequest {
r.sortBy = &sortBy
return r
}
func (r ApiGetTasksRequest) GetSortBy() *string {
return r.sortBy
}
func (r ApiGetTasksRequest) Type_(type_ string) ApiGetTasksRequest { func (r ApiGetTasksRequest) Type_(type_ string) ApiGetTasksRequest {
r.type_ = &type_ r.type_ = &type_
return r return r
@ -699,9 +791,14 @@ func (r ApiGetTasksRequest) ExecuteWithHttpInfo() (Tasks, *_nethttp.Response, er
/* /*
* GetTasks List all tasks * GetTasks List all tasks
* Retrieves a list of [tasks]({{% INFLUXDB_DOCS_URL %}}/process-data/).
To limit which tasks are returned, pass query parameters in your request.
If no query parameters are passed, InfluxDB returns all tasks up to the default `limit`.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetTasksRequest * @return ApiGetTasksRequest
*/ */
func (a *TasksApiService) GetTasks(ctx _context.Context) ApiGetTasksRequest { func (a *TasksApiService) GetTasks(ctx _context.Context) ApiGetTasksRequest {
return ApiGetTasksRequest{ return ApiGetTasksRequest{
ApiService: a, ApiService: a,
@ -766,6 +863,12 @@ func (a *TasksApiService) GetTasksExecuteWithHttpInfo(r ApiGetTasksRequest) (Tas
if r.limit != nil { if r.limit != nil {
localVarQueryParams.Add("limit", parameterToString(*r.limit, "")) localVarQueryParams.Add("limit", parameterToString(*r.limit, ""))
} }
if r.offset != nil {
localVarQueryParams.Add("offset", parameterToString(*r.offset, ""))
}
if r.sortBy != nil {
localVarQueryParams.Add("sortBy", parameterToString(*r.sortBy, ""))
}
if r.type_ != nil { if r.type_ != nil {
localVarQueryParams.Add("type", parameterToString(*r.type_, "")) localVarQueryParams.Add("type", parameterToString(*r.type_, ""))
} }
@ -818,6 +921,28 @@ func (a *TasksApiService) GetTasksExecuteWithHttpInfo(r ApiGetTasksRequest) (Tas
} }
newErr.body = localVarBody newErr.body = localVarBody
newErr.error = localVarHTTPResponse.Status newErr.error = localVarHTTPResponse.Status
if localVarHTTPResponse.StatusCode == 401 {
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
}
if localVarHTTPResponse.StatusCode == 500 {
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
}
var v Error var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil { if err != nil {
@ -884,10 +1009,13 @@ func (r ApiGetTasksIDRequest) ExecuteWithHttpInfo() (Task, *_nethttp.Response, e
/* /*
* GetTasksID Retrieve a task * GetTasksID Retrieve a task
* Retrieves a [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task)
by task ID.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @return ApiGetTasksIDRequest * @return ApiGetTasksIDRequest
*/ */
func (a *TasksApiService) GetTasksID(ctx _context.Context, taskID string) ApiGetTasksIDRequest { func (a *TasksApiService) GetTasksID(ctx _context.Context, taskID string) ApiGetTasksIDRequest {
return ApiGetTasksIDRequest{ return ApiGetTasksIDRequest{
ApiService: a, ApiService: a,
@ -982,6 +1110,17 @@ func (a *TasksApiService) GetTasksIDExecuteWithHttpInfo(r ApiGetTasksIDRequest)
} }
newErr.body = localVarBody newErr.body = localVarBody
newErr.error = localVarHTTPResponse.Status newErr.error = localVarHTTPResponse.Status
if localVarHTTPResponse.StatusCode == 400 {
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
}
var v Error var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil { if err != nil {
@ -1048,10 +1187,18 @@ func (r ApiGetTasksIDLogsRequest) ExecuteWithHttpInfo() (Logs, *_nethttp.Respons
/* /*
* GetTasksIDLogs Retrieve all logs for a task * GetTasksIDLogs Retrieve all logs for a task
* Retrieves a list of all logs for a [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task).
When an InfluxDB task runs, a “run” record is created in the task’s history.
Logs associated with each run provide relevant log messages, timestamps, and the exit status of the run attempt.
Use this endpoint to retrieve only the log events for a task,
without additional task metadata.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @return ApiGetTasksIDLogsRequest * @return ApiGetTasksIDLogsRequest
*/ */
func (a *TasksApiService) GetTasksIDLogs(ctx _context.Context, taskID string) ApiGetTasksIDLogsRequest { func (a *TasksApiService) GetTasksIDLogs(ctx _context.Context, taskID string) ApiGetTasksIDLogsRequest {
return ApiGetTasksIDLogsRequest{ return ApiGetTasksIDLogsRequest{
ApiService: a, ApiService: a,
@ -1432,12 +1579,16 @@ func (r ApiGetTasksIDRunsIDRequest) ExecuteWithHttpInfo() (Run, *_nethttp.Respon
} }
/* /*
* GetTasksIDRunsID Retrieve a single run for a task. * GetTasksIDRunsID Retrieve a run for a task.
* Retrieves a specific run for a [task]({{% INFLUXDB_DOCS_URL %}}/reference/glossary/#task).
Use this endpoint to retrieve detail and logs for a specific task run.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @param runID The run ID. * @param runID The run ID.
* @return ApiGetTasksIDRunsIDRequest * @return ApiGetTasksIDRunsIDRequest
*/ */
func (a *TasksApiService) GetTasksIDRunsID(ctx _context.Context, taskID string, runID string) ApiGetTasksIDRunsIDRequest { func (a *TasksApiService) GetTasksIDRunsID(ctx _context.Context, taskID string, runID string) ApiGetTasksIDRunsIDRequest {
return ApiGetTasksIDRunsIDRequest{ return ApiGetTasksIDRunsIDRequest{
ApiService: a, ApiService: a,
@ -1785,11 +1936,19 @@ func (r ApiPatchTasksIDRequest) ExecuteWithHttpInfo() (Task, *_nethttp.Response,
/* /*
* PatchTasksID Update a task * PatchTasksID Update a task
* Update a task. This will cancel all queued runs. * Updates a task and then cancels all scheduled runs of the task.
Use this endpoint to modify task properties (for example: `cron`, `name`, `flux`, `status`).
Once InfluxDB applies the update, it cancels all scheduled runs of the task.
To update a task, pass an object that contains the updated key-value pairs.
To activate or inactivate a task, set the `status` property.
_`"status": "inactive"`_ cancels scheduled runs and prevents manual runs of the task.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param taskID The task ID. * @param taskID The task ID.
* @return ApiPatchTasksIDRequest * @return ApiPatchTasksIDRequest
*/ */
func (a *TasksApiService) PatchTasksID(ctx _context.Context, taskID string) ApiPatchTasksIDRequest { func (a *TasksApiService) PatchTasksID(ctx _context.Context, taskID string) ApiPatchTasksIDRequest {
return ApiPatchTasksIDRequest{ return ApiPatchTasksIDRequest{
ApiService: a, ApiService: a,
@ -1954,10 +2113,28 @@ func (r ApiPostTasksRequest) ExecuteWithHttpInfo() (Task, *_nethttp.Response, er
} }
/* /*
* PostTasks Create a new task * PostTasks Create a task
* Creates a [task]({{% INFLUXDB_DOCS_URL %}}/process-data/) and returns the created task.
Use this endpoint to create a scheduled task that runs a Flux script.
In your task, provide one of the following:
- _`flux`_ property with an inline Flux script
- _`scriptID`_ property with an [invokable script](#tag/Invokable-Scripts) ID
#### InfluxDB Cloud
- Requires either _`flux`_ (Flux query) or _`scriptID`_ (invokable script ID) in the task.
#### Related guides
- [Create a task]({{% INFLUXDB_DOCS_URL %}}/process-data/manage-tasks/create-task/).
- [Common tasks]({{% INFLUXDB_DOCS_URL %}}/process-data/common-tasks/)
- [Task configuration options]({{% INFLUXDB_DOCS_URL %}}/process-data/task-options/)
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostTasksRequest * @return ApiPostTasksRequest
*/ */
func (a *TasksApiService) PostTasks(ctx _context.Context) ApiPostTasksRequest { func (a *TasksApiService) PostTasks(ctx _context.Context) ApiPostTasksRequest {
return ApiPostTasksRequest{ return ApiPostTasksRequest{
ApiService: a, ApiService: a,

View File

@ -134,6 +134,11 @@ type UsersApi interface {
/* /*
* PostUsersIDPassword Update a password * PostUsersIDPassword Update a password
* #### InfluxDB Cloud
InfluxDB Cloud does not support changing user passwords through the API.
Use the InfluxDB Cloud user interface to update your password.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param userID The user ID. * @param userID The user ID.
* @return ApiPostUsersIDPasswordRequest * @return ApiPostUsersIDPasswordRequest
@ -1060,10 +1065,15 @@ func (r ApiPostUsersIDPasswordRequest) ExecuteWithHttpInfo() (*_nethttp.Response
/* /*
* PostUsersIDPassword Update a password * PostUsersIDPassword Update a password
* #### InfluxDB Cloud
InfluxDB Cloud does not support changing user passwords through the API.
Use the InfluxDB Cloud user interface to update your password.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param userID The user ID. * @param userID The user ID.
* @return ApiPostUsersIDPasswordRequest * @return ApiPostUsersIDPasswordRequest
*/ */
func (a *UsersApiService) PostUsersIDPassword(ctx _context.Context, userID string) ApiPostUsersIDPasswordRequest { func (a *UsersApiService) PostUsersIDPassword(ctx _context.Context, userID string) ApiPostUsersIDPasswordRequest {
return ApiPostUsersIDPasswordRequest{ return ApiPostUsersIDPasswordRequest{
ApiService: a, ApiService: a,

View File

@ -373,17 +373,6 @@ func (a *WriteApiService) PostWriteExecuteWithHttpInfo(r ApiPostWriteRequest) (*
newErr.model = &v newErr.model = &v
return localVarHTTPResponse, newErr return localVarHTTPResponse, newErr
} }
if localVarHTTPResponse.StatusCode == 401 {
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
}
if localVarHTTPResponse.StatusCode == 404 { if localVarHTTPResponse.StatusCode == 404 {
var v Error var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
@ -406,17 +395,6 @@ func (a *WriteApiService) PostWriteExecuteWithHttpInfo(r ApiPostWriteRequest) (*
newErr.model = &v newErr.model = &v
return localVarHTTPResponse, newErr return localVarHTTPResponse, newErr
} }
if localVarHTTPResponse.StatusCode == 500 {
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
}
var v Error var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil { if err != nil {

View File

@ -58,9 +58,9 @@ paths:
/api/v2/delete: /api/v2/delete:
$ref: "./openapi/src/common/paths/delete.yml" $ref: "./openapi/src/common/paths/delete.yml"
/api/v2/tasks: /api/v2/tasks:
$ref: "./openapi/src/common/paths/tasks.yml" $ref: "./openapi/src/cloud/paths/tasks.yml"
/api/v2/tasks/{taskID}: /api/v2/tasks/{taskID}:
$ref: "./openapi/src/common/paths/tasks_taskID.yml" $ref: "./openapi/src/cloud/paths/tasks_taskID.yml"
/api/v2/tasks/{taskID}/runs: /api/v2/tasks/{taskID}/runs:
$ref: "./openapi/src/common/paths/tasks_taskID_runs.yml" $ref: "./openapi/src/common/paths/tasks_taskID_runs.yml"
/api/v2/tasks/{taskID}/runs/{runID}: /api/v2/tasks/{taskID}/runs/{runID}:
@ -252,15 +252,15 @@ components:
DeletePredicateRequest: DeletePredicateRequest:
$ref: "./openapi/src/common/schemas/DeletePredicateRequest.yml" $ref: "./openapi/src/common/schemas/DeletePredicateRequest.yml"
Tasks: Tasks:
$ref: "./openapi/src/common/schemas/Tasks.yml" $ref: "./openapi/src/cloud/schemas/Tasks.yml"
Task: Task:
$ref: "./openapi/src/common/schemas/Task.yml" $ref: "./openapi/src/cloud/schemas/Task.yml"
TaskCreateRequest: TaskCreateRequest:
$ref: "./openapi/src/common/schemas/TaskCreateRequest.yml" $ref: "./openapi/src/cloud/schemas/TaskCreateRequest.yml"
TaskStatusType: TaskStatusType:
$ref: "./openapi/src/common/schemas/TaskStatusType.yml" $ref: "./openapi/src/common/schemas/TaskStatusType.yml"
TaskUpdateRequest: TaskUpdateRequest:
$ref: "./openapi/src/common/schemas/TaskUpdateRequest.yml" $ref: "./openapi/src/cloud/schemas/TaskUpdateRequest.yml"
Runs: Runs:
$ref: "./openapi/src/common/schemas/Runs.yml" $ref: "./openapi/src/common/schemas/Runs.yml"
Run: Run:

View File

@ -19,7 +19,7 @@ type Label struct {
Id *string `json:"id,omitempty" yaml:"id,omitempty"` Id *string `json:"id,omitempty" yaml:"id,omitempty"`
OrgID *string `json:"orgID,omitempty" yaml:"orgID,omitempty"` OrgID *string `json:"orgID,omitempty" yaml:"orgID,omitempty"`
Name *string `json:"name,omitempty" yaml:"name,omitempty"` Name *string `json:"name,omitempty" yaml:"name,omitempty"`
// Key/Value pairs associated with this label. Keys can be removed by sending an update with an empty value. // Key-value pairs associated with this label. To remove a property, send an update with an empty value (`\"\"`) for the key.
Properties *map[string]string `json:"properties,omitempty" yaml:"properties,omitempty"` Properties *map[string]string `json:"properties,omitempty" yaml:"properties,omitempty"`
} }

View File

@ -18,8 +18,6 @@ import (
type PostOrganizationRequest struct { type PostOrganizationRequest struct {
Name string `json:"name" yaml:"name"` Name string `json:"name" yaml:"name"`
Description *string `json:"description,omitempty" yaml:"description,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty"`
// An optional list of email address's to be invited to the organization
Users *[]string `json:"users,omitempty" yaml:"users,omitempty"`
} }
// NewPostOrganizationRequest instantiates a new PostOrganizationRequest object // NewPostOrganizationRequest instantiates a new PostOrganizationRequest object
@ -96,38 +94,6 @@ func (o *PostOrganizationRequest) SetDescription(v string) {
o.Description = &v o.Description = &v
} }
// GetUsers returns the Users field value if set, zero value otherwise.
func (o *PostOrganizationRequest) GetUsers() []string {
if o == nil || o.Users == nil {
var ret []string
return ret
}
return *o.Users
}
// GetUsersOk returns a tuple with the Users field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PostOrganizationRequest) GetUsersOk() (*[]string, bool) {
if o == nil || o.Users == nil {
return nil, false
}
return o.Users, true
}
// HasUsers returns a boolean if a field has been set.
func (o *PostOrganizationRequest) HasUsers() bool {
if o != nil && o.Users != nil {
return true
}
return false
}
// SetUsers gets a reference to the given []string and assigns it to the Users field.
func (o *PostOrganizationRequest) SetUsers(v []string) {
o.Users = &v
}
func (o PostOrganizationRequest) MarshalJSON() ([]byte, error) { func (o PostOrganizationRequest) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{} toSerialize := map[string]interface{}{}
if true { if true {
@ -136,9 +102,6 @@ func (o PostOrganizationRequest) MarshalJSON() ([]byte, error) {
if o.Description != nil { if o.Description != nil {
toSerialize["description"] = o.Description toSerialize["description"] = o.Description
} }
if o.Users != nil {
toSerialize["users"] = o.Users
}
return json.Marshal(toSerialize) return json.Marshal(toSerialize)
} }

View File

@ -16,8 +16,9 @@ import (
// ScriptCreateRequest struct for ScriptCreateRequest // ScriptCreateRequest struct for ScriptCreateRequest
type ScriptCreateRequest struct { type ScriptCreateRequest struct {
// The name of the script. The name must be unique within the organization. // Script name. The name must be unique within the organization.
Name string `json:"name" yaml:"name"` Name string `json:"name" yaml:"name"`
// Script description. A description of the script.
Description string `json:"description" yaml:"description"` Description string `json:"description" yaml:"description"`
// The script to execute. // The script to execute.
Script string `json:"script" yaml:"script"` Script string `json:"script" yaml:"script"`

View File

@ -18,15 +18,13 @@ import (
// Task struct for Task // Task struct for Task
type Task struct { type Task struct {
Id string `json:"id" yaml:"id"` Id string `json:"id" yaml:"id"`
// The type of the task, useful for filtering a task list.
Type *string `json:"type,omitempty" yaml:"type,omitempty"`
// The ID of the organization that owns the task. // The ID of the organization that owns the task.
OrgID string `json:"orgID" yaml:"orgID"` OrgID string `json:"orgID" yaml:"orgID"`
// The name of the organization that owns the task. // The name of the organization that owns the task.
Org *string `json:"org,omitempty" yaml:"org,omitempty"` Org *string `json:"org,omitempty" yaml:"org,omitempty"`
// The name of the task. // The name of the task.
Name string `json:"name" yaml:"name"` Name string `json:"name" yaml:"name"`
// The ID of the user who owns this Task. // The ID of the user who owns the task.
OwnerID *string `json:"ownerID,omitempty" yaml:"ownerID,omitempty"` OwnerID *string `json:"ownerID,omitempty" yaml:"ownerID,omitempty"`
// The description of the task. // The description of the task.
Description *string `json:"description,omitempty" yaml:"description,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty"`
@ -34,11 +32,11 @@ type Task struct {
Labels *[]Label `json:"labels,omitempty" yaml:"labels,omitempty"` Labels *[]Label `json:"labels,omitempty" yaml:"labels,omitempty"`
// The ID of the authorization used when the task communicates with the query engine. // The ID of the authorization used when the task communicates with the query engine.
AuthorizationID *string `json:"authorizationID,omitempty" yaml:"authorizationID,omitempty"` AuthorizationID *string `json:"authorizationID,omitempty" yaml:"authorizationID,omitempty"`
// The Flux script to run for this task. // The Flux script that the task runs. #### Limitations - If you use the `flux` property, you can't use the `scriptID` and `scriptParameters` properties.
Flux string `json:"flux" yaml:"flux"` Flux *string `json:"flux,omitempty" yaml:"flux,omitempty"`
// An interval ([duration literal](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals))) at which the task runs. `every` also determines when the task first runs, depending on the specified time. // The interval ([duration literal](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals))) at which the task runs. `every` also determines when the task first runs, depending on the specified time.
Every *string `json:"every,omitempty" yaml:"every,omitempty"` Every *string `json:"every,omitempty" yaml:"every,omitempty"`
// [Cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. InfluxDB bases cron runs on the system time. // A [Cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. InfluxDB bases cron runs on the system time.
Cron *string `json:"cron,omitempty" yaml:"cron,omitempty"` Cron *string `json:"cron,omitempty" yaml:"cron,omitempty"`
// A [duration](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals) to delay execution of the task after the scheduled time has elapsed. `0` removes the offset. // A [duration](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals) to delay execution of the task after the scheduled time has elapsed. `0` removes the offset.
Offset *string `json:"offset,omitempty" yaml:"offset,omitempty"` Offset *string `json:"offset,omitempty" yaml:"offset,omitempty"`
@ -49,18 +47,21 @@ type Task struct {
CreatedAt *time.Time `json:"createdAt,omitempty" yaml:"createdAt,omitempty"` CreatedAt *time.Time `json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
UpdatedAt *time.Time `json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"` UpdatedAt *time.Time `json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
Links *TaskLinks `json:"links,omitempty" yaml:"links,omitempty"` Links *TaskLinks `json:"links,omitempty" yaml:"links,omitempty"`
// The ID of the script that the task runs. #### Limitations - If you use the `scriptID` property, you can't use the `flux` property.
ScriptID *string `json:"scriptID,omitempty" yaml:"scriptID,omitempty"`
// The parameter key-value pairs passed to the script (referenced by `scriptID`) during the task run. #### Limitations - `scriptParameters` requires `scriptID`. - If you use the `scriptID` and `scriptParameters` properties, you can't use the `flux` property.
ScriptParameters *map[string]interface{} `json:"scriptParameters,omitempty" yaml:"scriptParameters,omitempty"`
} }
// NewTask instantiates a new Task object // NewTask instantiates a new Task object
// This constructor will assign default values to properties that have it defined, // 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 // and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed // will change when the set of required properties is changed
func NewTask(id string, orgID string, name string, flux string) *Task { func NewTask(id string, orgID string, name string) *Task {
this := Task{} this := Task{}
this.Id = id this.Id = id
this.OrgID = orgID this.OrgID = orgID
this.Name = name this.Name = name
this.Flux = flux
return &this return &this
} }
@ -96,38 +97,6 @@ func (o *Task) SetId(v string) {
o.Id = v o.Id = v
} }
// GetType returns the Type field value if set, zero value otherwise.
func (o *Task) GetType() string {
if o == nil || o.Type == nil {
var ret string
return ret
}
return *o.Type
}
// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetTypeOk() (*string, bool) {
if o == nil || o.Type == nil {
return nil, false
}
return o.Type, true
}
// HasType returns a boolean if a field has been set.
func (o *Task) HasType() bool {
if o != nil && o.Type != nil {
return true
}
return false
}
// SetType gets a reference to the given string and assigns it to the Type field.
func (o *Task) SetType(v string) {
o.Type = &v
}
// GetOrgID returns the OrgID field value // GetOrgID returns the OrgID field value
func (o *Task) GetOrgID() string { func (o *Task) GetOrgID() string {
if o == nil { if o == nil {
@ -368,28 +337,36 @@ func (o *Task) SetAuthorizationID(v string) {
o.AuthorizationID = &v o.AuthorizationID = &v
} }
// GetFlux returns the Flux field value // GetFlux returns the Flux field value if set, zero value otherwise.
func (o *Task) GetFlux() string { func (o *Task) GetFlux() string {
if o == nil { if o == nil || o.Flux == nil {
var ret string var ret string
return ret return ret
} }
return *o.Flux
return o.Flux
} }
// GetFluxOk returns a tuple with the Flux field value // GetFluxOk returns a tuple with the Flux field value if set, nil otherwise
// and a boolean to check if the value has been set. // and a boolean to check if the value has been set.
func (o *Task) GetFluxOk() (*string, bool) { func (o *Task) GetFluxOk() (*string, bool) {
if o == nil { if o == nil || o.Flux == nil {
return nil, false return nil, false
} }
return &o.Flux, true return o.Flux, true
} }
// SetFlux sets field value // HasFlux returns a boolean if a field has been set.
func (o *Task) 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 *Task) SetFlux(v string) { func (o *Task) SetFlux(v string) {
o.Flux = v o.Flux = &v
} }
// GetEvery returns the Every field value if set, zero value otherwise. // GetEvery returns the Every field value if set, zero value otherwise.
@ -680,14 +657,75 @@ func (o *Task) SetLinks(v TaskLinks) {
o.Links = &v o.Links = &v
} }
// GetScriptID returns the ScriptID field value if set, zero value otherwise.
func (o *Task) GetScriptID() string {
if o == nil || o.ScriptID == nil {
var ret string
return ret
}
return *o.ScriptID
}
// GetScriptIDOk returns a tuple with the ScriptID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetScriptIDOk() (*string, bool) {
if o == nil || o.ScriptID == nil {
return nil, false
}
return o.ScriptID, true
}
// HasScriptID returns a boolean if a field has been set.
func (o *Task) HasScriptID() bool {
if o != nil && o.ScriptID != nil {
return true
}
return false
}
// SetScriptID gets a reference to the given string and assigns it to the ScriptID field.
func (o *Task) SetScriptID(v string) {
o.ScriptID = &v
}
// GetScriptParameters returns the ScriptParameters field value if set, zero value otherwise.
func (o *Task) GetScriptParameters() map[string]interface{} {
if o == nil || o.ScriptParameters == nil {
var ret map[string]interface{}
return ret
}
return *o.ScriptParameters
}
// GetScriptParametersOk returns a tuple with the ScriptParameters field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetScriptParametersOk() (*map[string]interface{}, bool) {
if o == nil || o.ScriptParameters == nil {
return nil, false
}
return o.ScriptParameters, true
}
// HasScriptParameters returns a boolean if a field has been set.
func (o *Task) HasScriptParameters() bool {
if o != nil && o.ScriptParameters != nil {
return true
}
return false
}
// SetScriptParameters gets a reference to the given map[string]interface{} and assigns it to the ScriptParameters field.
func (o *Task) SetScriptParameters(v map[string]interface{}) {
o.ScriptParameters = &v
}
func (o Task) MarshalJSON() ([]byte, error) { func (o Task) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{} toSerialize := map[string]interface{}{}
if true { if true {
toSerialize["id"] = o.Id toSerialize["id"] = o.Id
} }
if o.Type != nil {
toSerialize["type"] = o.Type
}
if true { if true {
toSerialize["orgID"] = o.OrgID toSerialize["orgID"] = o.OrgID
} }
@ -712,7 +750,7 @@ func (o Task) MarshalJSON() ([]byte, error) {
if o.AuthorizationID != nil { if o.AuthorizationID != nil {
toSerialize["authorizationID"] = o.AuthorizationID toSerialize["authorizationID"] = o.AuthorizationID
} }
if true { if o.Flux != nil {
toSerialize["flux"] = o.Flux toSerialize["flux"] = o.Flux
} }
if o.Every != nil { if o.Every != nil {
@ -742,6 +780,12 @@ func (o Task) MarshalJSON() ([]byte, error) {
if o.Links != nil { if o.Links != nil {
toSerialize["links"] = o.Links toSerialize["links"] = o.Links
} }
if o.ScriptID != nil {
toSerialize["scriptID"] = o.ScriptID
}
if o.ScriptParameters != nil {
toSerialize["scriptParameters"] = o.ScriptParameters
}
return json.Marshal(toSerialize) return json.Marshal(toSerialize)
} }

View File

@ -16,24 +16,35 @@ import (
// TaskCreateRequest struct for TaskCreateRequest // TaskCreateRequest struct for TaskCreateRequest
type TaskCreateRequest struct { type TaskCreateRequest struct {
// The ID of the organization that owns this Task. // The ID of the organization that owns the task.
OrgID *string `json:"orgID,omitempty" yaml:"orgID,omitempty"` OrgID *string `json:"orgID,omitempty" yaml:"orgID,omitempty"`
// The name of the organization that owns this Task. // The name of the organization that owns the task.
Org *string `json:"org,omitempty" yaml:"org,omitempty"` Org *string `json:"org,omitempty" yaml:"org,omitempty"`
Status *TaskStatusType `json:"status,omitempty" yaml:"status,omitempty"` Status *TaskStatusType `json:"status,omitempty" yaml:"status,omitempty"`
// The Flux script to run for this task. // The Flux script that the task runs. #### Limitations - If you use the `flux` property, you can't use the `scriptID` and `scriptParameters` properties.
Flux string `json:"flux" yaml:"flux"` Flux *string `json:"flux,omitempty" yaml:"flux,omitempty"`
// An optional description of the task. // The description of the task.
Description *string `json:"description,omitempty" yaml:"description,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty"`
// The ID of the script that the task runs. #### Limitations - If you use the `scriptID` property, you can't use the `flux` property.
ScriptID *string `json:"scriptID,omitempty" yaml:"scriptID,omitempty"`
// The parameter key-value pairs passed to the script (referenced by `scriptID`) during the task run. #### Limitations - `scriptParameters` requires `scriptID`. - If you use the `scriptID` and `scriptParameters` properties, you can't use the `flux` property.
ScriptParameters *map[string]interface{} `json:"scriptParameters,omitempty" yaml:"scriptParameters,omitempty"`
// The name of the task
Name *string `json:"name,omitempty" yaml:"name,omitempty"`
// The interval ([duration literal](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals))) at which the task runs. `every` also determines when the task first runs, depending on the specified time.
Every *string `json:"every,omitempty" yaml:"every,omitempty"`
// A [Cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. InfluxDB bases cron runs on the system time.
Cron *string `json:"cron,omitempty" yaml:"cron,omitempty"`
// A [duration](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals) to delay execution of the task after the scheduled time has elapsed. `0` removes the offset.
Offset *string `json:"offset,omitempty" yaml:"offset,omitempty"`
} }
// NewTaskCreateRequest instantiates a new TaskCreateRequest object // NewTaskCreateRequest instantiates a new TaskCreateRequest object
// This constructor will assign default values to properties that have it defined, // 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 // and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed // will change when the set of required properties is changed
func NewTaskCreateRequest(flux string) *TaskCreateRequest { func NewTaskCreateRequest() *TaskCreateRequest {
this := TaskCreateRequest{} this := TaskCreateRequest{}
this.Flux = flux
return &this return &this
} }
@ -141,28 +152,36 @@ func (o *TaskCreateRequest) SetStatus(v TaskStatusType) {
o.Status = &v o.Status = &v
} }
// GetFlux returns the Flux field value // GetFlux returns the Flux field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetFlux() string { func (o *TaskCreateRequest) GetFlux() string {
if o == nil { if o == nil || o.Flux == nil {
var ret string var ret string
return ret return ret
} }
return *o.Flux
return o.Flux
} }
// GetFluxOk returns a tuple with the Flux field value // GetFluxOk returns a tuple with the Flux field value if set, nil otherwise
// and a boolean to check if the value has been set. // and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetFluxOk() (*string, bool) { func (o *TaskCreateRequest) GetFluxOk() (*string, bool) {
if o == nil { if o == nil || o.Flux == nil {
return nil, false return nil, false
} }
return &o.Flux, true return o.Flux, true
} }
// SetFlux sets field value // HasFlux returns a boolean if a field has been set.
func (o *TaskCreateRequest) 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 *TaskCreateRequest) SetFlux(v string) { func (o *TaskCreateRequest) SetFlux(v string) {
o.Flux = v o.Flux = &v
} }
// GetDescription returns the Description field value if set, zero value otherwise. // GetDescription returns the Description field value if set, zero value otherwise.
@ -197,6 +216,198 @@ func (o *TaskCreateRequest) SetDescription(v string) {
o.Description = &v o.Description = &v
} }
// GetScriptID returns the ScriptID field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetScriptID() string {
if o == nil || o.ScriptID == nil {
var ret string
return ret
}
return *o.ScriptID
}
// GetScriptIDOk returns a tuple with the ScriptID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetScriptIDOk() (*string, bool) {
if o == nil || o.ScriptID == nil {
return nil, false
}
return o.ScriptID, true
}
// HasScriptID returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasScriptID() bool {
if o != nil && o.ScriptID != nil {
return true
}
return false
}
// SetScriptID gets a reference to the given string and assigns it to the ScriptID field.
func (o *TaskCreateRequest) SetScriptID(v string) {
o.ScriptID = &v
}
// GetScriptParameters returns the ScriptParameters field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetScriptParameters() map[string]interface{} {
if o == nil || o.ScriptParameters == nil {
var ret map[string]interface{}
return ret
}
return *o.ScriptParameters
}
// GetScriptParametersOk returns a tuple with the ScriptParameters field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetScriptParametersOk() (*map[string]interface{}, bool) {
if o == nil || o.ScriptParameters == nil {
return nil, false
}
return o.ScriptParameters, true
}
// HasScriptParameters returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasScriptParameters() bool {
if o != nil && o.ScriptParameters != nil {
return true
}
return false
}
// SetScriptParameters gets a reference to the given map[string]interface{} and assigns it to the ScriptParameters field.
func (o *TaskCreateRequest) SetScriptParameters(v map[string]interface{}) {
o.ScriptParameters = &v
}
// GetName returns the Name field value if set, zero value otherwise.
func (o *TaskCreateRequest) 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 *TaskCreateRequest) 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 *TaskCreateRequest) 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 *TaskCreateRequest) SetName(v string) {
o.Name = &v
}
// GetEvery returns the Every field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetEvery() string {
if o == nil || o.Every == nil {
var ret string
return ret
}
return *o.Every
}
// GetEveryOk returns a tuple with the Every field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetEveryOk() (*string, bool) {
if o == nil || o.Every == nil {
return nil, false
}
return o.Every, true
}
// HasEvery returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasEvery() bool {
if o != nil && o.Every != nil {
return true
}
return false
}
// SetEvery gets a reference to the given string and assigns it to the Every field.
func (o *TaskCreateRequest) SetEvery(v string) {
o.Every = &v
}
// GetCron returns the Cron field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetCron() string {
if o == nil || o.Cron == nil {
var ret string
return ret
}
return *o.Cron
}
// GetCronOk returns a tuple with the Cron field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetCronOk() (*string, bool) {
if o == nil || o.Cron == nil {
return nil, false
}
return o.Cron, true
}
// HasCron returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasCron() bool {
if o != nil && o.Cron != nil {
return true
}
return false
}
// SetCron gets a reference to the given string and assigns it to the Cron field.
func (o *TaskCreateRequest) SetCron(v string) {
o.Cron = &v
}
// GetOffset returns the Offset field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetOffset() string {
if o == nil || o.Offset == nil {
var ret string
return ret
}
return *o.Offset
}
// GetOffsetOk returns a tuple with the Offset field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetOffsetOk() (*string, bool) {
if o == nil || o.Offset == nil {
return nil, false
}
return o.Offset, true
}
// HasOffset returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasOffset() bool {
if o != nil && o.Offset != nil {
return true
}
return false
}
// SetOffset gets a reference to the given string and assigns it to the Offset field.
func (o *TaskCreateRequest) SetOffset(v string) {
o.Offset = &v
}
func (o TaskCreateRequest) MarshalJSON() ([]byte, error) { func (o TaskCreateRequest) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{} toSerialize := map[string]interface{}{}
if o.OrgID != nil { if o.OrgID != nil {
@ -208,12 +419,30 @@ func (o TaskCreateRequest) MarshalJSON() ([]byte, error) {
if o.Status != nil { if o.Status != nil {
toSerialize["status"] = o.Status toSerialize["status"] = o.Status
} }
if true { if o.Flux != nil {
toSerialize["flux"] = o.Flux toSerialize["flux"] = o.Flux
} }
if o.Description != nil { if o.Description != nil {
toSerialize["description"] = o.Description toSerialize["description"] = o.Description
} }
if o.ScriptID != nil {
toSerialize["scriptID"] = o.ScriptID
}
if o.ScriptParameters != nil {
toSerialize["scriptParameters"] = o.ScriptParameters
}
if o.Name != nil {
toSerialize["name"] = o.Name
}
if o.Every != nil {
toSerialize["every"] = o.Every
}
if o.Cron != nil {
toSerialize["cron"] = o.Cron
}
if o.Offset != nil {
toSerialize["offset"] = o.Offset
}
return json.Marshal(toSerialize) return json.Marshal(toSerialize)
} }

View File

@ -15,7 +15,7 @@ import (
"fmt" "fmt"
) )
// TaskStatusType the model 'TaskStatusType' // TaskStatusType `inactive` cancels scheduled runs and prevents manual runs of the task.
type TaskStatusType string type TaskStatusType string
// List of TaskStatusType // List of TaskStatusType

View File

@ -17,18 +17,22 @@ import (
// TaskUpdateRequest struct for TaskUpdateRequest // TaskUpdateRequest struct for TaskUpdateRequest
type TaskUpdateRequest struct { type TaskUpdateRequest struct {
Status *TaskStatusType `json:"status,omitempty" yaml:"status,omitempty"` Status *TaskStatusType `json:"status,omitempty" yaml:"status,omitempty"`
// The Flux script to run for this task. // Update the Flux script that the task runs.
Flux *string `json:"flux,omitempty" yaml:"flux,omitempty"` Flux *string `json:"flux,omitempty" yaml:"flux,omitempty"`
// Override the 'name' option in the flux script. // Update the 'name' option in the flux script.
Name *string `json:"name,omitempty" yaml:"name,omitempty"` Name *string `json:"name,omitempty" yaml:"name,omitempty"`
// Override the 'every' option in the flux script. // Update the 'every' option in the flux script.
Every *string `json:"every,omitempty" yaml:"every,omitempty"` Every *string `json:"every,omitempty" yaml:"every,omitempty"`
// Override the 'cron' option in the flux script. // Update the 'cron' option in the flux script.
Cron *string `json:"cron,omitempty" yaml:"cron,omitempty"` Cron *string `json:"cron,omitempty" yaml:"cron,omitempty"`
// Override the 'offset' option in the flux script. // Update the 'offset' option in the flux script.
Offset *string `json:"offset,omitempty" yaml:"offset,omitempty"` Offset *string `json:"offset,omitempty" yaml:"offset,omitempty"`
// An optional description of the task. // Update the description of the task.
Description *string `json:"description,omitempty" yaml:"description,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty"`
// Update the 'scriptID' of the task.
ScriptID *string `json:"scriptID,omitempty" yaml:"scriptID,omitempty"`
// Update the 'scriptParameters' of the task.
ScriptParameters *map[string]interface{} `json:"scriptParameters,omitempty" yaml:"scriptParameters,omitempty"`
} }
// NewTaskUpdateRequest instantiates a new TaskUpdateRequest object // NewTaskUpdateRequest instantiates a new TaskUpdateRequest object
@ -272,6 +276,70 @@ func (o *TaskUpdateRequest) SetDescription(v string) {
o.Description = &v o.Description = &v
} }
// GetScriptID returns the ScriptID field value if set, zero value otherwise.
func (o *TaskUpdateRequest) GetScriptID() string {
if o == nil || o.ScriptID == nil {
var ret string
return ret
}
return *o.ScriptID
}
// GetScriptIDOk returns a tuple with the ScriptID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskUpdateRequest) GetScriptIDOk() (*string, bool) {
if o == nil || o.ScriptID == nil {
return nil, false
}
return o.ScriptID, true
}
// HasScriptID returns a boolean if a field has been set.
func (o *TaskUpdateRequest) HasScriptID() bool {
if o != nil && o.ScriptID != nil {
return true
}
return false
}
// SetScriptID gets a reference to the given string and assigns it to the ScriptID field.
func (o *TaskUpdateRequest) SetScriptID(v string) {
o.ScriptID = &v
}
// GetScriptParameters returns the ScriptParameters field value if set, zero value otherwise.
func (o *TaskUpdateRequest) GetScriptParameters() map[string]interface{} {
if o == nil || o.ScriptParameters == nil {
var ret map[string]interface{}
return ret
}
return *o.ScriptParameters
}
// GetScriptParametersOk returns a tuple with the ScriptParameters field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskUpdateRequest) GetScriptParametersOk() (*map[string]interface{}, bool) {
if o == nil || o.ScriptParameters == nil {
return nil, false
}
return o.ScriptParameters, true
}
// HasScriptParameters returns a boolean if a field has been set.
func (o *TaskUpdateRequest) HasScriptParameters() bool {
if o != nil && o.ScriptParameters != nil {
return true
}
return false
}
// SetScriptParameters gets a reference to the given map[string]interface{} and assigns it to the ScriptParameters field.
func (o *TaskUpdateRequest) SetScriptParameters(v map[string]interface{}) {
o.ScriptParameters = &v
}
func (o TaskUpdateRequest) MarshalJSON() ([]byte, error) { func (o TaskUpdateRequest) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{} toSerialize := map[string]interface{}{}
if o.Status != nil { if o.Status != nil {
@ -295,6 +363,12 @@ func (o TaskUpdateRequest) MarshalJSON() ([]byte, error) {
if o.Description != nil { if o.Description != nil {
toSerialize["description"] = o.Description toSerialize["description"] = o.Description
} }
if o.ScriptID != nil {
toSerialize["scriptID"] = o.ScriptID
}
if o.ScriptParameters != nil {
toSerialize["scriptParameters"] = o.ScriptParameters
}
return json.Marshal(toSerialize) return json.Marshal(toSerialize)
} }

View File

@ -20,6 +20,8 @@ type Client struct {
type CreateParams struct { type CreateParams struct {
clients.OrgParams clients.OrgParams
FluxQuery string FluxQuery string
ScriptID string
ScriptParams map[string]interface{}
} }
type NameOrID struct { type NameOrID struct {
@ -73,9 +75,11 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
return err return err
} }
createRequest := api.TaskCreateRequest{ createRequest := api.TaskCreateRequest{
Flux: params.FluxQuery, Flux: &params.FluxQuery,
OrgID: org.IDOrNil(), OrgID: org.IDOrNil(),
Org: org.NameOrNil(), Org: org.NameOrNil(),
ScriptID: &params.ScriptID,
ScriptParameters: &params.ScriptParams,
} }
task, err := c.PostTasks(ctx).TaskCreateRequest(createRequest).Execute() task, err := c.PostTasks(ctx).TaskCreateRequest(createRequest).Execute()
if err != nil { if err != nil {
@ -261,6 +265,8 @@ type UpdateParams struct {
FluxQuery string FluxQuery string
TaskID string TaskID string
Status string Status string
ScriptID string
ScriptParams map[string]interface{}
} }
func (c Client) Update(ctx context.Context, params *UpdateParams) error { func (c Client) Update(ctx context.Context, params *UpdateParams) error {
@ -280,6 +286,8 @@ func (c Client) Update(ctx context.Context, params *UpdateParams) error {
task, err := c.PatchTasksID(ctx, params.TaskID).TaskUpdateRequest(api.TaskUpdateRequest{ task, err := c.PatchTasksID(ctx, params.TaskID).TaskUpdateRequest(api.TaskUpdateRequest{
Status: status, Status: status,
Flux: flux, Flux: flux,
ScriptID: &params.ScriptID,
ScriptParameters: &params.ScriptParams,
}).Execute() }).Execute()
if err != nil { if err != nil {
return err return err
@ -352,6 +360,7 @@ func (c Client) printTasks(printOpts taskPrintOpts) error {
"Status": derefOrEmpty((*string)(t.Status)), "Status": derefOrEmpty((*string)(t.Status)),
"Every": derefOrEmpty(t.Every), "Every": derefOrEmpty(t.Every),
"Cron": derefOrEmpty(t.Cron), "Cron": derefOrEmpty(t.Cron),
"ScriptID": derefOrEmpty(t.ScriptID),
} }
rows = append(rows, row) rows = append(rows, row)
} }