Skip to content

Commit a6a9d9c

Browse files
feat(api): manual updates
1 parent b87188b commit a6a9d9c

5 files changed

Lines changed: 27 additions & 115 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml
3-
openapi_spec_hash: 1bfde02a63416c036e9545927f727459
4-
config_hash: b415c06a3b29485af4601beb94ae1aeb
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml
3+
openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9
4+
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Methods:
2020

2121
Params Types:
2222

23-
- <a href="https://pkg.go.dev/github.com/imagekit-developer/imagekit-go">imagekit</a>.<a href="https://pkg.go.dev/github.com/imagekit-developer/imagekit-go#UpdateFileDetailsRequestUnionParam">UpdateFileDetailsRequestUnionParam</a>
23+
- <a href="https://pkg.go.dev/github.com/imagekit-developer/imagekit-go">imagekit</a>.<a href="https://pkg.go.dev/github.com/imagekit-developer/imagekit-go#UpdateFileRequestParam">UpdateFileRequestParam</a>
2424

2525
Response Types:
2626

file.go

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -607,32 +607,7 @@ func (r *MetadataExifThumbnail) UnmarshalJSON(data []byte) error {
607607
return apijson.UnmarshalRoot(data, r)
608608
}
609609

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 {
610+
type UpdateFileRequestParam struct {
636611
// Define an important area in the image in the format `x,y,width,height` e.g.
637612
// `10,10,100,100`. Send `null` to unset this value.
638613
CustomCoordinates param.Opt[string] `json:"customCoordinates,omitzero"`
@@ -661,36 +636,36 @@ type UpdateFileDetailsRequestUpdateFileDetailsParam struct {
661636
//
662637
// Note: The remove operation for `AITags` executes before any of the `extensions`
663638
// are processed.
664-
RemoveAITags UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam `json:"removeAITags,omitzero"`
639+
RemoveAITags UpdateFileRequestRemoveAITagsUnionParam `json:"removeAITags,omitzero"`
665640
paramObj
666641
}
667642

668-
func (r UpdateFileDetailsRequestUpdateFileDetailsParam) MarshalJSON() (data []byte, err error) {
669-
type shadow UpdateFileDetailsRequestUpdateFileDetailsParam
643+
func (r UpdateFileRequestParam) MarshalJSON() (data []byte, err error) {
644+
type shadow UpdateFileRequestParam
670645
return param.MarshalObject(r, (*shadow)(&r))
671646
}
672-
func (r *UpdateFileDetailsRequestUpdateFileDetailsParam) UnmarshalJSON(data []byte) error {
647+
func (r *UpdateFileRequestParam) UnmarshalJSON(data []byte) error {
673648
return apijson.UnmarshalRoot(data, r)
674649
}
675650

676651
// Only one field can be non-zero.
677652
//
678653
// Use [param.IsOmitted] to confirm if a field is set.
679-
type UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam struct {
654+
type UpdateFileRequestRemoveAITagsUnionParam struct {
680655
OfStringArray []string `json:",omitzero,inline"`
681656
// Construct this variant with constant.ValueOf[constant.All]()
682657
OfAll constant.All `json:",omitzero,inline"`
683658
paramUnion
684659
}
685660

686-
func (u UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam) MarshalJSON() ([]byte, error) {
661+
func (u UpdateFileRequestRemoveAITagsUnionParam) MarshalJSON() ([]byte, error) {
687662
return param.MarshalUnion(u, u.OfStringArray, u.OfAll)
688663
}
689-
func (u *UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam) UnmarshalJSON(data []byte) error {
664+
func (u *UpdateFileRequestRemoveAITagsUnionParam) UnmarshalJSON(data []byte) error {
690665
return apijson.UnmarshalRoot(data, u)
691666
}
692667

693-
func (u *UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam) asAny() any {
668+
func (u *UpdateFileRequestRemoveAITagsUnionParam) asAny() any {
694669
if !param.IsOmitted(u.OfStringArray) {
695670
return &u.OfStringArray
696671
} else if !param.IsOmitted(u.OfAll) {
@@ -699,40 +674,6 @@ func (u *UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam) asAny(
699674
return nil
700675
}
701676

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-
736677
// Object containing details of a file or file version.
737678
type FileUpdateResponse struct {
738679
ExtensionStatus FileUpdateResponseExtensionStatus `json:"extensionStatus"`
@@ -1019,15 +960,16 @@ func (r *FileUploadResponseVersionInfo) UnmarshalJSON(data []byte) error {
1019960
}
1020961

1021962
type FileUpdateParams struct {
1022-
UpdateFileDetailsRequest UpdateFileDetailsRequestUnionParam
963+
// Schema for update file update request.
964+
UpdateFileRequest UpdateFileRequestParam
1023965
paramObj
1024966
}
1025967

1026968
func (r FileUpdateParams) MarshalJSON() (data []byte, err error) {
1027-
return shimjson.Marshal(r.UpdateFileDetailsRequest)
969+
return shimjson.Marshal(r.UpdateFileRequest)
1028970
}
1029971
func (r *FileUpdateParams) UnmarshalJSON(data []byte) error {
1030-
return json.Unmarshal(data, &r.UpdateFileDetailsRequest)
972+
return json.Unmarshal(data, &r.UpdateFileRequest)
1031973
}
1032974

1033975
type FileCopyParams struct {

file_test.go

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,45 +34,15 @@ func TestFileUpdateWithOptionalParams(t *testing.T) {
3434
context.TODO(),
3535
"fileId",
3636
imagekit.FileUpdateParams{
37-
UpdateFileDetailsRequest: imagekit.UpdateFileDetailsRequestUnionParam{
38-
OfUpdateFileDetails: &imagekit.UpdateFileDetailsRequestUpdateFileDetailsParam{
39-
CustomCoordinates: imagekit.String("10,10,100,100"),
40-
CustomMetadata: map[string]any{
41-
"brand": "bar",
42-
"color": "bar",
43-
},
44-
Description: imagekit.String("description"),
45-
Extensions: shared.ExtensionsParam{shared.ExtensionUnionParam{
46-
OfRemoveBg: &shared.ExtensionRemoveBgParam{
47-
Options: shared.ExtensionRemoveBgOptionsParam{
48-
AddShadow: imagekit.Bool(true),
49-
BgColor: imagekit.String("bg_color"),
50-
BgImageURL: imagekit.String("bg_image_url"),
51-
Semitransparency: imagekit.Bool(true),
52-
},
53-
},
54-
}, shared.ExtensionUnionParam{
55-
OfAutoTagging: &shared.ExtensionAutoTaggingParam{
56-
MaxTags: 10,
57-
MinConfidence: 80,
58-
Name: "google-auto-tagging",
59-
},
60-
}, shared.ExtensionUnionParam{
61-
OfAutoTagging: &shared.ExtensionAutoTaggingParam{
62-
MaxTags: 10,
63-
MinConfidence: 80,
64-
Name: "aws-auto-tagging",
65-
},
66-
}, shared.ExtensionUnionParam{
67-
OfAIAutoDescription: &shared.ExtensionAIAutoDescriptionParam{},
68-
}},
69-
RemoveAITags: imagekit.UpdateFileDetailsRequestUpdateFileDetailsRemoveAITagsUnionParam{
70-
OfStringArray: []string{"car", "vehicle", "motorsports"},
71-
},
72-
Tags: []string{"tag1", "tag2"},
73-
WebhookURL: imagekit.String("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a"),
74-
},
75-
},
37+
UpdateFileRequest: imagekit.UpdateFileRequestParam{CustomCoordinates: imagekit.String("customCoordinates"), CustomMetadata: map[string]any{"foo": "bar"}, Description: imagekit.String("description"), Extensions: shared.ExtensionsParam{shared.ExtensionUnionParam{
38+
OfRemoveBg: &shared.ExtensionRemoveBgParam{Options: shared.ExtensionRemoveBgOptionsParam{AddShadow: imagekit.Bool(true), BgColor: imagekit.String("bg_color"), BgImageURL: imagekit.String("bg_image_url"), Semitransparency: imagekit.Bool(true)}},
39+
}, shared.ExtensionUnionParam{
40+
OfAutoTagging: &shared.ExtensionAutoTaggingParam{MaxTags: 5, MinConfidence: 95, Name: "google-auto-tagging"},
41+
}, shared.ExtensionUnionParam{
42+
OfAIAutoDescription: &shared.ExtensionAIAutoDescriptionParam{},
43+
}}, RemoveAITags: imagekit.UpdateFileRequestRemoveAITagsUnionParam{
44+
OfStringArray: []string{"string"},
45+
}, Tags: []string{"tag1", "tag2"}, WebhookURL: imagekit.String("https://example.com")},
7646
},
7747
)
7848
if err != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/imagekit-developer/imagekit-go
22

33
go 1.21.0
44

5-
toolchain go1.21.13
5+
toolchain go1.22.12
66

77
require (
88
github.com/standard-webhooks/standard-webhooks/libraries v0.0.0-20250711233419-a173a6c0125c

0 commit comments

Comments
 (0)