workflows

package
v1.58.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SchemaVersion = 3

Variables

View Source
var Elses = struct {
	Success Else
	Error   Else
}{
	"SKIP",
	"STOP",
}
View Source
var EntityTagsMatches = struct {
	All EntityTagsMatch
	Any EntityTagsMatch
}{
	"all",
	"any",
}
View Source
var EventTriggerTypes = struct {
	Event        EventTriggerType
	DavisProblem EventTriggerType
	DavisEvent   EventTriggerType
}{
	"event",
	"davis-problem",
	"davis-event",
}
View Source
var EventTypes = struct {
	Events    EventType
	BizEvents EventType
}{
	"events",
	"bizevents",
}
View Source
var ScheduleInputTypes = struct {
	Static ScheduleInputType
}{
	"static",
}
View Source
var ScheduleTriggerTypes = struct {
	Cron     ScheduleTriggerType
	Time     ScheduleTriggerType
	Interval ScheduleTriggerType
}{
	"cron",
	"time",
	"interval",
}
View Source
var States = struct {
	Running   State
	Success   State
	Error     State
	Waiting   State
	Idle      State
	Paused    State
	Delayed   State
	Cancelled State
}{
	"RUNNING",
	"SUCCESS",
	"ERROR",
	"WAITING",
	"IDLE",
	"PAUSED",
	"DELAYED",
	"CANCELLED",
}
View Source
var Statuses = struct {
	Success Status
	Error   Status
	Any     Status
	Ok      Status // Success or Skipped
	NOk     Status // Error or Cancelled
}{
	"SUCCESS",
	"ERROR",
	"ANY",
	"OK",
	"NOK",
}
View Source
var TriggerTypes = struct {
	Schedule TriggerType
	Event    TriggerType
	Manual   TriggerType
}{
	"Schedule",
	"Event",
	"Manual",
}
View Source
var Validate = func(fn ...schema.SchemaValidateDiagFunc) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		for _, validateFunc := range fn {
			diags = append(diags, validateFunc(i, p)...)
		}
		return diags
	}
}
View Source
var ValidateMax = func(max int) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		var iv int
		switch v := i.(type) {
		case int:
			iv = v
		case string:
			var err error
			v = strings.TrimSpace(v)
			if strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}") {
				return diags
			}
			iv, err = strconv.Atoi(v)
			if err != nil {
				diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%s is not a number", i.(string))})
				return diags
			}
		}
		if iv > max {
			diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%v must not be greater than %d", i, max)})
		}
		return diags
	}
}
View Source
var ValidateMaxLength = func(maxLength int) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		if len(i.(string)) > maxLength {
			diag := diag.Diagnostic{
				Severity: diag.Error,
				Summary:  fmt.Sprintf("%s exceeds the maximum length of %d characters", i.(string), maxLength),
			}
			diags = append(diags, diag)
		}
		return diags
	}
}
View Source
var ValidateMin = func(min int) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		var iv int
		switch v := i.(type) {
		case int:
			iv = v
		case string:
			var err error
			v = strings.TrimSpace(v)
			if strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}") {
				return diags
			}
			iv, err = strconv.Atoi(v)
			if err != nil {
				diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%s is not a number", i.(string))})
				return diags
			}
		}
		if iv < min {
			diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%v must not be less than %d", i, min)})
		}
		return diags
	}
}
View Source
var ValidateMinLength = func(min int) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		if len(i.(string)) < min {
			diag := diag.Diagnostic{
				Severity: diag.Error,
				Summary:  fmt.Sprintf("%s must be at least %d characters long", i.(string), min),
			}
			diags = append(diags, diag)
		}
		return diags
	}
}
View Source
var ValidateRange = func(min int, max int) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		var iv int
		switch v := i.(type) {
		case int:
			iv = v
		case string:
			var err error
			v = strings.TrimSpace(v)
			if strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}") {
				return diags
			}
			iv, err = strconv.Atoi(v)
			if err != nil {
				diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%s is not a number", i.(string))})
				return diags
			}
		}
		if iv < min || iv > max {
			diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%v is not in range %d and %d", i, min, max)})
		}
		return diags
	}
}
View Source
var ValidateRegex = func(r *regexp.Regexp, errorMessage string) schema.SchemaValidateDiagFunc {
	return func(i any, p cty.Path) diag.Diagnostics {
		var diags diag.Diagnostics
		if !r.MatchString(i.(string)) {
			diag := diag.Diagnostic{
				Severity: diag.Error,
				Summary:  fmt.Sprintf("%s contains invalid characters", i.(string)),
				Detail:   errorMessage,
			}
			diags = append(diags, diag)
		}
		return diags
	}
}
View Source
var ValidateUUID = func(i any, p cty.Path) diag.Diagnostics {
	var diags diag.Diagnostics
	if _, err := uuid.Parse(i.(string)); err != nil {
		diag := diag.Diagnostic{
			Severity: diag.Error,
			Summary:  "The value is expected to be a UUID",
			Detail:   fmt.Sprintf("%v is not a UUID", i),
		}
		diags = append(diags, diag)
	}
	return diags
}

Functions

This section is empty.

Types

type DavisEventConfig

type DavisEventConfig struct {
	EntityTagsMatch EntityTagsMatch   `json:"entityTagsMatch"`                // Possible values: `all` and `any`
	EntityTags      map[string]string `json:"entityTags"`                     // key/value pairs for entity tags to match for. For tags that don't require a value, just specify an empty string as value. Omit this attribute if all entities should match
	OnProblemClose  bool              `json:"onProblemClose" default:"false"` // If set to `true` closing a problem also is considered an event that triggers the execution
	Types           []string          `json:"types" flags:"uniqueitems"`      // The types of davis events to trigger an execution
}

func (*DavisEventConfig) MarshalHCL

func (me *DavisEventConfig) MarshalHCL(properties hcl.Properties) error

func (*DavisEventConfig) Schema

func (me *DavisEventConfig) Schema(prefix string) map[string]*schema.Schema

func (*DavisEventConfig) UnmarshalHCL

func (me *DavisEventConfig) UnmarshalHCL(decoder hcl.Decoder) error

type DavisProblemCategories

type DavisProblemCategories struct {
	MonitoringUnavailable bool `json:"monitoringUnavailable"` //
	Availability          bool `json:"availability"`          //
	Error                 bool `json:"error"`                 //
	Slowdown              bool `json:"slowdown"`              //
	Resource              bool `json:"resource"`              //
	Custom                bool `json:"custom"`                //
	Info                  bool `json:"info"`                  //
}

func (*DavisProblemCategories) MarshalHCL

func (me *DavisProblemCategories) MarshalHCL(properties hcl.Properties) error

func (*DavisProblemCategories) Schema

func (me *DavisProblemCategories) Schema(prefix string) map[string]*schema.Schema

func (*DavisProblemCategories) UnmarshalHCL

func (me *DavisProblemCategories) UnmarshalHCL(decoder hcl.Decoder) error

type DavisProblemConfig

type DavisProblemConfig struct {
	EntityTagsMatch EntityTagsMatch         `json:"entityTagsMatch"`                // Possible values: `all` and `any`
	EntityTags      map[string]string       `json:"entityTags"`                     //
	OnProblemClose  bool                    `json:"onProblemClose" default:"false"` //
	Categories      *DavisProblemCategories `json:"categories"`                     //
	CustomFilter    string                  `json:"customFilter,omitempty"`         //
}

func (*DavisProblemConfig) MarshalHCL

func (me *DavisProblemConfig) MarshalHCL(properties hcl.Properties) error

func (*DavisProblemConfig) Schema

func (me *DavisProblemConfig) Schema(prefix string) map[string]*schema.Schema

func (*DavisProblemConfig) UnmarshalHCL

func (me *DavisProblemConfig) UnmarshalHCL(decoder hcl.Decoder) error

type Else

type Else string

type EntityTagsMatch

type EntityTagsMatch string

type EventQuery

type EventQuery struct {
	Query     string    `json:"query" minlength:"1" maxlength:"800"` //
	EventType EventType `json:"eventType"`                           //
}

func (*EventQuery) MarshalHCL

func (me *EventQuery) MarshalHCL(properties hcl.Properties) error

func (*EventQuery) Schema

func (me *EventQuery) Schema(prefix string) map[string]*schema.Schema

func (*EventQuery) UnmarshalHCL

func (me *EventQuery) UnmarshalHCL(decoder hcl.Decoder) error

type EventTrigger

type EventTrigger struct {
	Active               bool                `json:"isActive"`             // The trigger is active (`true`) or not (`false`)
	TriggerConfiguration *EventTriggerConfig `json:"triggerConfiguration"` //

}

func (*EventTrigger) MarshalHCL

func (me *EventTrigger) MarshalHCL(properties hcl.Properties) error

func (*EventTrigger) Schema

func (me *EventTrigger) Schema(prefix string) map[string]*schema.Schema

func (*EventTrigger) UnmarshalHCL

func (me *EventTrigger) UnmarshalHCL(decoder hcl.Decoder) error

type EventTriggerConfig

type EventTriggerConfig struct {
	Type EventTriggerType `json:"type"` // `event`, `davis-problem` or `davis-event`

	DavisEventConfig   *DavisEventConfig   `json:"-"` // type = `event`
	DavisProblemConfig *DavisProblemConfig `json:"-"` // type = `davis-problem`
	EventQuery         *EventQuery         `json:"-"` // type = `davis-event`
	GenericConfig      *string             `json:"-"` // type = yet unknown
}

func (*EventTriggerConfig) GetType

func (me *EventTriggerConfig) GetType() *EventTriggerType

func (*EventTriggerConfig) MarshalHCL

func (me *EventTriggerConfig) MarshalHCL(properties hcl.Properties) error

func (*EventTriggerConfig) MarshalJSON

func (me *EventTriggerConfig) MarshalJSON() ([]byte, error)

func (*EventTriggerConfig) Schema

func (me *EventTriggerConfig) Schema(prefix string) map[string]*schema.Schema

func (*EventTriggerConfig) UnmarshalHCL

func (me *EventTriggerConfig) UnmarshalHCL(decoder hcl.Decoder) error

func (*EventTriggerConfig) UnmarshalJSON

func (me *EventTriggerConfig) UnmarshalJSON(data []byte) error

type EventTriggerType

type EventTriggerType string

func (EventTriggerType) IsKnown

func (me EventTriggerType) IsKnown() bool

type EventType

type EventType string

type Schedule

type Schedule struct {
	Active           bool                      `json:"isActive"`                     // The trigger is enabled (`true`) or not (`false`). Default is `false`
	Trigger          *ScheduleTrigger          `json:"trigger"`                      // Detailed configuration about the timing constraints that trigger the execution
	Rule             *string                   `json:"rule,omitempty" format:"uuid"` // Refers to a configured rule that determines at which days the schedule should be active. If not specified it implies that the schedule is valid every day
	FilterParameters *ScheduleFilterParameters `json:"filterParameters"`             // Advanced restrictions for the schedule to trigger executions
	Timezone         *string                   `json:"timezone,omitempty"`           // A time zone the scheduled times to align with. If not specified it will be chosen automatically based on the location of the Dynatrace Server

}

func (*Schedule) MarshalHCL

func (me *Schedule) MarshalHCL(properties hcl.Properties) error

func (*Schedule) Schema

func (me *Schedule) Schema(prefix string) map[string]*schema.Schema

func (*Schedule) UnmarshalHCL

func (me *Schedule) UnmarshalHCL(decoder hcl.Decoder) error

type ScheduleFilterParameters

type ScheduleFilterParameters struct {
	Count             *int     `json:"count,omitempty" default:"10" minimum:"1"`                     // If specified, the schedule will end triggering executions af the given amount of executions. Minimum: 1, Maximum: 10
	EarliestStart     *string  `json:"earliestStart,omitempty" format:"date"`                        // If specified, the schedule won't trigger executions before the given date
	EarliestStartTime *string  `json:"earliestStartTime,omitempty" default:"00:00:00" format:"time"` // If specified, the schedule won't trigger executions before the given time
	Until             *string  `json:"until,omitempty" format:"date"`                                // If specified, the schedule won't trigger executions after the given date
	IncludeDates      []string `json:"includeDates,omitempty" format:"date"`                         // If specified, the schedule will trigger executions on the given dates, even if the main configuration prohibits it
	ExcludeDates      []string `json:"excludeDates,omitempty" format:"date"`                         // If specified, the schedule won't trigger exeuctions on the given dates
}

func (*ScheduleFilterParameters) MarshalHCL

func (me *ScheduleFilterParameters) MarshalHCL(properties hcl.Properties) error

func (*ScheduleFilterParameters) Schema

func (me *ScheduleFilterParameters) Schema(prefix string) map[string]*schema.Schema

func (*ScheduleFilterParameters) UnmarshalHCL

func (me *ScheduleFilterParameters) UnmarshalHCL(decoder hcl.Decoder) error

type ScheduleInputType

type ScheduleInputType string

type ScheduleTrigger

type ScheduleTrigger struct {
	Type ScheduleTriggerType `json:"type"`

	// TimeTrigger - type <= time
	Time *string `json:"time,omitempty" pattern:"^([0-1]{1}[0-9]|2[0-3]):[0-5][0-9]$"` // Specifies a fixed time the schedule will trigger at in 24h format (e.g. `14:23:59`). Conflicts with `cron`, `interval_minutes`, `between_start` and `between_end`

	// CronTrigger - type <= cron
	Cron *string `json:"cron,omitempty" example:"0 0 * * *"` // Configures using cron syntax. Conflicts with `time`, `interval_minutes`, `between_start` and `between_end`.

	// IntervalTrigger - type <= interval
	IntervalMinutes *int    `json:"intervalMinutes,omitempty" minimum:"1" maximum:"720"`                  // Triggers the schedule every n minutes within a given time frame. Conflicts with `cron` and `time`. Required with `between_start` and `between_end`.
	BetweenStart    *string `json:"betweenStart,omitempty" pattern:"^([0-1]{1}[0-9]|2[0-3]):[0-5][0-9]$"` // Triggers the schedule every n minutes within a given time frame. Conflicts with `cron` and `time`. Required with `interval_minutes` and `between_end`.
	BetweenEnd      *string `json:"betweenEnd,omitempty" pattern:"^([0-1]{1}[0-9]|2[0-3]):[0-5][0-9]$"`   // Triggers the schedule every n minutes within a given time frame. Conflicts with `cron` and `time`. Required with `between_start` and `interval_minutes`.
}

func (*ScheduleTrigger) MarshalHCL

func (me *ScheduleTrigger) MarshalHCL(properties hcl.Properties) error

func (*ScheduleTrigger) Schema

func (me *ScheduleTrigger) Schema(prefix string) map[string]*schema.Schema

func (*ScheduleTrigger) UnmarshalHCL

func (me *ScheduleTrigger) UnmarshalHCL(decoder hcl.Decoder) error

type ScheduleTriggerType

type ScheduleTriggerType string

type State

type State string

type Status

type Status string

type Task

type Task struct {
	Name         string               `json:"name" pattern:"^(?!.*null$)([A-Za-z_][A-Za-z0-9-_]*)$"` // The name of the task
	Action       string               `json:"action" pattern:"^.+:.+$"`
	Description  *string              `json:"description,omitempty"` // A description for this task
	Input        map[string]any       `json:"input"`
	Active       bool                 `json:"active" default:"true"` // Specifies whether a task should be skipped as a no operation or not
	Position     *TaskPosition        `json:"position"`
	Predecessors []string             `json:"predecessors,omitempty"`
	Conditions   *TaskConditionOption `json:"conditions,omitempty"`
	WithItems    *string              `json:"withItems,omitempty"`
	Concurrency  *VarInt              `json:"concurrency" minimum:"1" maximum:"99"`
	Retry        *TaskRetryOption     `json:"retry,omitempty"`
	Timeout      *VarInt              `json:"timeout" default:"900" minimum:"1" maximum:"604800"` // Specifies a default task timeout. 15 * 60 (15min) is used when not set
}

func (*Task) MarshalHCL

func (me *Task) MarshalHCL(properties hcl.Properties) error

func (*Task) Schema

func (me *Task) Schema(prefix string) map[string]*schema.Schema

func (*Task) UnmarshalHCL

func (me *Task) UnmarshalHCL(decoder hcl.Decoder) error

type TaskConditionOption

type TaskConditionOption struct {
	States map[string]Status `json:"states,omitempty"` // key/value pairs where the `key` is the name of another task and the value the status it needs to be for the current task to get executed. Possible values are `SUCCESS`, `ERROR`, `ANY`, `OK` and `NOK`
	Custom *string           `json:"custom,omitempty"` // A custom condition that needs to be met for the current task to get executed
	Else   *Else             `json:"else,omitempty"`
}

func (*TaskConditionOption) MarshalHCL

func (me *TaskConditionOption) MarshalHCL(properties hcl.Properties) error

func (*TaskConditionOption) Schema

func (me *TaskConditionOption) Schema(prefix string) map[string]*schema.Schema

func (*TaskConditionOption) UnmarshalHCL

func (me *TaskConditionOption) UnmarshalHCL(decoder hcl.Decoder) error

type TaskPosition

type TaskPosition struct {
	X int `json:"x"`
	Y int `json:"y"`
}

func (*TaskPosition) MarshalHCL

func (me *TaskPosition) MarshalHCL(properties hcl.Properties) error

func (*TaskPosition) Schema

func (me *TaskPosition) Schema(prefix string) map[string]*schema.Schema

func (*TaskPosition) UnmarshalHCL

func (me *TaskPosition) UnmarshalHCL(decoder hcl.Decoder) error

type TaskRetryOption

type TaskRetryOption struct {
	Count                    VarInt  `json:"count" minimum:"0" maximum:"99"`                    // Specifies a maximum number of times that a task can be repeated in case it fails on execution
	Delay                    *VarInt `json:"delay,omitempty" minimum:"0" maximum:"3600"`        // Specifies a delay in seconds between subsequent task retries
	FailedLoopIterationsOnly *bool   `json:"failedLoopIterationsOnly,omitempty" default:"true"` // Specifies whether retrying the failed iterations or the whole loop. Default: True
}

func (*TaskRetryOption) MarshalHCL

func (me *TaskRetryOption) MarshalHCL(properties hcl.Properties) error

func (*TaskRetryOption) Schema

func (me *TaskRetryOption) Schema(prefix string) map[string]*schema.Schema

func (*TaskRetryOption) UnmarshalHCL

func (me *TaskRetryOption) UnmarshalHCL(decoder hcl.Decoder) error

type Tasks

type Tasks []*Task

func (Tasks) MarshalHCL

func (me Tasks) MarshalHCL(properties hcl.Properties) error

func (Tasks) MarshalJSON

func (me Tasks) MarshalJSON() ([]byte, error)

func (*Tasks) Schema

func (me *Tasks) Schema(prefix string) map[string]*schema.Schema

func (*Tasks) UnmarshalHCL

func (me *Tasks) UnmarshalHCL(decoder hcl.Decoder) error

func (*Tasks) UnmarshalJSON

func (me *Tasks) UnmarshalJSON(data []byte) error

type Trigger

type Trigger struct {
	Schedule     *Schedule     `json:"schedule,omitempty"`     // If specified the workflow is getting triggered based on a schedule
	EventTrigger *EventTrigger `json:"eventTrigger,omitempty"` // If specified the workflow is getting triggered based on events
}

func (*Trigger) MarshalHCL

func (me *Trigger) MarshalHCL(properties hcl.Properties) error

func (*Trigger) Schema

func (me *Trigger) Schema(prefix string) map[string]*schema.Schema

func (*Trigger) UnmarshalHCL

func (me *Trigger) UnmarshalHCL(decoder hcl.Decoder) error

type TriggerType

type TriggerType string

type VarInt

type VarInt string // pattern: ^{{.+}}$

func (VarInt) MarshalJSON

func (me VarInt) MarshalJSON() ([]byte, error)

func (*VarInt) UnmarshalJSON

func (me *VarInt) UnmarshalJSON(data []byte) error

type Workflow

type Workflow struct {
	Title       string `json:"title" maxlength:"200"` // The title / name of the workflow
	Description string `json:"description,omitempty"` // An optional description for the workflow

	Actor         string   `json:"actor,omitempty" maxlength:"36" format:"uuid"` // The user context the executions of the workflow will happen with
	Owner         string   `json:"owner,omitempty" format:"uuid"`                // The ID of the owner of this workflow
	Private       bool     `json:"isPrivate" default:"true"`                     // Defines whether this workflow is private to the owner or not. Default is `true`
	SchemaVersion int      `json:"schemaVersion,omitempty"`                      //
	Trigger       *Trigger `json:"trigger,omitempty"`                            // Configures how executions of the workflows are getting triggered. If no trigger is specified it means the workflow is getting manually triggered
	Tasks         Tasks    `json:"tasks,omitempty"`                              // The tasks to run for every execution of this workflow
}

func (*Workflow) MarshalHCL

func (me *Workflow) MarshalHCL(properties hcl.Properties) error

func (*Workflow) MarshalJSON

func (me *Workflow) MarshalJSON() ([]byte, error)

func (*Workflow) Name

func (me *Workflow) Name() string

func (*Workflow) Schema

func (me *Workflow) Schema() map[string]*schema.Schema

func (*Workflow) UnmarshalHCL

func (me *Workflow) UnmarshalHCL(decoder hcl.Decoder) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL