feat: create subcommand for tasks cli (#102)

* refactor: add task APIs to codegen

* feat: tasks subcommand

Co-authored-by: Dan Moran <dmoran@influxdata.com>
This commit is contained in:
Sam Arnold 2021-05-25 09:06:37 -04:00 committed by GitHub
parent 4981b6742e
commit d54aa9ec2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 5584 additions and 77 deletions

View File

@ -2,10 +2,14 @@ package main
import (
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"runtime"
"strings"
"github.com/influxdata/influx-cli/v2/internal/api"
"github.com/influxdata/influx-cli/v2/internal/cmd"
@ -242,34 +246,93 @@ func commonFlags() []cli.Flag {
return append(commonFlagsNoToken(), commonTokenFlag())
}
// getOrgBucketFlags returns flags used by commands that are scoped to a single org/bucket, binding
// getOrgFlags returns flags used by commands that are scoped to a single org, binding
// the flags to the given params container.
func getOrgBucketFlags(c *cmd.OrgBucketParams) []cli.Flag {
func getOrgFlags(params *cmd.OrgParams) []cli.Flag {
return []cli.Flag{
&cli.GenericFlag{
Name: "bucket-id",
Usage: "The bucket ID, required if name isn't provided",
Aliases: []string{"i"},
Value: &c.BucketID,
},
&cli.StringFlag{
Name: "bucket",
Usage: "The bucket name, org or org-id will be required by choosing this",
Aliases: []string{"n"},
Destination: &c.BucketName,
},
&cli.GenericFlag{
Name: "org-id",
Usage: "The ID of the organization",
EnvVars: []string{"INFLUX_ORG_ID"},
Value: &c.OrgID,
Value: &params.OrgID,
},
&cli.StringFlag{
Name: "org",
Usage: "The name of the organization",
Aliases: []string{"o"},
EnvVars: []string{"INFLUX_ORG"},
Destination: &c.OrgName,
Destination: &params.OrgName,
},
}
}
// getBucketFlags returns flags used by commands that are scoped to a single bucket, binding
// the flags to the given params container.
func getBucketFlags(params *cmd.BucketParams) []cli.Flag {
return []cli.Flag{
&cli.GenericFlag{
Name: "bucket-id",
Usage: "The bucket ID, required if name isn't provided",
Aliases: []string{"i"},
Value: &params.BucketID,
},
&cli.StringFlag{
Name: "bucket",
Usage: "The bucket name, org or org-id will be required by choosing this",
Aliases: []string{"n"},
Destination: &params.BucketName,
},
}
}
// getOrgBucketFlags returns flags used by commands that are scoped to a single org/bucket, binding
// the flags to the given params container.
func getOrgBucketFlags(c *cmd.OrgBucketParams) []cli.Flag {
return append(getBucketFlags(&c.BucketParams), getOrgFlags(&c.OrgParams)...)
}
// readQuery reads a Flux query into memory from a file, args, or stdin based on CLI parameters.
func readQuery(ctx *cli.Context) (string, error) {
nargs := ctx.NArg()
file := ctx.String("file")
if nargs > 1 {
return "", fmt.Errorf("at most 1 query string can be specified over the CLI, got %d", ctx.NArg())
}
if nargs == 1 && file != "" {
return "", errors.New("query can be specified via --file or over the CLI, not both")
}
readFile := func(path string) (string, error) {
queryBytes, err := ioutil.ReadFile(path)
if err != nil {
return "", fmt.Errorf("failed to read query from %q: %w", path, err)
}
return string(queryBytes), nil
}
readStdin := func() (string, error) {
queryBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return "", fmt.Errorf("failed to read query from stdin: %w", err)
}
return string(queryBytes), err
}
if file != "" {
return readFile(file)
}
if nargs == 0 {
return readStdin()
}
arg := ctx.Args().Get(0)
// Backwards compatibility.
if strings.HasPrefix(arg, "@") {
return readFile(arg[1:])
} else if arg == "-" {
return readStdin()
} else {
return arg, nil
}
}

View File

@ -43,6 +43,7 @@ var app = cli.App{
newOrgCmd(),
newDeleteCmd(),
newUserCmd(),
newTaskCommand(),
},
}

View File

@ -2,9 +2,6 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/influxdata/influx-cli/v2/internal/cmd"
@ -92,49 +89,3 @@ func newQueryCmd() *cli.Command {
},
}
}
// readQuery reads a Flux query into memory from a file, args, or stdin based on CLI parameters.
func readQuery(ctx *cli.Context) (string, error) {
nargs := ctx.NArg()
file := ctx.String("file")
if nargs > 1 {
return "", fmt.Errorf("at most 1 query string can be specified over the CLI, got %d", ctx.NArg())
}
if nargs == 1 && file != "" {
return "", errors.New("query can be specified via --file or over the CLI, not both")
}
readFile := func(path string) (string, error) {
queryBytes, err := ioutil.ReadFile(path)
if err != nil {
return "", fmt.Errorf("failed to read query from %q: %w", path, err)
}
return string(queryBytes), nil
}
readStdin := func() (string, error) {
queryBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return "", fmt.Errorf("failed to read query from stdin: %w", err)
}
return string(queryBytes), err
}
if file != "" {
return readFile(file)
}
if nargs == 0 {
return readStdin()
}
arg := ctx.Args().Get(0)
// Backwards compatibility.
if strings.HasPrefix(arg, "@") {
return readFile(arg[1:])
} else if arg == "-" {
return readStdin()
} else {
return arg, nil
}
}

54
cmd/influx/task.go Normal file
View File

@ -0,0 +1,54 @@
package main
import (
"github.com/influxdata/influx-cli/v2/internal/cmd/task"
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
"github.com/urfave/cli/v2"
)
func newTaskCommand() *cli.Command {
return &cli.Command{
Name: "task",
Usage: "Task management commands",
Subcommands: []*cli.Command{
//newTaskLogCmd(),
//newTaskRunCmd(),
newTaskCreateCmd(),
//newTaskDeleteCmd(),
//newTaskFindCmd(),
//newTaskUpdateCmd(),
//newTaskRetryFailedCmd(),
},
}
}
func newTaskCreateCmd() *cli.Command {
var params task.CreateParams
flags := append(commonFlags(), getOrgFlags(&params.OrgParams)...)
flags = append(flags, &cli.StringFlag{
Name: "file",
Usage: "Path to Flux script file",
Aliases: []string{"f"},
TakesFile: true,
})
return &cli.Command{
Name: "create",
Usage: "Create a task with a Flux script provided via the first argument or a file or stdin",
ArgsUsage: "[flux script or '-' for stdin]",
Flags: flags,
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
Action: func(ctx *cli.Context) error {
api := getAPI(ctx)
client := task.Client{
CLI: getCLI(ctx),
TasksApi: api.TasksApi,
}
var err error
params.FluxQuery, err = readQuery(ctx)
if err != nil {
return err
}
return client.Create(ctx.Context, &params)
},
}
}

File diff suppressed because it is too large Load Diff

View File

@ -61,6 +61,8 @@ type APIClient struct {
SetupApi SetupApi
TasksApi TasksApi
UsersApi UsersApi
WriteApi WriteApi
@ -89,6 +91,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {
c.OrganizationsApi = (*OrganizationsApiService)(&c.common)
c.QueryApi = (*QueryApiService)(&c.common)
c.SetupApi = (*SetupApiService)(&c.common)
c.TasksApi = (*TasksApiService)(&c.common)
c.UsersApi = (*UsersApiService)(&c.common)
c.WriteApi = (*WriteApiService)(&c.common)

View File

@ -39,6 +39,20 @@ paths:
$ref: "./openapi/src/common/paths/users_userID_password.yml"
/delete:
$ref: "./openapi/src/common/paths/delete.yml"
/tasks:
$ref: "./openapi/src/common/paths/tasks.yml"
/tasks/{taskID}:
$ref: "./openapi/src/common/paths/tasks_taskID.yml"
/tasks/{taskID}/runs:
$ref: "./openapi/src/common/paths/tasks_taskID_runs.yml"
/tasks/{taskID}/runs/{runID}:
$ref: "./openapi/src/common/paths/tasks_taskID_runs_runID.yml"
/tasks/{taskID}/runs/{runID}/retry:
$ref: "./openapi/src/common/paths/tasks_taskID_runs_runID_retry.yml"
/tasks/{taskID}/logs:
$ref: "./openapi/src/common/paths/tasks_taskID_logs.yml"
/tasks/{taskID}/runs/{runID}/logs:
$ref: "./openapi/src/common/paths/tasks_taskID_runs_runID_logs.yml"
components:
parameters:
TraceSpan:
@ -149,3 +163,23 @@ components:
$ref: "./overrides/schemas/Extern.yml"
DeletePredicateRequest:
$ref: "./openapi/src/common/schemas/DeletePredicateRequest.yml"
Tasks:
$ref: "./openapi/src/common/schemas/Tasks.yml"
Task:
$ref: "./openapi/src/common/schemas/Task.yml"
TaskCreateRequest:
$ref: "./openapi/src/common/schemas/TaskCreateRequest.yml"
TaskStatusType:
$ref: "./openapi/src/common/schemas/TaskStatusType.yml"
TaskUpdateRequest:
$ref: "./openapi/src/common/schemas/TaskUpdateRequest.yml"
Runs:
$ref: "./openapi/src/common/schemas/Runs.yml"
Run:
$ref: "./openapi/src/common/schemas/Run.yml"
RunManually:
$ref: "./openapi/src/common/schemas/RunManually.yml"
Logs:
$ref: "./openapi/src/common/schemas/Logs.yml"
LogEvent:
$ref: "./openapi/src/common/schemas/LogEvent.yml"

View File

@ -0,0 +1,152 @@
/*
* 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"
)
// LogEvent struct for LogEvent
type LogEvent struct {
// Time event occurred, RFC3339Nano.
Time *time.Time `json:"time,omitempty"`
// A description of the event that occurred.
Message *string `json:"message,omitempty"`
}
// NewLogEvent instantiates a new LogEvent 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 NewLogEvent() *LogEvent {
this := LogEvent{}
return &this
}
// NewLogEventWithDefaults instantiates a new LogEvent 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 NewLogEventWithDefaults() *LogEvent {
this := LogEvent{}
return &this
}
// GetTime returns the Time field value if set, zero value otherwise.
func (o *LogEvent) GetTime() time.Time {
if o == nil || o.Time == nil {
var ret time.Time
return ret
}
return *o.Time
}
// GetTimeOk returns a tuple with the Time field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *LogEvent) GetTimeOk() (*time.Time, bool) {
if o == nil || o.Time == nil {
return nil, false
}
return o.Time, true
}
// HasTime returns a boolean if a field has been set.
func (o *LogEvent) HasTime() bool {
if o != nil && o.Time != nil {
return true
}
return false
}
// SetTime gets a reference to the given time.Time and assigns it to the Time field.
func (o *LogEvent) SetTime(v time.Time) {
o.Time = &v
}
// GetMessage returns the Message field value if set, zero value otherwise.
func (o *LogEvent) GetMessage() string {
if o == nil || o.Message == nil {
var ret string
return ret
}
return *o.Message
}
// GetMessageOk returns a tuple with the Message field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *LogEvent) GetMessageOk() (*string, bool) {
if o == nil || o.Message == nil {
return nil, false
}
return o.Message, true
}
// HasMessage returns a boolean if a field has been set.
func (o *LogEvent) HasMessage() bool {
if o != nil && o.Message != nil {
return true
}
return false
}
// SetMessage gets a reference to the given string and assigns it to the Message field.
func (o *LogEvent) SetMessage(v string) {
o.Message = &v
}
func (o LogEvent) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Time != nil {
toSerialize["time"] = o.Time
}
if o.Message != nil {
toSerialize["message"] = o.Message
}
return json.Marshal(toSerialize)
}
type NullableLogEvent struct {
value *LogEvent
isSet bool
}
func (v NullableLogEvent) Get() *LogEvent {
return v.value
}
func (v *NullableLogEvent) Set(val *LogEvent) {
v.value = val
v.isSet = true
}
func (v NullableLogEvent) IsSet() bool {
return v.isSet
}
func (v *NullableLogEvent) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableLogEvent(val *LogEvent) *NullableLogEvent {
return &NullableLogEvent{value: val, isSet: true}
}
func (v NullableLogEvent) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableLogEvent) 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"
)
// Logs struct for Logs
type Logs struct {
Events *[]LogEvent `json:"events,omitempty"`
}
// NewLogs instantiates a new Logs 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 NewLogs() *Logs {
this := Logs{}
return &this
}
// NewLogsWithDefaults instantiates a new Logs 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 NewLogsWithDefaults() *Logs {
this := Logs{}
return &this
}
// GetEvents returns the Events field value if set, zero value otherwise.
func (o *Logs) GetEvents() []LogEvent {
if o == nil || o.Events == nil {
var ret []LogEvent
return ret
}
return *o.Events
}
// GetEventsOk returns a tuple with the Events field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Logs) GetEventsOk() (*[]LogEvent, bool) {
if o == nil || o.Events == nil {
return nil, false
}
return o.Events, true
}
// HasEvents returns a boolean if a field has been set.
func (o *Logs) HasEvents() bool {
if o != nil && o.Events != nil {
return true
}
return false
}
// SetEvents gets a reference to the given []LogEvent and assigns it to the Events field.
func (o *Logs) SetEvents(v []LogEvent) {
o.Events = &v
}
func (o Logs) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Events != nil {
toSerialize["events"] = o.Events
}
return json.Marshal(toSerialize)
}
type NullableLogs struct {
value *Logs
isSet bool
}
func (v NullableLogs) Get() *Logs {
return v.value
}
func (v *NullableLogs) Set(val *Logs) {
v.value = val
v.isSet = true
}
func (v NullableLogs) IsSet() bool {
return v.isSet
}
func (v *NullableLogs) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableLogs(val *Logs) *NullableLogs {
return &NullableLogs{value: val, isSet: true}
}
func (v NullableLogs) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableLogs) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,407 @@
/*
* 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"
)
// Run struct for Run
type Run struct {
Id *string `json:"id,omitempty"`
TaskID *string `json:"taskID,omitempty"`
Status *string `json:"status,omitempty"`
// Time used for run's \"now\" option, RFC3339.
ScheduledFor *time.Time `json:"scheduledFor,omitempty"`
// An array of logs associated with the run.
Log *[]RunLog `json:"log,omitempty"`
// Time run started executing, RFC3339Nano.
StartedAt *time.Time `json:"startedAt,omitempty"`
// Time run finished executing, RFC3339Nano.
FinishedAt *time.Time `json:"finishedAt,omitempty"`
// Time run was manually requested, RFC3339Nano.
RequestedAt *time.Time `json:"requestedAt,omitempty"`
Links *RunLinks `json:"links,omitempty"`
}
// NewRun instantiates a new Run 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 NewRun() *Run {
this := Run{}
return &this
}
// NewRunWithDefaults instantiates a new Run 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 NewRunWithDefaults() *Run {
this := Run{}
return &this
}
// GetId returns the Id field value if set, zero value otherwise.
func (o *Run) 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 *Run) 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 *Run) 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 *Run) SetId(v string) {
o.Id = &v
}
// GetTaskID returns the TaskID field value if set, zero value otherwise.
func (o *Run) GetTaskID() string {
if o == nil || o.TaskID == nil {
var ret string
return ret
}
return *o.TaskID
}
// GetTaskIDOk returns a tuple with the TaskID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetTaskIDOk() (*string, bool) {
if o == nil || o.TaskID == nil {
return nil, false
}
return o.TaskID, true
}
// HasTaskID returns a boolean if a field has been set.
func (o *Run) HasTaskID() bool {
if o != nil && o.TaskID != nil {
return true
}
return false
}
// SetTaskID gets a reference to the given string and assigns it to the TaskID field.
func (o *Run) SetTaskID(v string) {
o.TaskID = &v
}
// GetStatus returns the Status field value if set, zero value otherwise.
func (o *Run) GetStatus() string {
if o == nil || o.Status == nil {
var ret string
return ret
}
return *o.Status
}
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetStatusOk() (*string, bool) {
if o == nil || o.Status == nil {
return nil, false
}
return o.Status, true
}
// HasStatus returns a boolean if a field has been set.
func (o *Run) HasStatus() bool {
if o != nil && o.Status != nil {
return true
}
return false
}
// SetStatus gets a reference to the given string and assigns it to the Status field.
func (o *Run) SetStatus(v string) {
o.Status = &v
}
// GetScheduledFor returns the ScheduledFor field value if set, zero value otherwise.
func (o *Run) GetScheduledFor() time.Time {
if o == nil || o.ScheduledFor == nil {
var ret time.Time
return ret
}
return *o.ScheduledFor
}
// GetScheduledForOk returns a tuple with the ScheduledFor field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetScheduledForOk() (*time.Time, bool) {
if o == nil || o.ScheduledFor == nil {
return nil, false
}
return o.ScheduledFor, true
}
// HasScheduledFor returns a boolean if a field has been set.
func (o *Run) HasScheduledFor() bool {
if o != nil && o.ScheduledFor != nil {
return true
}
return false
}
// SetScheduledFor gets a reference to the given time.Time and assigns it to the ScheduledFor field.
func (o *Run) SetScheduledFor(v time.Time) {
o.ScheduledFor = &v
}
// GetLog returns the Log field value if set, zero value otherwise.
func (o *Run) GetLog() []RunLog {
if o == nil || o.Log == nil {
var ret []RunLog
return ret
}
return *o.Log
}
// GetLogOk returns a tuple with the Log field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetLogOk() (*[]RunLog, bool) {
if o == nil || o.Log == nil {
return nil, false
}
return o.Log, true
}
// HasLog returns a boolean if a field has been set.
func (o *Run) HasLog() bool {
if o != nil && o.Log != nil {
return true
}
return false
}
// SetLog gets a reference to the given []RunLog and assigns it to the Log field.
func (o *Run) SetLog(v []RunLog) {
o.Log = &v
}
// GetStartedAt returns the StartedAt field value if set, zero value otherwise.
func (o *Run) GetStartedAt() time.Time {
if o == nil || o.StartedAt == nil {
var ret time.Time
return ret
}
return *o.StartedAt
}
// GetStartedAtOk returns a tuple with the StartedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetStartedAtOk() (*time.Time, bool) {
if o == nil || o.StartedAt == nil {
return nil, false
}
return o.StartedAt, true
}
// HasStartedAt returns a boolean if a field has been set.
func (o *Run) HasStartedAt() bool {
if o != nil && o.StartedAt != nil {
return true
}
return false
}
// SetStartedAt gets a reference to the given time.Time and assigns it to the StartedAt field.
func (o *Run) SetStartedAt(v time.Time) {
o.StartedAt = &v
}
// GetFinishedAt returns the FinishedAt field value if set, zero value otherwise.
func (o *Run) GetFinishedAt() time.Time {
if o == nil || o.FinishedAt == nil {
var ret time.Time
return ret
}
return *o.FinishedAt
}
// GetFinishedAtOk returns a tuple with the FinishedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetFinishedAtOk() (*time.Time, bool) {
if o == nil || o.FinishedAt == nil {
return nil, false
}
return o.FinishedAt, true
}
// HasFinishedAt returns a boolean if a field has been set.
func (o *Run) HasFinishedAt() bool {
if o != nil && o.FinishedAt != nil {
return true
}
return false
}
// SetFinishedAt gets a reference to the given time.Time and assigns it to the FinishedAt field.
func (o *Run) SetFinishedAt(v time.Time) {
o.FinishedAt = &v
}
// GetRequestedAt returns the RequestedAt field value if set, zero value otherwise.
func (o *Run) GetRequestedAt() time.Time {
if o == nil || o.RequestedAt == nil {
var ret time.Time
return ret
}
return *o.RequestedAt
}
// GetRequestedAtOk returns a tuple with the RequestedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetRequestedAtOk() (*time.Time, bool) {
if o == nil || o.RequestedAt == nil {
return nil, false
}
return o.RequestedAt, true
}
// HasRequestedAt returns a boolean if a field has been set.
func (o *Run) HasRequestedAt() bool {
if o != nil && o.RequestedAt != nil {
return true
}
return false
}
// SetRequestedAt gets a reference to the given time.Time and assigns it to the RequestedAt field.
func (o *Run) SetRequestedAt(v time.Time) {
o.RequestedAt = &v
}
// GetLinks returns the Links field value if set, zero value otherwise.
func (o *Run) GetLinks() RunLinks {
if o == nil || o.Links == nil {
var ret RunLinks
return ret
}
return *o.Links
}
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Run) GetLinksOk() (*RunLinks, bool) {
if o == nil || o.Links == nil {
return nil, false
}
return o.Links, true
}
// HasLinks returns a boolean if a field has been set.
func (o *Run) HasLinks() bool {
if o != nil && o.Links != nil {
return true
}
return false
}
// SetLinks gets a reference to the given RunLinks and assigns it to the Links field.
func (o *Run) SetLinks(v RunLinks) {
o.Links = &v
}
func (o Run) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Id != nil {
toSerialize["id"] = o.Id
}
if o.TaskID != nil {
toSerialize["taskID"] = o.TaskID
}
if o.Status != nil {
toSerialize["status"] = o.Status
}
if o.ScheduledFor != nil {
toSerialize["scheduledFor"] = o.ScheduledFor
}
if o.Log != nil {
toSerialize["log"] = o.Log
}
if o.StartedAt != nil {
toSerialize["startedAt"] = o.StartedAt
}
if o.FinishedAt != nil {
toSerialize["finishedAt"] = o.FinishedAt
}
if o.RequestedAt != nil {
toSerialize["requestedAt"] = o.RequestedAt
}
if o.Links != nil {
toSerialize["links"] = o.Links
}
return json.Marshal(toSerialize)
}
type NullableRun struct {
value *Run
isSet bool
}
func (v NullableRun) Get() *Run {
return v.value
}
func (v *NullableRun) Set(val *Run) {
v.value = val
v.isSet = true
}
func (v NullableRun) IsSet() bool {
return v.isSet
}
func (v *NullableRun) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRun(val *Run) *NullableRun {
return &NullableRun{value: val, isSet: true}
}
func (v NullableRun) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRun) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,185 @@
/*
* 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"
)
// RunLinks struct for RunLinks
type RunLinks struct {
Self *string `json:"self,omitempty"`
Task *string `json:"task,omitempty"`
Retry *string `json:"retry,omitempty"`
}
// NewRunLinks instantiates a new RunLinks 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 NewRunLinks() *RunLinks {
this := RunLinks{}
return &this
}
// NewRunLinksWithDefaults instantiates a new RunLinks 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 NewRunLinksWithDefaults() *RunLinks {
this := RunLinks{}
return &this
}
// GetSelf returns the Self field value if set, zero value otherwise.
func (o *RunLinks) GetSelf() string {
if o == nil || o.Self == nil {
var ret string
return ret
}
return *o.Self
}
// GetSelfOk returns a tuple with the Self field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RunLinks) GetSelfOk() (*string, bool) {
if o == nil || o.Self == nil {
return nil, false
}
return o.Self, true
}
// HasSelf returns a boolean if a field has been set.
func (o *RunLinks) HasSelf() bool {
if o != nil && o.Self != nil {
return true
}
return false
}
// SetSelf gets a reference to the given string and assigns it to the Self field.
func (o *RunLinks) SetSelf(v string) {
o.Self = &v
}
// GetTask returns the Task field value if set, zero value otherwise.
func (o *RunLinks) GetTask() string {
if o == nil || o.Task == nil {
var ret string
return ret
}
return *o.Task
}
// GetTaskOk returns a tuple with the Task field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RunLinks) GetTaskOk() (*string, bool) {
if o == nil || o.Task == nil {
return nil, false
}
return o.Task, true
}
// HasTask returns a boolean if a field has been set.
func (o *RunLinks) HasTask() bool {
if o != nil && o.Task != nil {
return true
}
return false
}
// SetTask gets a reference to the given string and assigns it to the Task field.
func (o *RunLinks) SetTask(v string) {
o.Task = &v
}
// GetRetry returns the Retry field value if set, zero value otherwise.
func (o *RunLinks) GetRetry() string {
if o == nil || o.Retry == nil {
var ret string
return ret
}
return *o.Retry
}
// GetRetryOk returns a tuple with the Retry field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RunLinks) GetRetryOk() (*string, bool) {
if o == nil || o.Retry == nil {
return nil, false
}
return o.Retry, true
}
// HasRetry returns a boolean if a field has been set.
func (o *RunLinks) HasRetry() bool {
if o != nil && o.Retry != nil {
return true
}
return false
}
// SetRetry gets a reference to the given string and assigns it to the Retry field.
func (o *RunLinks) SetRetry(v string) {
o.Retry = &v
}
func (o RunLinks) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Self != nil {
toSerialize["self"] = o.Self
}
if o.Task != nil {
toSerialize["task"] = o.Task
}
if o.Retry != nil {
toSerialize["retry"] = o.Retry
}
return json.Marshal(toSerialize)
}
type NullableRunLinks struct {
value *RunLinks
isSet bool
}
func (v NullableRunLinks) Get() *RunLinks {
return v.value
}
func (v *NullableRunLinks) Set(val *RunLinks) {
v.value = val
v.isSet = true
}
func (v NullableRunLinks) IsSet() bool {
return v.isSet
}
func (v *NullableRunLinks) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRunLinks(val *RunLinks) *NullableRunLinks {
return &NullableRunLinks{value: val, isSet: true}
}
func (v NullableRunLinks) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRunLinks) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,185 @@
/*
* 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"
)
// RunLog struct for RunLog
type RunLog struct {
RunID *string `json:"runID,omitempty"`
Time *string `json:"time,omitempty"`
Message *string `json:"message,omitempty"`
}
// NewRunLog instantiates a new RunLog 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 NewRunLog() *RunLog {
this := RunLog{}
return &this
}
// NewRunLogWithDefaults instantiates a new RunLog 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 NewRunLogWithDefaults() *RunLog {
this := RunLog{}
return &this
}
// GetRunID returns the RunID field value if set, zero value otherwise.
func (o *RunLog) GetRunID() string {
if o == nil || o.RunID == nil {
var ret string
return ret
}
return *o.RunID
}
// GetRunIDOk returns a tuple with the RunID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RunLog) GetRunIDOk() (*string, bool) {
if o == nil || o.RunID == nil {
return nil, false
}
return o.RunID, true
}
// HasRunID returns a boolean if a field has been set.
func (o *RunLog) HasRunID() bool {
if o != nil && o.RunID != nil {
return true
}
return false
}
// SetRunID gets a reference to the given string and assigns it to the RunID field.
func (o *RunLog) SetRunID(v string) {
o.RunID = &v
}
// GetTime returns the Time field value if set, zero value otherwise.
func (o *RunLog) GetTime() string {
if o == nil || o.Time == nil {
var ret string
return ret
}
return *o.Time
}
// GetTimeOk returns a tuple with the Time field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RunLog) GetTimeOk() (*string, bool) {
if o == nil || o.Time == nil {
return nil, false
}
return o.Time, true
}
// HasTime returns a boolean if a field has been set.
func (o *RunLog) HasTime() bool {
if o != nil && o.Time != nil {
return true
}
return false
}
// SetTime gets a reference to the given string and assigns it to the Time field.
func (o *RunLog) SetTime(v string) {
o.Time = &v
}
// GetMessage returns the Message field value if set, zero value otherwise.
func (o *RunLog) GetMessage() string {
if o == nil || o.Message == nil {
var ret string
return ret
}
return *o.Message
}
// GetMessageOk returns a tuple with the Message field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RunLog) GetMessageOk() (*string, bool) {
if o == nil || o.Message == nil {
return nil, false
}
return o.Message, true
}
// HasMessage returns a boolean if a field has been set.
func (o *RunLog) HasMessage() bool {
if o != nil && o.Message != nil {
return true
}
return false
}
// SetMessage gets a reference to the given string and assigns it to the Message field.
func (o *RunLog) SetMessage(v string) {
o.Message = &v
}
func (o RunLog) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.RunID != nil {
toSerialize["runID"] = o.RunID
}
if o.Time != nil {
toSerialize["time"] = o.Time
}
if o.Message != nil {
toSerialize["message"] = o.Message
}
return json.Marshal(toSerialize)
}
type NullableRunLog struct {
value *RunLog
isSet bool
}
func (v NullableRunLog) Get() *RunLog {
return v.value
}
func (v *NullableRunLog) Set(val *RunLog) {
v.value = val
v.isSet = true
}
func (v NullableRunLog) IsSet() bool {
return v.isSet
}
func (v *NullableRunLog) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRunLog(val *RunLog) *NullableRunLog {
return &NullableRunLog{value: val, isSet: true}
}
func (v NullableRunLog) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRunLog) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,126 @@
/*
* 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"
)
// RunManually struct for RunManually
type RunManually struct {
// Time used for run's \"now\" option, RFC3339. Default is the server's now time.
ScheduledFor NullableTime `json:"scheduledFor,omitempty"`
}
// NewRunManually instantiates a new RunManually 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 NewRunManually() *RunManually {
this := RunManually{}
return &this
}
// NewRunManuallyWithDefaults instantiates a new RunManually 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 NewRunManuallyWithDefaults() *RunManually {
this := RunManually{}
return &this
}
// GetScheduledFor returns the ScheduledFor field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *RunManually) GetScheduledFor() time.Time {
if o == nil || o.ScheduledFor.Get() == nil {
var ret time.Time
return ret
}
return *o.ScheduledFor.Get()
}
// GetScheduledForOk returns a tuple with the ScheduledFor field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *RunManually) GetScheduledForOk() (*time.Time, bool) {
if o == nil {
return nil, false
}
return o.ScheduledFor.Get(), o.ScheduledFor.IsSet()
}
// HasScheduledFor returns a boolean if a field has been set.
func (o *RunManually) HasScheduledFor() bool {
if o != nil && o.ScheduledFor.IsSet() {
return true
}
return false
}
// SetScheduledFor gets a reference to the given NullableTime and assigns it to the ScheduledFor field.
func (o *RunManually) SetScheduledFor(v time.Time) {
o.ScheduledFor.Set(&v)
}
// SetScheduledForNil sets the value for ScheduledFor to be an explicit nil
func (o *RunManually) SetScheduledForNil() {
o.ScheduledFor.Set(nil)
}
// UnsetScheduledFor ensures that no value is present for ScheduledFor, not even an explicit nil
func (o *RunManually) UnsetScheduledFor() {
o.ScheduledFor.Unset()
}
func (o RunManually) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.ScheduledFor.IsSet() {
toSerialize["scheduledFor"] = o.ScheduledFor.Get()
}
return json.Marshal(toSerialize)
}
type NullableRunManually struct {
value *RunManually
isSet bool
}
func (v NullableRunManually) Get() *RunManually {
return v.value
}
func (v *NullableRunManually) Set(val *RunManually) {
v.value = val
v.isSet = true
}
func (v NullableRunManually) IsSet() bool {
return v.isSet
}
func (v *NullableRunManually) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRunManually(val *RunManually) *NullableRunManually {
return &NullableRunManually{value: val, isSet: true}
}
func (v NullableRunManually) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRunManually) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,149 @@
/*
* 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"
)
// Runs struct for Runs
type Runs struct {
Links *Links `json:"links,omitempty"`
Runs *[]Run `json:"runs,omitempty"`
}
// NewRuns instantiates a new Runs 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 NewRuns() *Runs {
this := Runs{}
return &this
}
// NewRunsWithDefaults instantiates a new Runs 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 NewRunsWithDefaults() *Runs {
this := Runs{}
return &this
}
// GetLinks returns the Links field value if set, zero value otherwise.
func (o *Runs) GetLinks() Links {
if o == nil || o.Links == nil {
var ret Links
return ret
}
return *o.Links
}
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Runs) GetLinksOk() (*Links, bool) {
if o == nil || o.Links == nil {
return nil, false
}
return o.Links, true
}
// HasLinks returns a boolean if a field has been set.
func (o *Runs) HasLinks() bool {
if o != nil && o.Links != nil {
return true
}
return false
}
// SetLinks gets a reference to the given Links and assigns it to the Links field.
func (o *Runs) SetLinks(v Links) {
o.Links = &v
}
// GetRuns returns the Runs field value if set, zero value otherwise.
func (o *Runs) GetRuns() []Run {
if o == nil || o.Runs == nil {
var ret []Run
return ret
}
return *o.Runs
}
// GetRunsOk returns a tuple with the Runs field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Runs) GetRunsOk() (*[]Run, bool) {
if o == nil || o.Runs == nil {
return nil, false
}
return o.Runs, true
}
// HasRuns returns a boolean if a field has been set.
func (o *Runs) HasRuns() bool {
if o != nil && o.Runs != nil {
return true
}
return false
}
// SetRuns gets a reference to the given []Run and assigns it to the Runs field.
func (o *Runs) SetRuns(v []Run) {
o.Runs = &v
}
func (o Runs) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Links != nil {
toSerialize["links"] = o.Links
}
if o.Runs != nil {
toSerialize["runs"] = o.Runs
}
return json.Marshal(toSerialize)
}
type NullableRuns struct {
value *Runs
isSet bool
}
func (v NullableRuns) Get() *Runs {
return v.value
}
func (v *NullableRuns) Set(val *Runs) {
v.value = val
v.isSet = true
}
func (v NullableRuns) IsSet() bool {
return v.isSet
}
func (v *NullableRuns) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRuns(val *Runs) *NullableRuns {
return &NullableRuns{value: val, isSet: true}
}
func (v NullableRuns) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRuns) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,745 @@
/*
* 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"
)
// Task struct for Task
type Task struct {
Id string `json:"id"`
// The type of task, this can be used for filtering tasks on list actions.
Type *string `json:"type,omitempty"`
// The ID of the organization that owns this Task.
OrgID string `json:"orgID"`
// The name of the organization that owns this Task.
Org *string `json:"org,omitempty"`
// The name of the task.
Name string `json:"name"`
// An optional description of the task.
Description *string `json:"description,omitempty"`
Status *TaskStatusType `json:"status,omitempty"`
Labels *[]Label `json:"labels,omitempty"`
// The ID of the authorization used when this task communicates with the query engine.
AuthorizationID *string `json:"authorizationID,omitempty"`
// The Flux script to run for this task.
Flux string `json:"flux"`
// A simple task repetition schedule; parsed from Flux.
Every *string `json:"every,omitempty"`
// A task repetition schedule in the form '* * * * * *'; parsed from Flux.
Cron *string `json:"cron,omitempty"`
// Duration to delay after the schedule, before executing the task; parsed from flux, if set to zero it will remove this option and use 0 as the default.
Offset *string `json:"offset,omitempty"`
// Timestamp of latest scheduled, completed run, RFC3339.
LatestCompleted *time.Time `json:"latestCompleted,omitempty"`
LastRunStatus *string `json:"lastRunStatus,omitempty"`
LastRunError *string `json:"lastRunError,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
Links *TaskLinks `json:"links,omitempty"`
}
// NewTask instantiates a new Task 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 NewTask(id string, orgID string, name string, flux string) *Task {
this := Task{}
this.Id = id
this.OrgID = orgID
this.Name = name
this.Flux = flux
return &this
}
// NewTaskWithDefaults instantiates a new Task 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 NewTaskWithDefaults() *Task {
this := Task{}
return &this
}
// GetId returns the Id field value
func (o *Task) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *Task) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *Task) SetId(v string) {
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
func (o *Task) 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 *Task) GetOrgIDOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OrgID, true
}
// SetOrgID sets field value
func (o *Task) SetOrgID(v string) {
o.OrgID = v
}
// GetOrg returns the Org field value if set, zero value otherwise.
func (o *Task) GetOrg() string {
if o == nil || o.Org == nil {
var ret string
return ret
}
return *o.Org
}
// GetOrgOk returns a tuple with the Org field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetOrgOk() (*string, bool) {
if o == nil || o.Org == nil {
return nil, false
}
return o.Org, true
}
// HasOrg returns a boolean if a field has been set.
func (o *Task) HasOrg() bool {
if o != nil && o.Org != nil {
return true
}
return false
}
// SetOrg gets a reference to the given string and assigns it to the Org field.
func (o *Task) SetOrg(v string) {
o.Org = &v
}
// GetName returns the Name field value
func (o *Task) 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 *Task) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *Task) SetName(v string) {
o.Name = v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *Task) 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 *Task) 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 *Task) 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 *Task) SetDescription(v string) {
o.Description = &v
}
// GetStatus returns the Status field value if set, zero value otherwise.
func (o *Task) GetStatus() TaskStatusType {
if o == nil || o.Status == nil {
var ret TaskStatusType
return ret
}
return *o.Status
}
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetStatusOk() (*TaskStatusType, bool) {
if o == nil || o.Status == nil {
return nil, false
}
return o.Status, true
}
// HasStatus returns a boolean if a field has been set.
func (o *Task) HasStatus() bool {
if o != nil && o.Status != nil {
return true
}
return false
}
// SetStatus gets a reference to the given TaskStatusType and assigns it to the Status field.
func (o *Task) SetStatus(v TaskStatusType) {
o.Status = &v
}
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *Task) GetLabels() []Label {
if o == nil || o.Labels == nil {
var ret []Label
return ret
}
return *o.Labels
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetLabelsOk() (*[]Label, bool) {
if o == nil || o.Labels == nil {
return nil, false
}
return o.Labels, true
}
// HasLabels returns a boolean if a field has been set.
func (o *Task) HasLabels() bool {
if o != nil && o.Labels != nil {
return true
}
return false
}
// SetLabels gets a reference to the given []Label and assigns it to the Labels field.
func (o *Task) SetLabels(v []Label) {
o.Labels = &v
}
// GetAuthorizationID returns the AuthorizationID field value if set, zero value otherwise.
func (o *Task) GetAuthorizationID() string {
if o == nil || o.AuthorizationID == nil {
var ret string
return ret
}
return *o.AuthorizationID
}
// GetAuthorizationIDOk returns a tuple with the AuthorizationID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetAuthorizationIDOk() (*string, bool) {
if o == nil || o.AuthorizationID == nil {
return nil, false
}
return o.AuthorizationID, true
}
// HasAuthorizationID returns a boolean if a field has been set.
func (o *Task) HasAuthorizationID() bool {
if o != nil && o.AuthorizationID != nil {
return true
}
return false
}
// SetAuthorizationID gets a reference to the given string and assigns it to the AuthorizationID field.
func (o *Task) SetAuthorizationID(v string) {
o.AuthorizationID = &v
}
// GetFlux returns the Flux field value
func (o *Task) GetFlux() string {
if o == nil {
var ret string
return ret
}
return o.Flux
}
// GetFluxOk returns a tuple with the Flux field value
// and a boolean to check if the value has been set.
func (o *Task) GetFluxOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Flux, true
}
// SetFlux sets field value
func (o *Task) SetFlux(v string) {
o.Flux = v
}
// GetEvery returns the Every field value if set, zero value otherwise.
func (o *Task) 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 *Task) 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 *Task) 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 *Task) SetEvery(v string) {
o.Every = &v
}
// GetCron returns the Cron field value if set, zero value otherwise.
func (o *Task) 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 *Task) 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 *Task) 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 *Task) SetCron(v string) {
o.Cron = &v
}
// GetOffset returns the Offset field value if set, zero value otherwise.
func (o *Task) 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 *Task) 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 *Task) 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 *Task) SetOffset(v string) {
o.Offset = &v
}
// GetLatestCompleted returns the LatestCompleted field value if set, zero value otherwise.
func (o *Task) GetLatestCompleted() time.Time {
if o == nil || o.LatestCompleted == nil {
var ret time.Time
return ret
}
return *o.LatestCompleted
}
// GetLatestCompletedOk returns a tuple with the LatestCompleted field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetLatestCompletedOk() (*time.Time, bool) {
if o == nil || o.LatestCompleted == nil {
return nil, false
}
return o.LatestCompleted, true
}
// HasLatestCompleted returns a boolean if a field has been set.
func (o *Task) HasLatestCompleted() bool {
if o != nil && o.LatestCompleted != nil {
return true
}
return false
}
// SetLatestCompleted gets a reference to the given time.Time and assigns it to the LatestCompleted field.
func (o *Task) SetLatestCompleted(v time.Time) {
o.LatestCompleted = &v
}
// GetLastRunStatus returns the LastRunStatus field value if set, zero value otherwise.
func (o *Task) GetLastRunStatus() string {
if o == nil || o.LastRunStatus == nil {
var ret string
return ret
}
return *o.LastRunStatus
}
// GetLastRunStatusOk returns a tuple with the LastRunStatus field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetLastRunStatusOk() (*string, bool) {
if o == nil || o.LastRunStatus == nil {
return nil, false
}
return o.LastRunStatus, true
}
// HasLastRunStatus returns a boolean if a field has been set.
func (o *Task) HasLastRunStatus() bool {
if o != nil && o.LastRunStatus != nil {
return true
}
return false
}
// SetLastRunStatus gets a reference to the given string and assigns it to the LastRunStatus field.
func (o *Task) SetLastRunStatus(v string) {
o.LastRunStatus = &v
}
// GetLastRunError returns the LastRunError field value if set, zero value otherwise.
func (o *Task) GetLastRunError() string {
if o == nil || o.LastRunError == nil {
var ret string
return ret
}
return *o.LastRunError
}
// GetLastRunErrorOk returns a tuple with the LastRunError field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetLastRunErrorOk() (*string, bool) {
if o == nil || o.LastRunError == nil {
return nil, false
}
return o.LastRunError, true
}
// HasLastRunError returns a boolean if a field has been set.
func (o *Task) HasLastRunError() bool {
if o != nil && o.LastRunError != nil {
return true
}
return false
}
// SetLastRunError gets a reference to the given string and assigns it to the LastRunError field.
func (o *Task) SetLastRunError(v string) {
o.LastRunError = &v
}
// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise.
func (o *Task) 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 *Task) 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 *Task) 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 *Task) SetCreatedAt(v time.Time) {
o.CreatedAt = &v
}
// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise.
func (o *Task) 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 *Task) 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 *Task) 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 *Task) SetUpdatedAt(v time.Time) {
o.UpdatedAt = &v
}
// GetLinks returns the Links field value if set, zero value otherwise.
func (o *Task) GetLinks() TaskLinks {
if o == nil || o.Links == nil {
var ret TaskLinks
return ret
}
return *o.Links
}
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Task) GetLinksOk() (*TaskLinks, bool) {
if o == nil || o.Links == nil {
return nil, false
}
return o.Links, true
}
// HasLinks returns a boolean if a field has been set.
func (o *Task) HasLinks() bool {
if o != nil && o.Links != nil {
return true
}
return false
}
// SetLinks gets a reference to the given TaskLinks and assigns it to the Links field.
func (o *Task) SetLinks(v TaskLinks) {
o.Links = &v
}
func (o Task) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if true {
toSerialize["id"] = o.Id
}
if o.Type != nil {
toSerialize["type"] = o.Type
}
if true {
toSerialize["orgID"] = o.OrgID
}
if o.Org != nil {
toSerialize["org"] = o.Org
}
if true {
toSerialize["name"] = o.Name
}
if o.Description != nil {
toSerialize["description"] = o.Description
}
if o.Status != nil {
toSerialize["status"] = o.Status
}
if o.Labels != nil {
toSerialize["labels"] = o.Labels
}
if o.AuthorizationID != nil {
toSerialize["authorizationID"] = o.AuthorizationID
}
if true {
toSerialize["flux"] = o.Flux
}
if o.Every != nil {
toSerialize["every"] = o.Every
}
if o.Cron != nil {
toSerialize["cron"] = o.Cron
}
if o.Offset != nil {
toSerialize["offset"] = o.Offset
}
if o.LatestCompleted != nil {
toSerialize["latestCompleted"] = o.LatestCompleted
}
if o.LastRunStatus != nil {
toSerialize["lastRunStatus"] = o.LastRunStatus
}
if o.LastRunError != nil {
toSerialize["lastRunError"] = o.LastRunError
}
if o.CreatedAt != nil {
toSerialize["createdAt"] = o.CreatedAt
}
if o.UpdatedAt != nil {
toSerialize["updatedAt"] = o.UpdatedAt
}
if o.Links != nil {
toSerialize["links"] = o.Links
}
return json.Marshal(toSerialize)
}
type NullableTask struct {
value *Task
isSet bool
}
func (v NullableTask) Get() *Task {
return v.value
}
func (v *NullableTask) Set(val *Task) {
v.value = val
v.isSet = true
}
func (v NullableTask) IsSet() bool {
return v.isSet
}
func (v *NullableTask) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTask(val *Task) *NullableTask {
return &NullableTask{value: val, isSet: true}
}
func (v NullableTask) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTask) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,254 @@
/*
* 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"
)
// TaskCreateRequest struct for TaskCreateRequest
type TaskCreateRequest struct {
// The ID of the organization that owns this Task.
OrgID *string `json:"orgID,omitempty"`
// The name of the organization that owns this Task.
Org *string `json:"org,omitempty"`
Status *TaskStatusType `json:"status,omitempty"`
// The Flux script to run for this task.
Flux string `json:"flux"`
// An optional description of the task.
Description *string `json:"description,omitempty"`
}
// NewTaskCreateRequest instantiates a new TaskCreateRequest 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 NewTaskCreateRequest(flux string) *TaskCreateRequest {
this := TaskCreateRequest{}
this.Flux = flux
return &this
}
// NewTaskCreateRequestWithDefaults instantiates a new TaskCreateRequest 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 NewTaskCreateRequestWithDefaults() *TaskCreateRequest {
this := TaskCreateRequest{}
return &this
}
// GetOrgID returns the OrgID field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetOrgID() string {
if o == nil || o.OrgID == nil {
var ret string
return ret
}
return *o.OrgID
}
// GetOrgIDOk returns a tuple with the OrgID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetOrgIDOk() (*string, bool) {
if o == nil || o.OrgID == nil {
return nil, false
}
return o.OrgID, true
}
// HasOrgID returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasOrgID() bool {
if o != nil && o.OrgID != nil {
return true
}
return false
}
// SetOrgID gets a reference to the given string and assigns it to the OrgID field.
func (o *TaskCreateRequest) SetOrgID(v string) {
o.OrgID = &v
}
// GetOrg returns the Org field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetOrg() string {
if o == nil || o.Org == nil {
var ret string
return ret
}
return *o.Org
}
// GetOrgOk returns a tuple with the Org field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetOrgOk() (*string, bool) {
if o == nil || o.Org == nil {
return nil, false
}
return o.Org, true
}
// HasOrg returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasOrg() bool {
if o != nil && o.Org != nil {
return true
}
return false
}
// SetOrg gets a reference to the given string and assigns it to the Org field.
func (o *TaskCreateRequest) SetOrg(v string) {
o.Org = &v
}
// GetStatus returns the Status field value if set, zero value otherwise.
func (o *TaskCreateRequest) GetStatus() TaskStatusType {
if o == nil || o.Status == nil {
var ret TaskStatusType
return ret
}
return *o.Status
}
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetStatusOk() (*TaskStatusType, bool) {
if o == nil || o.Status == nil {
return nil, false
}
return o.Status, true
}
// HasStatus returns a boolean if a field has been set.
func (o *TaskCreateRequest) HasStatus() bool {
if o != nil && o.Status != nil {
return true
}
return false
}
// SetStatus gets a reference to the given TaskStatusType and assigns it to the Status field.
func (o *TaskCreateRequest) SetStatus(v TaskStatusType) {
o.Status = &v
}
// GetFlux returns the Flux field value
func (o *TaskCreateRequest) GetFlux() string {
if o == nil {
var ret string
return ret
}
return o.Flux
}
// GetFluxOk returns a tuple with the Flux field value
// and a boolean to check if the value has been set.
func (o *TaskCreateRequest) GetFluxOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Flux, true
}
// SetFlux sets field value
func (o *TaskCreateRequest) SetFlux(v string) {
o.Flux = v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *TaskCreateRequest) 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 *TaskCreateRequest) 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 *TaskCreateRequest) 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 *TaskCreateRequest) SetDescription(v string) {
o.Description = &v
}
func (o TaskCreateRequest) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.OrgID != nil {
toSerialize["orgID"] = o.OrgID
}
if o.Org != nil {
toSerialize["org"] = o.Org
}
if o.Status != nil {
toSerialize["status"] = o.Status
}
if true {
toSerialize["flux"] = o.Flux
}
if o.Description != nil {
toSerialize["description"] = o.Description
}
return json.Marshal(toSerialize)
}
type NullableTaskCreateRequest struct {
value *TaskCreateRequest
isSet bool
}
func (v NullableTaskCreateRequest) Get() *TaskCreateRequest {
return v.value
}
func (v *NullableTaskCreateRequest) Set(val *TaskCreateRequest) {
v.value = val
v.isSet = true
}
func (v NullableTaskCreateRequest) IsSet() bool {
return v.isSet
}
func (v *NullableTaskCreateRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTaskCreateRequest(val *TaskCreateRequest) *NullableTaskCreateRequest {
return &NullableTaskCreateRequest{value: val, isSet: true}
}
func (v NullableTaskCreateRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTaskCreateRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,299 @@
/*
* 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"
)
// TaskLinks struct for TaskLinks
type TaskLinks struct {
// URI of resource.
Self *string `json:"self,omitempty"`
// URI of resource.
Owners *string `json:"owners,omitempty"`
// URI of resource.
Members *string `json:"members,omitempty"`
// URI of resource.
Runs *string `json:"runs,omitempty"`
// URI of resource.
Logs *string `json:"logs,omitempty"`
// URI of resource.
Labels *string `json:"labels,omitempty"`
}
// NewTaskLinks instantiates a new TaskLinks 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 NewTaskLinks() *TaskLinks {
this := TaskLinks{}
return &this
}
// NewTaskLinksWithDefaults instantiates a new TaskLinks 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 NewTaskLinksWithDefaults() *TaskLinks {
this := TaskLinks{}
return &this
}
// GetSelf returns the Self field value if set, zero value otherwise.
func (o *TaskLinks) GetSelf() string {
if o == nil || o.Self == nil {
var ret string
return ret
}
return *o.Self
}
// GetSelfOk returns a tuple with the Self field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskLinks) GetSelfOk() (*string, bool) {
if o == nil || o.Self == nil {
return nil, false
}
return o.Self, true
}
// HasSelf returns a boolean if a field has been set.
func (o *TaskLinks) HasSelf() bool {
if o != nil && o.Self != nil {
return true
}
return false
}
// SetSelf gets a reference to the given string and assigns it to the Self field.
func (o *TaskLinks) SetSelf(v string) {
o.Self = &v
}
// GetOwners returns the Owners field value if set, zero value otherwise.
func (o *TaskLinks) GetOwners() string {
if o == nil || o.Owners == nil {
var ret string
return ret
}
return *o.Owners
}
// GetOwnersOk returns a tuple with the Owners field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskLinks) GetOwnersOk() (*string, bool) {
if o == nil || o.Owners == nil {
return nil, false
}
return o.Owners, true
}
// HasOwners returns a boolean if a field has been set.
func (o *TaskLinks) HasOwners() bool {
if o != nil && o.Owners != nil {
return true
}
return false
}
// SetOwners gets a reference to the given string and assigns it to the Owners field.
func (o *TaskLinks) SetOwners(v string) {
o.Owners = &v
}
// GetMembers returns the Members field value if set, zero value otherwise.
func (o *TaskLinks) GetMembers() string {
if o == nil || o.Members == nil {
var ret string
return ret
}
return *o.Members
}
// GetMembersOk returns a tuple with the Members field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskLinks) GetMembersOk() (*string, bool) {
if o == nil || o.Members == nil {
return nil, false
}
return o.Members, true
}
// HasMembers returns a boolean if a field has been set.
func (o *TaskLinks) HasMembers() bool {
if o != nil && o.Members != nil {
return true
}
return false
}
// SetMembers gets a reference to the given string and assigns it to the Members field.
func (o *TaskLinks) SetMembers(v string) {
o.Members = &v
}
// GetRuns returns the Runs field value if set, zero value otherwise.
func (o *TaskLinks) GetRuns() string {
if o == nil || o.Runs == nil {
var ret string
return ret
}
return *o.Runs
}
// GetRunsOk returns a tuple with the Runs field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskLinks) GetRunsOk() (*string, bool) {
if o == nil || o.Runs == nil {
return nil, false
}
return o.Runs, true
}
// HasRuns returns a boolean if a field has been set.
func (o *TaskLinks) HasRuns() bool {
if o != nil && o.Runs != nil {
return true
}
return false
}
// SetRuns gets a reference to the given string and assigns it to the Runs field.
func (o *TaskLinks) SetRuns(v string) {
o.Runs = &v
}
// GetLogs returns the Logs field value if set, zero value otherwise.
func (o *TaskLinks) GetLogs() string {
if o == nil || o.Logs == nil {
var ret string
return ret
}
return *o.Logs
}
// GetLogsOk returns a tuple with the Logs field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskLinks) GetLogsOk() (*string, bool) {
if o == nil || o.Logs == nil {
return nil, false
}
return o.Logs, true
}
// HasLogs returns a boolean if a field has been set.
func (o *TaskLinks) HasLogs() bool {
if o != nil && o.Logs != nil {
return true
}
return false
}
// SetLogs gets a reference to the given string and assigns it to the Logs field.
func (o *TaskLinks) SetLogs(v string) {
o.Logs = &v
}
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *TaskLinks) GetLabels() string {
if o == nil || o.Labels == nil {
var ret string
return ret
}
return *o.Labels
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskLinks) GetLabelsOk() (*string, bool) {
if o == nil || o.Labels == nil {
return nil, false
}
return o.Labels, true
}
// HasLabels returns a boolean if a field has been set.
func (o *TaskLinks) HasLabels() bool {
if o != nil && o.Labels != nil {
return true
}
return false
}
// SetLabels gets a reference to the given string and assigns it to the Labels field.
func (o *TaskLinks) SetLabels(v string) {
o.Labels = &v
}
func (o TaskLinks) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Self != nil {
toSerialize["self"] = o.Self
}
if o.Owners != nil {
toSerialize["owners"] = o.Owners
}
if o.Members != nil {
toSerialize["members"] = o.Members
}
if o.Runs != nil {
toSerialize["runs"] = o.Runs
}
if o.Logs != nil {
toSerialize["logs"] = o.Logs
}
if o.Labels != nil {
toSerialize["labels"] = o.Labels
}
return json.Marshal(toSerialize)
}
type NullableTaskLinks struct {
value *TaskLinks
isSet bool
}
func (v NullableTaskLinks) Get() *TaskLinks {
return v.value
}
func (v *NullableTaskLinks) Set(val *TaskLinks) {
v.value = val
v.isSet = true
}
func (v NullableTaskLinks) IsSet() bool {
return v.isSet
}
func (v *NullableTaskLinks) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTaskLinks(val *TaskLinks) *NullableTaskLinks {
return &NullableTaskLinks{value: val, isSet: true}
}
func (v NullableTaskLinks) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTaskLinks) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,83 @@
/*
* 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"
)
// TaskStatusType the model 'TaskStatusType'
type TaskStatusType string
// List of TaskStatusType
const (
TASKSTATUSTYPE_ACTIVE TaskStatusType = "active"
TASKSTATUSTYPE_INACTIVE TaskStatusType = "inactive"
)
func (v *TaskStatusType) UnmarshalJSON(src []byte) error {
var value string
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
enumTypeValue := TaskStatusType(value)
for _, existing := range []TaskStatusType{"active", "inactive"} {
if existing == enumTypeValue {
*v = enumTypeValue
return nil
}
}
return fmt.Errorf("%+v is not a valid TaskStatusType", value)
}
// Ptr returns reference to TaskStatusType value
func (v TaskStatusType) Ptr() *TaskStatusType {
return &v
}
type NullableTaskStatusType struct {
value *TaskStatusType
isSet bool
}
func (v NullableTaskStatusType) Get() *TaskStatusType {
return v.value
}
func (v *NullableTaskStatusType) Set(val *TaskStatusType) {
v.value = val
v.isSet = true
}
func (v NullableTaskStatusType) IsSet() bool {
return v.isSet
}
func (v *NullableTaskStatusType) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTaskStatusType(val *TaskStatusType) *NullableTaskStatusType {
return &NullableTaskStatusType{value: val, isSet: true}
}
func (v NullableTaskStatusType) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTaskStatusType) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,335 @@
/*
* 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"
)
// TaskUpdateRequest struct for TaskUpdateRequest
type TaskUpdateRequest struct {
Status *TaskStatusType `json:"status,omitempty"`
// The Flux script to run for this task.
Flux *string `json:"flux,omitempty"`
// Override the 'name' option in the flux script.
Name *string `json:"name,omitempty"`
// Override the 'every' option in the flux script.
Every *string `json:"every,omitempty"`
// Override the 'cron' option in the flux script.
Cron *string `json:"cron,omitempty"`
// Override the 'offset' option in the flux script.
Offset *string `json:"offset,omitempty"`
// An optional description of the task.
Description *string `json:"description,omitempty"`
}
// NewTaskUpdateRequest instantiates a new TaskUpdateRequest 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 NewTaskUpdateRequest() *TaskUpdateRequest {
this := TaskUpdateRequest{}
return &this
}
// NewTaskUpdateRequestWithDefaults instantiates a new TaskUpdateRequest 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 NewTaskUpdateRequestWithDefaults() *TaskUpdateRequest {
this := TaskUpdateRequest{}
return &this
}
// GetStatus returns the Status field value if set, zero value otherwise.
func (o *TaskUpdateRequest) GetStatus() TaskStatusType {
if o == nil || o.Status == nil {
var ret TaskStatusType
return ret
}
return *o.Status
}
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TaskUpdateRequest) GetStatusOk() (*TaskStatusType, bool) {
if o == nil || o.Status == nil {
return nil, false
}
return o.Status, true
}
// HasStatus returns a boolean if a field has been set.
func (o *TaskUpdateRequest) HasStatus() bool {
if o != nil && o.Status != nil {
return true
}
return false
}
// SetStatus gets a reference to the given TaskStatusType and assigns it to the Status field.
func (o *TaskUpdateRequest) SetStatus(v TaskStatusType) {
o.Status = &v
}
// GetFlux returns the Flux field value if set, zero value otherwise.
func (o *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) SetFlux(v string) {
o.Flux = &v
}
// GetName returns the Name field value if set, zero value otherwise.
func (o *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) SetName(v string) {
o.Name = &v
}
// GetEvery returns the Every field value if set, zero value otherwise.
func (o *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) SetEvery(v string) {
o.Every = &v
}
// GetCron returns the Cron field value if set, zero value otherwise.
func (o *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) SetCron(v string) {
o.Cron = &v
}
// GetOffset returns the Offset field value if set, zero value otherwise.
func (o *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) SetOffset(v string) {
o.Offset = &v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) 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 *TaskUpdateRequest) SetDescription(v string) {
o.Description = &v
}
func (o TaskUpdateRequest) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Status != nil {
toSerialize["status"] = o.Status
}
if o.Flux != nil {
toSerialize["flux"] = o.Flux
}
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
}
if o.Description != nil {
toSerialize["description"] = o.Description
}
return json.Marshal(toSerialize)
}
type NullableTaskUpdateRequest struct {
value *TaskUpdateRequest
isSet bool
}
func (v NullableTaskUpdateRequest) Get() *TaskUpdateRequest {
return v.value
}
func (v *NullableTaskUpdateRequest) Set(val *TaskUpdateRequest) {
v.value = val
v.isSet = true
}
func (v NullableTaskUpdateRequest) IsSet() bool {
return v.isSet
}
func (v *NullableTaskUpdateRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTaskUpdateRequest(val *TaskUpdateRequest) *NullableTaskUpdateRequest {
return &NullableTaskUpdateRequest{value: val, isSet: true}
}
func (v NullableTaskUpdateRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTaskUpdateRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,149 @@
/*
* 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"
)
// Tasks struct for Tasks
type Tasks struct {
Links *Links `json:"links,omitempty"`
Tasks *[]Task `json:"tasks,omitempty"`
}
// NewTasks instantiates a new Tasks 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 NewTasks() *Tasks {
this := Tasks{}
return &this
}
// NewTasksWithDefaults instantiates a new Tasks 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 NewTasksWithDefaults() *Tasks {
this := Tasks{}
return &this
}
// GetLinks returns the Links field value if set, zero value otherwise.
func (o *Tasks) GetLinks() Links {
if o == nil || o.Links == nil {
var ret Links
return ret
}
return *o.Links
}
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Tasks) GetLinksOk() (*Links, bool) {
if o == nil || o.Links == nil {
return nil, false
}
return o.Links, true
}
// HasLinks returns a boolean if a field has been set.
func (o *Tasks) HasLinks() bool {
if o != nil && o.Links != nil {
return true
}
return false
}
// SetLinks gets a reference to the given Links and assigns it to the Links field.
func (o *Tasks) SetLinks(v Links) {
o.Links = &v
}
// GetTasks returns the Tasks field value if set, zero value otherwise.
func (o *Tasks) GetTasks() []Task {
if o == nil || o.Tasks == nil {
var ret []Task
return ret
}
return *o.Tasks
}
// GetTasksOk returns a tuple with the Tasks field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Tasks) GetTasksOk() (*[]Task, bool) {
if o == nil || o.Tasks == nil {
return nil, false
}
return o.Tasks, true
}
// HasTasks returns a boolean if a field has been set.
func (o *Tasks) HasTasks() bool {
if o != nil && o.Tasks != nil {
return true
}
return false
}
// SetTasks gets a reference to the given []Task and assigns it to the Tasks field.
func (o *Tasks) SetTasks(v []Task) {
o.Tasks = &v
}
func (o Tasks) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Links != nil {
toSerialize["links"] = o.Links
}
if o.Tasks != nil {
toSerialize["tasks"] = o.Tasks
}
return json.Marshal(toSerialize)
}
type NullableTasks struct {
value *Tasks
isSet bool
}
func (v NullableTasks) Get() *Tasks {
return v.value
}
func (v *NullableTasks) Set(val *Tasks) {
v.value = val
v.isSet = true
}
func (v NullableTasks) IsSet() bool {
return v.isSet
}
func (v *NullableTasks) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTasks(val *Tasks) *NullableTasks {
return &NullableTasks{value: val, isSet: true}
}
func (v NullableTasks) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTasks) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

99
internal/cmd/task/task.go Normal file
View File

@ -0,0 +1,99 @@
package task
import (
"context"
"github.com/influxdata/influx-cli/v2/internal/api"
"github.com/influxdata/influx-cli/v2/internal/cmd"
)
type Client struct {
cmd.CLI
api.TasksApi
// AllowEmptyOrg will be useful for Kapacitor which doesn't use org / orgID
AllowEmptyOrg bool
}
type CreateParams struct {
cmd.OrgParams
FluxQuery string
}
func (c Client) getOrg(params *cmd.OrgParams) (string, error) {
if params.OrgID.Valid() {
return params.OrgID.String(), nil
}
if params.OrgName != "" {
return params.OrgName, nil
}
if c.ActiveConfig.Org != "" {
return c.ActiveConfig.Org, nil
}
if c.AllowEmptyOrg {
return "", nil
}
return "", cmd.ErrMustSpecifyOrg
}
func (c Client) Create(ctx context.Context, params *CreateParams) error {
org, err := c.getOrg(&params.OrgParams)
if err != nil {
return err
}
task, err := c.PostTasks(ctx).TaskCreateRequest(api.TaskCreateRequest{
Org: &org,
Flux: params.FluxQuery,
Description: nil,
}).Execute()
if err != nil {
return err
}
return c.printTasks(taskPrintOpts{
task: &task,
})
}
type taskPrintOpts struct {
task *api.Task
tasks []*api.Task
}
func (c Client) printTasks(printOpts taskPrintOpts) error {
if c.PrintAsJSON {
var v interface{} = printOpts.tasks
if printOpts.task != nil {
v = printOpts.task
}
return c.PrintJSON(v)
}
headers := []string{
"ID",
"Name",
"Organization ID",
"Organization",
"Status",
"Every",
"Cron",
}
if printOpts.task != nil {
printOpts.tasks = append(printOpts.tasks, printOpts.task)
}
var rows []map[string]interface{}
for _, t := range printOpts.tasks {
row := map[string]interface{}{
"ID": t.Id,
"Name": t.Name,
"Organization ID": t.OrgID,
"Organization": t.Org,
"Status": t.Status,
"Every": t.Every,
"Cron": t.Cron,
}
rows = append(rows, row)
}
return c.PrintTable(headers, rows...)
}

View File

@ -24,17 +24,13 @@ type CreateParams struct {
var ErrMustSpecifyUser = errors.New("must specify user ID or user name")
func (c Client) Create(ctx context.Context, params *CreateParams) error {
func getOrgID(ctx context.Context, params *cmd.OrgParams, c cmd.CLI, orgApi api.OrganizationsApi) (string, error) {
if !params.OrgID.Valid() && params.OrgName == "" && c.ActiveConfig.Org == "" {
return cmd.ErrMustSpecifyOrg
return "", cmd.ErrMustSpecifyOrg
}
if params.Password != "" && len(params.Password) < cmd.MinPasswordLen {
return cmd.ErrPasswordIsTooShort
}
orgId := params.OrgID.String()
orgID := params.OrgID.String()
if !params.OrgID.Valid() {
req := c.GetOrgs(ctx)
req := orgApi.GetOrgs(ctx)
if params.OrgName != "" {
req = req.Org(params.OrgName)
} else {
@ -42,12 +38,24 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
}
orgs, err := req.Execute()
if err != nil {
return fmt.Errorf("failed to find org %q: %w", params.OrgName, err)
return "", fmt.Errorf("failed to find org %q: %w", params.OrgName, err)
}
if orgs.Orgs == nil || len(*orgs.Orgs) == 0 {
return fmt.Errorf("no org found with name %q", params.OrgName)
return "", fmt.Errorf("no org found with name %q", params.OrgName)
}
orgId = (*orgs.Orgs)[0].GetId()
orgID = (*orgs.Orgs)[0].GetId()
}
return orgID, nil
}
func (c Client) Create(ctx context.Context, params *CreateParams) error {
if params.Password != "" && len(params.Password) < cmd.MinPasswordLen {
return cmd.ErrPasswordIsTooShort
}
orgID, err := getOrgID(ctx, &params.OrgParams, c.CLI, c.OrganizationsApi)
if err != nil {
return err
}
user, err := c.PostUsers(ctx).User(api.User{Name: params.Name}).Execute()
@ -59,7 +67,7 @@ func (c Client) Create(ctx context.Context, params *CreateParams) error {
}
memberBody := api.AddResourceMemberRequestBody{Id: *user.Id}
if _, err := c.PostOrgsIDMembers(ctx, orgId).AddResourceMemberRequestBody(memberBody).Execute(); err != nil {
if _, err := c.PostOrgsIDMembers(ctx, orgID).AddResourceMemberRequestBody(memberBody).Execute(); err != nil {
_, _ = c.StdIO.WriteErr([]byte("WARN: initial password not set for user, use `influx user password` to set it\n"))
return fmt.Errorf("failed setting org membership for user %q, use `influx org members add` to retry: %w", user.Name, err)
}