-
Notifications
You must be signed in to change notification settings - Fork 728
Expand file tree
/
Copy pathmonitor.go
More file actions
767 lines (691 loc) · 29 KB
/
monitor.go
File metadata and controls
767 lines (691 loc) · 29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package load_balancers
import (
"context"
"errors"
"fmt"
"net/http"
"slices"
"github.com/cloudflare/cloudflare-go/v6/internal/apijson"
"github.com/cloudflare/cloudflare-go/v6/internal/param"
"github.com/cloudflare/cloudflare-go/v6/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v6/option"
"github.com/cloudflare/cloudflare-go/v6/packages/pagination"
"github.com/cloudflare/cloudflare-go/v6/shared"
)
// MonitorService contains methods and other services that help with interacting
// with the cloudflare API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewMonitorService] method instead.
type MonitorService struct {
Options []option.RequestOption
Previews *MonitorPreviewService
References *MonitorReferenceService
}
// NewMonitorService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewMonitorService(opts ...option.RequestOption) (r *MonitorService) {
r = &MonitorService{}
r.Options = opts
r.Previews = NewMonitorPreviewService(opts...)
r.References = NewMonitorReferenceService(opts...)
return
}
// Create a configured monitor.
func (r *MonitorService) New(ctx context.Context, params MonitorNewParams, opts ...option.RequestOption) (res *Monitor, err error) {
var env MonitorNewResponseEnvelope
opts = slices.Concat(r.Options, opts)
if params.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/load_balancers/monitors", params.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Modify a configured monitor.
func (r *MonitorService) Update(ctx context.Context, monitorID string, params MonitorUpdateParams, opts ...option.RequestOption) (res *Monitor, err error) {
var env MonitorUpdateResponseEnvelope
opts = slices.Concat(r.Options, opts)
if params.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
if monitorID == "" {
err = errors.New("missing required monitor_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// List configured monitors for an account.
func (r *MonitorService) List(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Monitor], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if query.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/load_balancers/monitors", query.AccountID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List configured monitors for an account.
func (r *MonitorService) ListAutoPaging(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Monitor] {
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
}
// Delete a configured monitor.
func (r *MonitorService) Delete(ctx context.Context, monitorID string, body MonitorDeleteParams, opts ...option.RequestOption) (res *MonitorDeleteResponse, err error) {
var env MonitorDeleteResponseEnvelope
opts = slices.Concat(r.Options, opts)
if body.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
if monitorID == "" {
err = errors.New("missing required monitor_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", body.AccountID, monitorID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Apply changes to an existing monitor, overwriting the supplied properties.
func (r *MonitorService) Edit(ctx context.Context, monitorID string, params MonitorEditParams, opts ...option.RequestOption) (res *Monitor, err error) {
var env MonitorEditResponseEnvelope
opts = slices.Concat(r.Options, opts)
if params.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
if monitorID == "" {
err = errors.New("missing required monitor_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// List a single configured monitor for an account.
func (r *MonitorService) Get(ctx context.Context, monitorID string, query MonitorGetParams, opts ...option.RequestOption) (res *Monitor, err error) {
var env MonitorGetResponseEnvelope
opts = slices.Concat(r.Options, opts)
if query.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
if monitorID == "" {
err = errors.New("missing required monitor_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", query.AccountID, monitorID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
type Monitor struct {
ID string `json:"id"`
// Do not validate the certificate when monitor use HTTPS. This parameter is
// currently only valid for HTTP and HTTPS monitors.
AllowInsecure bool `json:"allow_insecure"`
// To be marked unhealthy the monitored origin must fail this healthcheck N
// consecutive times.
ConsecutiveDown int64 `json:"consecutive_down"`
// To be marked healthy the monitored origin must pass this healthcheck N
// consecutive times.
ConsecutiveUp int64 `json:"consecutive_up"`
CreatedOn string `json:"created_on"`
// Object description.
Description string `json:"description"`
// A case-insensitive sub-string to look for in the response body. If this string
// is not found, the origin will be marked as unhealthy. This parameter is only
// valid for HTTP and HTTPS monitors.
ExpectedBody string `json:"expected_body"`
// The expected HTTP response code or code range of the health check. This
// parameter is only valid for HTTP and HTTPS monitors.
ExpectedCodes string `json:"expected_codes"`
// Follow redirects if returned by the origin. This parameter is only valid for
// HTTP and HTTPS monitors.
FollowRedirects bool `json:"follow_redirects"`
// The HTTP request headers to send in the health check. It is recommended you set
// a Host header by default. The User-Agent header cannot be overridden. This
// parameter is only valid for HTTP and HTTPS monitors.
Header map[string][]string `json:"header"`
// The interval between each health check. Shorter intervals may improve failover
// time, but will increase load on the origins as we check from multiple locations.
Interval int64 `json:"interval"`
// The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS
// based checks and 'connection_established' for TCP based health checks.
Method string `json:"method"`
ModifiedOn string `json:"modified_on"`
// The endpoint path you want to conduct a health check against. This parameter is
// only valid for HTTP and HTTPS monitors.
Path string `json:"path"`
// The port number to connect to for the health check. Required for TCP, UDP, and
// SMTP checks. HTTP and HTTPS checks should only define the port when using a
// non-standard port (HTTP: default 80, HTTPS: default 443).
Port int64 `json:"port,nullable"`
// Assign this monitor to emulate the specified zone while probing. This parameter
// is only valid for HTTP and HTTPS monitors.
ProbeZone string `json:"probe_zone"`
// The number of retries to attempt in case of a timeout before marking the origin
// as unhealthy. Retries are attempted immediately.
Retries int64 `json:"retries"`
// The timeout (in seconds) before marking the health check as failed.
Timeout int64 `json:"timeout"`
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
Type MonitorType `json:"type"`
JSON monitorJSON `json:"-"`
}
// monitorJSON contains the JSON metadata for the struct [Monitor]
type monitorJSON struct {
ID apijson.Field
AllowInsecure apijson.Field
ConsecutiveDown apijson.Field
ConsecutiveUp apijson.Field
CreatedOn apijson.Field
Description apijson.Field
ExpectedBody apijson.Field
ExpectedCodes apijson.Field
FollowRedirects apijson.Field
Header apijson.Field
Interval apijson.Field
Method apijson.Field
ModifiedOn apijson.Field
Path apijson.Field
Port apijson.Field
ProbeZone apijson.Field
Retries apijson.Field
Timeout apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Monitor) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorJSON) RawJSON() string {
return r.raw
}
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
type MonitorType string
const (
MonitorTypeHTTP MonitorType = "http"
MonitorTypeHTTPS MonitorType = "https"
MonitorTypeTCP MonitorType = "tcp"
MonitorTypeUdpIcmp MonitorType = "udp_icmp"
MonitorTypeIcmpPing MonitorType = "icmp_ping"
MonitorTypeSmtp MonitorType = "smtp"
)
func (r MonitorType) IsKnown() bool {
switch r {
case MonitorTypeHTTP, MonitorTypeHTTPS, MonitorTypeTCP, MonitorTypeUdpIcmp, MonitorTypeIcmpPing, MonitorTypeSmtp:
return true
}
return false
}
type MonitorDeleteResponse struct {
ID string `json:"id"`
JSON monitorDeleteResponseJSON `json:"-"`
}
// monitorDeleteResponseJSON contains the JSON metadata for the struct
// [MonitorDeleteResponse]
type monitorDeleteResponseJSON struct {
ID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorDeleteResponseJSON) RawJSON() string {
return r.raw
}
type MonitorNewParams struct {
// Identifier.
AccountID param.Field[string] `path:"account_id,required"`
// Do not validate the certificate when monitor use HTTPS. This parameter is
// currently only valid for HTTP and HTTPS monitors.
AllowInsecure param.Field[bool] `json:"allow_insecure"`
// To be marked unhealthy the monitored origin must fail this healthcheck N
// consecutive times.
ConsecutiveDown param.Field[int64] `json:"consecutive_down"`
// To be marked healthy the monitored origin must pass this healthcheck N
// consecutive times.
ConsecutiveUp param.Field[int64] `json:"consecutive_up"`
// Object description.
Description param.Field[string] `json:"description"`
// A case-insensitive sub-string to look for in the response body. If this string
// is not found, the origin will be marked as unhealthy. This parameter is only
// valid for HTTP and HTTPS monitors.
ExpectedBody param.Field[string] `json:"expected_body"`
// The expected HTTP response code or code range of the health check. This
// parameter is only valid for HTTP and HTTPS monitors.
ExpectedCodes param.Field[string] `json:"expected_codes"`
// Follow redirects if returned by the origin. This parameter is only valid for
// HTTP and HTTPS monitors.
FollowRedirects param.Field[bool] `json:"follow_redirects"`
// The HTTP request headers to send in the health check. It is recommended you set
// a Host header by default. The User-Agent header cannot be overridden. This
// parameter is only valid for HTTP and HTTPS monitors.
Header param.Field[map[string][]string] `json:"header"`
// The interval between each health check. Shorter intervals may improve failover
// time, but will increase load on the origins as we check from multiple locations.
Interval param.Field[int64] `json:"interval"`
// The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS
// based checks and 'connection_established' for TCP based health checks.
Method param.Field[string] `json:"method"`
// The endpoint path you want to conduct a health check against. This parameter is
// only valid for HTTP and HTTPS monitors.
Path param.Field[string] `json:"path"`
// The port number to connect to for the health check. Required for TCP, UDP, and
// SMTP checks. HTTP and HTTPS checks should only define the port when using a
// non-standard port (HTTP: default 80, HTTPS: default 443).
Port param.Field[int64] `json:"port"`
// Assign this monitor to emulate the specified zone while probing. This parameter
// is only valid for HTTP and HTTPS monitors.
ProbeZone param.Field[string] `json:"probe_zone"`
// The number of retries to attempt in case of a timeout before marking the origin
// as unhealthy. Retries are attempted immediately.
Retries param.Field[int64] `json:"retries"`
// The timeout (in seconds) before marking the health check as failed.
Timeout param.Field[int64] `json:"timeout"`
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
Type param.Field[MonitorNewParamsType] `json:"type"`
}
func (r MonitorNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
type MonitorNewParamsType string
const (
MonitorNewParamsTypeHTTP MonitorNewParamsType = "http"
MonitorNewParamsTypeHTTPS MonitorNewParamsType = "https"
MonitorNewParamsTypeTCP MonitorNewParamsType = "tcp"
MonitorNewParamsTypeUdpIcmp MonitorNewParamsType = "udp_icmp"
MonitorNewParamsTypeIcmpPing MonitorNewParamsType = "icmp_ping"
MonitorNewParamsTypeSmtp MonitorNewParamsType = "smtp"
)
func (r MonitorNewParamsType) IsKnown() bool {
switch r {
case MonitorNewParamsTypeHTTP, MonitorNewParamsTypeHTTPS, MonitorNewParamsTypeTCP, MonitorNewParamsTypeUdpIcmp, MonitorNewParamsTypeIcmpPing, MonitorNewParamsTypeSmtp:
return true
}
return false
}
type MonitorNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Monitor `json:"result,required"`
// Whether the API call was successful.
Success MonitorNewResponseEnvelopeSuccess `json:"success,required"`
JSON monitorNewResponseEnvelopeJSON `json:"-"`
}
// monitorNewResponseEnvelopeJSON contains the JSON metadata for the struct
// [MonitorNewResponseEnvelope]
type monitorNewResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorNewResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful.
type MonitorNewResponseEnvelopeSuccess bool
const (
MonitorNewResponseEnvelopeSuccessTrue MonitorNewResponseEnvelopeSuccess = true
)
func (r MonitorNewResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case MonitorNewResponseEnvelopeSuccessTrue:
return true
}
return false
}
type MonitorUpdateParams struct {
// Identifier.
AccountID param.Field[string] `path:"account_id,required"`
// Do not validate the certificate when monitor use HTTPS. This parameter is
// currently only valid for HTTP and HTTPS monitors.
AllowInsecure param.Field[bool] `json:"allow_insecure"`
// To be marked unhealthy the monitored origin must fail this healthcheck N
// consecutive times.
ConsecutiveDown param.Field[int64] `json:"consecutive_down"`
// To be marked healthy the monitored origin must pass this healthcheck N
// consecutive times.
ConsecutiveUp param.Field[int64] `json:"consecutive_up"`
// Object description.
Description param.Field[string] `json:"description"`
// A case-insensitive sub-string to look for in the response body. If this string
// is not found, the origin will be marked as unhealthy. This parameter is only
// valid for HTTP and HTTPS monitors.
ExpectedBody param.Field[string] `json:"expected_body"`
// The expected HTTP response code or code range of the health check. This
// parameter is only valid for HTTP and HTTPS monitors.
ExpectedCodes param.Field[string] `json:"expected_codes"`
// Follow redirects if returned by the origin. This parameter is only valid for
// HTTP and HTTPS monitors.
FollowRedirects param.Field[bool] `json:"follow_redirects"`
// The HTTP request headers to send in the health check. It is recommended you set
// a Host header by default. The User-Agent header cannot be overridden. This
// parameter is only valid for HTTP and HTTPS monitors.
Header param.Field[map[string][]string] `json:"header"`
// The interval between each health check. Shorter intervals may improve failover
// time, but will increase load on the origins as we check from multiple locations.
Interval param.Field[int64] `json:"interval"`
// The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS
// based checks and 'connection_established' for TCP based health checks.
Method param.Field[string] `json:"method"`
// The endpoint path you want to conduct a health check against. This parameter is
// only valid for HTTP and HTTPS monitors.
Path param.Field[string] `json:"path"`
// The port number to connect to for the health check. Required for TCP, UDP, and
// SMTP checks. HTTP and HTTPS checks should only define the port when using a
// non-standard port (HTTP: default 80, HTTPS: default 443).
Port param.Field[int64] `json:"port"`
// Assign this monitor to emulate the specified zone while probing. This parameter
// is only valid for HTTP and HTTPS monitors.
ProbeZone param.Field[string] `json:"probe_zone"`
// The number of retries to attempt in case of a timeout before marking the origin
// as unhealthy. Retries are attempted immediately.
Retries param.Field[int64] `json:"retries"`
// The timeout (in seconds) before marking the health check as failed.
Timeout param.Field[int64] `json:"timeout"`
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
Type param.Field[MonitorUpdateParamsType] `json:"type"`
}
func (r MonitorUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
type MonitorUpdateParamsType string
const (
MonitorUpdateParamsTypeHTTP MonitorUpdateParamsType = "http"
MonitorUpdateParamsTypeHTTPS MonitorUpdateParamsType = "https"
MonitorUpdateParamsTypeTCP MonitorUpdateParamsType = "tcp"
MonitorUpdateParamsTypeUdpIcmp MonitorUpdateParamsType = "udp_icmp"
MonitorUpdateParamsTypeIcmpPing MonitorUpdateParamsType = "icmp_ping"
MonitorUpdateParamsTypeSmtp MonitorUpdateParamsType = "smtp"
)
func (r MonitorUpdateParamsType) IsKnown() bool {
switch r {
case MonitorUpdateParamsTypeHTTP, MonitorUpdateParamsTypeHTTPS, MonitorUpdateParamsTypeTCP, MonitorUpdateParamsTypeUdpIcmp, MonitorUpdateParamsTypeIcmpPing, MonitorUpdateParamsTypeSmtp:
return true
}
return false
}
type MonitorUpdateResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Monitor `json:"result,required"`
// Whether the API call was successful.
Success MonitorUpdateResponseEnvelopeSuccess `json:"success,required"`
JSON monitorUpdateResponseEnvelopeJSON `json:"-"`
}
// monitorUpdateResponseEnvelopeJSON contains the JSON metadata for the struct
// [MonitorUpdateResponseEnvelope]
type monitorUpdateResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorUpdateResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful.
type MonitorUpdateResponseEnvelopeSuccess bool
const (
MonitorUpdateResponseEnvelopeSuccessTrue MonitorUpdateResponseEnvelopeSuccess = true
)
func (r MonitorUpdateResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case MonitorUpdateResponseEnvelopeSuccessTrue:
return true
}
return false
}
type MonitorListParams struct {
// Identifier.
AccountID param.Field[string] `path:"account_id,required"`
}
type MonitorDeleteParams struct {
// Identifier.
AccountID param.Field[string] `path:"account_id,required"`
}
type MonitorDeleteResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result MonitorDeleteResponse `json:"result,required"`
// Whether the API call was successful.
Success MonitorDeleteResponseEnvelopeSuccess `json:"success,required"`
JSON monitorDeleteResponseEnvelopeJSON `json:"-"`
}
// monitorDeleteResponseEnvelopeJSON contains the JSON metadata for the struct
// [MonitorDeleteResponseEnvelope]
type monitorDeleteResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorDeleteResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful.
type MonitorDeleteResponseEnvelopeSuccess bool
const (
MonitorDeleteResponseEnvelopeSuccessTrue MonitorDeleteResponseEnvelopeSuccess = true
)
func (r MonitorDeleteResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case MonitorDeleteResponseEnvelopeSuccessTrue:
return true
}
return false
}
type MonitorEditParams struct {
// Identifier.
AccountID param.Field[string] `path:"account_id,required"`
// Do not validate the certificate when monitor use HTTPS. This parameter is
// currently only valid for HTTP and HTTPS monitors.
AllowInsecure param.Field[bool] `json:"allow_insecure"`
// To be marked unhealthy the monitored origin must fail this healthcheck N
// consecutive times.
ConsecutiveDown param.Field[int64] `json:"consecutive_down"`
// To be marked healthy the monitored origin must pass this healthcheck N
// consecutive times.
ConsecutiveUp param.Field[int64] `json:"consecutive_up"`
// Object description.
Description param.Field[string] `json:"description"`
// A case-insensitive sub-string to look for in the response body. If this string
// is not found, the origin will be marked as unhealthy. This parameter is only
// valid for HTTP and HTTPS monitors.
ExpectedBody param.Field[string] `json:"expected_body"`
// The expected HTTP response code or code range of the health check. This
// parameter is only valid for HTTP and HTTPS monitors.
ExpectedCodes param.Field[string] `json:"expected_codes"`
// Follow redirects if returned by the origin. This parameter is only valid for
// HTTP and HTTPS monitors.
FollowRedirects param.Field[bool] `json:"follow_redirects"`
// The HTTP request headers to send in the health check. It is recommended you set
// a Host header by default. The User-Agent header cannot be overridden. This
// parameter is only valid for HTTP and HTTPS monitors.
Header param.Field[map[string][]string] `json:"header"`
// The interval between each health check. Shorter intervals may improve failover
// time, but will increase load on the origins as we check from multiple locations.
Interval param.Field[int64] `json:"interval"`
// The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS
// based checks and 'connection_established' for TCP based health checks.
Method param.Field[string] `json:"method"`
// The endpoint path you want to conduct a health check against. This parameter is
// only valid for HTTP and HTTPS monitors.
Path param.Field[string] `json:"path"`
// The port number to connect to for the health check. Required for TCP, UDP, and
// SMTP checks. HTTP and HTTPS checks should only define the port when using a
// non-standard port (HTTP: default 80, HTTPS: default 443).
Port param.Field[int64] `json:"port"`
// Assign this monitor to emulate the specified zone while probing. This parameter
// is only valid for HTTP and HTTPS monitors.
ProbeZone param.Field[string] `json:"probe_zone"`
// The number of retries to attempt in case of a timeout before marking the origin
// as unhealthy. Retries are attempted immediately.
Retries param.Field[int64] `json:"retries"`
// The timeout (in seconds) before marking the health check as failed.
Timeout param.Field[int64] `json:"timeout"`
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
Type param.Field[MonitorEditParamsType] `json:"type"`
}
func (r MonitorEditParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The protocol to use for the health check. Currently supported protocols are
// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.
type MonitorEditParamsType string
const (
MonitorEditParamsTypeHTTP MonitorEditParamsType = "http"
MonitorEditParamsTypeHTTPS MonitorEditParamsType = "https"
MonitorEditParamsTypeTCP MonitorEditParamsType = "tcp"
MonitorEditParamsTypeUdpIcmp MonitorEditParamsType = "udp_icmp"
MonitorEditParamsTypeIcmpPing MonitorEditParamsType = "icmp_ping"
MonitorEditParamsTypeSmtp MonitorEditParamsType = "smtp"
)
func (r MonitorEditParamsType) IsKnown() bool {
switch r {
case MonitorEditParamsTypeHTTP, MonitorEditParamsTypeHTTPS, MonitorEditParamsTypeTCP, MonitorEditParamsTypeUdpIcmp, MonitorEditParamsTypeIcmpPing, MonitorEditParamsTypeSmtp:
return true
}
return false
}
type MonitorEditResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Monitor `json:"result,required"`
// Whether the API call was successful.
Success MonitorEditResponseEnvelopeSuccess `json:"success,required"`
JSON monitorEditResponseEnvelopeJSON `json:"-"`
}
// monitorEditResponseEnvelopeJSON contains the JSON metadata for the struct
// [MonitorEditResponseEnvelope]
type monitorEditResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorEditResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful.
type MonitorEditResponseEnvelopeSuccess bool
const (
MonitorEditResponseEnvelopeSuccessTrue MonitorEditResponseEnvelopeSuccess = true
)
func (r MonitorEditResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case MonitorEditResponseEnvelopeSuccessTrue:
return true
}
return false
}
type MonitorGetParams struct {
// Identifier.
AccountID param.Field[string] `path:"account_id,required"`
}
type MonitorGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Monitor `json:"result,required"`
// Whether the API call was successful.
Success MonitorGetResponseEnvelopeSuccess `json:"success,required"`
JSON monitorGetResponseEnvelopeJSON `json:"-"`
}
// monitorGetResponseEnvelopeJSON contains the JSON metadata for the struct
// [MonitorGetResponseEnvelope]
type monitorGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r monitorGetResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful.
type MonitorGetResponseEnvelopeSuccess bool
const (
MonitorGetResponseEnvelopeSuccessTrue MonitorGetResponseEnvelopeSuccess = true
)
func (r MonitorGetResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case MonitorGetResponseEnvelopeSuccessTrue:
return true
}
return false
}