Skip to content

Commit 3a9117c

Browse files
Merge pull request #7 from greatestusername/stop-omitting-bools
Fix structs for current reality
2 parents 68a46b1 + e92dc5e commit 3a9117c

File tree

4 files changed

+440
-200
lines changed

4 files changed

+440
-200
lines changed

syntheticsclientv2/common_models.go

+39-33
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ type Networkconnection struct {
2828
}
2929

3030
type Advancedsettings struct {
31-
Authentication `json:"authentication"`
31+
Authentication *Authentication `json:"authentication"`
3232
Cookiesv2 []Cookiesv2 `json:"cookies"`
3333
BrowserHeaders []BrowserHeaders `json:"headers,omitempty"`
3434
HostOverrides []HostOverrides `json:"hostOverrides,omitempty"`
3535
UserAgent string `json:"userAgent,omitempty"`
36-
Verifycertificates bool `json:"verifyCertificates,omitempty"`
36+
Verifycertificates bool `json:"verifyCertificates"`
3737
}
3838

3939
type Authentication struct {
40-
Password string `json:"password"`
41-
Username string `json:"username"`
40+
Password string `json:"password,omitempty"`
41+
Username string `json:"username,omitempty"`
4242
}
4343

4444
type Cookiesv2 struct {
@@ -100,14 +100,14 @@ type Device struct {
100100

101101
type Requests struct {
102102
Configuration `json:"configuration,omitempty"`
103-
Setup []Setup `json:"setup,omitempty"`
104-
Validations []Validations `json:"validations,omitempty"`
103+
Setup []Setup `json:"setup"`
104+
Validations []Validations `json:"validations"`
105105
}
106106

107107
type Configuration struct {
108108
Body string `json:"body"`
109-
Headers `json:"headers,omitempty"`
110-
Name string `json:"name,omitempty"`
109+
Headers `json:"headers"`
110+
Name string `json:"name"`
111111
RequestMethod string `json:"requestMethod,omitempty"`
112112
URL string `json:"url,omitempty"`
113113
}
@@ -260,34 +260,40 @@ type PortCheckV2Input struct {
260260

261261
type HttpCheckV2Response struct {
262262
Test struct {
263-
ID int `json:"id"`
264-
Name string `json:"name"`
265-
Active bool `json:"active"`
266-
Frequency int `json:"frequency"`
267-
SchedulingStrategy string `json:"schedulingStrategy"`
268-
CreatedAt time.Time `json:"createdAt,omitempty"`
269-
UpdatedAt time.Time `json:"updatedAt,omitempty"`
270-
LocationIds []string `json:"locationIds"`
271-
Type string `json:"type"`
272-
URL string `json:"url"`
273-
RequestMethod string `json:"requestMethod"`
274-
Body string `json:"body,omitempty"`
275-
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
263+
ID int `json:"id"`
264+
Name string `json:"name"`
265+
Active bool `json:"active"`
266+
Frequency int `json:"frequency"`
267+
SchedulingStrategy string `json:"schedulingStrategy"`
268+
CreatedAt time.Time `json:"createdAt,omitempty"`
269+
UpdatedAt time.Time `json:"updatedAt,omitempty"`
270+
LocationIds []string `json:"locationIds"`
271+
Type string `json:"type"`
272+
URL string `json:"url"`
273+
RequestMethod string `json:"requestMethod"`
274+
Body string `json:"body,omitempty"`
275+
Authentication *Authentication `json:"authentication"`
276+
UserAgent string `json:"userAgent,omitempty"`
277+
Verifycertificates bool `json:"verifyCertificates"`
278+
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
276279
} `json:"test"`
277280
}
278281

279282
type HttpCheckV2Input struct {
280283
Test struct {
281-
Name string `json:"name"`
282-
Type string `json:"type"`
283-
URL string `json:"url"`
284-
LocationIds []string `json:"locationIds"`
285-
Frequency int `json:"frequency"`
286-
SchedulingStrategy string `json:"schedulingStrategy"`
287-
Active bool `json:"active"`
288-
RequestMethod string `json:"requestMethod"`
289-
Body string `json:"body,omitempty"`
290-
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
284+
Name string `json:"name"`
285+
Type string `json:"type"`
286+
URL string `json:"url"`
287+
LocationIds []string `json:"locationIds"`
288+
Frequency int `json:"frequency"`
289+
SchedulingStrategy string `json:"schedulingStrategy"`
290+
Active bool `json:"active"`
291+
RequestMethod string `json:"requestMethod"`
292+
Body string `json:"body,omitempty"`
293+
Authentication *Authentication `json:"authentication"`
294+
UserAgent string `json:"userAgent,omitempty"`
295+
Verifycertificates bool `json:"verifyCertificates"`
296+
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
291297
} `json:"test"`
292298
}
293299

@@ -305,7 +311,7 @@ type ApiCheckV2Input struct {
305311

306312
type ApiCheckV2Response struct {
307313
Test struct {
308-
Active bool `json:"active,omitempty"`
314+
Active bool `json:"active"`
309315
Createdat time.Time `json:"createdAt"`
310316
Device `json:"device,omitempty"`
311317
Frequency int `json:"frequency,omitempty"`
@@ -330,7 +336,7 @@ type BrowserCheckV2Input struct {
330336
Frequency int `json:"frequency"`
331337
Schedulingstrategy string `json:"schedulingStrategy"`
332338
Active bool `json:"active"`
333-
Advancedsettings `json:"advancedSettings"`
339+
Advancedsettings `json:"advancedSettings,omitempty"`
334340
} `json:"test"`
335341
}
336342

syntheticsclientv2/create_apicheckv2.go

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ func parseCreateApiCheckV2Response(response string) (*ApiCheckV2Response, error)
3232
}
3333

3434
func (c Client) CreateApiCheckV2(ApiCheckV2Details *ApiCheckV2Input) (*ApiCheckV2Response, *RequestDetails, error) {
35+
if ApiCheckV2Details.Test.Requests[0].Setup == nil {
36+
setup := make([]Setup, 0)
37+
ApiCheckV2Details.Test.Requests[0].Setup = setup
38+
}
39+
40+
if ApiCheckV2Details.Test.Requests[0].Validations == nil {
41+
validation := make([]Validations, 0)
42+
ApiCheckV2Details.Test.Requests[0].Validations = validation
43+
}
3544

3645
body, err := json.Marshal(ApiCheckV2Details)
3746
if err != nil {

0 commit comments

Comments
 (0)