Skip to content

Commit

Permalink
Regenerate client from commit 65b2053a of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Dec 8, 2022
1 parent debc4b7 commit 097483f
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 17 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.4",
"regenerated": "2022-12-05 18:23:36.599390",
"spec_repo_commit": "1cc231e1"
"regenerated": "2022-12-08 13:18:19.409276",
"spec_repo_commit": "65b2053a"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-12-05 18:23:36.614551",
"spec_repo_commit": "1cc231e1"
"regenerated": "2022-12-08 13:18:19.421026",
"spec_repo_commit": "65b2053a"
}
}
}
3 changes: 3 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11716,6 +11716,8 @@ components:
description: Scope to use when performing the authentication.
example: scope
type: string
tokenApiAuthentication:
$ref: '#/components/schemas/SyntheticsBasicAuthOauthTokenApiAuthentication'
type:
$ref: '#/components/schemas/SyntheticsBasicAuthOauthROPType'
username:
Expand All @@ -11725,6 +11727,7 @@ components:
required:
- accessTokenUrl
- password
- tokenApiAuthentication
- username
type: object
SyntheticsBasicAuthOauthROPType:
Expand Down
67 changes: 54 additions & 13 deletions api/datadogV1/model_synthetics_basic_auth_oauth_rop.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type SyntheticsBasicAuthOauthROP struct {
Resource *string `json:"resource,omitempty"`
// Scope to use when performing the authentication.
Scope *string `json:"scope,omitempty"`
// Type of token to use when performing the authentication.
TokenApiAuthentication SyntheticsBasicAuthOauthTokenApiAuthentication `json:"tokenApiAuthentication"`
// The type of basic authentication to use when performing the test.
Type *SyntheticsBasicAuthOauthROPType `json:"type,omitempty"`
// Username to use when performing the authentication.
Expand All @@ -38,10 +40,11 @@ type SyntheticsBasicAuthOauthROP struct {
// 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 NewSyntheticsBasicAuthOauthROP(accessTokenUrl string, password string, username string) *SyntheticsBasicAuthOauthROP {
func NewSyntheticsBasicAuthOauthROP(accessTokenUrl string, password string, tokenApiAuthentication SyntheticsBasicAuthOauthTokenApiAuthentication, username string) *SyntheticsBasicAuthOauthROP {
this := SyntheticsBasicAuthOauthROP{}
this.AccessTokenUrl = accessTokenUrl
this.Password = password
this.TokenApiAuthentication = tokenApiAuthentication
var typeVar SyntheticsBasicAuthOauthROPType = SYNTHETICSBASICAUTHOAUTHROPTYPE_OAUTH_ROP
this.Type = &typeVar
this.Username = username
Expand Down Expand Up @@ -244,6 +247,29 @@ func (o *SyntheticsBasicAuthOauthROP) SetScope(v string) {
o.Scope = &v
}

// GetTokenApiAuthentication returns the TokenApiAuthentication field value.
func (o *SyntheticsBasicAuthOauthROP) GetTokenApiAuthentication() SyntheticsBasicAuthOauthTokenApiAuthentication {
if o == nil {
var ret SyntheticsBasicAuthOauthTokenApiAuthentication
return ret
}
return o.TokenApiAuthentication
}

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

// SetTokenApiAuthentication sets field value.
func (o *SyntheticsBasicAuthOauthROP) SetTokenApiAuthentication(v SyntheticsBasicAuthOauthTokenApiAuthentication) {
o.TokenApiAuthentication = v
}

// GetType returns the Type field value if set, zero value otherwise.
func (o *SyntheticsBasicAuthOauthROP) GetType() SyntheticsBasicAuthOauthROPType {
if o == nil || o.Type == nil {
Expand Down Expand Up @@ -318,6 +344,7 @@ func (o SyntheticsBasicAuthOauthROP) MarshalJSON() ([]byte, error) {
if o.Scope != nil {
toSerialize["scope"] = o.Scope
}
toSerialize["tokenApiAuthentication"] = o.TokenApiAuthentication
if o.Type != nil {
toSerialize["type"] = o.Type
}
Expand All @@ -333,20 +360,22 @@ func (o SyntheticsBasicAuthOauthROP) MarshalJSON() ([]byte, error) {
func (o *SyntheticsBasicAuthOauthROP) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
required := struct {
AccessTokenUrl *string `json:"accessTokenUrl"`
Password *string `json:"password"`
Username *string `json:"username"`
AccessTokenUrl *string `json:"accessTokenUrl"`
Password *string `json:"password"`
TokenApiAuthentication *SyntheticsBasicAuthOauthTokenApiAuthentication `json:"tokenApiAuthentication"`
Username *string `json:"username"`
}{}
all := struct {
AccessTokenUrl string `json:"accessTokenUrl"`
Audience *string `json:"audience,omitempty"`
ClientId *string `json:"clientId,omitempty"`
ClientSecret *string `json:"clientSecret,omitempty"`
Password string `json:"password"`
Resource *string `json:"resource,omitempty"`
Scope *string `json:"scope,omitempty"`
Type *SyntheticsBasicAuthOauthROPType `json:"type,omitempty"`
Username string `json:"username"`
AccessTokenUrl string `json:"accessTokenUrl"`
Audience *string `json:"audience,omitempty"`
ClientId *string `json:"clientId,omitempty"`
ClientSecret *string `json:"clientSecret,omitempty"`
Password string `json:"password"`
Resource *string `json:"resource,omitempty"`
Scope *string `json:"scope,omitempty"`
TokenApiAuthentication SyntheticsBasicAuthOauthTokenApiAuthentication `json:"tokenApiAuthentication"`
Type *SyntheticsBasicAuthOauthROPType `json:"type,omitempty"`
Username string `json:"username"`
}{}
err = json.Unmarshal(bytes, &required)
if err != nil {
Expand All @@ -358,6 +387,9 @@ func (o *SyntheticsBasicAuthOauthROP) UnmarshalJSON(bytes []byte) (err error) {
if required.Password == nil {
return fmt.Errorf("required field password missing")
}
if required.TokenApiAuthentication == nil {
return fmt.Errorf("required field tokenApiAuthentication missing")
}
if required.Username == nil {
return fmt.Errorf("required field username missing")
}
Expand All @@ -370,6 +402,14 @@ func (o *SyntheticsBasicAuthOauthROP) UnmarshalJSON(bytes []byte) (err error) {
o.UnparsedObject = raw
return nil
}
if v := all.TokenApiAuthentication; !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
if v := all.Type; v != nil && !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
Expand All @@ -385,6 +425,7 @@ func (o *SyntheticsBasicAuthOauthROP) UnmarshalJSON(bytes []byte) (err error) {
o.Password = all.Password
o.Resource = all.Resource
o.Scope = all.Scope
o.TokenApiAuthentication = all.TokenApiAuthentication
o.Type = all.Type
o.Username = all.Username
return nil
Expand Down
137 changes: 137 additions & 0 deletions examples/v1/synthetics/CreateSyntheticsAPITest_960766374.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Create an API HTTP with oauth-rop test returns "OK - Returns the created test details." 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/datadogV1"
)

func main() {
body := datadogV1.SyntheticsAPITest{
Config: datadogV1.SyntheticsAPITestConfig{
Assertions: []datadogV1.SyntheticsAssertion{
datadogV1.SyntheticsAssertion{
SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS,
Property: datadog.PtrString("{{ PROPERTY }}"),
Target: "text/html",
Type: datadogV1.SYNTHETICSASSERTIONTYPE_HEADER,
}},
datadogV1.SyntheticsAssertion{
SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{
Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_LESS_THAN,
Target: 2000,
Type: datadogV1.SYNTHETICSASSERTIONTYPE_RESPONSE_TIME,
}},
datadogV1.SyntheticsAssertion{
SyntheticsAssertionJSONPathTarget: &datadogV1.SyntheticsAssertionJSONPathTarget{
Operator: datadogV1.SYNTHETICSASSERTIONJSONPATHOPERATOR_VALIDATES_JSON_PATH,
Target: &datadogV1.SyntheticsAssertionJSONPathTargetTarget{
JsonPath: datadog.PtrString("topKey"),
Operator: datadog.PtrString("isNot"),
TargetValue: "0",
},
Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY,
}},
datadogV1.SyntheticsAssertion{
SyntheticsAssertionXPathTarget: &datadogV1.SyntheticsAssertionXPathTarget{
Operator: datadogV1.SYNTHETICSASSERTIONXPATHOPERATOR_VALIDATES_X_PATH,
Target: &datadogV1.SyntheticsAssertionXPathTargetTarget{
XPath: datadog.PtrString("target-xpath"),
TargetValue: "0",
Operator: datadog.PtrString("contains"),
},
Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY,
}},
},
ConfigVariables: []datadogV1.SyntheticsConfigVariable{
{
Example: datadog.PtrString("content-type"),
Name: "PROPERTY",
Pattern: datadog.PtrString("content-type"),
Type: datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT,
},
},
Request: &datadogV1.SyntheticsTestRequest{
Certificate: &datadogV1.SyntheticsTestRequestCertificate{
Cert: &datadogV1.SyntheticsTestRequestCertificateItem{
Content: datadog.PtrString("cert-content"),
Filename: datadog.PtrString("cert-filename"),
UpdatedAt: datadog.PtrString("2020-10-16T09:23:24.857Z"),
},
Key: &datadogV1.SyntheticsTestRequestCertificateItem{
Content: datadog.PtrString("key-content"),
Filename: datadog.PtrString("key-filename"),
UpdatedAt: datadog.PtrString("2020-10-16T09:23:24.857Z"),
},
},
Headers: map[string]string{
"unique": "examplecreateanapihttpwithoauthroptestreturnsokreturnsthecreatedtestdetailsresponse",
},
Method: datadogV1.HTTPMETHOD_GET.Ptr(),
Timeout: datadog.PtrFloat64(10),
Url: datadog.PtrString("https://datadoghq.com"),
Proxy: &datadogV1.SyntheticsTestRequestProxy{
Url: "https://datadoghq.com",
Headers: map[string]string{},
},
BasicAuth: &datadogV1.SyntheticsBasicAuth{
SyntheticsBasicAuthOauthROP: &datadogV1.SyntheticsBasicAuthOauthROP{
AccessTokenUrl: "https://datadog-token.com",
Audience: datadog.PtrString("audience"),
ClientId: datadog.PtrString("client-id"),
ClientSecret: datadog.PtrString("client-secret"),
Resource: datadog.PtrString("resource"),
Scope: datadog.PtrString("yoyo"),
TokenApiAuthentication: datadogV1.SYNTHETICSBASICAUTHOAUTHTOKENAPIAUTHENTICATION_BODY,
Type: datadogV1.SYNTHETICSBASICAUTHOAUTHROPTYPE_OAUTH_ROP.Ptr(),
Username: "oauth-usermame",
Password: "oauth-password",
}},
},
},
Locations: []string{
"aws:us-east-2",
},
Message: "BDD test payload: synthetics_api_http_test_payload.json",
Name: "Example-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response",
Options: datadogV1.SyntheticsTestOptions{
AcceptSelfSigned: datadog.PtrBool(false),
AllowInsecure: datadog.PtrBool(true),
FollowRedirects: datadog.PtrBool(true),
MinFailureDuration: datadog.PtrInt64(10),
MinLocationFailed: datadog.PtrInt64(1),
MonitorName: datadog.PtrString("Example-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response"),
MonitorPriority: datadog.PtrInt32(5),
Retry: &datadogV1.SyntheticsTestOptionsRetry{
Count: datadog.PtrInt64(3),
Interval: datadog.PtrFloat64(10),
},
TickEvery: datadog.PtrInt64(60),
},
Subtype: datadogV1.SYNTHETICSTESTDETAILSSUBTYPE_HTTP.Ptr(),
Tags: []string{
"testing:api",
},
Type: datadogV1.SYNTHETICSAPITESTTYPE_API,
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewSyntheticsApi(apiClient)
resp, r, err := api.CreateSyntheticsAPITest(ctx, body)

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsAPITest`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsAPITest`:\n%s\n", responseContent)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-12-07T10:36:18.554Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
interactions:
- request:
body: |
{"config":{"assertions":[{"operator":"is","property":"{{ PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","password":"oauth-password","resource":"resource","scope":"yoyo","tokenApiAuthentication":"body","type":"oauth-rop","username":"oauth-usermame"},"certificate":{"cert":{"content":"cert-content","filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"content":"key-content","filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"headers":{"unique":"testcreateanapihttpwithoauthroptestreturnsokreturnsthecreatedtestdetailsresponse1670409378"},"method":"GET","proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"locations":["aws:us-east-2"],"message":"BDD test payload: synthetics_api_http_test_payload.json","name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
method: POST
url: https://api.datadoghq.com/api/v1/synthetics/tests/api
response:
body: '{"status":"live","public_id":"u7x-e98-98f","tags":["testing:api"],"org_id":569509,"locations":["aws:us-east-2"],"message":"BDD
test payload: synthetics_api_http_test_payload.json","deleted_at":null,"name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","monitor_id":105046994,"type":"api","created_at":"2022-12-07T10:36:19.000736+00:00","modified_at":"2022-12-07T10:36:19.000736+00:00","subtype":"http","config":{"request":{"certificate":{"cert":{"filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"url":"https://datadoghq.com","basicAuth":{"username":"oauth-usermame","clientSecret":"client-secret","resource":"resource","accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","scope":"yoyo","password":"oauth-password","type":"oauth-rop","tokenApiAuthentication":"body"},"headers":{"unique":"testcreateanapihttpwithoauthroptestreturnsokreturnsthecreatedtestdetailsresponse1670409378"},"proxy":{"url":"https://datadoghq.com","headers":{}},"timeout":10,"method":"GET"},"assertions":[{"operator":"is","property":"{{
PROPERTY }}","type":"header","target":"text/html"},{"operator":"lessThan","type":"responseTime","target":2000},{"operator":"validatesJSONPath","type":"body","target":{"operator":"isNot","targetValue":"0","jsonPath":"topKey"}},{"operator":"validatesXPath","type":"body","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"}}],"configVariables":[{"pattern":"content-type","type":"text","example":"content-type","name":"PROPERTY"}]},"options":{"accept_self_signed":false,"retry":{"count":3,"interval":10},"min_location_failed":1,"allow_insecure":true,"follow_redirects":true,"min_failure_duration":10,"monitor_priority":5,"monitor_name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","tick_every":60}}'
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 200 OK
- request:
body: |
{"public_ids":["u7x-e98-98f"]}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
method: POST
url: https://api.datadoghq.com/api/v1/synthetics/tests/delete
response:
body: '{"deleted_tests":[{"deleted_at":"2022-12-07T10:36:19.441845+00:00","public_id":"u7x-e98-98f"}]}
'
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 200 OK
version: 1
8 changes: 8 additions & 0 deletions tests/scenarios/features/v1/synthetics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ Feature: Synthetics
Then the response status is 200 OK - Returns the created test details.
And the response "name" is equal to "{{ unique }}"

@team:DataDog/synthetics-app
Scenario: Create an API HTTP with oauth-rop test returns "OK - Returns the created test details." response
Given new "CreateSyntheticsAPITest" request
And body from file "synthetics_api_http_test_oauth_rop_payload.json"
When the request is sent
Then the response status is 200 OK - Returns the created test details.
And the response "name" is equal to "{{ unique }}"

@team:DataDog/synthetics-app
Scenario: Create an API SSL test returns "OK - Returns the created test details." response
Given new "CreateSyntheticsAPITest" request
Expand Down
Loading

0 comments on commit 097483f

Please sign in to comment.