alerts

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ALERT_TYPE_ABSENCE = "absence"
View Source
const ALERT_TYPE_CHANGE = "change"
View Source
const ALERT_TYPE_THRESHOLD = "threshold"

Variables

View Source
var AbsenceAlertResourceSchema = schema.Schema{
	Description: "Represents an Absence Alert in a Pipeline",
	Attributes:  baseAlertSchemaAttributes,
}
View Source
var ChangeAlertResourceSchema = schema.Schema{
	Description: "Represents a Change Alert in a Pipeline",
	Attributes: ExtendBaseAttributes(map[string]schema.Attribute{
		"conditional": schema.SingleNestedAttribute{
			Required:    true,
			Description: ParentConditionalAttribute(Change_Operator_Labels).Description,
			Attributes:  ParentConditionalAttribute(Change_Operator_Labels).Attributes,
		},
		"operation": schema.StringAttribute{
			Required: true,
			Description: "Specifies the type of aggregation operation to use with the window type and duration. " +
				"This value must be `custom` for a Log event type.",
			Validators: []validator.String{
				stringvalidator.OneOf(MapKeys(Aggregate_Operations)...),
			},
		},
		"script": schema.StringAttribute{
			Optional: true,
			Validators: []validator.String{
				stringvalidator.LengthAtLeast(1),
				stringvalidator.LengthAtMost(5000),
			},
			Description: "A custom JavaScript function that will control the aggregation. At the " +
				"time of flushing, this aggregation will become the emitted event. This script " +
				"is required when choosing a `custom` operation.",
		},
	}),
}
View Source
var ThresholdAlertResourceSchema = schema.Schema{
	Description: "Represents a Threshold Alert in a Pipeline",
	Attributes: ExtendBaseAttributes(map[string]schema.Attribute{
		"conditional": schema.SingleNestedAttribute{
			Required:    true,
			Description: ParentConditionalAttribute(Non_Change_Operator_Labels).Description,
			Attributes:  ParentConditionalAttribute(Non_Change_Operator_Labels).Attributes,
		},
		"operation": schema.StringAttribute{
			Required: true,
			Description: "Specifies the type of aggregation operation to use with the window type and duration. " +
				"This value must be `custom` for a Log event type.",
			Validators: []validator.String{
				stringvalidator.OneOf(MapKeys(Aggregate_Operations)...),
			},
		},
		"script": schema.StringAttribute{
			Optional: true,
			Validators: []validator.String{
				stringvalidator.LengthAtLeast(1),
				stringvalidator.LengthAtMost(5000),
			},
			Description: "A custom JavaScript function that will control the aggregation. At the " +
				"time of flushing, this aggregation will become the emitted event. This script " +
				"is required when choosing a `custom` operation.",
		},
	}),
}

Functions

func AbsenceAlertFromModel

func AbsenceAlertFromModel(plan *AbsenceAlertModel, previousState *AbsenceAlertModel) (*Alert, diag.Diagnostics)

From terraform schema/model to a struct for sending to the API

func AbsenceAlertToModel

func AbsenceAlertToModel(plan *AbsenceAlertModel, component *Alert)

From an API response to a terraform model

func ChangeAlertFromModel

func ChangeAlertFromModel(plan *ChangeAlertModel, previousState *ChangeAlertModel) (*Alert, diag.Diagnostics)

From terraform schema/model to a struct for sending to the API

func ChangeAlertToModel

func ChangeAlertToModel(plan *ChangeAlertModel, component *Alert)

From an API response to a terraform model

func CustomErrorChecks

func CustomErrorChecks(plan *CheckedFields, dd *diag.Diagnostics) *diag.Diagnostics

func GetAlertPayloadFromModel

func GetAlertPayloadFromModel(v attr.Value, dd *diag.Diagnostics) map[string]any

Assemble the `alert_payload` object to be sent to the service, including error checking. The payload must match the required structure for the chosen service, i.e. there can be no extra fields for options that the service `name` doesn't expect.

func GetAlertPayloadToModel

func GetAlertPayloadToModel(component map[string]any) ObjectValue

Convert the api response for `alert_payload` into a Terraform model

func OperationAndScriptErrorChecks

func OperationAndScriptErrorChecks(plan *CheckedFields, dd *diag.Diagnostics) *diag.Diagnostics

func ThresholdAlertFromModel

func ThresholdAlertFromModel(plan *ThresholdAlertModel, previousState *ThresholdAlertModel) (*Alert, diag.Diagnostics)

From terraform schema/model to a struct for sending to the API

func ThresholdAlertToModel

func ThresholdAlertToModel(plan *ThresholdAlertModel, component *Alert)

From an API response to a terraform model

Types

type AbsenceAlertModel

type AbsenceAlertModel struct {
	Id                StringValue `tfsdk:"id"`
	PipelineId        StringValue `tfsdk:"pipeline_id"`
	ComponentKind     StringValue `tfsdk:"component_kind"`
	ComponentId       StringValue `tfsdk:"component_id"`
	Inputs            ListValue   `tfsdk:"inputs"`
	Active            BoolValue   `tfsdk:"active"`
	Name              StringValue `tfsdk:"name" user_config:"true"`
	Description       StringValue `tfsdk:"description" user_config:"true"`
	EventType         StringValue `tfsdk:"event_type" user_config:"true"`
	GroupBy           ListValue   `tfsdk:"group_by" user_config:"true"`
	WindowType        StringValue `tfsdk:"window_type" user_config:"true"`
	WindowDurationMin Int64Value  `tfsdk:"window_duration_minutes" user_config:"true"`
	EventTimestamp    StringValue `tfsdk:"event_timestamp" user_config:"true"`
	AlertPayload      ObjectValue `tfsdk:"alert_payload" user_config:"true"`
}

type ChangeAlertModel

type ChangeAlertModel struct {
	Id                StringValue `tfsdk:"id"`
	PipelineId        StringValue `tfsdk:"pipeline_id"`
	ComponentKind     StringValue `tfsdk:"component_kind"`
	ComponentId       StringValue `tfsdk:"component_id"`
	Inputs            ListValue   `tfsdk:"inputs"`
	Active            BoolValue   `tfsdk:"active"`
	Name              StringValue `tfsdk:"name" user_config:"true"`
	Description       StringValue `tfsdk:"description" user_config:"true"`
	EventType         StringValue `tfsdk:"event_type"`
	GroupBy           ListValue   `tfsdk:"group_by" user_config:"true"`
	Operation         StringValue `tfsdk:"operation" user_config:"true"`
	Conditional       ObjectValue `tfsdk:"conditional" user_config:"true"`
	WindowType        StringValue `tfsdk:"window_type" user_config:"true"`
	WindowDurationMin Int64Value  `tfsdk:"window_duration_minutes" user_config:"true"`
	Script            StringValue `tfsdk:"script" user_config:"true"`
	EventTimestamp    StringValue `tfsdk:"event_timestamp" user_config:"true"`
	AlertPayload      ObjectValue `tfsdk:"alert_payload" user_config:"true"`
}

type CheckedFields

type CheckedFields struct {
	Operation      StringValue
	EventType      StringValue
	Script         StringValue
	EventTimestamp StringValue
	GroupBy        ListValue
}

type SchemaAttributes

type SchemaAttributes map[string]schema.Attribute

func ExtendBaseAttributes

func ExtendBaseAttributes(target SchemaAttributes) SchemaAttributes

func ExtendSchemaAttributes

func ExtendSchemaAttributes(fromAttributes SchemaAttributes, toAttributes SchemaAttributes) SchemaAttributes

type ThresholdAlertModel

type ThresholdAlertModel struct {
	Id                StringValue `tfsdk:"id"`
	PipelineId        StringValue `tfsdk:"pipeline_id"`
	ComponentKind     StringValue `tfsdk:"component_kind"`
	ComponentId       StringValue `tfsdk:"component_id"`
	Inputs            ListValue   `tfsdk:"inputs"`
	Active            BoolValue   `tfsdk:"active"`
	Name              StringValue `tfsdk:"name" user_config:"true"`
	Description       StringValue `tfsdk:"description" user_config:"true"`
	EventType         StringValue `tfsdk:"event_type"`
	GroupBy           ListValue   `tfsdk:"group_by" user_config:"true"`
	Operation         StringValue `tfsdk:"operation" user_config:"true"`
	Conditional       ObjectValue `tfsdk:"conditional" user_config:"true"`
	WindowType        StringValue `tfsdk:"window_type" user_config:"true"`
	WindowDurationMin Int64Value  `tfsdk:"window_duration_minutes" user_config:"true"`
	Script            StringValue `tfsdk:"script" user_config:"true"`
	EventTimestamp    StringValue `tfsdk:"event_timestamp" user_config:"true"`
	AlertPayload      ObjectValue `tfsdk:"alert_payload" user_config:"true"`
}

Jump to

Keyboard shortcuts

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