/
ratelimit.go
745 lines (641 loc) · 23.6 KB
/
ratelimit.go
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package rate_limits
import (
"context"
"fmt"
"net/http"
"net/url"
"reflect"
"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/apiquery"
"github.com/cloudflare/cloudflare-go/v2/internal/pagination"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/internal/shared"
"github.com/cloudflare/cloudflare-go/v2/option"
"github.com/tidwall/gjson"
)
// RateLimitService 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 [NewRateLimitService] method instead.
type RateLimitService struct {
Options []option.RequestOption
}
// NewRateLimitService 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 NewRateLimitService(opts ...option.RequestOption) (r *RateLimitService) {
r = &RateLimitService{}
r.Options = opts
return
}
// Creates a new rate limit for a zone. Refer to the object definition for a list
// of required attributes.
func (r *RateLimitService) New(ctx context.Context, zoneIdentifier string, body RateLimitNewParams, opts ...option.RequestOption) (res *RateLimitNewResponseUnion, err error) {
opts = append(r.Options[:], opts...)
var env RateLimitNewResponseEnvelope
path := fmt.Sprintf("zones/%s/rate_limits", zoneIdentifier)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Fetches the rate limits for a zone.
func (r *RateLimitService) List(ctx context.Context, zoneIdentifier string, query RateLimitListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RateLimit], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := fmt.Sprintf("zones/%s/rate_limits", zoneIdentifier)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Fetches the rate limits for a zone.
func (r *RateLimitService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RateLimitListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RateLimit] {
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...))
}
// Deletes an existing rate limit.
func (r *RateLimitService) Delete(ctx context.Context, zoneIdentifier string, id string, body RateLimitDeleteParams, opts ...option.RequestOption) (res *RateLimitDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env RateLimitDeleteResponseEnvelope
path := fmt.Sprintf("zones/%s/rate_limits/%s", zoneIdentifier, id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Updates an existing rate limit.
func (r *RateLimitService) Edit(ctx context.Context, zoneIdentifier string, id string, body RateLimitEditParams, opts ...option.RequestOption) (res *RateLimitEditResponseUnion, err error) {
opts = append(r.Options[:], opts...)
var env RateLimitEditResponseEnvelope
path := fmt.Sprintf("zones/%s/rate_limits/%s", zoneIdentifier, id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Fetches the details of a rate limit.
func (r *RateLimitService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *RateLimitGetResponseUnion, err error) {
opts = append(r.Options[:], opts...)
var env RateLimitGetResponseEnvelope
path := fmt.Sprintf("zones/%s/rate_limits/%s", zoneIdentifier, id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// The action to apply to a matched request. The `log` action is only available on
// an Enterprise plan.
type Action string
const (
ActionBlock Action = "block"
ActionChallenge Action = "challenge"
ActionJSChallenge Action = "js_challenge"
ActionManagedChallenge Action = "managed_challenge"
ActionAllow Action = "allow"
ActionLog Action = "log"
ActionBypass Action = "bypass"
)
func (r Action) IsKnown() bool {
switch r {
case ActionBlock, ActionChallenge, ActionJSChallenge, ActionManagedChallenge, ActionAllow, ActionLog, ActionBypass:
return true
}
return false
}
// An HTTP method or `_ALL_` to indicate all methods.
type Methods string
const (
MethodsGet Methods = "GET"
MethodsPost Methods = "POST"
MethodsPut Methods = "PUT"
MethodsDelete Methods = "DELETE"
MethodsPatch Methods = "PATCH"
MethodsHead Methods = "HEAD"
Methods_All Methods = "_ALL_"
)
func (r Methods) IsKnown() bool {
switch r {
case MethodsGet, MethodsPost, MethodsPut, MethodsDelete, MethodsPatch, MethodsHead, Methods_All:
return true
}
return false
}
type RateLimit struct {
// The unique identifier of the rate limit.
ID string `json:"id"`
// The action to perform when the threshold of matched traffic within the
// configured period is exceeded.
Action RateLimitAction `json:"action"`
// Criteria specifying when the current rate limit should be bypassed. You can
// specify that the rate limit should not apply to one or more URLs.
Bypass []RateLimitBypass `json:"bypass"`
// An informative summary of the rate limit. This value is sanitized and any tags
// will be removed.
Description string `json:"description"`
// When true, indicates that the rate limit is currently disabled.
Disabled bool `json:"disabled"`
// Determines which traffic the rate limit counts towards the threshold.
Match RateLimitMatch `json:"match"`
// The time in seconds (an integer value) to count matching traffic. If the count
// exceeds the configured threshold within this period, Cloudflare will perform the
// configured action.
Period float64 `json:"period"`
// The threshold that will trigger the configured mitigation action. Configure this
// value along with the `period` property to establish a threshold per period.
Threshold float64 `json:"threshold"`
JSON rateLimitJSON `json:"-"`
}
// rateLimitJSON contains the JSON metadata for the struct [RateLimit]
type rateLimitJSON struct {
ID apijson.Field
Action apijson.Field
Bypass apijson.Field
Description apijson.Field
Disabled apijson.Field
Match apijson.Field
Period apijson.Field
Threshold apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimit) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitJSON) RawJSON() string {
return r.raw
}
// The action to perform when the threshold of matched traffic within the
// configured period is exceeded.
type RateLimitAction struct {
// The action to perform.
Mode RateLimitActionMode `json:"mode"`
// A custom content type and reponse to return when the threshold is exceeded. The
// custom response configured in this object will override the custom error for the
// zone. This object is optional. Notes: If you omit this object, Cloudflare will
// use the default HTML error page. If "mode" is "challenge", "managed_challenge",
// or "js_challenge", Cloudflare will use the zone challenge pages and you should
// not provide the "response" object.
Response RateLimitActionResponse `json:"response"`
// The time in seconds during which Cloudflare will perform the mitigation action.
// Must be an integer value greater than or equal to the period. Notes: If "mode"
// is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the
// zone's Challenge Passage time and you should not provide this value.
Timeout float64 `json:"timeout"`
JSON rateLimitActionJSON `json:"-"`
}
// rateLimitActionJSON contains the JSON metadata for the struct [RateLimitAction]
type rateLimitActionJSON struct {
Mode apijson.Field
Response apijson.Field
Timeout apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitAction) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitActionJSON) RawJSON() string {
return r.raw
}
// The action to perform.
type RateLimitActionMode string
const (
RateLimitActionModeSimulate RateLimitActionMode = "simulate"
RateLimitActionModeBan RateLimitActionMode = "ban"
RateLimitActionModeChallenge RateLimitActionMode = "challenge"
RateLimitActionModeJSChallenge RateLimitActionMode = "js_challenge"
RateLimitActionModeManagedChallenge RateLimitActionMode = "managed_challenge"
)
func (r RateLimitActionMode) IsKnown() bool {
switch r {
case RateLimitActionModeSimulate, RateLimitActionModeBan, RateLimitActionModeChallenge, RateLimitActionModeJSChallenge, RateLimitActionModeManagedChallenge:
return true
}
return false
}
// A custom content type and reponse to return when the threshold is exceeded. The
// custom response configured in this object will override the custom error for the
// zone. This object is optional. Notes: If you omit this object, Cloudflare will
// use the default HTML error page. If "mode" is "challenge", "managed_challenge",
// or "js_challenge", Cloudflare will use the zone challenge pages and you should
// not provide the "response" object.
type RateLimitActionResponse struct {
// The response body to return. The value must conform to the configured content
// type.
Body string `json:"body"`
// The content type of the body. Must be one of the following: `text/plain`,
// `text/xml`, or `application/json`.
ContentType string `json:"content_type"`
JSON rateLimitActionResponseJSON `json:"-"`
}
// rateLimitActionResponseJSON contains the JSON metadata for the struct
// [RateLimitActionResponse]
type rateLimitActionResponseJSON struct {
Body apijson.Field
ContentType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitActionResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitActionResponseJSON) RawJSON() string {
return r.raw
}
type RateLimitBypass struct {
Name RateLimitBypassName `json:"name"`
// The URL to bypass.
Value string `json:"value"`
JSON rateLimitBypassJSON `json:"-"`
}
// rateLimitBypassJSON contains the JSON metadata for the struct [RateLimitBypass]
type rateLimitBypassJSON struct {
Name apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitBypass) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitBypassJSON) RawJSON() string {
return r.raw
}
type RateLimitBypassName string
const (
RateLimitBypassNameURL RateLimitBypassName = "url"
)
func (r RateLimitBypassName) IsKnown() bool {
switch r {
case RateLimitBypassNameURL:
return true
}
return false
}
// Determines which traffic the rate limit counts towards the threshold.
type RateLimitMatch struct {
Headers []RateLimitMatchHeader `json:"headers"`
Request RateLimitMatchRequest `json:"request"`
Response RateLimitMatchResponse `json:"response"`
JSON rateLimitMatchJSON `json:"-"`
}
// rateLimitMatchJSON contains the JSON metadata for the struct [RateLimitMatch]
type rateLimitMatchJSON struct {
Headers apijson.Field
Request apijson.Field
Response apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitMatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitMatchJSON) RawJSON() string {
return r.raw
}
type RateLimitMatchHeader struct {
// The name of the response header to match.
Name string `json:"name"`
// The operator used when matching: `eq` means "equal" and `ne` means "not equal".
Op RateLimitMatchHeadersOp `json:"op"`
// The value of the response header, which must match exactly.
Value string `json:"value"`
JSON rateLimitMatchHeaderJSON `json:"-"`
}
// rateLimitMatchHeaderJSON contains the JSON metadata for the struct
// [RateLimitMatchHeader]
type rateLimitMatchHeaderJSON struct {
Name apijson.Field
Op apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitMatchHeader) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitMatchHeaderJSON) RawJSON() string {
return r.raw
}
// The operator used when matching: `eq` means "equal" and `ne` means "not equal".
type RateLimitMatchHeadersOp string
const (
RateLimitMatchHeadersOpEq RateLimitMatchHeadersOp = "eq"
RateLimitMatchHeadersOpNe RateLimitMatchHeadersOp = "ne"
)
func (r RateLimitMatchHeadersOp) IsKnown() bool {
switch r {
case RateLimitMatchHeadersOpEq, RateLimitMatchHeadersOpNe:
return true
}
return false
}
type RateLimitMatchRequest struct {
// The HTTP methods to match. You can specify a subset (for example,
// `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when
// creating a rate limit.
Methods []Methods `json:"methods"`
// The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both
// schemes (`['HTTP','HTTPS']`), or all schemes (`['_ALL_']`). This field is
// optional.
Schemes []string `json:"schemes"`
// The URL pattern to match, composed of a host and a path such as
// `example.org/path*`. Normalization is applied before the pattern is matched. `*`
// wildcards are expanded to match applicable traffic. Query strings are not
// matched. Set the value to `*` to match all traffic to your zone.
URL string `json:"url"`
JSON rateLimitMatchRequestJSON `json:"-"`
}
// rateLimitMatchRequestJSON contains the JSON metadata for the struct
// [RateLimitMatchRequest]
type rateLimitMatchRequestJSON struct {
Methods apijson.Field
Schemes apijson.Field
URL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitMatchRequest) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitMatchRequestJSON) RawJSON() string {
return r.raw
}
type RateLimitMatchResponse struct {
// When true, only the uncached traffic served from your origin servers will count
// towards rate limiting. In this case, any cached traffic served by Cloudflare
// will not count towards rate limiting. This field is optional. Notes: This field
// is deprecated. Instead, use response headers and set "origin_traffic" to "false"
// to avoid legacy behaviour interacting with the "response_headers" property.
OriginTraffic bool `json:"origin_traffic"`
JSON rateLimitMatchResponseJSON `json:"-"`
}
// rateLimitMatchResponseJSON contains the JSON metadata for the struct
// [RateLimitMatchResponse]
type rateLimitMatchResponseJSON struct {
OriginTraffic apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitMatchResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitMatchResponseJSON) RawJSON() string {
return r.raw
}
// Union satisfied by [rate_limits.RateLimitNewResponseUnknown] or
// [shared.UnionString].
type RateLimitNewResponseUnion interface {
ImplementsRateLimitsRateLimitNewResponseUnion()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*RateLimitNewResponseUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
)
}
type RateLimitDeleteResponse struct {
// The unique identifier of the rate limit.
ID string `json:"id"`
JSON rateLimitDeleteResponseJSON `json:"-"`
}
// rateLimitDeleteResponseJSON contains the JSON metadata for the struct
// [RateLimitDeleteResponse]
type rateLimitDeleteResponseJSON struct {
ID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitDeleteResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitDeleteResponseJSON) RawJSON() string {
return r.raw
}
// Union satisfied by [rate_limits.RateLimitEditResponseUnknown] or
// [shared.UnionString].
type RateLimitEditResponseUnion interface {
ImplementsRateLimitsRateLimitEditResponseUnion()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*RateLimitEditResponseUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
)
}
// Union satisfied by [rate_limits.RateLimitGetResponseUnknown] or
// [shared.UnionString].
type RateLimitGetResponseUnion interface {
ImplementsRateLimitsRateLimitGetResponseUnion()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*RateLimitGetResponseUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
)
}
type RateLimitNewParams struct {
Body interface{} `json:"body,required"`
}
func (r RateLimitNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.Body)
}
type RateLimitNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RateLimitNewResponseUnion `json:"result,required"`
// Whether the API call was successful
Success RateLimitNewResponseEnvelopeSuccess `json:"success,required"`
JSON rateLimitNewResponseEnvelopeJSON `json:"-"`
}
// rateLimitNewResponseEnvelopeJSON contains the JSON metadata for the struct
// [RateLimitNewResponseEnvelope]
type rateLimitNewResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitNewResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type RateLimitNewResponseEnvelopeSuccess bool
const (
RateLimitNewResponseEnvelopeSuccessTrue RateLimitNewResponseEnvelopeSuccess = true
)
func (r RateLimitNewResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case RateLimitNewResponseEnvelopeSuccessTrue:
return true
}
return false
}
type RateLimitListParams struct {
// The page number of paginated results.
Page param.Field[float64] `query:"page"`
// The maximum number of results per page. You can only set the value to `1` or to
// a multiple of 5 such as `5`, `10`, `15`, or `20`.
PerPage param.Field[float64] `query:"per_page"`
}
// URLQuery serializes [RateLimitListParams]'s query parameters as `url.Values`.
func (r RateLimitListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type RateLimitDeleteParams struct {
Body interface{} `json:"body,required"`
}
func (r RateLimitDeleteParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.Body)
}
type RateLimitDeleteResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RateLimitDeleteResponse `json:"result,required"`
// Whether the API call was successful
Success RateLimitDeleteResponseEnvelopeSuccess `json:"success,required"`
JSON rateLimitDeleteResponseEnvelopeJSON `json:"-"`
}
// rateLimitDeleteResponseEnvelopeJSON contains the JSON metadata for the struct
// [RateLimitDeleteResponseEnvelope]
type rateLimitDeleteResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitDeleteResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type RateLimitDeleteResponseEnvelopeSuccess bool
const (
RateLimitDeleteResponseEnvelopeSuccessTrue RateLimitDeleteResponseEnvelopeSuccess = true
)
func (r RateLimitDeleteResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case RateLimitDeleteResponseEnvelopeSuccessTrue:
return true
}
return false
}
type RateLimitEditParams struct {
Body interface{} `json:"body,required"`
}
func (r RateLimitEditParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.Body)
}
type RateLimitEditResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RateLimitEditResponseUnion `json:"result,required"`
// Whether the API call was successful
Success RateLimitEditResponseEnvelopeSuccess `json:"success,required"`
JSON rateLimitEditResponseEnvelopeJSON `json:"-"`
}
// rateLimitEditResponseEnvelopeJSON contains the JSON metadata for the struct
// [RateLimitEditResponseEnvelope]
type rateLimitEditResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitEditResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type RateLimitEditResponseEnvelopeSuccess bool
const (
RateLimitEditResponseEnvelopeSuccessTrue RateLimitEditResponseEnvelopeSuccess = true
)
func (r RateLimitEditResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case RateLimitEditResponseEnvelopeSuccessTrue:
return true
}
return false
}
type RateLimitGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RateLimitGetResponseUnion `json:"result,required"`
// Whether the API call was successful
Success RateLimitGetResponseEnvelopeSuccess `json:"success,required"`
JSON rateLimitGetResponseEnvelopeJSON `json:"-"`
}
// rateLimitGetResponseEnvelopeJSON contains the JSON metadata for the struct
// [RateLimitGetResponseEnvelope]
type rateLimitGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *RateLimitGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r rateLimitGetResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type RateLimitGetResponseEnvelopeSuccess bool
const (
RateLimitGetResponseEnvelopeSuccessTrue RateLimitGetResponseEnvelopeSuccess = true
)
func (r RateLimitGetResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case RateLimitGetResponseEnvelopeSuccessTrue:
return true
}
return false
}