-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the synthetics request port field into a oneOf (#2678)
* update formatter to stop matching templated strings in int schemas * Regenerate client from commit 3288a6f0 of spec repo --------- Co-authored-by: Kevin Zou <kevin.zou@datadoghq.com> Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
- Loading branch information
1 parent
d118537
commit 92128b1
Showing
28 changed files
with
220 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( | ||
"github.com/DataDog/datadog-api-client-go/v2/api/datadog" | ||
) | ||
|
||
// SyntheticsTestRequestPort - Port to use when performing the test. | ||
type SyntheticsTestRequestPort struct { | ||
SyntheticsTestRequestNumericalPort *int64 | ||
SyntheticsTestRequestVariablePort *string | ||
|
||
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct | ||
UnparsedObject interface{} | ||
} | ||
|
||
// SyntheticsTestRequestNumericalPortAsSyntheticsTestRequestPort is a convenience function that returns int64 wrapped in SyntheticsTestRequestPort. | ||
func SyntheticsTestRequestNumericalPortAsSyntheticsTestRequestPort(v *int64) SyntheticsTestRequestPort { | ||
return SyntheticsTestRequestPort{SyntheticsTestRequestNumericalPort: v} | ||
} | ||
|
||
// SyntheticsTestRequestVariablePortAsSyntheticsTestRequestPort is a convenience function that returns string wrapped in SyntheticsTestRequestPort. | ||
func SyntheticsTestRequestVariablePortAsSyntheticsTestRequestPort(v *string) SyntheticsTestRequestPort { | ||
return SyntheticsTestRequestPort{SyntheticsTestRequestVariablePort: v} | ||
} | ||
|
||
// UnmarshalJSON turns data into one of the pointers in the struct. | ||
func (obj *SyntheticsTestRequestPort) UnmarshalJSON(data []byte) error { | ||
var err error | ||
match := 0 | ||
// try to unmarshal data into SyntheticsTestRequestNumericalPort | ||
err = datadog.Unmarshal(data, &obj.SyntheticsTestRequestNumericalPort) | ||
if err == nil { | ||
if obj.SyntheticsTestRequestNumericalPort != nil { | ||
jsonSyntheticsTestRequestNumericalPort, _ := datadog.Marshal(obj.SyntheticsTestRequestNumericalPort) | ||
if string(jsonSyntheticsTestRequestNumericalPort) == "{}" { // empty struct | ||
obj.SyntheticsTestRequestNumericalPort = nil | ||
} else { | ||
match++ | ||
} | ||
} else { | ||
obj.SyntheticsTestRequestNumericalPort = nil | ||
} | ||
} else { | ||
obj.SyntheticsTestRequestNumericalPort = nil | ||
} | ||
|
||
// try to unmarshal data into SyntheticsTestRequestVariablePort | ||
err = datadog.Unmarshal(data, &obj.SyntheticsTestRequestVariablePort) | ||
if err == nil { | ||
if obj.SyntheticsTestRequestVariablePort != nil { | ||
jsonSyntheticsTestRequestVariablePort, _ := datadog.Marshal(obj.SyntheticsTestRequestVariablePort) | ||
if string(jsonSyntheticsTestRequestVariablePort) == "{}" { // empty struct | ||
obj.SyntheticsTestRequestVariablePort = nil | ||
} else { | ||
match++ | ||
} | ||
} else { | ||
obj.SyntheticsTestRequestVariablePort = nil | ||
} | ||
} else { | ||
obj.SyntheticsTestRequestVariablePort = nil | ||
} | ||
|
||
if match != 1 { // more than 1 match | ||
// reset to nil | ||
obj.SyntheticsTestRequestNumericalPort = nil | ||
obj.SyntheticsTestRequestVariablePort = nil | ||
return datadog.Unmarshal(data, &obj.UnparsedObject) | ||
} | ||
return nil // exactly one match | ||
} | ||
|
||
// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. | ||
func (obj SyntheticsTestRequestPort) MarshalJSON() ([]byte, error) { | ||
if obj.SyntheticsTestRequestNumericalPort != nil { | ||
return datadog.Marshal(&obj.SyntheticsTestRequestNumericalPort) | ||
} | ||
|
||
if obj.SyntheticsTestRequestVariablePort != nil { | ||
return datadog.Marshal(&obj.SyntheticsTestRequestVariablePort) | ||
} | ||
|
||
if obj.UnparsedObject != nil { | ||
return datadog.Marshal(obj.UnparsedObject) | ||
} | ||
return nil, nil // no data in oneOf schemas | ||
} | ||
|
||
// GetActualInstance returns the actual instance. | ||
func (obj *SyntheticsTestRequestPort) GetActualInstance() interface{} { | ||
if obj.SyntheticsTestRequestNumericalPort != nil { | ||
return obj.SyntheticsTestRequestNumericalPort | ||
} | ||
|
||
if obj.SyntheticsTestRequestVariablePort != nil { | ||
return obj.SyntheticsTestRequestVariablePort | ||
} | ||
|
||
// all schemas are nil | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/v1/Feature_Synthetics/Scenario_Create_a_FIDO_global_variable_returns_OK_response.freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2024-08-21T13:17:18.467Z | ||
2024-09-10T20:52:06.237Z |
Oops, something went wrong.