@@ -5,6 +5,7 @@ package imagekit
55import (
66 "bytes"
77 "context"
8+ "encoding/json"
89 "errors"
910 "fmt"
1011 "io"
@@ -14,6 +15,7 @@ import (
1415
1516 "github.com/imagekit-developer/imagekit-go/internal/apiform"
1617 "github.com/imagekit-developer/imagekit-go/internal/apijson"
18+ shimjson "github.com/imagekit-developer/imagekit-go/internal/encoding/json"
1719 "github.com/imagekit-developer/imagekit-go/internal/requestconfig"
1820 "github.com/imagekit-developer/imagekit-go/option"
1921 "github.com/imagekit-developer/imagekit-go/packages/param"
@@ -605,6 +607,132 @@ func (r *MetadataExifThumbnail) UnmarshalJSON(data []byte) error {
605607 return apijson .UnmarshalRoot (data , r )
606608}
607609
610+ // Only one field can be non-zero.
611+ //
612+ // Use [param.IsOmitted] to confirm if a field is set.
613+ type UpdateFileDetailsRequestUnionParam struct {
614+ OfUpdateFileDetails * UpdateFileDetailsRequestUpdateFileDetailsParam `json:",omitzero,inline"`
615+ OfChangePublicationStatus * UpdateFileDetailsRequestChangePublicationStatusParam `json:",omitzero,inline"`
616+ paramUnion
617+ }
618+
619+ func (u UpdateFileDetailsRequestUnionParam ) MarshalJSON () ([]byte , error ) {
620+ return param .MarshalUnion (u , u .OfUpdateFileDetails , u .OfChangePublicationStatus )
621+ }
622+ func (u * UpdateFileDetailsRequestUnionParam ) UnmarshalJSON (data []byte ) error {
623+ return apijson .UnmarshalRoot (data , u )
624+ }
625+
626+ func (u * UpdateFileDetailsRequestUnionParam ) asAny () any {
627+ if ! param .IsOmitted (u .OfUpdateFileDetails ) {
628+ return u .OfUpdateFileDetails
629+ } else if ! param .IsOmitted (u .OfChangePublicationStatus ) {
630+ return u .OfChangePublicationStatus
631+ }
632+ return nil
633+ }
634+
635+ type UpdateFileDetailsRequestUpdateFileDetailsParam struct {
636+ // Define an important area in the image in the format `x,y,width,height` e.g.
637+ // `10,10,100,100`. Send `null` to unset this value.
638+ CustomCoordinates param.Opt [string ] `json:"customCoordinates,omitzero"`
639+ // Optional text to describe the contents of the file.
640+ Description param.Opt [string ] `json:"description,omitzero"`
641+ // The final status of extensions after they have completed execution will be
642+ // delivered to this endpoint as a POST request.
643+ // [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure)
644+ // about the webhook payload structure.
645+ WebhookURL param.Opt [string ] `json:"webhookUrl,omitzero" format:"uri"`
646+ // An array of tags associated with the file, such as `["tag1", "tag2"]`. Send
647+ // `null` to unset all tags associated with the file.
648+ Tags []string `json:"tags,omitzero"`
649+ // A key-value data to be associated with the asset. To unset a key, send `null`
650+ // value for that key. Before setting any custom metadata on an asset you have to
651+ // create the field using custom metadata fields API.
652+ CustomMetadata map [string ]any `json:"customMetadata,omitzero"`
653+ // Array of extensions to be applied to the asset. Each extension can be configured
654+ // with specific parameters based on the extension type.
655+ Extensions shared.ExtensionsParam `json:"extensions,omitzero"`
656+ // An array of AITags associated with the file that you want to remove, e.g.
657+ // `["car", "vehicle", "motorsports"]`.
658+ //
659+ // If you want to remove all AITags associated with the file, send a string -
660+ // "all".
661+ //
662+ // Note: The remove operation for `AITags` executes before any of the `extensions`
663+ // are processed.
664+ RemoveAITags UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam `json:"removeAITags,omitzero"`
665+ paramObj
666+ }
667+
668+ func (r UpdateFileDetailsRequestUpdateFileDetailsParam ) MarshalJSON () (data []byte , err error ) {
669+ type shadow UpdateFileDetailsRequestUpdateFileDetailsParam
670+ return param .MarshalObject (r , (* shadow )(& r ))
671+ }
672+ func (r * UpdateFileDetailsRequestUpdateFileDetailsParam ) UnmarshalJSON (data []byte ) error {
673+ return apijson .UnmarshalRoot (data , r )
674+ }
675+
676+ // Only one field can be non-zero.
677+ //
678+ // Use [param.IsOmitted] to confirm if a field is set.
679+ type UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam struct {
680+ OfStringArray []string `json:",omitzero,inline"`
681+ // Construct this variant with constant.ValueOf[constant.All]()
682+ OfAll constant.All `json:",omitzero,inline"`
683+ paramUnion
684+ }
685+
686+ func (u UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam ) MarshalJSON () ([]byte , error ) {
687+ return param .MarshalUnion (u , u .OfStringArray , u .OfAll )
688+ }
689+ func (u * UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam ) UnmarshalJSON (data []byte ) error {
690+ return apijson .UnmarshalRoot (data , u )
691+ }
692+
693+ func (u * UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam ) asAny () any {
694+ if ! param .IsOmitted (u .OfStringArray ) {
695+ return & u .OfStringArray
696+ } else if ! param .IsOmitted (u .OfAll ) {
697+ return & u .OfAll
698+ }
699+ return nil
700+ }
701+
702+ type UpdateFileDetailsRequestChangePublicationStatusParam struct {
703+ // Configure the publication status of a file and its versions.
704+ Publish UpdateFileDetailsRequestChangePublicationStatusPublishParam `json:"publish,omitzero"`
705+ paramObj
706+ }
707+
708+ func (r UpdateFileDetailsRequestChangePublicationStatusParam ) MarshalJSON () (data []byte , err error ) {
709+ type shadow UpdateFileDetailsRequestChangePublicationStatusParam
710+ return param .MarshalObject (r , (* shadow )(& r ))
711+ }
712+ func (r * UpdateFileDetailsRequestChangePublicationStatusParam ) UnmarshalJSON (data []byte ) error {
713+ return apijson .UnmarshalRoot (data , r )
714+ }
715+
716+ // Configure the publication status of a file and its versions.
717+ //
718+ // The property IsPublished is required.
719+ type UpdateFileDetailsRequestChangePublicationStatusPublishParam struct {
720+ // Set to `true` to publish the file. Set to `false` to unpublish the file.
721+ IsPublished bool `json:"isPublished,required"`
722+ // Set to `true` to publish/unpublish all versions of the file. Set to `false` to
723+ // publish/unpublish only the current version of the file.
724+ IncludeFileVersions param.Opt [bool ] `json:"includeFileVersions,omitzero"`
725+ paramObj
726+ }
727+
728+ func (r UpdateFileDetailsRequestChangePublicationStatusPublishParam ) MarshalJSON () (data []byte , err error ) {
729+ type shadow UpdateFileDetailsRequestChangePublicationStatusPublishParam
730+ return param .MarshalObject (r , (* shadow )(& r ))
731+ }
732+ func (r * UpdateFileDetailsRequestChangePublicationStatusPublishParam ) UnmarshalJSON (data []byte ) error {
733+ return apijson .UnmarshalRoot (data , r )
734+ }
735+
608736// Object containing details of a file or file version.
609737type FileUpdateResponse struct {
610738 ExtensionStatus FileUpdateResponseExtensionStatus `json:"extensionStatus"`
@@ -891,125 +1019,15 @@ func (r *FileUploadResponseVersionInfo) UnmarshalJSON(data []byte) error {
8911019}
8921020
8931021type FileUpdateParams struct {
894-
895- //
896- // Request body variants
897- //
898-
899- // This field is a request body variant, only one variant field can be set.
900- OfUpdateFileDetails * FileUpdateParamsBodyUpdateFileDetails `json:",inline"`
901- // This field is a request body variant, only one variant field can be set.
902- OfChangePublicationStatus * FileUpdateParamsBodyChangePublicationStatus `json:",inline"`
903-
1022+ UpdateFileDetailsRequest UpdateFileDetailsRequestUnionParam
9041023 paramObj
9051024}
9061025
907- func (u FileUpdateParams ) MarshalJSON () ([]byte , error ) {
908- return param . MarshalUnion ( u , u . OfUpdateFileDetails , u . OfChangePublicationStatus )
1026+ func (r FileUpdateParams ) MarshalJSON () (data []byte , err error ) {
1027+ return shimjson . Marshal ( r . UpdateFileDetailsRequest )
9091028}
9101029func (r * FileUpdateParams ) UnmarshalJSON (data []byte ) error {
911- return apijson .UnmarshalRoot (data , r )
912- }
913-
914- type FileUpdateParamsBodyUpdateFileDetails struct {
915- // Define an important area in the image in the format `x,y,width,height` e.g.
916- // `10,10,100,100`. Send `null` to unset this value.
917- CustomCoordinates param.Opt [string ] `json:"customCoordinates,omitzero"`
918- // Optional text to describe the contents of the file.
919- Description param.Opt [string ] `json:"description,omitzero"`
920- // The final status of extensions after they have completed execution will be
921- // delivered to this endpoint as a POST request.
922- // [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure)
923- // about the webhook payload structure.
924- WebhookURL param.Opt [string ] `json:"webhookUrl,omitzero" format:"uri"`
925- // An array of tags associated with the file, such as `["tag1", "tag2"]`. Send
926- // `null` to unset all tags associated with the file.
927- Tags []string `json:"tags,omitzero"`
928- // A key-value data to be associated with the asset. To unset a key, send `null`
929- // value for that key. Before setting any custom metadata on an asset you have to
930- // create the field using custom metadata fields API.
931- CustomMetadata map [string ]any `json:"customMetadata,omitzero"`
932- // Array of extensions to be applied to the asset. Each extension can be configured
933- // with specific parameters based on the extension type.
934- Extensions shared.ExtensionsParam `json:"extensions,omitzero"`
935- // An array of AITags associated with the file that you want to remove, e.g.
936- // `["car", "vehicle", "motorsports"]`.
937- //
938- // If you want to remove all AITags associated with the file, send a string -
939- // "all".
940- //
941- // Note: The remove operation for `AITags` executes before any of the `extensions`
942- // are processed.
943- RemoveAITags FileUpdateParamsBodyUpdateFileDetailsRemoveAITagsUnion `json:"removeAITags,omitzero"`
944- paramObj
945- }
946-
947- func (r FileUpdateParamsBodyUpdateFileDetails ) MarshalJSON () (data []byte , err error ) {
948- type shadow FileUpdateParamsBodyUpdateFileDetails
949- return param .MarshalObject (r , (* shadow )(& r ))
950- }
951- func (r * FileUpdateParamsBodyUpdateFileDetails ) UnmarshalJSON (data []byte ) error {
952- return apijson .UnmarshalRoot (data , r )
953- }
954-
955- // Only one field can be non-zero.
956- //
957- // Use [param.IsOmitted] to confirm if a field is set.
958- type FileUpdateParamsBodyUpdateFileDetailsRemoveAITagsUnion struct {
959- OfStringArray []string `json:",omitzero,inline"`
960- // Construct this variant with constant.ValueOf[constant.All]()
961- OfAll constant.All `json:",omitzero,inline"`
962- paramUnion
963- }
964-
965- func (u FileUpdateParamsBodyUpdateFileDetailsRemoveAITagsUnion ) MarshalJSON () ([]byte , error ) {
966- return param .MarshalUnion (u , u .OfStringArray , u .OfAll )
967- }
968- func (u * FileUpdateParamsBodyUpdateFileDetailsRemoveAITagsUnion ) UnmarshalJSON (data []byte ) error {
969- return apijson .UnmarshalRoot (data , u )
970- }
971-
972- func (u * FileUpdateParamsBodyUpdateFileDetailsRemoveAITagsUnion ) asAny () any {
973- if ! param .IsOmitted (u .OfStringArray ) {
974- return & u .OfStringArray
975- } else if ! param .IsOmitted (u .OfAll ) {
976- return & u .OfAll
977- }
978- return nil
979- }
980-
981- type FileUpdateParamsBodyChangePublicationStatus struct {
982- // Configure the publication status of a file and its versions.
983- Publish FileUpdateParamsBodyChangePublicationStatusPublish `json:"publish,omitzero"`
984- paramObj
985- }
986-
987- func (r FileUpdateParamsBodyChangePublicationStatus ) MarshalJSON () (data []byte , err error ) {
988- type shadow FileUpdateParamsBodyChangePublicationStatus
989- return param .MarshalObject (r , (* shadow )(& r ))
990- }
991- func (r * FileUpdateParamsBodyChangePublicationStatus ) UnmarshalJSON (data []byte ) error {
992- return apijson .UnmarshalRoot (data , r )
993- }
994-
995- // Configure the publication status of a file and its versions.
996- //
997- // The property IsPublished is required.
998- type FileUpdateParamsBodyChangePublicationStatusPublish struct {
999- // Set to `true` to publish the file. Set to `false` to unpublish the file.
1000- IsPublished bool `json:"isPublished,required"`
1001- // Set to `true` to publish/unpublish all versions of the file. Set to `false` to
1002- // publish/unpublish only the current version of the file.
1003- IncludeFileVersions param.Opt [bool ] `json:"includeFileVersions,omitzero"`
1004- paramObj
1005- }
1006-
1007- func (r FileUpdateParamsBodyChangePublicationStatusPublish ) MarshalJSON () (data []byte , err error ) {
1008- type shadow FileUpdateParamsBodyChangePublicationStatusPublish
1009- return param .MarshalObject (r , (* shadow )(& r ))
1010- }
1011- func (r * FileUpdateParamsBodyChangePublicationStatusPublish ) UnmarshalJSON (data []byte ) error {
1012- return apijson .UnmarshalRoot (data , r )
1030+ return json .Unmarshal (data , & r .UpdateFileDetailsRequest )
10131031}
10141032
10151033type FileCopyParams struct {
0 commit comments