Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TOTP parameters to Synthetics test options #1815

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "2023-01-11 09:53:51.620609",
"spec_repo_commit": "c22824fc"
"regenerated": "2023-01-11 12:48:13.442587",
"spec_repo_commit": "c986b09e"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-01-11 09:53:51.635618",
"spec_repo_commit": "c22824fc"
"regenerated": "2023-01-11 12:48:13.454082",
"spec_repo_commit": "c986b09e"
}
}
}
26 changes: 26 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12722,6 +12722,12 @@ components:
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 Synthetics global variable
from a Synthetics Test. Used in conjunction with `parse_test_public_id`.
Expand Down Expand Up @@ -12771,12 +12777,32 @@ components:
- 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
Expand Down
105 changes: 105 additions & 0 deletions api/datadogV1/model_synthetics_global_variable_options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// 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 (
"encoding/json"
)

// 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{}
}

// 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 json.Marshal(o.UnparsedObject)
}
if o.TotpParameters != nil {
toSerialize["totp_parameters"] = o.TotpParameters
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return json.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *SyntheticsGlobalVariableOptions) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
all := struct {
TotpParameters *SyntheticsGlobalVariableTOTPParameters `json:"totp_parameters,omitempty"`
}{}
err = json.Unmarshal(bytes, &all)
if err != nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
if all.TotpParameters != nil && all.TotpParameters.UnparsedObject != nil && o.UnparsedObject == nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
}
o.TotpParameters = all.TotpParameters
return nil
}
133 changes: 133 additions & 0 deletions api/datadogV1/model_synthetics_global_variable_totp_parameters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// 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 (
"encoding/json"
)

// 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{}
}

// 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 json.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 json.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *SyntheticsGlobalVariableTOTPParameters) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
all := struct {
Digits *int32 `json:"digits,omitempty"`
RefreshInterval *int32 `json:"refresh_interval,omitempty"`
}{}
err = json.Unmarshal(bytes, &all)
if err != nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
o.Digits = all.Digits
o.RefreshInterval = all.RefreshInterval
return nil
}
46 changes: 44 additions & 2 deletions api/datadogV1/model_synthetics_global_variable_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

// 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,
Expand Down Expand Up @@ -37,6 +39,34 @@ func NewSyntheticsGlobalVariableValueWithDefaults() *SyntheticsGlobalVariableVal
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 {
Expand Down Expand Up @@ -99,6 +129,9 @@ func (o SyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) {
if o.UnparsedObject != nil {
return json.Marshal(o.UnparsedObject)
}
if o.Options != nil {
toSerialize["options"] = o.Options
}
if o.Secure != nil {
toSerialize["secure"] = o.Secure
}
Expand All @@ -116,8 +149,9 @@ func (o SyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) {
func (o *SyntheticsGlobalVariableValue) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
all := struct {
Secure *bool `json:"secure,omitempty"`
Value *string `json:"value,omitempty"`
Options *SyntheticsGlobalVariableOptions `json:"options,omitempty"`
Secure *bool `json:"secure,omitempty"`
Value *string `json:"value,omitempty"`
}{}
err = json.Unmarshal(bytes, &all)
if err != nil {
Expand All @@ -128,6 +162,14 @@ func (o *SyntheticsGlobalVariableValue) UnmarshalJSON(bytes []byte) (err error)
o.UnparsedObject = raw
return nil
}
if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
}
o.Options = all.Options
o.Secure = all.Secure
o.Value = all.Value
return nil
Expand Down
6 changes: 6 additions & 0 deletions examples/v1/synthetics/CreateGlobalVariable_1068962881.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ func main() {
Value: datadogV1.SyntheticsGlobalVariableValue{
Secure: datadog.PtrBool(false),
Value: datadog.PtrString(""),
Options: &datadogV1.SyntheticsGlobalVariableOptions{
TotpParameters: &datadogV1.SyntheticsGlobalVariableTOTPParameters{
Digits: datadog.PtrInt32(6),
RefreshInterval: datadog.PtrInt32(30),
},
},
},
ParseTestPublicId: datadog.PtrString(SyntheticsAPITestMultiStepPublicID),
ParseTestOptions: &datadogV1.SyntheticsGlobalVariableParseTestOptions{
Expand Down
Loading