|
| 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 datadogV1 |
| 6 | + |
| 7 | +import ( |
| 8 | + "encoding/json" |
| 9 | + "fmt" |
| 10 | +) |
| 11 | + |
| 12 | +// SyntheticsAssertionXPathOperator Assertion operator to apply. |
| 13 | +type SyntheticsAssertionXPathOperator string |
| 14 | + |
| 15 | +// List of SyntheticsAssertionXPathOperator. |
| 16 | +const ( |
| 17 | + SYNTHETICSASSERTIONXPATHOPERATOR_VALIDATES_X_PATH SyntheticsAssertionXPathOperator = "validatesXPath" |
| 18 | +) |
| 19 | + |
| 20 | +var allowedSyntheticsAssertionXPathOperatorEnumValues = []SyntheticsAssertionXPathOperator{ |
| 21 | + SYNTHETICSASSERTIONXPATHOPERATOR_VALIDATES_X_PATH, |
| 22 | +} |
| 23 | + |
| 24 | +// GetAllowedValues reeturns the list of possible values. |
| 25 | +func (v *SyntheticsAssertionXPathOperator) GetAllowedValues() []SyntheticsAssertionXPathOperator { |
| 26 | + return allowedSyntheticsAssertionXPathOperatorEnumValues |
| 27 | +} |
| 28 | + |
| 29 | +// UnmarshalJSON deserializes the given payload. |
| 30 | +func (v *SyntheticsAssertionXPathOperator) UnmarshalJSON(src []byte) error { |
| 31 | + var value string |
| 32 | + err := json.Unmarshal(src, &value) |
| 33 | + if err != nil { |
| 34 | + return err |
| 35 | + } |
| 36 | + *v = SyntheticsAssertionXPathOperator(value) |
| 37 | + return nil |
| 38 | +} |
| 39 | + |
| 40 | +// NewSyntheticsAssertionXPathOperatorFromValue returns a pointer to a valid SyntheticsAssertionXPathOperator |
| 41 | +// for the value passed as argument, or an error if the value passed is not allowed by the enum. |
| 42 | +func NewSyntheticsAssertionXPathOperatorFromValue(v string) (*SyntheticsAssertionXPathOperator, error) { |
| 43 | + ev := SyntheticsAssertionXPathOperator(v) |
| 44 | + if ev.IsValid() { |
| 45 | + return &ev, nil |
| 46 | + } |
| 47 | + return nil, fmt.Errorf("invalid value '%v' for SyntheticsAssertionXPathOperator: valid values are %v", v, allowedSyntheticsAssertionXPathOperatorEnumValues) |
| 48 | +} |
| 49 | + |
| 50 | +// IsValid return true if the value is valid for the enum, false otherwise. |
| 51 | +func (v SyntheticsAssertionXPathOperator) IsValid() bool { |
| 52 | + for _, existing := range allowedSyntheticsAssertionXPathOperatorEnumValues { |
| 53 | + if existing == v { |
| 54 | + return true |
| 55 | + } |
| 56 | + } |
| 57 | + return false |
| 58 | +} |
| 59 | + |
| 60 | +// Ptr returns reference to SyntheticsAssertionXPathOperator value. |
| 61 | +func (v SyntheticsAssertionXPathOperator) Ptr() *SyntheticsAssertionXPathOperator { |
| 62 | + return &v |
| 63 | +} |
| 64 | + |
| 65 | +// NullableSyntheticsAssertionXPathOperator handles when a null is used for SyntheticsAssertionXPathOperator. |
| 66 | +type NullableSyntheticsAssertionXPathOperator struct { |
| 67 | + value *SyntheticsAssertionXPathOperator |
| 68 | + isSet bool |
| 69 | +} |
| 70 | + |
| 71 | +// Get returns the associated value. |
| 72 | +func (v NullableSyntheticsAssertionXPathOperator) Get() *SyntheticsAssertionXPathOperator { |
| 73 | + return v.value |
| 74 | +} |
| 75 | + |
| 76 | +// Set changes the value and indicates it's been called. |
| 77 | +func (v *NullableSyntheticsAssertionXPathOperator) Set(val *SyntheticsAssertionXPathOperator) { |
| 78 | + v.value = val |
| 79 | + v.isSet = true |
| 80 | +} |
| 81 | + |
| 82 | +// IsSet returns whether Set has been called. |
| 83 | +func (v NullableSyntheticsAssertionXPathOperator) IsSet() bool { |
| 84 | + return v.isSet |
| 85 | +} |
| 86 | + |
| 87 | +// Unset sets the value to nil and resets the set flag. |
| 88 | +func (v *NullableSyntheticsAssertionXPathOperator) Unset() { |
| 89 | + v.value = nil |
| 90 | + v.isSet = false |
| 91 | +} |
| 92 | + |
| 93 | +// NewNullableSyntheticsAssertionXPathOperator initializes the struct as if Set has been called. |
| 94 | +func NewNullableSyntheticsAssertionXPathOperator(val *SyntheticsAssertionXPathOperator) *NullableSyntheticsAssertionXPathOperator { |
| 95 | + return &NullableSyntheticsAssertionXPathOperator{value: val, isSet: true} |
| 96 | +} |
| 97 | + |
| 98 | +// MarshalJSON serializes the associated value. |
| 99 | +func (v NullableSyntheticsAssertionXPathOperator) MarshalJSON() ([]byte, error) { |
| 100 | + return json.Marshal(v.value) |
| 101 | +} |
| 102 | + |
| 103 | +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. |
| 104 | +func (v *NullableSyntheticsAssertionXPathOperator) UnmarshalJSON(src []byte) error { |
| 105 | + v.isSet = true |
| 106 | + return json.Unmarshal(src, &v.value) |
| 107 | +} |
0 commit comments