Skip to content

Commit

Permalink
Regenerate client from commit b4de72c1 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Aug 6, 2024
1 parent f079aa9 commit 991d04b
Show file tree
Hide file tree
Showing 21 changed files with 281 additions and 62 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-08-05 16:34:54.924716",
"spec_repo_commit": "578f6c8c"
"regenerated": "2024-08-06 12:13:47.552050",
"spec_repo_commit": "b4de72c1"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-08-05 16:34:54.942887",
"spec_repo_commit": "578f6c8c"
"regenerated": "2024-08-06 12:13:47.570280",
"spec_repo_commit": "b4de72c1"
}
}
}
16 changes: 16 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13818,6 +13818,7 @@ components:
- $ref: '#/components/schemas/SyntheticsAssertionJSONPathTarget'
- $ref: '#/components/schemas/SyntheticsAssertionJSONSchemaTarget'
- $ref: '#/components/schemas/SyntheticsAssertionXPathTarget'
- $ref: '#/components/schemas/SyntheticsAssertionJavascript'
SyntheticsAssertionBodyHashOperator:
description: Assertion operator to apply.
enum:
Expand Down Expand Up @@ -13934,6 +13935,19 @@ components:
metaSchema:
$ref: '#/components/schemas/SyntheticsAssertionJSONSchemaMetaSchema'
type: object
SyntheticsAssertionJavascript:
description: A JavaScript assertion.
properties:
code:
description: The JavaScript code that performs the assertions.
example: dd.expect(dd.response.statusCode).to.equal(200);
type: string
type:
$ref: '#/components/schemas/SyntheticsAssertionType'
required:
- type
- code
type: object
SyntheticsAssertionOperator:
description: Assertion operator to apply.
enum:
Expand Down Expand Up @@ -14021,6 +14035,7 @@ components:
- grpcMetadata
- grpcProto
- connection
- javascript
example: statusCode
type: string
x-enum-varnames:
Expand All @@ -14043,6 +14058,7 @@ components:
- GRPC_METADATA
- GRPC_PROTO
- CONNECTION
- JAVASCRIPT
SyntheticsAssertionXPathOperator:
description: Assertion operator to apply.
enum:
Expand Down
32 changes: 32 additions & 0 deletions api/datadogV1/model_synthetics_assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type SyntheticsAssertion struct {
SyntheticsAssertionJSONPathTarget *SyntheticsAssertionJSONPathTarget
SyntheticsAssertionJSONSchemaTarget *SyntheticsAssertionJSONSchemaTarget
SyntheticsAssertionXPathTarget *SyntheticsAssertionXPathTarget
SyntheticsAssertionJavascript *SyntheticsAssertionJavascript

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
Expand Down Expand Up @@ -46,6 +47,11 @@ func SyntheticsAssertionXPathTargetAsSyntheticsAssertion(v *SyntheticsAssertionX
return SyntheticsAssertion{SyntheticsAssertionXPathTarget: v}
}

// SyntheticsAssertionJavascriptAsSyntheticsAssertion is a convenience function that returns SyntheticsAssertionJavascript wrapped in SyntheticsAssertion.
func SyntheticsAssertionJavascriptAsSyntheticsAssertion(v *SyntheticsAssertionJavascript) SyntheticsAssertion {
return SyntheticsAssertion{SyntheticsAssertionJavascript: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *SyntheticsAssertion) UnmarshalJSON(data []byte) error {
var err error
Expand Down Expand Up @@ -135,13 +141,31 @@ func (obj *SyntheticsAssertion) UnmarshalJSON(data []byte) error {
obj.SyntheticsAssertionXPathTarget = nil
}

// try to unmarshal data into SyntheticsAssertionJavascript
err = datadog.Unmarshal(data, &obj.SyntheticsAssertionJavascript)
if err == nil {
if obj.SyntheticsAssertionJavascript != nil && obj.SyntheticsAssertionJavascript.UnparsedObject == nil {
jsonSyntheticsAssertionJavascript, _ := datadog.Marshal(obj.SyntheticsAssertionJavascript)
if string(jsonSyntheticsAssertionJavascript) == "{}" { // empty struct
obj.SyntheticsAssertionJavascript = nil
} else {
match++
}
} else {
obj.SyntheticsAssertionJavascript = nil
}
} else {
obj.SyntheticsAssertionJavascript = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.SyntheticsAssertionTarget = nil
obj.SyntheticsAssertionBodyHashTarget = nil
obj.SyntheticsAssertionJSONPathTarget = nil
obj.SyntheticsAssertionJSONSchemaTarget = nil
obj.SyntheticsAssertionXPathTarget = nil
obj.SyntheticsAssertionJavascript = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
Expand Down Expand Up @@ -169,6 +193,10 @@ func (obj SyntheticsAssertion) MarshalJSON() ([]byte, error) {
return datadog.Marshal(&obj.SyntheticsAssertionXPathTarget)
}

if obj.SyntheticsAssertionJavascript != nil {
return datadog.Marshal(&obj.SyntheticsAssertionJavascript)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
Expand Down Expand Up @@ -197,6 +225,10 @@ func (obj *SyntheticsAssertion) GetActualInstance() interface{} {
return obj.SyntheticsAssertionXPathTarget
}

if obj.SyntheticsAssertionJavascript != nil {
return obj.SyntheticsAssertionJavascript
}

// all schemas are nil
return nil
}
143 changes: 143 additions & 0 deletions api/datadogV1/model_synthetics_assertion_javascript.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// 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"
)

// SyntheticsAssertionJavascript A JavaScript assertion.
type SyntheticsAssertionJavascript struct {
// The JavaScript code that performs the assertions.
Code string `json:"code"`
// Type of the assertion.
Type SyntheticsAssertionType `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{} `json:"-"`
}

// NewSyntheticsAssertionJavascript instantiates a new SyntheticsAssertionJavascript 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 NewSyntheticsAssertionJavascript(code string, typeVar SyntheticsAssertionType) *SyntheticsAssertionJavascript {
this := SyntheticsAssertionJavascript{}
this.Code = code
this.Type = typeVar
return &this
}

// NewSyntheticsAssertionJavascriptWithDefaults instantiates a new SyntheticsAssertionJavascript 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 NewSyntheticsAssertionJavascriptWithDefaults() *SyntheticsAssertionJavascript {
this := SyntheticsAssertionJavascript{}
return &this
}

// GetCode returns the Code field value.
func (o *SyntheticsAssertionJavascript) GetCode() string {
if o == nil {
var ret string
return ret
}
return o.Code
}

// GetCodeOk returns a tuple with the Code field value
// and a boolean to check if the value has been set.
func (o *SyntheticsAssertionJavascript) GetCodeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Code, true
}

// SetCode sets field value.
func (o *SyntheticsAssertionJavascript) SetCode(v string) {
o.Code = v
}

// GetType returns the Type field value.
func (o *SyntheticsAssertionJavascript) GetType() SyntheticsAssertionType {
if o == nil {
var ret SyntheticsAssertionType
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 *SyntheticsAssertionJavascript) GetTypeOk() (*SyntheticsAssertionType, bool) {
if o == nil {
return nil, false
}
return &o.Type, true
}

// SetType sets field value.
func (o *SyntheticsAssertionJavascript) SetType(v SyntheticsAssertionType) {
o.Type = v
}

// MarshalJSON serializes the struct using spec logic.
func (o SyntheticsAssertionJavascript) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["code"] = o.Code
toSerialize["type"] = o.Type

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *SyntheticsAssertionJavascript) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Code *string `json:"code"`
Type *SyntheticsAssertionType `json:"type"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Code == nil {
return fmt.Errorf("required field code 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{"code", "type"})
} else {
return err
}

hasInvalidField := false
o.Code = *all.Code
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
}
2 changes: 2 additions & 0 deletions api/datadogV1/model_synthetics_assertion_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
SYNTHETICSASSERTIONTYPE_GRPC_METADATA SyntheticsAssertionType = "grpcMetadata"
SYNTHETICSASSERTIONTYPE_GRPC_PROTO SyntheticsAssertionType = "grpcProto"
SYNTHETICSASSERTIONTYPE_CONNECTION SyntheticsAssertionType = "connection"
SYNTHETICSASSERTIONTYPE_JAVASCRIPT SyntheticsAssertionType = "javascript"
)

var allowedSyntheticsAssertionTypeEnumValues = []SyntheticsAssertionType{
Expand All @@ -56,6 +57,7 @@ var allowedSyntheticsAssertionTypeEnumValues = []SyntheticsAssertionType{
SYNTHETICSASSERTIONTYPE_GRPC_METADATA,
SYNTHETICSASSERTIONTYPE_GRPC_PROTO,
SYNTHETICSASSERTIONTYPE_CONNECTION,
SYNTHETICSASSERTIONTYPE_JAVASCRIPT,
}

// GetAllowedValues reeturns the list of possible values.
Expand Down
5 changes: 5 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func main() {
Target: "a",
Type: datadogV1.SYNTHETICSASSERTIONBODYHASHTYPE_BODY_HASH,
}},
datadogV1.SyntheticsAssertion{
SyntheticsAssertionJavascript: &datadogV1.SyntheticsAssertionJavascript{
Code: "const hello = 'world';",
Type: datadogV1.SYNTHETICSASSERTIONTYPE_JAVASCRIPT,
}},
},
ConfigVariables: []datadogV1.SyntheticsConfigVariable{
{
Expand Down
5 changes: 5 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_1987645492.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func main() {
Target: "a",
Type: datadogV1.SYNTHETICSASSERTIONBODYHASHTYPE_BODY_HASH,
}},
datadogV1.SyntheticsAssertion{
SyntheticsAssertionJavascript: &datadogV1.SyntheticsAssertionJavascript{
Code: "const hello = 'world';",
Type: datadogV1.SYNTHETICSASSERTIONTYPE_JAVASCRIPT,
}},
},
ConfigVariables: []datadogV1.SyntheticsConfigVariable{
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-14T15:19:35.860Z
2024-08-06T12:03:16.833Z
Loading

0 comments on commit 991d04b

Please sign in to comment.