Skip to content

Commit 49c8193

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

4 files changed

Lines changed: 111 additions & 22 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 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-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml
3-
openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
3+
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
44
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#UpdateFileRequestParam">UpdateFileRequestParam</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#UpdateFileRequestUnionParam">UpdateFileRequestUnionParam</a>
2424

2525
Response Types:
2626

file.go

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

610-
type UpdateFileRequestParam struct {
610+
// Only one field can be non-zero.
611+
//
612+
// Use [param.IsOmitted] to confirm if a field is set.
613+
type UpdateFileRequestUnionParam struct {
614+
OfUpdateFileDetails *UpdateFileRequestUpdateFileDetailsParam `json:",omitzero,inline"`
615+
OfChangePublicationStatus *UpdateFileRequestChangePublicationStatusParam `json:",omitzero,inline"`
616+
paramUnion
617+
}
618+
619+
func (u UpdateFileRequestUnionParam) MarshalJSON() ([]byte, error) {
620+
return param.MarshalUnion(u, u.OfUpdateFileDetails, u.OfChangePublicationStatus)
621+
}
622+
func (u *UpdateFileRequestUnionParam) UnmarshalJSON(data []byte) error {
623+
return apijson.UnmarshalRoot(data, u)
624+
}
625+
626+
func (u *UpdateFileRequestUnionParam) 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 UpdateFileRequestUpdateFileDetailsParam struct {
611636
// Define an important area in the image in the format `x,y,width,height` e.g.
612637
// `10,10,100,100`. Send `null` to unset this value.
613638
CustomCoordinates param.Opt[string] `json:"customCoordinates,omitzero"`
@@ -636,36 +661,36 @@ type UpdateFileRequestParam struct {
636661
//
637662
// Note: The remove operation for `AITags` executes before any of the `extensions`
638663
// are processed.
639-
RemoveAITags UpdateFileRequestRemoveAITagsUnionParam `json:"removeAITags,omitzero"`
664+
RemoveAITags UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam `json:"removeAITags,omitzero"`
640665
paramObj
641666
}
642667

643-
func (r UpdateFileRequestParam) MarshalJSON() (data []byte, err error) {
644-
type shadow UpdateFileRequestParam
668+
func (r UpdateFileRequestUpdateFileDetailsParam) MarshalJSON() (data []byte, err error) {
669+
type shadow UpdateFileRequestUpdateFileDetailsParam
645670
return param.MarshalObject(r, (*shadow)(&r))
646671
}
647-
func (r *UpdateFileRequestParam) UnmarshalJSON(data []byte) error {
672+
func (r *UpdateFileRequestUpdateFileDetailsParam) UnmarshalJSON(data []byte) error {
648673
return apijson.UnmarshalRoot(data, r)
649674
}
650675

651676
// Only one field can be non-zero.
652677
//
653678
// Use [param.IsOmitted] to confirm if a field is set.
654-
type UpdateFileRequestRemoveAITagsUnionParam struct {
679+
type UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam struct {
655680
OfStringArray []string `json:",omitzero,inline"`
656681
// Construct this variant with constant.ValueOf[constant.All]()
657682
OfAll constant.All `json:",omitzero,inline"`
658683
paramUnion
659684
}
660685

661-
func (u UpdateFileRequestRemoveAITagsUnionParam) MarshalJSON() ([]byte, error) {
686+
func (u UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam) MarshalJSON() ([]byte, error) {
662687
return param.MarshalUnion(u, u.OfStringArray, u.OfAll)
663688
}
664-
func (u *UpdateFileRequestRemoveAITagsUnionParam) UnmarshalJSON(data []byte) error {
689+
func (u *UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam) UnmarshalJSON(data []byte) error {
665690
return apijson.UnmarshalRoot(data, u)
666691
}
667692

668-
func (u *UpdateFileRequestRemoveAITagsUnionParam) asAny() any {
693+
func (u *UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam) asAny() any {
669694
if !param.IsOmitted(u.OfStringArray) {
670695
return &u.OfStringArray
671696
} else if !param.IsOmitted(u.OfAll) {
@@ -674,6 +699,40 @@ func (u *UpdateFileRequestRemoveAITagsUnionParam) asAny() any {
674699
return nil
675700
}
676701

702+
type UpdateFileRequestChangePublicationStatusParam struct {
703+
// Configure the publication status of a file and its versions.
704+
Publish UpdateFileRequestChangePublicationStatusPublishParam `json:"publish,omitzero"`
705+
paramObj
706+
}
707+
708+
func (r UpdateFileRequestChangePublicationStatusParam) MarshalJSON() (data []byte, err error) {
709+
type shadow UpdateFileRequestChangePublicationStatusParam
710+
return param.MarshalObject(r, (*shadow)(&r))
711+
}
712+
func (r *UpdateFileRequestChangePublicationStatusParam) 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 UpdateFileRequestChangePublicationStatusPublishParam 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 UpdateFileRequestChangePublicationStatusPublishParam) MarshalJSON() (data []byte, err error) {
729+
type shadow UpdateFileRequestChangePublicationStatusPublishParam
730+
return param.MarshalObject(r, (*shadow)(&r))
731+
}
732+
func (r *UpdateFileRequestChangePublicationStatusPublishParam) UnmarshalJSON(data []byte) error {
733+
return apijson.UnmarshalRoot(data, r)
734+
}
735+
677736
// Object containing details of a file or file version.
678737
type FileUpdateResponse struct {
679738
ExtensionStatus FileUpdateResponseExtensionStatus `json:"extensionStatus"`
@@ -961,7 +1020,7 @@ func (r *FileUploadResponseVersionInfo) UnmarshalJSON(data []byte) error {
9611020

9621021
type FileUpdateParams struct {
9631022
// Schema for update file update request.
964-
UpdateFileRequest UpdateFileRequestParam
1023+
UpdateFileRequest UpdateFileRequestUnionParam
9651024
paramObj
9661025
}
9671026

file_test.go

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,45 @@ func TestFileUpdateWithOptionalParams(t *testing.T) {
3434
context.TODO(),
3535
"fileId",
3636
imagekit.FileUpdateParams{
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")},
37+
UpdateFileRequest: imagekit.UpdateFileRequestUnionParam{
38+
OfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{
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.UpdateFileRequestUpdateFileDetailsRemoveAITagsUnionParam{
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+
},
4676
},
4777
)
4878
if err != nil {

0 commit comments

Comments
 (0)