-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bodyHash as a synthetics assertion type. (#2518)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
- Loading branch information
1 parent
dcbfc17
commit 7125535
Showing
23 changed files
with
671 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
api/datadogV1/model_synthetics_assertion_body_hash_operator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2019-Present Datadog, Inc. | ||
|
||
package datadogV1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/DataDog/datadog-api-client-go/v2/api/datadog" | ||
) | ||
|
||
// SyntheticsAssertionBodyHashOperator Assertion operator to apply. | ||
type SyntheticsAssertionBodyHashOperator string | ||
|
||
// List of SyntheticsAssertionBodyHashOperator. | ||
const ( | ||
SYNTHETICSASSERTIONBODYHASHOPERATOR_MD5 SyntheticsAssertionBodyHashOperator = "md5" | ||
SYNTHETICSASSERTIONBODYHASHOPERATOR_SHA1 SyntheticsAssertionBodyHashOperator = "sha1" | ||
SYNTHETICSASSERTIONBODYHASHOPERATOR_SHA256 SyntheticsAssertionBodyHashOperator = "sha256" | ||
) | ||
|
||
var allowedSyntheticsAssertionBodyHashOperatorEnumValues = []SyntheticsAssertionBodyHashOperator{ | ||
SYNTHETICSASSERTIONBODYHASHOPERATOR_MD5, | ||
SYNTHETICSASSERTIONBODYHASHOPERATOR_SHA1, | ||
SYNTHETICSASSERTIONBODYHASHOPERATOR_SHA256, | ||
} | ||
|
||
// GetAllowedValues reeturns the list of possible values. | ||
func (v *SyntheticsAssertionBodyHashOperator) GetAllowedValues() []SyntheticsAssertionBodyHashOperator { | ||
return allowedSyntheticsAssertionBodyHashOperatorEnumValues | ||
} | ||
|
||
// UnmarshalJSON deserializes the given payload. | ||
func (v *SyntheticsAssertionBodyHashOperator) UnmarshalJSON(src []byte) error { | ||
var value string | ||
err := datadog.Unmarshal(src, &value) | ||
if err != nil { | ||
return err | ||
} | ||
*v = SyntheticsAssertionBodyHashOperator(value) | ||
return nil | ||
} | ||
|
||
// NewSyntheticsAssertionBodyHashOperatorFromValue returns a pointer to a valid SyntheticsAssertionBodyHashOperator | ||
// for the value passed as argument, or an error if the value passed is not allowed by the enum. | ||
func NewSyntheticsAssertionBodyHashOperatorFromValue(v string) (*SyntheticsAssertionBodyHashOperator, error) { | ||
ev := SyntheticsAssertionBodyHashOperator(v) | ||
if ev.IsValid() { | ||
return &ev, nil | ||
} | ||
return nil, fmt.Errorf("invalid value '%v' for SyntheticsAssertionBodyHashOperator: valid values are %v", v, allowedSyntheticsAssertionBodyHashOperatorEnumValues) | ||
} | ||
|
||
// IsValid return true if the value is valid for the enum, false otherwise. | ||
func (v SyntheticsAssertionBodyHashOperator) IsValid() bool { | ||
for _, existing := range allowedSyntheticsAssertionBodyHashOperatorEnumValues { | ||
if existing == v { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// Ptr returns reference to SyntheticsAssertionBodyHashOperator value. | ||
func (v SyntheticsAssertionBodyHashOperator) Ptr() *SyntheticsAssertionBodyHashOperator { | ||
return &v | ||
} |
179 changes: 179 additions & 0 deletions
179
api/datadogV1/model_synthetics_assertion_body_hash_target.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2019-Present Datadog, Inc. | ||
|
||
package datadogV1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/DataDog/datadog-api-client-go/v2/api/datadog" | ||
) | ||
|
||
// SyntheticsAssertionBodyHashTarget An assertion which targets body hash. | ||
type SyntheticsAssertionBodyHashTarget struct { | ||
// Assertion operator to apply. | ||
Operator SyntheticsAssertionBodyHashOperator `json:"operator"` | ||
// Value used by the operator. | ||
Target interface{} `json:"target"` | ||
// Type of the assertion. | ||
Type SyntheticsAssertionBodyHashType `json:"type"` | ||
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct | ||
UnparsedObject map[string]interface{} `json:"-"` | ||
AdditionalProperties map[string]interface{} | ||
} | ||
|
||
// NewSyntheticsAssertionBodyHashTarget instantiates a new SyntheticsAssertionBodyHashTarget object. | ||
// This constructor will assign default values to properties that have it defined, | ||
// and makes sure properties required by API are set, but the set of arguments | ||
// will change when the set of required properties is changed. | ||
func NewSyntheticsAssertionBodyHashTarget(operator SyntheticsAssertionBodyHashOperator, target interface{}, typeVar SyntheticsAssertionBodyHashType) *SyntheticsAssertionBodyHashTarget { | ||
this := SyntheticsAssertionBodyHashTarget{} | ||
this.Operator = operator | ||
this.Target = target | ||
this.Type = typeVar | ||
return &this | ||
} | ||
|
||
// NewSyntheticsAssertionBodyHashTargetWithDefaults instantiates a new SyntheticsAssertionBodyHashTarget object. | ||
// This constructor will only assign default values to properties that have it defined, | ||
// but it doesn't guarantee that properties required by API are set. | ||
func NewSyntheticsAssertionBodyHashTargetWithDefaults() *SyntheticsAssertionBodyHashTarget { | ||
this := SyntheticsAssertionBodyHashTarget{} | ||
return &this | ||
} | ||
|
||
// GetOperator returns the Operator field value. | ||
func (o *SyntheticsAssertionBodyHashTarget) GetOperator() SyntheticsAssertionBodyHashOperator { | ||
if o == nil { | ||
var ret SyntheticsAssertionBodyHashOperator | ||
return ret | ||
} | ||
return o.Operator | ||
} | ||
|
||
// GetOperatorOk returns a tuple with the Operator field value | ||
// and a boolean to check if the value has been set. | ||
func (o *SyntheticsAssertionBodyHashTarget) GetOperatorOk() (*SyntheticsAssertionBodyHashOperator, bool) { | ||
if o == nil { | ||
return nil, false | ||
} | ||
return &o.Operator, true | ||
} | ||
|
||
// SetOperator sets field value. | ||
func (o *SyntheticsAssertionBodyHashTarget) SetOperator(v SyntheticsAssertionBodyHashOperator) { | ||
o.Operator = v | ||
} | ||
|
||
// GetTarget returns the Target field value. | ||
func (o *SyntheticsAssertionBodyHashTarget) GetTarget() interface{} { | ||
if o == nil { | ||
var ret interface{} | ||
return ret | ||
} | ||
return o.Target | ||
} | ||
|
||
// GetTargetOk returns a tuple with the Target field value | ||
// and a boolean to check if the value has been set. | ||
func (o *SyntheticsAssertionBodyHashTarget) GetTargetOk() (*interface{}, bool) { | ||
if o == nil { | ||
return nil, false | ||
} | ||
return &o.Target, true | ||
} | ||
|
||
// SetTarget sets field value. | ||
func (o *SyntheticsAssertionBodyHashTarget) SetTarget(v interface{}) { | ||
o.Target = v | ||
} | ||
|
||
// GetType returns the Type field value. | ||
func (o *SyntheticsAssertionBodyHashTarget) GetType() SyntheticsAssertionBodyHashType { | ||
if o == nil { | ||
var ret SyntheticsAssertionBodyHashType | ||
return ret | ||
} | ||
return o.Type | ||
} | ||
|
||
// GetTypeOk returns a tuple with the Type field value | ||
// and a boolean to check if the value has been set. | ||
func (o *SyntheticsAssertionBodyHashTarget) GetTypeOk() (*SyntheticsAssertionBodyHashType, bool) { | ||
if o == nil { | ||
return nil, false | ||
} | ||
return &o.Type, true | ||
} | ||
|
||
// SetType sets field value. | ||
func (o *SyntheticsAssertionBodyHashTarget) SetType(v SyntheticsAssertionBodyHashType) { | ||
o.Type = v | ||
} | ||
|
||
// MarshalJSON serializes the struct using spec logic. | ||
func (o SyntheticsAssertionBodyHashTarget) MarshalJSON() ([]byte, error) { | ||
toSerialize := map[string]interface{}{} | ||
if o.UnparsedObject != nil { | ||
return datadog.Marshal(o.UnparsedObject) | ||
} | ||
toSerialize["operator"] = o.Operator | ||
toSerialize["target"] = o.Target | ||
toSerialize["type"] = o.Type | ||
|
||
for key, value := range o.AdditionalProperties { | ||
toSerialize[key] = value | ||
} | ||
return datadog.Marshal(toSerialize) | ||
} | ||
|
||
// UnmarshalJSON deserializes the given payload. | ||
func (o *SyntheticsAssertionBodyHashTarget) UnmarshalJSON(bytes []byte) (err error) { | ||
all := struct { | ||
Operator *SyntheticsAssertionBodyHashOperator `json:"operator"` | ||
Target *interface{} `json:"target"` | ||
Type *SyntheticsAssertionBodyHashType `json:"type"` | ||
}{} | ||
if err = datadog.Unmarshal(bytes, &all); err != nil { | ||
return datadog.Unmarshal(bytes, &o.UnparsedObject) | ||
} | ||
if all.Operator == nil { | ||
return fmt.Errorf("required field operator missing") | ||
} | ||
if all.Target == nil { | ||
return fmt.Errorf("required field target missing") | ||
} | ||
if all.Type == nil { | ||
return fmt.Errorf("required field type missing") | ||
} | ||
additionalProperties := make(map[string]interface{}) | ||
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { | ||
datadog.DeleteKeys(additionalProperties, &[]string{"operator", "target", "type"}) | ||
} else { | ||
return err | ||
} | ||
|
||
hasInvalidField := false | ||
if !all.Operator.IsValid() { | ||
hasInvalidField = true | ||
} else { | ||
o.Operator = *all.Operator | ||
} | ||
o.Target = *all.Target | ||
if !all.Type.IsValid() { | ||
hasInvalidField = true | ||
} else { | ||
o.Type = *all.Type | ||
} | ||
|
||
if len(additionalProperties) > 0 { | ||
o.AdditionalProperties = additionalProperties | ||
} | ||
|
||
if hasInvalidField { | ||
return datadog.Unmarshal(bytes, &o.UnparsedObject) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.