-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaccountorigin.go
More file actions
1095 lines (1008 loc) · 41.6 KB
/
accountorigin.go
File metadata and controls
1095 lines (1008 loc) · 41.6 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
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
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package imagekit
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"slices"
"github.com/imagekit-developer/imagekit-go/v2/internal/apijson"
shimjson "github.com/imagekit-developer/imagekit-go/v2/internal/encoding/json"
"github.com/imagekit-developer/imagekit-go/v2/internal/requestconfig"
"github.com/imagekit-developer/imagekit-go/v2/option"
"github.com/imagekit-developer/imagekit-go/v2/packages/param"
"github.com/imagekit-developer/imagekit-go/v2/packages/respjson"
"github.com/imagekit-developer/imagekit-go/v2/shared/constant"
)
// AccountOriginService contains methods and other services that help with
// interacting with the ImageKit 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 [NewAccountOriginService] method instead.
type AccountOriginService struct {
Options []option.RequestOption
}
// NewAccountOriginService 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 NewAccountOriginService(opts ...option.RequestOption) (r AccountOriginService) {
r = AccountOriginService{}
r.Options = opts
return
}
// **Note:** This API is currently in beta.
// Creates a new origin and returns the origin object.
func (r *AccountOriginService) New(ctx context.Context, body AccountOriginNewParams, opts ...option.RequestOption) (res *OriginResponseUnion, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/accounts/origins"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// **Note:** This API is currently in beta.
// Updates the origin identified by `id` and returns the updated origin object.
func (r *AccountOriginService) Update(ctx context.Context, id string, body AccountOriginUpdateParams, opts ...option.RequestOption) (res *OriginResponseUnion, err error) {
opts = slices.Concat(r.Options, opts)
if id == "" {
err = errors.New("missing required id parameter")
return nil, err
}
path := fmt.Sprintf("v1/accounts/origins/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
return res, err
}
// **Note:** This API is currently in beta.
// Returns an array of all configured origins for the current account.
func (r *AccountOriginService) List(ctx context.Context, opts ...option.RequestOption) (res *[]OriginResponseUnion, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/accounts/origins"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// **Note:** This API is currently in beta.
// Permanently removes the origin identified by `id`. If the origin is in use by
// any URL‑endpoints, the API will return an error.
func (r *AccountOriginService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if id == "" {
err = errors.New("missing required id parameter")
return err
}
path := fmt.Sprintf("v1/accounts/origins/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
// **Note:** This API is currently in beta.
// Retrieves the origin identified by `id`.
func (r *AccountOriginService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *OriginResponseUnion, err error) {
opts = slices.Concat(r.Options, opts)
if id == "" {
err = errors.New("missing required id parameter")
return nil, err
}
path := fmt.Sprintf("v1/accounts/origins/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
func OriginRequestParamOfWebFolder(baseURL string, name string) OriginRequestUnionParam {
var webFolder OriginRequestWebFolderParam
webFolder.BaseURL = baseURL
webFolder.Name = name
return OriginRequestUnionParam{OfWebFolder: &webFolder}
}
func OriginRequestParamOfWebProxy(name string) OriginRequestUnionParam {
var webProxy OriginRequestWebProxyParam
webProxy.Name = name
return OriginRequestUnionParam{OfWebProxy: &webProxy}
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type OriginRequestUnionParam struct {
OfS3 *OriginRequestS3Param `json:",omitzero,inline"`
OfS3Compatible *OriginRequestS3CompatibleParam `json:",omitzero,inline"`
OfCloudinaryBackup *OriginRequestCloudinaryBackupParam `json:",omitzero,inline"`
OfWebFolder *OriginRequestWebFolderParam `json:",omitzero,inline"`
OfWebProxy *OriginRequestWebProxyParam `json:",omitzero,inline"`
OfGcs *OriginRequestGcsParam `json:",omitzero,inline"`
OfAzureBlob *OriginRequestAzureBlobParam `json:",omitzero,inline"`
OfAkeneoPim *OriginRequestAkeneoPimParam `json:",omitzero,inline"`
paramUnion
}
func (u OriginRequestUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfS3,
u.OfS3Compatible,
u.OfCloudinaryBackup,
u.OfWebFolder,
u.OfWebProxy,
u.OfGcs,
u.OfAzureBlob,
u.OfAkeneoPim)
}
func (u *OriginRequestUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *OriginRequestUnionParam) asAny() any {
if !param.IsOmitted(u.OfS3) {
return u.OfS3
} else if !param.IsOmitted(u.OfS3Compatible) {
return u.OfS3Compatible
} else if !param.IsOmitted(u.OfCloudinaryBackup) {
return u.OfCloudinaryBackup
} else if !param.IsOmitted(u.OfWebFolder) {
return u.OfWebFolder
} else if !param.IsOmitted(u.OfWebProxy) {
return u.OfWebProxy
} else if !param.IsOmitted(u.OfGcs) {
return u.OfGcs
} else if !param.IsOmitted(u.OfAzureBlob) {
return u.OfAzureBlob
} else if !param.IsOmitted(u.OfAkeneoPim) {
return u.OfAkeneoPim
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetEndpoint() *string {
if vt := u.OfS3Compatible; vt != nil {
return &vt.Endpoint
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetS3ForcePathStyle() *bool {
if vt := u.OfS3Compatible; vt != nil && vt.S3ForcePathStyle.Valid() {
return &vt.S3ForcePathStyle.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetForwardHostHeaderToOrigin() *bool {
if vt := u.OfWebFolder; vt != nil && vt.ForwardHostHeaderToOrigin.Valid() {
return &vt.ForwardHostHeaderToOrigin.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetClientEmail() *string {
if vt := u.OfGcs; vt != nil {
return &vt.ClientEmail
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetPrivateKey() *string {
if vt := u.OfGcs; vt != nil {
return &vt.PrivateKey
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetAccountName() *string {
if vt := u.OfAzureBlob; vt != nil {
return &vt.AccountName
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetContainer() *string {
if vt := u.OfAzureBlob; vt != nil {
return &vt.Container
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetSasToken() *string {
if vt := u.OfAzureBlob; vt != nil {
return &vt.SasToken
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetClientID() *string {
if vt := u.OfAkeneoPim; vt != nil {
return &vt.ClientID
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetClientSecret() *string {
if vt := u.OfAkeneoPim; vt != nil {
return &vt.ClientSecret
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetPassword() *string {
if vt := u.OfAkeneoPim; vt != nil {
return &vt.Password
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetUsername() *string {
if vt := u.OfAkeneoPim; vt != nil {
return &vt.Username
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetAccessKey() *string {
if vt := u.OfS3; vt != nil {
return (*string)(&vt.AccessKey)
} else if vt := u.OfS3Compatible; vt != nil {
return (*string)(&vt.AccessKey)
} else if vt := u.OfCloudinaryBackup; vt != nil {
return (*string)(&vt.AccessKey)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetBucket() *string {
if vt := u.OfS3; vt != nil {
return (*string)(&vt.Bucket)
} else if vt := u.OfS3Compatible; vt != nil {
return (*string)(&vt.Bucket)
} else if vt := u.OfCloudinaryBackup; vt != nil {
return (*string)(&vt.Bucket)
} else if vt := u.OfGcs; vt != nil {
return (*string)(&vt.Bucket)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetName() *string {
if vt := u.OfS3; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfS3Compatible; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfCloudinaryBackup; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfWebFolder; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfWebProxy; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfGcs; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfAzureBlob; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfAkeneoPim; vt != nil {
return (*string)(&vt.Name)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetSecretKey() *string {
if vt := u.OfS3; vt != nil {
return (*string)(&vt.SecretKey)
} else if vt := u.OfS3Compatible; vt != nil {
return (*string)(&vt.SecretKey)
} else if vt := u.OfCloudinaryBackup; vt != nil {
return (*string)(&vt.SecretKey)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetType() *string {
if vt := u.OfS3; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfS3Compatible; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfCloudinaryBackup; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfWebFolder; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfWebProxy; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfGcs; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfAzureBlob; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfAkeneoPim; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetBaseURLForCanonicalHeader() *string {
if vt := u.OfS3; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfS3Compatible; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfCloudinaryBackup; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfWebFolder; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfWebProxy; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfGcs; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfAzureBlob; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
} else if vt := u.OfAkeneoPim; vt != nil && vt.BaseURLForCanonicalHeader.Valid() {
return &vt.BaseURLForCanonicalHeader.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetIncludeCanonicalHeader() *bool {
if vt := u.OfS3; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfS3Compatible; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfCloudinaryBackup; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfWebFolder; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfWebProxy; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfGcs; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfAzureBlob; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
} else if vt := u.OfAkeneoPim; vt != nil && vt.IncludeCanonicalHeader.Valid() {
return &vt.IncludeCanonicalHeader.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetPrefix() *string {
if vt := u.OfS3; vt != nil && vt.Prefix.Valid() {
return &vt.Prefix.Value
} else if vt := u.OfS3Compatible; vt != nil && vt.Prefix.Valid() {
return &vt.Prefix.Value
} else if vt := u.OfCloudinaryBackup; vt != nil && vt.Prefix.Valid() {
return &vt.Prefix.Value
} else if vt := u.OfGcs; vt != nil && vt.Prefix.Valid() {
return &vt.Prefix.Value
} else if vt := u.OfAzureBlob; vt != nil && vt.Prefix.Valid() {
return &vt.Prefix.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u OriginRequestUnionParam) GetBaseURL() *string {
if vt := u.OfWebFolder; vt != nil {
return (*string)(&vt.BaseURL)
} else if vt := u.OfAkeneoPim; vt != nil {
return (*string)(&vt.BaseURL)
}
return nil
}
func init() {
apijson.RegisterUnion[OriginRequestUnionParam](
"type",
apijson.Discriminator[OriginRequestS3Param]("S3"),
apijson.Discriminator[OriginRequestS3CompatibleParam]("S3_COMPATIBLE"),
apijson.Discriminator[OriginRequestCloudinaryBackupParam]("CLOUDINARY_BACKUP"),
apijson.Discriminator[OriginRequestWebFolderParam]("WEB_FOLDER"),
apijson.Discriminator[OriginRequestWebProxyParam]("WEB_PROXY"),
apijson.Discriminator[OriginRequestGcsParam]("GCS"),
apijson.Discriminator[OriginRequestAzureBlobParam]("AZURE_BLOB"),
apijson.Discriminator[OriginRequestAkeneoPimParam]("AKENEO_PIM"),
)
}
// The properties AccessKey, Bucket, Name, SecretKey, Type are required.
type OriginRequestS3Param struct {
// Access key for the bucket.
AccessKey string `json:"accessKey" api:"required"`
// S3 bucket name.
Bucket string `json:"bucket" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Secret key for the bucket.
SecretKey string `json:"secretKey" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
// Path prefix inside the bucket.
Prefix param.Opt[string] `json:"prefix,omitzero"`
// This field can be elided, and will marshal its zero value as "S3".
Type constant.S3 `json:"type" default:"S3"`
paramObj
}
func (r OriginRequestS3Param) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestS3Param
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestS3Param) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties AccessKey, Bucket, Endpoint, Name, SecretKey, Type are required.
type OriginRequestS3CompatibleParam struct {
// Access key for the bucket.
AccessKey string `json:"accessKey" api:"required"`
// S3 bucket name.
Bucket string `json:"bucket" api:"required"`
// Custom S3-compatible endpoint.
Endpoint string `json:"endpoint" api:"required" format:"uri"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Secret key for the bucket.
SecretKey string `json:"secretKey" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
// Path prefix inside the bucket.
Prefix param.Opt[string] `json:"prefix,omitzero"`
// Use path-style S3 URLs?
S3ForcePathStyle param.Opt[bool] `json:"s3ForcePathStyle,omitzero"`
// This field can be elided, and will marshal its zero value as "S3_COMPATIBLE".
Type constant.S3Compatible `json:"type" default:"S3_COMPATIBLE"`
paramObj
}
func (r OriginRequestS3CompatibleParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestS3CompatibleParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestS3CompatibleParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties AccessKey, Bucket, Name, SecretKey, Type are required.
type OriginRequestCloudinaryBackupParam struct {
// Access key for the bucket.
AccessKey string `json:"accessKey" api:"required"`
// S3 bucket name.
Bucket string `json:"bucket" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Secret key for the bucket.
SecretKey string `json:"secretKey" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
// Path prefix inside the bucket.
Prefix param.Opt[string] `json:"prefix,omitzero"`
// This field can be elided, and will marshal its zero value as
// "CLOUDINARY_BACKUP".
Type constant.CloudinaryBackup `json:"type" default:"CLOUDINARY_BACKUP"`
paramObj
}
func (r OriginRequestCloudinaryBackupParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestCloudinaryBackupParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestCloudinaryBackupParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties BaseURL, Name, Type are required.
type OriginRequestWebFolderParam struct {
// Root URL for the web folder origin.
BaseURL string `json:"baseUrl" api:"required" format:"uri"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Forward the Host header to origin?
ForwardHostHeaderToOrigin param.Opt[bool] `json:"forwardHostHeaderToOrigin,omitzero"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
// This field can be elided, and will marshal its zero value as "WEB_FOLDER".
Type constant.WebFolder `json:"type" default:"WEB_FOLDER"`
paramObj
}
func (r OriginRequestWebFolderParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestWebFolderParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestWebFolderParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties Name, Type are required.
type OriginRequestWebProxyParam struct {
// Display name of the origin.
Name string `json:"name" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
// This field can be elided, and will marshal its zero value as "WEB_PROXY".
Type constant.WebProxy `json:"type" default:"WEB_PROXY"`
paramObj
}
func (r OriginRequestWebProxyParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestWebProxyParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestWebProxyParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties Bucket, ClientEmail, Name, PrivateKey, Type are required.
type OriginRequestGcsParam struct {
Bucket string `json:"bucket" api:"required"`
ClientEmail string `json:"clientEmail" api:"required" format:"email"`
// Display name of the origin.
Name string `json:"name" api:"required"`
PrivateKey string `json:"privateKey" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
Prefix param.Opt[string] `json:"prefix,omitzero"`
// This field can be elided, and will marshal its zero value as "GCS".
Type constant.Gcs `json:"type" default:"GCS"`
paramObj
}
func (r OriginRequestGcsParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestGcsParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestGcsParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties AccountName, Container, Name, SasToken, Type are required.
type OriginRequestAzureBlobParam struct {
AccountName string `json:"accountName" api:"required"`
Container string `json:"container" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
SasToken string `json:"sasToken" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
Prefix param.Opt[string] `json:"prefix,omitzero"`
// This field can be elided, and will marshal its zero value as "AZURE_BLOB".
Type constant.AzureBlob `json:"type" default:"AZURE_BLOB"`
paramObj
}
func (r OriginRequestAzureBlobParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestAzureBlobParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestAzureBlobParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The properties BaseURL, ClientID, ClientSecret, Name, Password, Type, Username
// are required.
type OriginRequestAkeneoPimParam struct {
// Akeneo instance base URL.
BaseURL string `json:"baseUrl" api:"required" format:"uri"`
// Akeneo API client ID.
ClientID string `json:"clientId" api:"required"`
// Akeneo API client secret.
ClientSecret string `json:"clientSecret" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Akeneo API password.
Password string `json:"password" api:"required"`
// Akeneo API username.
Username string `json:"username" api:"required"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader param.Opt[string] `json:"baseUrlForCanonicalHeader,omitzero" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader param.Opt[bool] `json:"includeCanonicalHeader,omitzero"`
// This field can be elided, and will marshal its zero value as "AKENEO_PIM".
Type constant.AkeneoPim `json:"type" default:"AKENEO_PIM"`
paramObj
}
func (r OriginRequestAkeneoPimParam) MarshalJSON() (data []byte, err error) {
type shadow OriginRequestAkeneoPimParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *OriginRequestAkeneoPimParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// OriginResponseUnion contains all possible properties and values from
// [OriginResponseS3], [OriginResponseS3Compatible],
// [OriginResponseCloudinaryBackup], [OriginResponseWebFolder],
// [OriginResponseWebProxy], [OriginResponseGcs], [OriginResponseAzureBlob],
// [OriginResponseAkeneoPim].
//
// Use the [OriginResponseUnion.AsAny] method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type OriginResponseUnion struct {
ID string `json:"id"`
Bucket string `json:"bucket"`
IncludeCanonicalHeader bool `json:"includeCanonicalHeader"`
Name string `json:"name"`
Prefix string `json:"prefix"`
// Any of "S3", "S3_COMPATIBLE", "CLOUDINARY_BACKUP", "WEB_FOLDER", "WEB_PROXY",
// "GCS", "AZURE_BLOB", "AKENEO_PIM".
Type string `json:"type"`
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader"`
// This field is from variant [OriginResponseS3Compatible].
Endpoint string `json:"endpoint"`
// This field is from variant [OriginResponseS3Compatible].
S3ForcePathStyle bool `json:"s3ForcePathStyle"`
BaseURL string `json:"baseUrl"`
// This field is from variant [OriginResponseWebFolder].
ForwardHostHeaderToOrigin bool `json:"forwardHostHeaderToOrigin"`
// This field is from variant [OriginResponseGcs].
ClientEmail string `json:"clientEmail"`
// This field is from variant [OriginResponseAzureBlob].
AccountName string `json:"accountName"`
// This field is from variant [OriginResponseAzureBlob].
Container string `json:"container"`
JSON struct {
ID respjson.Field
Bucket respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Prefix respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
Endpoint respjson.Field
S3ForcePathStyle respjson.Field
BaseURL respjson.Field
ForwardHostHeaderToOrigin respjson.Field
ClientEmail respjson.Field
AccountName respjson.Field
Container respjson.Field
raw string
} `json:"-"`
}
// anyOriginResponse is implemented by each variant of [OriginResponseUnion] to add
// type safety for the return type of [OriginResponseUnion.AsAny]
type anyOriginResponse interface {
implOriginResponseUnion()
}
func (OriginResponseS3) implOriginResponseUnion() {}
func (OriginResponseS3Compatible) implOriginResponseUnion() {}
func (OriginResponseCloudinaryBackup) implOriginResponseUnion() {}
func (OriginResponseWebFolder) implOriginResponseUnion() {}
func (OriginResponseWebProxy) implOriginResponseUnion() {}
func (OriginResponseGcs) implOriginResponseUnion() {}
func (OriginResponseAzureBlob) implOriginResponseUnion() {}
func (OriginResponseAkeneoPim) implOriginResponseUnion() {}
// Use the following switch statement to find the correct variant
//
// switch variant := OriginResponseUnion.AsAny().(type) {
// case imagekit.OriginResponseS3:
// case imagekit.OriginResponseS3Compatible:
// case imagekit.OriginResponseCloudinaryBackup:
// case imagekit.OriginResponseWebFolder:
// case imagekit.OriginResponseWebProxy:
// case imagekit.OriginResponseGcs:
// case imagekit.OriginResponseAzureBlob:
// case imagekit.OriginResponseAkeneoPim:
// default:
// fmt.Errorf("no variant present")
// }
func (u OriginResponseUnion) AsAny() anyOriginResponse {
switch u.Type {
case "S3":
return u.AsS3()
case "S3_COMPATIBLE":
return u.AsS3Compatible()
case "CLOUDINARY_BACKUP":
return u.AsCloudinaryBackup()
case "WEB_FOLDER":
return u.AsWebFolder()
case "WEB_PROXY":
return u.AsWebProxy()
case "GCS":
return u.AsGcs()
case "AZURE_BLOB":
return u.AsAzureBlob()
case "AKENEO_PIM":
return u.AsAkeneoPim()
}
return nil
}
func (u OriginResponseUnion) AsS3() (v OriginResponseS3) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsS3Compatible() (v OriginResponseS3Compatible) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsCloudinaryBackup() (v OriginResponseCloudinaryBackup) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsWebFolder() (v OriginResponseWebFolder) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsWebProxy() (v OriginResponseWebProxy) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsGcs() (v OriginResponseGcs) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsAzureBlob() (v OriginResponseAzureBlob) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u OriginResponseUnion) AsAkeneoPim() (v OriginResponseAkeneoPim) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u OriginResponseUnion) RawJSON() string { return u.JSON.raw }
func (r *OriginResponseUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type OriginResponseS3 struct {
// Unique identifier for the origin. This is generated by ImageKit when you create
// a new origin.
ID string `json:"id" api:"required"`
// S3 bucket name.
Bucket string `json:"bucket" api:"required"`
// Whether to send a Canonical header.
IncludeCanonicalHeader bool `json:"includeCanonicalHeader" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Path prefix inside the bucket.
Prefix string `json:"prefix" api:"required"`
Type constant.S3 `json:"type" default:"S3"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Bucket respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Prefix respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r OriginResponseS3) RawJSON() string { return r.JSON.raw }
func (r *OriginResponseS3) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type OriginResponseS3Compatible struct {
// Unique identifier for the origin. This is generated by ImageKit when you create
// a new origin.
ID string `json:"id" api:"required"`
// S3 bucket name.
Bucket string `json:"bucket" api:"required"`
// Custom S3-compatible endpoint.
Endpoint string `json:"endpoint" api:"required" format:"uri"`
// Whether to send a Canonical header.
IncludeCanonicalHeader bool `json:"includeCanonicalHeader" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Path prefix inside the bucket.
Prefix string `json:"prefix" api:"required"`
// Use path-style S3 URLs?
S3ForcePathStyle bool `json:"s3ForcePathStyle" api:"required"`
Type constant.S3Compatible `json:"type" default:"S3_COMPATIBLE"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Bucket respjson.Field
Endpoint respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Prefix respjson.Field
S3ForcePathStyle respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r OriginResponseS3Compatible) RawJSON() string { return r.JSON.raw }
func (r *OriginResponseS3Compatible) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type OriginResponseCloudinaryBackup struct {
// Unique identifier for the origin. This is generated by ImageKit when you create
// a new origin.
ID string `json:"id" api:"required"`
// S3 bucket name.
Bucket string `json:"bucket" api:"required"`
// Whether to send a Canonical header.
IncludeCanonicalHeader bool `json:"includeCanonicalHeader" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
// Path prefix inside the bucket.
Prefix string `json:"prefix" api:"required"`
Type constant.CloudinaryBackup `json:"type" default:"CLOUDINARY_BACKUP"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Bucket respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Prefix respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r OriginResponseCloudinaryBackup) RawJSON() string { return r.JSON.raw }
func (r *OriginResponseCloudinaryBackup) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type OriginResponseWebFolder struct {
// Unique identifier for the origin. This is generated by ImageKit when you create
// a new origin.
ID string `json:"id" api:"required"`
// Root URL for the web folder origin.
BaseURL string `json:"baseUrl" api:"required" format:"uri"`
// Forward the Host header to origin?
ForwardHostHeaderToOrigin bool `json:"forwardHostHeaderToOrigin" api:"required"`
// Whether to send a Canonical header.
IncludeCanonicalHeader bool `json:"includeCanonicalHeader" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
Type constant.WebFolder `json:"type" default:"WEB_FOLDER"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
BaseURL respjson.Field
ForwardHostHeaderToOrigin respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r OriginResponseWebFolder) RawJSON() string { return r.JSON.raw }
func (r *OriginResponseWebFolder) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type OriginResponseWebProxy struct {
// Unique identifier for the origin. This is generated by ImageKit when you create
// a new origin.
ID string `json:"id" api:"required"`
// Whether to send a Canonical header.
IncludeCanonicalHeader bool `json:"includeCanonicalHeader" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
Type constant.WebProxy `json:"type" default:"WEB_PROXY"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r OriginResponseWebProxy) RawJSON() string { return r.JSON.raw }
func (r *OriginResponseWebProxy) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type OriginResponseGcs struct {
// Unique identifier for the origin. This is generated by ImageKit when you create
// a new origin.
ID string `json:"id" api:"required"`
Bucket string `json:"bucket" api:"required"`
ClientEmail string `json:"clientEmail" api:"required" format:"email"`
// Whether to send a Canonical header.
IncludeCanonicalHeader bool `json:"includeCanonicalHeader" api:"required"`
// Display name of the origin.
Name string `json:"name" api:"required"`
Prefix string `json:"prefix" api:"required"`
Type constant.Gcs `json:"type" default:"GCS"`
// URL used in the Canonical header (if enabled).
BaseURLForCanonicalHeader string `json:"baseUrlForCanonicalHeader" format:"uri"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Bucket respjson.Field
ClientEmail respjson.Field
IncludeCanonicalHeader respjson.Field
Name respjson.Field
Prefix respjson.Field
Type respjson.Field
BaseURLForCanonicalHeader respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r OriginResponseGcs) RawJSON() string { return r.JSON.raw }
func (r *OriginResponseGcs) UnmarshalJSON(data []byte) error {