Skip to content

Commit

Permalink
Fix VFTs and extracted local variables enum types (#2604)
Browse files Browse the repository at this point in the history
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
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Sep 3, 2024
1 parent 2d033ad commit 8f9d833
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 29 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-29 20:02:09.349484",
"spec_repo_commit": "518ca9df"
"regenerated": "2024-09-03 13:58:43.754442",
"spec_repo_commit": "ff772101"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-08-29 20:02:09.367553",
"spec_repo_commit": "518ca9df"
"regenerated": "2024-09-03 13:58:43.774050",
"spec_repo_commit": "ff772101"
}
}
}
30 changes: 24 additions & 6 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15267,17 +15267,18 @@ components:
- type
type: object
SyntheticsGlobalVariableParseTestOptionsType:
description: Property of the Synthetic Test Response to use for a Synthetic
global variable.
description: Type of value to extract from a test for a Synthetic global variable.
enum:
- http_body
- http_header
- http_status_code
- local_variable
example: http_body
type: string
x-enum-varnames:
- HTTP_BODY
- HTTP_HEADER
- HTTP_STATUS_CODE
- LOCAL_VARIABLE
SyntheticsGlobalVariableParserType:
description: Type of parser for a Synthetic global variable from a synthetics
Expand Down Expand Up @@ -15396,6 +15397,23 @@ components:
$ref: '#/components/schemas/SyntheticsTestDetails'
type: array
type: object
SyntheticsLocalVariableParsingOptionsType:
description: Property of the Synthetic Test Response to extract into a local
variable.
enum:
- grpc_message
- grpc_metadata
- http_body
- http_header
- http_status_code
example: http_body
type: string
x-enum-varnames:
- GRPC_MESSAGE
- GRPC_METADATA
- HTTP_BODY
- HTTP_HEADER
- HTTP_STATUS_CODE
SyntheticsLocation:
description: 'Synthetic location that can be used when creating or editing a

Expand All @@ -15422,8 +15440,8 @@ components:
example: {}
properties:
field:
description: When type is `http_header`, name of the header to use to extract
the value.
description: When type is `http_header` or `grpc_metadata`, name of the
header or metadatum to extract.
example: content-type
type: string
name:
Expand All @@ -15435,7 +15453,7 @@ components:
description: Determines whether or not the extracted value will be obfuscated.
type: boolean
type:
$ref: '#/components/schemas/SyntheticsGlobalVariableParseTestOptionsType'
$ref: '#/components/schemas/SyntheticsLocalVariableParsingOptionsType'
type: object
SyntheticsPatchTestBody:
description: Wrapper around an array of [JSON Patch](https://jsonpatch.com)
Expand Down Expand Up @@ -16010,7 +16028,7 @@ components:
type: object
SyntheticsTestMetadata:
additionalProperties:
description: A single Metadatum.
description: A single metadatum.
type: string
description: Metadata to include when performing the gRPC test.
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type SyntheticsGlobalVariableParseTestOptions struct {
LocalVariableName *string `json:"localVariableName,omitempty"`
// Details of the parser to use for the global variable.
Parser *SyntheticsVariableParser `json:"parser,omitempty"`
// Property of the Synthetic Test Response to use for a Synthetic global variable.
// Type of value to extract from a test for a Synthetic global variable.
Type SyntheticsGlobalVariableParseTestOptionsType `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:"-"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// SyntheticsGlobalVariableParseTestOptionsType Property of the Synthetic Test Response to use for a Synthetic global variable.
// SyntheticsGlobalVariableParseTestOptionsType Type of value to extract from a test for a Synthetic global variable.
type SyntheticsGlobalVariableParseTestOptionsType string

// List of SyntheticsGlobalVariableParseTestOptionsType.
const (
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_BODY SyntheticsGlobalVariableParseTestOptionsType = "http_body"
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_HEADER SyntheticsGlobalVariableParseTestOptionsType = "http_header"
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_LOCAL_VARIABLE SyntheticsGlobalVariableParseTestOptionsType = "local_variable"
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_BODY SyntheticsGlobalVariableParseTestOptionsType = "http_body"
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_HEADER SyntheticsGlobalVariableParseTestOptionsType = "http_header"
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_STATUS_CODE SyntheticsGlobalVariableParseTestOptionsType = "http_status_code"
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_LOCAL_VARIABLE SyntheticsGlobalVariableParseTestOptionsType = "local_variable"
)

var allowedSyntheticsGlobalVariableParseTestOptionsTypeEnumValues = []SyntheticsGlobalVariableParseTestOptionsType{
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_BODY,
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_HEADER,
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_STATUS_CODE,
SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_LOCAL_VARIABLE,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// 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"
)

// SyntheticsLocalVariableParsingOptionsType Property of the Synthetic Test Response to extract into a local variable.
type SyntheticsLocalVariableParsingOptionsType string

// List of SyntheticsLocalVariableParsingOptionsType.
const (
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_GRPC_MESSAGE SyntheticsLocalVariableParsingOptionsType = "grpc_message"
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_GRPC_METADATA SyntheticsLocalVariableParsingOptionsType = "grpc_metadata"
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_BODY SyntheticsLocalVariableParsingOptionsType = "http_body"
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_HEADER SyntheticsLocalVariableParsingOptionsType = "http_header"
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_STATUS_CODE SyntheticsLocalVariableParsingOptionsType = "http_status_code"
)

var allowedSyntheticsLocalVariableParsingOptionsTypeEnumValues = []SyntheticsLocalVariableParsingOptionsType{
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_GRPC_MESSAGE,
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_GRPC_METADATA,
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_BODY,
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_HEADER,
SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_STATUS_CODE,
}

// GetAllowedValues reeturns the list of possible values.
func (v *SyntheticsLocalVariableParsingOptionsType) GetAllowedValues() []SyntheticsLocalVariableParsingOptionsType {
return allowedSyntheticsLocalVariableParsingOptionsTypeEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *SyntheticsLocalVariableParsingOptionsType) UnmarshalJSON(src []byte) error {
var value string
err := datadog.Unmarshal(src, &value)
if err != nil {
return err
}
*v = SyntheticsLocalVariableParsingOptionsType(value)
return nil
}

// NewSyntheticsLocalVariableParsingOptionsTypeFromValue returns a pointer to a valid SyntheticsLocalVariableParsingOptionsType
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewSyntheticsLocalVariableParsingOptionsTypeFromValue(v string) (*SyntheticsLocalVariableParsingOptionsType, error) {
ev := SyntheticsLocalVariableParsingOptionsType(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for SyntheticsLocalVariableParsingOptionsType: valid values are %v", v, allowedSyntheticsLocalVariableParsingOptionsTypeEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v SyntheticsLocalVariableParsingOptionsType) IsValid() bool {
for _, existing := range allowedSyntheticsLocalVariableParsingOptionsTypeEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to SyntheticsLocalVariableParsingOptionsType value.
func (v SyntheticsLocalVariableParsingOptionsType) Ptr() *SyntheticsLocalVariableParsingOptionsType {
return &v
}
26 changes: 13 additions & 13 deletions api/datadogV1/model_synthetics_parsing_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (

// SyntheticsParsingOptions Parsing options for variables to extract.
type SyntheticsParsingOptions struct {
// When type is `http_header`, name of the header to use to extract the value.
// When type is `http_header` or `grpc_metadata`, name of the header or metadatum to extract.
Field *string `json:"field,omitempty"`
// Name of the variable to extract.
Name *string `json:"name,omitempty"`
// Details of the parser to use for the global variable.
Parser *SyntheticsVariableParser `json:"parser,omitempty"`
// Determines whether or not the extracted value will be obfuscated.
Secure *bool `json:"secure,omitempty"`
// Property of the Synthetic Test Response to use for a Synthetic global variable.
Type *SyntheticsGlobalVariableParseTestOptionsType `json:"type,omitempty"`
// Property of the Synthetic Test Response to extract into a local variable.
Type *SyntheticsLocalVariableParsingOptionsType `json:"type,omitempty"`
// 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:"-"`
Expand Down Expand Up @@ -155,17 +155,17 @@ func (o *SyntheticsParsingOptions) SetSecure(v bool) {
}

// GetType returns the Type field value if set, zero value otherwise.
func (o *SyntheticsParsingOptions) GetType() SyntheticsGlobalVariableParseTestOptionsType {
func (o *SyntheticsParsingOptions) GetType() SyntheticsLocalVariableParsingOptionsType {
if o == nil || o.Type == nil {
var ret SyntheticsGlobalVariableParseTestOptionsType
var ret SyntheticsLocalVariableParsingOptionsType
return ret
}
return *o.Type
}

// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SyntheticsParsingOptions) GetTypeOk() (*SyntheticsGlobalVariableParseTestOptionsType, bool) {
func (o *SyntheticsParsingOptions) GetTypeOk() (*SyntheticsLocalVariableParsingOptionsType, bool) {
if o == nil || o.Type == nil {
return nil, false
}
Expand All @@ -177,8 +177,8 @@ func (o *SyntheticsParsingOptions) HasType() bool {
return o != nil && o.Type != nil
}

// SetType gets a reference to the given SyntheticsGlobalVariableParseTestOptionsType and assigns it to the Type field.
func (o *SyntheticsParsingOptions) SetType(v SyntheticsGlobalVariableParseTestOptionsType) {
// SetType gets a reference to the given SyntheticsLocalVariableParsingOptionsType and assigns it to the Type field.
func (o *SyntheticsParsingOptions) SetType(v SyntheticsLocalVariableParsingOptionsType) {
o.Type = &v
}

Expand Down Expand Up @@ -213,11 +213,11 @@ func (o SyntheticsParsingOptions) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *SyntheticsParsingOptions) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Field *string `json:"field,omitempty"`
Name *string `json:"name,omitempty"`
Parser *SyntheticsVariableParser `json:"parser,omitempty"`
Secure *bool `json:"secure,omitempty"`
Type *SyntheticsGlobalVariableParseTestOptionsType `json:"type,omitempty"`
Field *string `json:"field,omitempty"`
Name *string `json:"name,omitempty"`
Parser *SyntheticsVariableParser `json:"parser,omitempty"`
Secure *bool `json:"secure,omitempty"`
Type *SyntheticsLocalVariableParsingOptionsType `json:"type,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func main() {
Parser: &datadogV1.SyntheticsVariableParser{
Type: datadogV1.SYNTHETICSGLOBALVARIABLEPARSERTYPE_RAW,
},
Type: datadogV1.SYNTHETICSGLOBALVARIABLEPARSETESTOPTIONSTYPE_HTTP_HEADER.Ptr(),
Type: datadogV1.SYNTHETICSLOCALVARIABLEPARSINGOPTIONSTYPE_HTTP_HEADER.Ptr(),
Secure: datadog.PtrBool(true),
},
},
Expand Down

0 comments on commit 8f9d833

Please sign in to comment.