github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.1.0/pkg/imaging/policy.gen.go (about) 1 package imaging 2 3 import ( 4 "encoding/json" 5 "errors" 6 "fmt" 7 "strings" 8 9 validation "github.com/go-ozzo/ozzo-validation/v4" 10 ) 11 12 type ( 13 // TransformationType is implemented by Transformation types 14 TransformationType interface { 15 transformationType() string 16 } 17 18 // TransformationTypePost is implemented by PostBreakpointTransformations types 19 TransformationTypePost interface { 20 transformationTypePost() string 21 } 22 23 // Transformations represents an array of Transformations 24 Transformations []TransformationType 25 26 // PostBreakpointTransformations represents an array of PostBreakPointTransformations 27 PostBreakpointTransformations []TransformationTypePost 28 29 // ImageType is implemented by ImageType types 30 ImageType interface { 31 imageType() string 32 } 33 34 // ImageTypePost is implemented by ImageTypePost types 35 ImageTypePost interface { 36 imageTypePost() string 37 } 38 39 // ShapeType is implemented by ImageType types 40 ShapeType interface { 41 shapeType() string 42 } 43 44 // InlineVariable represents an inline variable 45 InlineVariable struct { 46 Var string `json:"var"` 47 } 48 49 /*-----------------------------------------------*/ 50 ///////////////// Generated types ///////////////// 51 /*-----------------------------------------------*/ 52 53 // Append Places a specified `image` beside the source image. The API places the `image` on a major dimension, then aligns it on the minor dimension. Transparent pixels fill any area not covered by either image. 54 Append struct { 55 // Gravity Specifies where to place the `image` relative to the source image. The available values represent the eight cardinal directions (`North`, `South`, `East`, `West`, `NorthEast`, `NorthWest`, `SouthEast`, `SouthWest`) and a `Center` by default. 56 Gravity *GravityVariableInline `json:"gravity,omitempty"` 57 // GravityPriority Determines the exact placement of the `image` when `gravity` is `Center` or a diagonal. The value is either `horizontal` or `vertical`. Use `horizontal` to append an `image` east or west of the source image. This aligns the `image` on the vertical gravity component, placing `Center` gravity east. Use `vertical` to append an `image` north or south of the source image. This aligns the `image` on the horizontal gravity component, placing `Center` gravity south. 58 GravityPriority *AppendGravityPriorityVariableInline `json:"gravityPriority,omitempty"` 59 Image ImageType `json:"image"` 60 // PreserveMinorDimension Whether to preserve the source image's minor dimension, `false` by default. The minor dimension is the dimension opposite the dimension that the appending `image` is placed. For example, the dimensions of the source image are 100 × 100 pixels. The dimensions of the appending `image` are 50 × 150 pixels. The `gravity` is set to `East`. This makes the major dimension horizontal and the source image's minor dimension vertical. To preserve the source image's minor dimension at 100 pixels, the `preserveMinorDimension` is set to `true`. As a result of the append, the major dimension expanded with the appended image to 150 pixels. The source image's minor dimension was maintained at 100 pixels. The total combined dimension of the image is 150 × 100 pixels. 61 PreserveMinorDimension *BooleanVariableInline `json:"preserveMinorDimension,omitempty"` 62 // Transformation Identifies this type of transformation, `Append` in this case. 63 Transformation AppendTransformation `json:"transformation"` 64 } 65 66 // AppendGravityPriority ... 67 AppendGravityPriority string 68 69 // AppendGravityPriorityVariableInline represents a type which stores either a value or a variable name 70 AppendGravityPriorityVariableInline struct { 71 Name *string 72 Value *AppendGravityPriority 73 } 74 75 // AppendTransformation ... 76 AppendTransformation string 77 78 // AspectCrop Lets you change the height or width of an image (either by cropping or expanding the area) to an aspect ratio of your choosing. 79 AspectCrop struct { 80 // AllowExpansion Increases the size of the image canvas to achieve the requested aspect ratio instead of cropping the image. Use the Horizontal Offset and Vertical Offset settings to determine where to add the fully transparent pixels on the expanded image canvas. 81 AllowExpansion *BooleanVariableInline `json:"allowExpansion,omitempty"` 82 // Height The height term of the aspect ratio to crop. 83 Height *NumberVariableInline `json:"height,omitempty"` 84 // Transformation Identifies this type of transformation, `AspectCrop` in this case. 85 Transformation AspectCropTransformation `json:"transformation"` 86 // Width The width term of the aspect ratio to crop. 87 Width *NumberVariableInline `json:"width,omitempty"` 88 // XPosition Specifies the horizontal portion of the image you want to keep when the aspect ratio cropping is applied. When using Allow Expansion this setting defines the horizontal position of the image on the new expanded image canvas. 89 XPosition *NumberVariableInline `json:"xPosition,omitempty"` 90 // YPosition Specifies the horizontal portion of the image you want to keep when the aspect ratio cropping is applied. When using Allow Expansion this setting defines the horizontal position of the image on the new expanded image canvas. 91 YPosition *NumberVariableInline `json:"yPosition,omitempty"` 92 } 93 94 // AspectCropTransformation ... 95 AspectCropTransformation string 96 97 // BackgroundColor Places a transparent image on a set background color. Color is specified in the typical CSS hexadecimal format. 98 BackgroundColor struct { 99 // Color The hexadecimal CSS color value for the background. 100 Color *StringVariableInline `json:"color"` 101 // Transformation Identifies this type of transformation, `BackgroundColor` in this case. 102 Transformation BackgroundColorTransformation `json:"transformation"` 103 } 104 105 // BackgroundColorTransformation ... 106 BackgroundColorTransformation string 107 108 // Blur Applies a Gaussian blur to the image. 109 Blur struct { 110 // Sigma The number of pixels to scatter the original pixel by to create the blur effect. Resulting images may be larger than the original as pixels at the edge of the image might scatter outside the image's original dimensions. 111 Sigma *NumberVariableInline `json:"sigma,omitempty"` 112 // Transformation Identifies this type of transformation, `Blur` in this case. 113 Transformation BlurTransformation `json:"transformation"` 114 } 115 116 // BlurTransformation ... 117 BlurTransformation string 118 119 // BooleanVariableInline represents a type which stores either a value or a variable name 120 BooleanVariableInline struct { 121 Name *string 122 Value *bool 123 } 124 125 // BoxImageType A rectangular box, with a specified color and applied transformation. 126 BoxImageType struct { 127 // Color The fill color of the box, not the edge of the box. The API supports hexadecimal representation and CSS hexadecimal color values. 128 Color *StringVariableInline `json:"color,omitempty"` 129 // Height The height of the box in pixels. 130 Height *IntegerVariableInline `json:"height,omitempty"` 131 Transformation TransformationType `json:"transformation,omitempty"` 132 // Type Identifies the type of image, `Box` in this case. 133 Type BoxImageTypeType `json:"type"` 134 // Width The width of the box in pixels. 135 Width *IntegerVariableInline `json:"width,omitempty"` 136 } 137 138 // BoxImageTypePost A rectangular box, with a specified color and applied transformation. 139 BoxImageTypePost struct { 140 // Color The fill color of the box, not the edge of the box. The API supports hexadecimal representation and CSS hexadecimal color values. 141 Color *StringVariableInline `json:"color,omitempty"` 142 // Height The height of the box in pixels. 143 Height *IntegerVariableInline `json:"height,omitempty"` 144 Transformation TransformationTypePost `json:"transformation,omitempty"` 145 // Type Identifies the type of image, `Box` in this case. 146 Type BoxImageTypePostType `json:"type"` 147 // Width The width of the box in pixels. 148 Width *IntegerVariableInline `json:"width,omitempty"` 149 } 150 151 // BoxImageTypePostType ... 152 BoxImageTypePostType string 153 154 // BoxImageTypeType ... 155 BoxImageTypeType string 156 157 // Breakpoints The breakpoint widths (in pixels) to use to create derivative images/videos. 158 Breakpoints struct { 159 Widths []int `json:"widths,omitempty"` 160 } 161 162 // ChromaKey Changes any color in an image within the specified volume of the HSL colorspace to transparent or semitransparent. This transformation applies a 'green screen' technique commonly used to isolate and remove background colors. 163 ChromaKey struct { 164 // Hue The hue to remove. Enter the degree of rotation between 0 and 360 degrees around the color wheel. By default Chroma Key removes a green hue, 120° on the color wheel. 165 Hue *NumberVariableInline `json:"hue,omitempty"` 166 // HueFeather How much additional hue to make semi-transparent beyond the Hue Tolerance. By default Hue Feather is 0.083 which applies semi-transparency to hues 30° around the Hue Tolerance. 167 HueFeather *NumberVariableInline `json:"hueFeather,omitempty"` 168 // HueTolerance How close a color's hue needs to be to the selected hue for it to be changed to fully transparent. If you enter the maximum value of 1.0 the entire image is made transparent. By default Hue Tolerance is approximately 0.083 or 8.3% of the color wheel. This value corresponds to 30° around the specified hue. 169 HueTolerance *NumberVariableInline `json:"hueTolerance,omitempty"` 170 // LightnessFeather How much additional lightness to make semi-transparent beyond the Lightness Tolerance. The default value of 0.1 corresponds to 10% away from the tolerated lightness towards full black or full white. 171 LightnessFeather *NumberVariableInline `json:"lightnessFeather,omitempty"` 172 // LightnessTolerance How much of the lightest part and darkest part of a color to preserve. For example, you can space this value out from the middle (i.e. 0.5 lightness or full color) to help preserve the splash lighting impact in the image. You can define how close the color needs to be to the full color to remove it from your image. The default value of 0.75 means that a colour must be within 75% of the full color to full white or full black for full removal. 173 LightnessTolerance *NumberVariableInline `json:"lightnessTolerance,omitempty"` 174 // SaturationFeather How much additional saturation to make semi-transparent beyond the Saturation Tolerance. By default Saturation Feather is 0.1 which applies semi-transparency to hues 10% below the saturationTolerance. 175 SaturationFeather *NumberVariableInline `json:"saturationFeather,omitempty"` 176 // SaturationTolerance How close a color's saturation needs to be to full saturation for it to be changed to fully transparent. For example, you can define how green the color needs to be to remove it from your image. The default value of 0.75 means that a color must be within 75% of full saturation in order to be made fully transparent. 177 SaturationTolerance *NumberVariableInline `json:"saturationTolerance,omitempty"` 178 // Transformation Identifies this type of transformation, `ChromaKey` in this case. 179 Transformation ChromaKeyTransformation `json:"transformation"` 180 } 181 182 // ChromaKeyTransformation ... 183 ChromaKeyTransformation string 184 185 // CircleImageType A rectangular box, with a specified color and applied transformation. 186 CircleImageType struct { 187 // Color The fill color of the circle. The API supports hexadecimal representation and CSS hexadecimal color values. 188 Color *StringVariableInline `json:"color,omitempty"` 189 // Diameter The diameter of the circle. The diameter will be the width and the height of the image in pixels. 190 Diameter *IntegerVariableInline `json:"diameter,omitempty"` 191 Transformation TransformationType `json:"transformation,omitempty"` 192 // Type Identifies the type of image, `Circle` in this case. 193 Type CircleImageTypeType `json:"type"` 194 // Width The width of the box in pixels. 195 Width *IntegerVariableInline `json:"width,omitempty"` 196 } 197 198 // CircleImageTypePost A rectangular box, with a specified color and applied transformation. 199 CircleImageTypePost struct { 200 // Color The fill color of the circle. The API supports hexadecimal representation and CSS hexadecimal color values. 201 Color *StringVariableInline `json:"color,omitempty"` 202 // Diameter The diameter of the circle. The diameter will be the width and the height of the image in pixels. 203 Diameter *IntegerVariableInline `json:"diameter,omitempty"` 204 Transformation TransformationTypePost `json:"transformation,omitempty"` 205 // Type Identifies the type of image, `Circle` in this case. 206 Type CircleImageTypePostType `json:"type"` 207 // Width The width of the box in pixels. 208 Width *IntegerVariableInline `json:"width,omitempty"` 209 } 210 211 // CircleImageTypePostType ... 212 CircleImageTypePostType string 213 214 // CircleImageTypeType ... 215 CircleImageTypeType string 216 217 // CircleShapeType Defines a circle with a specified `radius` from its `center` point. 218 CircleShapeType struct { 219 // Center Defines coordinates for a single point, to help define polygons and rectangles. Each point may be an object with `x`and `y` members, or a two-element array. 220 Center *PointShapeType `json:"center"` 221 // Radius The radius of the circle measured in pixels. 222 Radius *NumberVariableInline `json:"radius"` 223 } 224 225 // Composite Applies another image to the source image, either as an overlay or an underlay. The image that's underneath is visible in areas that are beyond the edges of the top image or that are less than 100% opaque. A common use of an overlay composite is to add a watermark. 226 Composite struct { 227 // Gravity Compass direction indicating the corner or edge of the base image to place the applied image. Use Horizontal and Vertical Offset to adjust the applied image's gravity position 228 Gravity *GravityVariableInline `json:"gravity,omitempty"` 229 Image ImageType `json:"image"` 230 // Placement Place applied image on top of or underneath the base image. Watermarks are usually applied over. Backgrounds are usually applied under. 231 Placement *CompositePlacementVariableInline `json:"placement,omitempty"` 232 // Scale A multiplier to resize the applied image relative to the source image and preserve aspect ratio, 1 by default. Set the `scaleDimension` to calculate the `scale` from the source image's width or height. 233 Scale *NumberVariableInline `json:"scale,omitempty"` 234 // ScaleDimension The dimension, either `width` or `height`, of the source image to scale. 235 ScaleDimension *CompositeScaleDimensionVariableInline `json:"scaleDimension,omitempty"` 236 // Transformation Identifies this type of transformation, `Composite` in this case. 237 Transformation CompositeTransformation `json:"transformation"` 238 // XPosition The x-axis position of the image to apply. 239 XPosition *IntegerVariableInline `json:"xPosition,omitempty"` 240 // YPosition The y-axis position of the image to apply. 241 YPosition *IntegerVariableInline `json:"yPosition,omitempty"` 242 } 243 244 // CompositePlacement ... 245 CompositePlacement string 246 247 // CompositePlacementVariableInline represents a type which stores either a value or a variable name 248 CompositePlacementVariableInline struct { 249 Name *string 250 Value *CompositePlacement 251 } 252 253 // CompositePost Applies another image to the source image, either as an overlay or an underlay. The image that's underneath is visible in areas that are beyond the edges of the top image or that are less than 100% opaque. A common use of an overlay composite is to add a watermark. 254 CompositePost struct { 255 // Gravity Compass direction indicating the corner or edge of the base image to place the applied image. Use Horizontal and Vertical Offset to adjust the applied image's gravity position 256 Gravity *GravityPostVariableInline `json:"gravity,omitempty"` 257 Image ImageTypePost `json:"image"` 258 // Placement Place applied image on top of or underneath the base image. Watermarks are usually applied over. Backgrounds are usually applied under. 259 Placement *CompositePostPlacementVariableInline `json:"placement,omitempty"` 260 // Scale A multiplier to resize the applied image relative to the source image and preserve aspect ratio, 1 by default. Set the `scaleDimension` to calculate the `scale` from the source image's width or height. 261 Scale *NumberVariableInline `json:"scale,omitempty"` 262 // ScaleDimension The dimension, either `width` or `height`, of the source image to scale. 263 ScaleDimension *CompositePostScaleDimensionVariableInline `json:"scaleDimension,omitempty"` 264 // Transformation Identifies this type of transformation, `Composite` in this case. 265 Transformation CompositePostTransformation `json:"transformation"` 266 // XPosition The x-axis position of the image to apply. 267 XPosition *IntegerVariableInline `json:"xPosition,omitempty"` 268 // YPosition The y-axis position of the image to apply. 269 YPosition *IntegerVariableInline `json:"yPosition,omitempty"` 270 } 271 272 // CompositePostPlacement ... 273 CompositePostPlacement string 274 275 // CompositePostPlacementVariableInline represents a type which stores either a value or a variable name 276 CompositePostPlacementVariableInline struct { 277 Name *string 278 Value *CompositePostPlacement 279 } 280 281 // CompositePostScaleDimension ... 282 CompositePostScaleDimension string 283 284 // CompositePostScaleDimensionVariableInline represents a type which stores either a value or a variable name 285 CompositePostScaleDimensionVariableInline struct { 286 Name *string 287 Value *CompositePostScaleDimension 288 } 289 290 // CompositePostTransformation ... 291 CompositePostTransformation string 292 293 // CompositeScaleDimension ... 294 CompositeScaleDimension string 295 296 // CompositeScaleDimensionVariableInline represents a type which stores either a value or a variable name 297 CompositeScaleDimensionVariableInline struct { 298 Name *string 299 Value *CompositeScaleDimension 300 } 301 302 // CompositeTransformation ... 303 CompositeTransformation string 304 305 // Compound ... 306 Compound struct { 307 // Transformation Identifies this type of transformation, `Compound` in this case. 308 Transformation CompoundTransformation `json:"transformation"` 309 Transformations Transformations `json:"transformations,omitempty"` 310 } 311 312 // CompoundPost ... 313 CompoundPost struct { 314 // Transformation Identifies this type of transformation, `Compound` in this case. 315 Transformation CompoundPostTransformation `json:"transformation"` 316 Transformations PostBreakpointTransformations `json:"transformations,omitempty"` 317 } 318 319 // CompoundPostTransformation ... 320 CompoundPostTransformation string 321 322 // CompoundTransformation ... 323 CompoundTransformation string 324 325 // Contrast Adjusts both the contrast and brightness of an image. 326 Contrast struct { 327 // Brightness Adjusts the brightness of the image. Positive values increase brightness and negative values decrease brightness. A value of `1` produces a white image. A value of `-1` produces a black image. The default value is `0`, which leaves the image unchanged. The acceptable value range is `-1.0` to `1.0`. Values outside of the acceptable range clamp to this range. 328 Brightness *NumberVariableInline `json:"brightness,omitempty"` 329 // Contrast Adjusts the contrast of the image. Expressed as a range from `-1` to `1`, positive values increase contrast, negative values decrease it, while `0` leaves the image unchanged. Values outside of the `-1` to `1` range clamp to this range. 330 Contrast *NumberVariableInline `json:"contrast,omitempty"` 331 // Transformation Identifies this type of transformation, `Contrast` in this case. 332 Transformation ContrastTransformation `json:"transformation"` 333 } 334 335 // ContrastTransformation ... 336 ContrastTransformation string 337 338 // Crop Crops an image. 339 Crop struct { 340 // AllowExpansion If cropping an area outside of the existing canvas, expands the image canvas. 341 AllowExpansion *BooleanVariableInline `json:"allowExpansion,omitempty"` 342 // Gravity Frame of reference for X and Y Positions. 343 Gravity *GravityVariableInline `json:"gravity,omitempty"` 344 // Height The number of pixels to crop along the y-axis. 345 Height *IntegerVariableInline `json:"height"` 346 // Transformation Identifies this type of transformation, `Crop` in this case. 347 Transformation CropTransformation `json:"transformation"` 348 // Width The number of pixels to crop along the x-axis. 349 Width *IntegerVariableInline `json:"width"` 350 // XPosition The x-axis position of the image to crop from. 351 XPosition *IntegerVariableInline `json:"xPosition,omitempty"` 352 // YPosition The y-axis position of the image to crop from. 353 YPosition *IntegerVariableInline `json:"yPosition,omitempty"` 354 } 355 356 // CropTransformation ... 357 CropTransformation string 358 359 // EnumOptions Optionally limits the set of possible values for a variable. References to an enum `id` insert a corresponding `value`. 360 EnumOptions struct { 361 // ID The unique identifier for each enum value, up to 50 alphanumeric characters. 362 ID string `json:"id"` 363 // Value The value of the variable when the `id` is provided. 364 Value string `json:"value"` 365 } 366 367 // FaceCrop Applies a method to detect faces in the source image and applies the rectangular crop on either the `biggest` face or `all` of the faces detected. Image and Video Manager tries to preserve faces in the image instead of using specified crop coordinates. 368 FaceCrop struct { 369 // Algorithm Specifies the type of algorithm used to detect faces in the image, either `cascade` for the cascade classifier algorithm or `dnn` for the deep neural network algorithm, `cascade` by default. 370 Algorithm *FaceCropAlgorithmVariableInline `json:"algorithm,omitempty"` 371 // Confidence With `algorithm` set to `dnn`, specifies the minimum confidence needed to detect faces in the image. Values range from `0` to `1` for increased confidence, and possibly fewer faces detected. 372 Confidence *NumberVariableInline `json:"confidence,omitempty"` 373 // FailGravity Controls placement of the crop if Image and Video Manager does not detect any faces in the image. Directions are relative to the edges of the image being transformed. 374 FailGravity *GravityVariableInline `json:"failGravity,omitempty"` 375 // Focus Distinguishes the faces detected, either `biggestFace` or `allFaces` to place the crop rectangle around the full set of faces, `all` by default. 376 Focus *FaceCropFocusVariableInline `json:"focus,omitempty"` 377 // Gravity Controls placement of the crop. Directions are relative to the face(s) plus padding. 378 Gravity *GravityVariableInline `json:"gravity,omitempty"` 379 // Height The height of the output image in pixels relative to the specified `style` value. 380 Height *IntegerVariableInline `json:"height"` 381 // Padding The padding ratio based on the dimensions of the biggest face detected, `0.5` by default. Larger values increase padding. 382 Padding *NumberVariableInline `json:"padding,omitempty"` 383 // Style Specifies how to crop or scale a crop area for the faces detected in the source image, `zoom` by default. The output image resizes to the specified `width` and `height` values. A value of `crop` places a raw crop around the faces, relative to the specified `gravity` value. A value of `fill` scales the crop area to include as much of the image and faces as possible, relative to the specified `width` and `height` values. A value of `zoom` scales the crop area as small as possible to fit the faces, relative to the specified `width` and `height` values. Allows Variable substitution. 384 Style *FaceCropStyleVariableInline `json:"style,omitempty"` 385 // Transformation Identifies this type of transformation, `FaceCrop` in this case. 386 Transformation FaceCropTransformation `json:"transformation"` 387 // Width The width of the output image in pixels relative to the specified `style` value. 388 Width *IntegerVariableInline `json:"width"` 389 } 390 391 // FaceCropAlgorithm ... 392 FaceCropAlgorithm string 393 394 // FaceCropAlgorithmVariableInline represents a type which stores either a value or a variable name 395 FaceCropAlgorithmVariableInline struct { 396 Name *string 397 Value *FaceCropAlgorithm 398 } 399 400 // FaceCropFocus ... 401 FaceCropFocus string 402 403 // FaceCropFocusVariableInline represents a type which stores either a value or a variable name 404 FaceCropFocusVariableInline struct { 405 Name *string 406 Value *FaceCropFocus 407 } 408 409 // FaceCropStyle ... 410 FaceCropStyle string 411 412 // FaceCropStyleVariableInline represents a type which stores either a value or a variable name 413 FaceCropStyleVariableInline struct { 414 Name *string 415 Value *FaceCropStyle 416 } 417 418 // FaceCropTransformation ... 419 FaceCropTransformation string 420 421 // FeatureCrop Identifies prominent features of the source image, then crops around as many of these features as possible relative to the specified `width` and `height` values. 422 FeatureCrop struct { 423 // FailGravity Controls placement of the crop if Image and Video Manager does not detect any features in the image. Directions are relative to the edges of the image being transformed. 424 FailGravity *GravityVariableInline `json:"failGravity,omitempty"` 425 // FeatureRadius The size in pixels of the important features to search for. If identified, two features never appear closer together than this value, `8.0` by default. 426 FeatureRadius *NumberVariableInline `json:"featureRadius,omitempty"` 427 // Gravity Controls placement of the crop. Directions are relative to the region of interest plus padding. 428 Gravity *GravityVariableInline `json:"gravity,omitempty"` 429 // Height The height in pixels of the output image relative to the specified `style` value. 430 Height *IntegerVariableInline `json:"height"` 431 // MaxFeatures The maximum number of features to identify as important features, `32` by default. The strongest features are always chosen. 432 MaxFeatures *IntegerVariableInline `json:"maxFeatures,omitempty"` 433 // MinFeatureQuality Determines the minimum quality level of the feature identified. To consider a feature important, the feature needs to surpass this value. Image and Video Manager measures quality on a scale from `0` for the lowest quality to `1` for the highest quality, `.1` by default. 434 MinFeatureQuality *NumberVariableInline `json:"minFeatureQuality,omitempty"` 435 // Padding Adds space around the region of interest. The amount of padding added is directly related to the size of the bounding box of the selected features. Specifically, the region of interest is expanded in all directions by the largest dimension of the bounding box of the selected features multiplied by this value. 436 Padding *NumberVariableInline `json:"padding,omitempty"` 437 // Style Specifies how to crop or scale a crop area for the features identified in the source image, `fill` by default. The output image resizes to the specified `width` and `height` values. A value of `crop` performs a raw crop around the features, relative to the specified `gravity` value. A value of `fill` scales the crop area to include as much of the image and features as possible, relative to the specified `width` and `height` values. A value of `zoom` scales the crop area as small as possible to fit the features, relative to the specified `width` and `height` values. Allows Variable substitution. 438 Style *FeatureCropStyleVariableInline `json:"style,omitempty"` 439 // Transformation Identifies this type of transformation, `FeatureCrop` in this case. 440 Transformation FeatureCropTransformation `json:"transformation"` 441 // Width The width in pixels of the output image relative to the specified `style` value. 442 Width *IntegerVariableInline `json:"width"` 443 } 444 445 // FeatureCropStyle ... 446 FeatureCropStyle string 447 448 // FeatureCropStyleVariableInline represents a type which stores either a value or a variable name 449 FeatureCropStyleVariableInline struct { 450 Name *string 451 Value *FeatureCropStyle 452 } 453 454 // FeatureCropTransformation ... 455 FeatureCropTransformation string 456 457 // FitAndFill Resizes an image to fit within a specific size box and then uses a fill of that same image to cover any transparent space at the edges. By default the fill image has a Blur transformation with a sigma value of 8 applied, but the transformation can be customized using the fillTransformation parameter. 458 FitAndFill struct { 459 FillTransformation TransformationType `json:"fillTransformation,omitempty"` 460 // Height The height value of the resized image. 461 Height *IntegerVariableInline `json:"height"` 462 // Transformation Identifies this type of transformation, `FitAndFill` in this case. 463 Transformation FitAndFillTransformation `json:"transformation"` 464 // Width The width value of the resized image. 465 Width *IntegerVariableInline `json:"width"` 466 } 467 468 // FitAndFillTransformation ... 469 FitAndFillTransformation string 470 471 // Goop Distorts an image by randomly repositioning a set of control points along a specified grid. The transformed image appears _goopy_. Adjust the density of the grid and the degree of randomity. You can use this transformation to create watermarks for use in security. 472 Goop struct { 473 // Chaos Specifies the greatest distance control points may move from their original position. A value of `1.0` shifts control points over as far as the next one in the original grid. A value of `0.0` leaves the image unchanged. Values under `0.5` work better for subtle distortions, otherwise control points may pass each other and cause a twisting effect. 474 Chaos *NumberVariableInline `json:"chaos,omitempty"` 475 // Density Controls the density of control points used to distort the image. The largest dimension of the input image is divided up to fit this number of control points. A grid of points is extended on the smaller dimension such that each row and column of control points is equidistant from each adjacent row or column. This parameter strongly affects transformation performance. Be careful choosing values above the default if you expect to transform medium to large size images. 476 Density *IntegerVariableInline `json:"density,omitempty"` 477 // Power By default, the distortion algorithm relies on inverse squares to calculate distance but this allows you to change the exponent. You shouldnt need to vary the default value of `2.0`. 478 Power *NumberVariableInline `json:"power,omitempty"` 479 // Seed Specifies your own `seed` value as an alternative to the default, which is subject to variability. This allows for reproducible and deterministic distortions. If all parameters are kept equal and a constant seed is used, `Goop` distorts an input image consistently over many transformations. By default, this value is set to the current Epoch Time measured in milliseconds, which provides inconsistent transformation output. 480 Seed *IntegerVariableInline `json:"seed,omitempty"` 481 // Transformation Identifies this type of transformation, `Goop` in this case. 482 Transformation GoopTransformation `json:"transformation"` 483 } 484 485 // GoopTransformation ... 486 GoopTransformation string 487 488 // Gravity ... 489 Gravity string 490 491 // GravityPost ... 492 GravityPost string 493 494 // GravityPostVariableInline represents a type which stores either a value or a variable name 495 GravityPostVariableInline struct { 496 Name *string 497 Value *GravityPost 498 } 499 500 // GravityVariableInline represents a type which stores either a value or a variable name 501 GravityVariableInline struct { 502 Name *string 503 Value *Gravity 504 } 505 506 // Grayscale Restricts image color to shades of gray only. 507 Grayscale struct { 508 // Transformation Identifies this type of transformation, `Grayscale` in this case. 509 Transformation GrayscaleTransformation `json:"transformation"` 510 // Type The algorithm used to transform colors to grays, either `Brightness`, `Lightness`, `Rec601`, or the default `Rec709`. 511 Type *GrayscaleTypeVariableInline `json:"type,omitempty"` 512 } 513 514 // GrayscaleTransformation ... 515 GrayscaleTransformation string 516 517 // GrayscaleType ... 518 GrayscaleType string 519 520 // GrayscaleTypeVariableInline represents a type which stores either a value or a variable name 521 GrayscaleTypeVariableInline struct { 522 Name *string 523 Value *GrayscaleType 524 } 525 526 // HSL Adjusts the hue, saturation, and lightness (HSL) of an image. Hue is the number of degrees that colors rotate around the color wheel. Saturation is a multiplier to increase or decrease color saturation. Lightness is a multiplier to increase or decrease the lightness of an image. Other transformations can also affect color, such as `Grayscale` and `MaxColors`. If youre using more than one, consider the order to apply them for the desired results. 527 HSL struct { 528 // Hue The number of degrees to rotate colors around the color wheel, `0` by default. 529 Hue *NumberVariableInline `json:"hue,omitempty"` 530 // Lightness A multiplier to adjust the lightness of colors in the image. Note that lightness is distinct from brightness. For example, reducing the lightness of a light green might give you a lime green whereas reducing the brightness of a light green might give you a darker shade of the same green. Values less than `1.0` decrease the lightness of colors in the image. Values greater than `1.0` increase the lightness of colors in the image. 531 Lightness *NumberVariableInline `json:"lightness,omitempty"` 532 // Saturation A multiplier to adjust the saturation of colors in the image. Values less than `1.0` decrease saturation and values greater than `1.0` increase the saturation. A value of `0.0` removes all color from the image. 533 Saturation *NumberVariableInline `json:"saturation,omitempty"` 534 // Transformation Identifies this type of transformation, `HSL` in this case. 535 Transformation HSLTransformation `json:"transformation"` 536 } 537 538 // HSLTransformation ... 539 HSLTransformation string 540 541 // HSV Identical to HSL except it replaces `lightness` with `value`. For example, if you reduce the `lightness` of a light green, almost white, image, the color turns a vibrant green. Reducing the `value` turns the image a darker color, close to grey. This happens because the original image color is very close to white. 542 HSV struct { 543 // Hue The number of degrees to rotate colors around the color wheel, `0.0` by default. 544 Hue *NumberVariableInline `json:"hue,omitempty"` 545 // Saturation A multiplier to adjust the saturation of colors in the image. Values less than `1.0` decrease saturation and values greater than `1.0` increase the saturation. A value of `0.0` removes all color from the image. 546 Saturation *NumberVariableInline `json:"saturation,omitempty"` 547 // Transformation Identifies this type of transformation, `HSV` in this case. 548 Transformation HSVTransformation `json:"transformation"` 549 // Value A multiplier to adjust the lightness or darkness of the images base color. Values less than 1.0 decrease the base colors in the image, making them appear darker. Values greater than 1.0 increase the base colors in the image, making them appear lighter. 550 Value *NumberVariableInline `json:"value,omitempty"` 551 } 552 553 // HSVTransformation ... 554 HSVTransformation string 555 556 // IfDimension ... 557 IfDimension struct { 558 Default TransformationType `json:"default,omitempty"` 559 // Dimension The dimension to use to select the transformation, either `height`, `width`, or `both`. 560 Dimension *IfDimensionDimensionVariableInline `json:"dimension,omitempty"` 561 Equal TransformationType `json:"equal,omitempty"` 562 GreaterThan TransformationType `json:"greaterThan,omitempty"` 563 LessThan TransformationType `json:"lessThan,omitempty"` 564 // Transformation Identifies this type of transformation, `IfDimension` in this case. 565 Transformation IfDimensionTransformation `json:"transformation"` 566 // Value The value to compare against the source image dimension. For example, if the image dimension is less than the value the lessThan transformation is applied. 567 Value *IntegerVariableInline `json:"value"` 568 } 569 570 // IfDimensionDimension ... 571 IfDimensionDimension string 572 573 // IfDimensionDimensionVariableInline represents a type which stores either a value or a variable name 574 IfDimensionDimensionVariableInline struct { 575 Name *string 576 Value *IfDimensionDimension 577 } 578 579 // IfDimensionPost ... 580 IfDimensionPost struct { 581 Default TransformationTypePost `json:"default,omitempty"` 582 // Dimension The dimension to use to select the transformation, either `height`, `width`, or `both`. 583 Dimension *IfDimensionPostDimensionVariableInline `json:"dimension,omitempty"` 584 Equal TransformationTypePost `json:"equal,omitempty"` 585 GreaterThan TransformationTypePost `json:"greaterThan,omitempty"` 586 LessThan TransformationTypePost `json:"lessThan,omitempty"` 587 // Transformation Identifies this type of transformation, `IfDimension` in this case. 588 Transformation IfDimensionPostTransformation `json:"transformation"` 589 // Value The value to compare against the source image dimension. For example, if the image dimension is less than the value the lessThan transformation is applied. 590 Value *IntegerVariableInline `json:"value"` 591 } 592 593 // IfDimensionPostDimension ... 594 IfDimensionPostDimension string 595 596 // IfDimensionPostDimensionVariableInline represents a type which stores either a value or a variable name 597 IfDimensionPostDimensionVariableInline struct { 598 Name *string 599 Value *IfDimensionPostDimension 600 } 601 602 // IfDimensionPostTransformation ... 603 IfDimensionPostTransformation string 604 605 // IfDimensionTransformation ... 606 IfDimensionTransformation string 607 608 // IfOrientation ... 609 IfOrientation struct { 610 Default TransformationType `json:"default,omitempty"` 611 Landscape TransformationType `json:"landscape,omitempty"` 612 Portrait TransformationType `json:"portrait,omitempty"` 613 Square TransformationType `json:"square,omitempty"` 614 // Transformation Identifies this type of transformation, `IfOrientation` in this case. 615 Transformation IfOrientationTransformation `json:"transformation"` 616 } 617 618 // IfOrientationPost ... 619 IfOrientationPost struct { 620 Default TransformationTypePost `json:"default,omitempty"` 621 Landscape TransformationTypePost `json:"landscape,omitempty"` 622 Portrait TransformationTypePost `json:"portrait,omitempty"` 623 Square TransformationTypePost `json:"square,omitempty"` 624 // Transformation Identifies this type of transformation, `IfOrientation` in this case. 625 Transformation IfOrientationPostTransformation `json:"transformation"` 626 } 627 628 // IfOrientationPostTransformation ... 629 IfOrientationPostTransformation string 630 631 // IfOrientationTransformation ... 632 IfOrientationTransformation string 633 634 // ImQuery Apply artistic transformations to images quickly and dynamically by specifying transformations with a query string appendedto the image URL. 635 ImQuery struct { 636 // AllowedTransformations Specifies the transformations that can be applied using the query string parameter. 637 AllowedTransformations []ImQueryAllowedTransformations `json:"allowedTransformations"` 638 Query *QueryVariableInline `json:"query"` 639 // Transformation Identifies this type of transformation, `ImQuery` in this case. 640 Transformation ImQueryTransformation `json:"transformation"` 641 } 642 643 // ImQueryAllowedTransformations ... 644 ImQueryAllowedTransformations string 645 646 // ImQueryTransformation ... 647 ImQueryTransformation string 648 649 // IntegerVariableInline represents a type which stores either a value or a variable name 650 IntegerVariableInline struct { 651 Name *string 652 Value *int 653 } 654 655 // MaxColors Set the maximum number of colors in the images palette. Reducing the number of colors in an image can help to reduce file size. 656 MaxColors struct { 657 // Colors The value representing the maximum number of colors to use with the source image. 658 Colors *IntegerVariableInline `json:"colors"` 659 // Transformation Identifies this type of transformation, `MaxColors` in this case. 660 Transformation MaxColorsTransformation `json:"transformation"` 661 } 662 663 // MaxColorsTransformation ... 664 MaxColorsTransformation string 665 666 // Mirror Flips an image horizontally, vertically, or both. 667 Mirror struct { 668 // Horizontal Flips the image horizontally. 669 Horizontal *BooleanVariableInline `json:"horizontal,omitempty"` 670 // Transformation Identifies this type of transformation, `Mirror` in this case. 671 Transformation MirrorTransformation `json:"transformation"` 672 // Vertical Flips the image vertically. 673 Vertical *BooleanVariableInline `json:"vertical,omitempty"` 674 } 675 676 // MirrorTransformation ... 677 MirrorTransformation string 678 679 // MonoHue Allows you to set all hues in an image to a single specified hue of your choosing. Mono Hue maintains the original color’s lightness and saturation but sets the hue to that of the specified value. This has the effect of making the image shades of the specified hue. 680 MonoHue struct { 681 // Hue Specify a hue by indicating the degree of rotation between 0 and 360 degrees around the color wheel. By default Mono Hue applies a red hue, 0.0 on the color wheel. 682 Hue *NumberVariableInline `json:"hue,omitempty"` 683 // Transformation Identifies this type of transformation, `MonoHue` in this case. 684 Transformation MonoHueTransformation `json:"transformation"` 685 } 686 687 // MonoHueTransformation ... 688 MonoHueTransformation string 689 690 // NumberVariableInline represents a type which stores either a value or a variable name 691 NumberVariableInline struct { 692 Name *string 693 Value *float64 694 } 695 696 // Opacity Adjusts the level of transparency of an image. Use this transformation to make an image more or less transparent. 697 Opacity struct { 698 // Opacity Represents alpha values on a scale of `0` to `1`. Values below `1` increase transparency, and `0` is invisible. For images that have some transparency, values above `1` increase the opacity of the transparent portions. 699 Opacity *NumberVariableInline `json:"opacity"` 700 // Transformation Identifies this type of transformation, `Opacity` in this case. 701 Transformation OpacityTransformation `json:"transformation"` 702 } 703 704 // OpacityTransformation ... 705 OpacityTransformation string 706 707 // OutputImage Dictates the output quality (either `quality` or `perceptualQuality`) and formats that are created for each resized image. If unspecified, image formats are created to support all browsers at the default quality level (`85`), which includes formats such as WEBP, JPEG2000 and JPEG-XR for specific browsers. 708 OutputImage struct { 709 // AdaptiveQuality Override the quality of image to serve when Image & Video Manager detects a slow connection. Specifying lower values lets users with slow connections browse your site with reduced load times without impacting the quality of images for users with faster connections. 710 AdaptiveQuality *int `json:"adaptiveQuality,omitempty"` 711 // AllowPristineOnDownsize Whether a pristine image wider than the requested breakpoint is allowed as a derivative image if it has the fewest bytes. This will not have an affect if transformations are present. 712 AllowPristineOnDownsize *bool `json:"allowPristineOnDownsize,omitempty"` 713 // AllowedFormats The graphics file formats allowed for browser specific results. 714 AllowedFormats []OutputImageAllowedFormats `json:"allowedFormats,omitempty"` 715 // ForcedFormats The forced extra formats for the `imFormat` query parameter, which requests a specific browser type. By default, Image and Video Manager detects the browser and returns the appropriate image. 716 ForcedFormats []OutputImageForcedFormats `json:"forcedFormats,omitempty"` 717 // PerceptualQuality Mutually exclusive with quality. The perceptual quality to use when comparing resulting images, which overrides the `quality` setting. Perceptual quality tunes each image format's quality parameter dynamically based on the human-perceived quality of the output image. This can result in better byte savings (as compared to using regular quality) as many images can be encoded at a much lower quality without compromising perception of the image. In addition, certain images may need to be encoded at a slightly higher quality in order to maintain human-perceived quality. Values are tiered `high`, `mediumHigh`, `medium`, `mediumLow`, or `low`. 718 PerceptualQuality *OutputImagePerceptualQualityVariableInline `json:"perceptualQuality,omitempty"` 719 // PerceptualQualityFloor Only applies with perceptualQuality set. Sets a minimum image quality to respect when using perceptual quality. Perceptual quality will not reduce the quality below this value even if it determines the compressed image to be acceptably visually similar. 720 PerceptualQualityFloor *int `json:"perceptualQualityFloor,omitempty"` 721 // PreferModernFormats Whether derivative image formats should be selected with a preference for modern formats (such as WebP and Avif) instead the format that results in the fewest bytes. 722 PreferModernFormats *bool `json:"preferModernFormats,omitempty"` 723 // Quality Mutually exclusive with perceptualQuality, used by default if neither is specified. The chosen quality of the output images. Using a quality value from 1-100 resembles JPEG quality across output formats. 724 Quality *IntegerVariableInline `json:"quality,omitempty"` 725 } 726 727 // OutputImageAllowedFormats ... 728 OutputImageAllowedFormats string 729 730 // OutputImageForcedFormats ... 731 OutputImageForcedFormats string 732 733 // OutputImagePerceptualQuality ... 734 OutputImagePerceptualQuality string 735 736 // OutputImagePerceptualQualityVariableInline represents a type which stores either a value or a variable name 737 OutputImagePerceptualQualityVariableInline struct { 738 Name *string 739 Value *OutputImagePerceptualQuality 740 } 741 742 // PointShapeType Defines coordinates for a single point, to help define polygons and rectangles. Each point may be an object with `x`and `y` members, or a two-element array. 743 PointShapeType struct { 744 // X The horizontal position of the point, measured in pixels. 745 X *NumberVariableInline `json:"x"` 746 // Y The vertical position of the point, measured in pixels. 747 Y *NumberVariableInline `json:"y"` 748 } 749 750 // PolicyOutputImage Specifies details for each policy, such as transformations to apply and variations in image size and formats. 751 PolicyOutputImage struct { 752 // Breakpoints The breakpoint widths (in pixels) to use to create derivative images/videos. 753 Breakpoints *Breakpoints `json:"breakpoints,omitempty"` 754 // DateCreated Date this policy version was created in ISO 8601 extended notation format. 755 DateCreated string `json:"dateCreated"` 756 // Hosts Hosts that are allowed for image/video URLs within transformations or variables. 757 Hosts []string `json:"hosts,omitempty"` 758 // ID Unique identifier for a policy, up to 64 alphanumeric characters including underscores or dashes. 759 ID string `json:"id"` 760 // Output Dictates the output quality (either `quality` or `perceptualQuality`) and formats that are created for each resized image. If unspecified, image formats are created to support all browsers at the default quality level (`85`), which includes formats such as WEBP, JPEG2000 and JPEG-XR for specific browsers. 761 Output *OutputImage `json:"output,omitempty"` 762 // PostBreakpointTransformations Post-processing Transformations are applied to the image after image and quality settings have been applied. 763 PostBreakpointTransformations PostBreakpointTransformations `json:"postBreakpointTransformations,omitempty"` 764 // PreviousVersion The previous version number of this policy version 765 PreviousVersion int `json:"previousVersion"` 766 // RolloutInfo Contains information about policy rollout start and completion times. 767 RolloutInfo *RolloutInfo `json:"rolloutInfo"` 768 // Transformations Set of image transformations to apply to the source image. If unspecified, no operations are performed. 769 Transformations Transformations `json:"transformations,omitempty"` 770 // User The user who created this policy version 771 User string `json:"user"` 772 // Variables Declares variables for use within the policy. Any variable declared here can be invoked throughout transformations as a [Variable](#variable) object, so that you don't have to specify values separately. You can also pass in these variable names and values dynamically as query parameters in the image's request URL. 773 Variables []Variable `json:"variables,omitempty"` 774 // Version The version number of this policy version 775 Version int `json:"version"` 776 // Video Identifies this as an image policy. 777 Video *bool `json:"video,omitempty"` 778 } 779 780 // PolicyOutputImageVideo ... 781 PolicyOutputImageVideo bool 782 783 // PolygonShapeType Defines a polygon from a series of connected points. 784 PolygonShapeType struct { 785 // Points Series of [PointShapeType](#pointshapetype) objects. The last and first points connect to close the shape automatically. 786 Points []PointShapeType `json:"points"` 787 } 788 789 // QueryVariableInline represents a type which stores either a value or a variable name 790 QueryVariableInline struct { 791 Name *string 792 } 793 794 // RectangleShapeType Defines a rectangle's `width` and `height` relative to an `anchor` point at the top left corner. 795 RectangleShapeType struct { 796 Anchor *PointShapeType `json:"anchor"` 797 // Height Extends the rectangle down from the `anchor` point. 798 Height *NumberVariableInline `json:"height"` 799 // Width Extends the rectangle right from the `anchor` point. 800 Width *NumberVariableInline `json:"width"` 801 } 802 803 // RegionOfInterestCrop Crops to a region around a specified area of interest relative to the specified `width` and `height` values. 804 RegionOfInterestCrop struct { 805 // Gravity The placement of the crop area relative to the specified area of interest. 806 Gravity *GravityVariableInline `json:"gravity,omitempty"` 807 // Height The height in pixels of the output image relative to the specified `style` value. 808 Height *IntegerVariableInline `json:"height"` 809 RegionOfInterest ShapeType `json:"regionOfInterest"` 810 // Style Specifies how to crop or scale a crop area for the specified area of interest in the source image, `zoom` by default. The output image resizes to the specified `width` and `height` values. A value of `crop` places raw crop around the point of interest, relative to the specified `gravity` value. A value of `fill` scales the crop area to include as much of the image and point of interest as possible, relative to the specified `width` and `height` values. A value of `zoom` scales the crop area as small as possible to fit the point of interest, relative to the specified `width` and `height` values. 811 Style *RegionOfInterestCropStyleVariableInline `json:"style,omitempty"` 812 // Transformation Identifies this type of transformation, `RegionOfInterestCrop` in this case. 813 Transformation RegionOfInterestCropTransformation `json:"transformation"` 814 // Width The width in pixels of the output image relative to the specified `style` value. 815 Width *IntegerVariableInline `json:"width"` 816 } 817 818 // RegionOfInterestCropStyle ... 819 RegionOfInterestCropStyle string 820 821 // RegionOfInterestCropStyleVariableInline represents a type which stores either a value or a variable name 822 RegionOfInterestCropStyleVariableInline struct { 823 Name *string 824 Value *RegionOfInterestCropStyle 825 } 826 827 // RegionOfInterestCropTransformation ... 828 RegionOfInterestCropTransformation string 829 830 // RelativeCrop Shrinks or expands an image relative to the image's specified dimensions. Image and Video Manager fills the expanded areas with transparency. Positive values shrink the side, while negative values expand it. 831 RelativeCrop struct { 832 // East The number of pixels to shrink or expand the right side of the image. 833 East *IntegerVariableInline `json:"east,omitempty"` 834 // North The number of pixels to shrink or expand the top side of the image. 835 North *IntegerVariableInline `json:"north,omitempty"` 836 // South The number of pixels to shrink or expand the bottom side of the image. 837 South *IntegerVariableInline `json:"south,omitempty"` 838 // Transformation Identifies this type of transformation, `RelativeCrop` in this case. 839 Transformation RelativeCropTransformation `json:"transformation"` 840 // West The number of pixels to shrink or expand the left side of the image. 841 West *IntegerVariableInline `json:"west,omitempty"` 842 } 843 844 // RelativeCropTransformation ... 845 RelativeCropTransformation string 846 847 // RemoveColor Removes a specified color from an image and replaces it with transparent pixels. This transformation is ideal for removing solid background colors from product images photographed on clean, consistent backgrounds without any shadows. 848 RemoveColor struct { 849 // Color The hexadecimal CSS color value to remove. 850 Color *StringVariableInline `json:"color"` 851 // Feather The RemoveColor transformation may create a hard edge around an image. To minimize these hard edges and make the removal of the color more gradual in appearance, use the Feather option. This option allows you to extend the color removal beyond the specified Tolerance. The pixels in this extended tolerance become semi-transparent - creating a softer edge. The first realtime request for an image using the feather option may result in a slow transformation time. Subsequent requests are not impacted as they are served directly out of cache. 852 Feather *NumberVariableInline `json:"feather,omitempty"` 853 // Tolerance The Tolerance option defines how close the color needs to be to the selected color before it's changed to fully transparent. Set the Tolerance to 0.0 to remove only the exact color specified. 854 Tolerance *NumberVariableInline `json:"tolerance,omitempty"` 855 // Transformation Identifies this type of transformation, `RemoveColor` in this case. 856 Transformation RemoveColorTransformation `json:"transformation"` 857 } 858 859 // RemoveColorTransformation ... 860 RemoveColorTransformation string 861 862 // Resize Resizes an image to a particular, absolute dimension. If you don't enter a `width` or a `height`, the image is resized with the `fit` aspect preservation mode, which selects a value for the missing dimension that preserves the image's aspect. 863 Resize struct { 864 // Aspect Preserves the aspect ratio. Select `fit` to make the image fit entirely within the selected width and height. When using `fit`, the resulting image has the largest possible size for the specified dimensions. Select `fill` to size the image so it both completely fills the dimensions and has the smallest possible file size. Otherwise `ignore` changes the original aspect ratio to fit within an arbitrarily shaped rectangle. 865 Aspect *ResizeAspectVariableInline `json:"aspect,omitempty"` 866 // Height The height to resize the source image to. Must be set if height is not specified. 867 Height *IntegerVariableInline `json:"height,omitempty"` 868 // Transformation Identifies this type of transformation, `Resize` in this case. 869 Transformation ResizeTransformation `json:"transformation"` 870 // Type Sets constraints for the image resize. Select `normal` to resize in all cases, either increasing or decreasing the dimensions. Select `downsize` to ignore this transformation if the result would be larger than the original. Select `upsize` to ignore this transformation if the result would be smaller. 871 Type *ResizeTypeVariableInline `json:"type,omitempty"` 872 // Width The width to resize the source image to. Must be set if width is not specified. 873 Width *IntegerVariableInline `json:"width,omitempty"` 874 } 875 876 // ResizeAspect ... 877 ResizeAspect string 878 879 // ResizeAspectVariableInline represents a type which stores either a value or a variable name 880 ResizeAspectVariableInline struct { 881 Name *string 882 Value *ResizeAspect 883 } 884 885 // ResizeTransformation ... 886 ResizeTransformation string 887 888 // ResizeType ... 889 ResizeType string 890 891 // ResizeTypeVariableInline represents a type which stores either a value or a variable name 892 ResizeTypeVariableInline struct { 893 Name *string 894 Value *ResizeType 895 } 896 897 // RolloutInfo Contains information about policy rollout start and completion times. 898 RolloutInfo struct { 899 // EndTime The estimated time that rollout for this policy will end. Value is a unix timestamp. 900 EndTime int `json:"endTime"` 901 // RolloutDuration The amount of time in seconds that the policy takes to rollout. During the rollout an increasing proportion of images/videos will begin to use the new policy instead of the cached images/videos from the previous version. Policies on the staging network deploy as quickly as possible without rollout. For staging policies this value will always be 1. 902 RolloutDuration int `json:"rolloutDuration"` 903 // ServeStaleEndTime The estimated time that serving stale for this policy will end. Value is a unix timestamp. 904 ServeStaleEndTime *int `json:"serveStaleEndTime,omitempty"` 905 // StartTime The estimated time that rollout for this policy will begin. Value is a unix timestamp. 906 StartTime int `json:"startTime"` 907 } 908 909 // Rotate Rotate the image around its center by indicating the degrees of rotation. 910 Rotate struct { 911 // Degrees The value to rotate the image by. Positive values rotate clockwise, while negative values rotate counter-clockwise. 912 Degrees *NumberVariableInline `json:"degrees"` 913 // Transformation Identifies this type of transformation, `Rotate` in this case. 914 Transformation RotateTransformation `json:"transformation"` 915 } 916 917 // RotateTransformation ... 918 RotateTransformation string 919 920 // Scale Changes the image's size to different dimensions relative to its starting size. 921 Scale struct { 922 // Height Scaling factor for the input height to determine the output height of the image, where values between `0` and `1` decrease size. Image dimensions need to be non-zero positive numbers. 923 Height *NumberVariableInline `json:"height"` 924 // Transformation Identifies this type of transformation, `Scale` in this case. 925 Transformation ScaleTransformation `json:"transformation"` 926 // Width Scaling factor for the input width to determine the output width of the image, where `1` leaves the width unchanged. Values greater than `1` increase the image size. Image dimensions need to be non-zero positive numbers. 927 Width *NumberVariableInline `json:"width"` 928 } 929 930 // ScaleTransformation ... 931 ScaleTransformation string 932 933 // Shear Slants an image into a parallelogram, as a percent of the starting dimension as represented in decimal format. You need to specify at least one axis property. Transparent pixels fill empty areas around the sheared image as needed, so it's often useful to use a `BackgroundColor` transformation for these areas. 934 Shear struct { 935 // Transformation Identifies this type of transformation, `Shear` in this case. 936 Transformation ShearTransformation `json:"transformation"` 937 // XShear The amount to shear along the x-axis, measured in multiples of the image's width. Must be set if yShear is not specified. 938 XShear *NumberVariableInline `json:"xShear,omitempty"` 939 // YShear The amount to shear along the y-axis, measured in multiples of the image's height. Must be set if xShear is not specified. 940 YShear *NumberVariableInline `json:"yShear,omitempty"` 941 } 942 943 // ShearTransformation ... 944 ShearTransformation string 945 946 // SmartCrop Crops around whatever is most important in the image, to a region around a specified area of interest relative to the specified `width` and `height` values. The crop detects any faces present, otherwise features. 947 SmartCrop struct { 948 // Debug When enabled, the SmartCrop transformation doesn't actually execute. Instead, it outlines found faces or features, the region of interest, and the crop area. 949 Debug *BooleanVariableInline `json:"debug,omitempty"` 950 // Height The height in pixels of the output image relative to the specified `style` value. 951 Height *IntegerVariableInline `json:"height,omitempty"` 952 // Sloppy Whether to sacrifice any image fidelity for transformation performance. 953 Sloppy *BooleanVariableInline `json:"sloppy,omitempty"` 954 // Style Specifies how to crop or scale a crop area for the specified area of interest in the source image, `fill` by default. The output image resizes to the specified `width` and `height` values. A value of `crop` places raw crop around the point of interest. A value of `fill` scales the crop area to include as much of the image and point of interest as possible, relative to the specified `width` and `height` values. A value of `zoom` scales the crop area as small as possible to fit the point of interest, relative to the specified `width` and `height` values. 955 Style *SmartCropStyleVariableInline `json:"style,omitempty"` 956 // Transformation Identifies this type of transformation, `SmartCrop` in this case. 957 Transformation SmartCropTransformation `json:"transformation"` 958 // Width The width in pixels of the output image relative to the specified `style` value. 959 Width *IntegerVariableInline `json:"width,omitempty"` 960 } 961 962 // SmartCropStyle ... 963 SmartCropStyle string 964 965 // SmartCropStyleVariableInline represents a type which stores either a value or a variable name 966 SmartCropStyleVariableInline struct { 967 Name *string 968 Value *SmartCropStyle 969 } 970 971 // SmartCropTransformation ... 972 SmartCropTransformation string 973 974 // StringVariableInline represents a type which stores either a value or a variable name 975 StringVariableInline struct { 976 Name *string 977 Value *string 978 } 979 980 // TextImageType A snippet of text. Defines font family and size, fill color, and outline stroke width and color. 981 TextImageType struct { 982 // Fill The main fill color of the text. 983 Fill *StringVariableInline `json:"fill,omitempty"` 984 // Size The size in pixels to render the text. 985 Size *NumberVariableInline `json:"size,omitempty"` 986 // Stroke The color for the outline of the text. 987 Stroke *StringVariableInline `json:"stroke,omitempty"` 988 // StrokeSize The thickness in points for the outline of the text. 989 StrokeSize *NumberVariableInline `json:"strokeSize,omitempty"` 990 // Text The line of text to render. 991 Text *StringVariableInline `json:"text"` 992 Transformation TransformationType `json:"transformation,omitempty"` 993 // Type Identifies the type of image, `Text` in this case. 994 Type TextImageTypeType `json:"type"` 995 // Typeface The font family to apply to the text image. This may be a URL to a TrueType or WOFF (v1) typeface, or a string that refers to one of the standard built-in browser fonts. 996 Typeface *StringVariableInline `json:"typeface,omitempty"` 997 } 998 999 // TextImageTypePost A snippet of text. Defines font family and size, fill color, and outline stroke width and color. 1000 TextImageTypePost struct { 1001 // Fill The main fill color of the text. 1002 Fill *StringVariableInline `json:"fill,omitempty"` 1003 // Size The size in pixels to render the text. 1004 Size *NumberVariableInline `json:"size,omitempty"` 1005 // Stroke The color for the outline of the text. 1006 Stroke *StringVariableInline `json:"stroke,omitempty"` 1007 // StrokeSize The thickness in points for the outline of the text. 1008 StrokeSize *NumberVariableInline `json:"strokeSize,omitempty"` 1009 // Text The line of text to render. 1010 Text *StringVariableInline `json:"text"` 1011 Transformation TransformationTypePost `json:"transformation,omitempty"` 1012 // Type Identifies the type of image, `Text` in this case. 1013 Type TextImageTypePostType `json:"type"` 1014 // Typeface The font family to apply to the text image. This may be a URL to a TrueType or WOFF (v1) typeface, or a string that refers to one of the standard built-in browser fonts. 1015 Typeface *StringVariableInline `json:"typeface,omitempty"` 1016 } 1017 1018 // TextImageTypePostType ... 1019 TextImageTypePostType string 1020 1021 // TextImageTypeType ... 1022 TextImageTypeType string 1023 1024 // Trim Automatically crops uniform backgrounds from the edges of an image. 1025 Trim struct { 1026 // Fuzz The fuzz tolerance of the trim, a value between `0` and `1` that determines the acceptable amount of background variation before trimming stops. 1027 Fuzz *NumberVariableInline `json:"fuzz,omitempty"` 1028 // Padding The amount of padding in pixels to add to the trimmed image. 1029 Padding *IntegerVariableInline `json:"padding,omitempty"` 1030 // Transformation Identifies this type of transformation, `Trim` in this case. 1031 Transformation TrimTransformation `json:"transformation"` 1032 } 1033 1034 // TrimTransformation ... 1035 TrimTransformation string 1036 1037 // URLImageType An image loaded from a URL. 1038 URLImageType struct { 1039 Transformation TransformationType `json:"transformation,omitempty"` 1040 // Type Identifies the type of image, `URL` in this case. 1041 Type URLImageTypeType `json:"type,omitempty"` 1042 // URL The URL of the image. 1043 URL *StringVariableInline `json:"url"` 1044 } 1045 1046 // URLImageTypePost An image loaded from a URL. 1047 URLImageTypePost struct { 1048 Transformation TransformationTypePost `json:"transformation,omitempty"` 1049 // Type Identifies the type of image, `URL` in this case. 1050 Type URLImageTypePostType `json:"type,omitempty"` 1051 // URL The URL of the image. 1052 URL *StringVariableInline `json:"url"` 1053 } 1054 1055 // URLImageTypePostType ... 1056 URLImageTypePostType string 1057 1058 // URLImageTypeType ... 1059 URLImageTypeType string 1060 1061 // UnionShapeType Identifies a combined shape based on a set of other shapes. You can use a full JSON object to represent a union or an array of shapes that describe it. 1062 UnionShapeType struct { 1063 Shapes []ShapeType `json:"shapes"` 1064 } 1065 1066 // UnsharpMask Emphasizes edges and details in source images without distorting the colors. Although this effect is often referred to as _sharpening_ an image, it actually creates a blurred, inverted copy of the image known as an unsharp mask. Image and Video Manager combines the unsharp mask with the source image to create an image perceived as clearer. 1067 UnsharpMask struct { 1068 // Gain Set how much emphasis the filter applies to details. Higher values increase apparent sharpness of details. 1069 Gain *NumberVariableInline `json:"gain,omitempty"` 1070 // Sigma The standard deviation of the Gaussian distribution used in the in unsharp mask, measured in pixels, `1.0` by default. High values emphasize large details and low values emphasize small details. 1071 Sigma *NumberVariableInline `json:"sigma,omitempty"` 1072 // Threshold Set the minimum change required to include a detail in the filter. Higher values discard more changes. 1073 Threshold *NumberVariableInline `json:"threshold,omitempty"` 1074 // Transformation Identifies this type of transformation, `UnsharpMask` in this case. 1075 Transformation UnsharpMaskTransformation `json:"transformation"` 1076 } 1077 1078 // UnsharpMaskTransformation ... 1079 UnsharpMaskTransformation string 1080 1081 // Variable ... 1082 Variable struct { 1083 // DefaultValue The default value of the variable if no query parameter is provided. It needs to be one of the `enumOptions` if any are provided. 1084 DefaultValue string `json:"defaultValue"` 1085 EnumOptions []*EnumOptions `json:"enumOptions,omitempty"` 1086 // Name The name of the variable, also available as the query parameter name to set the variable's value dynamically. Use up to 50 alphanumeric characters. 1087 Name string `json:"name"` 1088 // Postfix A postfix added to the value provided for the variable, or to the default value. 1089 Postfix *string `json:"postfix,omitempty"` 1090 // Prefix A prefix added to the value provided for the variable, or to the default value. 1091 Prefix *string `json:"prefix,omitempty"` 1092 // Type The type of value for the variable. 1093 Type VariableType `json:"type"` 1094 } 1095 1096 // VariableInline References the name of a variable defined [by the policy](#63c7bea4). Use this object to substitute preset values within transformations, or to pass in values dynamically using image URL query parameters. 1097 VariableInline struct { 1098 // Var Corresponds to the `name` of the variable declared by the policy, to insert the corresponding value. 1099 Var string `json:"var"` 1100 } 1101 1102 // VariableType ... 1103 VariableType string 1104 1105 // OutputVideo Dictates the output quality that are created for each resized video. 1106 OutputVideo struct { 1107 // PerceptualQuality The quality of derivative videos. High preserves video quality with reduced byte savings while low reduces video quality to increase byte savings. 1108 PerceptualQuality *OutputVideoPerceptualQualityVariableInline `json:"perceptualQuality,omitempty"` 1109 // PlaceholderVideoURL Allows you to add a specific placeholder video that appears when a user first requests a video, but before Image & Video Manager processes the video. If not specified the original video plays during the processing time. 1110 PlaceholderVideoURL *StringVariableInline `json:"placeholderVideoUrl,omitempty"` 1111 // VideoAdaptiveQuality Override the quality of video to serve when Image & Video Manager detects a slow connection. Specifying lower values lets users with slow connections browse your site with reduced load times without impacting the quality of videos for users with faster connections. 1112 VideoAdaptiveQuality *OutputVideoVideoAdaptiveQualityVariableInline `json:"videoAdaptiveQuality,omitempty"` 1113 } 1114 1115 // OutputVideoPerceptualQuality ... 1116 OutputVideoPerceptualQuality string 1117 1118 // OutputVideoPerceptualQualityVariableInline represents a type which stores either a value or a variable name 1119 OutputVideoPerceptualQualityVariableInline struct { 1120 Name *string 1121 Value *OutputVideoPerceptualQuality 1122 } 1123 1124 // OutputVideoVideoAdaptiveQuality ... 1125 OutputVideoVideoAdaptiveQuality string 1126 1127 // OutputVideoVideoAdaptiveQualityVariableInline represents a type which stores either a value or a variable name 1128 OutputVideoVideoAdaptiveQualityVariableInline struct { 1129 Name *string 1130 Value *OutputVideoVideoAdaptiveQuality 1131 } 1132 1133 // PolicyOutputVideo Specifies details for each policy such as video size. 1134 PolicyOutputVideo struct { 1135 // Breakpoints The breakpoint widths (in pixels) to use to create derivative images/videos. 1136 Breakpoints *Breakpoints `json:"breakpoints,omitempty"` 1137 // DateCreated Date this policy version was created in ISO 8601 extended notation format. 1138 DateCreated string `json:"dateCreated"` 1139 // Hosts Hosts that are allowed for image/video URLs within transformations or variables. 1140 Hosts []string `json:"hosts,omitempty"` 1141 // ID Unique identifier for a policy, up to 64 alphanumeric characters including underscores or dashes. 1142 ID string `json:"id"` 1143 // Output Dictates the output quality that are created for each resized video. 1144 Output *OutputVideo `json:"output,omitempty"` 1145 // PreviousVersion The previous version number of this policy version 1146 PreviousVersion int `json:"previousVersion"` 1147 // RolloutInfo Contains information about policy rollout start and completion times. 1148 RolloutInfo *RolloutInfo `json:"rolloutInfo"` 1149 // User The user who created this policy version 1150 User string `json:"user"` 1151 // Variables Declares variables for use within the policy. Any variable declared here can be invoked throughout transformations as a [Variable](#variable) object, so that you don't have to specify values separately. You can also pass in these variable names and values dynamically as query parameters in the image's request URL. 1152 Variables []Variable `json:"variables,omitempty"` 1153 // Version The version number of this policy version 1154 Version int `json:"version"` 1155 // Video Identifies this as a video policy. 1156 Video *bool `json:"video,omitempty"` 1157 } 1158 1159 // PolicyOutputVideoVideo ... 1160 PolicyOutputVideoVideo bool 1161 ) 1162 1163 /*-----------------------------------------------*/ 1164 /////////////// Generated constants /////////////// 1165 /*-----------------------------------------------*/ 1166 const ( 1167 1168 // AppendGravityPriorityHorizontal const 1169 AppendGravityPriorityHorizontal AppendGravityPriority = "horizontal" 1170 // AppendGravityPriorityVertical const 1171 AppendGravityPriorityVertical AppendGravityPriority = "vertical" 1172 1173 // AppendTransformationAppend const 1174 AppendTransformationAppend AppendTransformation = "Append" 1175 1176 // AspectCropTransformationAspectCrop const 1177 AspectCropTransformationAspectCrop AspectCropTransformation = "AspectCrop" 1178 1179 // BackgroundColorTransformationBackgroundColor const 1180 BackgroundColorTransformationBackgroundColor BackgroundColorTransformation = "BackgroundColor" 1181 1182 // BlurTransformationBlur const 1183 BlurTransformationBlur BlurTransformation = "Blur" 1184 1185 // BoxImageTypePostTypeBox const 1186 BoxImageTypePostTypeBox BoxImageTypePostType = "Box" 1187 1188 // BoxImageTypeTypeBox const 1189 BoxImageTypeTypeBox BoxImageTypeType = "Box" 1190 1191 // ChromaKeyTransformationChromaKey const 1192 ChromaKeyTransformationChromaKey ChromaKeyTransformation = "ChromaKey" 1193 1194 // CircleImageTypePostTypeCircle const 1195 CircleImageTypePostTypeCircle CircleImageTypePostType = "Circle" 1196 1197 // CircleImageTypeTypeCircle const 1198 CircleImageTypeTypeCircle CircleImageTypeType = "Circle" 1199 1200 // CompositePlacementOver const 1201 CompositePlacementOver CompositePlacement = "Over" 1202 // CompositePlacementUnder const 1203 CompositePlacementUnder CompositePlacement = "Under" 1204 // CompositePlacementMask const 1205 CompositePlacementMask CompositePlacement = "Mask" 1206 // CompositePlacementStencil const 1207 CompositePlacementStencil CompositePlacement = "Stencil" 1208 1209 // CompositePostPlacementOver const 1210 CompositePostPlacementOver CompositePostPlacement = "Over" 1211 // CompositePostPlacementUnder const 1212 CompositePostPlacementUnder CompositePostPlacement = "Under" 1213 // CompositePostPlacementMask const 1214 CompositePostPlacementMask CompositePostPlacement = "Mask" 1215 // CompositePostPlacementStencil const 1216 CompositePostPlacementStencil CompositePostPlacement = "Stencil" 1217 1218 // CompositePostScaleDimensionWidth const 1219 CompositePostScaleDimensionWidth CompositePostScaleDimension = "width" 1220 // CompositePostScaleDimensionHeight const 1221 CompositePostScaleDimensionHeight CompositePostScaleDimension = "height" 1222 1223 // CompositePostTransformationComposite const 1224 CompositePostTransformationComposite CompositePostTransformation = "Composite" 1225 1226 // CompositeScaleDimensionWidth const 1227 CompositeScaleDimensionWidth CompositeScaleDimension = "width" 1228 // CompositeScaleDimensionHeight const 1229 CompositeScaleDimensionHeight CompositeScaleDimension = "height" 1230 1231 // CompositeTransformationComposite const 1232 CompositeTransformationComposite CompositeTransformation = "Composite" 1233 1234 // CompoundPostTransformationCompound const 1235 CompoundPostTransformationCompound CompoundPostTransformation = "Compound" 1236 1237 // CompoundTransformationCompound const 1238 CompoundTransformationCompound CompoundTransformation = "Compound" 1239 1240 // ContrastTransformationContrast const 1241 ContrastTransformationContrast ContrastTransformation = "Contrast" 1242 1243 // CropTransformationCrop const 1244 CropTransformationCrop CropTransformation = "Crop" 1245 1246 // FaceCropAlgorithmCascade const 1247 FaceCropAlgorithmCascade FaceCropAlgorithm = "cascade" 1248 // FaceCropAlgorithmDnn const 1249 FaceCropAlgorithmDnn FaceCropAlgorithm = "dnn" 1250 1251 // FaceCropFocusAllFaces const 1252 FaceCropFocusAllFaces FaceCropFocus = "allFaces" 1253 // FaceCropFocusBiggestFace const 1254 FaceCropFocusBiggestFace FaceCropFocus = "biggestFace" 1255 1256 // FaceCropStyleCrop const 1257 FaceCropStyleCrop FaceCropStyle = "crop" 1258 // FaceCropStyleFill const 1259 FaceCropStyleFill FaceCropStyle = "fill" 1260 // FaceCropStyleZoom const 1261 FaceCropStyleZoom FaceCropStyle = "zoom" 1262 1263 // FaceCropTransformationFaceCrop const 1264 FaceCropTransformationFaceCrop FaceCropTransformation = "FaceCrop" 1265 1266 // FeatureCropStyleCrop const 1267 FeatureCropStyleCrop FeatureCropStyle = "crop" 1268 // FeatureCropStyleFill const 1269 FeatureCropStyleFill FeatureCropStyle = "fill" 1270 // FeatureCropStyleZoom const 1271 FeatureCropStyleZoom FeatureCropStyle = "zoom" 1272 1273 // FeatureCropTransformationFeatureCrop const 1274 FeatureCropTransformationFeatureCrop FeatureCropTransformation = "FeatureCrop" 1275 1276 // FitAndFillTransformationFitAndFill const 1277 FitAndFillTransformationFitAndFill FitAndFillTransformation = "FitAndFill" 1278 1279 // GoopTransformationGoop const 1280 GoopTransformationGoop GoopTransformation = "Goop" 1281 1282 // GravityNorth const 1283 GravityNorth Gravity = "North" 1284 // GravityNorthEast const 1285 GravityNorthEast Gravity = "NorthEast" 1286 // GravityNorthWest const 1287 GravityNorthWest Gravity = "NorthWest" 1288 // GravitySouth const 1289 GravitySouth Gravity = "South" 1290 // GravitySouthEast const 1291 GravitySouthEast Gravity = "SouthEast" 1292 // GravitySouthWest const 1293 GravitySouthWest Gravity = "SouthWest" 1294 // GravityCenter const 1295 GravityCenter Gravity = "Center" 1296 // GravityEast const 1297 GravityEast Gravity = "East" 1298 // GravityWest const 1299 GravityWest Gravity = "West" 1300 1301 // GravityPostNorth const 1302 GravityPostNorth GravityPost = "North" 1303 // GravityPostNorthEast const 1304 GravityPostNorthEast GravityPost = "NorthEast" 1305 // GravityPostNorthWest const 1306 GravityPostNorthWest GravityPost = "NorthWest" 1307 // GravityPostSouth const 1308 GravityPostSouth GravityPost = "South" 1309 // GravityPostSouthEast const 1310 GravityPostSouthEast GravityPost = "SouthEast" 1311 // GravityPostSouthWest const 1312 GravityPostSouthWest GravityPost = "SouthWest" 1313 // GravityPostCenter const 1314 GravityPostCenter GravityPost = "Center" 1315 // GravityPostEast const 1316 GravityPostEast GravityPost = "East" 1317 // GravityPostWest const 1318 GravityPostWest GravityPost = "West" 1319 1320 // GrayscaleTransformationGrayscale const 1321 GrayscaleTransformationGrayscale GrayscaleTransformation = "Grayscale" 1322 1323 // GrayscaleTypeRec601 const 1324 GrayscaleTypeRec601 GrayscaleType = "Rec601" 1325 // GrayscaleTypeRec709 const 1326 GrayscaleTypeRec709 GrayscaleType = "Rec709" 1327 // GrayscaleTypeBrightness const 1328 GrayscaleTypeBrightness GrayscaleType = "Brightness" 1329 // GrayscaleTypeLightness const 1330 GrayscaleTypeLightness GrayscaleType = "Lightness" 1331 1332 // HSLTransformationHSL const 1333 HSLTransformationHSL HSLTransformation = "HSL" 1334 1335 // HSVTransformationHSV const 1336 HSVTransformationHSV HSVTransformation = "HSV" 1337 1338 // IfDimensionDimensionWidth const 1339 IfDimensionDimensionWidth IfDimensionDimension = "width" 1340 // IfDimensionDimensionHeight const 1341 IfDimensionDimensionHeight IfDimensionDimension = "height" 1342 // IfDimensionDimensionBoth const 1343 IfDimensionDimensionBoth IfDimensionDimension = "both" 1344 1345 // IfDimensionPostDimensionWidth const 1346 IfDimensionPostDimensionWidth IfDimensionPostDimension = "width" 1347 // IfDimensionPostDimensionHeight const 1348 IfDimensionPostDimensionHeight IfDimensionPostDimension = "height" 1349 // IfDimensionPostDimensionBoth const 1350 IfDimensionPostDimensionBoth IfDimensionPostDimension = "both" 1351 1352 // IfDimensionPostTransformationIfDimension const 1353 IfDimensionPostTransformationIfDimension IfDimensionPostTransformation = "IfDimension" 1354 1355 // IfDimensionTransformationIfDimension const 1356 IfDimensionTransformationIfDimension IfDimensionTransformation = "IfDimension" 1357 1358 // IfOrientationPostTransformationIfOrientation const 1359 IfOrientationPostTransformationIfOrientation IfOrientationPostTransformation = "IfOrientation" 1360 1361 // IfOrientationTransformationIfOrientation const 1362 IfOrientationTransformationIfOrientation IfOrientationTransformation = "IfOrientation" 1363 1364 // ImQueryAllowedTransformationsAppend const 1365 ImQueryAllowedTransformationsAppend ImQueryAllowedTransformations = "Append" 1366 // ImQueryAllowedTransformationsAspectCrop const 1367 ImQueryAllowedTransformationsAspectCrop ImQueryAllowedTransformations = "AspectCrop" 1368 // ImQueryAllowedTransformationsBackgroundColor const 1369 ImQueryAllowedTransformationsBackgroundColor ImQueryAllowedTransformations = "BackgroundColor" 1370 // ImQueryAllowedTransformationsBlur const 1371 ImQueryAllowedTransformationsBlur ImQueryAllowedTransformations = "Blur" 1372 // ImQueryAllowedTransformationsComposite const 1373 ImQueryAllowedTransformationsComposite ImQueryAllowedTransformations = "Composite" 1374 // ImQueryAllowedTransformationsContrast const 1375 ImQueryAllowedTransformationsContrast ImQueryAllowedTransformations = "Contrast" 1376 // ImQueryAllowedTransformationsCrop const 1377 ImQueryAllowedTransformationsCrop ImQueryAllowedTransformations = "Crop" 1378 // ImQueryAllowedTransformationsChromaKey const 1379 ImQueryAllowedTransformationsChromaKey ImQueryAllowedTransformations = "ChromaKey" 1380 // ImQueryAllowedTransformationsFaceCrop const 1381 ImQueryAllowedTransformationsFaceCrop ImQueryAllowedTransformations = "FaceCrop" 1382 // ImQueryAllowedTransformationsFeatureCrop const 1383 ImQueryAllowedTransformationsFeatureCrop ImQueryAllowedTransformations = "FeatureCrop" 1384 // ImQueryAllowedTransformationsFitAndFill const 1385 ImQueryAllowedTransformationsFitAndFill ImQueryAllowedTransformations = "FitAndFill" 1386 // ImQueryAllowedTransformationsGoop const 1387 ImQueryAllowedTransformationsGoop ImQueryAllowedTransformations = "Goop" 1388 // ImQueryAllowedTransformationsGrayscale const 1389 ImQueryAllowedTransformationsGrayscale ImQueryAllowedTransformations = "Grayscale" 1390 // ImQueryAllowedTransformationsHSL const 1391 ImQueryAllowedTransformationsHSL ImQueryAllowedTransformations = "HSL" 1392 // ImQueryAllowedTransformationsHSV const 1393 ImQueryAllowedTransformationsHSV ImQueryAllowedTransformations = "HSV" 1394 // ImQueryAllowedTransformationsMaxColors const 1395 ImQueryAllowedTransformationsMaxColors ImQueryAllowedTransformations = "MaxColors" 1396 // ImQueryAllowedTransformationsMirror const 1397 ImQueryAllowedTransformationsMirror ImQueryAllowedTransformations = "Mirror" 1398 // ImQueryAllowedTransformationsMonoHue const 1399 ImQueryAllowedTransformationsMonoHue ImQueryAllowedTransformations = "MonoHue" 1400 // ImQueryAllowedTransformationsOpacity const 1401 ImQueryAllowedTransformationsOpacity ImQueryAllowedTransformations = "Opacity" 1402 // ImQueryAllowedTransformationsRegionOfInterestCrop const 1403 ImQueryAllowedTransformationsRegionOfInterestCrop ImQueryAllowedTransformations = "RegionOfInterestCrop" 1404 // ImQueryAllowedTransformationsRelativeCrop const 1405 ImQueryAllowedTransformationsRelativeCrop ImQueryAllowedTransformations = "RelativeCrop" 1406 // ImQueryAllowedTransformationsRemoveColor const 1407 ImQueryAllowedTransformationsRemoveColor ImQueryAllowedTransformations = "RemoveColor" 1408 // ImQueryAllowedTransformationsResize const 1409 ImQueryAllowedTransformationsResize ImQueryAllowedTransformations = "Resize" 1410 // ImQueryAllowedTransformationsRotate const 1411 ImQueryAllowedTransformationsRotate ImQueryAllowedTransformations = "Rotate" 1412 // ImQueryAllowedTransformationsScale const 1413 ImQueryAllowedTransformationsScale ImQueryAllowedTransformations = "Scale" 1414 // ImQueryAllowedTransformationsShear const 1415 ImQueryAllowedTransformationsShear ImQueryAllowedTransformations = "Shear" 1416 // ImQueryAllowedTransformationsTrim const 1417 ImQueryAllowedTransformationsTrim ImQueryAllowedTransformations = "Trim" 1418 // ImQueryAllowedTransformationsUnsharpMask const 1419 ImQueryAllowedTransformationsUnsharpMask ImQueryAllowedTransformations = "UnsharpMask" 1420 // ImQueryAllowedTransformationsIfDimension const 1421 ImQueryAllowedTransformationsIfDimension ImQueryAllowedTransformations = "IfDimension" 1422 // ImQueryAllowedTransformationsIfOrientation const 1423 ImQueryAllowedTransformationsIfOrientation ImQueryAllowedTransformations = "IfOrientation" 1424 1425 // ImQueryTransformationImQuery const 1426 ImQueryTransformationImQuery ImQueryTransformation = "ImQuery" 1427 1428 // MaxColorsTransformationMaxColors const 1429 MaxColorsTransformationMaxColors MaxColorsTransformation = "MaxColors" 1430 1431 // MirrorTransformationMirror const 1432 MirrorTransformationMirror MirrorTransformation = "Mirror" 1433 1434 // MonoHueTransformationMonoHue const 1435 MonoHueTransformationMonoHue MonoHueTransformation = "MonoHue" 1436 1437 // OpacityTransformationOpacity const 1438 OpacityTransformationOpacity OpacityTransformation = "Opacity" 1439 1440 // OutputImageAllowedFormatsGif const 1441 OutputImageAllowedFormatsGif OutputImageAllowedFormats = "gif" 1442 // OutputImageAllowedFormatsJpeg const 1443 OutputImageAllowedFormatsJpeg OutputImageAllowedFormats = "jpeg" 1444 // OutputImageAllowedFormatsPng const 1445 OutputImageAllowedFormatsPng OutputImageAllowedFormats = "png" 1446 // OutputImageAllowedFormatsWebp const 1447 OutputImageAllowedFormatsWebp OutputImageAllowedFormats = "webp" 1448 // OutputImageAllowedFormatsJpegxr const 1449 OutputImageAllowedFormatsJpegxr OutputImageAllowedFormats = "jpegxr" 1450 // OutputImageAllowedFormatsJpeg2000 const 1451 OutputImageAllowedFormatsJpeg2000 OutputImageAllowedFormats = "jpeg2000" 1452 // OutputImageAllowedFormatsAvif const 1453 OutputImageAllowedFormatsAvif OutputImageAllowedFormats = "avif" 1454 1455 // OutputImageForcedFormatsGif const 1456 OutputImageForcedFormatsGif OutputImageForcedFormats = "gif" 1457 // OutputImageForcedFormatsJpeg const 1458 OutputImageForcedFormatsJpeg OutputImageForcedFormats = "jpeg" 1459 // OutputImageForcedFormatsPng const 1460 OutputImageForcedFormatsPng OutputImageForcedFormats = "png" 1461 // OutputImageForcedFormatsWebp const 1462 OutputImageForcedFormatsWebp OutputImageForcedFormats = "webp" 1463 // OutputImageForcedFormatsJpegxr const 1464 OutputImageForcedFormatsJpegxr OutputImageForcedFormats = "jpegxr" 1465 // OutputImageForcedFormatsJpeg2000 const 1466 OutputImageForcedFormatsJpeg2000 OutputImageForcedFormats = "jpeg2000" 1467 // OutputImageForcedFormatsAvif const 1468 OutputImageForcedFormatsAvif OutputImageForcedFormats = "avif" 1469 1470 // OutputImagePerceptualQualityHigh const 1471 OutputImagePerceptualQualityHigh OutputImagePerceptualQuality = "high" 1472 // OutputImagePerceptualQualityMediumHigh const 1473 OutputImagePerceptualQualityMediumHigh OutputImagePerceptualQuality = "mediumHigh" 1474 // OutputImagePerceptualQualityMedium const 1475 OutputImagePerceptualQualityMedium OutputImagePerceptualQuality = "medium" 1476 // OutputImagePerceptualQualityMediumLow const 1477 OutputImagePerceptualQualityMediumLow OutputImagePerceptualQuality = "mediumLow" 1478 // OutputImagePerceptualQualityLow const 1479 OutputImagePerceptualQualityLow OutputImagePerceptualQuality = "low" 1480 1481 // PolicyOutputImageVideoFalse const 1482 PolicyOutputImageVideoFalse PolicyOutputImageVideo = false 1483 1484 // RegionOfInterestCropStyleCrop const 1485 RegionOfInterestCropStyleCrop RegionOfInterestCropStyle = "crop" 1486 // RegionOfInterestCropStyleFill const 1487 RegionOfInterestCropStyleFill RegionOfInterestCropStyle = "fill" 1488 // RegionOfInterestCropStyleZoom const 1489 RegionOfInterestCropStyleZoom RegionOfInterestCropStyle = "zoom" 1490 1491 // RegionOfInterestCropTransformationRegionOfInterestCrop const 1492 RegionOfInterestCropTransformationRegionOfInterestCrop RegionOfInterestCropTransformation = "RegionOfInterestCrop" 1493 1494 // RelativeCropTransformationRelativeCrop const 1495 RelativeCropTransformationRelativeCrop RelativeCropTransformation = "RelativeCrop" 1496 1497 // RemoveColorTransformationRemoveColor const 1498 RemoveColorTransformationRemoveColor RemoveColorTransformation = "RemoveColor" 1499 1500 // ResizeAspectFit const 1501 ResizeAspectFit ResizeAspect = "fit" 1502 // ResizeAspectFill const 1503 ResizeAspectFill ResizeAspect = "fill" 1504 // ResizeAspectIgnore const 1505 ResizeAspectIgnore ResizeAspect = "ignore" 1506 1507 // ResizeTransformationResize const 1508 ResizeTransformationResize ResizeTransformation = "Resize" 1509 1510 // ResizeTypeNormal const 1511 ResizeTypeNormal ResizeType = "normal" 1512 // ResizeTypeUpsize const 1513 ResizeTypeUpsize ResizeType = "upsize" 1514 // ResizeTypeDownsize const 1515 ResizeTypeDownsize ResizeType = "downsize" 1516 1517 // RotateTransformationRotate const 1518 RotateTransformationRotate RotateTransformation = "Rotate" 1519 1520 // ScaleTransformationScale const 1521 ScaleTransformationScale ScaleTransformation = "Scale" 1522 1523 // ShearTransformationShear const 1524 ShearTransformationShear ShearTransformation = "Shear" 1525 1526 // SmartCropStyleCrop const 1527 SmartCropStyleCrop SmartCropStyle = "crop" 1528 // SmartCropStyleFill const 1529 SmartCropStyleFill SmartCropStyle = "fill" 1530 // SmartCropStyleZoom const 1531 SmartCropStyleZoom SmartCropStyle = "zoom" 1532 1533 // SmartCropTransformationSmartCrop const 1534 SmartCropTransformationSmartCrop SmartCropTransformation = "SmartCrop" 1535 1536 // TextImageTypePostTypeText const 1537 TextImageTypePostTypeText TextImageTypePostType = "Text" 1538 1539 // TextImageTypeTypeText const 1540 TextImageTypeTypeText TextImageTypeType = "Text" 1541 1542 // TrimTransformationTrim const 1543 TrimTransformationTrim TrimTransformation = "Trim" 1544 1545 // URLImageTypePostTypeURL const 1546 URLImageTypePostTypeURL URLImageTypePostType = "URL" 1547 1548 // URLImageTypeTypeURL const 1549 URLImageTypeTypeURL URLImageTypeType = "URL" 1550 1551 // UnsharpMaskTransformationUnsharpMask const 1552 UnsharpMaskTransformationUnsharpMask UnsharpMaskTransformation = "UnsharpMask" 1553 1554 // VariableTypeBool const 1555 VariableTypeBool VariableType = "bool" 1556 // VariableTypeNumber const 1557 VariableTypeNumber VariableType = "number" 1558 // VariableTypeURL const 1559 VariableTypeURL VariableType = "url" 1560 // VariableTypeColor const 1561 VariableTypeColor VariableType = "color" 1562 // VariableTypeGravity const 1563 VariableTypeGravity VariableType = "gravity" 1564 // VariableTypePlacement const 1565 VariableTypePlacement VariableType = "placement" 1566 // VariableTypeScaleDimension const 1567 VariableTypeScaleDimension VariableType = "scaleDimension" 1568 // VariableTypeGrayscaleType const 1569 VariableTypeGrayscaleType VariableType = "grayscaleType" 1570 // VariableTypeAspect const 1571 VariableTypeAspect VariableType = "aspect" 1572 // VariableTypeResizeType const 1573 VariableTypeResizeType VariableType = "resizeType" 1574 // VariableTypeDimension const 1575 VariableTypeDimension VariableType = "dimension" 1576 // VariableTypePerceptualQuality const 1577 VariableTypePerceptualQuality VariableType = "perceptualQuality" 1578 // VariableTypeString const 1579 VariableTypeString VariableType = "string" 1580 // VariableTypeFocus const 1581 VariableTypeFocus VariableType = "focus" 1582 1583 // OutputVideoPerceptualQualityHigh const 1584 OutputVideoPerceptualQualityHigh OutputVideoPerceptualQuality = "high" 1585 // OutputVideoPerceptualQualityMediumHigh const 1586 OutputVideoPerceptualQualityMediumHigh OutputVideoPerceptualQuality = "mediumHigh" 1587 // OutputVideoPerceptualQualityMedium const 1588 OutputVideoPerceptualQualityMedium OutputVideoPerceptualQuality = "medium" 1589 // OutputVideoPerceptualQualityMediumLow const 1590 OutputVideoPerceptualQualityMediumLow OutputVideoPerceptualQuality = "mediumLow" 1591 // OutputVideoPerceptualQualityLow const 1592 OutputVideoPerceptualQualityLow OutputVideoPerceptualQuality = "low" 1593 1594 // OutputVideoVideoAdaptiveQualityHigh const 1595 OutputVideoVideoAdaptiveQualityHigh OutputVideoVideoAdaptiveQuality = "high" 1596 // OutputVideoVideoAdaptiveQualityMediumHigh const 1597 OutputVideoVideoAdaptiveQualityMediumHigh OutputVideoVideoAdaptiveQuality = "mediumHigh" 1598 // OutputVideoVideoAdaptiveQualityMedium const 1599 OutputVideoVideoAdaptiveQualityMedium OutputVideoVideoAdaptiveQuality = "medium" 1600 // OutputVideoVideoAdaptiveQualityMediumLow const 1601 OutputVideoVideoAdaptiveQualityMediumLow OutputVideoVideoAdaptiveQuality = "mediumLow" 1602 // OutputVideoVideoAdaptiveQualityLow const 1603 OutputVideoVideoAdaptiveQualityLow OutputVideoVideoAdaptiveQuality = "low" 1604 1605 // PolicyOutputVideoVideoTrue const 1606 PolicyOutputVideoVideoTrue PolicyOutputVideoVideo = true 1607 ) 1608 1609 /*-----------------------------------------------*/ 1610 //////////// Interface implementations //////////// 1611 /*-----------------------------------------------*/ 1612 1613 func (Append) transformationType() string { 1614 return "Append" 1615 } 1616 1617 func (AspectCrop) transformationType() string { 1618 return "AspectCrop" 1619 } 1620 1621 func (BackgroundColor) transformationType() string { 1622 return "BackgroundColor" 1623 } 1624 1625 func (Blur) transformationType() string { 1626 return "Blur" 1627 } 1628 1629 func (BoxImageType) imageType() string { 1630 return "BoxImageType" 1631 } 1632 1633 func (BoxImageTypePost) imageTypePost() string { 1634 return "BoxImageTypePost" 1635 } 1636 1637 func (ChromaKey) transformationType() string { 1638 return "ChromaKey" 1639 } 1640 1641 func (CircleImageType) imageType() string { 1642 return "CircleImageType" 1643 } 1644 1645 func (CircleImageTypePost) imageTypePost() string { 1646 return "CircleImageTypePost" 1647 } 1648 1649 func (CircleShapeType) shapeType() string { 1650 return "CircleShapeType" 1651 } 1652 1653 func (Composite) transformationType() string { 1654 return "Composite" 1655 } 1656 1657 func (Compound) transformationType() string { 1658 return "Compound" 1659 } 1660 1661 func (Contrast) transformationType() string { 1662 return "Contrast" 1663 } 1664 1665 func (Crop) transformationType() string { 1666 return "Crop" 1667 } 1668 1669 func (FaceCrop) transformationType() string { 1670 return "FaceCrop" 1671 } 1672 1673 func (FeatureCrop) transformationType() string { 1674 return "FeatureCrop" 1675 } 1676 1677 func (FitAndFill) transformationType() string { 1678 return "FitAndFill" 1679 } 1680 1681 func (Goop) transformationType() string { 1682 return "Goop" 1683 } 1684 1685 func (Grayscale) transformationType() string { 1686 return "Grayscale" 1687 } 1688 1689 func (HSL) transformationType() string { 1690 return "HSL" 1691 } 1692 1693 func (HSV) transformationType() string { 1694 return "HSV" 1695 } 1696 1697 func (IfDimension) transformationType() string { 1698 return "IfDimension" 1699 } 1700 1701 func (IfOrientation) transformationType() string { 1702 return "IfOrientation" 1703 } 1704 1705 func (ImQuery) transformationType() string { 1706 return "ImQuery" 1707 } 1708 1709 func (MaxColors) transformationType() string { 1710 return "MaxColors" 1711 } 1712 1713 func (Mirror) transformationType() string { 1714 return "Mirror" 1715 } 1716 1717 func (MonoHue) transformationType() string { 1718 return "MonoHue" 1719 } 1720 1721 func (Opacity) transformationType() string { 1722 return "Opacity" 1723 } 1724 1725 func (PointShapeType) shapeType() string { 1726 return "PointShapeType" 1727 } 1728 1729 func (PolygonShapeType) shapeType() string { 1730 return "PolygonShapeType" 1731 } 1732 1733 func (RectangleShapeType) shapeType() string { 1734 return "RectangleShapeType" 1735 } 1736 1737 func (RegionOfInterestCrop) transformationType() string { 1738 return "RegionOfInterestCrop" 1739 } 1740 1741 func (RelativeCrop) transformationType() string { 1742 return "RelativeCrop" 1743 } 1744 1745 func (RemoveColor) transformationType() string { 1746 return "RemoveColor" 1747 } 1748 1749 func (Resize) transformationType() string { 1750 return "Resize" 1751 } 1752 1753 func (Rotate) transformationType() string { 1754 return "Rotate" 1755 } 1756 1757 func (Scale) transformationType() string { 1758 return "Scale" 1759 } 1760 1761 func (Shear) transformationType() string { 1762 return "Shear" 1763 } 1764 1765 func (SmartCrop) transformationType() string { 1766 return "SmartCrop" 1767 } 1768 1769 func (TextImageType) imageType() string { 1770 return "TextImageType" 1771 } 1772 1773 func (TextImageTypePost) imageTypePost() string { 1774 return "TextImageTypePost" 1775 } 1776 1777 func (Trim) transformationType() string { 1778 return "Trim" 1779 } 1780 1781 func (URLImageType) imageType() string { 1782 return "URLImageType" 1783 } 1784 1785 func (URLImageTypePost) imageTypePost() string { 1786 return "URLImageTypePost" 1787 } 1788 1789 func (UnionShapeType) shapeType() string { 1790 return "UnionShapeType" 1791 } 1792 1793 func (UnsharpMask) transformationType() string { 1794 return "UnsharpMask" 1795 } 1796 1797 func (BackgroundColor) transformationTypePost() string { 1798 return "BackgroundColor" 1799 } 1800 1801 func (Blur) transformationTypePost() string { 1802 return "Blur" 1803 } 1804 1805 func (ChromaKey) transformationTypePost() string { 1806 return "ChromaKey" 1807 } 1808 1809 func (CompositePost) transformationTypePost() string { 1810 return "CompositePost" 1811 } 1812 1813 func (CompoundPost) transformationTypePost() string { 1814 return "CompoundPost" 1815 } 1816 1817 func (Contrast) transformationTypePost() string { 1818 return "Contrast" 1819 } 1820 1821 func (Goop) transformationTypePost() string { 1822 return "Goop" 1823 } 1824 1825 func (Grayscale) transformationTypePost() string { 1826 return "Grayscale" 1827 } 1828 1829 func (HSL) transformationTypePost() string { 1830 return "HSL" 1831 } 1832 1833 func (HSV) transformationTypePost() string { 1834 return "HSV" 1835 } 1836 1837 func (IfDimensionPost) transformationTypePost() string { 1838 return "IfDimensionPost" 1839 } 1840 1841 func (IfOrientationPost) transformationTypePost() string { 1842 return "IfOrientationPost" 1843 } 1844 1845 func (MaxColors) transformationTypePost() string { 1846 return "MaxColors" 1847 } 1848 1849 func (Mirror) transformationTypePost() string { 1850 return "Mirror" 1851 } 1852 1853 func (MonoHue) transformationTypePost() string { 1854 return "MonoHue" 1855 } 1856 1857 func (Opacity) transformationTypePost() string { 1858 return "Opacity" 1859 } 1860 1861 func (RemoveColor) transformationTypePost() string { 1862 return "RemoveColor" 1863 } 1864 1865 func (UnsharpMask) transformationTypePost() string { 1866 return "UnsharpMask" 1867 } 1868 1869 /*-----------------------------------------------*/ 1870 //////////////// Pointer functions //////////////// 1871 /*-----------------------------------------------*/ 1872 1873 // AppendGravityPriorityPtr returns pointer of AppendGravityPriority 1874 func AppendGravityPriorityPtr(v AppendGravityPriority) *AppendGravityPriority { 1875 return &v 1876 } 1877 1878 // AppendTransformationPtr returns pointer of AppendTransformation 1879 func AppendTransformationPtr(v AppendTransformation) *AppendTransformation { 1880 return &v 1881 } 1882 1883 // AspectCropTransformationPtr returns pointer of AspectCropTransformation 1884 func AspectCropTransformationPtr(v AspectCropTransformation) *AspectCropTransformation { 1885 return &v 1886 } 1887 1888 // BackgroundColorTransformationPtr returns pointer of BackgroundColorTransformation 1889 func BackgroundColorTransformationPtr(v BackgroundColorTransformation) *BackgroundColorTransformation { 1890 return &v 1891 } 1892 1893 // BlurTransformationPtr returns pointer of BlurTransformation 1894 func BlurTransformationPtr(v BlurTransformation) *BlurTransformation { 1895 return &v 1896 } 1897 1898 // BoxImageTypePostTypePtr returns pointer of BoxImageTypePostType 1899 func BoxImageTypePostTypePtr(v BoxImageTypePostType) *BoxImageTypePostType { 1900 return &v 1901 } 1902 1903 // BoxImageTypeTypePtr returns pointer of BoxImageTypeType 1904 func BoxImageTypeTypePtr(v BoxImageTypeType) *BoxImageTypeType { 1905 return &v 1906 } 1907 1908 // ChromaKeyTransformationPtr returns pointer of ChromaKeyTransformation 1909 func ChromaKeyTransformationPtr(v ChromaKeyTransformation) *ChromaKeyTransformation { 1910 return &v 1911 } 1912 1913 // CircleImageTypePostTypePtr returns pointer of CircleImageTypePostType 1914 func CircleImageTypePostTypePtr(v CircleImageTypePostType) *CircleImageTypePostType { 1915 return &v 1916 } 1917 1918 // CircleImageTypeTypePtr returns pointer of CircleImageTypeType 1919 func CircleImageTypeTypePtr(v CircleImageTypeType) *CircleImageTypeType { 1920 return &v 1921 } 1922 1923 // CompositePlacementPtr returns pointer of CompositePlacement 1924 func CompositePlacementPtr(v CompositePlacement) *CompositePlacement { 1925 return &v 1926 } 1927 1928 // CompositePostPlacementPtr returns pointer of CompositePostPlacement 1929 func CompositePostPlacementPtr(v CompositePostPlacement) *CompositePostPlacement { 1930 return &v 1931 } 1932 1933 // CompositePostScaleDimensionPtr returns pointer of CompositePostScaleDimension 1934 func CompositePostScaleDimensionPtr(v CompositePostScaleDimension) *CompositePostScaleDimension { 1935 return &v 1936 } 1937 1938 // CompositePostTransformationPtr returns pointer of CompositePostTransformation 1939 func CompositePostTransformationPtr(v CompositePostTransformation) *CompositePostTransformation { 1940 return &v 1941 } 1942 1943 // CompositeScaleDimensionPtr returns pointer of CompositeScaleDimension 1944 func CompositeScaleDimensionPtr(v CompositeScaleDimension) *CompositeScaleDimension { 1945 return &v 1946 } 1947 1948 // CompositeTransformationPtr returns pointer of CompositeTransformation 1949 func CompositeTransformationPtr(v CompositeTransformation) *CompositeTransformation { 1950 return &v 1951 } 1952 1953 // CompoundPostTransformationPtr returns pointer of CompoundPostTransformation 1954 func CompoundPostTransformationPtr(v CompoundPostTransformation) *CompoundPostTransformation { 1955 return &v 1956 } 1957 1958 // CompoundTransformationPtr returns pointer of CompoundTransformation 1959 func CompoundTransformationPtr(v CompoundTransformation) *CompoundTransformation { 1960 return &v 1961 } 1962 1963 // ContrastTransformationPtr returns pointer of ContrastTransformation 1964 func ContrastTransformationPtr(v ContrastTransformation) *ContrastTransformation { 1965 return &v 1966 } 1967 1968 // CropTransformationPtr returns pointer of CropTransformation 1969 func CropTransformationPtr(v CropTransformation) *CropTransformation { 1970 return &v 1971 } 1972 1973 // FaceCropAlgorithmPtr returns pointer of FaceCropAlgorithm 1974 func FaceCropAlgorithmPtr(v FaceCropAlgorithm) *FaceCropAlgorithm { 1975 return &v 1976 } 1977 1978 // FaceCropFocusPtr returns pointer of FaceCropFocus 1979 func FaceCropFocusPtr(v FaceCropFocus) *FaceCropFocus { 1980 return &v 1981 } 1982 1983 // FaceCropStylePtr returns pointer of FaceCropStyle 1984 func FaceCropStylePtr(v FaceCropStyle) *FaceCropStyle { 1985 return &v 1986 } 1987 1988 // FaceCropTransformationPtr returns pointer of FaceCropTransformation 1989 func FaceCropTransformationPtr(v FaceCropTransformation) *FaceCropTransformation { 1990 return &v 1991 } 1992 1993 // FeatureCropStylePtr returns pointer of FeatureCropStyle 1994 func FeatureCropStylePtr(v FeatureCropStyle) *FeatureCropStyle { 1995 return &v 1996 } 1997 1998 // FeatureCropTransformationPtr returns pointer of FeatureCropTransformation 1999 func FeatureCropTransformationPtr(v FeatureCropTransformation) *FeatureCropTransformation { 2000 return &v 2001 } 2002 2003 // FitAndFillTransformationPtr returns pointer of FitAndFillTransformation 2004 func FitAndFillTransformationPtr(v FitAndFillTransformation) *FitAndFillTransformation { 2005 return &v 2006 } 2007 2008 // GoopTransformationPtr returns pointer of GoopTransformation 2009 func GoopTransformationPtr(v GoopTransformation) *GoopTransformation { 2010 return &v 2011 } 2012 2013 // GravityPtr returns pointer of Gravity 2014 func GravityPtr(v Gravity) *Gravity { 2015 return &v 2016 } 2017 2018 // GravityPostPtr returns pointer of GravityPost 2019 func GravityPostPtr(v GravityPost) *GravityPost { 2020 return &v 2021 } 2022 2023 // GrayscaleTransformationPtr returns pointer of GrayscaleTransformation 2024 func GrayscaleTransformationPtr(v GrayscaleTransformation) *GrayscaleTransformation { 2025 return &v 2026 } 2027 2028 // GrayscaleTypePtr returns pointer of GrayscaleType 2029 func GrayscaleTypePtr(v GrayscaleType) *GrayscaleType { 2030 return &v 2031 } 2032 2033 // HSLTransformationPtr returns pointer of HSLTransformation 2034 func HSLTransformationPtr(v HSLTransformation) *HSLTransformation { 2035 return &v 2036 } 2037 2038 // HSVTransformationPtr returns pointer of HSVTransformation 2039 func HSVTransformationPtr(v HSVTransformation) *HSVTransformation { 2040 return &v 2041 } 2042 2043 // IfDimensionDimensionPtr returns pointer of IfDimensionDimension 2044 func IfDimensionDimensionPtr(v IfDimensionDimension) *IfDimensionDimension { 2045 return &v 2046 } 2047 2048 // IfDimensionPostDimensionPtr returns pointer of IfDimensionPostDimension 2049 func IfDimensionPostDimensionPtr(v IfDimensionPostDimension) *IfDimensionPostDimension { 2050 return &v 2051 } 2052 2053 // IfDimensionPostTransformationPtr returns pointer of IfDimensionPostTransformation 2054 func IfDimensionPostTransformationPtr(v IfDimensionPostTransformation) *IfDimensionPostTransformation { 2055 return &v 2056 } 2057 2058 // IfDimensionTransformationPtr returns pointer of IfDimensionTransformation 2059 func IfDimensionTransformationPtr(v IfDimensionTransformation) *IfDimensionTransformation { 2060 return &v 2061 } 2062 2063 // IfOrientationPostTransformationPtr returns pointer of IfOrientationPostTransformation 2064 func IfOrientationPostTransformationPtr(v IfOrientationPostTransformation) *IfOrientationPostTransformation { 2065 return &v 2066 } 2067 2068 // IfOrientationTransformationPtr returns pointer of IfOrientationTransformation 2069 func IfOrientationTransformationPtr(v IfOrientationTransformation) *IfOrientationTransformation { 2070 return &v 2071 } 2072 2073 // ImQueryAllowedTransformationsPtr returns pointer of ImQueryAllowedTransformations 2074 func ImQueryAllowedTransformationsPtr(v ImQueryAllowedTransformations) *ImQueryAllowedTransformations { 2075 return &v 2076 } 2077 2078 // ImQueryTransformationPtr returns pointer of ImQueryTransformation 2079 func ImQueryTransformationPtr(v ImQueryTransformation) *ImQueryTransformation { 2080 return &v 2081 } 2082 2083 // MaxColorsTransformationPtr returns pointer of MaxColorsTransformation 2084 func MaxColorsTransformationPtr(v MaxColorsTransformation) *MaxColorsTransformation { 2085 return &v 2086 } 2087 2088 // MirrorTransformationPtr returns pointer of MirrorTransformation 2089 func MirrorTransformationPtr(v MirrorTransformation) *MirrorTransformation { 2090 return &v 2091 } 2092 2093 // MonoHueTransformationPtr returns pointer of MonoHueTransformation 2094 func MonoHueTransformationPtr(v MonoHueTransformation) *MonoHueTransformation { 2095 return &v 2096 } 2097 2098 // OpacityTransformationPtr returns pointer of OpacityTransformation 2099 func OpacityTransformationPtr(v OpacityTransformation) *OpacityTransformation { 2100 return &v 2101 } 2102 2103 // OutputImageAllowedFormatsPtr returns pointer of OutputImageAllowedFormats 2104 func OutputImageAllowedFormatsPtr(v OutputImageAllowedFormats) *OutputImageAllowedFormats { 2105 return &v 2106 } 2107 2108 // OutputImageForcedFormatsPtr returns pointer of OutputImageForcedFormats 2109 func OutputImageForcedFormatsPtr(v OutputImageForcedFormats) *OutputImageForcedFormats { 2110 return &v 2111 } 2112 2113 // OutputImagePerceptualQualityPtr returns pointer of OutputImagePerceptualQuality 2114 func OutputImagePerceptualQualityPtr(v OutputImagePerceptualQuality) *OutputImagePerceptualQuality { 2115 return &v 2116 } 2117 2118 // RegionOfInterestCropStylePtr returns pointer of RegionOfInterestCropStyle 2119 func RegionOfInterestCropStylePtr(v RegionOfInterestCropStyle) *RegionOfInterestCropStyle { 2120 return &v 2121 } 2122 2123 // RegionOfInterestCropTransformationPtr returns pointer of RegionOfInterestCropTransformation 2124 func RegionOfInterestCropTransformationPtr(v RegionOfInterestCropTransformation) *RegionOfInterestCropTransformation { 2125 return &v 2126 } 2127 2128 // RelativeCropTransformationPtr returns pointer of RelativeCropTransformation 2129 func RelativeCropTransformationPtr(v RelativeCropTransformation) *RelativeCropTransformation { 2130 return &v 2131 } 2132 2133 // RemoveColorTransformationPtr returns pointer of RemoveColorTransformation 2134 func RemoveColorTransformationPtr(v RemoveColorTransformation) *RemoveColorTransformation { 2135 return &v 2136 } 2137 2138 // ResizeAspectPtr returns pointer of ResizeAspect 2139 func ResizeAspectPtr(v ResizeAspect) *ResizeAspect { 2140 return &v 2141 } 2142 2143 // ResizeTransformationPtr returns pointer of ResizeTransformation 2144 func ResizeTransformationPtr(v ResizeTransformation) *ResizeTransformation { 2145 return &v 2146 } 2147 2148 // ResizeTypePtr returns pointer of ResizeType 2149 func ResizeTypePtr(v ResizeType) *ResizeType { 2150 return &v 2151 } 2152 2153 // RotateTransformationPtr returns pointer of RotateTransformation 2154 func RotateTransformationPtr(v RotateTransformation) *RotateTransformation { 2155 return &v 2156 } 2157 2158 // ScaleTransformationPtr returns pointer of ScaleTransformation 2159 func ScaleTransformationPtr(v ScaleTransformation) *ScaleTransformation { 2160 return &v 2161 } 2162 2163 // ShearTransformationPtr returns pointer of ShearTransformation 2164 func ShearTransformationPtr(v ShearTransformation) *ShearTransformation { 2165 return &v 2166 } 2167 2168 // SmartCropStylePtr returns pointer of SmartCropStyle 2169 func SmartCropStylePtr(v SmartCropStyle) *SmartCropStyle { 2170 return &v 2171 } 2172 2173 // SmartCropTransformationPtr returns pointer of SmartCropTransformation 2174 func SmartCropTransformationPtr(v SmartCropTransformation) *SmartCropTransformation { 2175 return &v 2176 } 2177 2178 // TextImageTypePostTypePtr returns pointer of TextImageTypePostType 2179 func TextImageTypePostTypePtr(v TextImageTypePostType) *TextImageTypePostType { 2180 return &v 2181 } 2182 2183 // TextImageTypeTypePtr returns pointer of TextImageTypeType 2184 func TextImageTypeTypePtr(v TextImageTypeType) *TextImageTypeType { 2185 return &v 2186 } 2187 2188 // TrimTransformationPtr returns pointer of TrimTransformation 2189 func TrimTransformationPtr(v TrimTransformation) *TrimTransformation { 2190 return &v 2191 } 2192 2193 // URLImageTypePostTypePtr returns pointer of URLImageTypePostType 2194 func URLImageTypePostTypePtr(v URLImageTypePostType) *URLImageTypePostType { 2195 return &v 2196 } 2197 2198 // URLImageTypeTypePtr returns pointer of URLImageTypeType 2199 func URLImageTypeTypePtr(v URLImageTypeType) *URLImageTypeType { 2200 return &v 2201 } 2202 2203 // UnsharpMaskTransformationPtr returns pointer of UnsharpMaskTransformation 2204 func UnsharpMaskTransformationPtr(v UnsharpMaskTransformation) *UnsharpMaskTransformation { 2205 return &v 2206 } 2207 2208 // VariableTypePtr returns pointer of VariableType 2209 func VariableTypePtr(v VariableType) *VariableType { 2210 return &v 2211 } 2212 2213 // OutputVideoPerceptualQualityPtr returns pointer of OutputVideoPerceptualQuality 2214 func OutputVideoPerceptualQualityPtr(v OutputVideoPerceptualQuality) *OutputVideoPerceptualQuality { 2215 return &v 2216 } 2217 2218 // OutputVideoVideoAdaptiveQualityPtr returns pointer of OutputVideoVideoAdaptiveQuality 2219 func OutputVideoVideoAdaptiveQualityPtr(v OutputVideoVideoAdaptiveQuality) *OutputVideoVideoAdaptiveQuality { 2220 return &v 2221 } 2222 2223 /*-----------------------------------------------*/ 2224 /////////////////// Validators //////////////////// 2225 /*-----------------------------------------------*/ 2226 2227 // Validate validates Append 2228 func (a Append) Validate() error { 2229 return validation.Errors{ 2230 "Gravity": validation.Validate(a.Gravity), 2231 "GravityPriority": validation.Validate(a.GravityPriority), 2232 "Image": validation.Validate(a.Image, 2233 validation.Required, 2234 ), 2235 "PreserveMinorDimension": validation.Validate(a.PreserveMinorDimension), 2236 "Transformation": validation.Validate(a.Transformation, 2237 validation.Required, 2238 validation.In(AppendTransformationAppend), 2239 ), 2240 }.Filter() 2241 } 2242 2243 // Validate validates AppendGravityPriorityVariableInline 2244 func (a AppendGravityPriorityVariableInline) Validate() error { 2245 return validation.Errors{ 2246 "Name": validation.Validate(a.Name), 2247 "Value": validation.Validate(a.Value, 2248 validation.In(AppendGravityPriorityHorizontal, AppendGravityPriorityVertical), 2249 ), 2250 }.Filter() 2251 } 2252 2253 // Validate validates AspectCrop 2254 func (a AspectCrop) Validate() error { 2255 return validation.Errors{ 2256 "AllowExpansion": validation.Validate(a.AllowExpansion), 2257 "Height": validation.Validate(a.Height), 2258 "Transformation": validation.Validate(a.Transformation, 2259 validation.Required, 2260 validation.In(AspectCropTransformationAspectCrop), 2261 ), 2262 "Width": validation.Validate(a.Width), 2263 "XPosition": validation.Validate(a.XPosition), 2264 "YPosition": validation.Validate(a.YPosition), 2265 }.Filter() 2266 } 2267 2268 // Validate validates BackgroundColor 2269 func (b BackgroundColor) Validate() error { 2270 return validation.Errors{ 2271 "Color": validation.Validate(b.Color, 2272 validation.Required, 2273 ), 2274 "Transformation": validation.Validate(b.Transformation, 2275 validation.Required, 2276 validation.In(BackgroundColorTransformationBackgroundColor), 2277 ), 2278 }.Filter() 2279 } 2280 2281 // Validate validates Blur 2282 func (b Blur) Validate() error { 2283 return validation.Errors{ 2284 "Sigma": validation.Validate(b.Sigma), 2285 "Transformation": validation.Validate(b.Transformation, 2286 validation.Required, 2287 validation.In(BlurTransformationBlur), 2288 ), 2289 }.Filter() 2290 } 2291 2292 // Validate validates BooleanVariableInline 2293 func (b BooleanVariableInline) Validate() error { 2294 return validation.Errors{ 2295 "Name": validation.Validate(b.Name), 2296 "Value": validation.Validate(b.Value), 2297 }.Filter() 2298 } 2299 2300 // Validate validates BoxImageType 2301 func (b BoxImageType) Validate() error { 2302 return validation.Errors{ 2303 "Color": validation.Validate(b.Color), 2304 "Height": validation.Validate(b.Height), 2305 "Transformation": validation.Validate(b.Transformation), 2306 "Type": validation.Validate(b.Type, 2307 validation.Required, 2308 validation.In(BoxImageTypeTypeBox), 2309 ), 2310 "Width": validation.Validate(b.Width), 2311 }.Filter() 2312 } 2313 2314 // Validate validates BoxImageTypePost 2315 func (b BoxImageTypePost) Validate() error { 2316 return validation.Errors{ 2317 "Color": validation.Validate(b.Color), 2318 "Height": validation.Validate(b.Height), 2319 "Transformation": validation.Validate(b.Transformation), 2320 "Type": validation.Validate(b.Type, 2321 validation.Required, 2322 validation.In(BoxImageTypePostTypeBox), 2323 ), 2324 "Width": validation.Validate(b.Width), 2325 }.Filter() 2326 } 2327 2328 // Validate validates Breakpoints 2329 func (b Breakpoints) Validate() error { 2330 return validation.Errors{ 2331 "Widths": validation.Validate(b.Widths, validation.Each()), 2332 }.Filter() 2333 } 2334 2335 // Validate validates ChromaKey 2336 func (c ChromaKey) Validate() error { 2337 return validation.Errors{ 2338 "Hue": validation.Validate(c.Hue), 2339 "HueFeather": validation.Validate(c.HueFeather), 2340 "HueTolerance": validation.Validate(c.HueTolerance), 2341 "LightnessFeather": validation.Validate(c.LightnessFeather), 2342 "LightnessTolerance": validation.Validate(c.LightnessTolerance), 2343 "SaturationFeather": validation.Validate(c.SaturationFeather), 2344 "SaturationTolerance": validation.Validate(c.SaturationTolerance), 2345 "Transformation": validation.Validate(c.Transformation, 2346 validation.Required, 2347 validation.In(ChromaKeyTransformationChromaKey), 2348 ), 2349 }.Filter() 2350 } 2351 2352 // Validate validates CircleImageType 2353 func (c CircleImageType) Validate() error { 2354 return validation.Errors{ 2355 "Color": validation.Validate(c.Color), 2356 "Diameter": validation.Validate(c.Diameter), 2357 "Transformation": validation.Validate(c.Transformation), 2358 "Type": validation.Validate(c.Type, 2359 validation.Required, 2360 validation.In(CircleImageTypeTypeCircle), 2361 ), 2362 "Width": validation.Validate(c.Width), 2363 }.Filter() 2364 } 2365 2366 // Validate validates CircleImageTypePost 2367 func (c CircleImageTypePost) Validate() error { 2368 return validation.Errors{ 2369 "Color": validation.Validate(c.Color), 2370 "Diameter": validation.Validate(c.Diameter), 2371 "Transformation": validation.Validate(c.Transformation), 2372 "Type": validation.Validate(c.Type, 2373 validation.Required, 2374 validation.In(CircleImageTypePostTypeCircle), 2375 ), 2376 "Width": validation.Validate(c.Width), 2377 }.Filter() 2378 } 2379 2380 // Validate validates CircleShapeType 2381 func (c CircleShapeType) Validate() error { 2382 return validation.Errors{ 2383 "Center": validation.Validate(c.Center, 2384 validation.Required, 2385 ), 2386 "Radius": validation.Validate(c.Radius, 2387 validation.Required, 2388 ), 2389 }.Filter() 2390 } 2391 2392 // Validate validates Composite 2393 func (c Composite) Validate() error { 2394 return validation.Errors{ 2395 "Gravity": validation.Validate(c.Gravity), 2396 "Image": validation.Validate(c.Image, 2397 validation.Required, 2398 ), 2399 "Placement": validation.Validate(c.Placement), 2400 "Scale": validation.Validate(c.Scale), 2401 "ScaleDimension": validation.Validate(c.ScaleDimension), 2402 "Transformation": validation.Validate(c.Transformation, 2403 validation.Required, 2404 validation.In(CompositeTransformationComposite), 2405 ), 2406 "XPosition": validation.Validate(c.XPosition), 2407 "YPosition": validation.Validate(c.YPosition), 2408 }.Filter() 2409 } 2410 2411 // Validate validates CompositePlacementVariableInline 2412 func (c CompositePlacementVariableInline) Validate() error { 2413 return validation.Errors{ 2414 "Name": validation.Validate(c.Name), 2415 "Value": validation.Validate(c.Value, 2416 validation.In(CompositePlacementOver, 2417 CompositePlacementUnder, 2418 CompositePlacementMask, 2419 CompositePlacementStencil), 2420 ), 2421 }.Filter() 2422 } 2423 2424 // Validate validates CompositePost 2425 func (c CompositePost) Validate() error { 2426 return validation.Errors{ 2427 "Gravity": validation.Validate(c.Gravity), 2428 "Image": validation.Validate(c.Image, 2429 validation.Required, 2430 ), 2431 "Placement": validation.Validate(c.Placement), 2432 "Scale": validation.Validate(c.Scale), 2433 "ScaleDimension": validation.Validate(c.ScaleDimension), 2434 "Transformation": validation.Validate(c.Transformation, 2435 validation.Required, 2436 validation.In(CompositePostTransformationComposite), 2437 ), 2438 "XPosition": validation.Validate(c.XPosition), 2439 "YPosition": validation.Validate(c.YPosition), 2440 }.Filter() 2441 } 2442 2443 // Validate validates CompositePostPlacementVariableInline 2444 func (c CompositePostPlacementVariableInline) Validate() error { 2445 return validation.Errors{ 2446 "Name": validation.Validate(c.Name), 2447 "Value": validation.Validate(c.Value, 2448 validation.In(CompositePostPlacementOver, 2449 CompositePostPlacementUnder, 2450 CompositePostPlacementMask, 2451 CompositePostPlacementStencil), 2452 ), 2453 }.Filter() 2454 } 2455 2456 // Validate validates CompositePostScaleDimensionVariableInline 2457 func (c CompositePostScaleDimensionVariableInline) Validate() error { 2458 return validation.Errors{ 2459 "Name": validation.Validate(c.Name), 2460 "Value": validation.Validate(c.Value, 2461 validation.In(CompositePostScaleDimensionWidth, CompositePostScaleDimensionHeight), 2462 ), 2463 }.Filter() 2464 } 2465 2466 // Validate validates CompositeScaleDimensionVariableInline 2467 func (c CompositeScaleDimensionVariableInline) Validate() error { 2468 return validation.Errors{ 2469 "Name": validation.Validate(c.Name), 2470 "Value": validation.Validate(c.Value, 2471 validation.In(CompositeScaleDimensionWidth, CompositeScaleDimensionHeight), 2472 ), 2473 }.Filter() 2474 } 2475 2476 // Validate validates Compound 2477 func (c Compound) Validate() error { 2478 return validation.Errors{ 2479 "Transformation": validation.Validate(c.Transformation, 2480 validation.Required, 2481 validation.In(CompoundTransformationCompound), 2482 ), 2483 "Transformations": validation.Validate(c.Transformations), 2484 }.Filter() 2485 } 2486 2487 // Validate validates CompoundPost 2488 func (c CompoundPost) Validate() error { 2489 return validation.Errors{ 2490 "Transformation": validation.Validate(c.Transformation, 2491 validation.Required, 2492 validation.In(CompoundPostTransformationCompound), 2493 ), 2494 "Transformations": validation.Validate(c.Transformations), 2495 }.Filter() 2496 } 2497 2498 // Validate validates Contrast 2499 func (c Contrast) Validate() error { 2500 return validation.Errors{ 2501 "Brightness": validation.Validate(c.Brightness), 2502 "Contrast": validation.Validate(c.Contrast), 2503 "Transformation": validation.Validate(c.Transformation, 2504 validation.Required, 2505 validation.In(ContrastTransformationContrast), 2506 ), 2507 }.Filter() 2508 } 2509 2510 // Validate validates Crop 2511 func (c Crop) Validate() error { 2512 return validation.Errors{ 2513 "AllowExpansion": validation.Validate(c.AllowExpansion), 2514 "Gravity": validation.Validate(c.Gravity), 2515 "Height": validation.Validate(c.Height, 2516 validation.Required, 2517 ), 2518 "Transformation": validation.Validate(c.Transformation, 2519 validation.Required, 2520 validation.In(CropTransformationCrop), 2521 ), 2522 "Width": validation.Validate(c.Width, 2523 validation.Required, 2524 ), 2525 "XPosition": validation.Validate(c.XPosition), 2526 "YPosition": validation.Validate(c.YPosition), 2527 }.Filter() 2528 } 2529 2530 // Validate validates EnumOptions 2531 func (e EnumOptions) Validate() error { 2532 return validation.Errors{ 2533 "ID": validation.Validate(e.ID, 2534 validation.Required, 2535 ), 2536 "Value": validation.Validate(e.Value, 2537 validation.Required, 2538 ), 2539 }.Filter() 2540 } 2541 2542 // Validate validates FaceCrop 2543 func (f FaceCrop) Validate() error { 2544 return validation.Errors{ 2545 "Algorithm": validation.Validate(f.Algorithm), 2546 "Confidence": validation.Validate(f.Confidence), 2547 "FailGravity": validation.Validate(f.FailGravity), 2548 "Focus": validation.Validate(f.Focus), 2549 "Gravity": validation.Validate(f.Gravity), 2550 "Height": validation.Validate(f.Height, 2551 validation.Required, 2552 ), 2553 "Padding": validation.Validate(f.Padding), 2554 "Style": validation.Validate(f.Style), 2555 "Transformation": validation.Validate(f.Transformation, 2556 validation.Required, 2557 validation.In(FaceCropTransformationFaceCrop), 2558 ), 2559 "Width": validation.Validate(f.Width, 2560 validation.Required, 2561 ), 2562 }.Filter() 2563 } 2564 2565 // Validate validates FaceCropAlgorithmVariableInline 2566 func (f FaceCropAlgorithmVariableInline) Validate() error { 2567 return validation.Errors{ 2568 "Name": validation.Validate(f.Name), 2569 "Value": validation.Validate(f.Value, 2570 validation.In(FaceCropAlgorithmCascade, FaceCropAlgorithmDnn), 2571 ), 2572 }.Filter() 2573 } 2574 2575 // Validate validates FaceCropFocusVariableInline 2576 func (f FaceCropFocusVariableInline) Validate() error { 2577 return validation.Errors{ 2578 "Name": validation.Validate(f.Name), 2579 "Value": validation.Validate(f.Value, 2580 validation.In(FaceCropFocusAllFaces, FaceCropFocusBiggestFace), 2581 ), 2582 }.Filter() 2583 } 2584 2585 // Validate validates FaceCropStyleVariableInline 2586 func (f FaceCropStyleVariableInline) Validate() error { 2587 return validation.Errors{ 2588 "Name": validation.Validate(f.Name), 2589 "Value": validation.Validate(f.Value, 2590 validation.In(FaceCropStyleCrop, FaceCropStyleFill, FaceCropStyleZoom), 2591 ), 2592 }.Filter() 2593 } 2594 2595 // Validate validates FeatureCrop 2596 func (f FeatureCrop) Validate() error { 2597 return validation.Errors{ 2598 "FailGravity": validation.Validate(f.FailGravity), 2599 "FeatureRadius": validation.Validate(f.FeatureRadius), 2600 "Gravity": validation.Validate(f.Gravity), 2601 "Height": validation.Validate(f.Height, 2602 validation.Required, 2603 ), 2604 "MaxFeatures": validation.Validate(f.MaxFeatures), 2605 "MinFeatureQuality": validation.Validate(f.MinFeatureQuality), 2606 "Padding": validation.Validate(f.Padding), 2607 "Style": validation.Validate(f.Style), 2608 "Transformation": validation.Validate(f.Transformation, 2609 validation.Required, 2610 validation.In(FeatureCropTransformationFeatureCrop), 2611 ), 2612 "Width": validation.Validate(f.Width, 2613 validation.Required, 2614 ), 2615 }.Filter() 2616 } 2617 2618 // Validate validates FeatureCropStyleVariableInline 2619 func (f FeatureCropStyleVariableInline) Validate() error { 2620 return validation.Errors{ 2621 "Name": validation.Validate(f.Name), 2622 "Value": validation.Validate(f.Value, 2623 validation.In(FeatureCropStyleCrop, FeatureCropStyleFill, FeatureCropStyleZoom), 2624 ), 2625 }.Filter() 2626 } 2627 2628 // Validate validates FitAndFill 2629 func (f FitAndFill) Validate() error { 2630 return validation.Errors{ 2631 "FillTransformation": validation.Validate(f.FillTransformation), 2632 "Height": validation.Validate(f.Height, 2633 validation.Required, 2634 ), 2635 "Transformation": validation.Validate(f.Transformation, 2636 validation.Required, 2637 validation.In(FitAndFillTransformationFitAndFill), 2638 ), 2639 "Width": validation.Validate(f.Width, 2640 validation.Required, 2641 ), 2642 }.Filter() 2643 } 2644 2645 // Validate validates Goop 2646 func (g Goop) Validate() error { 2647 return validation.Errors{ 2648 "Chaos": validation.Validate(g.Chaos), 2649 "Density": validation.Validate(g.Density), 2650 "Power": validation.Validate(g.Power), 2651 "Seed": validation.Validate(g.Seed), 2652 "Transformation": validation.Validate(g.Transformation, 2653 validation.Required, 2654 validation.In(GoopTransformationGoop), 2655 ), 2656 }.Filter() 2657 } 2658 2659 // Validate validates GravityPostVariableInline 2660 func (g GravityPostVariableInline) Validate() error { 2661 return validation.Errors{ 2662 "Name": validation.Validate(g.Name), 2663 "Value": validation.Validate(g.Value, 2664 validation.In(GravityPostNorth, 2665 GravityPostNorthEast, 2666 GravityPostNorthWest, 2667 GravityPostSouth, 2668 GravityPostSouthEast, 2669 GravityPostSouthWest, 2670 GravityPostCenter, 2671 GravityPostEast, 2672 GravityPostWest), 2673 ), 2674 }.Filter() 2675 } 2676 2677 // Validate validates GravityVariableInline 2678 func (g GravityVariableInline) Validate() error { 2679 return validation.Errors{ 2680 "Name": validation.Validate(g.Name), 2681 "Value": validation.Validate(g.Value, 2682 validation.In(GravityNorth, 2683 GravityNorthEast, 2684 GravityNorthWest, 2685 GravitySouth, 2686 GravitySouthEast, 2687 GravitySouthWest, 2688 GravityCenter, 2689 GravityEast, 2690 GravityWest), 2691 ), 2692 }.Filter() 2693 } 2694 2695 // Validate validates Grayscale 2696 func (g Grayscale) Validate() error { 2697 return validation.Errors{ 2698 "Transformation": validation.Validate(g.Transformation, 2699 validation.Required, 2700 validation.In(GrayscaleTransformationGrayscale), 2701 ), 2702 "Type": validation.Validate(g.Type), 2703 }.Filter() 2704 } 2705 2706 // Validate validates GrayscaleTypeVariableInline 2707 func (g GrayscaleTypeVariableInline) Validate() error { 2708 return validation.Errors{ 2709 "Name": validation.Validate(g.Name), 2710 "Value": validation.Validate(g.Value, 2711 validation.In(GrayscaleTypeRec601, 2712 GrayscaleTypeRec709, 2713 GrayscaleTypeBrightness, 2714 GrayscaleTypeLightness), 2715 ), 2716 }.Filter() 2717 } 2718 2719 // Validate validates HSL 2720 func (h HSL) Validate() error { 2721 return validation.Errors{ 2722 "Hue": validation.Validate(h.Hue), 2723 "Lightness": validation.Validate(h.Lightness), 2724 "Saturation": validation.Validate(h.Saturation), 2725 "Transformation": validation.Validate(h.Transformation, 2726 validation.Required, 2727 validation.In(HSLTransformationHSL), 2728 ), 2729 }.Filter() 2730 } 2731 2732 // Validate validates HSV 2733 func (h HSV) Validate() error { 2734 return validation.Errors{ 2735 "Hue": validation.Validate(h.Hue), 2736 "Saturation": validation.Validate(h.Saturation), 2737 "Transformation": validation.Validate(h.Transformation, 2738 validation.Required, 2739 validation.In(HSVTransformationHSV), 2740 ), 2741 "Value": validation.Validate(h.Value), 2742 }.Filter() 2743 } 2744 2745 // Validate validates IfDimension 2746 func (i IfDimension) Validate() error { 2747 return validation.Errors{ 2748 "Default": validation.Validate(i.Default), 2749 "Dimension": validation.Validate(i.Dimension), 2750 "Equal": validation.Validate(i.Equal), 2751 "GreaterThan": validation.Validate(i.GreaterThan), 2752 "LessThan": validation.Validate(i.LessThan), 2753 "Transformation": validation.Validate(i.Transformation, 2754 validation.Required, 2755 validation.In(IfDimensionTransformationIfDimension), 2756 ), 2757 "Value": validation.Validate(i.Value, 2758 validation.Required, 2759 ), 2760 }.Filter() 2761 } 2762 2763 // Validate validates IfDimensionDimensionVariableInline 2764 func (i IfDimensionDimensionVariableInline) Validate() error { 2765 return validation.Errors{ 2766 "Name": validation.Validate(i.Name), 2767 "Value": validation.Validate(i.Value, 2768 validation.In(IfDimensionDimensionWidth, IfDimensionDimensionHeight, IfDimensionDimensionBoth), 2769 ), 2770 }.Filter() 2771 } 2772 2773 // Validate validates IfDimensionPost 2774 func (i IfDimensionPost) Validate() error { 2775 return validation.Errors{ 2776 "Default": validation.Validate(i.Default), 2777 "Dimension": validation.Validate(i.Dimension), 2778 "Equal": validation.Validate(i.Equal), 2779 "GreaterThan": validation.Validate(i.GreaterThan), 2780 "LessThan": validation.Validate(i.LessThan), 2781 "Transformation": validation.Validate(i.Transformation, 2782 validation.Required, 2783 validation.In(IfDimensionPostTransformationIfDimension), 2784 ), 2785 "Value": validation.Validate(i.Value, 2786 validation.Required, 2787 ), 2788 }.Filter() 2789 } 2790 2791 // Validate validates IfDimensionPostDimensionVariableInline 2792 func (i IfDimensionPostDimensionVariableInline) Validate() error { 2793 return validation.Errors{ 2794 "Name": validation.Validate(i.Name), 2795 "Value": validation.Validate(i.Value, 2796 validation.In(IfDimensionPostDimensionWidth, IfDimensionPostDimensionHeight, IfDimensionPostDimensionBoth), 2797 ), 2798 }.Filter() 2799 } 2800 2801 // Validate validates IfOrientation 2802 func (i IfOrientation) Validate() error { 2803 return validation.Errors{ 2804 "Default": validation.Validate(i.Default), 2805 "Landscape": validation.Validate(i.Landscape), 2806 "Portrait": validation.Validate(i.Portrait), 2807 "Square": validation.Validate(i.Square), 2808 "Transformation": validation.Validate(i.Transformation, 2809 validation.Required, 2810 validation.In(IfOrientationTransformationIfOrientation), 2811 ), 2812 }.Filter() 2813 } 2814 2815 // Validate validates IfOrientationPost 2816 func (i IfOrientationPost) Validate() error { 2817 return validation.Errors{ 2818 "Default": validation.Validate(i.Default), 2819 "Landscape": validation.Validate(i.Landscape), 2820 "Portrait": validation.Validate(i.Portrait), 2821 "Square": validation.Validate(i.Square), 2822 "Transformation": validation.Validate(i.Transformation, 2823 validation.Required, 2824 validation.In(IfOrientationPostTransformationIfOrientation), 2825 ), 2826 }.Filter() 2827 } 2828 2829 // Validate validates ImQuery 2830 func (i ImQuery) Validate() error { 2831 return validation.Errors{ 2832 "AllowedTransformations": validation.Validate(i.AllowedTransformations, 2833 validation.Required, validation.Each( 2834 validation.In(ImQueryAllowedTransformationsAppend, 2835 ImQueryAllowedTransformationsAspectCrop, 2836 ImQueryAllowedTransformationsBackgroundColor, 2837 ImQueryAllowedTransformationsBlur, 2838 ImQueryAllowedTransformationsComposite, 2839 ImQueryAllowedTransformationsContrast, 2840 ImQueryAllowedTransformationsCrop, 2841 ImQueryAllowedTransformationsChromaKey, 2842 ImQueryAllowedTransformationsFaceCrop, 2843 ImQueryAllowedTransformationsFeatureCrop, 2844 ImQueryAllowedTransformationsFitAndFill, 2845 ImQueryAllowedTransformationsGoop, 2846 ImQueryAllowedTransformationsGrayscale, 2847 ImQueryAllowedTransformationsHSL, 2848 ImQueryAllowedTransformationsHSV, 2849 ImQueryAllowedTransformationsMaxColors, 2850 ImQueryAllowedTransformationsMirror, 2851 ImQueryAllowedTransformationsMonoHue, 2852 ImQueryAllowedTransformationsOpacity, 2853 ImQueryAllowedTransformationsRegionOfInterestCrop, 2854 ImQueryAllowedTransformationsRelativeCrop, 2855 ImQueryAllowedTransformationsRemoveColor, 2856 ImQueryAllowedTransformationsResize, 2857 ImQueryAllowedTransformationsRotate, 2858 ImQueryAllowedTransformationsScale, 2859 ImQueryAllowedTransformationsShear, 2860 ImQueryAllowedTransformationsTrim, 2861 ImQueryAllowedTransformationsUnsharpMask, 2862 ImQueryAllowedTransformationsIfDimension, 2863 ImQueryAllowedTransformationsIfOrientation)), 2864 ), 2865 "Query": validation.Validate(i.Query, 2866 validation.Required, 2867 ), 2868 "Transformation": validation.Validate(i.Transformation, 2869 validation.Required, 2870 validation.In(ImQueryTransformationImQuery), 2871 ), 2872 }.Filter() 2873 } 2874 2875 // Validate validates IntegerVariableInline 2876 func (i IntegerVariableInline) Validate() error { 2877 return validation.Errors{ 2878 "Name": validation.Validate(i.Name), 2879 "Value": validation.Validate(i.Value), 2880 }.Filter() 2881 } 2882 2883 // Validate validates MaxColors 2884 func (m MaxColors) Validate() error { 2885 return validation.Errors{ 2886 "Colors": validation.Validate(m.Colors, 2887 validation.Required, 2888 ), 2889 "Transformation": validation.Validate(m.Transformation, 2890 validation.Required, 2891 validation.In(MaxColorsTransformationMaxColors), 2892 ), 2893 }.Filter() 2894 } 2895 2896 // Validate validates Mirror 2897 func (m Mirror) Validate() error { 2898 return validation.Errors{ 2899 "Horizontal": validation.Validate(m.Horizontal), 2900 "Transformation": validation.Validate(m.Transformation, 2901 validation.Required, 2902 validation.In(MirrorTransformationMirror), 2903 ), 2904 "Vertical": validation.Validate(m.Vertical), 2905 }.Filter() 2906 } 2907 2908 // Validate validates MonoHue 2909 func (m MonoHue) Validate() error { 2910 return validation.Errors{ 2911 "Hue": validation.Validate(m.Hue), 2912 "Transformation": validation.Validate(m.Transformation, 2913 validation.Required, 2914 validation.In(MonoHueTransformationMonoHue), 2915 ), 2916 }.Filter() 2917 } 2918 2919 // Validate validates NumberVariableInline 2920 func (n NumberVariableInline) Validate() error { 2921 return validation.Errors{ 2922 "Name": validation.Validate(n.Name), 2923 "Value": validation.Validate(n.Value), 2924 }.Filter() 2925 } 2926 2927 // Validate validates Opacity 2928 func (o Opacity) Validate() error { 2929 return validation.Errors{ 2930 "Opacity": validation.Validate(o.Opacity, 2931 validation.Required, 2932 ), 2933 "Transformation": validation.Validate(o.Transformation, 2934 validation.Required, 2935 validation.In(OpacityTransformationOpacity), 2936 ), 2937 }.Filter() 2938 } 2939 2940 // Validate validates OutputImage 2941 func (o OutputImage) Validate() error { 2942 return validation.Errors{ 2943 "AdaptiveQuality": validation.Validate(o.AdaptiveQuality, 2944 validation.Min(1), 2945 validation.Max(100), 2946 ), 2947 "AllowPristineOnDownsize": validation.Validate(o.AllowPristineOnDownsize), 2948 "AllowedFormats": validation.Validate(o.AllowedFormats, validation.Each( 2949 validation.In(OutputImageAllowedFormatsGif, 2950 OutputImageAllowedFormatsJpeg, 2951 OutputImageAllowedFormatsPng, 2952 OutputImageAllowedFormatsWebp, 2953 OutputImageAllowedFormatsJpegxr, 2954 OutputImageAllowedFormatsJpeg2000, 2955 OutputImageAllowedFormatsAvif)), 2956 ), 2957 "ForcedFormats": validation.Validate(o.ForcedFormats, validation.Each( 2958 validation.In(OutputImageForcedFormatsGif, 2959 OutputImageForcedFormatsJpeg, 2960 OutputImageForcedFormatsPng, 2961 OutputImageForcedFormatsWebp, 2962 OutputImageForcedFormatsJpegxr, 2963 OutputImageForcedFormatsJpeg2000, 2964 OutputImageForcedFormatsAvif)), 2965 ), 2966 "PerceptualQuality": validation.Validate(o.PerceptualQuality), 2967 "PerceptualQualityFloor": validation.Validate(o.PerceptualQualityFloor, 2968 validation.Min(1), 2969 validation.Max(100), 2970 ), 2971 "PreferModernFormats": validation.Validate(o.PreferModernFormats), 2972 "Quality": validation.Validate(o.Quality), 2973 }.Filter() 2974 } 2975 2976 // Validate validates OutputImagePerceptualQualityVariableInline 2977 func (o OutputImagePerceptualQualityVariableInline) Validate() error { 2978 return validation.Errors{ 2979 "Name": validation.Validate(o.Name), 2980 "Value": validation.Validate(o.Value, 2981 validation.In(OutputImagePerceptualQualityHigh, 2982 OutputImagePerceptualQualityMediumHigh, 2983 OutputImagePerceptualQualityMedium, 2984 OutputImagePerceptualQualityMediumLow, 2985 OutputImagePerceptualQualityLow), 2986 ), 2987 }.Filter() 2988 } 2989 2990 // Validate validates PointShapeType 2991 func (p PointShapeType) Validate() error { 2992 return validation.Errors{ 2993 "X": validation.Validate(p.X, 2994 validation.Required, 2995 ), 2996 "Y": validation.Validate(p.Y, 2997 validation.Required, 2998 ), 2999 }.Filter() 3000 } 3001 3002 // Validate validates PolicyOutputImage 3003 func (p PolicyOutputImage) Validate() error { 3004 return validation.Errors{ 3005 "Breakpoints": validation.Validate(p.Breakpoints), 3006 "DateCreated": validation.Validate(p.DateCreated, 3007 validation.Required, 3008 ), 3009 "Hosts": validation.Validate(p.Hosts, validation.Each()), 3010 "ID": validation.Validate(p.ID, 3011 validation.Required, 3012 ), 3013 "Output": validation.Validate(p.Output), 3014 "PostBreakpointTransformations": validation.Validate(p.PostBreakpointTransformations), 3015 "PreviousVersion": validation.Validate(p.PreviousVersion, 3016 validation.Required, 3017 ), 3018 "RolloutInfo": validation.Validate(p.RolloutInfo, 3019 validation.Required, 3020 ), 3021 "Transformations": validation.Validate(p.Transformations), 3022 "User": validation.Validate(p.User, 3023 validation.Required, 3024 ), 3025 "Variables": validation.Validate(p.Variables, validation.Each()), 3026 "Version": validation.Validate(p.Version, 3027 validation.Required, 3028 ), 3029 "Video": validation.Validate(p.Video, 3030 validation.In(PolicyOutputImageVideoFalse), 3031 ), 3032 }.Filter() 3033 } 3034 3035 // Validate validates PolygonShapeType 3036 func (p PolygonShapeType) Validate() error { 3037 return validation.Errors{ 3038 "Points": validation.Validate(p.Points, 3039 validation.Required, validation.Each(), 3040 ), 3041 }.Filter() 3042 } 3043 3044 // Validate validates QueryVariableInline 3045 func (q QueryVariableInline) Validate() error { 3046 return validation.Errors{ 3047 "Name": validation.Validate(q.Name, 3048 validation.Required, 3049 ), 3050 }.Filter() 3051 } 3052 3053 // Validate validates RectangleShapeType 3054 func (r RectangleShapeType) Validate() error { 3055 return validation.Errors{ 3056 "Anchor": validation.Validate(r.Anchor, 3057 validation.Required, 3058 ), 3059 "Height": validation.Validate(r.Height, 3060 validation.Required, 3061 ), 3062 "Width": validation.Validate(r.Width, 3063 validation.Required, 3064 ), 3065 }.Filter() 3066 } 3067 3068 // Validate validates RegionOfInterestCrop 3069 func (r RegionOfInterestCrop) Validate() error { 3070 return validation.Errors{ 3071 "Gravity": validation.Validate(r.Gravity), 3072 "Height": validation.Validate(r.Height, 3073 validation.Required, 3074 ), 3075 "RegionOfInterest": validation.Validate(r.RegionOfInterest, 3076 validation.Required, 3077 ), 3078 "Style": validation.Validate(r.Style), 3079 "Transformation": validation.Validate(r.Transformation, 3080 validation.Required, 3081 validation.In(RegionOfInterestCropTransformationRegionOfInterestCrop), 3082 ), 3083 "Width": validation.Validate(r.Width, 3084 validation.Required, 3085 ), 3086 }.Filter() 3087 } 3088 3089 // Validate validates RegionOfInterestCropStyleVariableInline 3090 func (r RegionOfInterestCropStyleVariableInline) Validate() error { 3091 return validation.Errors{ 3092 "Name": validation.Validate(r.Name), 3093 "Value": validation.Validate(r.Value, 3094 validation.In(RegionOfInterestCropStyleCrop, RegionOfInterestCropStyleFill, RegionOfInterestCropStyleZoom), 3095 ), 3096 }.Filter() 3097 } 3098 3099 // Validate validates RelativeCrop 3100 func (r RelativeCrop) Validate() error { 3101 return validation.Errors{ 3102 "East": validation.Validate(r.East), 3103 "North": validation.Validate(r.North), 3104 "South": validation.Validate(r.South), 3105 "Transformation": validation.Validate(r.Transformation, 3106 validation.Required, 3107 validation.In(RelativeCropTransformationRelativeCrop), 3108 ), 3109 "West": validation.Validate(r.West), 3110 }.Filter() 3111 } 3112 3113 // Validate validates RemoveColor 3114 func (r RemoveColor) Validate() error { 3115 return validation.Errors{ 3116 "Color": validation.Validate(r.Color, 3117 validation.Required, 3118 ), 3119 "Feather": validation.Validate(r.Feather), 3120 "Tolerance": validation.Validate(r.Tolerance), 3121 "Transformation": validation.Validate(r.Transformation, 3122 validation.Required, 3123 validation.In(RemoveColorTransformationRemoveColor), 3124 ), 3125 }.Filter() 3126 } 3127 3128 // Validate validates Resize 3129 func (r Resize) Validate() error { 3130 return validation.Errors{ 3131 "Aspect": validation.Validate(r.Aspect), 3132 "Height": validation.Validate(r.Height), 3133 "Transformation": validation.Validate(r.Transformation, 3134 validation.Required, 3135 validation.In(ResizeTransformationResize), 3136 ), 3137 "Type": validation.Validate(r.Type), 3138 "Width": validation.Validate(r.Width), 3139 }.Filter() 3140 } 3141 3142 // Validate validates ResizeAspectVariableInline 3143 func (r ResizeAspectVariableInline) Validate() error { 3144 return validation.Errors{ 3145 "Name": validation.Validate(r.Name), 3146 "Value": validation.Validate(r.Value, 3147 validation.In(ResizeAspectFit, ResizeAspectFill, ResizeAspectIgnore), 3148 ), 3149 }.Filter() 3150 } 3151 3152 // Validate validates ResizeTypeVariableInline 3153 func (r ResizeTypeVariableInline) Validate() error { 3154 return validation.Errors{ 3155 "Name": validation.Validate(r.Name), 3156 "Value": validation.Validate(r.Value, 3157 validation.In(ResizeTypeNormal, ResizeTypeUpsize, ResizeTypeDownsize), 3158 ), 3159 }.Filter() 3160 } 3161 3162 // Validate validates RolloutInfo 3163 func (r RolloutInfo) Validate() error { 3164 return validation.Errors{ 3165 "EndTime": validation.Validate(r.EndTime, 3166 validation.Required, 3167 ), 3168 "RolloutDuration": validation.Validate(r.RolloutDuration, 3169 validation.Required, 3170 validation.Min(3600), 3171 validation.Max(604800), 3172 ), 3173 "ServeStaleEndTime": validation.Validate(r.ServeStaleEndTime), 3174 "StartTime": validation.Validate(r.StartTime, 3175 validation.Required, 3176 ), 3177 }.Filter() 3178 } 3179 3180 // Validate validates Rotate 3181 func (r Rotate) Validate() error { 3182 return validation.Errors{ 3183 "Degrees": validation.Validate(r.Degrees, 3184 validation.Required, 3185 ), 3186 "Transformation": validation.Validate(r.Transformation, 3187 validation.Required, 3188 validation.In(RotateTransformationRotate), 3189 ), 3190 }.Filter() 3191 } 3192 3193 // Validate validates Scale 3194 func (s Scale) Validate() error { 3195 return validation.Errors{ 3196 "Height": validation.Validate(s.Height, 3197 validation.Required, 3198 ), 3199 "Transformation": validation.Validate(s.Transformation, 3200 validation.Required, 3201 validation.In(ScaleTransformationScale), 3202 ), 3203 "Width": validation.Validate(s.Width, 3204 validation.Required, 3205 ), 3206 }.Filter() 3207 } 3208 3209 // Validate validates Shear 3210 func (s Shear) Validate() error { 3211 return validation.Errors{ 3212 "Transformation": validation.Validate(s.Transformation, 3213 validation.Required, 3214 validation.In(ShearTransformationShear), 3215 ), 3216 "XShear": validation.Validate(s.XShear), 3217 "YShear": validation.Validate(s.YShear), 3218 }.Filter() 3219 } 3220 3221 // Validate validates SmartCrop 3222 func (s SmartCrop) Validate() error { 3223 return validation.Errors{ 3224 "Debug": validation.Validate(s.Debug), 3225 "Height": validation.Validate(s.Height), 3226 "Sloppy": validation.Validate(s.Sloppy), 3227 "Style": validation.Validate(s.Style), 3228 "Transformation": validation.Validate(s.Transformation, 3229 validation.Required, 3230 validation.In(SmartCropTransformationSmartCrop), 3231 ), 3232 "Width": validation.Validate(s.Width), 3233 }.Filter() 3234 } 3235 3236 // Validate validates SmartCropStyleVariableInline 3237 func (s SmartCropStyleVariableInline) Validate() error { 3238 return validation.Errors{ 3239 "Name": validation.Validate(s.Name), 3240 "Value": validation.Validate(s.Value, 3241 validation.In(SmartCropStyleCrop, SmartCropStyleFill, SmartCropStyleZoom), 3242 ), 3243 }.Filter() 3244 } 3245 3246 // Validate validates StringVariableInline 3247 func (s StringVariableInline) Validate() error { 3248 return validation.Errors{ 3249 "Name": validation.Validate(s.Name), 3250 "Value": validation.Validate(s.Value), 3251 }.Filter() 3252 } 3253 3254 // Validate validates TextImageType 3255 func (t TextImageType) Validate() error { 3256 return validation.Errors{ 3257 "Fill": validation.Validate(t.Fill), 3258 "Size": validation.Validate(t.Size), 3259 "Stroke": validation.Validate(t.Stroke), 3260 "StrokeSize": validation.Validate(t.StrokeSize), 3261 "Text": validation.Validate(t.Text, 3262 validation.Required, 3263 ), 3264 "Transformation": validation.Validate(t.Transformation), 3265 "Type": validation.Validate(t.Type, 3266 validation.Required, 3267 validation.In(TextImageTypeTypeText), 3268 ), 3269 "Typeface": validation.Validate(t.Typeface), 3270 }.Filter() 3271 } 3272 3273 // Validate validates TextImageTypePost 3274 func (t TextImageTypePost) Validate() error { 3275 return validation.Errors{ 3276 "Fill": validation.Validate(t.Fill), 3277 "Size": validation.Validate(t.Size), 3278 "Stroke": validation.Validate(t.Stroke), 3279 "StrokeSize": validation.Validate(t.StrokeSize), 3280 "Text": validation.Validate(t.Text, 3281 validation.Required, 3282 ), 3283 "Transformation": validation.Validate(t.Transformation), 3284 "Type": validation.Validate(t.Type, 3285 validation.Required, 3286 validation.In(TextImageTypePostTypeText), 3287 ), 3288 "Typeface": validation.Validate(t.Typeface), 3289 }.Filter() 3290 } 3291 3292 // Validate validates Trim 3293 func (t Trim) Validate() error { 3294 return validation.Errors{ 3295 "Fuzz": validation.Validate(t.Fuzz, 3296 validation.Max(1), 3297 ), 3298 "Padding": validation.Validate(t.Padding), 3299 "Transformation": validation.Validate(t.Transformation, 3300 validation.Required, 3301 validation.In(TrimTransformationTrim), 3302 ), 3303 }.Filter() 3304 } 3305 3306 // Validate validates URLImageType 3307 func (u URLImageType) Validate() error { 3308 return validation.Errors{ 3309 "Transformation": validation.Validate(u.Transformation), 3310 "Type": validation.Validate(u.Type, 3311 validation.In(URLImageTypeTypeURL), 3312 ), 3313 "URL": validation.Validate(u.URL, 3314 validation.Required, 3315 ), 3316 }.Filter() 3317 } 3318 3319 // Validate validates URLImageTypePost 3320 func (u URLImageTypePost) Validate() error { 3321 return validation.Errors{ 3322 "Transformation": validation.Validate(u.Transformation), 3323 "Type": validation.Validate(u.Type, 3324 validation.In(URLImageTypePostTypeURL), 3325 ), 3326 "URL": validation.Validate(u.URL, 3327 validation.Required, 3328 ), 3329 }.Filter() 3330 } 3331 3332 // Validate validates UnionShapeType 3333 func (u UnionShapeType) Validate() error { 3334 return validation.Errors{ 3335 "Shapes": validation.Validate(u.Shapes, 3336 validation.Required, validation.Each(), 3337 ), 3338 }.Filter() 3339 } 3340 3341 // Validate validates UnsharpMask 3342 func (u UnsharpMask) Validate() error { 3343 return validation.Errors{ 3344 "Gain": validation.Validate(u.Gain), 3345 "Sigma": validation.Validate(u.Sigma), 3346 "Threshold": validation.Validate(u.Threshold), 3347 "Transformation": validation.Validate(u.Transformation, 3348 validation.Required, 3349 validation.In(UnsharpMaskTransformationUnsharpMask), 3350 ), 3351 }.Filter() 3352 } 3353 3354 // Validate validates Variable 3355 func (v Variable) Validate() error { 3356 return validation.Errors{ 3357 "DefaultValue": validation.Validate(v.DefaultValue, 3358 validation.Required.When(v.Type != VariableTypeString), 3359 ), 3360 "EnumOptions": validation.Validate(v.EnumOptions, validation.Each()), 3361 "Name": validation.Validate(v.Name, 3362 validation.Required, 3363 ), 3364 "Postfix": validation.Validate(v.Postfix), 3365 "Prefix": validation.Validate(v.Prefix), 3366 "Type": validation.Validate(v.Type, 3367 validation.Required, 3368 validation.In(VariableTypeBool, 3369 VariableTypeNumber, 3370 VariableTypeURL, 3371 VariableTypeColor, 3372 VariableTypeGravity, 3373 VariableTypePlacement, 3374 VariableTypeScaleDimension, 3375 VariableTypeGrayscaleType, 3376 VariableTypeAspect, 3377 VariableTypeResizeType, 3378 VariableTypeDimension, 3379 VariableTypePerceptualQuality, 3380 VariableTypeString, 3381 VariableTypeFocus), 3382 ), 3383 }.Filter() 3384 } 3385 3386 // Validate validates VariableInline 3387 func (v VariableInline) Validate() error { 3388 return validation.Errors{ 3389 "Var": validation.Validate(v.Var, 3390 validation.Required, 3391 ), 3392 }.Filter() 3393 } 3394 3395 // Validate validates OutputVideo 3396 func (o OutputVideo) Validate() error { 3397 return validation.Errors{ 3398 "PerceptualQuality": validation.Validate(o.PerceptualQuality), 3399 "PlaceholderVideoURL": validation.Validate(o.PlaceholderVideoURL), 3400 "VideoAdaptiveQuality": validation.Validate(o.VideoAdaptiveQuality), 3401 }.Filter() 3402 } 3403 3404 // Validate validates OutputVideoPerceptualQualityVariableInline 3405 func (o OutputVideoPerceptualQualityVariableInline) Validate() error { 3406 return validation.Errors{ 3407 "Name": validation.Validate(o.Name), 3408 "Value": validation.Validate(o.Value, 3409 validation.In(OutputVideoPerceptualQualityHigh, 3410 OutputVideoPerceptualQualityMediumHigh, 3411 OutputVideoPerceptualQualityMedium, 3412 OutputVideoPerceptualQualityMediumLow, 3413 OutputVideoPerceptualQualityLow), 3414 ), 3415 }.Filter() 3416 } 3417 3418 // Validate validates OutputVideoVideoAdaptiveQualityVariableInline 3419 func (o OutputVideoVideoAdaptiveQualityVariableInline) Validate() error { 3420 return validation.Errors{ 3421 "Name": validation.Validate(o.Name), 3422 "Value": validation.Validate(o.Value, 3423 validation.In(OutputVideoVideoAdaptiveQualityHigh, 3424 OutputVideoVideoAdaptiveQualityMediumHigh, 3425 OutputVideoVideoAdaptiveQualityMedium, 3426 OutputVideoVideoAdaptiveQualityMediumLow, 3427 OutputVideoVideoAdaptiveQualityLow), 3428 ), 3429 }.Filter() 3430 } 3431 3432 // Validate validates PolicyOutputVideo 3433 func (p PolicyOutputVideo) Validate() error { 3434 return validation.Errors{ 3435 "Breakpoints": validation.Validate(p.Breakpoints), 3436 "DateCreated": validation.Validate(p.DateCreated, 3437 validation.Required, 3438 ), 3439 "Hosts": validation.Validate(p.Hosts, validation.Each()), 3440 "ID": validation.Validate(p.ID, 3441 validation.Required, 3442 ), 3443 "Output": validation.Validate(p.Output), 3444 "PreviousVersion": validation.Validate(p.PreviousVersion, 3445 validation.Required, 3446 ), 3447 "RolloutInfo": validation.Validate(p.RolloutInfo, 3448 validation.Required, 3449 ), 3450 "User": validation.Validate(p.User, 3451 validation.Required, 3452 ), 3453 "Variables": validation.Validate(p.Variables, validation.Each()), 3454 "Version": validation.Validate(p.Version, 3455 validation.Required, 3456 ), 3457 "Video": validation.Validate(p.Video, 3458 validation.In(PolicyOutputVideoVideoTrue), 3459 ), 3460 }.Filter() 3461 } 3462 3463 /*-----------------------------------------------*/ 3464 //// Variable type marshalers and unmarshalers //// 3465 /*-----------------------------------------------*/ 3466 var ( 3467 3468 // ErrUnmarshalVariableAppendGravityPriorityVariableInline represents an error while unmarshalling AppendGravityPriorityVariableInline 3469 ErrUnmarshalVariableAppendGravityPriorityVariableInline = errors.New("unmarshalling AppendGravityPriorityVariableInline") 3470 // ErrUnmarshalVariableBooleanVariableInline represents an error while unmarshalling BooleanVariableInline 3471 ErrUnmarshalVariableBooleanVariableInline = errors.New("unmarshalling BooleanVariableInline") 3472 // ErrUnmarshalVariableCompositePlacementVariableInline represents an error while unmarshalling CompositePlacementVariableInline 3473 ErrUnmarshalVariableCompositePlacementVariableInline = errors.New("unmarshalling CompositePlacementVariableInline") 3474 // ErrUnmarshalVariableCompositePostPlacementVariableInline represents an error while unmarshalling CompositePostPlacementVariableInline 3475 ErrUnmarshalVariableCompositePostPlacementVariableInline = errors.New("unmarshalling CompositePostPlacementVariableInline") 3476 // ErrUnmarshalVariableCompositePostScaleDimensionVariableInline represents an error while unmarshalling CompositePostScaleDimensionVariableInline 3477 ErrUnmarshalVariableCompositePostScaleDimensionVariableInline = errors.New("unmarshalling CompositePostScaleDimensionVariableInline") 3478 // ErrUnmarshalVariableCompositeScaleDimensionVariableInline represents an error while unmarshalling CompositeScaleDimensionVariableInline 3479 ErrUnmarshalVariableCompositeScaleDimensionVariableInline = errors.New("unmarshalling CompositeScaleDimensionVariableInline") 3480 // ErrUnmarshalVariableFaceCropAlgorithmVariableInline represents an error while unmarshalling FaceCropAlgorithmVariableInline 3481 ErrUnmarshalVariableFaceCropAlgorithmVariableInline = errors.New("unmarshalling FaceCropAlgorithmVariableInline") 3482 // ErrUnmarshalVariableFaceCropFocusVariableInline represents an error while unmarshalling FaceCropFocusVariableInline 3483 ErrUnmarshalVariableFaceCropFocusVariableInline = errors.New("unmarshalling FaceCropFocusVariableInline") 3484 // ErrUnmarshalVariableFaceCropStyleVariableInline represents an error while unmarshalling FaceCropStyleVariableInline 3485 ErrUnmarshalVariableFaceCropStyleVariableInline = errors.New("unmarshalling FaceCropStyleVariableInline") 3486 // ErrUnmarshalVariableFeatureCropStyleVariableInline represents an error while unmarshalling FeatureCropStyleVariableInline 3487 ErrUnmarshalVariableFeatureCropStyleVariableInline = errors.New("unmarshalling FeatureCropStyleVariableInline") 3488 // ErrUnmarshalVariableGravityPostVariableInline represents an error while unmarshalling GravityPostVariableInline 3489 ErrUnmarshalVariableGravityPostVariableInline = errors.New("unmarshalling GravityPostVariableInline") 3490 // ErrUnmarshalVariableGravityVariableInline represents an error while unmarshalling GravityVariableInline 3491 ErrUnmarshalVariableGravityVariableInline = errors.New("unmarshalling GravityVariableInline") 3492 // ErrUnmarshalVariableGrayscaleTypeVariableInline represents an error while unmarshalling GrayscaleTypeVariableInline 3493 ErrUnmarshalVariableGrayscaleTypeVariableInline = errors.New("unmarshalling GrayscaleTypeVariableInline") 3494 // ErrUnmarshalVariableIfDimensionDimensionVariableInline represents an error while unmarshalling IfDimensionDimensionVariableInline 3495 ErrUnmarshalVariableIfDimensionDimensionVariableInline = errors.New("unmarshalling IfDimensionDimensionVariableInline") 3496 // ErrUnmarshalVariableIfDimensionPostDimensionVariableInline represents an error while unmarshalling IfDimensionPostDimensionVariableInline 3497 ErrUnmarshalVariableIfDimensionPostDimensionVariableInline = errors.New("unmarshalling IfDimensionPostDimensionVariableInline") 3498 // ErrUnmarshalVariableIntegerVariableInline represents an error while unmarshalling IntegerVariableInline 3499 ErrUnmarshalVariableIntegerVariableInline = errors.New("unmarshalling IntegerVariableInline") 3500 // ErrUnmarshalVariableNumberVariableInline represents an error while unmarshalling NumberVariableInline 3501 ErrUnmarshalVariableNumberVariableInline = errors.New("unmarshalling NumberVariableInline") 3502 // ErrUnmarshalVariableOutputImagePerceptualQualityVariableInline represents an error while unmarshalling OutputImagePerceptualQualityVariableInline 3503 ErrUnmarshalVariableOutputImagePerceptualQualityVariableInline = errors.New("unmarshalling OutputImagePerceptualQualityVariableInline") 3504 // ErrUnmarshalVariableQueryVariableInline represents an error while unmarshalling QueryVariableInline 3505 ErrUnmarshalVariableQueryVariableInline = errors.New("unmarshalling QueryVariableInline") 3506 // ErrUnmarshalVariableRegionOfInterestCropStyleVariableInline represents an error while unmarshalling RegionOfInterestCropStyleVariableInline 3507 ErrUnmarshalVariableRegionOfInterestCropStyleVariableInline = errors.New("unmarshalling RegionOfInterestCropStyleVariableInline") 3508 // ErrUnmarshalVariableResizeAspectVariableInline represents an error while unmarshalling ResizeAspectVariableInline 3509 ErrUnmarshalVariableResizeAspectVariableInline = errors.New("unmarshalling ResizeAspectVariableInline") 3510 // ErrUnmarshalVariableResizeTypeVariableInline represents an error while unmarshalling ResizeTypeVariableInline 3511 ErrUnmarshalVariableResizeTypeVariableInline = errors.New("unmarshalling ResizeTypeVariableInline") 3512 // ErrUnmarshalVariableSmartCropStyleVariableInline represents an error while unmarshalling SmartCropStyleVariableInline 3513 ErrUnmarshalVariableSmartCropStyleVariableInline = errors.New("unmarshalling SmartCropStyleVariableInline") 3514 // ErrUnmarshalVariableStringVariableInline represents an error while unmarshalling StringVariableInline 3515 ErrUnmarshalVariableStringVariableInline = errors.New("unmarshalling StringVariableInline") 3516 // ErrUnmarshalVariableOutputVideoPerceptualQualityVariableInline represents an error while unmarshalling OutputVideoPerceptualQualityVariableInline 3517 ErrUnmarshalVariableOutputVideoPerceptualQualityVariableInline = errors.New("unmarshalling OutputVideoPerceptualQualityVariableInline") 3518 // ErrUnmarshalVariableOutputVideoVideoAdaptiveQualityVariableInline represents an error while unmarshalling OutputVideoVideoAdaptiveQualityVariableInline 3519 ErrUnmarshalVariableOutputVideoVideoAdaptiveQualityVariableInline = errors.New("unmarshalling OutputVideoVideoAdaptiveQualityVariableInline") 3520 ) 3521 3522 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3523 func (a *AppendGravityPriorityVariableInline) UnmarshalJSON(in []byte) error { 3524 var err error 3525 var variable InlineVariable 3526 if err = json.Unmarshal(in, &variable); err == nil { 3527 a.Name = &variable.Var 3528 a.Value = nil 3529 return nil 3530 } 3531 var value AppendGravityPriority 3532 if err = json.Unmarshal(in, &value); err == nil { 3533 a.Name = nil 3534 a.Value = &value 3535 return nil 3536 } 3537 return fmt.Errorf("%w: %s", ErrUnmarshalVariableAppendGravityPriorityVariableInline, err) 3538 } 3539 3540 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3541 func (a *AppendGravityPriorityVariableInline) MarshalJSON() ([]byte, error) { 3542 if a.Value != nil { 3543 return json.Marshal(*a.Value) 3544 } 3545 if a.Name != nil { 3546 return json.Marshal(VariableInline{Var: *a.Name}) 3547 } 3548 return nil, nil 3549 } 3550 3551 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3552 func (b *BooleanVariableInline) UnmarshalJSON(in []byte) error { 3553 var err error 3554 var variable InlineVariable 3555 if err = json.Unmarshal(in, &variable); err == nil { 3556 b.Name = &variable.Var 3557 b.Value = nil 3558 return nil 3559 } 3560 var value bool 3561 if err = json.Unmarshal(in, &value); err == nil { 3562 b.Name = nil 3563 b.Value = &value 3564 return nil 3565 } 3566 return fmt.Errorf("%w: %s", ErrUnmarshalVariableBooleanVariableInline, err) 3567 } 3568 3569 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3570 func (b *BooleanVariableInline) MarshalJSON() ([]byte, error) { 3571 if b.Value != nil { 3572 return json.Marshal(*b.Value) 3573 } 3574 if b.Name != nil { 3575 return json.Marshal(VariableInline{Var: *b.Name}) 3576 } 3577 return nil, nil 3578 } 3579 3580 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3581 func (c *CompositePlacementVariableInline) UnmarshalJSON(in []byte) error { 3582 var err error 3583 var variable InlineVariable 3584 if err = json.Unmarshal(in, &variable); err == nil { 3585 c.Name = &variable.Var 3586 c.Value = nil 3587 return nil 3588 } 3589 var value CompositePlacement 3590 if err = json.Unmarshal(in, &value); err == nil { 3591 c.Name = nil 3592 c.Value = &value 3593 return nil 3594 } 3595 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositePlacementVariableInline, err) 3596 } 3597 3598 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3599 func (c *CompositePlacementVariableInline) MarshalJSON() ([]byte, error) { 3600 if c.Value != nil { 3601 return json.Marshal(*c.Value) 3602 } 3603 if c.Name != nil { 3604 return json.Marshal(VariableInline{Var: *c.Name}) 3605 } 3606 return nil, nil 3607 } 3608 3609 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3610 func (c *CompositePostPlacementVariableInline) UnmarshalJSON(in []byte) error { 3611 var err error 3612 var variable InlineVariable 3613 if err = json.Unmarshal(in, &variable); err == nil { 3614 c.Name = &variable.Var 3615 c.Value = nil 3616 return nil 3617 } 3618 var value CompositePostPlacement 3619 if err = json.Unmarshal(in, &value); err == nil { 3620 c.Name = nil 3621 c.Value = &value 3622 return nil 3623 } 3624 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositePostPlacementVariableInline, err) 3625 } 3626 3627 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3628 func (c *CompositePostPlacementVariableInline) MarshalJSON() ([]byte, error) { 3629 if c.Value != nil { 3630 return json.Marshal(*c.Value) 3631 } 3632 if c.Name != nil { 3633 return json.Marshal(VariableInline{Var: *c.Name}) 3634 } 3635 return nil, nil 3636 } 3637 3638 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3639 func (c *CompositePostScaleDimensionVariableInline) UnmarshalJSON(in []byte) error { 3640 var err error 3641 var variable InlineVariable 3642 if err = json.Unmarshal(in, &variable); err == nil { 3643 c.Name = &variable.Var 3644 c.Value = nil 3645 return nil 3646 } 3647 var value CompositePostScaleDimension 3648 if err = json.Unmarshal(in, &value); err == nil { 3649 c.Name = nil 3650 c.Value = &value 3651 return nil 3652 } 3653 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositePostScaleDimensionVariableInline, err) 3654 } 3655 3656 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3657 func (c *CompositePostScaleDimensionVariableInline) MarshalJSON() ([]byte, error) { 3658 if c.Value != nil { 3659 return json.Marshal(*c.Value) 3660 } 3661 if c.Name != nil { 3662 return json.Marshal(VariableInline{Var: *c.Name}) 3663 } 3664 return nil, nil 3665 } 3666 3667 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3668 func (c *CompositeScaleDimensionVariableInline) UnmarshalJSON(in []byte) error { 3669 var err error 3670 var variable InlineVariable 3671 if err = json.Unmarshal(in, &variable); err == nil { 3672 c.Name = &variable.Var 3673 c.Value = nil 3674 return nil 3675 } 3676 var value CompositeScaleDimension 3677 if err = json.Unmarshal(in, &value); err == nil { 3678 c.Name = nil 3679 c.Value = &value 3680 return nil 3681 } 3682 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositeScaleDimensionVariableInline, err) 3683 } 3684 3685 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3686 func (c *CompositeScaleDimensionVariableInline) MarshalJSON() ([]byte, error) { 3687 if c.Value != nil { 3688 return json.Marshal(*c.Value) 3689 } 3690 if c.Name != nil { 3691 return json.Marshal(VariableInline{Var: *c.Name}) 3692 } 3693 return nil, nil 3694 } 3695 3696 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3697 func (f *FaceCropAlgorithmVariableInline) UnmarshalJSON(in []byte) error { 3698 var err error 3699 var variable InlineVariable 3700 if err = json.Unmarshal(in, &variable); err == nil { 3701 f.Name = &variable.Var 3702 f.Value = nil 3703 return nil 3704 } 3705 var value FaceCropAlgorithm 3706 if err = json.Unmarshal(in, &value); err == nil { 3707 f.Name = nil 3708 f.Value = &value 3709 return nil 3710 } 3711 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFaceCropAlgorithmVariableInline, err) 3712 } 3713 3714 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3715 func (f *FaceCropAlgorithmVariableInline) MarshalJSON() ([]byte, error) { 3716 if f.Value != nil { 3717 return json.Marshal(*f.Value) 3718 } 3719 if f.Name != nil { 3720 return json.Marshal(VariableInline{Var: *f.Name}) 3721 } 3722 return nil, nil 3723 } 3724 3725 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3726 func (f *FaceCropFocusVariableInline) UnmarshalJSON(in []byte) error { 3727 var err error 3728 var variable InlineVariable 3729 if err = json.Unmarshal(in, &variable); err == nil { 3730 f.Name = &variable.Var 3731 f.Value = nil 3732 return nil 3733 } 3734 var value FaceCropFocus 3735 if err = json.Unmarshal(in, &value); err == nil { 3736 f.Name = nil 3737 f.Value = &value 3738 return nil 3739 } 3740 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFaceCropFocusVariableInline, err) 3741 } 3742 3743 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3744 func (f *FaceCropFocusVariableInline) MarshalJSON() ([]byte, error) { 3745 if f.Value != nil { 3746 return json.Marshal(*f.Value) 3747 } 3748 if f.Name != nil { 3749 return json.Marshal(VariableInline{Var: *f.Name}) 3750 } 3751 return nil, nil 3752 } 3753 3754 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3755 func (f *FaceCropStyleVariableInline) UnmarshalJSON(in []byte) error { 3756 var err error 3757 var variable InlineVariable 3758 if err = json.Unmarshal(in, &variable); err == nil { 3759 f.Name = &variable.Var 3760 f.Value = nil 3761 return nil 3762 } 3763 var value FaceCropStyle 3764 if err = json.Unmarshal(in, &value); err == nil { 3765 f.Name = nil 3766 f.Value = &value 3767 return nil 3768 } 3769 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFaceCropStyleVariableInline, err) 3770 } 3771 3772 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3773 func (f *FaceCropStyleVariableInline) MarshalJSON() ([]byte, error) { 3774 if f.Value != nil { 3775 return json.Marshal(*f.Value) 3776 } 3777 if f.Name != nil { 3778 return json.Marshal(VariableInline{Var: *f.Name}) 3779 } 3780 return nil, nil 3781 } 3782 3783 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3784 func (f *FeatureCropStyleVariableInline) UnmarshalJSON(in []byte) error { 3785 var err error 3786 var variable InlineVariable 3787 if err = json.Unmarshal(in, &variable); err == nil { 3788 f.Name = &variable.Var 3789 f.Value = nil 3790 return nil 3791 } 3792 var value FeatureCropStyle 3793 if err = json.Unmarshal(in, &value); err == nil { 3794 f.Name = nil 3795 f.Value = &value 3796 return nil 3797 } 3798 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFeatureCropStyleVariableInline, err) 3799 } 3800 3801 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3802 func (f *FeatureCropStyleVariableInline) MarshalJSON() ([]byte, error) { 3803 if f.Value != nil { 3804 return json.Marshal(*f.Value) 3805 } 3806 if f.Name != nil { 3807 return json.Marshal(VariableInline{Var: *f.Name}) 3808 } 3809 return nil, nil 3810 } 3811 3812 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3813 func (g *GravityPostVariableInline) UnmarshalJSON(in []byte) error { 3814 var err error 3815 var variable InlineVariable 3816 if err = json.Unmarshal(in, &variable); err == nil { 3817 g.Name = &variable.Var 3818 g.Value = nil 3819 return nil 3820 } 3821 var value GravityPost 3822 if err = json.Unmarshal(in, &value); err == nil { 3823 g.Name = nil 3824 g.Value = &value 3825 return nil 3826 } 3827 return fmt.Errorf("%w: %s", ErrUnmarshalVariableGravityPostVariableInline, err) 3828 } 3829 3830 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3831 func (g *GravityPostVariableInline) MarshalJSON() ([]byte, error) { 3832 if g.Value != nil { 3833 return json.Marshal(*g.Value) 3834 } 3835 if g.Name != nil { 3836 return json.Marshal(VariableInline{Var: *g.Name}) 3837 } 3838 return nil, nil 3839 } 3840 3841 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3842 func (g *GravityVariableInline) UnmarshalJSON(in []byte) error { 3843 var err error 3844 var variable InlineVariable 3845 if err = json.Unmarshal(in, &variable); err == nil { 3846 g.Name = &variable.Var 3847 g.Value = nil 3848 return nil 3849 } 3850 var value Gravity 3851 if err = json.Unmarshal(in, &value); err == nil { 3852 g.Name = nil 3853 g.Value = &value 3854 return nil 3855 } 3856 return fmt.Errorf("%w: %s", ErrUnmarshalVariableGravityVariableInline, err) 3857 } 3858 3859 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3860 func (g *GravityVariableInline) MarshalJSON() ([]byte, error) { 3861 if g.Value != nil { 3862 return json.Marshal(*g.Value) 3863 } 3864 if g.Name != nil { 3865 return json.Marshal(VariableInline{Var: *g.Name}) 3866 } 3867 return nil, nil 3868 } 3869 3870 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3871 func (g *GrayscaleTypeVariableInline) UnmarshalJSON(in []byte) error { 3872 var err error 3873 var variable InlineVariable 3874 if err = json.Unmarshal(in, &variable); err == nil { 3875 g.Name = &variable.Var 3876 g.Value = nil 3877 return nil 3878 } 3879 var value GrayscaleType 3880 if err = json.Unmarshal(in, &value); err == nil { 3881 g.Name = nil 3882 g.Value = &value 3883 return nil 3884 } 3885 return fmt.Errorf("%w: %s", ErrUnmarshalVariableGrayscaleTypeVariableInline, err) 3886 } 3887 3888 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3889 func (g *GrayscaleTypeVariableInline) MarshalJSON() ([]byte, error) { 3890 if g.Value != nil { 3891 return json.Marshal(*g.Value) 3892 } 3893 if g.Name != nil { 3894 return json.Marshal(VariableInline{Var: *g.Name}) 3895 } 3896 return nil, nil 3897 } 3898 3899 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3900 func (i *IfDimensionDimensionVariableInline) UnmarshalJSON(in []byte) error { 3901 var err error 3902 var variable InlineVariable 3903 if err = json.Unmarshal(in, &variable); err == nil { 3904 i.Name = &variable.Var 3905 i.Value = nil 3906 return nil 3907 } 3908 var value IfDimensionDimension 3909 if err = json.Unmarshal(in, &value); err == nil { 3910 i.Name = nil 3911 i.Value = &value 3912 return nil 3913 } 3914 return fmt.Errorf("%w: %s", ErrUnmarshalVariableIfDimensionDimensionVariableInline, err) 3915 } 3916 3917 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3918 func (i *IfDimensionDimensionVariableInline) MarshalJSON() ([]byte, error) { 3919 if i.Value != nil { 3920 return json.Marshal(*i.Value) 3921 } 3922 if i.Name != nil { 3923 return json.Marshal(VariableInline{Var: *i.Name}) 3924 } 3925 return nil, nil 3926 } 3927 3928 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3929 func (i *IfDimensionPostDimensionVariableInline) UnmarshalJSON(in []byte) error { 3930 var err error 3931 var variable InlineVariable 3932 if err = json.Unmarshal(in, &variable); err == nil { 3933 i.Name = &variable.Var 3934 i.Value = nil 3935 return nil 3936 } 3937 var value IfDimensionPostDimension 3938 if err = json.Unmarshal(in, &value); err == nil { 3939 i.Name = nil 3940 i.Value = &value 3941 return nil 3942 } 3943 return fmt.Errorf("%w: %s", ErrUnmarshalVariableIfDimensionPostDimensionVariableInline, err) 3944 } 3945 3946 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3947 func (i *IfDimensionPostDimensionVariableInline) MarshalJSON() ([]byte, error) { 3948 if i.Value != nil { 3949 return json.Marshal(*i.Value) 3950 } 3951 if i.Name != nil { 3952 return json.Marshal(VariableInline{Var: *i.Name}) 3953 } 3954 return nil, nil 3955 } 3956 3957 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3958 func (i *IntegerVariableInline) UnmarshalJSON(in []byte) error { 3959 var err error 3960 var variable InlineVariable 3961 if err = json.Unmarshal(in, &variable); err == nil { 3962 i.Name = &variable.Var 3963 i.Value = nil 3964 return nil 3965 } 3966 var value int 3967 if err = json.Unmarshal(in, &value); err == nil { 3968 i.Name = nil 3969 i.Value = &value 3970 return nil 3971 } 3972 return fmt.Errorf("%w: %s", ErrUnmarshalVariableIntegerVariableInline, err) 3973 } 3974 3975 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3976 func (i *IntegerVariableInline) MarshalJSON() ([]byte, error) { 3977 if i.Value != nil { 3978 return json.Marshal(*i.Value) 3979 } 3980 if i.Name != nil { 3981 return json.Marshal(VariableInline{Var: *i.Name}) 3982 } 3983 return nil, nil 3984 } 3985 3986 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3987 func (n *NumberVariableInline) UnmarshalJSON(in []byte) error { 3988 var err error 3989 var variable InlineVariable 3990 if err = json.Unmarshal(in, &variable); err == nil { 3991 n.Name = &variable.Var 3992 n.Value = nil 3993 return nil 3994 } 3995 var value float64 3996 if err = json.Unmarshal(in, &value); err == nil { 3997 n.Name = nil 3998 n.Value = &value 3999 return nil 4000 } 4001 return fmt.Errorf("%w: %s", ErrUnmarshalVariableNumberVariableInline, err) 4002 } 4003 4004 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4005 func (n *NumberVariableInline) MarshalJSON() ([]byte, error) { 4006 if n.Value != nil { 4007 return json.Marshal(*n.Value) 4008 } 4009 if n.Name != nil { 4010 return json.Marshal(VariableInline{Var: *n.Name}) 4011 } 4012 return nil, nil 4013 } 4014 4015 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4016 func (o *OutputImagePerceptualQualityVariableInline) UnmarshalJSON(in []byte) error { 4017 var err error 4018 var variable InlineVariable 4019 if err = json.Unmarshal(in, &variable); err == nil { 4020 o.Name = &variable.Var 4021 o.Value = nil 4022 return nil 4023 } 4024 var value OutputImagePerceptualQuality 4025 if err = json.Unmarshal(in, &value); err == nil { 4026 o.Name = nil 4027 o.Value = &value 4028 return nil 4029 } 4030 return fmt.Errorf("%w: %s", ErrUnmarshalVariableOutputImagePerceptualQualityVariableInline, err) 4031 } 4032 4033 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4034 func (o *OutputImagePerceptualQualityVariableInline) MarshalJSON() ([]byte, error) { 4035 if o.Value != nil { 4036 return json.Marshal(*o.Value) 4037 } 4038 if o.Name != nil { 4039 return json.Marshal(VariableInline{Var: *o.Name}) 4040 } 4041 return nil, nil 4042 } 4043 4044 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4045 func (q *QueryVariableInline) UnmarshalJSON(in []byte) error { 4046 var err error 4047 var variable InlineVariable 4048 if err = json.Unmarshal(in, &variable); err == nil { 4049 q.Name = &variable.Var 4050 return nil 4051 } 4052 return fmt.Errorf("%w: %s", ErrUnmarshalVariableQueryVariableInline, err) 4053 } 4054 4055 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4056 func (q *QueryVariableInline) MarshalJSON() ([]byte, error) { 4057 if q.Name != nil { 4058 return json.Marshal(VariableInline{Var: *q.Name}) 4059 } 4060 return nil, nil 4061 } 4062 4063 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4064 func (r *RegionOfInterestCropStyleVariableInline) UnmarshalJSON(in []byte) error { 4065 var err error 4066 var variable InlineVariable 4067 if err = json.Unmarshal(in, &variable); err == nil { 4068 r.Name = &variable.Var 4069 r.Value = nil 4070 return nil 4071 } 4072 var value RegionOfInterestCropStyle 4073 if err = json.Unmarshal(in, &value); err == nil { 4074 r.Name = nil 4075 r.Value = &value 4076 return nil 4077 } 4078 return fmt.Errorf("%w: %s", ErrUnmarshalVariableRegionOfInterestCropStyleVariableInline, err) 4079 } 4080 4081 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4082 func (r *RegionOfInterestCropStyleVariableInline) MarshalJSON() ([]byte, error) { 4083 if r.Value != nil { 4084 return json.Marshal(*r.Value) 4085 } 4086 if r.Name != nil { 4087 return json.Marshal(VariableInline{Var: *r.Name}) 4088 } 4089 return nil, nil 4090 } 4091 4092 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4093 func (r *ResizeAspectVariableInline) UnmarshalJSON(in []byte) error { 4094 var err error 4095 var variable InlineVariable 4096 if err = json.Unmarshal(in, &variable); err == nil { 4097 r.Name = &variable.Var 4098 r.Value = nil 4099 return nil 4100 } 4101 var value ResizeAspect 4102 if err = json.Unmarshal(in, &value); err == nil { 4103 r.Name = nil 4104 r.Value = &value 4105 return nil 4106 } 4107 return fmt.Errorf("%w: %s", ErrUnmarshalVariableResizeAspectVariableInline, err) 4108 } 4109 4110 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4111 func (r *ResizeAspectVariableInline) MarshalJSON() ([]byte, error) { 4112 if r.Value != nil { 4113 return json.Marshal(*r.Value) 4114 } 4115 if r.Name != nil { 4116 return json.Marshal(VariableInline{Var: *r.Name}) 4117 } 4118 return nil, nil 4119 } 4120 4121 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4122 func (r *ResizeTypeVariableInline) UnmarshalJSON(in []byte) error { 4123 var err error 4124 var variable InlineVariable 4125 if err = json.Unmarshal(in, &variable); err == nil { 4126 r.Name = &variable.Var 4127 r.Value = nil 4128 return nil 4129 } 4130 var value ResizeType 4131 if err = json.Unmarshal(in, &value); err == nil { 4132 r.Name = nil 4133 r.Value = &value 4134 return nil 4135 } 4136 return fmt.Errorf("%w: %s", ErrUnmarshalVariableResizeTypeVariableInline, err) 4137 } 4138 4139 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4140 func (r *ResizeTypeVariableInline) MarshalJSON() ([]byte, error) { 4141 if r.Value != nil { 4142 return json.Marshal(*r.Value) 4143 } 4144 if r.Name != nil { 4145 return json.Marshal(VariableInline{Var: *r.Name}) 4146 } 4147 return nil, nil 4148 } 4149 4150 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4151 func (s *SmartCropStyleVariableInline) UnmarshalJSON(in []byte) error { 4152 var err error 4153 var variable InlineVariable 4154 if err = json.Unmarshal(in, &variable); err == nil { 4155 s.Name = &variable.Var 4156 s.Value = nil 4157 return nil 4158 } 4159 var value SmartCropStyle 4160 if err = json.Unmarshal(in, &value); err == nil { 4161 s.Name = nil 4162 s.Value = &value 4163 return nil 4164 } 4165 return fmt.Errorf("%w: %s", ErrUnmarshalVariableSmartCropStyleVariableInline, err) 4166 } 4167 4168 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4169 func (s *SmartCropStyleVariableInline) MarshalJSON() ([]byte, error) { 4170 if s.Value != nil { 4171 return json.Marshal(*s.Value) 4172 } 4173 if s.Name != nil { 4174 return json.Marshal(VariableInline{Var: *s.Name}) 4175 } 4176 return nil, nil 4177 } 4178 4179 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4180 func (s *StringVariableInline) UnmarshalJSON(in []byte) error { 4181 var err error 4182 var variable InlineVariable 4183 if err = json.Unmarshal(in, &variable); err == nil { 4184 s.Name = &variable.Var 4185 s.Value = nil 4186 return nil 4187 } 4188 var value string 4189 if err = json.Unmarshal(in, &value); err == nil { 4190 s.Name = nil 4191 s.Value = &value 4192 return nil 4193 } 4194 return fmt.Errorf("%w: %s", ErrUnmarshalVariableStringVariableInline, err) 4195 } 4196 4197 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4198 func (s *StringVariableInline) MarshalJSON() ([]byte, error) { 4199 if s.Value != nil { 4200 return json.Marshal(*s.Value) 4201 } 4202 if s.Name != nil { 4203 return json.Marshal(VariableInline{Var: *s.Name}) 4204 } 4205 return nil, nil 4206 } 4207 4208 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4209 func (o *OutputVideoPerceptualQualityVariableInline) UnmarshalJSON(in []byte) error { 4210 var err error 4211 var variable InlineVariable 4212 if err = json.Unmarshal(in, &variable); err == nil { 4213 o.Name = &variable.Var 4214 o.Value = nil 4215 return nil 4216 } 4217 var value OutputVideoPerceptualQuality 4218 if err = json.Unmarshal(in, &value); err == nil { 4219 o.Name = nil 4220 o.Value = &value 4221 return nil 4222 } 4223 return fmt.Errorf("%w: %s", ErrUnmarshalVariableOutputVideoPerceptualQualityVariableInline, err) 4224 } 4225 4226 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4227 func (o *OutputVideoPerceptualQualityVariableInline) MarshalJSON() ([]byte, error) { 4228 if o.Value != nil { 4229 return json.Marshal(*o.Value) 4230 } 4231 if o.Name != nil { 4232 return json.Marshal(VariableInline{Var: *o.Name}) 4233 } 4234 return nil, nil 4235 } 4236 4237 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4238 func (o *OutputVideoVideoAdaptiveQualityVariableInline) UnmarshalJSON(in []byte) error { 4239 var err error 4240 var variable InlineVariable 4241 if err = json.Unmarshal(in, &variable); err == nil { 4242 o.Name = &variable.Var 4243 o.Value = nil 4244 return nil 4245 } 4246 var value OutputVideoVideoAdaptiveQuality 4247 if err = json.Unmarshal(in, &value); err == nil { 4248 o.Name = nil 4249 o.Value = &value 4250 return nil 4251 } 4252 return fmt.Errorf("%w: %s", ErrUnmarshalVariableOutputVideoVideoAdaptiveQualityVariableInline, err) 4253 } 4254 4255 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4256 func (o *OutputVideoVideoAdaptiveQualityVariableInline) MarshalJSON() ([]byte, error) { 4257 if o.Value != nil { 4258 return json.Marshal(*o.Value) 4259 } 4260 if o.Name != nil { 4261 return json.Marshal(VariableInline{Var: *o.Name}) 4262 } 4263 return nil, nil 4264 } 4265 4266 /*-----------------------------------------------*/ 4267 ///////////// Image type unmarshalers ///////////// 4268 /*-----------------------------------------------*/ 4269 4270 // ImageTypeValueHandlers is a map of available image types 4271 var ImageTypeValueHandlers = map[string]func() ImageType{ 4272 "box": func() ImageType { return &BoxImageType{} }, 4273 "text": func() ImageType { return &TextImageType{} }, 4274 "url": func() ImageType { return &URLImageType{} }, 4275 "circle": func() ImageType { return &CircleImageType{} }, 4276 } 4277 4278 // ImageTypePostValueHandlers is a map of available image post types 4279 var ImageTypePostValueHandlers = map[string]func() ImageTypePost{ 4280 "box": func() ImageTypePost { return &BoxImageTypePost{} }, 4281 "text": func() ImageTypePost { return &TextImageTypePost{} }, 4282 "url": func() ImageTypePost { return &URLImageTypePost{} }, 4283 "circle": func() ImageTypePost { return &CircleImageTypePost{} }, 4284 } 4285 4286 var ( 4287 4288 // ErrUnmarshalImageTypeAppend represents an error while unmarshalling Append 4289 ErrUnmarshalImageTypeAppend = errors.New("unmarshalling Append") 4290 // ErrUnmarshalImageTypeComposite represents an error while unmarshalling Composite 4291 ErrUnmarshalImageTypeComposite = errors.New("unmarshalling Composite") 4292 ) 4293 4294 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ImageType interface 4295 func (a *Append) UnmarshalJSON(in []byte) error { 4296 data := make(map[string]interface{}) 4297 type AppendT Append 4298 err := json.Unmarshal(in, &data) 4299 if err != nil { 4300 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeAppend, err) 4301 } 4302 image, ok := data["image"] 4303 if !ok { 4304 var target AppendT 4305 err = json.Unmarshal(in, &target) 4306 if err != nil { 4307 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeAppend, err) 4308 } 4309 *a = Append(target) 4310 return nil 4311 } 4312 imageMap := image.(map[string]interface{}) 4313 imageType, ok := imageMap["type"] 4314 if !ok { 4315 _, ok := imageMap["url"] 4316 if !ok { 4317 return fmt.Errorf("%w: missing image type", ErrUnmarshalImageTypeAppend) 4318 } 4319 imageType = "URL" 4320 } 4321 typeName, ok := imageType.(string) 4322 if !ok { 4323 return fmt.Errorf("%w: 'type' field on image should be a string", ErrUnmarshalImageTypeAppend) 4324 } 4325 var target AppendT 4326 targetImage, ok := ImageTypeValueHandlers[strings.ToLower(typeName)] 4327 if !ok { 4328 return fmt.Errorf("%w: invalid image type: %s", ErrUnmarshalImageTypeAppend, imageType) 4329 } 4330 target.Image = targetImage() 4331 err = json.Unmarshal(in, &target) 4332 if err != nil { 4333 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeAppend, err) 4334 } 4335 *a = Append(target) 4336 return nil 4337 } 4338 4339 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ImageType interface 4340 func (c *Composite) UnmarshalJSON(in []byte) error { 4341 data := make(map[string]interface{}) 4342 type CompositeT Composite 4343 err := json.Unmarshal(in, &data) 4344 if err != nil { 4345 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeComposite, err) 4346 } 4347 image, ok := data["image"] 4348 if !ok { 4349 var target CompositeT 4350 err = json.Unmarshal(in, &target) 4351 if err != nil { 4352 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeComposite, err) 4353 } 4354 *c = Composite(target) 4355 return nil 4356 } 4357 imageMap := image.(map[string]interface{}) 4358 imageType, ok := imageMap["type"] 4359 if !ok { 4360 _, ok := imageMap["url"] 4361 if !ok { 4362 return fmt.Errorf("%w: missing image type", ErrUnmarshalImageTypeComposite) 4363 } 4364 imageType = "URL" 4365 } 4366 typeName, ok := imageType.(string) 4367 if !ok { 4368 return fmt.Errorf("%w: 'type' field on image should be a string", ErrUnmarshalImageTypeComposite) 4369 } 4370 var target CompositeT 4371 targetImage, ok := ImageTypeValueHandlers[strings.ToLower(typeName)] 4372 if !ok { 4373 return fmt.Errorf("%w: invalid image type: %s", ErrUnmarshalImageTypeComposite, imageType) 4374 } 4375 target.Image = targetImage() 4376 err = json.Unmarshal(in, &target) 4377 if err != nil { 4378 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeComposite, err) 4379 } 4380 *c = Composite(target) 4381 return nil 4382 } 4383 4384 var ( 4385 4386 // ErrUnmarshalImageTypeCompositePost represents an error while unmarshalling CompositePost 4387 ErrUnmarshalImageTypeCompositePost = errors.New("unmarshalling CompositePost") 4388 ) 4389 4390 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ImageType interface 4391 func (c *CompositePost) UnmarshalJSON(in []byte) error { 4392 data := make(map[string]interface{}) 4393 type CompositePostT CompositePost 4394 err := json.Unmarshal(in, &data) 4395 if err != nil { 4396 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeCompositePost, err) 4397 } 4398 image, ok := data["image"] 4399 if !ok { 4400 var target CompositePostT 4401 err = json.Unmarshal(in, &target) 4402 if err != nil { 4403 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeCompositePost, err) 4404 } 4405 *c = CompositePost(target) 4406 return nil 4407 } 4408 imageMap := image.(map[string]interface{}) 4409 imageType, ok := imageMap["type"] 4410 if !ok { 4411 _, ok := imageMap["url"] 4412 if !ok { 4413 return fmt.Errorf("%w: missing image type", ErrUnmarshalImageTypeCompositePost) 4414 } 4415 imageType = "URL" 4416 } 4417 typeName, ok := imageType.(string) 4418 if !ok { 4419 return fmt.Errorf("%w: 'type' field on image should be a string", ErrUnmarshalImageTypeCompositePost) 4420 } 4421 var target CompositePostT 4422 targetImage, ok := ImageTypePostValueHandlers[strings.ToLower(typeName)] 4423 if !ok { 4424 return fmt.Errorf("%w: invalid image type: %s", ErrUnmarshalImageTypeCompositePost, imageType) 4425 } 4426 target.Image = targetImage() 4427 err = json.Unmarshal(in, &target) 4428 if err != nil { 4429 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeCompositePost, err) 4430 } 4431 *c = CompositePost(target) 4432 return nil 4433 } 4434 4435 /*-----------------------------------------------*/ 4436 ///////////// Shape type unmarshalers ///////////// 4437 /*-----------------------------------------------*/ 4438 4439 // ShapeTypes is a map of available shape types 4440 var ShapeTypes = map[string]func() ShapeType{ 4441 "circle": func() ShapeType { return &CircleShapeType{} }, 4442 "point": func() ShapeType { return &PointShapeType{} }, 4443 "polygon": func() ShapeType { return &PolygonShapeType{} }, 4444 "rectangle": func() ShapeType { return &RectangleShapeType{} }, 4445 "union": func() ShapeType { return &UnionShapeType{} }, 4446 } 4447 4448 // ShapeTypeValueHandlers returns a ShapeType based on fields specific for a concrete ShapeType 4449 var ShapeTypeValueHandlers = func(m map[string]interface{}) ShapeType { 4450 if _, ok := m["radius"]; ok { 4451 return ShapeTypes["circle"]() 4452 } 4453 if _, ok := m["x"]; ok { 4454 return ShapeTypes["point"]() 4455 } 4456 if _, ok := m["points"]; ok { 4457 return ShapeTypes["polygon"]() 4458 } 4459 if _, ok := m["anchor"]; ok { 4460 return ShapeTypes["rectangle"]() 4461 } 4462 if _, ok := m["shapes"]; ok { 4463 return ShapeTypes["union"]() 4464 } 4465 return nil 4466 } 4467 4468 var ( 4469 4470 // ErrUnmarshalShapeTypeRegionOfInterestCrop represents an error while unmarshalling {$compositeType}} 4471 ErrUnmarshalShapeTypeRegionOfInterestCrop = errors.New("unmarshalling RegionOfInterestCrop") 4472 ) 4473 4474 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ShapeType interface 4475 func (r *RegionOfInterestCrop) UnmarshalJSON(in []byte) error { 4476 data := make(map[string]interface{}) 4477 type RegionOfInterestCropT RegionOfInterestCrop 4478 err := json.Unmarshal(in, &data) 4479 if err != nil { 4480 return fmt.Errorf("%w: %s", ErrUnmarshalShapeTypeRegionOfInterestCrop, err) 4481 } 4482 shape, ok := data["regionOfInterest"] 4483 if !ok { 4484 var target RegionOfInterestCropT 4485 err = json.Unmarshal(in, &target) 4486 if err != nil { 4487 return fmt.Errorf("%w: %s", ErrUnmarshalShapeTypeRegionOfInterestCrop, err) 4488 } 4489 *r = RegionOfInterestCrop(target) 4490 return nil 4491 } 4492 shapeMap := shape.(map[string]interface{}) 4493 var target RegionOfInterestCropT 4494 targetShape := ShapeTypeValueHandlers(shapeMap) 4495 if targetShape == nil { 4496 return fmt.Errorf("%w: invalid shape type", ErrUnmarshalShapeTypeRegionOfInterestCrop) 4497 } 4498 target.RegionOfInterest = targetShape 4499 err = json.Unmarshal(in, &target) 4500 if err != nil { 4501 return fmt.Errorf("%w: %s", ErrUnmarshalShapeTypeRegionOfInterestCrop, err) 4502 } 4503 *r = RegionOfInterestCrop(target) 4504 return nil 4505 } 4506 4507 /*-----------------------------------------------*/ 4508 ////////// Transformation unmarshalers /////////// 4509 /*-----------------------------------------------*/ 4510 4511 var ( 4512 4513 // ErrUnmarshalTransformationBoxImageType represents an error while unmarshalling {$compositeType}} 4514 ErrUnmarshalTransformationBoxImageType = errors.New("unmarshalling BoxImageType") 4515 // ErrUnmarshalTransformationCircleImageType represents an error while unmarshalling {$compositeType}} 4516 ErrUnmarshalTransformationCircleImageType = errors.New("unmarshalling CircleImageType") 4517 // ErrUnmarshalTransformationFitAndFill represents an error while unmarshalling {$compositeType}} 4518 ErrUnmarshalTransformationFitAndFill = errors.New("unmarshalling FitAndFill") 4519 // ErrUnmarshalTransformationIfDimension represents an error while unmarshalling {$compositeType}} 4520 ErrUnmarshalTransformationIfDimension = errors.New("unmarshalling IfDimension") 4521 // ErrUnmarshalTransformationIfOrientation represents an error while unmarshalling {$compositeType}} 4522 ErrUnmarshalTransformationIfOrientation = errors.New("unmarshalling IfOrientation") 4523 // ErrUnmarshalTransformationTextImageType represents an error while unmarshalling {$compositeType}} 4524 ErrUnmarshalTransformationTextImageType = errors.New("unmarshalling TextImageType") 4525 // ErrUnmarshalTransformationURLImageType represents an error while unmarshalling {$compositeType}} 4526 ErrUnmarshalTransformationURLImageType = errors.New("unmarshalling URLImageType") 4527 ) 4528 4529 var ( 4530 4531 // ErrUnmarshalPostBreakpointTransformationBoxImageTypePost represents an error while unmarshalling {$compositeType}} 4532 ErrUnmarshalPostBreakpointTransformationBoxImageTypePost = errors.New("unmarshalling BoxImageTypePost") 4533 // ErrUnmarshalPostBreakpointTransformationCircleImageTypePost represents an error while unmarshalling {$compositeType}} 4534 ErrUnmarshalPostBreakpointTransformationCircleImageTypePost = errors.New("unmarshalling CircleImageTypePost") 4535 // ErrUnmarshalPostBreakpointTransformationIfDimensionPost represents an error while unmarshalling {$compositeType}} 4536 ErrUnmarshalPostBreakpointTransformationIfDimensionPost = errors.New("unmarshalling IfDimensionPost") 4537 // ErrUnmarshalPostBreakpointTransformationIfOrientationPost represents an error while unmarshalling {$compositeType}} 4538 ErrUnmarshalPostBreakpointTransformationIfOrientationPost = errors.New("unmarshalling IfOrientationPost") 4539 // ErrUnmarshalPostBreakpointTransformationTextImageTypePost represents an error while unmarshalling {$compositeType}} 4540 ErrUnmarshalPostBreakpointTransformationTextImageTypePost = errors.New("unmarshalling TextImageTypePost") 4541 // ErrUnmarshalPostBreakpointTransformationURLImageTypePost represents an error while unmarshalling {$compositeType}} 4542 ErrUnmarshalPostBreakpointTransformationURLImageTypePost = errors.New("unmarshalling URLImageTypePost") 4543 ) 4544 4545 // TransformationHandlers is a map of available transformations 4546 var TransformationHandlers = map[string]func() TransformationType{ 4547 "Append": func() TransformationType { return &Append{} }, 4548 "AspectCrop": func() TransformationType { return &AspectCrop{} }, 4549 "BackgroundColor": func() TransformationType { return &BackgroundColor{} }, 4550 "Blur": func() TransformationType { return &Blur{} }, 4551 "ChromaKey": func() TransformationType { return &ChromaKey{} }, 4552 "Composite": func() TransformationType { return &Composite{} }, 4553 "Compound": func() TransformationType { return &Compound{} }, 4554 "Contrast": func() TransformationType { return &Contrast{} }, 4555 "Crop": func() TransformationType { return &Crop{} }, 4556 "FaceCrop": func() TransformationType { return &FaceCrop{} }, 4557 "FeatureCrop": func() TransformationType { return &FeatureCrop{} }, 4558 "FitAndFill": func() TransformationType { return &FitAndFill{} }, 4559 "Goop": func() TransformationType { return &Goop{} }, 4560 "Grayscale": func() TransformationType { return &Grayscale{} }, 4561 "HSL": func() TransformationType { return &HSL{} }, 4562 "HSV": func() TransformationType { return &HSV{} }, 4563 "IfDimension": func() TransformationType { return &IfDimension{} }, 4564 "IfOrientation": func() TransformationType { return &IfOrientation{} }, 4565 "ImQuery": func() TransformationType { return &ImQuery{} }, 4566 "MaxColors": func() TransformationType { return &MaxColors{} }, 4567 "Mirror": func() TransformationType { return &Mirror{} }, 4568 "MonoHue": func() TransformationType { return &MonoHue{} }, 4569 "Opacity": func() TransformationType { return &Opacity{} }, 4570 "RegionOfInterestCrop": func() TransformationType { return &RegionOfInterestCrop{} }, 4571 "RelativeCrop": func() TransformationType { return &RelativeCrop{} }, 4572 "RemoveColor": func() TransformationType { return &RemoveColor{} }, 4573 "Resize": func() TransformationType { return &Resize{} }, 4574 "Rotate": func() TransformationType { return &Rotate{} }, 4575 "Scale": func() TransformationType { return &Scale{} }, 4576 "Shear": func() TransformationType { return &Shear{} }, 4577 "SmartCrop": func() TransformationType { return &SmartCrop{} }, 4578 "Trim": func() TransformationType { return &Trim{} }, 4579 "UnsharpMask": func() TransformationType { return &UnsharpMask{} }, 4580 } 4581 4582 // PostBreakpointTransformationHandlers is a map of available PostBreakpointTransformations 4583 var PostBreakpointTransformationHandlers = map[string]func() TransformationTypePost{ 4584 "BackgroundColor": func() TransformationTypePost { return &BackgroundColor{} }, 4585 "Blur": func() TransformationTypePost { return &Blur{} }, 4586 "ChromaKey": func() TransformationTypePost { return &ChromaKey{} }, 4587 "Compound": func() TransformationTypePost { return &CompoundPost{} }, 4588 "Composite": func() TransformationTypePost { return &CompositePost{} }, 4589 "Contrast": func() TransformationTypePost { return &Contrast{} }, 4590 "Goop": func() TransformationTypePost { return &Goop{} }, 4591 "Grayscale": func() TransformationTypePost { return &Grayscale{} }, 4592 "HSL": func() TransformationTypePost { return &HSL{} }, 4593 "HSV": func() TransformationTypePost { return &HSV{} }, 4594 "IfDimension": func() TransformationTypePost { return &IfDimensionPost{} }, 4595 "IfOrientation": func() TransformationTypePost { return &IfOrientationPost{} }, 4596 "MaxColors": func() TransformationTypePost { return &MaxColors{} }, 4597 "Mirror": func() TransformationTypePost { return &Mirror{} }, 4598 "MonoHue": func() TransformationTypePost { return &MonoHue{} }, 4599 "Opacity": func() TransformationTypePost { return &Opacity{} }, 4600 "RemoveColor": func() TransformationTypePost { return &RemoveColor{} }, 4601 "UnsharpMask": func() TransformationTypePost { return &UnsharpMask{} }, 4602 } 4603 4604 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4605 func (b *BoxImageType) UnmarshalJSON(in []byte) error { 4606 data := make(map[string]interface{}) 4607 type BoxImageTypeT BoxImageType 4608 err := json.Unmarshal(in, &data) 4609 if err != nil { 4610 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationBoxImageType, err) 4611 } 4612 var target BoxImageTypeT 4613 4614 transformationParam, ok := data["transformation"] 4615 if ok { 4616 transformationMap, ok := transformationParam.(map[string]interface{}) 4617 if !ok { 4618 return fmt.Errorf("%w: 'transformation' field on BoxImageType should be a map", ErrUnmarshalTransformationBoxImageType) 4619 } 4620 typeName := transformationMap["transformation"].(string) 4621 transformationTarget, ok := TransformationHandlers[typeName] 4622 if !ok { 4623 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationBoxImageType, typeName) 4624 } 4625 target.Transformation = transformationTarget() 4626 } 4627 4628 err = json.Unmarshal(in, &target) 4629 if err != nil { 4630 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationBoxImageType, err) 4631 } 4632 *b = BoxImageType(target) 4633 return nil 4634 } 4635 4636 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4637 func (c *CircleImageType) UnmarshalJSON(in []byte) error { 4638 data := make(map[string]interface{}) 4639 type CircleImageTypeT CircleImageType 4640 err := json.Unmarshal(in, &data) 4641 if err != nil { 4642 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationCircleImageType, err) 4643 } 4644 var target CircleImageTypeT 4645 4646 transformationParam, ok := data["transformation"] 4647 if ok { 4648 transformationMap, ok := transformationParam.(map[string]interface{}) 4649 if !ok { 4650 return fmt.Errorf("%w: 'transformation' field on CircleImageType should be a map", ErrUnmarshalTransformationCircleImageType) 4651 } 4652 typeName := transformationMap["transformation"].(string) 4653 transformationTarget, ok := TransformationHandlers[typeName] 4654 if !ok { 4655 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationCircleImageType, typeName) 4656 } 4657 target.Transformation = transformationTarget() 4658 } 4659 4660 err = json.Unmarshal(in, &target) 4661 if err != nil { 4662 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationCircleImageType, err) 4663 } 4664 *c = CircleImageType(target) 4665 return nil 4666 } 4667 4668 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4669 func (f *FitAndFill) UnmarshalJSON(in []byte) error { 4670 data := make(map[string]interface{}) 4671 type FitAndFillT FitAndFill 4672 err := json.Unmarshal(in, &data) 4673 if err != nil { 4674 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationFitAndFill, err) 4675 } 4676 var target FitAndFillT 4677 4678 fillTransformationParam, ok := data["fillTransformation"] 4679 if ok { 4680 fillTransformationMap, ok := fillTransformationParam.(map[string]interface{}) 4681 if !ok { 4682 return fmt.Errorf("%w: 'fillTransformation' field on FitAndFill should be a map", ErrUnmarshalTransformationFitAndFill) 4683 } 4684 typeName := fillTransformationMap["transformation"].(string) 4685 fillTransformationTarget, ok := TransformationHandlers[typeName] 4686 if !ok { 4687 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationFitAndFill, typeName) 4688 } 4689 target.FillTransformation = fillTransformationTarget() 4690 } 4691 4692 err = json.Unmarshal(in, &target) 4693 if err != nil { 4694 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationFitAndFill, err) 4695 } 4696 *f = FitAndFill(target) 4697 return nil 4698 } 4699 4700 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4701 func (i *IfDimension) UnmarshalJSON(in []byte) error { 4702 data := make(map[string]interface{}) 4703 type IfDimensionT IfDimension 4704 err := json.Unmarshal(in, &data) 4705 if err != nil { 4706 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfDimension, err) 4707 } 4708 var target IfDimensionT 4709 4710 defaultParam, ok := data["default"] 4711 if ok { 4712 defaultMap, ok := defaultParam.(map[string]interface{}) 4713 if !ok { 4714 return fmt.Errorf("%w: 'default' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4715 } 4716 typeName := defaultMap["transformation"].(string) 4717 defaultTarget, ok := TransformationHandlers[typeName] 4718 if !ok { 4719 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4720 } 4721 target.Default = defaultTarget() 4722 } 4723 4724 equalParam, ok := data["equal"] 4725 if ok { 4726 equalMap, ok := equalParam.(map[string]interface{}) 4727 if !ok { 4728 return fmt.Errorf("%w: 'equal' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4729 } 4730 typeName := equalMap["transformation"].(string) 4731 equalTarget, ok := TransformationHandlers[typeName] 4732 if !ok { 4733 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4734 } 4735 target.Equal = equalTarget() 4736 } 4737 4738 greaterThanParam, ok := data["greaterThan"] 4739 if ok { 4740 greaterThanMap, ok := greaterThanParam.(map[string]interface{}) 4741 if !ok { 4742 return fmt.Errorf("%w: 'greaterThan' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4743 } 4744 typeName := greaterThanMap["transformation"].(string) 4745 greaterThanTarget, ok := TransformationHandlers[typeName] 4746 if !ok { 4747 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4748 } 4749 target.GreaterThan = greaterThanTarget() 4750 } 4751 4752 lessThanParam, ok := data["lessThan"] 4753 if ok { 4754 lessThanMap, ok := lessThanParam.(map[string]interface{}) 4755 if !ok { 4756 return fmt.Errorf("%w: 'lessThan' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4757 } 4758 typeName := lessThanMap["transformation"].(string) 4759 lessThanTarget, ok := TransformationHandlers[typeName] 4760 if !ok { 4761 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4762 } 4763 target.LessThan = lessThanTarget() 4764 } 4765 4766 err = json.Unmarshal(in, &target) 4767 if err != nil { 4768 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfDimension, err) 4769 } 4770 *i = IfDimension(target) 4771 return nil 4772 } 4773 4774 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4775 func (i *IfOrientation) UnmarshalJSON(in []byte) error { 4776 data := make(map[string]interface{}) 4777 type IfOrientationT IfOrientation 4778 err := json.Unmarshal(in, &data) 4779 if err != nil { 4780 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfOrientation, err) 4781 } 4782 var target IfOrientationT 4783 4784 defaultParam, ok := data["default"] 4785 if ok { 4786 defaultMap, ok := defaultParam.(map[string]interface{}) 4787 if !ok { 4788 return fmt.Errorf("%w: 'default' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4789 } 4790 typeName := defaultMap["transformation"].(string) 4791 defaultTarget, ok := TransformationHandlers[typeName] 4792 if !ok { 4793 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4794 } 4795 target.Default = defaultTarget() 4796 } 4797 4798 landscapeParam, ok := data["landscape"] 4799 if ok { 4800 landscapeMap, ok := landscapeParam.(map[string]interface{}) 4801 if !ok { 4802 return fmt.Errorf("%w: 'landscape' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4803 } 4804 typeName := landscapeMap["transformation"].(string) 4805 landscapeTarget, ok := TransformationHandlers[typeName] 4806 if !ok { 4807 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4808 } 4809 target.Landscape = landscapeTarget() 4810 } 4811 4812 portraitParam, ok := data["portrait"] 4813 if ok { 4814 portraitMap, ok := portraitParam.(map[string]interface{}) 4815 if !ok { 4816 return fmt.Errorf("%w: 'portrait' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4817 } 4818 typeName := portraitMap["transformation"].(string) 4819 portraitTarget, ok := TransformationHandlers[typeName] 4820 if !ok { 4821 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4822 } 4823 target.Portrait = portraitTarget() 4824 } 4825 4826 squareParam, ok := data["square"] 4827 if ok { 4828 squareMap, ok := squareParam.(map[string]interface{}) 4829 if !ok { 4830 return fmt.Errorf("%w: 'square' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4831 } 4832 typeName := squareMap["transformation"].(string) 4833 squareTarget, ok := TransformationHandlers[typeName] 4834 if !ok { 4835 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4836 } 4837 target.Square = squareTarget() 4838 } 4839 4840 err = json.Unmarshal(in, &target) 4841 if err != nil { 4842 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfOrientation, err) 4843 } 4844 *i = IfOrientation(target) 4845 return nil 4846 } 4847 4848 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4849 func (t *TextImageType) UnmarshalJSON(in []byte) error { 4850 data := make(map[string]interface{}) 4851 type TextImageTypeT TextImageType 4852 err := json.Unmarshal(in, &data) 4853 if err != nil { 4854 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationTextImageType, err) 4855 } 4856 var target TextImageTypeT 4857 4858 transformationParam, ok := data["transformation"] 4859 if ok { 4860 transformationMap, ok := transformationParam.(map[string]interface{}) 4861 if !ok { 4862 return fmt.Errorf("%w: 'transformation' field on TextImageType should be a map", ErrUnmarshalTransformationTextImageType) 4863 } 4864 typeName := transformationMap["transformation"].(string) 4865 transformationTarget, ok := TransformationHandlers[typeName] 4866 if !ok { 4867 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationTextImageType, typeName) 4868 } 4869 target.Transformation = transformationTarget() 4870 } 4871 4872 err = json.Unmarshal(in, &target) 4873 if err != nil { 4874 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationTextImageType, err) 4875 } 4876 *t = TextImageType(target) 4877 return nil 4878 } 4879 4880 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4881 func (u *URLImageType) UnmarshalJSON(in []byte) error { 4882 data := make(map[string]interface{}) 4883 type URLImageTypeT URLImageType 4884 err := json.Unmarshal(in, &data) 4885 if err != nil { 4886 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationURLImageType, err) 4887 } 4888 var target URLImageTypeT 4889 4890 transformationParam, ok := data["transformation"] 4891 if ok { 4892 transformationMap, ok := transformationParam.(map[string]interface{}) 4893 if !ok { 4894 return fmt.Errorf("%w: 'transformation' field on URLImageType should be a map", ErrUnmarshalTransformationURLImageType) 4895 } 4896 typeName := transformationMap["transformation"].(string) 4897 transformationTarget, ok := TransformationHandlers[typeName] 4898 if !ok { 4899 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationURLImageType, typeName) 4900 } 4901 target.Transformation = transformationTarget() 4902 } 4903 4904 err = json.Unmarshal(in, &target) 4905 if err != nil { 4906 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationURLImageType, err) 4907 } 4908 *u = URLImageType(target) 4909 return nil 4910 } 4911 4912 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4913 func (b *BoxImageTypePost) UnmarshalJSON(in []byte) error { 4914 data := make(map[string]interface{}) 4915 type BoxImageTypePostT BoxImageTypePost 4916 err := json.Unmarshal(in, &data) 4917 if err != nil { 4918 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost, err) 4919 } 4920 var target BoxImageTypePostT 4921 4922 transformationParam, ok := data["transformation"] 4923 if ok { 4924 transformationMap, ok := transformationParam.(map[string]interface{}) 4925 if !ok { 4926 return fmt.Errorf("%w: 'transformation' field on BoxImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost) 4927 } 4928 typeName := transformationMap["transformation"].(string) 4929 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 4930 if !ok { 4931 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost, typeName) 4932 } 4933 target.Transformation = transformationTarget() 4934 } 4935 4936 err = json.Unmarshal(in, &target) 4937 if err != nil { 4938 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost, err) 4939 } 4940 *b = BoxImageTypePost(target) 4941 return nil 4942 } 4943 4944 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4945 func (c *CircleImageTypePost) UnmarshalJSON(in []byte) error { 4946 data := make(map[string]interface{}) 4947 type CircleImageTypePostT CircleImageTypePost 4948 err := json.Unmarshal(in, &data) 4949 if err != nil { 4950 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost, err) 4951 } 4952 var target CircleImageTypePostT 4953 4954 transformationParam, ok := data["transformation"] 4955 if ok { 4956 transformationMap, ok := transformationParam.(map[string]interface{}) 4957 if !ok { 4958 return fmt.Errorf("%w: 'transformation' field on CircleImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost) 4959 } 4960 typeName := transformationMap["transformation"].(string) 4961 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 4962 if !ok { 4963 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost, typeName) 4964 } 4965 target.Transformation = transformationTarget() 4966 } 4967 4968 err = json.Unmarshal(in, &target) 4969 if err != nil { 4970 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost, err) 4971 } 4972 *c = CircleImageTypePost(target) 4973 return nil 4974 } 4975 4976 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4977 func (i *IfDimensionPost) UnmarshalJSON(in []byte) error { 4978 data := make(map[string]interface{}) 4979 type IfDimensionPostT IfDimensionPost 4980 err := json.Unmarshal(in, &data) 4981 if err != nil { 4982 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, err) 4983 } 4984 var target IfDimensionPostT 4985 4986 defaultParam, ok := data["default"] 4987 if ok { 4988 defaultMap, ok := defaultParam.(map[string]interface{}) 4989 if !ok { 4990 return fmt.Errorf("%w: 'default' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 4991 } 4992 typeName := defaultMap["transformation"].(string) 4993 defaultTarget, ok := PostBreakpointTransformationHandlers[typeName] 4994 if !ok { 4995 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 4996 } 4997 target.Default = defaultTarget() 4998 } 4999 5000 equalParam, ok := data["equal"] 5001 if ok { 5002 equalMap, ok := equalParam.(map[string]interface{}) 5003 if !ok { 5004 return fmt.Errorf("%w: 'equal' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 5005 } 5006 typeName := equalMap["transformation"].(string) 5007 equalTarget, ok := PostBreakpointTransformationHandlers[typeName] 5008 if !ok { 5009 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 5010 } 5011 target.Equal = equalTarget() 5012 } 5013 5014 greaterThanParam, ok := data["greaterThan"] 5015 if ok { 5016 greaterThanMap, ok := greaterThanParam.(map[string]interface{}) 5017 if !ok { 5018 return fmt.Errorf("%w: 'greaterThan' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 5019 } 5020 typeName := greaterThanMap["transformation"].(string) 5021 greaterThanTarget, ok := PostBreakpointTransformationHandlers[typeName] 5022 if !ok { 5023 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 5024 } 5025 target.GreaterThan = greaterThanTarget() 5026 } 5027 5028 lessThanParam, ok := data["lessThan"] 5029 if ok { 5030 lessThanMap, ok := lessThanParam.(map[string]interface{}) 5031 if !ok { 5032 return fmt.Errorf("%w: 'lessThan' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 5033 } 5034 typeName := lessThanMap["transformation"].(string) 5035 lessThanTarget, ok := PostBreakpointTransformationHandlers[typeName] 5036 if !ok { 5037 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 5038 } 5039 target.LessThan = lessThanTarget() 5040 } 5041 5042 err = json.Unmarshal(in, &target) 5043 if err != nil { 5044 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, err) 5045 } 5046 *i = IfDimensionPost(target) 5047 return nil 5048 } 5049 5050 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 5051 func (i *IfOrientationPost) UnmarshalJSON(in []byte) error { 5052 data := make(map[string]interface{}) 5053 type IfOrientationPostT IfOrientationPost 5054 err := json.Unmarshal(in, &data) 5055 if err != nil { 5056 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, err) 5057 } 5058 var target IfOrientationPostT 5059 5060 defaultParam, ok := data["default"] 5061 if ok { 5062 defaultMap, ok := defaultParam.(map[string]interface{}) 5063 if !ok { 5064 return fmt.Errorf("%w: 'default' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 5065 } 5066 typeName := defaultMap["transformation"].(string) 5067 defaultTarget, ok := PostBreakpointTransformationHandlers[typeName] 5068 if !ok { 5069 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 5070 } 5071 target.Default = defaultTarget() 5072 } 5073 5074 landscapeParam, ok := data["landscape"] 5075 if ok { 5076 landscapeMap, ok := landscapeParam.(map[string]interface{}) 5077 if !ok { 5078 return fmt.Errorf("%w: 'landscape' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 5079 } 5080 typeName := landscapeMap["transformation"].(string) 5081 landscapeTarget, ok := PostBreakpointTransformationHandlers[typeName] 5082 if !ok { 5083 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 5084 } 5085 target.Landscape = landscapeTarget() 5086 } 5087 5088 portraitParam, ok := data["portrait"] 5089 if ok { 5090 portraitMap, ok := portraitParam.(map[string]interface{}) 5091 if !ok { 5092 return fmt.Errorf("%w: 'portrait' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 5093 } 5094 typeName := portraitMap["transformation"].(string) 5095 portraitTarget, ok := PostBreakpointTransformationHandlers[typeName] 5096 if !ok { 5097 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 5098 } 5099 target.Portrait = portraitTarget() 5100 } 5101 5102 squareParam, ok := data["square"] 5103 if ok { 5104 squareMap, ok := squareParam.(map[string]interface{}) 5105 if !ok { 5106 return fmt.Errorf("%w: 'square' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 5107 } 5108 typeName := squareMap["transformation"].(string) 5109 squareTarget, ok := PostBreakpointTransformationHandlers[typeName] 5110 if !ok { 5111 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 5112 } 5113 target.Square = squareTarget() 5114 } 5115 5116 err = json.Unmarshal(in, &target) 5117 if err != nil { 5118 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, err) 5119 } 5120 *i = IfOrientationPost(target) 5121 return nil 5122 } 5123 5124 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 5125 func (t *TextImageTypePost) UnmarshalJSON(in []byte) error { 5126 data := make(map[string]interface{}) 5127 type TextImageTypePostT TextImageTypePost 5128 err := json.Unmarshal(in, &data) 5129 if err != nil { 5130 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationTextImageTypePost, err) 5131 } 5132 var target TextImageTypePostT 5133 5134 transformationParam, ok := data["transformation"] 5135 if ok { 5136 transformationMap, ok := transformationParam.(map[string]interface{}) 5137 if !ok { 5138 return fmt.Errorf("%w: 'transformation' field on TextImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationTextImageTypePost) 5139 } 5140 typeName := transformationMap["transformation"].(string) 5141 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 5142 if !ok { 5143 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationTextImageTypePost, typeName) 5144 } 5145 target.Transformation = transformationTarget() 5146 } 5147 5148 err = json.Unmarshal(in, &target) 5149 if err != nil { 5150 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationTextImageTypePost, err) 5151 } 5152 *t = TextImageTypePost(target) 5153 return nil 5154 } 5155 5156 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 5157 func (u *URLImageTypePost) UnmarshalJSON(in []byte) error { 5158 data := make(map[string]interface{}) 5159 type URLImageTypePostT URLImageTypePost 5160 err := json.Unmarshal(in, &data) 5161 if err != nil { 5162 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationURLImageTypePost, err) 5163 } 5164 var target URLImageTypePostT 5165 5166 transformationParam, ok := data["transformation"] 5167 if ok { 5168 transformationMap, ok := transformationParam.(map[string]interface{}) 5169 if !ok { 5170 return fmt.Errorf("%w: 'transformation' field on URLImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationURLImageTypePost) 5171 } 5172 typeName := transformationMap["transformation"].(string) 5173 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 5174 if !ok { 5175 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationURLImageTypePost, typeName) 5176 } 5177 target.Transformation = transformationTarget() 5178 } 5179 5180 err = json.Unmarshal(in, &target) 5181 if err != nil { 5182 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationURLImageTypePost, err) 5183 } 5184 *u = URLImageTypePost(target) 5185 return nil 5186 } 5187 5188 // ErrUnmarshalTransformationList represents an error while unmarshalling transformation list 5189 var ErrUnmarshalTransformationList = errors.New("unmarshalling transformation list") 5190 5191 // ErrUnmarshalPostBreakpointTransformationList represents an error while unmarshalling post breakpoint transformation list 5192 var ErrUnmarshalPostBreakpointTransformationList = errors.New("unmarshalling post breakpoint transformation list") 5193 5194 // UnmarshalJSON is a custom unmarshaler used to decode a slice of Transformation interfaces 5195 func (t *Transformations) UnmarshalJSON(in []byte) error { 5196 data := make([]map[string]interface{}, 0) 5197 if err := json.Unmarshal(in, &data); err != nil { 5198 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationList, err) 5199 } 5200 for _, transformation := range data { 5201 transformationType, ok := transformation["transformation"] 5202 if !ok { 5203 return fmt.Errorf("%w: transformation should contain 'transformation' field", ErrUnmarshalTransformationList) 5204 } 5205 transformationTypeName, ok := transformationType.(string) 5206 if !ok { 5207 return fmt.Errorf("%w: 'transformation' field on transformation entry should be a string", ErrUnmarshalTransformationList) 5208 } 5209 5210 bytes, err := json.Marshal(transformation) 5211 if err != nil { 5212 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationList, err) 5213 } 5214 5215 indicatedTransformationType, ok := TransformationHandlers[transformationTypeName] 5216 if !ok { 5217 return fmt.Errorf("%w: unsupported transformation type: %s", ErrUnmarshalTransformationList, transformationTypeName) 5218 } 5219 ipt := indicatedTransformationType() 5220 err = json.Unmarshal(bytes, ipt) 5221 if err != nil { 5222 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationList, err) 5223 } 5224 *t = append(*t, ipt) 5225 } 5226 return nil 5227 } 5228 5229 // UnmarshalJSON is a custom unmarshaler used to decode a slice of PostBreakpointTransformation interfaces 5230 func (t *PostBreakpointTransformations) UnmarshalJSON(in []byte) error { 5231 data := make([]map[string]interface{}, 0) 5232 if err := json.Unmarshal(in, &data); err != nil { 5233 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationList, err) 5234 } 5235 for _, transformation := range data { 5236 transformationType, ok := transformation["transformation"] 5237 if !ok { 5238 return fmt.Errorf("%w: transformation should contain 'transformation' field", ErrUnmarshalPostBreakpointTransformationList) 5239 } 5240 transformationTypeName, ok := transformationType.(string) 5241 if !ok { 5242 return fmt.Errorf("%w: 'transformation' field on transformation entry should be a string", ErrUnmarshalPostBreakpointTransformationList) 5243 } 5244 5245 bytes, err := json.Marshal(transformation) 5246 if err != nil { 5247 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationList, err) 5248 } 5249 5250 indicatedTransformationType, ok := PostBreakpointTransformationHandlers[transformationTypeName] 5251 if !ok { 5252 return fmt.Errorf("%w: unsupported transformation type: %s", ErrUnmarshalPostBreakpointTransformationList, transformationTypeName) 5253 } 5254 ipt := indicatedTransformationType() 5255 err = json.Unmarshal(bytes, ipt) 5256 if err != nil { 5257 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationList, err) 5258 } 5259 *t = append(*t, ipt) 5260 } 5261 return nil 5262 }