@@ -10,8 +10,9 @@ import (
1010
1111// SyntheticsAPIStep - The steps used in a Synthetic multi-step API test.
1212type SyntheticsAPIStep struct {
13- SyntheticsAPITestStep * SyntheticsAPITestStep
14- SyntheticsAPIWaitStep * SyntheticsAPIWaitStep
13+ SyntheticsAPITestStep * SyntheticsAPITestStep
14+ SyntheticsAPIWaitStep * SyntheticsAPIWaitStep
15+ SyntheticsAPISubtestStep * SyntheticsAPISubtestStep
1516
1617 // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
1718 UnparsedObject interface {}
@@ -27,6 +28,11 @@ func SyntheticsAPIWaitStepAsSyntheticsAPIStep(v *SyntheticsAPIWaitStep) Syntheti
2728 return SyntheticsAPIStep {SyntheticsAPIWaitStep : v }
2829}
2930
31+ // SyntheticsAPISubtestStepAsSyntheticsAPIStep is a convenience function that returns SyntheticsAPISubtestStep wrapped in SyntheticsAPIStep.
32+ func SyntheticsAPISubtestStepAsSyntheticsAPIStep (v * SyntheticsAPISubtestStep ) SyntheticsAPIStep {
33+ return SyntheticsAPIStep {SyntheticsAPISubtestStep : v }
34+ }
35+
3036// UnmarshalJSON turns data into one of the pointers in the struct.
3137func (obj * SyntheticsAPIStep ) UnmarshalJSON (data []byte ) error {
3238 var err error
@@ -65,10 +71,28 @@ func (obj *SyntheticsAPIStep) UnmarshalJSON(data []byte) error {
6571 obj .SyntheticsAPIWaitStep = nil
6672 }
6773
74+ // try to unmarshal data into SyntheticsAPISubtestStep
75+ err = datadog .Unmarshal (data , & obj .SyntheticsAPISubtestStep )
76+ if err == nil {
77+ if obj .SyntheticsAPISubtestStep != nil && obj .SyntheticsAPISubtestStep .UnparsedObject == nil {
78+ jsonSyntheticsAPISubtestStep , _ := datadog .Marshal (obj .SyntheticsAPISubtestStep )
79+ if string (jsonSyntheticsAPISubtestStep ) == "{}" { // empty struct
80+ obj .SyntheticsAPISubtestStep = nil
81+ } else {
82+ match ++
83+ }
84+ } else {
85+ obj .SyntheticsAPISubtestStep = nil
86+ }
87+ } else {
88+ obj .SyntheticsAPISubtestStep = nil
89+ }
90+
6891 if match != 1 { // more than 1 match
6992 // reset to nil
7093 obj .SyntheticsAPITestStep = nil
7194 obj .SyntheticsAPIWaitStep = nil
95+ obj .SyntheticsAPISubtestStep = nil
7296 return datadog .Unmarshal (data , & obj .UnparsedObject )
7397 }
7498 return nil // exactly one match
@@ -84,6 +108,10 @@ func (obj SyntheticsAPIStep) MarshalJSON() ([]byte, error) {
84108 return datadog .Marshal (& obj .SyntheticsAPIWaitStep )
85109 }
86110
111+ if obj .SyntheticsAPISubtestStep != nil {
112+ return datadog .Marshal (& obj .SyntheticsAPISubtestStep )
113+ }
114+
87115 if obj .UnparsedObject != nil {
88116 return datadog .Marshal (obj .UnparsedObject )
89117 }
@@ -100,6 +128,10 @@ func (obj *SyntheticsAPIStep) GetActualInstance() interface{} {
100128 return obj .SyntheticsAPIWaitStep
101129 }
102130
131+ if obj .SyntheticsAPISubtestStep != nil {
132+ return obj .SyntheticsAPISubtestStep
133+ }
134+
103135 // all schemas are nil
104136 return nil
105137}
0 commit comments