modelutils

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const VRL_PARSER_APACHE = "apache_log"
View Source
const VRL_PARSER_CEF = "cef_log"
View Source
const VRL_PARSER_CSV = "csv_row"
View Source
const VRL_PARSER_GROK = "grok_parser"
View Source
const VRL_PARSER_KEY_VALUE = "key_value_log"
View Source
const VRL_PARSER_NGINX = "nginx_log"
View Source
const VRL_PARSER_REGEX = "regex_parser"
View Source
const VRL_PARSER_TIMESTAMP = "timestamp_parser"

Variables

View Source
var APACHE_LOG_FORMATS = append(NGINX_LOG_FORMATS, "common")
View Source
var EncryptionAlgorithms = []string{
	"AES-256-CFB",
	"AES-192-CFB",
	"AES-128-CFB",
	"AES-256-OFB",
	"AES-192-OFB",
	"AES-128-OFB",
	"AES-256-CTR",
	"AES-192-CTR",
	"AES-128-CTR",
	"AES-256-CBC-PKCS7",
	"AES-192-CBC-PKCS7",
	"AES-128-CBC-PKCS7",
	"AES-256-CBC-ANSIX923",
	"AES-192-CBC-ANSIX923",
	"AES-128-CBC-ANSIX923",
	"AES-256-CBC-ISO7816",
	"AES-192-CBC-ISO7816",
	"AES-128-CBC-ISO7816",
	"AES-256-CBC-ISO10126",
	"AES-192-CBC-ISO10126",
	"AES-128-CBC-ISO10126",
}
View Source
var ExpressionAttributes = map[string]schema.Attribute{
	"field": schema.StringAttribute{
		Required:    true,
		Description: "The field path whose value will be used in the comparison",
		Validators: []validator.String{
			stringvalidator.LengthAtLeast(1),
		},
	},
	"operator": schema.StringAttribute{
		Required:    true,
		Description: "The comparison operator",
		Validators: []validator.String{
			stringvalidator.OneOf(Operators...),
		},
	},
	"value_string": schema.StringAttribute{
		Optional:    true,
		Description: "The operand to compare the field value with, when the value is a string",
		Validators: []validator.String{
			stringvalidator.LengthAtLeast(1),
			stringvalidator.ConflictsWith(
				path.MatchRelative().AtParent().AtName("value_number"),
			),
		},
	},
	"value_number": schema.Float64Attribute{
		Optional:    true,
		Description: "The operand to compare the field value with, when the value is a number",
	},
}
View Source
var ExpressionListAttribute = schema.ListNestedAttribute{
	Optional:    true,
	Description: "Defines a list of expressions for field comparisons",
	NestedObject: schema.NestedAttributeObject{
		Attributes: ExpressionAttributes,
	},
	Validators: []validator.List{
		listvalidator.SizeAtLeast(1),
		listvalidator.ConflictsWith(
			path.MatchRelative().AtParent().AtName("expressions_group"),
		),
	},
}
View Source
var ExpressionTypes = map[string]attr.Type{
	"field":        StringType{},
	"operator":     StringType{},
	"value_number": Float64Type{},
	"value_string": StringType{},
}
View Source
var LimitExceedAction = []string{
	"drop_tag",
	"drop_event",
}
View Source
var LogicalOperationAttribute = schema.StringAttribute{
	Optional:    true,
	Computed:    true,
	Description: "The logical operation (AND/OR) to be applied to the list of conditionals",
	Validators: []validator.String{
		stringvalidator.OneOf("AND", "OR"),
	},
}
View Source
var MAX_NESTED_LEVELS = 5
View Source
var MetricKind = []string{
	"incremental",
	"absolute",
}
View Source
var MetricType = []string{
	"counter",
	"sum",
	"gauge",
}
View Source
var NGINX_LOG_FORMATS = []string{"combined", "error"}
View Source
var NestedExpressionAttribute = schema.NestedAttributeObject{
	Attributes: ExpressionAttributes,
}
View Source
var OPTIONAL_FIELDS_BY_PARSER = map[string][]string{
	"apache_log":       {"timestamp_format", "custom_timestamp_format"},
	"csv_row":          {"field_names"},
	"key_value_log":    {"field_delimiter", "key_delimiter"},
	"nginx_log":        {"timestamp_format", "custom_timestamp_format"},
	"timestamp_parser": {"custom_format"},
}
View Source
var Operators = []string{
	"contains",
	"ends_with",
	"equal",
	"exists",
	"greater",
	"greater_or_equal",
	"is_array",
	"is_boolean",
	"is_empty",
	"is_ip_in_cidr_range",
	"is_metric",
	"is_null",
	"is_number",
	"is_object",
	"is_string",
	"less",
	"less_or_equal",
	"not_contains",
	"not_equal",
	"not_exists",
	"not_regex_match",
	"regex_match",
	"starts_with",
}
View Source
var ParentConditionalAttribute = schema.SingleNestedAttribute{
	Optional:    true,
	Description: "A group of expressions (optionally nested) joined by a logical operator",
	Attributes: map[string]schema.Attribute{
		"expressions": ExpressionListAttribute,
		"expressions_group": schema.ListNestedAttribute{
			Optional:     true,
			Description:  "A group of expressions joined by a logical operator",
			NestedObject: getChildExpressionGroupAttributes(0),
		},
		"logical_operation": LogicalOperationAttribute,
	},
}
View Source
var ReduceMergeStrategies = []string{
	"array",
	"shortest_array",
	"longest_array",
	"flat_unique",
	"concat",
	"concat_newline",
	"concat_raw",
	"discard",
	"retain",
	"min",
	"max",
	"sum",
}
View Source
var TagCardinalityMode = []string{
	"exact",
	"probabilistic",
}
View Source
var VRL_PARSERS = map[string]string{
	"apache_log":              "parse_apache_log",
	"aws_alb_log":             "parse_aws_alb_log",
	"aws_cloudwatch_log":      "parse_aws_cloudwatch_log_subscription_message",
	"aws_vpc_flow_log":        "parse_aws_vpc_flow_log",
	"cef_log":                 "parse_cef",
	"common_log":              "parse_common_log",
	"csv_row":                 "parse_csv",
	"glog":                    "parse_glog",
	"grok_parser":             "parse_grok",
	"int_parser":              "parse_int",
	"json_parser":             "parse_json",
	"key_value_log":           "parse_key_value",
	"klog":                    "parse_klog",
	"linux_authorization_log": "parse_linux_authorization",
	"nginx_log":               "parse_nginx_log",
	"querystring_parser":      "parse_query_string",
	"regex_parser":            "parse_regex",
	"syslog":                  "parse_syslog",
	"timestamp_parser":        "parse_timestamp",
	"token_parser":            "parse_tokens",
	"url_parser":              "parse_url",
	"user_agent_parser":       "parse_user_agent",
}
View Source
var VRL_PARSERS_WITH_REQUIRED_OPTIONS = []string{
	"apache_log",
	"grok_parser",
	"regex_parser",
	"nginx_log",
	"timestamp_parser",
}

Functions

func BrokersFromModelList

func BrokersFromModelList(Brokers List, dd diag.Diagnostics) ([]map[string]any, diag.Diagnostics)

Kafka-specific functions, shared between multiple types

func BrokersToModelList

func BrokersToModelList(elementType attr.Type, brokers []interface{}) List

func FindKey

func FindKey[K comparable, V comparable](m map[K]V, value V) K

Returns the key for a given map, panicking when not found

func GetAttributeValue

func GetAttributeValue[T any](m map[string]attr.Value, name string) T

Gets a known attribute value from an attribute map and casts it to the provided type.

func GetAttributesByLevel

func GetAttributesByLevel(level int) map[string]schema.Attribute

func GetChildExpressionGroupTypeByLevel

func GetChildExpressionGroupTypeByLevel(level int) attr.Type

func KafkaDestinationSASLToModel

func KafkaDestinationSASLToModel(types map[string]attr.Type, user_config map[string]interface{}) basetypes.ObjectValue

func MapAnyFillMissingValues

func MapAnyFillMissingValues(attrs map[string]attr.Type, values map[string]any, optional_fields []string) map[string]attr.Value

Make a complete map of values, using a null-equivalent for any missing fields

func MapAnyToMapValues

func MapAnyToMapValues(values map[string]any) map[string]attr.Value

This function can help with taking an object from an API response and translating it into a basetype object from the terraform-plugin-framework

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

Returns the keys of the provided map

func MapValuesToMapAny

func MapValuesToMapAny(obj interface{}, dd *diag.Diagnostics) map[string]any

This function can receive a terraform object (as defined in their basetypes) and return a regular map[string]any object that can be used in `Component` such that it can be used in an API call.

func PopulateMissingMapValues

func PopulateMissingMapValues(attrs map[string]attr.Type, result map[string]attr.Value)

func PrintJSON

func PrintJSON(label string, obj any)

func SetOptionalAttributeStringFromMap

func SetOptionalAttributeStringFromMap(target map[string]attr.Value, source map[string]any, names ...string)

Sets one or more optional string attributes from a source map

func SetOptionalStringFromAttributeMap

func SetOptionalStringFromAttributeMap(target map[string]any, attr_source_map map[string]attr.Value, names ...string)

Sets one or more optional string values from a attribute map into a target map

func SliceToStringListValue

func SliceToStringListValue[T any](s []T) List

func StringListValueToStringSlice

func StringListValueToStringSlice(list List) []string

func ToAttrTypes

func ToAttrTypes(attributes map[string]schema.Attribute) map[string]attr.Type

Given a map of schema (resource, data, etc) attributes, returns the attribute types

func UnwindConditionalToModel added in v1.0.4

func UnwindConditionalToModel(component map[string]any) ObjectValue

Types

This section is empty.

Jump to

Keyboard shortcuts

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