scheduling_rules

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Directions = struct {
	Next     Direction
	Previous Direction
}{
	"next",
	"previous",
}
View Source
var Frequencies = struct {
	Yearly   Frequency
	Monthly  Frequency
	Weekly   Frequency
	Daily    Frequency
	Hourly   Frequency
	Minutely Frequency
	Secondly Frequency
}{
	"YEARLY",
	"MONTHLY",
	"WEEKLY",
	"DAILY",
	"HOURLY",
	"MINUTELY",
	"SECONDLY",
}
View Source
var RuleTypes = struct {
	RRule          RuleType
	Grouping       RuleType
	FixedOffset    RuleType
	RelativeOffset RuleType
}{
	"rrule",
	"grouping",
	"fixed_offset",
	"relative_offset",
}
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 Direction

type Direction string

type FixedOffsetRule

type FixedOffsetRule struct {
	Rule   string `json:"rule"`   // Refers to a scheduling rule for which to produce valid days with an offset
	Offset int    `json:"offset"` // Every day of the scheduling rule referred to with `rule` will be offset by this amount of days
}

func (*FixedOffsetRule) MarshalHCL

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

func (*FixedOffsetRule) Schema

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

func (*FixedOffsetRule) UnmarshalHCL

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

type Frequency

type Frequency string

type GroupingRule

type GroupingRule struct {
	Combine   []string `json:"combine"`             // The IDs of scheduling rules determining the days the schedule should apply to
	Intersect []string `json:"intersect,omitempty"` // The IDs of scheduling rules determining the days the schedule is allowed apply to. If specified, only days that are covered by `combine` and `intersect` are valid days for the schedule
	Subtract  []string `json:"subtract,omitempty"`  // The IDs of scheduling rules determing the days the schedule must not apply. If specified it reduces down the set of days covered by `combine` and `intersect`
}

func (*GroupingRule) MarshalHCL

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

func (*GroupingRule) Schema

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

func (*GroupingRule) UnmarshalHCL

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

type IntArray

type IntArray []int

func (*IntArray) UnmarshalJSON

func (me *IntArray) UnmarshalJSON(data []byte) (err error)

type RecurrenceRule

type RecurrenceRule struct {
	Frequency  Frequency `json:"freq"`                                       // Possible values are `YEARLY`, `MONTHLY`, `WEEKLY`, `DAILY`, `HOURLY`, `MINUTELY` and `SECONDLY`
	DateStart  string    `json:"datestart" format:"date"`                    // The recurrence start
	Interval   int       `json:"interval,omitempty" default:"1" minimum:"0"` // The interval between each freq iteration
	ByMonth    []int     `json:"bymonth,omitempty"`                          // The months to apply the recurrence to. `1` for `January`, `2` for `February`, ..., `12` for `December`
	ByMonthDay []int     `json:"bymonthday,omitempty"`                       // The days within a month to apply the recurrence to. `1`, `2`, `3`, ... refers to the first, second, third day in the month. You can also specify negative values to refer to values relative to the last day. `-1` refers to the last day, `-2` refers to the second to the last day, ...
	ByYearDay  []int     `json:"byyearday,omitempty"`                        // The days within a year to apply the recurrence to. `1`, `2`, `3`, ... refers to the first, second, third day in the year. You can also specify negative values to refer to values relative to the last day. `-1` refers to the last day, `-2` refers to the second to the last day, ...
	ByEaster   []int     `json:"byeaster,omitempty"`                         // Each value will define an offset from the Easter Sunday. The offset `0` will yield the Easter Sunday itself
	ByWeekNo   []int     `json:"byweekno,omitempty"`                         // The calendar week within the year to apply the recurrence to. `1`, `2`, `3`, ... refers to the first, second, third week of the year. You can also specify negative values to refer to values relative to the last week. `-1` refers to the last week, `-2` refers to the second to the last week, ...
	ByWeekDay  []string  `json:"byday,omitempty"`                            // Define the weekdays where the recurrence will be applied. Possible values are `MO`, `TU`, `WE`, `TH`, `FR`, `SA` and `SU`
	ByWorkDay  string    `json:"automation_server_byworkday,omitempty"`      // Possible values are `WORKING` (Work days), `HOLIDAYS` (Holidays) and `OFF` (Weekends + Holidays)

}

func (*RecurrenceRule) MarshalHCL

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

func (*RecurrenceRule) Schema

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

func (*RecurrenceRule) UnmarshalHCL

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

func (*RecurrenceRule) UnmarshalJSON

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

type RelativeOffsetRule

type RelativeOffsetRule struct {
	Direction  Direction `json:"direction"`  //
	SourceRule string    `json:"sourceRule"` //
	TargetRule string    `json:"targetRule"` //
}

func (*RelativeOffsetRule) MarshalHCL

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

func (*RelativeOffsetRule) Schema

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

func (*RelativeOffsetRule) UnmarshalHCL

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

type RuleType

type RuleType string

type Settings

type Settings struct {
	Title              string              `json:"title" minlength:"1" maxlength:"2"`
	Description        *string             `json:"description,omitempty"`
	RuleType           RuleType            `json:"ruleType"`
	RecurrenceRule     *RecurrenceRule     `json:"rrule,omitempty"`
	GroupingRule       *GroupingRule       `json:"groupingRule,omitempty"`
	FixedOffsetRule    *FixedOffsetRule    `json:"fixedOffsetRule,omitempty"`
	RelativeOffsetRule *RelativeOffsetRule `json:"relativeOffsetRule,omitempty"`
	BusinessCalendar   *string             `json:"businessCalendar,omitempty" format:"uuid"`
}

func (*Settings) MarshalHCL

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

func (*Settings) Name

func (me *Settings) Name() string

func (*Settings) Schema

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

func (*Settings) UnmarshalHCL

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

Jump to

Keyboard shortcuts

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