From d8ca9e52631a8271634b41b148ea33a4c8b3504c Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 21 Nov 2025 12:59:16 +0000 Subject: [PATCH] Regenerate client from commit 73f2ad5 of spec repo --- .generator/schemas/v2/openapi.yaml | 315 +++++++++++++ api/datadogV2/api_synthetics.go | 88 ++++ api/datadogV2/doc.go | 1 + api/datadogV2/model_global_variable_data.go | 185 ++++++++ ...odel_global_variable_json_patch_request.go | 110 +++++ ...global_variable_json_patch_request_data.go | 150 +++++++ ...able_json_patch_request_data_attributes.go | 102 +++++ .../model_global_variable_json_patch_type.go | 64 +++ .../model_global_variable_response.go | 111 +++++ api/datadogV2/model_global_variable_type.go | 64 +++ api/datadogV2/model_json_patch_operation.go | 178 ++++++++ .../model_json_patch_operation_op.go | 74 +++ .../model_synthetics_global_variable.go | 422 ++++++++++++++++++ ...l_synthetics_global_variable_attributes.go | 102 +++++ ...odel_synthetics_global_variable_options.go | 111 +++++ ...tics_global_variable_parse_test_options.go | 219 +++++++++ ...global_variable_parse_test_options_type.go | 70 +++ ..._synthetics_global_variable_parser_type.go | 70 +++ ...thetics_global_variable_totp_parameters.go | 137 ++++++ .../model_synthetics_global_variable_value.go | 182 ++++++++ .../model_synthetics_variable_parser.go | 146 ++++++ examples/v2/synthetics/PatchGlobalVariable.go | 42 ++ .../scenarios/features/v2/synthetics.feature | 24 + tests/scenarios/features/v2/undo.json | 6 + 24 files changed, 2973 insertions(+) create mode 100644 api/datadogV2/model_global_variable_data.go create mode 100644 api/datadogV2/model_global_variable_json_patch_request.go create mode 100644 api/datadogV2/model_global_variable_json_patch_request_data.go create mode 100644 api/datadogV2/model_global_variable_json_patch_request_data_attributes.go create mode 100644 api/datadogV2/model_global_variable_json_patch_type.go create mode 100644 api/datadogV2/model_global_variable_response.go create mode 100644 api/datadogV2/model_global_variable_type.go create mode 100644 api/datadogV2/model_json_patch_operation.go create mode 100644 api/datadogV2/model_json_patch_operation_op.go create mode 100644 api/datadogV2/model_synthetics_global_variable.go create mode 100644 api/datadogV2/model_synthetics_global_variable_attributes.go create mode 100644 api/datadogV2/model_synthetics_global_variable_options.go create mode 100644 api/datadogV2/model_synthetics_global_variable_parse_test_options.go create mode 100644 api/datadogV2/model_synthetics_global_variable_parse_test_options_type.go create mode 100644 api/datadogV2/model_synthetics_global_variable_parser_type.go create mode 100644 api/datadogV2/model_synthetics_global_variable_totp_parameters.go create mode 100644 api/datadogV2/model_synthetics_global_variable_value.go create mode 100644 api/datadogV2/model_synthetics_variable_parser.go create mode 100644 examples/v2/synthetics/PatchGlobalVariable.go diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb715496..1fe0e1f167d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23651,6 +23651,61 @@ components: required: - type type: object + GlobalVariableData: + description: Synthetics global variable data. Wrapper around the global variable + object. + properties: + attributes: + $ref: '#/components/schemas/SyntheticsGlobalVariable' + id: + description: Global variable identifier. + type: string + type: + $ref: '#/components/schemas/GlobalVariableType' + type: object + GlobalVariableJsonPatchRequest: + description: JSON Patch request for global variable. + properties: + data: + $ref: '#/components/schemas/GlobalVariableJsonPatchRequestData' + required: + - data + type: object + GlobalVariableJsonPatchRequestData: + properties: + attributes: + $ref: '#/components/schemas/GlobalVariableJsonPatchRequestDataAttributes' + type: + $ref: '#/components/schemas/GlobalVariableJsonPatchType' + type: object + GlobalVariableJsonPatchRequestDataAttributes: + properties: + json_patch: + description: JSON Patch operations following RFC 6902. + items: + $ref: '#/components/schemas/JsonPatchOperation' + type: array + type: object + GlobalVariableJsonPatchType: + description: Global variable JSON Patch type. + enum: + - global_variables_json_patch + type: string + x-enum-varnames: + - GLOBAL_VARIABLES_JSON_PATCH + GlobalVariableResponse: + description: Global variable response. + properties: + data: + $ref: '#/components/schemas/GlobalVariableData' + type: object + GlobalVariableType: + description: Global variable type. + enum: + - global_variables + type: string + x-enum-varnames: + - GLOBAL_VARIABLES GoogleMeetConfigurationReference: description: A reference to a Google Meet Configuration resource. nullable: true @@ -28404,6 +28459,40 @@ components: - to - index type: object + JsonPatchOperation: + description: A JSON Patch operation as per RFC 6902. + properties: + op: + $ref: '#/components/schemas/JsonPatchOperationOp' + path: + description: A JSON Pointer path (e.g., "/name", "/value/secure"). + example: /name + type: string + value: + description: The value to use for the operation (not applicable for "remove" + and "test" operations). + required: + - op + - path + type: object + JsonPatchOperationOp: + description: The operation to perform. + enum: + - add + - remove + - replace + - move + - copy + - test + example: add + type: string + x-enum-varnames: + - ADD + - REMOVE + - REPLACE + - MOVE + - COPY + - TEST KindAttributes: description: Kind attributes. properties: @@ -51322,6 +51411,178 @@ components: format: double type: number type: object + SyntheticsGlobalVariable: + description: Synthetic global variable. + properties: + attributes: + $ref: '#/components/schemas/SyntheticsGlobalVariableAttributes' + description: + description: Description of the global variable. + example: Example description + type: string + id: + description: Unique identifier of the global variable. + readOnly: true + type: string + is_fido: + description: Determines if the global variable is a FIDO variable. + type: boolean + is_totp: + description: Determines if the global variable is a TOTP/MFA variable. + type: boolean + name: + description: Name of the global variable. Unique across Synthetic global + variables. + example: MY_VARIABLE + type: string + parse_test_options: + $ref: '#/components/schemas/SyntheticsGlobalVariableParseTestOptions' + parse_test_public_id: + description: A Synthetic test ID to use as a test to generate the variable + value. + example: abc-def-123 + type: string + tags: + description: Tags of the global variable. + example: + - team:front + - test:workflow-1 + items: + description: Tag name. + type: string + type: array + value: + $ref: '#/components/schemas/SyntheticsGlobalVariableValue' + required: + - description + - name + - tags + - value + type: object + SyntheticsGlobalVariableAttributes: + description: Attributes of the global variable. + properties: + restricted_roles: + $ref: '#/components/schemas/SyntheticsRestrictedRoles' + type: object + SyntheticsGlobalVariableOptions: + description: Options for the Global Variable for MFA. + properties: + totp_parameters: + $ref: '#/components/schemas/SyntheticsGlobalVariableTOTPParameters' + type: object + SyntheticsGlobalVariableParseTestOptions: + description: Parser options to use for retrieving a Synthetic global variable + from a Synthetic test. Used in conjunction with `parse_test_public_id`. + properties: + field: + description: When type is `http_header`, name of the header to use to extract + the value. + example: content-type + type: string + localVariableName: + description: When type is `local_variable`, name of the local variable to + use to extract the value. + example: LOCAL_VARIABLE + type: string + parser: + $ref: '#/components/schemas/SyntheticsVariableParser' + type: + $ref: '#/components/schemas/SyntheticsGlobalVariableParseTestOptionsType' + required: + - type + type: object + SyntheticsGlobalVariableParseTestOptionsType: + 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 + test. + enum: + - raw + - json_path + - regex + - x_path + example: raw + type: string + x-enum-varnames: + - RAW + - JSON_PATH + - REGEX + - X_PATH + SyntheticsGlobalVariableTOTPParameters: + description: Parameters for the TOTP/MFA variable + properties: + digits: + description: Number of digits for the OTP code. + example: 6 + format: int32 + maximum: 10 + minimum: 4 + type: integer + refresh_interval: + description: Interval for which to refresh the token (in seconds). + example: 30 + format: int32 + maximum: 999 + minimum: 0 + type: integer + type: object + SyntheticsGlobalVariableValue: + description: Value of the global variable. + example: + secure: true + value: value + properties: + options: + $ref: '#/components/schemas/SyntheticsGlobalVariableOptions' + secure: + description: Determines if the value of the variable is hidden. + type: boolean + value: + description: 'Value of the global variable. When reading a global variable, + + the value will not be present if the variable is hidden with the `secure` + property.' + example: example-value + type: string + type: object + SyntheticsRestrictedRoles: + description: A list of role identifiers that can be pulled from the Roles API, + for restricting read and write access. + example: + - xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + items: + description: UUID for a role. + example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + type: string + type: array + SyntheticsVariableParser: + description: Details of the parser to use for the global variable. + example: + type: regex + value: .* + properties: + type: + $ref: '#/components/schemas/SyntheticsGlobalVariableParserType' + value: + description: Regex or JSON path used for the parser. Not used with type + `raw`. + type: string + required: + - type + type: object TableResultV2: description: A reference table resource containing its full configuration and state. @@ -81694,6 +81955,60 @@ paths: operator: OR permissions: - billing_edit + /api/v2/synthetics/variables/{variable_id}/jsonpatch: + patch: + description: 'Patch a global variable using JSON Patch (RFC 6902). + + This endpoint allows partial updates to a global variable by specifying only + the fields to modify. + + + Common operations include: + + - Replace field values: `{"op": "replace", "path": "/name", "value": "new_name"}` + + - Update nested values: `{"op": "replace", "path": "/value/value", "value": + "new_value"}` + + - Add/update tags: `{"op": "add", "path": "/tags/-", "value": "new_tag"}` + + - Remove fields: `{"op": "remove", "path": "/description"}`' + operationId: PatchGlobalVariable + parameters: + - description: The ID of the global variable. + in: path + name: variable_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalVariableJsonPatchRequest' + description: JSON Patch document with operations to apply. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalVariableResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Patch a global variable + tags: + - Synthetics + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - synthetics_global_variable_write /api/v2/tags/enrichment: get: description: List all tag pipeline rulesets - Retrieve a list of all tag pipeline diff --git a/api/datadogV2/api_synthetics.go b/api/datadogV2/api_synthetics.go index 3c3fed060c9..7e914546cba 100644 --- a/api/datadogV2/api_synthetics.go +++ b/api/datadogV2/api_synthetics.go @@ -92,6 +92,94 @@ func (a *SyntheticsApi) GetOnDemandConcurrencyCap(ctx _context.Context) (OnDeman return localVarReturnValue, localVarHTTPResponse, nil } +// PatchGlobalVariable Patch a global variable. +// Patch a global variable using JSON Patch (RFC 6902). +// This endpoint allows partial updates to a global variable by specifying only the fields to modify. +// +// Common operations include: +// - Replace field values: `{"op": "replace", "path": "/name", "value": "new_name"}` +// - Update nested values: `{"op": "replace", "path": "/value/value", "value": "new_value"}` +// - Add/update tags: `{"op": "add", "path": "/tags/-", "value": "new_tag"}` +// - Remove fields: `{"op": "remove", "path": "/description"}` +func (a *SyntheticsApi) PatchGlobalVariable(ctx _context.Context, variableId string, body GlobalVariableJsonPatchRequest) (GlobalVariableResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue GlobalVariableResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.PatchGlobalVariable") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/variables/{variable_id}/jsonpatch" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{variable_id}", _neturl.PathEscape(datadog.ParameterToString(variableId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // SetOnDemandConcurrencyCap Save new value for on-demand concurrency cap. // Save new value for on-demand concurrency cap. func (a *SyntheticsApi) SetOnDemandConcurrencyCap(ctx _context.Context, body OnDemandConcurrencyCapAttributes) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c5cf4723b97..0998fd38e66 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -623,6 +623,7 @@ // - [StaticAnalysisApi.CreateSCAResolveVulnerableSymbols] // - [StaticAnalysisApi.CreateSCAResult] // - [SyntheticsApi.GetOnDemandConcurrencyCap] +// - [SyntheticsApi.PatchGlobalVariable] // - [SyntheticsApi.SetOnDemandConcurrencyCap] // - [TeamConnectionsApi.CreateTeamConnections] // - [TeamConnectionsApi.DeleteTeamConnections] diff --git a/api/datadogV2/model_global_variable_data.go b/api/datadogV2/model_global_variable_data.go new file mode 100644 index 00000000000..b057a5da04a --- /dev/null +++ b/api/datadogV2/model_global_variable_data.go @@ -0,0 +1,185 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableData Synthetics global variable data. Wrapper around the global variable object. +type GlobalVariableData struct { + // Synthetic global variable. + Attributes *SyntheticsGlobalVariable `json:"attributes,omitempty"` + // Global variable identifier. + Id *string `json:"id,omitempty"` + // Global variable type. + Type *GlobalVariableType `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:"-"` +} + +// NewGlobalVariableData instantiates a new GlobalVariableData 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 NewGlobalVariableData() *GlobalVariableData { + this := GlobalVariableData{} + return &this +} + +// NewGlobalVariableDataWithDefaults instantiates a new GlobalVariableData 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 NewGlobalVariableDataWithDefaults() *GlobalVariableData { + this := GlobalVariableData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GlobalVariableData) GetAttributes() SyntheticsGlobalVariable { + if o == nil || o.Attributes == nil { + var ret SyntheticsGlobalVariable + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GlobalVariableData) GetAttributesOk() (*SyntheticsGlobalVariable, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GlobalVariableData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given SyntheticsGlobalVariable and assigns it to the Attributes field. +func (o *GlobalVariableData) SetAttributes(v SyntheticsGlobalVariable) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GlobalVariableData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GlobalVariableData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *GlobalVariableData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *GlobalVariableData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GlobalVariableData) GetType() GlobalVariableType { + if o == nil || o.Type == nil { + var ret GlobalVariableType + 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 *GlobalVariableData) GetTypeOk() (*GlobalVariableType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GlobalVariableData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GlobalVariableType and assigns it to the Type field. +func (o *GlobalVariableData) SetType(v GlobalVariableType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalVariableData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalVariableData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsGlobalVariable `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *GlobalVariableType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !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 +} diff --git a/api/datadogV2/model_global_variable_json_patch_request.go b/api/datadogV2/model_global_variable_json_patch_request.go new file mode 100644 index 00000000000..e88c3994ce1 --- /dev/null +++ b/api/datadogV2/model_global_variable_json_patch_request.go @@ -0,0 +1,110 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableJsonPatchRequest JSON Patch request for global variable. +type GlobalVariableJsonPatchRequest struct { + // + Data GlobalVariableJsonPatchRequestData `json:"data"` + // 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:"-"` +} + +// NewGlobalVariableJsonPatchRequest instantiates a new GlobalVariableJsonPatchRequest 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 NewGlobalVariableJsonPatchRequest(data GlobalVariableJsonPatchRequestData) *GlobalVariableJsonPatchRequest { + this := GlobalVariableJsonPatchRequest{} + this.Data = data + return &this +} + +// NewGlobalVariableJsonPatchRequestWithDefaults instantiates a new GlobalVariableJsonPatchRequest 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 NewGlobalVariableJsonPatchRequestWithDefaults() *GlobalVariableJsonPatchRequest { + this := GlobalVariableJsonPatchRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *GlobalVariableJsonPatchRequest) GetData() GlobalVariableJsonPatchRequestData { + if o == nil { + var ret GlobalVariableJsonPatchRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GlobalVariableJsonPatchRequest) GetDataOk() (*GlobalVariableJsonPatchRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GlobalVariableJsonPatchRequest) SetData(v GlobalVariableJsonPatchRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalVariableJsonPatchRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalVariableJsonPatchRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GlobalVariableJsonPatchRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_global_variable_json_patch_request_data.go b/api/datadogV2/model_global_variable_json_patch_request_data.go new file mode 100644 index 00000000000..c8ba12ddebf --- /dev/null +++ b/api/datadogV2/model_global_variable_json_patch_request_data.go @@ -0,0 +1,150 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableJsonPatchRequestData +type GlobalVariableJsonPatchRequestData struct { + // + Attributes *GlobalVariableJsonPatchRequestDataAttributes `json:"attributes,omitempty"` + // Global variable JSON Patch type. + Type *GlobalVariableJsonPatchType `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:"-"` +} + +// NewGlobalVariableJsonPatchRequestData instantiates a new GlobalVariableJsonPatchRequestData 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 NewGlobalVariableJsonPatchRequestData() *GlobalVariableJsonPatchRequestData { + this := GlobalVariableJsonPatchRequestData{} + return &this +} + +// NewGlobalVariableJsonPatchRequestDataWithDefaults instantiates a new GlobalVariableJsonPatchRequestData 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 NewGlobalVariableJsonPatchRequestDataWithDefaults() *GlobalVariableJsonPatchRequestData { + this := GlobalVariableJsonPatchRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GlobalVariableJsonPatchRequestData) GetAttributes() GlobalVariableJsonPatchRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret GlobalVariableJsonPatchRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GlobalVariableJsonPatchRequestData) GetAttributesOk() (*GlobalVariableJsonPatchRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *GlobalVariableJsonPatchRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GlobalVariableJsonPatchRequestDataAttributes and assigns it to the Attributes field. +func (o *GlobalVariableJsonPatchRequestData) SetAttributes(v GlobalVariableJsonPatchRequestDataAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GlobalVariableJsonPatchRequestData) GetType() GlobalVariableJsonPatchType { + if o == nil || o.Type == nil { + var ret GlobalVariableJsonPatchType + 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 *GlobalVariableJsonPatchRequestData) GetTypeOk() (*GlobalVariableJsonPatchType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GlobalVariableJsonPatchRequestData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GlobalVariableJsonPatchType and assigns it to the Type field. +func (o *GlobalVariableJsonPatchRequestData) SetType(v GlobalVariableJsonPatchType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalVariableJsonPatchRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalVariableJsonPatchRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GlobalVariableJsonPatchRequestDataAttributes `json:"attributes,omitempty"` + Type *GlobalVariableJsonPatchType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != nil && !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 +} diff --git a/api/datadogV2/model_global_variable_json_patch_request_data_attributes.go b/api/datadogV2/model_global_variable_json_patch_request_data_attributes.go new file mode 100644 index 00000000000..3e56ef06005 --- /dev/null +++ b/api/datadogV2/model_global_variable_json_patch_request_data_attributes.go @@ -0,0 +1,102 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableJsonPatchRequestDataAttributes +type GlobalVariableJsonPatchRequestDataAttributes struct { + // JSON Patch operations following RFC 6902. + JsonPatch []JsonPatchOperation `json:"json_patch,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:"-"` +} + +// NewGlobalVariableJsonPatchRequestDataAttributes instantiates a new GlobalVariableJsonPatchRequestDataAttributes 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 NewGlobalVariableJsonPatchRequestDataAttributes() *GlobalVariableJsonPatchRequestDataAttributes { + this := GlobalVariableJsonPatchRequestDataAttributes{} + return &this +} + +// NewGlobalVariableJsonPatchRequestDataAttributesWithDefaults instantiates a new GlobalVariableJsonPatchRequestDataAttributes 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 NewGlobalVariableJsonPatchRequestDataAttributesWithDefaults() *GlobalVariableJsonPatchRequestDataAttributes { + this := GlobalVariableJsonPatchRequestDataAttributes{} + return &this +} + +// GetJsonPatch returns the JsonPatch field value if set, zero value otherwise. +func (o *GlobalVariableJsonPatchRequestDataAttributes) GetJsonPatch() []JsonPatchOperation { + if o == nil || o.JsonPatch == nil { + var ret []JsonPatchOperation + return ret + } + return o.JsonPatch +} + +// GetJsonPatchOk returns a tuple with the JsonPatch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GlobalVariableJsonPatchRequestDataAttributes) GetJsonPatchOk() (*[]JsonPatchOperation, bool) { + if o == nil || o.JsonPatch == nil { + return nil, false + } + return &o.JsonPatch, true +} + +// HasJsonPatch returns a boolean if a field has been set. +func (o *GlobalVariableJsonPatchRequestDataAttributes) HasJsonPatch() bool { + return o != nil && o.JsonPatch != nil +} + +// SetJsonPatch gets a reference to the given []JsonPatchOperation and assigns it to the JsonPatch field. +func (o *GlobalVariableJsonPatchRequestDataAttributes) SetJsonPatch(v []JsonPatchOperation) { + o.JsonPatch = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalVariableJsonPatchRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.JsonPatch != nil { + toSerialize["json_patch"] = o.JsonPatch + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalVariableJsonPatchRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + JsonPatch []JsonPatchOperation `json:"json_patch,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"json_patch"}) + } else { + return err + } + o.JsonPatch = all.JsonPatch + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_global_variable_json_patch_type.go b/api/datadogV2/model_global_variable_json_patch_type.go new file mode 100644 index 00000000000..043e1a5de6c --- /dev/null +++ b/api/datadogV2/model_global_variable_json_patch_type.go @@ -0,0 +1,64 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableJsonPatchType Global variable JSON Patch type. +type GlobalVariableJsonPatchType string + +// List of GlobalVariableJsonPatchType. +const ( + GLOBALVARIABLEJSONPATCHTYPE_GLOBAL_VARIABLES_JSON_PATCH GlobalVariableJsonPatchType = "global_variables_json_patch" +) + +var allowedGlobalVariableJsonPatchTypeEnumValues = []GlobalVariableJsonPatchType{ + GLOBALVARIABLEJSONPATCHTYPE_GLOBAL_VARIABLES_JSON_PATCH, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GlobalVariableJsonPatchType) GetAllowedValues() []GlobalVariableJsonPatchType { + return allowedGlobalVariableJsonPatchTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GlobalVariableJsonPatchType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GlobalVariableJsonPatchType(value) + return nil +} + +// NewGlobalVariableJsonPatchTypeFromValue returns a pointer to a valid GlobalVariableJsonPatchType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGlobalVariableJsonPatchTypeFromValue(v string) (*GlobalVariableJsonPatchType, error) { + ev := GlobalVariableJsonPatchType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GlobalVariableJsonPatchType: valid values are %v", v, allowedGlobalVariableJsonPatchTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GlobalVariableJsonPatchType) IsValid() bool { + for _, existing := range allowedGlobalVariableJsonPatchTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GlobalVariableJsonPatchType value. +func (v GlobalVariableJsonPatchType) Ptr() *GlobalVariableJsonPatchType { + return &v +} diff --git a/api/datadogV2/model_global_variable_response.go b/api/datadogV2/model_global_variable_response.go new file mode 100644 index 00000000000..e44a2689417 --- /dev/null +++ b/api/datadogV2/model_global_variable_response.go @@ -0,0 +1,111 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableResponse Global variable response. +type GlobalVariableResponse struct { + // Synthetics global variable data. Wrapper around the global variable object. + Data *GlobalVariableData `json:"data,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:"-"` +} + +// NewGlobalVariableResponse instantiates a new GlobalVariableResponse 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 NewGlobalVariableResponse() *GlobalVariableResponse { + this := GlobalVariableResponse{} + return &this +} + +// NewGlobalVariableResponseWithDefaults instantiates a new GlobalVariableResponse 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 NewGlobalVariableResponseWithDefaults() *GlobalVariableResponse { + this := GlobalVariableResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GlobalVariableResponse) GetData() GlobalVariableData { + if o == nil || o.Data == nil { + var ret GlobalVariableData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GlobalVariableResponse) GetDataOk() (*GlobalVariableData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *GlobalVariableResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GlobalVariableData and assigns it to the Data field. +func (o *GlobalVariableResponse) SetData(v GlobalVariableData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalVariableResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalVariableResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GlobalVariableData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_global_variable_type.go b/api/datadogV2/model_global_variable_type.go new file mode 100644 index 00000000000..27d8afd31f3 --- /dev/null +++ b/api/datadogV2/model_global_variable_type.go @@ -0,0 +1,64 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalVariableType Global variable type. +type GlobalVariableType string + +// List of GlobalVariableType. +const ( + GLOBALVARIABLETYPE_GLOBAL_VARIABLES GlobalVariableType = "global_variables" +) + +var allowedGlobalVariableTypeEnumValues = []GlobalVariableType{ + GLOBALVARIABLETYPE_GLOBAL_VARIABLES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GlobalVariableType) GetAllowedValues() []GlobalVariableType { + return allowedGlobalVariableTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GlobalVariableType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GlobalVariableType(value) + return nil +} + +// NewGlobalVariableTypeFromValue returns a pointer to a valid GlobalVariableType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGlobalVariableTypeFromValue(v string) (*GlobalVariableType, error) { + ev := GlobalVariableType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GlobalVariableType: valid values are %v", v, allowedGlobalVariableTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GlobalVariableType) IsValid() bool { + for _, existing := range allowedGlobalVariableTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GlobalVariableType value. +func (v GlobalVariableType) Ptr() *GlobalVariableType { + return &v +} diff --git a/api/datadogV2/model_json_patch_operation.go b/api/datadogV2/model_json_patch_operation.go new file mode 100644 index 00000000000..e3e071ec292 --- /dev/null +++ b/api/datadogV2/model_json_patch_operation.go @@ -0,0 +1,178 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JsonPatchOperation A JSON Patch operation as per RFC 6902. +type JsonPatchOperation struct { + // The operation to perform. + Op JsonPatchOperationOp `json:"op"` + // A JSON Pointer path (e.g., "/name", "/value/secure"). + Path string `json:"path"` + // The value to use for the operation (not applicable for "remove" and "test" operations). + Value interface{} `json:"value,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:"-"` +} + +// NewJsonPatchOperation instantiates a new JsonPatchOperation 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 NewJsonPatchOperation(op JsonPatchOperationOp, path string) *JsonPatchOperation { + this := JsonPatchOperation{} + this.Op = op + this.Path = path + return &this +} + +// NewJsonPatchOperationWithDefaults instantiates a new JsonPatchOperation 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 NewJsonPatchOperationWithDefaults() *JsonPatchOperation { + this := JsonPatchOperation{} + return &this +} + +// GetOp returns the Op field value. +func (o *JsonPatchOperation) GetOp() JsonPatchOperationOp { + if o == nil { + var ret JsonPatchOperationOp + return ret + } + return o.Op +} + +// GetOpOk returns a tuple with the Op field value +// and a boolean to check if the value has been set. +func (o *JsonPatchOperation) GetOpOk() (*JsonPatchOperationOp, bool) { + if o == nil { + return nil, false + } + return &o.Op, true +} + +// SetOp sets field value. +func (o *JsonPatchOperation) SetOp(v JsonPatchOperationOp) { + o.Op = v +} + +// GetPath returns the Path field value. +func (o *JsonPatchOperation) GetPath() string { + if o == nil { + var ret string + return ret + } + return o.Path +} + +// GetPathOk returns a tuple with the Path field value +// and a boolean to check if the value has been set. +func (o *JsonPatchOperation) GetPathOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Path, true +} + +// SetPath sets field value. +func (o *JsonPatchOperation) SetPath(v string) { + o.Path = v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *JsonPatchOperation) GetValue() interface{} { + if o == nil || o.Value == nil { + var ret interface{} + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JsonPatchOperation) GetValueOk() (*interface{}, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return &o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *JsonPatchOperation) HasValue() bool { + return o != nil && o.Value != nil +} + +// SetValue gets a reference to the given interface{} and assigns it to the Value field. +func (o *JsonPatchOperation) SetValue(v interface{}) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JsonPatchOperation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["op"] = o.Op + toSerialize["path"] = o.Path + if o.Value != nil { + toSerialize["value"] = o.Value + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JsonPatchOperation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Op *JsonPatchOperationOp `json:"op"` + Path *string `json:"path"` + Value interface{} `json:"value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Op == nil { + return fmt.Errorf("required field op missing") + } + if all.Path == nil { + return fmt.Errorf("required field path missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"op", "path", "value"}) + } else { + return err + } + + hasInvalidField := false + if !all.Op.IsValid() { + hasInvalidField = true + } else { + o.Op = *all.Op + } + o.Path = *all.Path + o.Value = all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_json_patch_operation_op.go b/api/datadogV2/model_json_patch_operation_op.go new file mode 100644 index 00000000000..7880a6bf206 --- /dev/null +++ b/api/datadogV2/model_json_patch_operation_op.go @@ -0,0 +1,74 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JsonPatchOperationOp The operation to perform. +type JsonPatchOperationOp string + +// List of JsonPatchOperationOp. +const ( + JSONPATCHOPERATIONOP_ADD JsonPatchOperationOp = "add" + JSONPATCHOPERATIONOP_REMOVE JsonPatchOperationOp = "remove" + JSONPATCHOPERATIONOP_REPLACE JsonPatchOperationOp = "replace" + JSONPATCHOPERATIONOP_MOVE JsonPatchOperationOp = "move" + JSONPATCHOPERATIONOP_COPY JsonPatchOperationOp = "copy" + JSONPATCHOPERATIONOP_TEST JsonPatchOperationOp = "test" +) + +var allowedJsonPatchOperationOpEnumValues = []JsonPatchOperationOp{ + JSONPATCHOPERATIONOP_ADD, + JSONPATCHOPERATIONOP_REMOVE, + JSONPATCHOPERATIONOP_REPLACE, + JSONPATCHOPERATIONOP_MOVE, + JSONPATCHOPERATIONOP_COPY, + JSONPATCHOPERATIONOP_TEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *JsonPatchOperationOp) GetAllowedValues() []JsonPatchOperationOp { + return allowedJsonPatchOperationOpEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *JsonPatchOperationOp) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = JsonPatchOperationOp(value) + return nil +} + +// NewJsonPatchOperationOpFromValue returns a pointer to a valid JsonPatchOperationOp +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewJsonPatchOperationOpFromValue(v string) (*JsonPatchOperationOp, error) { + ev := JsonPatchOperationOp(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for JsonPatchOperationOp: valid values are %v", v, allowedJsonPatchOperationOpEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v JsonPatchOperationOp) IsValid() bool { + for _, existing := range allowedJsonPatchOperationOpEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to JsonPatchOperationOp value. +func (v JsonPatchOperationOp) Ptr() *JsonPatchOperationOp { + return &v +} diff --git a/api/datadogV2/model_synthetics_global_variable.go b/api/datadogV2/model_synthetics_global_variable.go new file mode 100644 index 00000000000..bf00ddeb3a5 --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable.go @@ -0,0 +1,422 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariable Synthetic global variable. +type SyntheticsGlobalVariable struct { + // Attributes of the global variable. + Attributes *SyntheticsGlobalVariableAttributes `json:"attributes,omitempty"` + // Description of the global variable. + Description string `json:"description"` + // Unique identifier of the global variable. + Id *string `json:"id,omitempty"` + // Determines if the global variable is a FIDO variable. + IsFido *bool `json:"is_fido,omitempty"` + // Determines if the global variable is a TOTP/MFA variable. + IsTotp *bool `json:"is_totp,omitempty"` + // Name of the global variable. Unique across Synthetic global variables. + Name string `json:"name"` + // Parser options to use for retrieving a Synthetic global variable from a Synthetic test. Used in conjunction with `parse_test_public_id`. + ParseTestOptions *SyntheticsGlobalVariableParseTestOptions `json:"parse_test_options,omitempty"` + // A Synthetic test ID to use as a test to generate the variable value. + ParseTestPublicId *string `json:"parse_test_public_id,omitempty"` + // Tags of the global variable. + Tags []string `json:"tags"` + // Value of the global variable. + Value SyntheticsGlobalVariableValue `json:"value"` + // 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:"-"` +} + +// NewSyntheticsGlobalVariable instantiates a new SyntheticsGlobalVariable 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 NewSyntheticsGlobalVariable(description string, name string, tags []string, value SyntheticsGlobalVariableValue) *SyntheticsGlobalVariable { + this := SyntheticsGlobalVariable{} + this.Description = description + this.Name = name + this.Tags = tags + this.Value = value + return &this +} + +// NewSyntheticsGlobalVariableWithDefaults instantiates a new SyntheticsGlobalVariable 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 NewSyntheticsGlobalVariableWithDefaults() *SyntheticsGlobalVariable { + this := SyntheticsGlobalVariable{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) GetAttributes() SyntheticsGlobalVariableAttributes { + if o == nil || o.Attributes == nil { + var ret SyntheticsGlobalVariableAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetAttributesOk() (*SyntheticsGlobalVariableAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariable) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given SyntheticsGlobalVariableAttributes and assigns it to the Attributes field. +func (o *SyntheticsGlobalVariable) SetAttributes(v SyntheticsGlobalVariableAttributes) { + o.Attributes = &v +} + +// GetDescription returns the Description field value. +func (o *SyntheticsGlobalVariable) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *SyntheticsGlobalVariable) SetDescription(v string) { + o.Description = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariable) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *SyntheticsGlobalVariable) SetId(v string) { + o.Id = &v +} + +// GetIsFido returns the IsFido field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) GetIsFido() bool { + if o == nil || o.IsFido == nil { + var ret bool + return ret + } + return *o.IsFido +} + +// GetIsFidoOk returns a tuple with the IsFido field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetIsFidoOk() (*bool, bool) { + if o == nil || o.IsFido == nil { + return nil, false + } + return o.IsFido, true +} + +// HasIsFido returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariable) HasIsFido() bool { + return o != nil && o.IsFido != nil +} + +// SetIsFido gets a reference to the given bool and assigns it to the IsFido field. +func (o *SyntheticsGlobalVariable) SetIsFido(v bool) { + o.IsFido = &v +} + +// GetIsTotp returns the IsTotp field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) GetIsTotp() bool { + if o == nil || o.IsTotp == nil { + var ret bool + return ret + } + return *o.IsTotp +} + +// GetIsTotpOk returns a tuple with the IsTotp field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetIsTotpOk() (*bool, bool) { + if o == nil || o.IsTotp == nil { + return nil, false + } + return o.IsTotp, true +} + +// HasIsTotp returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariable) HasIsTotp() bool { + return o != nil && o.IsTotp != nil +} + +// SetIsTotp gets a reference to the given bool and assigns it to the IsTotp field. +func (o *SyntheticsGlobalVariable) SetIsTotp(v bool) { + o.IsTotp = &v +} + +// GetName returns the Name field value. +func (o *SyntheticsGlobalVariable) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *SyntheticsGlobalVariable) SetName(v string) { + o.Name = v +} + +// GetParseTestOptions returns the ParseTestOptions field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) GetParseTestOptions() SyntheticsGlobalVariableParseTestOptions { + if o == nil || o.ParseTestOptions == nil { + var ret SyntheticsGlobalVariableParseTestOptions + return ret + } + return *o.ParseTestOptions +} + +// GetParseTestOptionsOk returns a tuple with the ParseTestOptions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetParseTestOptionsOk() (*SyntheticsGlobalVariableParseTestOptions, bool) { + if o == nil || o.ParseTestOptions == nil { + return nil, false + } + return o.ParseTestOptions, true +} + +// HasParseTestOptions returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariable) HasParseTestOptions() bool { + return o != nil && o.ParseTestOptions != nil +} + +// SetParseTestOptions gets a reference to the given SyntheticsGlobalVariableParseTestOptions and assigns it to the ParseTestOptions field. +func (o *SyntheticsGlobalVariable) SetParseTestOptions(v SyntheticsGlobalVariableParseTestOptions) { + o.ParseTestOptions = &v +} + +// GetParseTestPublicId returns the ParseTestPublicId field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) GetParseTestPublicId() string { + if o == nil || o.ParseTestPublicId == nil { + var ret string + return ret + } + return *o.ParseTestPublicId +} + +// GetParseTestPublicIdOk returns a tuple with the ParseTestPublicId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetParseTestPublicIdOk() (*string, bool) { + if o == nil || o.ParseTestPublicId == nil { + return nil, false + } + return o.ParseTestPublicId, true +} + +// HasParseTestPublicId returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariable) HasParseTestPublicId() bool { + return o != nil && o.ParseTestPublicId != nil +} + +// SetParseTestPublicId gets a reference to the given string and assigns it to the ParseTestPublicId field. +func (o *SyntheticsGlobalVariable) SetParseTestPublicId(v string) { + o.ParseTestPublicId = &v +} + +// GetTags returns the Tags field value. +func (o *SyntheticsGlobalVariable) GetTags() []string { + if o == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetTagsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Tags, true +} + +// SetTags sets field value. +func (o *SyntheticsGlobalVariable) SetTags(v []string) { + o.Tags = v +} + +// GetValue returns the Value field value. +func (o *SyntheticsGlobalVariable) GetValue() SyntheticsGlobalVariableValue { + if o == nil { + var ret SyntheticsGlobalVariableValue + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetValueOk() (*SyntheticsGlobalVariableValue, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *SyntheticsGlobalVariable) SetValue(v SyntheticsGlobalVariableValue) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsGlobalVariable) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["description"] = o.Description + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.IsFido != nil { + toSerialize["is_fido"] = o.IsFido + } + if o.IsTotp != nil { + toSerialize["is_totp"] = o.IsTotp + } + toSerialize["name"] = o.Name + if o.ParseTestOptions != nil { + toSerialize["parse_test_options"] = o.ParseTestOptions + } + if o.ParseTestPublicId != nil { + toSerialize["parse_test_public_id"] = o.ParseTestPublicId + } + toSerialize["tags"] = o.Tags + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsGlobalVariable) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsGlobalVariableAttributes `json:"attributes,omitempty"` + Description *string `json:"description"` + Id *string `json:"id,omitempty"` + IsFido *bool `json:"is_fido,omitempty"` + IsTotp *bool `json:"is_totp,omitempty"` + Name *string `json:"name"` + ParseTestOptions *SyntheticsGlobalVariableParseTestOptions `json:"parse_test_options,omitempty"` + ParseTestPublicId *string `json:"parse_test_public_id,omitempty"` + Tags *[]string `json:"tags"` + Value *SyntheticsGlobalVariableValue `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Tags == nil { + return fmt.Errorf("required field tags missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "description", "id", "is_fido", "is_totp", "name", "parse_test_options", "parse_test_public_id", "tags", "value"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Description = *all.Description + o.Id = all.Id + o.IsFido = all.IsFido + o.IsTotp = all.IsTotp + o.Name = *all.Name + if all.ParseTestOptions != nil && all.ParseTestOptions.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ParseTestOptions = all.ParseTestOptions + o.ParseTestPublicId = all.ParseTestPublicId + o.Tags = *all.Tags + if all.Value.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_global_variable_attributes.go b/api/datadogV2/model_synthetics_global_variable_attributes.go new file mode 100644 index 00000000000..a52d4c59b04 --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_attributes.go @@ -0,0 +1,102 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariableAttributes Attributes of the global variable. +type SyntheticsGlobalVariableAttributes struct { + // A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. + RestrictedRoles []string `json:"restricted_roles,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:"-"` +} + +// NewSyntheticsGlobalVariableAttributes instantiates a new SyntheticsGlobalVariableAttributes 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 NewSyntheticsGlobalVariableAttributes() *SyntheticsGlobalVariableAttributes { + this := SyntheticsGlobalVariableAttributes{} + return &this +} + +// NewSyntheticsGlobalVariableAttributesWithDefaults instantiates a new SyntheticsGlobalVariableAttributes 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 NewSyntheticsGlobalVariableAttributesWithDefaults() *SyntheticsGlobalVariableAttributes { + this := SyntheticsGlobalVariableAttributes{} + return &this +} + +// GetRestrictedRoles returns the RestrictedRoles field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableAttributes) GetRestrictedRoles() []string { + if o == nil || o.RestrictedRoles == nil { + var ret []string + return ret + } + return o.RestrictedRoles +} + +// GetRestrictedRolesOk returns a tuple with the RestrictedRoles field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableAttributes) GetRestrictedRolesOk() (*[]string, bool) { + if o == nil || o.RestrictedRoles == nil { + return nil, false + } + return &o.RestrictedRoles, true +} + +// HasRestrictedRoles returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableAttributes) HasRestrictedRoles() bool { + return o != nil && o.RestrictedRoles != nil +} + +// SetRestrictedRoles gets a reference to the given []string and assigns it to the RestrictedRoles field. +func (o *SyntheticsGlobalVariableAttributes) SetRestrictedRoles(v []string) { + o.RestrictedRoles = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsGlobalVariableAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.RestrictedRoles != nil { + toSerialize["restricted_roles"] = o.RestrictedRoles + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsGlobalVariableAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RestrictedRoles []string `json:"restricted_roles,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"restricted_roles"}) + } else { + return err + } + o.RestrictedRoles = all.RestrictedRoles + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_global_variable_options.go b/api/datadogV2/model_synthetics_global_variable_options.go new file mode 100644 index 00000000000..4463dc617ba --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_options.go @@ -0,0 +1,111 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariableOptions Options for the Global Variable for MFA. +type SyntheticsGlobalVariableOptions struct { + // Parameters for the TOTP/MFA variable + TotpParameters *SyntheticsGlobalVariableTOTPParameters `json:"totp_parameters,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:"-"` +} + +// NewSyntheticsGlobalVariableOptions instantiates a new SyntheticsGlobalVariableOptions 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 NewSyntheticsGlobalVariableOptions() *SyntheticsGlobalVariableOptions { + this := SyntheticsGlobalVariableOptions{} + return &this +} + +// NewSyntheticsGlobalVariableOptionsWithDefaults instantiates a new SyntheticsGlobalVariableOptions 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 NewSyntheticsGlobalVariableOptionsWithDefaults() *SyntheticsGlobalVariableOptions { + this := SyntheticsGlobalVariableOptions{} + return &this +} + +// GetTotpParameters returns the TotpParameters field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableOptions) GetTotpParameters() SyntheticsGlobalVariableTOTPParameters { + if o == nil || o.TotpParameters == nil { + var ret SyntheticsGlobalVariableTOTPParameters + return ret + } + return *o.TotpParameters +} + +// GetTotpParametersOk returns a tuple with the TotpParameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableOptions) GetTotpParametersOk() (*SyntheticsGlobalVariableTOTPParameters, bool) { + if o == nil || o.TotpParameters == nil { + return nil, false + } + return o.TotpParameters, true +} + +// HasTotpParameters returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableOptions) HasTotpParameters() bool { + return o != nil && o.TotpParameters != nil +} + +// SetTotpParameters gets a reference to the given SyntheticsGlobalVariableTOTPParameters and assigns it to the TotpParameters field. +func (o *SyntheticsGlobalVariableOptions) SetTotpParameters(v SyntheticsGlobalVariableTOTPParameters) { + o.TotpParameters = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsGlobalVariableOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.TotpParameters != nil { + toSerialize["totp_parameters"] = o.TotpParameters + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsGlobalVariableOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + TotpParameters *SyntheticsGlobalVariableTOTPParameters `json:"totp_parameters,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"totp_parameters"}) + } else { + return err + } + + hasInvalidField := false + if all.TotpParameters != nil && all.TotpParameters.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.TotpParameters = all.TotpParameters + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_global_variable_parse_test_options.go b/api/datadogV2/model_synthetics_global_variable_parse_test_options.go new file mode 100644 index 00000000000..e4df8cdede3 --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_parse_test_options.go @@ -0,0 +1,219 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariableParseTestOptions Parser options to use for retrieving a Synthetic global variable from a Synthetic test. Used in conjunction with `parse_test_public_id`. +type SyntheticsGlobalVariableParseTestOptions struct { + // When type is `http_header`, name of the header to use to extract the value. + Field *string `json:"field,omitempty"` + // When type is `local_variable`, name of the local variable to use to extract the value. + LocalVariableName *string `json:"localVariableName,omitempty"` + // Details of the parser to use for the global variable. + Parser *SyntheticsVariableParser `json:"parser,omitempty"` + // 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:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsGlobalVariableParseTestOptions instantiates a new SyntheticsGlobalVariableParseTestOptions 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 NewSyntheticsGlobalVariableParseTestOptions(typeVar SyntheticsGlobalVariableParseTestOptionsType) *SyntheticsGlobalVariableParseTestOptions { + this := SyntheticsGlobalVariableParseTestOptions{} + this.Type = typeVar + return &this +} + +// NewSyntheticsGlobalVariableParseTestOptionsWithDefaults instantiates a new SyntheticsGlobalVariableParseTestOptions 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 NewSyntheticsGlobalVariableParseTestOptionsWithDefaults() *SyntheticsGlobalVariableParseTestOptions { + this := SyntheticsGlobalVariableParseTestOptions{} + return &this +} + +// GetField returns the Field field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableParseTestOptions) GetField() string { + if o == nil || o.Field == nil { + var ret string + return ret + } + return *o.Field +} + +// GetFieldOk returns a tuple with the Field field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableParseTestOptions) GetFieldOk() (*string, bool) { + if o == nil || o.Field == nil { + return nil, false + } + return o.Field, true +} + +// HasField returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableParseTestOptions) HasField() bool { + return o != nil && o.Field != nil +} + +// SetField gets a reference to the given string and assigns it to the Field field. +func (o *SyntheticsGlobalVariableParseTestOptions) SetField(v string) { + o.Field = &v +} + +// GetLocalVariableName returns the LocalVariableName field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableParseTestOptions) GetLocalVariableName() string { + if o == nil || o.LocalVariableName == nil { + var ret string + return ret + } + return *o.LocalVariableName +} + +// GetLocalVariableNameOk returns a tuple with the LocalVariableName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableParseTestOptions) GetLocalVariableNameOk() (*string, bool) { + if o == nil || o.LocalVariableName == nil { + return nil, false + } + return o.LocalVariableName, true +} + +// HasLocalVariableName returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableParseTestOptions) HasLocalVariableName() bool { + return o != nil && o.LocalVariableName != nil +} + +// SetLocalVariableName gets a reference to the given string and assigns it to the LocalVariableName field. +func (o *SyntheticsGlobalVariableParseTestOptions) SetLocalVariableName(v string) { + o.LocalVariableName = &v +} + +// GetParser returns the Parser field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableParseTestOptions) GetParser() SyntheticsVariableParser { + if o == nil || o.Parser == nil { + var ret SyntheticsVariableParser + return ret + } + return *o.Parser +} + +// GetParserOk returns a tuple with the Parser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableParseTestOptions) GetParserOk() (*SyntheticsVariableParser, bool) { + if o == nil || o.Parser == nil { + return nil, false + } + return o.Parser, true +} + +// HasParser returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableParseTestOptions) HasParser() bool { + return o != nil && o.Parser != nil +} + +// SetParser gets a reference to the given SyntheticsVariableParser and assigns it to the Parser field. +func (o *SyntheticsGlobalVariableParseTestOptions) SetParser(v SyntheticsVariableParser) { + o.Parser = &v +} + +// GetType returns the Type field value. +func (o *SyntheticsGlobalVariableParseTestOptions) GetType() SyntheticsGlobalVariableParseTestOptionsType { + if o == nil { + var ret SyntheticsGlobalVariableParseTestOptionsType + 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 *SyntheticsGlobalVariableParseTestOptions) GetTypeOk() (*SyntheticsGlobalVariableParseTestOptionsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SyntheticsGlobalVariableParseTestOptions) SetType(v SyntheticsGlobalVariableParseTestOptionsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsGlobalVariableParseTestOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Field != nil { + toSerialize["field"] = o.Field + } + if o.LocalVariableName != nil { + toSerialize["localVariableName"] = o.LocalVariableName + } + if o.Parser != nil { + toSerialize["parser"] = o.Parser + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsGlobalVariableParseTestOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Field *string `json:"field,omitempty"` + LocalVariableName *string `json:"localVariableName,omitempty"` + Parser *SyntheticsVariableParser `json:"parser,omitempty"` + Type *SyntheticsGlobalVariableParseTestOptionsType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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{"field", "localVariableName", "parser", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Field = all.Field + o.LocalVariableName = all.LocalVariableName + if all.Parser != nil && all.Parser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Parser = all.Parser + 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 +} diff --git a/api/datadogV2/model_synthetics_global_variable_parse_test_options_type.go b/api/datadogV2/model_synthetics_global_variable_parse_test_options_type.go new file mode 100644 index 00000000000..6fc1e949685 --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_parse_test_options_type.go @@ -0,0 +1,70 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// 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_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, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsGlobalVariableParseTestOptionsType) GetAllowedValues() []SyntheticsGlobalVariableParseTestOptionsType { + return allowedSyntheticsGlobalVariableParseTestOptionsTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsGlobalVariableParseTestOptionsType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsGlobalVariableParseTestOptionsType(value) + return nil +} + +// NewSyntheticsGlobalVariableParseTestOptionsTypeFromValue returns a pointer to a valid SyntheticsGlobalVariableParseTestOptionsType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsGlobalVariableParseTestOptionsTypeFromValue(v string) (*SyntheticsGlobalVariableParseTestOptionsType, error) { + ev := SyntheticsGlobalVariableParseTestOptionsType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsGlobalVariableParseTestOptionsType: valid values are %v", v, allowedSyntheticsGlobalVariableParseTestOptionsTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsGlobalVariableParseTestOptionsType) IsValid() bool { + for _, existing := range allowedSyntheticsGlobalVariableParseTestOptionsTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsGlobalVariableParseTestOptionsType value. +func (v SyntheticsGlobalVariableParseTestOptionsType) Ptr() *SyntheticsGlobalVariableParseTestOptionsType { + return &v +} diff --git a/api/datadogV2/model_synthetics_global_variable_parser_type.go b/api/datadogV2/model_synthetics_global_variable_parser_type.go new file mode 100644 index 00000000000..7c3ca74d61b --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_parser_type.go @@ -0,0 +1,70 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariableParserType Type of parser for a Synthetic global variable from a synthetics test. +type SyntheticsGlobalVariableParserType string + +// List of SyntheticsGlobalVariableParserType. +const ( + SYNTHETICSGLOBALVARIABLEPARSERTYPE_RAW SyntheticsGlobalVariableParserType = "raw" + SYNTHETICSGLOBALVARIABLEPARSERTYPE_JSON_PATH SyntheticsGlobalVariableParserType = "json_path" + SYNTHETICSGLOBALVARIABLEPARSERTYPE_REGEX SyntheticsGlobalVariableParserType = "regex" + SYNTHETICSGLOBALVARIABLEPARSERTYPE_X_PATH SyntheticsGlobalVariableParserType = "x_path" +) + +var allowedSyntheticsGlobalVariableParserTypeEnumValues = []SyntheticsGlobalVariableParserType{ + SYNTHETICSGLOBALVARIABLEPARSERTYPE_RAW, + SYNTHETICSGLOBALVARIABLEPARSERTYPE_JSON_PATH, + SYNTHETICSGLOBALVARIABLEPARSERTYPE_REGEX, + SYNTHETICSGLOBALVARIABLEPARSERTYPE_X_PATH, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsGlobalVariableParserType) GetAllowedValues() []SyntheticsGlobalVariableParserType { + return allowedSyntheticsGlobalVariableParserTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsGlobalVariableParserType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsGlobalVariableParserType(value) + return nil +} + +// NewSyntheticsGlobalVariableParserTypeFromValue returns a pointer to a valid SyntheticsGlobalVariableParserType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsGlobalVariableParserTypeFromValue(v string) (*SyntheticsGlobalVariableParserType, error) { + ev := SyntheticsGlobalVariableParserType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsGlobalVariableParserType: valid values are %v", v, allowedSyntheticsGlobalVariableParserTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsGlobalVariableParserType) IsValid() bool { + for _, existing := range allowedSyntheticsGlobalVariableParserTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsGlobalVariableParserType value. +func (v SyntheticsGlobalVariableParserType) Ptr() *SyntheticsGlobalVariableParserType { + return &v +} diff --git a/api/datadogV2/model_synthetics_global_variable_totp_parameters.go b/api/datadogV2/model_synthetics_global_variable_totp_parameters.go new file mode 100644 index 00000000000..b2d84c7a014 --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_totp_parameters.go @@ -0,0 +1,137 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariableTOTPParameters Parameters for the TOTP/MFA variable +type SyntheticsGlobalVariableTOTPParameters struct { + // Number of digits for the OTP code. + Digits *int32 `json:"digits,omitempty"` + // Interval for which to refresh the token (in seconds). + RefreshInterval *int32 `json:"refresh_interval,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:"-"` +} + +// NewSyntheticsGlobalVariableTOTPParameters instantiates a new SyntheticsGlobalVariableTOTPParameters 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 NewSyntheticsGlobalVariableTOTPParameters() *SyntheticsGlobalVariableTOTPParameters { + this := SyntheticsGlobalVariableTOTPParameters{} + return &this +} + +// NewSyntheticsGlobalVariableTOTPParametersWithDefaults instantiates a new SyntheticsGlobalVariableTOTPParameters 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 NewSyntheticsGlobalVariableTOTPParametersWithDefaults() *SyntheticsGlobalVariableTOTPParameters { + this := SyntheticsGlobalVariableTOTPParameters{} + return &this +} + +// GetDigits returns the Digits field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableTOTPParameters) GetDigits() int32 { + if o == nil || o.Digits == nil { + var ret int32 + return ret + } + return *o.Digits +} + +// GetDigitsOk returns a tuple with the Digits field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableTOTPParameters) GetDigitsOk() (*int32, bool) { + if o == nil || o.Digits == nil { + return nil, false + } + return o.Digits, true +} + +// HasDigits returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableTOTPParameters) HasDigits() bool { + return o != nil && o.Digits != nil +} + +// SetDigits gets a reference to the given int32 and assigns it to the Digits field. +func (o *SyntheticsGlobalVariableTOTPParameters) SetDigits(v int32) { + o.Digits = &v +} + +// GetRefreshInterval returns the RefreshInterval field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableTOTPParameters) GetRefreshInterval() int32 { + if o == nil || o.RefreshInterval == nil { + var ret int32 + return ret + } + return *o.RefreshInterval +} + +// GetRefreshIntervalOk returns a tuple with the RefreshInterval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableTOTPParameters) GetRefreshIntervalOk() (*int32, bool) { + if o == nil || o.RefreshInterval == nil { + return nil, false + } + return o.RefreshInterval, true +} + +// HasRefreshInterval returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableTOTPParameters) HasRefreshInterval() bool { + return o != nil && o.RefreshInterval != nil +} + +// SetRefreshInterval gets a reference to the given int32 and assigns it to the RefreshInterval field. +func (o *SyntheticsGlobalVariableTOTPParameters) SetRefreshInterval(v int32) { + o.RefreshInterval = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsGlobalVariableTOTPParameters) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Digits != nil { + toSerialize["digits"] = o.Digits + } + if o.RefreshInterval != nil { + toSerialize["refresh_interval"] = o.RefreshInterval + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsGlobalVariableTOTPParameters) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Digits *int32 `json:"digits,omitempty"` + RefreshInterval *int32 `json:"refresh_interval,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"digits", "refresh_interval"}) + } else { + return err + } + o.Digits = all.Digits + o.RefreshInterval = all.RefreshInterval + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_global_variable_value.go b/api/datadogV2/model_synthetics_global_variable_value.go new file mode 100644 index 00000000000..fdc040ade86 --- /dev/null +++ b/api/datadogV2/model_synthetics_global_variable_value.go @@ -0,0 +1,182 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsGlobalVariableValue Value of the global variable. +type SyntheticsGlobalVariableValue struct { + // Options for the Global Variable for MFA. + Options *SyntheticsGlobalVariableOptions `json:"options,omitempty"` + // Determines if the value of the variable is hidden. + Secure *bool `json:"secure,omitempty"` + // Value of the global variable. When reading a global variable, + // the value will not be present if the variable is hidden with the `secure` property. + Value *string `json:"value,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:"-"` +} + +// NewSyntheticsGlobalVariableValue instantiates a new SyntheticsGlobalVariableValue 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 NewSyntheticsGlobalVariableValue() *SyntheticsGlobalVariableValue { + this := SyntheticsGlobalVariableValue{} + return &this +} + +// NewSyntheticsGlobalVariableValueWithDefaults instantiates a new SyntheticsGlobalVariableValue 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 NewSyntheticsGlobalVariableValueWithDefaults() *SyntheticsGlobalVariableValue { + this := SyntheticsGlobalVariableValue{} + return &this +} + +// GetOptions returns the Options field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableValue) GetOptions() SyntheticsGlobalVariableOptions { + if o == nil || o.Options == nil { + var ret SyntheticsGlobalVariableOptions + return ret + } + return *o.Options +} + +// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableValue) GetOptionsOk() (*SyntheticsGlobalVariableOptions, bool) { + if o == nil || o.Options == nil { + return nil, false + } + return o.Options, true +} + +// HasOptions returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableValue) HasOptions() bool { + return o != nil && o.Options != nil +} + +// SetOptions gets a reference to the given SyntheticsGlobalVariableOptions and assigns it to the Options field. +func (o *SyntheticsGlobalVariableValue) SetOptions(v SyntheticsGlobalVariableOptions) { + o.Options = &v +} + +// GetSecure returns the Secure field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableValue) GetSecure() bool { + if o == nil || o.Secure == nil { + var ret bool + return ret + } + return *o.Secure +} + +// GetSecureOk returns a tuple with the Secure field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableValue) GetSecureOk() (*bool, bool) { + if o == nil || o.Secure == nil { + return nil, false + } + return o.Secure, true +} + +// HasSecure returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableValue) HasSecure() bool { + return o != nil && o.Secure != nil +} + +// SetSecure gets a reference to the given bool and assigns it to the Secure field. +func (o *SyntheticsGlobalVariableValue) SetSecure(v bool) { + o.Secure = &v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableValue) GetValue() string { + if o == nil || o.Value == nil { + var ret string + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableValue) GetValueOk() (*string, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableValue) HasValue() bool { + return o != nil && o.Value != nil +} + +// SetValue gets a reference to the given string and assigns it to the Value field. +func (o *SyntheticsGlobalVariableValue) SetValue(v string) { + o.Value = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Options != nil { + toSerialize["options"] = o.Options + } + if o.Secure != nil { + toSerialize["secure"] = o.Secure + } + if o.Value != nil { + toSerialize["value"] = o.Value + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsGlobalVariableValue) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Options *SyntheticsGlobalVariableOptions `json:"options,omitempty"` + Secure *bool `json:"secure,omitempty"` + Value *string `json:"value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"options", "secure", "value"}) + } else { + return err + } + + hasInvalidField := false + if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Options = all.Options + o.Secure = all.Secure + o.Value = all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_variable_parser.go b/api/datadogV2/model_synthetics_variable_parser.go new file mode 100644 index 00000000000..edd5cd00c9e --- /dev/null +++ b/api/datadogV2/model_synthetics_variable_parser.go @@ -0,0 +1,146 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsVariableParser Details of the parser to use for the global variable. +type SyntheticsVariableParser struct { + // Type of parser for a Synthetic global variable from a synthetics test. + Type SyntheticsGlobalVariableParserType `json:"type"` + // Regex or JSON path used for the parser. Not used with type `raw`. + Value *string `json:"value,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:"-"` +} + +// NewSyntheticsVariableParser instantiates a new SyntheticsVariableParser 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 NewSyntheticsVariableParser(typeVar SyntheticsGlobalVariableParserType) *SyntheticsVariableParser { + this := SyntheticsVariableParser{} + this.Type = typeVar + return &this +} + +// NewSyntheticsVariableParserWithDefaults instantiates a new SyntheticsVariableParser 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 NewSyntheticsVariableParserWithDefaults() *SyntheticsVariableParser { + this := SyntheticsVariableParser{} + return &this +} + +// GetType returns the Type field value. +func (o *SyntheticsVariableParser) GetType() SyntheticsGlobalVariableParserType { + if o == nil { + var ret SyntheticsGlobalVariableParserType + 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 *SyntheticsVariableParser) GetTypeOk() (*SyntheticsGlobalVariableParserType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SyntheticsVariableParser) SetType(v SyntheticsGlobalVariableParserType) { + o.Type = v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *SyntheticsVariableParser) GetValue() string { + if o == nil || o.Value == nil { + var ret string + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsVariableParser) GetValueOk() (*string, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *SyntheticsVariableParser) HasValue() bool { + return o != nil && o.Value != nil +} + +// SetValue gets a reference to the given string and assigns it to the Value field. +func (o *SyntheticsVariableParser) SetValue(v string) { + o.Value = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsVariableParser) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["type"] = o.Type + if o.Value != nil { + toSerialize["value"] = o.Value + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsVariableParser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Type *SyntheticsGlobalVariableParserType `json:"type"` + Value *string `json:"value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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{"type", "value"}) + } else { + return err + } + + hasInvalidField := false + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.Value = all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/examples/v2/synthetics/PatchGlobalVariable.go b/examples/v2/synthetics/PatchGlobalVariable.go new file mode 100644 index 00000000000..3e2aaaf7f1a --- /dev/null +++ b/examples/v2/synthetics/PatchGlobalVariable.go @@ -0,0 +1,42 @@ +// Patch a global variable returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.GlobalVariableJsonPatchRequest{ + Data: datadogV2.GlobalVariableJsonPatchRequestData{ + Attributes: &datadogV2.GlobalVariableJsonPatchRequestDataAttributes{ + JsonPatch: []datadogV2.JsonPatchOperation{ + { + Op: datadogV2.JSONPATCHOPERATIONOP_ADD, + Path: "/name", + }, + }, + }, + Type: datadogV2.GLOBALVARIABLEJSONPATCHTYPE_GLOBAL_VARIABLES_JSON_PATCH.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.PatchGlobalVariable(ctx, "variable_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.PatchGlobalVariable`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.PatchGlobalVariable`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/synthetics.feature b/tests/scenarios/features/v2/synthetics.feature index 73efa73ec29..133993b11b7 100644 --- a/tests/scenarios/features/v2/synthetics.feature +++ b/tests/scenarios/features/v2/synthetics.feature @@ -20,6 +20,30 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-managing + Scenario: Patch a global variable returns "Bad Request" response + Given new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"json_patch": [{"op": "add", "path": "/name"}]}, "type": "global_variables_json_patch"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Patch a global variable returns "Not Found" response + Given new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"json_patch": [{"op": "add", "path": "/name"}]}, "type": "global_variables_json_patch"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Patch a global variable returns "OK" response + Given new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"json_patch": [{"op": "add", "path": "/name"}]}, "type": "global_variables_json_patch"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/synthetics-managing Scenario: Save new value for on-demand concurrency cap returns "OK" response Given new "SetOnDemandConcurrencyCap" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 3799e64e630..f4cbbb2baae 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4284,6 +4284,12 @@ "type": "safe" } }, + "PatchGlobalVariable": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, "ListTagPipelinesRulesets": { "tag": "Cloud Cost Management", "undo": {