Skip to content

Commit ca779ce

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add TOTP parameters to Synthetics test options (#1815)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent e22ba06 commit ca779ce

10 files changed

+336
-18
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2023-01-11 09:53:51.620609",
8-
"spec_repo_commit": "c22824fc"
7+
"regenerated": "2023-01-11 12:48:13.442587",
8+
"spec_repo_commit": "c986b09e"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-01-11 09:53:51.635618",
13-
"spec_repo_commit": "c22824fc"
12+
"regenerated": "2023-01-11 12:48:13.454082",
13+
"spec_repo_commit": "c986b09e"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12722,6 +12722,12 @@ components:
1272212722
restricted_roles:
1272312723
$ref: '#/components/schemas/SyntheticsRestrictedRoles'
1272412724
type: object
12725+
SyntheticsGlobalVariableOptions:
12726+
description: Options for the Global Variable for MFA.
12727+
properties:
12728+
totp_parameters:
12729+
$ref: '#/components/schemas/SyntheticsGlobalVariableTOTPParameters'
12730+
type: object
1272512731
SyntheticsGlobalVariableParseTestOptions:
1272612732
description: Parser options to use for retrieving a Synthetics global variable
1272712733
from a Synthetics Test. Used in conjunction with `parse_test_public_id`.
@@ -12771,12 +12777,32 @@ components:
1277112777
- JSON_PATH
1277212778
- REGEX
1277312779
- X_PATH
12780+
SyntheticsGlobalVariableTOTPParameters:
12781+
description: Parameters for the TOTP/MFA variable
12782+
properties:
12783+
digits:
12784+
description: Number of digits for the OTP code.
12785+
example: 6
12786+
format: int32
12787+
maximum: 10
12788+
minimum: 4
12789+
type: integer
12790+
refresh_interval:
12791+
description: Interval for which to refresh the token (in seconds).
12792+
example: 30
12793+
format: int32
12794+
maximum: 999
12795+
minimum: 0
12796+
type: integer
12797+
type: object
1277412798
SyntheticsGlobalVariableValue:
1277512799
description: Value of the global variable.
1277612800
example:
1277712801
secure: true
1277812802
value: value
1277912803
properties:
12804+
options:
12805+
$ref: '#/components/schemas/SyntheticsGlobalVariableOptions'
1278012806
secure:
1278112807
description: Determines if the value of the variable is hidden.
1278212808
type: boolean
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV1
6+
7+
import (
8+
"encoding/json"
9+
)
10+
11+
// SyntheticsGlobalVariableOptions Options for the Global Variable for MFA.
12+
type SyntheticsGlobalVariableOptions struct {
13+
// Parameters for the TOTP/MFA variable
14+
TotpParameters *SyntheticsGlobalVariableTOTPParameters `json:"totp_parameters,omitempty"`
15+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
16+
UnparsedObject map[string]interface{} `json:"-"`
17+
AdditionalProperties map[string]interface{}
18+
}
19+
20+
// NewSyntheticsGlobalVariableOptions instantiates a new SyntheticsGlobalVariableOptions object.
21+
// This constructor will assign default values to properties that have it defined,
22+
// and makes sure properties required by API are set, but the set of arguments
23+
// will change when the set of required properties is changed.
24+
func NewSyntheticsGlobalVariableOptions() *SyntheticsGlobalVariableOptions {
25+
this := SyntheticsGlobalVariableOptions{}
26+
return &this
27+
}
28+
29+
// NewSyntheticsGlobalVariableOptionsWithDefaults instantiates a new SyntheticsGlobalVariableOptions object.
30+
// This constructor will only assign default values to properties that have it defined,
31+
// but it doesn't guarantee that properties required by API are set.
32+
func NewSyntheticsGlobalVariableOptionsWithDefaults() *SyntheticsGlobalVariableOptions {
33+
this := SyntheticsGlobalVariableOptions{}
34+
return &this
35+
}
36+
37+
// GetTotpParameters returns the TotpParameters field value if set, zero value otherwise.
38+
func (o *SyntheticsGlobalVariableOptions) GetTotpParameters() SyntheticsGlobalVariableTOTPParameters {
39+
if o == nil || o.TotpParameters == nil {
40+
var ret SyntheticsGlobalVariableTOTPParameters
41+
return ret
42+
}
43+
return *o.TotpParameters
44+
}
45+
46+
// GetTotpParametersOk returns a tuple with the TotpParameters field value if set, nil otherwise
47+
// and a boolean to check if the value has been set.
48+
func (o *SyntheticsGlobalVariableOptions) GetTotpParametersOk() (*SyntheticsGlobalVariableTOTPParameters, bool) {
49+
if o == nil || o.TotpParameters == nil {
50+
return nil, false
51+
}
52+
return o.TotpParameters, true
53+
}
54+
55+
// HasTotpParameters returns a boolean if a field has been set.
56+
func (o *SyntheticsGlobalVariableOptions) HasTotpParameters() bool {
57+
return o != nil && o.TotpParameters != nil
58+
}
59+
60+
// SetTotpParameters gets a reference to the given SyntheticsGlobalVariableTOTPParameters and assigns it to the TotpParameters field.
61+
func (o *SyntheticsGlobalVariableOptions) SetTotpParameters(v SyntheticsGlobalVariableTOTPParameters) {
62+
o.TotpParameters = &v
63+
}
64+
65+
// MarshalJSON serializes the struct using spec logic.
66+
func (o SyntheticsGlobalVariableOptions) MarshalJSON() ([]byte, error) {
67+
toSerialize := map[string]interface{}{}
68+
if o.UnparsedObject != nil {
69+
return json.Marshal(o.UnparsedObject)
70+
}
71+
if o.TotpParameters != nil {
72+
toSerialize["totp_parameters"] = o.TotpParameters
73+
}
74+
75+
for key, value := range o.AdditionalProperties {
76+
toSerialize[key] = value
77+
}
78+
return json.Marshal(toSerialize)
79+
}
80+
81+
// UnmarshalJSON deserializes the given payload.
82+
func (o *SyntheticsGlobalVariableOptions) UnmarshalJSON(bytes []byte) (err error) {
83+
raw := map[string]interface{}{}
84+
all := struct {
85+
TotpParameters *SyntheticsGlobalVariableTOTPParameters `json:"totp_parameters,omitempty"`
86+
}{}
87+
err = json.Unmarshal(bytes, &all)
88+
if err != nil {
89+
err = json.Unmarshal(bytes, &raw)
90+
if err != nil {
91+
return err
92+
}
93+
o.UnparsedObject = raw
94+
return nil
95+
}
96+
if all.TotpParameters != nil && all.TotpParameters.UnparsedObject != nil && o.UnparsedObject == nil {
97+
err = json.Unmarshal(bytes, &raw)
98+
if err != nil {
99+
return err
100+
}
101+
o.UnparsedObject = raw
102+
}
103+
o.TotpParameters = all.TotpParameters
104+
return nil
105+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV1
6+
7+
import (
8+
"encoding/json"
9+
)
10+
11+
// SyntheticsGlobalVariableTOTPParameters Parameters for the TOTP/MFA variable
12+
type SyntheticsGlobalVariableTOTPParameters struct {
13+
// Number of digits for the OTP code.
14+
Digits *int32 `json:"digits,omitempty"`
15+
// Interval for which to refresh the token (in seconds).
16+
RefreshInterval *int32 `json:"refresh_interval,omitempty"`
17+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
18+
UnparsedObject map[string]interface{} `json:"-"`
19+
AdditionalProperties map[string]interface{}
20+
}
21+
22+
// NewSyntheticsGlobalVariableTOTPParameters instantiates a new SyntheticsGlobalVariableTOTPParameters object.
23+
// This constructor will assign default values to properties that have it defined,
24+
// and makes sure properties required by API are set, but the set of arguments
25+
// will change when the set of required properties is changed.
26+
func NewSyntheticsGlobalVariableTOTPParameters() *SyntheticsGlobalVariableTOTPParameters {
27+
this := SyntheticsGlobalVariableTOTPParameters{}
28+
return &this
29+
}
30+
31+
// NewSyntheticsGlobalVariableTOTPParametersWithDefaults instantiates a new SyntheticsGlobalVariableTOTPParameters object.
32+
// This constructor will only assign default values to properties that have it defined,
33+
// but it doesn't guarantee that properties required by API are set.
34+
func NewSyntheticsGlobalVariableTOTPParametersWithDefaults() *SyntheticsGlobalVariableTOTPParameters {
35+
this := SyntheticsGlobalVariableTOTPParameters{}
36+
return &this
37+
}
38+
39+
// GetDigits returns the Digits field value if set, zero value otherwise.
40+
func (o *SyntheticsGlobalVariableTOTPParameters) GetDigits() int32 {
41+
if o == nil || o.Digits == nil {
42+
var ret int32
43+
return ret
44+
}
45+
return *o.Digits
46+
}
47+
48+
// GetDigitsOk returns a tuple with the Digits field value if set, nil otherwise
49+
// and a boolean to check if the value has been set.
50+
func (o *SyntheticsGlobalVariableTOTPParameters) GetDigitsOk() (*int32, bool) {
51+
if o == nil || o.Digits == nil {
52+
return nil, false
53+
}
54+
return o.Digits, true
55+
}
56+
57+
// HasDigits returns a boolean if a field has been set.
58+
func (o *SyntheticsGlobalVariableTOTPParameters) HasDigits() bool {
59+
return o != nil && o.Digits != nil
60+
}
61+
62+
// SetDigits gets a reference to the given int32 and assigns it to the Digits field.
63+
func (o *SyntheticsGlobalVariableTOTPParameters) SetDigits(v int32) {
64+
o.Digits = &v
65+
}
66+
67+
// GetRefreshInterval returns the RefreshInterval field value if set, zero value otherwise.
68+
func (o *SyntheticsGlobalVariableTOTPParameters) GetRefreshInterval() int32 {
69+
if o == nil || o.RefreshInterval == nil {
70+
var ret int32
71+
return ret
72+
}
73+
return *o.RefreshInterval
74+
}
75+
76+
// GetRefreshIntervalOk returns a tuple with the RefreshInterval field value if set, nil otherwise
77+
// and a boolean to check if the value has been set.
78+
func (o *SyntheticsGlobalVariableTOTPParameters) GetRefreshIntervalOk() (*int32, bool) {
79+
if o == nil || o.RefreshInterval == nil {
80+
return nil, false
81+
}
82+
return o.RefreshInterval, true
83+
}
84+
85+
// HasRefreshInterval returns a boolean if a field has been set.
86+
func (o *SyntheticsGlobalVariableTOTPParameters) HasRefreshInterval() bool {
87+
return o != nil && o.RefreshInterval != nil
88+
}
89+
90+
// SetRefreshInterval gets a reference to the given int32 and assigns it to the RefreshInterval field.
91+
func (o *SyntheticsGlobalVariableTOTPParameters) SetRefreshInterval(v int32) {
92+
o.RefreshInterval = &v
93+
}
94+
95+
// MarshalJSON serializes the struct using spec logic.
96+
func (o SyntheticsGlobalVariableTOTPParameters) MarshalJSON() ([]byte, error) {
97+
toSerialize := map[string]interface{}{}
98+
if o.UnparsedObject != nil {
99+
return json.Marshal(o.UnparsedObject)
100+
}
101+
if o.Digits != nil {
102+
toSerialize["digits"] = o.Digits
103+
}
104+
if o.RefreshInterval != nil {
105+
toSerialize["refresh_interval"] = o.RefreshInterval
106+
}
107+
108+
for key, value := range o.AdditionalProperties {
109+
toSerialize[key] = value
110+
}
111+
return json.Marshal(toSerialize)
112+
}
113+
114+
// UnmarshalJSON deserializes the given payload.
115+
func (o *SyntheticsGlobalVariableTOTPParameters) UnmarshalJSON(bytes []byte) (err error) {
116+
raw := map[string]interface{}{}
117+
all := struct {
118+
Digits *int32 `json:"digits,omitempty"`
119+
RefreshInterval *int32 `json:"refresh_interval,omitempty"`
120+
}{}
121+
err = json.Unmarshal(bytes, &all)
122+
if err != nil {
123+
err = json.Unmarshal(bytes, &raw)
124+
if err != nil {
125+
return err
126+
}
127+
o.UnparsedObject = raw
128+
return nil
129+
}
130+
o.Digits = all.Digits
131+
o.RefreshInterval = all.RefreshInterval
132+
return nil
133+
}

api/datadogV1/model_synthetics_global_variable_value.go

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010

1111
// SyntheticsGlobalVariableValue Value of the global variable.
1212
type SyntheticsGlobalVariableValue struct {
13+
// Options for the Global Variable for MFA.
14+
Options *SyntheticsGlobalVariableOptions `json:"options,omitempty"`
1315
// Determines if the value of the variable is hidden.
1416
Secure *bool `json:"secure,omitempty"`
1517
// Value of the global variable. When reading a global variable,
@@ -37,6 +39,34 @@ func NewSyntheticsGlobalVariableValueWithDefaults() *SyntheticsGlobalVariableVal
3739
return &this
3840
}
3941

42+
// GetOptions returns the Options field value if set, zero value otherwise.
43+
func (o *SyntheticsGlobalVariableValue) GetOptions() SyntheticsGlobalVariableOptions {
44+
if o == nil || o.Options == nil {
45+
var ret SyntheticsGlobalVariableOptions
46+
return ret
47+
}
48+
return *o.Options
49+
}
50+
51+
// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise
52+
// and a boolean to check if the value has been set.
53+
func (o *SyntheticsGlobalVariableValue) GetOptionsOk() (*SyntheticsGlobalVariableOptions, bool) {
54+
if o == nil || o.Options == nil {
55+
return nil, false
56+
}
57+
return o.Options, true
58+
}
59+
60+
// HasOptions returns a boolean if a field has been set.
61+
func (o *SyntheticsGlobalVariableValue) HasOptions() bool {
62+
return o != nil && o.Options != nil
63+
}
64+
65+
// SetOptions gets a reference to the given SyntheticsGlobalVariableOptions and assigns it to the Options field.
66+
func (o *SyntheticsGlobalVariableValue) SetOptions(v SyntheticsGlobalVariableOptions) {
67+
o.Options = &v
68+
}
69+
4070
// GetSecure returns the Secure field value if set, zero value otherwise.
4171
func (o *SyntheticsGlobalVariableValue) GetSecure() bool {
4272
if o == nil || o.Secure == nil {
@@ -99,6 +129,9 @@ func (o SyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) {
99129
if o.UnparsedObject != nil {
100130
return json.Marshal(o.UnparsedObject)
101131
}
132+
if o.Options != nil {
133+
toSerialize["options"] = o.Options
134+
}
102135
if o.Secure != nil {
103136
toSerialize["secure"] = o.Secure
104137
}
@@ -116,8 +149,9 @@ func (o SyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) {
116149
func (o *SyntheticsGlobalVariableValue) UnmarshalJSON(bytes []byte) (err error) {
117150
raw := map[string]interface{}{}
118151
all := struct {
119-
Secure *bool `json:"secure,omitempty"`
120-
Value *string `json:"value,omitempty"`
152+
Options *SyntheticsGlobalVariableOptions `json:"options,omitempty"`
153+
Secure *bool `json:"secure,omitempty"`
154+
Value *string `json:"value,omitempty"`
121155
}{}
122156
err = json.Unmarshal(bytes, &all)
123157
if err != nil {
@@ -128,6 +162,14 @@ func (o *SyntheticsGlobalVariableValue) UnmarshalJSON(bytes []byte) (err error)
128162
o.UnparsedObject = raw
129163
return nil
130164
}
165+
if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil {
166+
err = json.Unmarshal(bytes, &raw)
167+
if err != nil {
168+
return err
169+
}
170+
o.UnparsedObject = raw
171+
}
172+
o.Options = all.Options
131173
o.Secure = all.Secure
132174
o.Value = all.Value
133175
return nil

examples/v1/synthetics/CreateGlobalVariable_1068962881.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ func main() {
2323
Value: datadogV1.SyntheticsGlobalVariableValue{
2424
Secure: datadog.PtrBool(false),
2525
Value: datadog.PtrString(""),
26+
Options: &datadogV1.SyntheticsGlobalVariableOptions{
27+
TotpParameters: &datadogV1.SyntheticsGlobalVariableTOTPParameters{
28+
Digits: datadog.PtrInt32(6),
29+
RefreshInterval: datadog.PtrInt32(30),
30+
},
31+
},
2632
},
2733
ParseTestPublicId: datadog.PtrString(SyntheticsAPITestMultiStepPublicID),
2834
ParseTestOptions: &datadogV1.SyntheticsGlobalVariableParseTestOptions{

0 commit comments

Comments
 (0)