@@ -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.
0 commit comments