-
Notifications
You must be signed in to change notification settings - Fork 542
/
app.go
848 lines (746 loc) · 31.5 KB
/
app.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
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package spectrum
import (
"context"
"fmt"
"net/http"
"net/url"
"reflect"
"time"
"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/option"
"github.com/cloudflare/cloudflare-go/v2/shared"
"github.com/tidwall/gjson"
)
// AppService 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 [NewAppService] method instead.
type AppService struct {
Options []option.RequestOption
}
// NewAppService 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 NewAppService(opts ...option.RequestOption) (r *AppService) {
r = &AppService{}
r.Options = opts
return
}
// Creates a new Spectrum application from a configuration using a name for the
// origin.
func (r *AppService) New(ctx context.Context, zone string, body AppNewParams, opts ...option.RequestOption) (res *AppNewResponse, err error) {
opts = append(r.Options[:], opts...)
var env AppNewResponseEnvelope
path := fmt.Sprintf("zones/%s/spectrum/apps", zone)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Updates a previously existing application's configuration that uses a name for
// the origin.
func (r *AppService) Update(ctx context.Context, zone string, appID string, body AppUpdateParams, opts ...option.RequestOption) (res *AppUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
var env AppUpdateResponseEnvelope
path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Retrieves a list of currently existing Spectrum applications inside a zone.
func (r *AppService) List(ctx context.Context, zone string, query AppListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[AppListResponse], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := fmt.Sprintf("zones/%s/spectrum/apps", zone)
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
}
// Retrieves a list of currently existing Spectrum applications inside a zone.
func (r *AppService) ListAutoPaging(ctx context.Context, zone string, query AppListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[AppListResponse] {
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zone, query, opts...))
}
// Deletes a previously existing application.
func (r *AppService) Delete(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env AppDeleteResponseEnvelope
path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
// Gets the application configuration of a specific application inside a zone.
func (r *AppService) Get(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppGetResponseUnion, err error) {
opts = append(r.Options[:], opts...)
var env AppGetResponseEnvelope
path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}
type AppNewResponse struct {
// Application identifier.
ID string `json:"id"`
// Enables Argo Smart Routing for this application. Notes: Only available for TCP
// applications with traffic_type set to "direct".
ArgoSmartRouting bool `json:"argo_smart_routing"`
// When the Application was created.
CreatedOn time.Time `json:"created_on" format:"date-time"`
// The name and type of DNS record for the Spectrum application.
DNS DNS `json:"dns"`
// The anycast edge IP configuration for the hostname of this application.
EdgeIPs EdgeIPs `json:"edge_ips"`
// Enables IP Access Rules for this application. Notes: Only available for TCP
// applications.
IPFirewall bool `json:"ip_firewall"`
// When the Application was last modified.
ModifiedOn time.Time `json:"modified_on" format:"date-time"`
// The name and type of DNS record for the Spectrum application.
OriginDNS OriginDNS `json:"origin_dns"`
// The destination port at the origin. Only specified in conjunction with
// origin_dns. May use an integer to specify a single origin port, for example
// `1000`, or a string to specify a range of origin ports, for example
// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the
// range must match the number of ports specified in the "protocol" field.
OriginPort OriginPortUnion `json:"origin_port"`
// The port configuration at Cloudflare’s edge. May specify a single port, for
// example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`.
Protocol string `json:"protocol"`
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
ProxyProtocol AppNewResponseProxyProtocol `json:"proxy_protocol"`
// The type of TLS termination associated with the application.
TLS AppNewResponseTLS `json:"tls"`
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
TrafficType AppNewResponseTrafficType `json:"traffic_type"`
JSON appNewResponseJSON `json:"-"`
}
// appNewResponseJSON contains the JSON metadata for the struct [AppNewResponse]
type appNewResponseJSON struct {
ID apijson.Field
ArgoSmartRouting apijson.Field
CreatedOn apijson.Field
DNS apijson.Field
EdgeIPs apijson.Field
IPFirewall apijson.Field
ModifiedOn apijson.Field
OriginDNS apijson.Field
OriginPort apijson.Field
Protocol apijson.Field
ProxyProtocol apijson.Field
TLS apijson.Field
TrafficType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appNewResponseJSON) RawJSON() string {
return r.raw
}
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
type AppNewResponseProxyProtocol string
const (
AppNewResponseProxyProtocolOff AppNewResponseProxyProtocol = "off"
AppNewResponseProxyProtocolV1 AppNewResponseProxyProtocol = "v1"
AppNewResponseProxyProtocolV2 AppNewResponseProxyProtocol = "v2"
AppNewResponseProxyProtocolSimple AppNewResponseProxyProtocol = "simple"
)
func (r AppNewResponseProxyProtocol) IsKnown() bool {
switch r {
case AppNewResponseProxyProtocolOff, AppNewResponseProxyProtocolV1, AppNewResponseProxyProtocolV2, AppNewResponseProxyProtocolSimple:
return true
}
return false
}
// The type of TLS termination associated with the application.
type AppNewResponseTLS string
const (
AppNewResponseTLSOff AppNewResponseTLS = "off"
AppNewResponseTLSFlexible AppNewResponseTLS = "flexible"
AppNewResponseTLSFull AppNewResponseTLS = "full"
AppNewResponseTLSStrict AppNewResponseTLS = "strict"
)
func (r AppNewResponseTLS) IsKnown() bool {
switch r {
case AppNewResponseTLSOff, AppNewResponseTLSFlexible, AppNewResponseTLSFull, AppNewResponseTLSStrict:
return true
}
return false
}
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
type AppNewResponseTrafficType string
const (
AppNewResponseTrafficTypeDirect AppNewResponseTrafficType = "direct"
AppNewResponseTrafficTypeHTTP AppNewResponseTrafficType = "http"
AppNewResponseTrafficTypeHTTPS AppNewResponseTrafficType = "https"
)
func (r AppNewResponseTrafficType) IsKnown() bool {
switch r {
case AppNewResponseTrafficTypeDirect, AppNewResponseTrafficTypeHTTP, AppNewResponseTrafficTypeHTTPS:
return true
}
return false
}
type AppUpdateResponse struct {
// Application identifier.
ID string `json:"id"`
// Enables Argo Smart Routing for this application. Notes: Only available for TCP
// applications with traffic_type set to "direct".
ArgoSmartRouting bool `json:"argo_smart_routing"`
// When the Application was created.
CreatedOn time.Time `json:"created_on" format:"date-time"`
// The name and type of DNS record for the Spectrum application.
DNS DNS `json:"dns"`
// The anycast edge IP configuration for the hostname of this application.
EdgeIPs EdgeIPs `json:"edge_ips"`
// Enables IP Access Rules for this application. Notes: Only available for TCP
// applications.
IPFirewall bool `json:"ip_firewall"`
// When the Application was last modified.
ModifiedOn time.Time `json:"modified_on" format:"date-time"`
// The name and type of DNS record for the Spectrum application.
OriginDNS OriginDNS `json:"origin_dns"`
// The destination port at the origin. Only specified in conjunction with
// origin_dns. May use an integer to specify a single origin port, for example
// `1000`, or a string to specify a range of origin ports, for example
// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the
// range must match the number of ports specified in the "protocol" field.
OriginPort OriginPortUnion `json:"origin_port"`
// The port configuration at Cloudflare’s edge. May specify a single port, for
// example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`.
Protocol string `json:"protocol"`
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
ProxyProtocol AppUpdateResponseProxyProtocol `json:"proxy_protocol"`
// The type of TLS termination associated with the application.
TLS AppUpdateResponseTLS `json:"tls"`
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
TrafficType AppUpdateResponseTrafficType `json:"traffic_type"`
JSON appUpdateResponseJSON `json:"-"`
}
// appUpdateResponseJSON contains the JSON metadata for the struct
// [AppUpdateResponse]
type appUpdateResponseJSON struct {
ID apijson.Field
ArgoSmartRouting apijson.Field
CreatedOn apijson.Field
DNS apijson.Field
EdgeIPs apijson.Field
IPFirewall apijson.Field
ModifiedOn apijson.Field
OriginDNS apijson.Field
OriginPort apijson.Field
Protocol apijson.Field
ProxyProtocol apijson.Field
TLS apijson.Field
TrafficType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppUpdateResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appUpdateResponseJSON) RawJSON() string {
return r.raw
}
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
type AppUpdateResponseProxyProtocol string
const (
AppUpdateResponseProxyProtocolOff AppUpdateResponseProxyProtocol = "off"
AppUpdateResponseProxyProtocolV1 AppUpdateResponseProxyProtocol = "v1"
AppUpdateResponseProxyProtocolV2 AppUpdateResponseProxyProtocol = "v2"
AppUpdateResponseProxyProtocolSimple AppUpdateResponseProxyProtocol = "simple"
)
func (r AppUpdateResponseProxyProtocol) IsKnown() bool {
switch r {
case AppUpdateResponseProxyProtocolOff, AppUpdateResponseProxyProtocolV1, AppUpdateResponseProxyProtocolV2, AppUpdateResponseProxyProtocolSimple:
return true
}
return false
}
// The type of TLS termination associated with the application.
type AppUpdateResponseTLS string
const (
AppUpdateResponseTLSOff AppUpdateResponseTLS = "off"
AppUpdateResponseTLSFlexible AppUpdateResponseTLS = "flexible"
AppUpdateResponseTLSFull AppUpdateResponseTLS = "full"
AppUpdateResponseTLSStrict AppUpdateResponseTLS = "strict"
)
func (r AppUpdateResponseTLS) IsKnown() bool {
switch r {
case AppUpdateResponseTLSOff, AppUpdateResponseTLSFlexible, AppUpdateResponseTLSFull, AppUpdateResponseTLSStrict:
return true
}
return false
}
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
type AppUpdateResponseTrafficType string
const (
AppUpdateResponseTrafficTypeDirect AppUpdateResponseTrafficType = "direct"
AppUpdateResponseTrafficTypeHTTP AppUpdateResponseTrafficType = "http"
AppUpdateResponseTrafficTypeHTTPS AppUpdateResponseTrafficType = "https"
)
func (r AppUpdateResponseTrafficType) IsKnown() bool {
switch r {
case AppUpdateResponseTrafficTypeDirect, AppUpdateResponseTrafficTypeHTTP, AppUpdateResponseTrafficTypeHTTPS:
return true
}
return false
}
type AppListResponse = interface{}
type AppDeleteResponse struct {
// Application identifier.
ID string `json:"id"`
JSON appDeleteResponseJSON `json:"-"`
}
// appDeleteResponseJSON contains the JSON metadata for the struct
// [AppDeleteResponse]
type appDeleteResponseJSON struct {
ID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppDeleteResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appDeleteResponseJSON) RawJSON() string {
return r.raw
}
// Union satisfied by [spectrum.AppGetResponseUnknown] or [shared.UnionString].
type AppGetResponseUnion interface {
ImplementsSpectrumAppGetResponseUnion()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*AppGetResponseUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
)
}
type AppNewParams struct {
// The name and type of DNS record for the Spectrum application.
DNS param.Field[DNSParam] `json:"dns,required"`
// The name and type of DNS record for the Spectrum application.
OriginDNS param.Field[OriginDNSParam] `json:"origin_dns,required"`
// The destination port at the origin. Only specified in conjunction with
// origin_dns. May use an integer to specify a single origin port, for example
// `1000`, or a string to specify a range of origin ports, for example
// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the
// range must match the number of ports specified in the "protocol" field.
OriginPort param.Field[OriginPortUnionParam] `json:"origin_port,required"`
// The port configuration at Cloudflare’s edge. May specify a single port, for
// example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`.
Protocol param.Field[string] `json:"protocol,required"`
// Enables Argo Smart Routing for this application. Notes: Only available for TCP
// applications with traffic_type set to "direct".
ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"`
// The anycast edge IP configuration for the hostname of this application.
EdgeIPs param.Field[EdgeIPsUnionParam] `json:"edge_ips"`
// Enables IP Access Rules for this application. Notes: Only available for TCP
// applications.
IPFirewall param.Field[bool] `json:"ip_firewall"`
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
ProxyProtocol param.Field[AppNewParamsProxyProtocol] `json:"proxy_protocol"`
// The type of TLS termination associated with the application.
TLS param.Field[AppNewParamsTLS] `json:"tls"`
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
TrafficType param.Field[AppNewParamsTrafficType] `json:"traffic_type"`
}
func (r AppNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
type AppNewParamsProxyProtocol string
const (
AppNewParamsProxyProtocolOff AppNewParamsProxyProtocol = "off"
AppNewParamsProxyProtocolV1 AppNewParamsProxyProtocol = "v1"
AppNewParamsProxyProtocolV2 AppNewParamsProxyProtocol = "v2"
AppNewParamsProxyProtocolSimple AppNewParamsProxyProtocol = "simple"
)
func (r AppNewParamsProxyProtocol) IsKnown() bool {
switch r {
case AppNewParamsProxyProtocolOff, AppNewParamsProxyProtocolV1, AppNewParamsProxyProtocolV2, AppNewParamsProxyProtocolSimple:
return true
}
return false
}
// The type of TLS termination associated with the application.
type AppNewParamsTLS string
const (
AppNewParamsTLSOff AppNewParamsTLS = "off"
AppNewParamsTLSFlexible AppNewParamsTLS = "flexible"
AppNewParamsTLSFull AppNewParamsTLS = "full"
AppNewParamsTLSStrict AppNewParamsTLS = "strict"
)
func (r AppNewParamsTLS) IsKnown() bool {
switch r {
case AppNewParamsTLSOff, AppNewParamsTLSFlexible, AppNewParamsTLSFull, AppNewParamsTLSStrict:
return true
}
return false
}
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
type AppNewParamsTrafficType string
const (
AppNewParamsTrafficTypeDirect AppNewParamsTrafficType = "direct"
AppNewParamsTrafficTypeHTTP AppNewParamsTrafficType = "http"
AppNewParamsTrafficTypeHTTPS AppNewParamsTrafficType = "https"
)
func (r AppNewParamsTrafficType) IsKnown() bool {
switch r {
case AppNewParamsTrafficTypeDirect, AppNewParamsTrafficTypeHTTP, AppNewParamsTrafficTypeHTTPS:
return true
}
return false
}
type AppNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result AppNewResponse `json:"result,required,nullable"`
// Whether the API call was successful
Success AppNewResponseEnvelopeSuccess `json:"success,required"`
JSON appNewResponseEnvelopeJSON `json:"-"`
}
// appNewResponseEnvelopeJSON contains the JSON metadata for the struct
// [AppNewResponseEnvelope]
type appNewResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appNewResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type AppNewResponseEnvelopeSuccess bool
const (
AppNewResponseEnvelopeSuccessTrue AppNewResponseEnvelopeSuccess = true
)
func (r AppNewResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case AppNewResponseEnvelopeSuccessTrue:
return true
}
return false
}
type AppUpdateParams struct {
// The name and type of DNS record for the Spectrum application.
DNS param.Field[DNSParam] `json:"dns,required"`
// The name and type of DNS record for the Spectrum application.
OriginDNS param.Field[OriginDNSParam] `json:"origin_dns,required"`
// The destination port at the origin. Only specified in conjunction with
// origin_dns. May use an integer to specify a single origin port, for example
// `1000`, or a string to specify a range of origin ports, for example
// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the
// range must match the number of ports specified in the "protocol" field.
OriginPort param.Field[OriginPortUnionParam] `json:"origin_port,required"`
// The port configuration at Cloudflare’s edge. May specify a single port, for
// example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`.
Protocol param.Field[string] `json:"protocol,required"`
// Enables Argo Smart Routing for this application. Notes: Only available for TCP
// applications with traffic_type set to "direct".
ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"`
// The anycast edge IP configuration for the hostname of this application.
EdgeIPs param.Field[EdgeIPsUnionParam] `json:"edge_ips"`
// Enables IP Access Rules for this application. Notes: Only available for TCP
// applications.
IPFirewall param.Field[bool] `json:"ip_firewall"`
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
ProxyProtocol param.Field[AppUpdateParamsProxyProtocol] `json:"proxy_protocol"`
// The type of TLS termination associated with the application.
TLS param.Field[AppUpdateParamsTLS] `json:"tls"`
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
TrafficType param.Field[AppUpdateParamsTrafficType] `json:"traffic_type"`
}
func (r AppUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Enables Proxy Protocol to the origin. Refer to
// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/)
// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple
// Proxy Protocol.
type AppUpdateParamsProxyProtocol string
const (
AppUpdateParamsProxyProtocolOff AppUpdateParamsProxyProtocol = "off"
AppUpdateParamsProxyProtocolV1 AppUpdateParamsProxyProtocol = "v1"
AppUpdateParamsProxyProtocolV2 AppUpdateParamsProxyProtocol = "v2"
AppUpdateParamsProxyProtocolSimple AppUpdateParamsProxyProtocol = "simple"
)
func (r AppUpdateParamsProxyProtocol) IsKnown() bool {
switch r {
case AppUpdateParamsProxyProtocolOff, AppUpdateParamsProxyProtocolV1, AppUpdateParamsProxyProtocolV2, AppUpdateParamsProxyProtocolSimple:
return true
}
return false
}
// The type of TLS termination associated with the application.
type AppUpdateParamsTLS string
const (
AppUpdateParamsTLSOff AppUpdateParamsTLS = "off"
AppUpdateParamsTLSFlexible AppUpdateParamsTLS = "flexible"
AppUpdateParamsTLSFull AppUpdateParamsTLS = "full"
AppUpdateParamsTLSStrict AppUpdateParamsTLS = "strict"
)
func (r AppUpdateParamsTLS) IsKnown() bool {
switch r {
case AppUpdateParamsTLSOff, AppUpdateParamsTLSFlexible, AppUpdateParamsTLSFull, AppUpdateParamsTLSStrict:
return true
}
return false
}
// Determines how data travels from the edge to your origin. When set to "direct",
// Spectrum will send traffic directly to your origin, and the application's type
// is derived from the `protocol`. When set to "http" or "https", Spectrum will
// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and
// the application type matches this property exactly.
type AppUpdateParamsTrafficType string
const (
AppUpdateParamsTrafficTypeDirect AppUpdateParamsTrafficType = "direct"
AppUpdateParamsTrafficTypeHTTP AppUpdateParamsTrafficType = "http"
AppUpdateParamsTrafficTypeHTTPS AppUpdateParamsTrafficType = "https"
)
func (r AppUpdateParamsTrafficType) IsKnown() bool {
switch r {
case AppUpdateParamsTrafficTypeDirect, AppUpdateParamsTrafficTypeHTTP, AppUpdateParamsTrafficTypeHTTPS:
return true
}
return false
}
type AppUpdateResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result AppUpdateResponse `json:"result,required,nullable"`
// Whether the API call was successful
Success AppUpdateResponseEnvelopeSuccess `json:"success,required"`
JSON appUpdateResponseEnvelopeJSON `json:"-"`
}
// appUpdateResponseEnvelopeJSON contains the JSON metadata for the struct
// [AppUpdateResponseEnvelope]
type appUpdateResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appUpdateResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type AppUpdateResponseEnvelopeSuccess bool
const (
AppUpdateResponseEnvelopeSuccessTrue AppUpdateResponseEnvelopeSuccess = true
)
func (r AppUpdateResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case AppUpdateResponseEnvelopeSuccessTrue:
return true
}
return false
}
type AppListParams struct {
// Sets the direction by which results are ordered.
Direction param.Field[AppListParamsDirection] `query:"direction"`
// Application field by which results are ordered.
Order param.Field[AppListParamsOrder] `query:"order"`
// Page number of paginated results. This parameter is required in order to use
// other pagination parameters. If included in the query, `result_info` will be
// present in the response.
Page param.Field[float64] `query:"page"`
// Sets the maximum number of results per page.
PerPage param.Field[float64] `query:"per_page"`
}
// URLQuery serializes [AppListParams]'s query parameters as `url.Values`.
func (r AppListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Sets the direction by which results are ordered.
type AppListParamsDirection string
const (
AppListParamsDirectionAsc AppListParamsDirection = "asc"
AppListParamsDirectionDesc AppListParamsDirection = "desc"
)
func (r AppListParamsDirection) IsKnown() bool {
switch r {
case AppListParamsDirectionAsc, AppListParamsDirectionDesc:
return true
}
return false
}
// Application field by which results are ordered.
type AppListParamsOrder string
const (
AppListParamsOrderProtocol AppListParamsOrder = "protocol"
AppListParamsOrderAppID AppListParamsOrder = "app_id"
AppListParamsOrderCreatedOn AppListParamsOrder = "created_on"
AppListParamsOrderModifiedOn AppListParamsOrder = "modified_on"
AppListParamsOrderDNS AppListParamsOrder = "dns"
)
func (r AppListParamsOrder) IsKnown() bool {
switch r {
case AppListParamsOrderProtocol, AppListParamsOrderAppID, AppListParamsOrderCreatedOn, AppListParamsOrderModifiedOn, AppListParamsOrderDNS:
return true
}
return false
}
type AppDeleteResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result AppDeleteResponse `json:"result,required,nullable"`
// Whether the API call was successful
Success AppDeleteResponseEnvelopeSuccess `json:"success,required"`
JSON appDeleteResponseEnvelopeJSON `json:"-"`
}
// appDeleteResponseEnvelopeJSON contains the JSON metadata for the struct
// [AppDeleteResponseEnvelope]
type appDeleteResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appDeleteResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type AppDeleteResponseEnvelopeSuccess bool
const (
AppDeleteResponseEnvelopeSuccessTrue AppDeleteResponseEnvelopeSuccess = true
)
func (r AppDeleteResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case AppDeleteResponseEnvelopeSuccessTrue:
return true
}
return false
}
type AppGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result AppGetResponseUnion `json:"result,required"`
// Whether the API call was successful
Success AppGetResponseEnvelopeSuccess `json:"success,required"`
JSON appGetResponseEnvelopeJSON `json:"-"`
}
// appGetResponseEnvelopeJSON contains the JSON metadata for the struct
// [AppGetResponseEnvelope]
type appGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *AppGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r appGetResponseEnvelopeJSON) RawJSON() string {
return r.raw
}
// Whether the API call was successful
type AppGetResponseEnvelopeSuccess bool
const (
AppGetResponseEnvelopeSuccessTrue AppGetResponseEnvelopeSuccess = true
)
func (r AppGetResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case AppGetResponseEnvelopeSuccessTrue:
return true
}
return false
}