Skip to content

Commit 5829397

Browse files
feat(api): manual updates
1 parent cc22fef commit 5829397

8 files changed

Lines changed: 227 additions & 525 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml
33
openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072
4-
config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c
4+
config_hash: da949a1217f48ac01676eab81ca9d1b1

aliases.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package imagekit
55
import (
66
"github.com/imagekit-developer/imagekit-go/internal/apierror"
77
"github.com/imagekit-developer/imagekit-go/packages/param"
8+
"github.com/imagekit-developer/imagekit-go/shared"
89
)
910

1011
// aliased to make [param.APIUnion] private when embedding
@@ -14,3 +15,24 @@ type paramUnion = param.APIUnion
1415
type paramObj = param.APIObject
1516

1617
type Error = apierror.Error
18+
19+
// Array of extensions to be applied to the asset. Each extension can be configured
20+
// with specific parameters based on the extension type.
21+
//
22+
// This is an alias to an internal type.
23+
type ExtensionsParam = shared.ExtensionsParam
24+
25+
// This is an alias to an internal type.
26+
type ExtensionUnionParam = shared.ExtensionUnionParam
27+
28+
// This is an alias to an internal type.
29+
type ExtensionRemoveBgParam = shared.ExtensionRemoveBgParam
30+
31+
// This is an alias to an internal type.
32+
type ExtensionRemoveBgOptionsParam = shared.ExtensionRemoveBgOptionsParam
33+
34+
// This is an alias to an internal type.
35+
type ExtensionAutoTaggingParam = shared.ExtensionAutoTaggingParam
36+
37+
// This is an alias to an internal type.
38+
type ExtensionAIAutoDescriptionParam = shared.ExtensionAIAutoDescriptionParam

api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Shared Params Types
2+
3+
- <a href="https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/shared#ExtensionsParam">ExtensionsParam</a>
4+
15
# CustomMetadataFields
26

37
Response Types:

betav2file.go

Lines changed: 2 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/imagekit-developer/imagekit-go/option"
1616
"github.com/imagekit-developer/imagekit-go/packages/param"
1717
"github.com/imagekit-developer/imagekit-go/packages/respjson"
18+
"github.com/imagekit-developer/imagekit-go/shared"
1819
"github.com/imagekit-developer/imagekit-go/shared/constant"
1920
)
2021

@@ -357,7 +358,7 @@ type BetaV2FileUploadParams struct {
357358
CustomMetadata map[string]any `json:"customMetadata,omitzero"`
358359
// Array of extensions to be applied to the asset. Each extension can be configured
359360
// with specific parameters based on the extension type.
360-
Extensions []BetaV2FileUploadParamsExtensionUnion `json:"extensions,omitzero"`
361+
Extensions shared.ExtensionsParam `json:"extensions,omitzero"`
361362
// Array of response field keys to include in the API response body.
362363
//
363364
// Any of "tags", "customCoordinates", "isPrivateFile", "embeddedMetadata",
@@ -401,172 +402,6 @@ func (r BetaV2FileUploadParams) MarshalMultipart() (data []byte, contentType str
401402
return buf.Bytes(), writer.FormDataContentType(), nil
402403
}
403404

404-
// Only one field can be non-zero.
405-
//
406-
// Use [param.IsOmitted] to confirm if a field is set.
407-
type BetaV2FileUploadParamsExtensionUnion struct {
408-
OfRemoveBg *BetaV2FileUploadParamsExtensionRemoveBg `json:",omitzero,inline"`
409-
OfAutoTagging *BetaV2FileUploadParamsExtensionAutoTagging `json:",omitzero,inline"`
410-
OfAIAutoDescription *BetaV2FileUploadParamsExtensionAIAutoDescription `json:",omitzero,inline"`
411-
paramUnion
412-
}
413-
414-
func (u BetaV2FileUploadParamsExtensionUnion) MarshalJSON() ([]byte, error) {
415-
return param.MarshalUnion(u, u.OfRemoveBg, u.OfAutoTagging, u.OfAIAutoDescription)
416-
}
417-
func (u *BetaV2FileUploadParamsExtensionUnion) UnmarshalJSON(data []byte) error {
418-
return apijson.UnmarshalRoot(data, u)
419-
}
420-
421-
func (u *BetaV2FileUploadParamsExtensionUnion) asAny() any {
422-
if !param.IsOmitted(u.OfRemoveBg) {
423-
return u.OfRemoveBg
424-
} else if !param.IsOmitted(u.OfAutoTagging) {
425-
return u.OfAutoTagging
426-
} else if !param.IsOmitted(u.OfAIAutoDescription) {
427-
return u.OfAIAutoDescription
428-
}
429-
return nil
430-
}
431-
432-
// Returns a pointer to the underlying variant's property, if present.
433-
func (u BetaV2FileUploadParamsExtensionUnion) GetOptions() *BetaV2FileUploadParamsExtensionRemoveBgOptions {
434-
if vt := u.OfRemoveBg; vt != nil {
435-
return &vt.Options
436-
}
437-
return nil
438-
}
439-
440-
// Returns a pointer to the underlying variant's property, if present.
441-
func (u BetaV2FileUploadParamsExtensionUnion) GetMaxTags() *int64 {
442-
if vt := u.OfAutoTagging; vt != nil {
443-
return &vt.MaxTags
444-
}
445-
return nil
446-
}
447-
448-
// Returns a pointer to the underlying variant's property, if present.
449-
func (u BetaV2FileUploadParamsExtensionUnion) GetMinConfidence() *int64 {
450-
if vt := u.OfAutoTagging; vt != nil {
451-
return &vt.MinConfidence
452-
}
453-
return nil
454-
}
455-
456-
// Returns a pointer to the underlying variant's property, if present.
457-
func (u BetaV2FileUploadParamsExtensionUnion) GetName() *string {
458-
if vt := u.OfRemoveBg; vt != nil {
459-
return (*string)(&vt.Name)
460-
} else if vt := u.OfAutoTagging; vt != nil {
461-
return (*string)(&vt.Name)
462-
} else if vt := u.OfAIAutoDescription; vt != nil {
463-
return (*string)(&vt.Name)
464-
}
465-
return nil
466-
}
467-
468-
func init() {
469-
apijson.RegisterUnion[BetaV2FileUploadParamsExtensionUnion](
470-
"name",
471-
apijson.Discriminator[BetaV2FileUploadParamsExtensionRemoveBg]("remove-bg"),
472-
apijson.Discriminator[BetaV2FileUploadParamsExtensionAutoTagging]("google-auto-tagging"),
473-
apijson.Discriminator[BetaV2FileUploadParamsExtensionAutoTagging]("aws-auto-tagging"),
474-
apijson.Discriminator[BetaV2FileUploadParamsExtensionAIAutoDescription]("ai-auto-description"),
475-
)
476-
}
477-
478-
// The property Name is required.
479-
type BetaV2FileUploadParamsExtensionRemoveBg struct {
480-
Options BetaV2FileUploadParamsExtensionRemoveBgOptions `json:"options,omitzero"`
481-
// Specifies the background removal extension.
482-
//
483-
// This field can be elided, and will marshal its zero value as "remove-bg".
484-
Name constant.RemoveBg `json:"name,required"`
485-
paramObj
486-
}
487-
488-
func (r BetaV2FileUploadParamsExtensionRemoveBg) MarshalJSON() (data []byte, err error) {
489-
type shadow BetaV2FileUploadParamsExtensionRemoveBg
490-
return param.MarshalObject(r, (*shadow)(&r))
491-
}
492-
func (r *BetaV2FileUploadParamsExtensionRemoveBg) UnmarshalJSON(data []byte) error {
493-
return apijson.UnmarshalRoot(data, r)
494-
}
495-
496-
type BetaV2FileUploadParamsExtensionRemoveBgOptions struct {
497-
// Whether to add an artificial shadow to the result. Default is false. Note:
498-
// Adding shadows is currently only supported for car photos.
499-
AddShadow param.Opt[bool] `json:"add_shadow,omitzero"`
500-
// Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or
501-
// color name (e.g., "green"). If this parameter is set, `bg_image_url` must be
502-
// empty.
503-
BgColor param.Opt[string] `json:"bg_color,omitzero"`
504-
// Sets a background image from a URL. If this parameter is set, `bg_color` must be
505-
// empty.
506-
BgImageURL param.Opt[string] `json:"bg_image_url,omitzero"`
507-
// Allows semi-transparent regions in the result. Default is true. Note:
508-
// Semitransparency is currently only supported for car windows.
509-
Semitransparency param.Opt[bool] `json:"semitransparency,omitzero"`
510-
paramObj
511-
}
512-
513-
func (r BetaV2FileUploadParamsExtensionRemoveBgOptions) MarshalJSON() (data []byte, err error) {
514-
type shadow BetaV2FileUploadParamsExtensionRemoveBgOptions
515-
return param.MarshalObject(r, (*shadow)(&r))
516-
}
517-
func (r *BetaV2FileUploadParamsExtensionRemoveBgOptions) UnmarshalJSON(data []byte) error {
518-
return apijson.UnmarshalRoot(data, r)
519-
}
520-
521-
// The properties MaxTags, MinConfidence, Name are required.
522-
type BetaV2FileUploadParamsExtensionAutoTagging struct {
523-
// Maximum number of tags to attach to the asset.
524-
MaxTags int64 `json:"maxTags,required"`
525-
// Minimum confidence level for tags to be considered valid.
526-
MinConfidence int64 `json:"minConfidence,required"`
527-
// Specifies the auto-tagging extension used.
528-
//
529-
// Any of "google-auto-tagging", "aws-auto-tagging".
530-
Name string `json:"name,omitzero,required"`
531-
paramObj
532-
}
533-
534-
func (r BetaV2FileUploadParamsExtensionAutoTagging) MarshalJSON() (data []byte, err error) {
535-
type shadow BetaV2FileUploadParamsExtensionAutoTagging
536-
return param.MarshalObject(r, (*shadow)(&r))
537-
}
538-
func (r *BetaV2FileUploadParamsExtensionAutoTagging) UnmarshalJSON(data []byte) error {
539-
return apijson.UnmarshalRoot(data, r)
540-
}
541-
542-
func init() {
543-
apijson.RegisterFieldValidator[BetaV2FileUploadParamsExtensionAutoTagging](
544-
"name", "google-auto-tagging", "aws-auto-tagging",
545-
)
546-
}
547-
548-
func NewBetaV2FileUploadParamsExtensionAIAutoDescription() BetaV2FileUploadParamsExtensionAIAutoDescription {
549-
return BetaV2FileUploadParamsExtensionAIAutoDescription{
550-
Name: "ai-auto-description",
551-
}
552-
}
553-
554-
// This struct has a constant value, construct it with
555-
// [NewBetaV2FileUploadParamsExtensionAIAutoDescription].
556-
type BetaV2FileUploadParamsExtensionAIAutoDescription struct {
557-
// Specifies the auto description extension.
558-
Name constant.AIAutoDescription `json:"name,required"`
559-
paramObj
560-
}
561-
562-
func (r BetaV2FileUploadParamsExtensionAIAutoDescription) MarshalJSON() (data []byte, err error) {
563-
type shadow BetaV2FileUploadParamsExtensionAIAutoDescription
564-
return param.MarshalObject(r, (*shadow)(&r))
565-
}
566-
func (r *BetaV2FileUploadParamsExtensionAIAutoDescription) UnmarshalJSON(data []byte) error {
567-
return apijson.UnmarshalRoot(data, r)
568-
}
569-
570405
// Configure pre-processing (`pre`) and post-processing (`post`) transformations.
571406
//
572407
// - `pre` — applied before the file is uploaded to the Media Library.

betav2file_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/imagekit-developer/imagekit-go"
1414
"github.com/imagekit-developer/imagekit-go/internal/testutil"
1515
"github.com/imagekit-developer/imagekit-go/option"
16+
"github.com/imagekit-developer/imagekit-go/shared"
1617
)
1718

1819
func TestBetaV2FileUploadWithOptionalParams(t *testing.T) {
@@ -40,23 +41,23 @@ func TestBetaV2FileUploadWithOptionalParams(t *testing.T) {
4041
"color": "bar",
4142
},
4243
Description: imagekit.String("Running shoes"),
43-
Extensions: []imagekit.BetaV2FileUploadParamsExtensionUnion{{
44-
OfRemoveBg: &imagekit.BetaV2FileUploadParamsExtensionRemoveBg{
45-
Options: imagekit.BetaV2FileUploadParamsExtensionRemoveBgOptions{
44+
Extensions: shared.ExtensionsParam{shared.ExtensionUnionParam{
45+
OfRemoveBg: &shared.ExtensionRemoveBgParam{
46+
Options: shared.ExtensionRemoveBgOptionsParam{
4647
AddShadow: imagekit.Bool(true),
4748
BgColor: imagekit.String("bg_color"),
4849
BgImageURL: imagekit.String("bg_image_url"),
4950
Semitransparency: imagekit.Bool(true),
5051
},
5152
},
52-
}, {
53-
OfAutoTagging: &imagekit.BetaV2FileUploadParamsExtensionAutoTagging{
53+
}, shared.ExtensionUnionParam{
54+
OfAutoTagging: &shared.ExtensionAutoTaggingParam{
5455
MaxTags: 5,
5556
MinConfidence: 95,
5657
Name: "google-auto-tagging",
5758
},
58-
}, {
59-
OfAIAutoDescription: &imagekit.BetaV2FileUploadParamsExtensionAIAutoDescription{},
59+
}, shared.ExtensionUnionParam{
60+
OfAIAutoDescription: &shared.ExtensionAIAutoDescriptionParam{},
6061
}},
6162
Folder: imagekit.String("folder"),
6263
IsPrivateFile: imagekit.Bool(true),

0 commit comments

Comments
 (0)