-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfile.go
More file actions
1485 lines (1389 loc) · 59 KB
/
file.go
File metadata and controls
1485 lines (1389 loc) · 59 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 (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"slices"
"strings"
"time"
"github.com/imagekit-developer/imagekit-go/v2/internal/apiform"
"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"
"github.com/imagekit-developer/imagekit-go/v2/shared/constant"
)
// FileService 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 [NewFileService] method instead.
type FileService struct {
Options []option.RequestOption
Bulk FileBulkService
Versions FileVersionService
Metadata FileMetadataService
}
// NewFileService 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 NewFileService(opts ...option.RequestOption) (r FileService) {
r = FileService{}
r.Options = opts
r.Bulk = NewFileBulkService(opts...)
r.Versions = NewFileVersionService(opts...)
r.Metadata = NewFileMetadataService(opts...)
return
}
// This API updates the details or attributes of the current version of the file.
// You can update `tags`, `customCoordinates`, `customMetadata`, publication
// status, remove existing `AITags` and apply extensions using this API.
func (r *FileService) Update(ctx context.Context, fileID string, body FileUpdateParams, opts ...option.RequestOption) (res *FileUpdateResponse, err error) {
opts = slices.Concat(r.Options, opts)
if fileID == "" {
err = errors.New("missing required fileId parameter")
return nil, err
}
path := fmt.Sprintf("v1/files/%s/details", fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return res, err
}
// This API deletes the file and all its file versions permanently.
//
// Note: If a file or specific transformation has been requested in the past, then
// the response is cached. Deleting a file does not purge the cache. You can purge
// the cache using purge cache API.
func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if fileID == "" {
err = errors.New("missing required fileId parameter")
return err
}
path := fmt.Sprintf("v1/files/%s", fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
// This will copy a file from one folder to another.
//
// Note: If any file at the destination has the same name as the source file, then
// the source file and its versions (if `includeFileVersions` is set to true) will
// be appended to the destination file version history.
func (r *FileService) Copy(ctx context.Context, body FileCopyParams, opts ...option.RequestOption) (res *FileCopyResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/copy"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// This API returns an object with details or attributes about the current version
// of the file.
func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *File, err error) {
opts = slices.Concat(r.Options, opts)
if fileID == "" {
err = errors.New("missing required fileId parameter")
return nil, err
}
path := fmt.Sprintf("v1/files/%s/details", fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// This will move a file and all its versions from one folder to another.
//
// Note: If any file at the destination has the same name as the source file, then
// the source file and its versions will be appended to the destination file.
func (r *FileService) Move(ctx context.Context, body FileMoveParams, opts ...option.RequestOption) (res *FileMoveResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/move"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// You can rename an already existing file in the media library using rename file
// API. This operation would rename all file versions of the file.
//
// Note: The old URLs will stop working. The file/file version URLs cached on CDN
// will continue to work unless a purge is requested.
func (r *FileService) Rename(ctx context.Context, body FileRenameParams, opts ...option.RequestOption) (res *FileRenameResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/files/rename"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
return res, err
}
// ImageKit.io allows you to upload files directly from both the server and client
// sides. For server-side uploads, private API key authentication is used. For
// client-side uploads, generate a one-time `token`, `signature`, and `expire` from
// your secure backend using private API.
// [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload)
// about how to implement client-side file upload.
//
// The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security
// by verifying the entire payload using JWT.
//
// **File size limit** \
// On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw
// files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB
// for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan,
// these limits increase to 50MB for images, audio, and raw files and 2GB for videos.
// These limits can be further increased with enterprise plans.
//
// **Version limit** \
// A file can have a maximum of 100 versions.
//
// **Demo applications**
//
// - A full-fledged
// [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader),
// supporting file selections from local storage, URL, Dropbox, Google Drive,
// Instagram, and more.
// - [Quick start guides](/docs/quick-start-guides) for various frameworks and
// technologies.
func (r *FileService) Upload(ctx context.Context, body FileUploadParams, opts ...option.RequestOption) (res *FileUploadResponse, err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithBaseURL("https://upload.imagekit.io/")}, opts...)
path := "api/v1/files/upload"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Object containing details of a file or file version.
type File struct {
// Array of AI-generated tags associated with the image. If no AITags are set, it
// will be null.
AITags []shared.AITag `json:"AITags" api:"nullable"`
// The audio codec used in the video (only for video/audio).
AudioCodec string `json:"audioCodec"`
// The bit rate of the video in kbps (only for video).
BitRate int64 `json:"bitRate"`
// Date and time when the file was uploaded. The date and time is in ISO8601
// format.
CreatedAt time.Time `json:"createdAt" format:"date-time"`
// An string with custom coordinates of the file.
CustomCoordinates string `json:"customCoordinates" api:"nullable"`
// An object with custom metadata for the file.
CustomMetadata shared.CustomMetadata `json:"customMetadata"`
// Optional text to describe the contents of the file. Can be set by the user or
// the ai-auto-description extension.
Description string `json:"description"`
// The duration of the video in seconds (only for video).
Duration int64 `json:"duration"`
// Consolidated embedded metadata associated with the file. It includes exif, iptc,
// and xmp data.
EmbeddedMetadata shared.EmbeddedMetadata `json:"embeddedMetadata"`
// Unique identifier of the asset.
FileID string `json:"fileId"`
// Path of the file. This is the path you would use in the URL to access the file.
// For example, if the file is at the root of the media library, the path will be
// `/file.jpg`. If the file is inside a folder named `images`, the path will be
// `/images/file.jpg`.
FilePath string `json:"filePath"`
// Type of the file. Possible values are `image`, `non-image`.
FileType string `json:"fileType"`
// Specifies if the image has an alpha channel.
HasAlpha bool `json:"hasAlpha"`
// Height of the file.
Height float64 `json:"height"`
// Specifies if the file is private or not.
IsPrivateFile bool `json:"isPrivateFile"`
// Specifies if the file is published or not.
IsPublished bool `json:"isPublished"`
// MIME type of the file.
Mime string `json:"mime"`
// Name of the asset.
Name string `json:"name"`
// This field is included in the response only if the Path policy feature is
// available in the plan. It contains schema definitions for the custom metadata
// fields selected for the specified file path. Field selection can only be done
// when the Path policy feature is enabled.
//
// Keys are the names of the custom metadata fields; the value object has details
// about the custom metadata schema.
SelectedFieldsSchema shared.SelectedFieldsSchema `json:"selectedFieldsSchema"`
// Size of the file in bytes.
Size float64 `json:"size"`
// An array of tags assigned to the file. Tags are used to search files in the
// media library.
Tags []string `json:"tags" api:"nullable"`
// URL of the thumbnail image. This URL is used to access the thumbnail image of
// the file in the media library.
Thumbnail string `json:"thumbnail" format:"uri"`
// Type of the asset.
//
// Any of "file", "file-version".
Type FileType `json:"type"`
// Date and time when the file was last updated. The date and time is in ISO8601
// format.
UpdatedAt time.Time `json:"updatedAt" format:"date-time"`
// URL of the file.
URL string `json:"url" format:"uri"`
// An object with details of the file version.
VersionInfo shared.VersionInfo `json:"versionInfo"`
// The video codec used in the video (only for video).
VideoCodec string `json:"videoCodec"`
// Width of the file.
Width float64 `json:"width"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AITags respjson.Field
AudioCodec respjson.Field
BitRate respjson.Field
CreatedAt respjson.Field
CustomCoordinates respjson.Field
CustomMetadata respjson.Field
Description respjson.Field
Duration respjson.Field
EmbeddedMetadata respjson.Field
FileID respjson.Field
FilePath respjson.Field
FileType respjson.Field
HasAlpha respjson.Field
Height respjson.Field
IsPrivateFile respjson.Field
IsPublished respjson.Field
Mime respjson.Field
Name respjson.Field
SelectedFieldsSchema respjson.Field
Size respjson.Field
Tags respjson.Field
Thumbnail respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
URL respjson.Field
VersionInfo respjson.Field
VideoCodec respjson.Field
Width respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r File) RawJSON() string { return r.JSON.raw }
func (r *File) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Type of the asset.
type FileType string
const (
FileTypeFile FileType = "file"
FileTypeFileVersion FileType = "file-version"
)
type Folder struct {
// Date and time when the folder was created. The date and time is in ISO8601
// format.
CreatedAt time.Time `json:"createdAt" format:"date-time"`
// An object with custom metadata for the folder. Returns empty object if no custom
// metadata is set.
CustomMetadata map[string]any `json:"customMetadata"`
// Unique identifier of the asset.
FolderID string `json:"folderId"`
// Path of the folder. This is the path you would use in the URL to access the
// folder. For example, if the folder is at the root of the media library, the path
// will be /folder. If the folder is inside another folder named images, the path
// will be /images/folder.
FolderPath string `json:"folderPath"`
// Name of the asset.
Name string `json:"name"`
// Type of the asset.
//
// Any of "folder".
Type FolderType `json:"type"`
// Date and time when the folder was last updated. The date and time is in ISO8601
// format.
UpdatedAt time.Time `json:"updatedAt" format:"date-time"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CreatedAt respjson.Field
CustomMetadata respjson.Field
FolderID respjson.Field
FolderPath respjson.Field
Name respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r Folder) RawJSON() string { return r.JSON.raw }
func (r *Folder) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Type of the asset.
type FolderType string
const (
FolderTypeFolder FolderType = "folder"
)
// JSON object containing metadata.
type Metadata struct {
// The audio codec used in the video (only for video).
AudioCodec string `json:"audioCodec"`
// The bit rate of the video in kbps (only for video).
BitRate int64 `json:"bitRate"`
// The density of the image in DPI.
Density int64 `json:"density"`
// The duration of the video in seconds (only for video).
Duration int64 `json:"duration"`
Exif MetadataExif `json:"exif"`
// The format of the file (e.g., 'jpg', 'mp4').
Format string `json:"format"`
// Indicates if the image has a color profile.
HasColorProfile bool `json:"hasColorProfile"`
// Indicates if the image contains transparent areas.
HasTransparency bool `json:"hasTransparency"`
// The height of the image or video in pixels.
Height int64 `json:"height"`
// Perceptual hash of the image.
PHash string `json:"pHash"`
// The quality indicator of the image.
Quality int64 `json:"quality"`
// The file size in bytes.
Size int64 `json:"size"`
// The video codec used in the video (only for video).
VideoCodec string `json:"videoCodec"`
// The width of the image or video in pixels.
Width int64 `json:"width"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AudioCodec respjson.Field
BitRate respjson.Field
Density respjson.Field
Duration respjson.Field
Exif respjson.Field
Format respjson.Field
HasColorProfile respjson.Field
HasTransparency respjson.Field
Height respjson.Field
PHash respjson.Field
Quality respjson.Field
Size respjson.Field
VideoCodec respjson.Field
Width respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r Metadata) RawJSON() string { return r.JSON.raw }
func (r *Metadata) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type MetadataExif struct {
// Object containing Exif details.
Exif MetadataExifExif `json:"exif"`
// Object containing GPS information.
Gps MetadataExifGps `json:"gps"`
// Object containing EXIF image information.
Image MetadataExifImage `json:"image"`
// JSON object.
Interoperability MetadataExifInteroperability `json:"interoperability"`
Makernote map[string]any `json:"makernote"`
// Object containing Thumbnail information.
Thumbnail MetadataExifThumbnail `json:"thumbnail"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Exif respjson.Field
Gps respjson.Field
Image respjson.Field
Interoperability respjson.Field
Makernote respjson.Field
Thumbnail respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MetadataExif) RawJSON() string { return r.JSON.raw }
func (r *MetadataExif) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Object containing Exif details.
type MetadataExifExif struct {
ApertureValue float64 `json:"ApertureValue"`
ColorSpace int64 `json:"ColorSpace"`
CreateDate string `json:"CreateDate"`
CustomRendered int64 `json:"CustomRendered"`
DateTimeOriginal string `json:"DateTimeOriginal"`
ExifImageHeight int64 `json:"ExifImageHeight"`
ExifImageWidth int64 `json:"ExifImageWidth"`
ExifVersion string `json:"ExifVersion"`
ExposureCompensation float64 `json:"ExposureCompensation"`
ExposureMode int64 `json:"ExposureMode"`
ExposureProgram int64 `json:"ExposureProgram"`
ExposureTime float64 `json:"ExposureTime"`
Flash int64 `json:"Flash"`
FlashpixVersion string `json:"FlashpixVersion"`
FNumber float64 `json:"FNumber"`
FocalLength int64 `json:"FocalLength"`
FocalPlaneResolutionUnit int64 `json:"FocalPlaneResolutionUnit"`
FocalPlaneXResolution float64 `json:"FocalPlaneXResolution"`
FocalPlaneYResolution float64 `json:"FocalPlaneYResolution"`
InteropOffset int64 `json:"InteropOffset"`
ISO int64 `json:"ISO"`
MeteringMode int64 `json:"MeteringMode"`
SceneCaptureType int64 `json:"SceneCaptureType"`
ShutterSpeedValue float64 `json:"ShutterSpeedValue"`
SubSecTime string `json:"SubSecTime"`
WhiteBalance int64 `json:"WhiteBalance"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ApertureValue respjson.Field
ColorSpace respjson.Field
CreateDate respjson.Field
CustomRendered respjson.Field
DateTimeOriginal respjson.Field
ExifImageHeight respjson.Field
ExifImageWidth respjson.Field
ExifVersion respjson.Field
ExposureCompensation respjson.Field
ExposureMode respjson.Field
ExposureProgram respjson.Field
ExposureTime respjson.Field
Flash respjson.Field
FlashpixVersion respjson.Field
FNumber respjson.Field
FocalLength respjson.Field
FocalPlaneResolutionUnit respjson.Field
FocalPlaneXResolution respjson.Field
FocalPlaneYResolution respjson.Field
InteropOffset respjson.Field
ISO respjson.Field
MeteringMode respjson.Field
SceneCaptureType respjson.Field
ShutterSpeedValue respjson.Field
SubSecTime respjson.Field
WhiteBalance respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MetadataExifExif) RawJSON() string { return r.JSON.raw }
func (r *MetadataExifExif) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Object containing GPS information.
type MetadataExifGps struct {
GpsVersionID []int64 `json:"GPSVersionID"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
GpsVersionID respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MetadataExifGps) RawJSON() string { return r.JSON.raw }
func (r *MetadataExifGps) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Object containing EXIF image information.
type MetadataExifImage struct {
ExifOffset int64 `json:"ExifOffset"`
GpsInfo int64 `json:"GPSInfo"`
Make string `json:"Make"`
Model string `json:"Model"`
ModifyDate string `json:"ModifyDate"`
Orientation int64 `json:"Orientation"`
ResolutionUnit int64 `json:"ResolutionUnit"`
Software string `json:"Software"`
XResolution int64 `json:"XResolution"`
YCbCrPositioning int64 `json:"YCbCrPositioning"`
YResolution int64 `json:"YResolution"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExifOffset respjson.Field
GpsInfo respjson.Field
Make respjson.Field
Model respjson.Field
ModifyDate respjson.Field
Orientation respjson.Field
ResolutionUnit respjson.Field
Software respjson.Field
XResolution respjson.Field
YCbCrPositioning respjson.Field
YResolution respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MetadataExifImage) RawJSON() string { return r.JSON.raw }
func (r *MetadataExifImage) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// JSON object.
type MetadataExifInteroperability struct {
InteropIndex string `json:"InteropIndex"`
InteropVersion string `json:"InteropVersion"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
InteropIndex respjson.Field
InteropVersion respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MetadataExifInteroperability) RawJSON() string { return r.JSON.raw }
func (r *MetadataExifInteroperability) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Object containing Thumbnail information.
type MetadataExifThumbnail struct {
Compression int64 `json:"Compression"`
ResolutionUnit int64 `json:"ResolutionUnit"`
ThumbnailLength int64 `json:"ThumbnailLength"`
ThumbnailOffset int64 `json:"ThumbnailOffset"`
XResolution int64 `json:"XResolution"`
YResolution int64 `json:"YResolution"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Compression respjson.Field
ResolutionUnit respjson.Field
ThumbnailLength respjson.Field
ThumbnailOffset respjson.Field
XResolution respjson.Field
YResolution respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MetadataExifThumbnail) RawJSON() string { return r.JSON.raw }
func (r *MetadataExifThumbnail) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type UpdateFileRequestUnionParam struct {
OfUpdateFileDetails *UpdateFileRequestUpdateFileDetailsParam `json:",omitzero,inline"`
OfChangePublicationStatus *UpdateFileRequestChangePublicationStatusParam `json:",omitzero,inline"`
paramUnion
}
func (u UpdateFileRequestUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfUpdateFileDetails, u.OfChangePublicationStatus)
}
func (u *UpdateFileRequestUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *UpdateFileRequestUnionParam) asAny() any {
if !param.IsOmitted(u.OfUpdateFileDetails) {
return u.OfUpdateFileDetails
} else if !param.IsOmitted(u.OfChangePublicationStatus) {
return u.OfChangePublicationStatus
}
return nil
}
type UpdateFileRequestUpdateFileDetailsParam struct {
// Define an important area in the image in the format `x,y,width,height` e.g.
// `10,10,100,100`. Send `null` to unset this value.
CustomCoordinates param.Opt[string] `json:"customCoordinates,omitzero"`
// Optional text to describe the contents of the file.
Description param.Opt[string] `json:"description,omitzero"`
// The final status of extensions after they have completed execution will be
// delivered to this endpoint as a POST request.
// [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure)
// about the webhook payload structure.
WebhookURL param.Opt[string] `json:"webhookUrl,omitzero" format:"uri"`
// An array of tags associated with the file, such as `["tag1", "tag2"]`. Send
// `null` to unset all tags associated with the file.
Tags []string `json:"tags,omitzero"`
// A key-value data to be associated with the asset. To unset a key, send `null`
// value for that key. Before setting any custom metadata on an asset you have to
// create the field using custom metadata fields API.
CustomMetadata map[string]any `json:"customMetadata,omitzero"`
// Array of extensions to be applied to the asset. Each extension can be configured
// with specific parameters based on the extension type.
Extensions shared.ExtensionsParam `json:"extensions,omitzero"`
// An array of AITags associated with the file that you want to remove, e.g.
// `["car", "vehicle", "motorsports"]`.
//
// If you want to remove all AITags associated with the file, send a string -
// "all".
//
// Note: The remove operation for `AITags` executes before any of the `extensions`
// are processed.
RemoveAITags UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam `json:"removeAITags,omitzero"`
paramObj
}
func (r UpdateFileRequestUpdateFileDetailsParam) MarshalJSON() (data []byte, err error) {
type shadow UpdateFileRequestUpdateFileDetailsParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *UpdateFileRequestUpdateFileDetailsParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam struct {
OfStringArray []string `json:",omitzero,inline"`
// Construct this variant with constant.ValueOf[constant.All]()
OfAll constant.All `json:",omitzero,inline"`
paramUnion
}
func (u UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfStringArray, u.OfAll)
}
func (u *UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam) asAny() any {
if !param.IsOmitted(u.OfStringArray) {
return &u.OfStringArray
} else if !param.IsOmitted(u.OfAll) {
return &u.OfAll
}
return nil
}
type UpdateFileRequestChangePublicationStatusParam struct {
// Configure the publication status of a file and its versions.
Publish UpdateFileRequestChangePublicationStatusPublishParam `json:"publish,omitzero"`
paramObj
}
func (r UpdateFileRequestChangePublicationStatusParam) MarshalJSON() (data []byte, err error) {
type shadow UpdateFileRequestChangePublicationStatusParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *UpdateFileRequestChangePublicationStatusParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Configure the publication status of a file and its versions.
//
// The property IsPublished is required.
type UpdateFileRequestChangePublicationStatusPublishParam struct {
// Set to `true` to publish the file. Set to `false` to unpublish the file.
IsPublished bool `json:"isPublished" api:"required"`
// Set to `true` to publish/unpublish all versions of the file. Set to `false` to
// publish/unpublish only the current version of the file.
IncludeFileVersions param.Opt[bool] `json:"includeFileVersions,omitzero"`
paramObj
}
func (r UpdateFileRequestChangePublicationStatusPublishParam) MarshalJSON() (data []byte, err error) {
type shadow UpdateFileRequestChangePublicationStatusPublishParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *UpdateFileRequestChangePublicationStatusPublishParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Object containing details of a file or file version.
type FileUpdateResponse struct {
ExtensionStatus FileUpdateResponseExtensionStatus `json:"extensionStatus"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExtensionStatus respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
File
}
// Returns the unmodified JSON received from the API
func (r FileUpdateResponse) RawJSON() string { return r.JSON.raw }
func (r *FileUpdateResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileUpdateResponseExtensionStatus struct {
// Any of "success", "pending", "failed".
AIAutoDescription string `json:"ai-auto-description"`
// Any of "success", "pending", "failed".
AITasks string `json:"ai-tasks"`
// Any of "success", "pending", "failed".
AwsAutoTagging string `json:"aws-auto-tagging"`
// Any of "success", "pending", "failed".
GoogleAutoTagging string `json:"google-auto-tagging"`
// Any of "success", "pending", "failed".
RemoveBg string `json:"remove-bg"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AIAutoDescription respjson.Field
AITasks respjson.Field
AwsAutoTagging respjson.Field
GoogleAutoTagging respjson.Field
RemoveBg respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileUpdateResponseExtensionStatus) RawJSON() string { return r.JSON.raw }
func (r *FileUpdateResponseExtensionStatus) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileCopyResponse struct {
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileCopyResponse) RawJSON() string { return r.JSON.raw }
func (r *FileCopyResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileMoveResponse struct {
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileMoveResponse) RawJSON() string { return r.JSON.raw }
func (r *FileMoveResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileRenameResponse struct {
// Unique identifier of the purge request. This can be used to check the status of
// the purge request.
PurgeRequestID string `json:"purgeRequestId"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
PurgeRequestID respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileRenameResponse) RawJSON() string { return r.JSON.raw }
func (r *FileRenameResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Object containing details of a successful upload.
type FileUploadResponse struct {
// An array of tags assigned to the uploaded file by auto tagging.
AITags []shared.AITag `json:"AITags" api:"nullable"`
// The audio codec used in the video (only for video).
AudioCodec string `json:"audioCodec"`
// The bit rate of the video in kbps (only for video).
BitRate int64 `json:"bitRate"`
// Value of custom coordinates associated with the image in the format
// `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`.
// Send `customCoordinates` in `responseFields` in API request to get the value of
// this field.
CustomCoordinates string `json:"customCoordinates" api:"nullable"`
// A key-value data associated with the asset. Use `responseField` in API request
// to get `customMetadata` in the upload API response. Before setting any custom
// metadata on an asset, you have to create the field using custom metadata fields
// API. Send `customMetadata` in `responseFields` in API request to get the value
// of this field.
CustomMetadata shared.CustomMetadata `json:"customMetadata"`
// Optional text to describe the contents of the file. Can be set by the user or
// the ai-auto-description extension.
Description string `json:"description"`
// The duration of the video in seconds (only for video).
Duration int64 `json:"duration"`
// Consolidated embedded metadata associated with the file. It includes exif, iptc,
// and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get
// embeddedMetadata in the upload API response.
EmbeddedMetadata shared.EmbeddedMetadata `json:"embeddedMetadata"`
// Extension names with their processing status at the time of completion of the
// request. It could have one of the following status values:
//
// `success`: The extension has been successfully applied. `failed`: The extension
// has failed and will not be retried. `pending`: The extension will finish
// processing in some time. On completion, the final status (success / failed) will
// be sent to the `webhookUrl` provided.
//
// If no extension was requested, then this parameter is not returned.
ExtensionStatus FileUploadResponseExtensionStatus `json:"extensionStatus"`
// Unique fileId. Store this fileld in your database, as this will be used to
// perform update action on this file.
FileID string `json:"fileId"`
// The relative path of the file in the media library e.g.
// `/marketing-assets/new-banner.jpg`.
FilePath string `json:"filePath"`
// Type of the uploaded file. Possible values are `image`, `non-image`.
FileType string `json:"fileType"`
// Height of the image in pixels (Only for images)
Height float64 `json:"height"`
// Is the file marked as private. It can be either `true` or `false`. Send
// `isPrivateFile` in `responseFields` in API request to get the value of this
// field.
IsPrivateFile bool `json:"isPrivateFile"`
// Is the file published or in draft state. It can be either `true` or `false`.
// Send `isPublished` in `responseFields` in API request to get the value of this
// field.
IsPublished bool `json:"isPublished"`
// Legacy metadata. Send `metadata` in `responseFields` in API request to get
// metadata in the upload API response.
Metadata Metadata `json:"metadata"`
// Name of the asset.
Name string `json:"name"`
// This field is included in the response only if the Path policy feature is
// available in the plan. It contains schema definitions for the custom metadata
// fields selected for the specified file path. Field selection can only be done
// when the Path policy feature is enabled.
//
// Keys are the names of the custom metadata fields; the value object has details
// about the custom metadata schema.
SelectedFieldsSchema shared.SelectedFieldsSchema `json:"selectedFieldsSchema"`
// Size of the image file in Bytes.
Size float64 `json:"size"`
// The array of tags associated with the asset. If no tags are set, it will be
// `null`. Send `tags` in `responseFields` in API request to get the value of this
// field.
Tags []string `json:"tags" api:"nullable"`
// In the case of an image, a small thumbnail URL.
ThumbnailURL string `json:"thumbnailUrl"`
// A publicly accessible URL of the file.
URL string `json:"url"`
// An object containing the file or file version's `id` (versionId) and `name`.
VersionInfo shared.VersionInfo `json:"versionInfo"`
// The video codec used in the video (only for video).
VideoCodec string `json:"videoCodec"`
// Width of the image in pixels (Only for Images)
Width float64 `json:"width"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AITags respjson.Field
AudioCodec respjson.Field
BitRate respjson.Field
CustomCoordinates respjson.Field
CustomMetadata respjson.Field
Description respjson.Field
Duration respjson.Field
EmbeddedMetadata respjson.Field
ExtensionStatus respjson.Field
FileID respjson.Field
FilePath respjson.Field
FileType respjson.Field
Height respjson.Field
IsPrivateFile respjson.Field
IsPublished respjson.Field
Metadata respjson.Field
Name respjson.Field
SelectedFieldsSchema respjson.Field
Size respjson.Field
Tags respjson.Field
ThumbnailURL respjson.Field
URL respjson.Field
VersionInfo respjson.Field
VideoCodec respjson.Field
Width respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileUploadResponse) RawJSON() string { return r.JSON.raw }
func (r *FileUploadResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Extension names with their processing status at the time of completion of the
// request. It could have one of the following status values:
//
// `success`: The extension has been successfully applied. `failed`: The extension
// has failed and will not be retried. `pending`: The extension will finish
// processing in some time. On completion, the final status (success / failed) will
// be sent to the `webhookUrl` provided.
//
// If no extension was requested, then this parameter is not returned.
type FileUploadResponseExtensionStatus struct {
// Any of "success", "pending", "failed".
AIAutoDescription string `json:"ai-auto-description"`
// Any of "success", "pending", "failed".
AITasks string `json:"ai-tasks"`
// Any of "success", "pending", "failed".
AwsAutoTagging string `json:"aws-auto-tagging"`
// Any of "success", "pending", "failed".
GoogleAutoTagging string `json:"google-auto-tagging"`
// Any of "success", "pending", "failed".
RemoveBg string `json:"remove-bg"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AIAutoDescription respjson.Field
AITasks respjson.Field
AwsAutoTagging respjson.Field
GoogleAutoTagging respjson.Field
RemoveBg respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FileUploadResponseExtensionStatus) RawJSON() string { return r.JSON.raw }
func (r *FileUploadResponseExtensionStatus) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileUpdateParams struct {
// Schema for update file update request.
UpdateFileRequest UpdateFileRequestUnionParam
paramObj
}
func (r FileUpdateParams) MarshalJSON() (data []byte, err error) {
return shimjson.Marshal(r.UpdateFileRequest)
}
func (r *FileUpdateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FileCopyParams struct {
// Full path to the folder you want to copy the above file into.
DestinationPath string `json:"destinationPath" api:"required"`
// The full path of the file you want to copy.
SourceFilePath string `json:"sourceFilePath" api:"required"`
// Option to copy all versions of a file. By default, only the current version of
// the file is copied. When set to true, all versions of the file will be copied.
// Default value - `false`.
IncludeFileVersions param.Opt[bool] `json:"includeFileVersions,omitzero"`
paramObj