Skip to content

Commit

Permalink
Regenerate client from commit 0686849c of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Nov 17, 2023
1 parent 1c7b7cb commit fabed32
Show file tree
Hide file tree
Showing 12 changed files with 682 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2023-11-17 11:20:28.325496",
"spec_repo_commit": "04139dfa"
"regenerated": "2023-11-17 12:05:36.502802",
"spec_repo_commit": "0686849c"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-11-17 11:20:28.339599",
"spec_repo_commit": "04139dfa"
"regenerated": "2023-11-17 12:05:36.525495",
"spec_repo_commit": "0686849c"
}
}
}
105 changes: 104 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14705,6 +14705,55 @@ components:
type:
$ref: '#/components/schemas/SyntheticsGlobalVariableParseTestOptionsType'
type: object
SyntheticsPatchTestBody:
description: Wrapper around an array of [JSON Patch](https://jsonpatch.com)
operations to perform on the test
properties:
data:
description: Array of [JSON Patch](https://jsonpatch.com) operations to
perform on the test
example:
- op: replace
path: /name
value: New test name
- op: remove
path: /config/assertions/0
items:
$ref: '#/components/schemas/SyntheticsPatchTestOperation'
type: array
type: object
SyntheticsPatchTestOperation:
description: A single [JSON Patch](https://jsonpatch.com) operation to perform
on the test
properties:
op:
$ref: '#/components/schemas/SyntheticsPatchTestOperationName'
path:
description: The path to the value to modify
example: /name
type: string
value:
description: A value to use in a [JSON Patch](https://jsonpatch.com) operation
example: New Test Name
type: object
SyntheticsPatchTestOperationName:
description: The operation to perform
enum:
- add
- remove
- replace
- move
- copy
- test
example: replace
type: string
x-enum-varnames:
- ADD
- REMOVE
- REPLACE
- MOVE
- COPY
- TEST
SyntheticsPlayingTab:
description: Navigate between different tabs for your browser test.
enum:
Expand Down Expand Up @@ -29651,7 +29700,7 @@ paths:
description: Edit the configuration of a Synthetic browser test.
operationId: UpdateBrowserTest
parameters:
- description: The public ID of the test to get details from.
- description: The public ID of the test to edit.
in: path
name: public_id
required: true
Expand Down Expand Up @@ -29990,6 +30039,60 @@ paths:
summary: Get a test configuration
tags:
- Synthetics
patch:
description: Patch the configuration of a Synthetic test with partial data.
operationId: PatchTest
parameters:
- description: The public ID of the test to patch.
in: path
name: public_id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SyntheticsPatchTestBody'
description: '[JSON Patch](https://jsonpatch.com/) compliant list of operations'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SyntheticsTestDetails'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: '- JSON format is wrong

- Updating sub-type is forbidden'
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: '- Synthetic Monitoring is not activated for the user

- Test is not owned by the user

- Test can''t be found'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Patch a Synthetic test
tags:
- Synthetics
x-codegen-request-body-name: body
/api/v1/synthetics/tests/{public_id}/results:
get:
description: Get the last 150 test results summaries for a given Synthetic API
Expand Down
74 changes: 74 additions & 0 deletions api/datadogV1/api_synthetics.go
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,80 @@ func (a *SyntheticsApi) ListTestsWithPagination(ctx _context.Context, o ...ListT
return items, cancel
}

// PatchTest Patch a Synthetic test.
// Patch the configuration of a Synthetic test with partial data.
func (a *SyntheticsApi) PatchTest(ctx _context.Context, publicId string, body SyntheticsPatchTestBody) (SyntheticsTestDetails, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPatch
localVarPostBody interface{}
localVarReturnValue SyntheticsTestDetails
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v1.SyntheticsApi.PatchTest")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v1/synthetics/tests/{public_id}"
localVarPath = strings.Replace(localVarPath, "{"+"public_id"+"}", _neturl.PathEscape(datadog.ParameterToString(publicId, "")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Content-Type"] = "application/json"
localVarHeaderParams["Accept"] = "application/json"

// body params
localVarPostBody = &body
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 == 403 || 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
}

// TriggerCITests Trigger tests from CI/CD pipelines.
// Trigger a set of Synthetic tests for continuous integration.
func (a *SyntheticsApi) TriggerCITests(ctx _context.Context, body SyntheticsCITestBody) (SyntheticsTriggerCITestsResponse, *_nethttp.Response, error) {
Expand Down
1 change: 1 addition & 0 deletions api/datadogV1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
// - [SyntheticsApi.ListGlobalVariables]
// - [SyntheticsApi.ListLocations]
// - [SyntheticsApi.ListTests]
// - [SyntheticsApi.PatchTest]
// - [SyntheticsApi.TriggerCITests]
// - [SyntheticsApi.TriggerTests]
// - [SyntheticsApi.UpdateAPITest]
Expand Down
102 changes: 102 additions & 0 deletions api/datadogV1/model_synthetics_patch_test_body.go
Original file line number Diff line number Diff line change
@@ -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 datadogV1

import (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// SyntheticsPatchTestBody Wrapper around an array of [JSON Patch](https://jsonpatch.com) operations to perform on the test
type SyntheticsPatchTestBody struct {
// Array of [JSON Patch](https://jsonpatch.com) operations to perform on the test
Data []SyntheticsPatchTestOperation `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{}
}

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

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

// GetData returns the Data field value if set, zero value otherwise.
func (o *SyntheticsPatchTestBody) GetData() []SyntheticsPatchTestOperation {
if o == nil || o.Data == nil {
var ret []SyntheticsPatchTestOperation
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 *SyntheticsPatchTestBody) GetDataOk() (*[]SyntheticsPatchTestOperation, 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 *SyntheticsPatchTestBody) HasData() bool {
return o != nil && o.Data != nil
}

// SetData gets a reference to the given []SyntheticsPatchTestOperation and assigns it to the Data field.
func (o *SyntheticsPatchTestBody) SetData(v []SyntheticsPatchTestOperation) {
o.Data = v
}

// MarshalJSON serializes the struct using spec logic.
func (o SyntheticsPatchTestBody) 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 *SyntheticsPatchTestBody) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Data []SyntheticsPatchTestOperation `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
}
o.Data = all.Data

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

return nil
}
Loading

0 comments on commit fabed32

Please sign in to comment.