|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// SecurityMonitoringRuleSort The sort parameters used for querying security monitoring rules. |
| 14 | +type SecurityMonitoringRuleSort string |
| 15 | + |
| 16 | +// List of SecurityMonitoringRuleSort. |
| 17 | +const ( |
| 18 | + SECURITYMONITORINGRULESORT_NAME SecurityMonitoringRuleSort = "name" |
| 19 | + SECURITYMONITORINGRULESORT_CREATION_DATE SecurityMonitoringRuleSort = "creation_date" |
| 20 | + SECURITYMONITORINGRULESORT_UPDATE_DATE SecurityMonitoringRuleSort = "update_date" |
| 21 | + SECURITYMONITORINGRULESORT_ENABLED SecurityMonitoringRuleSort = "enabled" |
| 22 | + SECURITYMONITORINGRULESORT_TYPE SecurityMonitoringRuleSort = "type" |
| 23 | + SECURITYMONITORINGRULESORT_HIGHEST_SEVERITY SecurityMonitoringRuleSort = "highest_severity" |
| 24 | + SECURITYMONITORINGRULESORT_SOURCE SecurityMonitoringRuleSort = "source" |
| 25 | + SECURITYMONITORINGRULESORT_NAME_DESCENDING SecurityMonitoringRuleSort = "-name" |
| 26 | + SECURITYMONITORINGRULESORT_CREATION_DATE_DESCENDING SecurityMonitoringRuleSort = "-creation_date" |
| 27 | + SECURITYMONITORINGRULESORT_UPDATE_DATE_DESCENDING SecurityMonitoringRuleSort = "-update_date" |
| 28 | + SECURITYMONITORINGRULESORT_ENABLED_DESCENDING SecurityMonitoringRuleSort = "-enabled" |
| 29 | + SECURITYMONITORINGRULESORT_TYPE_DESCENDING SecurityMonitoringRuleSort = "-type" |
| 30 | + SECURITYMONITORINGRULESORT_HIGHEST_SEVERITY_DESCENDING SecurityMonitoringRuleSort = "-highest_severity" |
| 31 | + SECURITYMONITORINGRULESORT_SOURCE_DESCENDING SecurityMonitoringRuleSort = "-source" |
| 32 | +) |
| 33 | + |
| 34 | +var allowedSecurityMonitoringRuleSortEnumValues = []SecurityMonitoringRuleSort{ |
| 35 | + SECURITYMONITORINGRULESORT_NAME, |
| 36 | + SECURITYMONITORINGRULESORT_CREATION_DATE, |
| 37 | + SECURITYMONITORINGRULESORT_UPDATE_DATE, |
| 38 | + SECURITYMONITORINGRULESORT_ENABLED, |
| 39 | + SECURITYMONITORINGRULESORT_TYPE, |
| 40 | + SECURITYMONITORINGRULESORT_HIGHEST_SEVERITY, |
| 41 | + SECURITYMONITORINGRULESORT_SOURCE, |
| 42 | + SECURITYMONITORINGRULESORT_NAME_DESCENDING, |
| 43 | + SECURITYMONITORINGRULESORT_CREATION_DATE_DESCENDING, |
| 44 | + SECURITYMONITORINGRULESORT_UPDATE_DATE_DESCENDING, |
| 45 | + SECURITYMONITORINGRULESORT_ENABLED_DESCENDING, |
| 46 | + SECURITYMONITORINGRULESORT_TYPE_DESCENDING, |
| 47 | + SECURITYMONITORINGRULESORT_HIGHEST_SEVERITY_DESCENDING, |
| 48 | + SECURITYMONITORINGRULESORT_SOURCE_DESCENDING, |
| 49 | +} |
| 50 | + |
| 51 | +// GetAllowedValues reeturns the list of possible values. |
| 52 | +func (v *SecurityMonitoringRuleSort) GetAllowedValues() []SecurityMonitoringRuleSort { |
| 53 | + return allowedSecurityMonitoringRuleSortEnumValues |
| 54 | +} |
| 55 | + |
| 56 | +// UnmarshalJSON deserializes the given payload. |
| 57 | +func (v *SecurityMonitoringRuleSort) UnmarshalJSON(src []byte) error { |
| 58 | + var value string |
| 59 | + err := datadog.Unmarshal(src, &value) |
| 60 | + if err != nil { |
| 61 | + return err |
| 62 | + } |
| 63 | + *v = SecurityMonitoringRuleSort(value) |
| 64 | + return nil |
| 65 | +} |
| 66 | + |
| 67 | +// NewSecurityMonitoringRuleSortFromValue returns a pointer to a valid SecurityMonitoringRuleSort |
| 68 | +// for the value passed as argument, or an error if the value passed is not allowed by the enum. |
| 69 | +func NewSecurityMonitoringRuleSortFromValue(v string) (*SecurityMonitoringRuleSort, error) { |
| 70 | + ev := SecurityMonitoringRuleSort(v) |
| 71 | + if ev.IsValid() { |
| 72 | + return &ev, nil |
| 73 | + } |
| 74 | + return nil, fmt.Errorf("invalid value '%v' for SecurityMonitoringRuleSort: valid values are %v", v, allowedSecurityMonitoringRuleSortEnumValues) |
| 75 | +} |
| 76 | + |
| 77 | +// IsValid return true if the value is valid for the enum, false otherwise. |
| 78 | +func (v SecurityMonitoringRuleSort) IsValid() bool { |
| 79 | + for _, existing := range allowedSecurityMonitoringRuleSortEnumValues { |
| 80 | + if existing == v { |
| 81 | + return true |
| 82 | + } |
| 83 | + } |
| 84 | + return false |
| 85 | +} |
| 86 | + |
| 87 | +// Ptr returns reference to SecurityMonitoringRuleSort value. |
| 88 | +func (v SecurityMonitoringRuleSort) Ptr() *SecurityMonitoringRuleSort { |
| 89 | + return &v |
| 90 | +} |
0 commit comments