github.com/akamai/AkamaiOPEN-edgegrid-golang/v5@v5.0.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 // AllowedFormats The graphics file formats allowed for browser specific results. 712 AllowedFormats []OutputImageAllowedFormats `json:"allowedFormats,omitempty"` 713 // 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. 714 ForcedFormats []OutputImageForcedFormats `json:"forcedFormats,omitempty"` 715 // 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`. 716 PerceptualQuality *OutputImagePerceptualQualityVariableInline `json:"perceptualQuality,omitempty"` 717 // 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. 718 PerceptualQualityFloor *int `json:"perceptualQualityFloor,omitempty"` 719 // 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. 720 Quality *IntegerVariableInline `json:"quality,omitempty"` 721 } 722 723 // OutputImageAllowedFormats ... 724 OutputImageAllowedFormats string 725 726 // OutputImageForcedFormats ... 727 OutputImageForcedFormats string 728 729 // OutputImagePerceptualQuality ... 730 OutputImagePerceptualQuality string 731 732 // OutputImagePerceptualQualityVariableInline represents a type which stores either a value or a variable name 733 OutputImagePerceptualQualityVariableInline struct { 734 Name *string 735 Value *OutputImagePerceptualQuality 736 } 737 738 // 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. 739 PointShapeType struct { 740 // X The horizontal position of the point, measured in pixels. 741 X *NumberVariableInline `json:"x"` 742 // Y The vertical position of the point, measured in pixels. 743 Y *NumberVariableInline `json:"y"` 744 } 745 746 // PolicyOutputImage Specifies details for each policy, such as transformations to apply and variations in image size and formats. 747 PolicyOutputImage struct { 748 // Breakpoints The breakpoint widths (in pixels) to use to create derivative images/videos. 749 Breakpoints *Breakpoints `json:"breakpoints,omitempty"` 750 // DateCreated Date this policy version was created in ISO 8601 extended notation format. 751 DateCreated string `json:"dateCreated"` 752 // Hosts Hosts that are allowed for image/video URLs within transformations or variables. 753 Hosts []string `json:"hosts,omitempty"` 754 // ID Unique identifier for a policy, up to 64 alphanumeric characters including underscores or dashes. 755 ID string `json:"id"` 756 // 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. 757 Output *OutputImage `json:"output,omitempty"` 758 // PostBreakpointTransformations Post-processing Transformations are applied to the image after image and quality settings have been applied. 759 PostBreakpointTransformations PostBreakpointTransformations `json:"postBreakpointTransformations,omitempty"` 760 // PreviousVersion The previous version number of this policy version 761 PreviousVersion int `json:"previousVersion"` 762 // RolloutInfo Contains information about policy rollout start and completion times. 763 RolloutInfo *RolloutInfo `json:"rolloutInfo"` 764 // Transformations Set of image transformations to apply to the source image. If unspecified, no operations are performed. 765 Transformations Transformations `json:"transformations,omitempty"` 766 // User The user who created this policy version 767 User string `json:"user"` 768 // 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. 769 Variables []Variable `json:"variables,omitempty"` 770 // Version The version number of this policy version 771 Version int `json:"version"` 772 // Video Identifies this as an image policy. 773 Video *bool `json:"video,omitempty"` 774 } 775 776 // PolicyOutputImageVideo ... 777 PolicyOutputImageVideo bool 778 779 // PolygonShapeType Defines a polygon from a series of connected points. 780 PolygonShapeType struct { 781 // Points Series of [PointShapeType](#pointshapetype) objects. The last and first points connect to close the shape automatically. 782 Points []PointShapeType `json:"points"` 783 } 784 785 // QueryVariableInline represents a type which stores either a value or a variable name 786 QueryVariableInline struct { 787 Name *string 788 } 789 790 // RectangleShapeType Defines a rectangle's `width` and `height` relative to an `anchor` point at the top left corner. 791 RectangleShapeType struct { 792 Anchor *PointShapeType `json:"anchor"` 793 // Height Extends the rectangle down from the `anchor` point. 794 Height *NumberVariableInline `json:"height"` 795 // Width Extends the rectangle right from the `anchor` point. 796 Width *NumberVariableInline `json:"width"` 797 } 798 799 // RegionOfInterestCrop Crops to a region around a specified area of interest relative to the specified `width` and `height` values. 800 RegionOfInterestCrop struct { 801 // Gravity The placement of the crop area relative to the specified area of interest. 802 Gravity *GravityVariableInline `json:"gravity,omitempty"` 803 // Height The height in pixels of the output image relative to the specified `style` value. 804 Height *IntegerVariableInline `json:"height"` 805 RegionOfInterest ShapeType `json:"regionOfInterest"` 806 // 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. 807 Style *RegionOfInterestCropStyleVariableInline `json:"style,omitempty"` 808 // Transformation Identifies this type of transformation, `RegionOfInterestCrop` in this case. 809 Transformation RegionOfInterestCropTransformation `json:"transformation"` 810 // Width The width in pixels of the output image relative to the specified `style` value. 811 Width *IntegerVariableInline `json:"width"` 812 } 813 814 // RegionOfInterestCropStyle ... 815 RegionOfInterestCropStyle string 816 817 // RegionOfInterestCropStyleVariableInline represents a type which stores either a value or a variable name 818 RegionOfInterestCropStyleVariableInline struct { 819 Name *string 820 Value *RegionOfInterestCropStyle 821 } 822 823 // RegionOfInterestCropTransformation ... 824 RegionOfInterestCropTransformation string 825 826 // 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. 827 RelativeCrop struct { 828 // East The number of pixels to shrink or expand the right side of the image. 829 East *IntegerVariableInline `json:"east,omitempty"` 830 // North The number of pixels to shrink or expand the top side of the image. 831 North *IntegerVariableInline `json:"north,omitempty"` 832 // South The number of pixels to shrink or expand the bottom side of the image. 833 South *IntegerVariableInline `json:"south,omitempty"` 834 // Transformation Identifies this type of transformation, `RelativeCrop` in this case. 835 Transformation RelativeCropTransformation `json:"transformation"` 836 // West The number of pixels to shrink or expand the left side of the image. 837 West *IntegerVariableInline `json:"west,omitempty"` 838 } 839 840 // RelativeCropTransformation ... 841 RelativeCropTransformation string 842 843 // 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. 844 RemoveColor struct { 845 // Color The hexadecimal CSS color value to remove. 846 Color *StringVariableInline `json:"color"` 847 // 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. 848 Feather *NumberVariableInline `json:"feather,omitempty"` 849 // 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. 850 Tolerance *NumberVariableInline `json:"tolerance,omitempty"` 851 // Transformation Identifies this type of transformation, `RemoveColor` in this case. 852 Transformation RemoveColorTransformation `json:"transformation"` 853 } 854 855 // RemoveColorTransformation ... 856 RemoveColorTransformation string 857 858 // 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. 859 Resize struct { 860 // 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. 861 Aspect *ResizeAspectVariableInline `json:"aspect,omitempty"` 862 // Height The height to resize the source image to. Must be set if height is not specified. 863 Height *IntegerVariableInline `json:"height,omitempty"` 864 // Transformation Identifies this type of transformation, `Resize` in this case. 865 Transformation ResizeTransformation `json:"transformation"` 866 // 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. 867 Type *ResizeTypeVariableInline `json:"type,omitempty"` 868 // Width The width to resize the source image to. Must be set if width is not specified. 869 Width *IntegerVariableInline `json:"width,omitempty"` 870 } 871 872 // ResizeAspect ... 873 ResizeAspect string 874 875 // ResizeAspectVariableInline represents a type which stores either a value or a variable name 876 ResizeAspectVariableInline struct { 877 Name *string 878 Value *ResizeAspect 879 } 880 881 // ResizeTransformation ... 882 ResizeTransformation string 883 884 // ResizeType ... 885 ResizeType string 886 887 // ResizeTypeVariableInline represents a type which stores either a value or a variable name 888 ResizeTypeVariableInline struct { 889 Name *string 890 Value *ResizeType 891 } 892 893 // RolloutInfo Contains information about policy rollout start and completion times. 894 RolloutInfo struct { 895 // EndTime The estimated time that rollout for this policy will end. Value is a unix timestamp. 896 EndTime int `json:"endTime"` 897 // 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. 898 RolloutDuration int `json:"rolloutDuration"` 899 // StartTime The estimated time that rollout for this policy will begin. Value is a unix timestamp. 900 StartTime int `json:"startTime"` 901 } 902 903 // Rotate Rotate the image around its center by indicating the degrees of rotation. 904 Rotate struct { 905 // Degrees The value to rotate the image by. Positive values rotate clockwise, while negative values rotate counter-clockwise. 906 Degrees *NumberVariableInline `json:"degrees"` 907 // Transformation Identifies this type of transformation, `Rotate` in this case. 908 Transformation RotateTransformation `json:"transformation"` 909 } 910 911 // RotateTransformation ... 912 RotateTransformation string 913 914 // Scale Changes the image's size to different dimensions relative to its starting size. 915 Scale struct { 916 // 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. 917 Height *NumberVariableInline `json:"height"` 918 // Transformation Identifies this type of transformation, `Scale` in this case. 919 Transformation ScaleTransformation `json:"transformation"` 920 // 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. 921 Width *NumberVariableInline `json:"width"` 922 } 923 924 // ScaleTransformation ... 925 ScaleTransformation string 926 927 // 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. 928 Shear struct { 929 // Transformation Identifies this type of transformation, `Shear` in this case. 930 Transformation ShearTransformation `json:"transformation"` 931 // 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. 932 XShear *NumberVariableInline `json:"xShear,omitempty"` 933 // 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. 934 YShear *NumberVariableInline `json:"yShear,omitempty"` 935 } 936 937 // ShearTransformation ... 938 ShearTransformation string 939 940 // StringVariableInline represents a type which stores either a value or a variable name 941 StringVariableInline struct { 942 Name *string 943 Value *string 944 } 945 946 // TextImageType A snippet of text. Defines font family and size, fill color, and outline stroke width and color. 947 TextImageType struct { 948 // Fill The main fill color of the text. 949 Fill *StringVariableInline `json:"fill,omitempty"` 950 // Size The size in pixels to render the text. 951 Size *NumberVariableInline `json:"size,omitempty"` 952 // Stroke The color for the outline of the text. 953 Stroke *StringVariableInline `json:"stroke,omitempty"` 954 // StrokeSize The thickness in points for the outline of the text. 955 StrokeSize *NumberVariableInline `json:"strokeSize,omitempty"` 956 // Text The line of text to render. 957 Text *StringVariableInline `json:"text"` 958 Transformation TransformationType `json:"transformation,omitempty"` 959 // Type Identifies the type of image, `Text` in this case. 960 Type TextImageTypeType `json:"type"` 961 // 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. 962 Typeface *StringVariableInline `json:"typeface,omitempty"` 963 } 964 965 // TextImageTypePost A snippet of text. Defines font family and size, fill color, and outline stroke width and color. 966 TextImageTypePost struct { 967 // Fill The main fill color of the text. 968 Fill *StringVariableInline `json:"fill,omitempty"` 969 // Size The size in pixels to render the text. 970 Size *NumberVariableInline `json:"size,omitempty"` 971 // Stroke The color for the outline of the text. 972 Stroke *StringVariableInline `json:"stroke,omitempty"` 973 // StrokeSize The thickness in points for the outline of the text. 974 StrokeSize *NumberVariableInline `json:"strokeSize,omitempty"` 975 // Text The line of text to render. 976 Text *StringVariableInline `json:"text"` 977 Transformation TransformationTypePost `json:"transformation,omitempty"` 978 // Type Identifies the type of image, `Text` in this case. 979 Type TextImageTypePostType `json:"type"` 980 // 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. 981 Typeface *StringVariableInline `json:"typeface,omitempty"` 982 } 983 984 // TextImageTypePostType ... 985 TextImageTypePostType string 986 987 // TextImageTypeType ... 988 TextImageTypeType string 989 990 // Trim Automatically crops uniform backgrounds from the edges of an image. 991 Trim struct { 992 // Fuzz The fuzz tolerance of the trim, a value between `0` and `1` that determines the acceptable amount of background variation before trimming stops. 993 Fuzz *NumberVariableInline `json:"fuzz,omitempty"` 994 // Padding The amount of padding in pixels to add to the trimmed image. 995 Padding *IntegerVariableInline `json:"padding,omitempty"` 996 // Transformation Identifies this type of transformation, `Trim` in this case. 997 Transformation TrimTransformation `json:"transformation"` 998 } 999 1000 // TrimTransformation ... 1001 TrimTransformation string 1002 1003 // URLImageType An image loaded from a URL. 1004 URLImageType struct { 1005 Transformation TransformationType `json:"transformation,omitempty"` 1006 // Type Identifies the type of image, `URL` in this case. 1007 Type URLImageTypeType `json:"type,omitempty"` 1008 // URL The URL of the image. 1009 URL *StringVariableInline `json:"url"` 1010 } 1011 1012 // URLImageTypePost An image loaded from a URL. 1013 URLImageTypePost struct { 1014 Transformation TransformationTypePost `json:"transformation,omitempty"` 1015 // Type Identifies the type of image, `URL` in this case. 1016 Type URLImageTypePostType `json:"type,omitempty"` 1017 // URL The URL of the image. 1018 URL *StringVariableInline `json:"url"` 1019 } 1020 1021 // URLImageTypePostType ... 1022 URLImageTypePostType string 1023 1024 // URLImageTypeType ... 1025 URLImageTypeType string 1026 1027 // 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. 1028 UnionShapeType struct { 1029 Shapes []ShapeType `json:"shapes"` 1030 } 1031 1032 // 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. 1033 UnsharpMask struct { 1034 // Gain Set how much emphasis the filter applies to details. Higher values increase apparent sharpness of details. 1035 Gain *NumberVariableInline `json:"gain,omitempty"` 1036 // 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. 1037 Sigma *NumberVariableInline `json:"sigma,omitempty"` 1038 // Threshold Set the minimum change required to include a detail in the filter. Higher values discard more changes. 1039 Threshold *NumberVariableInline `json:"threshold,omitempty"` 1040 // Transformation Identifies this type of transformation, `UnsharpMask` in this case. 1041 Transformation UnsharpMaskTransformation `json:"transformation"` 1042 } 1043 1044 // UnsharpMaskTransformation ... 1045 UnsharpMaskTransformation string 1046 1047 // Variable ... 1048 Variable struct { 1049 // 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. 1050 DefaultValue string `json:"defaultValue"` 1051 EnumOptions []*EnumOptions `json:"enumOptions,omitempty"` 1052 // 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. 1053 Name string `json:"name"` 1054 // Postfix A postfix added to the value provided for the variable, or to the default value. 1055 Postfix *string `json:"postfix,omitempty"` 1056 // Prefix A prefix added to the value provided for the variable, or to the default value. 1057 Prefix *string `json:"prefix,omitempty"` 1058 // Type The type of value for the variable. 1059 Type VariableType `json:"type"` 1060 } 1061 1062 // 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. 1063 VariableInline struct { 1064 // Var Corresponds to the `name` of the variable declared by the policy, to insert the corresponding value. 1065 Var string `json:"var"` 1066 } 1067 1068 // VariableType ... 1069 VariableType string 1070 1071 // OutputVideo Dictates the output quality that are created for each resized video. 1072 OutputVideo struct { 1073 // PerceptualQuality The quality of derivative videos. High preserves video quality with reduced byte savings while low reduces video quality to increase byte savings. 1074 PerceptualQuality *OutputVideoPerceptualQualityVariableInline `json:"perceptualQuality,omitempty"` 1075 // 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. 1076 PlaceholderVideoURL *StringVariableInline `json:"placeholderVideoUrl,omitempty"` 1077 // 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. 1078 VideoAdaptiveQuality *OutputVideoVideoAdaptiveQualityVariableInline `json:"videoAdaptiveQuality,omitempty"` 1079 } 1080 1081 // OutputVideoPerceptualQuality ... 1082 OutputVideoPerceptualQuality string 1083 1084 // OutputVideoPerceptualQualityVariableInline represents a type which stores either a value or a variable name 1085 OutputVideoPerceptualQualityVariableInline struct { 1086 Name *string 1087 Value *OutputVideoPerceptualQuality 1088 } 1089 1090 // OutputVideoVideoAdaptiveQuality ... 1091 OutputVideoVideoAdaptiveQuality string 1092 1093 // OutputVideoVideoAdaptiveQualityVariableInline represents a type which stores either a value or a variable name 1094 OutputVideoVideoAdaptiveQualityVariableInline struct { 1095 Name *string 1096 Value *OutputVideoVideoAdaptiveQuality 1097 } 1098 1099 // PolicyOutputVideo Specifies details for each policy such as video size. 1100 PolicyOutputVideo struct { 1101 // Breakpoints The breakpoint widths (in pixels) to use to create derivative images/videos. 1102 Breakpoints *Breakpoints `json:"breakpoints,omitempty"` 1103 // DateCreated Date this policy version was created in ISO 8601 extended notation format. 1104 DateCreated string `json:"dateCreated"` 1105 // Hosts Hosts that are allowed for image/video URLs within transformations or variables. 1106 Hosts []string `json:"hosts,omitempty"` 1107 // ID Unique identifier for a policy, up to 64 alphanumeric characters including underscores or dashes. 1108 ID string `json:"id"` 1109 // Output Dictates the output quality that are created for each resized video. 1110 Output *OutputVideo `json:"output,omitempty"` 1111 // PreviousVersion The previous version number of this policy version 1112 PreviousVersion int `json:"previousVersion"` 1113 // RolloutInfo Contains information about policy rollout start and completion times. 1114 RolloutInfo *RolloutInfo `json:"rolloutInfo"` 1115 // User The user who created this policy version 1116 User string `json:"user"` 1117 // 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. 1118 Variables []Variable `json:"variables,omitempty"` 1119 // Version The version number of this policy version 1120 Version int `json:"version"` 1121 // Video Identifies this as a video policy. 1122 Video *bool `json:"video,omitempty"` 1123 } 1124 1125 // PolicyOutputVideoVideo ... 1126 PolicyOutputVideoVideo bool 1127 ) 1128 1129 /*-----------------------------------------------*/ 1130 /////////////// Generated constants /////////////// 1131 /*-----------------------------------------------*/ 1132 const ( 1133 1134 // AppendGravityPriorityHorizontal const 1135 AppendGravityPriorityHorizontal AppendGravityPriority = "horizontal" 1136 // AppendGravityPriorityVertical const 1137 AppendGravityPriorityVertical AppendGravityPriority = "vertical" 1138 1139 // AppendTransformationAppend const 1140 AppendTransformationAppend AppendTransformation = "Append" 1141 1142 // AspectCropTransformationAspectCrop const 1143 AspectCropTransformationAspectCrop AspectCropTransformation = "AspectCrop" 1144 1145 // BackgroundColorTransformationBackgroundColor const 1146 BackgroundColorTransformationBackgroundColor BackgroundColorTransformation = "BackgroundColor" 1147 1148 // BlurTransformationBlur const 1149 BlurTransformationBlur BlurTransformation = "Blur" 1150 1151 // BoxImageTypePostTypeBox const 1152 BoxImageTypePostTypeBox BoxImageTypePostType = "Box" 1153 1154 // BoxImageTypeTypeBox const 1155 BoxImageTypeTypeBox BoxImageTypeType = "Box" 1156 1157 // ChromaKeyTransformationChromaKey const 1158 ChromaKeyTransformationChromaKey ChromaKeyTransformation = "ChromaKey" 1159 1160 // CircleImageTypePostTypeCircle const 1161 CircleImageTypePostTypeCircle CircleImageTypePostType = "Circle" 1162 1163 // CircleImageTypeTypeCircle const 1164 CircleImageTypeTypeCircle CircleImageTypeType = "Circle" 1165 1166 // CompositePlacementOver const 1167 CompositePlacementOver CompositePlacement = "Over" 1168 // CompositePlacementUnder const 1169 CompositePlacementUnder CompositePlacement = "Under" 1170 // CompositePlacementMask const 1171 CompositePlacementMask CompositePlacement = "Mask" 1172 // CompositePlacementStencil const 1173 CompositePlacementStencil CompositePlacement = "Stencil" 1174 1175 // CompositePostPlacementOver const 1176 CompositePostPlacementOver CompositePostPlacement = "Over" 1177 // CompositePostPlacementUnder const 1178 CompositePostPlacementUnder CompositePostPlacement = "Under" 1179 // CompositePostPlacementMask const 1180 CompositePostPlacementMask CompositePostPlacement = "Mask" 1181 // CompositePostPlacementStencil const 1182 CompositePostPlacementStencil CompositePostPlacement = "Stencil" 1183 1184 // CompositePostScaleDimensionWidth const 1185 CompositePostScaleDimensionWidth CompositePostScaleDimension = "width" 1186 // CompositePostScaleDimensionHeight const 1187 CompositePostScaleDimensionHeight CompositePostScaleDimension = "height" 1188 1189 // CompositePostTransformationComposite const 1190 CompositePostTransformationComposite CompositePostTransformation = "Composite" 1191 1192 // CompositeScaleDimensionWidth const 1193 CompositeScaleDimensionWidth CompositeScaleDimension = "width" 1194 // CompositeScaleDimensionHeight const 1195 CompositeScaleDimensionHeight CompositeScaleDimension = "height" 1196 1197 // CompositeTransformationComposite const 1198 CompositeTransformationComposite CompositeTransformation = "Composite" 1199 1200 // CompoundPostTransformationCompound const 1201 CompoundPostTransformationCompound CompoundPostTransformation = "Compound" 1202 1203 // CompoundTransformationCompound const 1204 CompoundTransformationCompound CompoundTransformation = "Compound" 1205 1206 // ContrastTransformationContrast const 1207 ContrastTransformationContrast ContrastTransformation = "Contrast" 1208 1209 // CropTransformationCrop const 1210 CropTransformationCrop CropTransformation = "Crop" 1211 1212 // FaceCropAlgorithmCascade const 1213 FaceCropAlgorithmCascade FaceCropAlgorithm = "cascade" 1214 // FaceCropAlgorithmDnn const 1215 FaceCropAlgorithmDnn FaceCropAlgorithm = "dnn" 1216 1217 // FaceCropFocusAllFaces const 1218 FaceCropFocusAllFaces FaceCropFocus = "allFaces" 1219 // FaceCropFocusBiggestFace const 1220 FaceCropFocusBiggestFace FaceCropFocus = "biggestFace" 1221 1222 // FaceCropStyleCrop const 1223 FaceCropStyleCrop FaceCropStyle = "crop" 1224 // FaceCropStyleFill const 1225 FaceCropStyleFill FaceCropStyle = "fill" 1226 // FaceCropStyleZoom const 1227 FaceCropStyleZoom FaceCropStyle = "zoom" 1228 1229 // FaceCropTransformationFaceCrop const 1230 FaceCropTransformationFaceCrop FaceCropTransformation = "FaceCrop" 1231 1232 // FeatureCropStyleCrop const 1233 FeatureCropStyleCrop FeatureCropStyle = "crop" 1234 // FeatureCropStyleFill const 1235 FeatureCropStyleFill FeatureCropStyle = "fill" 1236 // FeatureCropStyleZoom const 1237 FeatureCropStyleZoom FeatureCropStyle = "zoom" 1238 1239 // FeatureCropTransformationFeatureCrop const 1240 FeatureCropTransformationFeatureCrop FeatureCropTransformation = "FeatureCrop" 1241 1242 // FitAndFillTransformationFitAndFill const 1243 FitAndFillTransformationFitAndFill FitAndFillTransformation = "FitAndFill" 1244 1245 // GoopTransformationGoop const 1246 GoopTransformationGoop GoopTransformation = "Goop" 1247 1248 // GravityNorth const 1249 GravityNorth Gravity = "North" 1250 // GravityNorthEast const 1251 GravityNorthEast Gravity = "NorthEast" 1252 // GravityNorthWest const 1253 GravityNorthWest Gravity = "NorthWest" 1254 // GravitySouth const 1255 GravitySouth Gravity = "South" 1256 // GravitySouthEast const 1257 GravitySouthEast Gravity = "SouthEast" 1258 // GravitySouthWest const 1259 GravitySouthWest Gravity = "SouthWest" 1260 // GravityCenter const 1261 GravityCenter Gravity = "Center" 1262 // GravityEast const 1263 GravityEast Gravity = "East" 1264 // GravityWest const 1265 GravityWest Gravity = "West" 1266 1267 // GravityPostNorth const 1268 GravityPostNorth GravityPost = "North" 1269 // GravityPostNorthEast const 1270 GravityPostNorthEast GravityPost = "NorthEast" 1271 // GravityPostNorthWest const 1272 GravityPostNorthWest GravityPost = "NorthWest" 1273 // GravityPostSouth const 1274 GravityPostSouth GravityPost = "South" 1275 // GravityPostSouthEast const 1276 GravityPostSouthEast GravityPost = "SouthEast" 1277 // GravityPostSouthWest const 1278 GravityPostSouthWest GravityPost = "SouthWest" 1279 // GravityPostCenter const 1280 GravityPostCenter GravityPost = "Center" 1281 // GravityPostEast const 1282 GravityPostEast GravityPost = "East" 1283 // GravityPostWest const 1284 GravityPostWest GravityPost = "West" 1285 1286 // GrayscaleTransformationGrayscale const 1287 GrayscaleTransformationGrayscale GrayscaleTransformation = "Grayscale" 1288 1289 // GrayscaleTypeRec601 const 1290 GrayscaleTypeRec601 GrayscaleType = "Rec601" 1291 // GrayscaleTypeRec709 const 1292 GrayscaleTypeRec709 GrayscaleType = "Rec709" 1293 // GrayscaleTypeBrightness const 1294 GrayscaleTypeBrightness GrayscaleType = "Brightness" 1295 // GrayscaleTypeLightness const 1296 GrayscaleTypeLightness GrayscaleType = "Lightness" 1297 1298 // HSLTransformationHSL const 1299 HSLTransformationHSL HSLTransformation = "HSL" 1300 1301 // HSVTransformationHSV const 1302 HSVTransformationHSV HSVTransformation = "HSV" 1303 1304 // IfDimensionDimensionWidth const 1305 IfDimensionDimensionWidth IfDimensionDimension = "width" 1306 // IfDimensionDimensionHeight const 1307 IfDimensionDimensionHeight IfDimensionDimension = "height" 1308 // IfDimensionDimensionBoth const 1309 IfDimensionDimensionBoth IfDimensionDimension = "both" 1310 1311 // IfDimensionPostDimensionWidth const 1312 IfDimensionPostDimensionWidth IfDimensionPostDimension = "width" 1313 // IfDimensionPostDimensionHeight const 1314 IfDimensionPostDimensionHeight IfDimensionPostDimension = "height" 1315 // IfDimensionPostDimensionBoth const 1316 IfDimensionPostDimensionBoth IfDimensionPostDimension = "both" 1317 1318 // IfDimensionPostTransformationIfDimension const 1319 IfDimensionPostTransformationIfDimension IfDimensionPostTransformation = "IfDimension" 1320 1321 // IfDimensionTransformationIfDimension const 1322 IfDimensionTransformationIfDimension IfDimensionTransformation = "IfDimension" 1323 1324 // IfOrientationPostTransformationIfOrientation const 1325 IfOrientationPostTransformationIfOrientation IfOrientationPostTransformation = "IfOrientation" 1326 1327 // IfOrientationTransformationIfOrientation const 1328 IfOrientationTransformationIfOrientation IfOrientationTransformation = "IfOrientation" 1329 1330 // ImQueryAllowedTransformationsAppend const 1331 ImQueryAllowedTransformationsAppend ImQueryAllowedTransformations = "Append" 1332 // ImQueryAllowedTransformationsAspectCrop const 1333 ImQueryAllowedTransformationsAspectCrop ImQueryAllowedTransformations = "AspectCrop" 1334 // ImQueryAllowedTransformationsBackgroundColor const 1335 ImQueryAllowedTransformationsBackgroundColor ImQueryAllowedTransformations = "BackgroundColor" 1336 // ImQueryAllowedTransformationsBlur const 1337 ImQueryAllowedTransformationsBlur ImQueryAllowedTransformations = "Blur" 1338 // ImQueryAllowedTransformationsComposite const 1339 ImQueryAllowedTransformationsComposite ImQueryAllowedTransformations = "Composite" 1340 // ImQueryAllowedTransformationsContrast const 1341 ImQueryAllowedTransformationsContrast ImQueryAllowedTransformations = "Contrast" 1342 // ImQueryAllowedTransformationsCrop const 1343 ImQueryAllowedTransformationsCrop ImQueryAllowedTransformations = "Crop" 1344 // ImQueryAllowedTransformationsChromaKey const 1345 ImQueryAllowedTransformationsChromaKey ImQueryAllowedTransformations = "ChromaKey" 1346 // ImQueryAllowedTransformationsFaceCrop const 1347 ImQueryAllowedTransformationsFaceCrop ImQueryAllowedTransformations = "FaceCrop" 1348 // ImQueryAllowedTransformationsFeatureCrop const 1349 ImQueryAllowedTransformationsFeatureCrop ImQueryAllowedTransformations = "FeatureCrop" 1350 // ImQueryAllowedTransformationsFitAndFill const 1351 ImQueryAllowedTransformationsFitAndFill ImQueryAllowedTransformations = "FitAndFill" 1352 // ImQueryAllowedTransformationsGoop const 1353 ImQueryAllowedTransformationsGoop ImQueryAllowedTransformations = "Goop" 1354 // ImQueryAllowedTransformationsGrayscale const 1355 ImQueryAllowedTransformationsGrayscale ImQueryAllowedTransformations = "Grayscale" 1356 // ImQueryAllowedTransformationsHSL const 1357 ImQueryAllowedTransformationsHSL ImQueryAllowedTransformations = "HSL" 1358 // ImQueryAllowedTransformationsHSV const 1359 ImQueryAllowedTransformationsHSV ImQueryAllowedTransformations = "HSV" 1360 // ImQueryAllowedTransformationsMaxColors const 1361 ImQueryAllowedTransformationsMaxColors ImQueryAllowedTransformations = "MaxColors" 1362 // ImQueryAllowedTransformationsMirror const 1363 ImQueryAllowedTransformationsMirror ImQueryAllowedTransformations = "Mirror" 1364 // ImQueryAllowedTransformationsMonoHue const 1365 ImQueryAllowedTransformationsMonoHue ImQueryAllowedTransformations = "MonoHue" 1366 // ImQueryAllowedTransformationsOpacity const 1367 ImQueryAllowedTransformationsOpacity ImQueryAllowedTransformations = "Opacity" 1368 // ImQueryAllowedTransformationsRegionOfInterestCrop const 1369 ImQueryAllowedTransformationsRegionOfInterestCrop ImQueryAllowedTransformations = "RegionOfInterestCrop" 1370 // ImQueryAllowedTransformationsRelativeCrop const 1371 ImQueryAllowedTransformationsRelativeCrop ImQueryAllowedTransformations = "RelativeCrop" 1372 // ImQueryAllowedTransformationsRemoveColor const 1373 ImQueryAllowedTransformationsRemoveColor ImQueryAllowedTransformations = "RemoveColor" 1374 // ImQueryAllowedTransformationsResize const 1375 ImQueryAllowedTransformationsResize ImQueryAllowedTransformations = "Resize" 1376 // ImQueryAllowedTransformationsRotate const 1377 ImQueryAllowedTransformationsRotate ImQueryAllowedTransformations = "Rotate" 1378 // ImQueryAllowedTransformationsScale const 1379 ImQueryAllowedTransformationsScale ImQueryAllowedTransformations = "Scale" 1380 // ImQueryAllowedTransformationsShear const 1381 ImQueryAllowedTransformationsShear ImQueryAllowedTransformations = "Shear" 1382 // ImQueryAllowedTransformationsTrim const 1383 ImQueryAllowedTransformationsTrim ImQueryAllowedTransformations = "Trim" 1384 // ImQueryAllowedTransformationsUnsharpMask const 1385 ImQueryAllowedTransformationsUnsharpMask ImQueryAllowedTransformations = "UnsharpMask" 1386 // ImQueryAllowedTransformationsIfDimension const 1387 ImQueryAllowedTransformationsIfDimension ImQueryAllowedTransformations = "IfDimension" 1388 // ImQueryAllowedTransformationsIfOrientation const 1389 ImQueryAllowedTransformationsIfOrientation ImQueryAllowedTransformations = "IfOrientation" 1390 1391 // ImQueryTransformationImQuery const 1392 ImQueryTransformationImQuery ImQueryTransformation = "ImQuery" 1393 1394 // MaxColorsTransformationMaxColors const 1395 MaxColorsTransformationMaxColors MaxColorsTransformation = "MaxColors" 1396 1397 // MirrorTransformationMirror const 1398 MirrorTransformationMirror MirrorTransformation = "Mirror" 1399 1400 // MonoHueTransformationMonoHue const 1401 MonoHueTransformationMonoHue MonoHueTransformation = "MonoHue" 1402 1403 // OpacityTransformationOpacity const 1404 OpacityTransformationOpacity OpacityTransformation = "Opacity" 1405 1406 // OutputImageAllowedFormatsGif const 1407 OutputImageAllowedFormatsGif OutputImageAllowedFormats = "gif" 1408 // OutputImageAllowedFormatsJpeg const 1409 OutputImageAllowedFormatsJpeg OutputImageAllowedFormats = "jpeg" 1410 // OutputImageAllowedFormatsPng const 1411 OutputImageAllowedFormatsPng OutputImageAllowedFormats = "png" 1412 // OutputImageAllowedFormatsWebp const 1413 OutputImageAllowedFormatsWebp OutputImageAllowedFormats = "webp" 1414 // OutputImageAllowedFormatsJpegxr const 1415 OutputImageAllowedFormatsJpegxr OutputImageAllowedFormats = "jpegxr" 1416 // OutputImageAllowedFormatsJpeg2000 const 1417 OutputImageAllowedFormatsJpeg2000 OutputImageAllowedFormats = "jpeg2000" 1418 // OutputImageAllowedFormatsAvif const 1419 OutputImageAllowedFormatsAvif OutputImageAllowedFormats = "avif" 1420 1421 // OutputImageForcedFormatsGif const 1422 OutputImageForcedFormatsGif OutputImageForcedFormats = "gif" 1423 // OutputImageForcedFormatsJpeg const 1424 OutputImageForcedFormatsJpeg OutputImageForcedFormats = "jpeg" 1425 // OutputImageForcedFormatsPng const 1426 OutputImageForcedFormatsPng OutputImageForcedFormats = "png" 1427 // OutputImageForcedFormatsWebp const 1428 OutputImageForcedFormatsWebp OutputImageForcedFormats = "webp" 1429 // OutputImageForcedFormatsJpegxr const 1430 OutputImageForcedFormatsJpegxr OutputImageForcedFormats = "jpegxr" 1431 // OutputImageForcedFormatsJpeg2000 const 1432 OutputImageForcedFormatsJpeg2000 OutputImageForcedFormats = "jpeg2000" 1433 // OutputImageForcedFormatsAvif const 1434 OutputImageForcedFormatsAvif OutputImageForcedFormats = "avif" 1435 1436 // OutputImagePerceptualQualityHigh const 1437 OutputImagePerceptualQualityHigh OutputImagePerceptualQuality = "high" 1438 // OutputImagePerceptualQualityMediumHigh const 1439 OutputImagePerceptualQualityMediumHigh OutputImagePerceptualQuality = "mediumHigh" 1440 // OutputImagePerceptualQualityMedium const 1441 OutputImagePerceptualQualityMedium OutputImagePerceptualQuality = "medium" 1442 // OutputImagePerceptualQualityMediumLow const 1443 OutputImagePerceptualQualityMediumLow OutputImagePerceptualQuality = "mediumLow" 1444 // OutputImagePerceptualQualityLow const 1445 OutputImagePerceptualQualityLow OutputImagePerceptualQuality = "low" 1446 1447 // PolicyOutputImageVideoFalse const 1448 PolicyOutputImageVideoFalse PolicyOutputImageVideo = false 1449 1450 // RegionOfInterestCropStyleCrop const 1451 RegionOfInterestCropStyleCrop RegionOfInterestCropStyle = "crop" 1452 // RegionOfInterestCropStyleFill const 1453 RegionOfInterestCropStyleFill RegionOfInterestCropStyle = "fill" 1454 // RegionOfInterestCropStyleZoom const 1455 RegionOfInterestCropStyleZoom RegionOfInterestCropStyle = "zoom" 1456 1457 // RegionOfInterestCropTransformationRegionOfInterestCrop const 1458 RegionOfInterestCropTransformationRegionOfInterestCrop RegionOfInterestCropTransformation = "RegionOfInterestCrop" 1459 1460 // RelativeCropTransformationRelativeCrop const 1461 RelativeCropTransformationRelativeCrop RelativeCropTransformation = "RelativeCrop" 1462 1463 // RemoveColorTransformationRemoveColor const 1464 RemoveColorTransformationRemoveColor RemoveColorTransformation = "RemoveColor" 1465 1466 // ResizeAspectFit const 1467 ResizeAspectFit ResizeAspect = "fit" 1468 // ResizeAspectFill const 1469 ResizeAspectFill ResizeAspect = "fill" 1470 // ResizeAspectIgnore const 1471 ResizeAspectIgnore ResizeAspect = "ignore" 1472 1473 // ResizeTransformationResize const 1474 ResizeTransformationResize ResizeTransformation = "Resize" 1475 1476 // ResizeTypeNormal const 1477 ResizeTypeNormal ResizeType = "normal" 1478 // ResizeTypeUpsize const 1479 ResizeTypeUpsize ResizeType = "upsize" 1480 // ResizeTypeDownsize const 1481 ResizeTypeDownsize ResizeType = "downsize" 1482 1483 // RotateTransformationRotate const 1484 RotateTransformationRotate RotateTransformation = "Rotate" 1485 1486 // ScaleTransformationScale const 1487 ScaleTransformationScale ScaleTransformation = "Scale" 1488 1489 // ShearTransformationShear const 1490 ShearTransformationShear ShearTransformation = "Shear" 1491 1492 // TextImageTypePostTypeText const 1493 TextImageTypePostTypeText TextImageTypePostType = "Text" 1494 1495 // TextImageTypeTypeText const 1496 TextImageTypeTypeText TextImageTypeType = "Text" 1497 1498 // TrimTransformationTrim const 1499 TrimTransformationTrim TrimTransformation = "Trim" 1500 1501 // URLImageTypePostTypeURL const 1502 URLImageTypePostTypeURL URLImageTypePostType = "URL" 1503 1504 // URLImageTypeTypeURL const 1505 URLImageTypeTypeURL URLImageTypeType = "URL" 1506 1507 // UnsharpMaskTransformationUnsharpMask const 1508 UnsharpMaskTransformationUnsharpMask UnsharpMaskTransformation = "UnsharpMask" 1509 1510 // VariableTypeBool const 1511 VariableTypeBool VariableType = "bool" 1512 // VariableTypeNumber const 1513 VariableTypeNumber VariableType = "number" 1514 // VariableTypeURL const 1515 VariableTypeURL VariableType = "url" 1516 // VariableTypeColor const 1517 VariableTypeColor VariableType = "color" 1518 // VariableTypeGravity const 1519 VariableTypeGravity VariableType = "gravity" 1520 // VariableTypePlacement const 1521 VariableTypePlacement VariableType = "placement" 1522 // VariableTypeScaleDimension const 1523 VariableTypeScaleDimension VariableType = "scaleDimension" 1524 // VariableTypeGrayscaleType const 1525 VariableTypeGrayscaleType VariableType = "grayscaleType" 1526 // VariableTypeAspect const 1527 VariableTypeAspect VariableType = "aspect" 1528 // VariableTypeResizeType const 1529 VariableTypeResizeType VariableType = "resizeType" 1530 // VariableTypeDimension const 1531 VariableTypeDimension VariableType = "dimension" 1532 // VariableTypePerceptualQuality const 1533 VariableTypePerceptualQuality VariableType = "perceptualQuality" 1534 // VariableTypeString const 1535 VariableTypeString VariableType = "string" 1536 // VariableTypeFocus const 1537 VariableTypeFocus VariableType = "focus" 1538 1539 // OutputVideoPerceptualQualityHigh const 1540 OutputVideoPerceptualQualityHigh OutputVideoPerceptualQuality = "high" 1541 // OutputVideoPerceptualQualityMediumHigh const 1542 OutputVideoPerceptualQualityMediumHigh OutputVideoPerceptualQuality = "mediumHigh" 1543 // OutputVideoPerceptualQualityMedium const 1544 OutputVideoPerceptualQualityMedium OutputVideoPerceptualQuality = "medium" 1545 // OutputVideoPerceptualQualityMediumLow const 1546 OutputVideoPerceptualQualityMediumLow OutputVideoPerceptualQuality = "mediumLow" 1547 // OutputVideoPerceptualQualityLow const 1548 OutputVideoPerceptualQualityLow OutputVideoPerceptualQuality = "low" 1549 1550 // OutputVideoVideoAdaptiveQualityHigh const 1551 OutputVideoVideoAdaptiveQualityHigh OutputVideoVideoAdaptiveQuality = "high" 1552 // OutputVideoVideoAdaptiveQualityMediumHigh const 1553 OutputVideoVideoAdaptiveQualityMediumHigh OutputVideoVideoAdaptiveQuality = "mediumHigh" 1554 // OutputVideoVideoAdaptiveQualityMedium const 1555 OutputVideoVideoAdaptiveQualityMedium OutputVideoVideoAdaptiveQuality = "medium" 1556 // OutputVideoVideoAdaptiveQualityMediumLow const 1557 OutputVideoVideoAdaptiveQualityMediumLow OutputVideoVideoAdaptiveQuality = "mediumLow" 1558 // OutputVideoVideoAdaptiveQualityLow const 1559 OutputVideoVideoAdaptiveQualityLow OutputVideoVideoAdaptiveQuality = "low" 1560 1561 // PolicyOutputVideoVideoTrue const 1562 PolicyOutputVideoVideoTrue PolicyOutputVideoVideo = true 1563 ) 1564 1565 /*-----------------------------------------------*/ 1566 //////////// Interface implementations //////////// 1567 /*-----------------------------------------------*/ 1568 1569 func (Append) transformationType() string { 1570 return "Append" 1571 } 1572 1573 func (AspectCrop) transformationType() string { 1574 return "AspectCrop" 1575 } 1576 1577 func (BackgroundColor) transformationType() string { 1578 return "BackgroundColor" 1579 } 1580 1581 func (Blur) transformationType() string { 1582 return "Blur" 1583 } 1584 1585 func (BoxImageType) imageType() string { 1586 return "BoxImageType" 1587 } 1588 1589 func (BoxImageTypePost) imageTypePost() string { 1590 return "BoxImageTypePost" 1591 } 1592 1593 func (ChromaKey) transformationType() string { 1594 return "ChromaKey" 1595 } 1596 1597 func (CircleImageType) imageType() string { 1598 return "CircleImageType" 1599 } 1600 1601 func (CircleImageTypePost) imageTypePost() string { 1602 return "CircleImageTypePost" 1603 } 1604 1605 func (CircleShapeType) shapeType() string { 1606 return "CircleShapeType" 1607 } 1608 1609 func (Composite) transformationType() string { 1610 return "Composite" 1611 } 1612 1613 func (Compound) transformationType() string { 1614 return "Compound" 1615 } 1616 1617 func (Contrast) transformationType() string { 1618 return "Contrast" 1619 } 1620 1621 func (Crop) transformationType() string { 1622 return "Crop" 1623 } 1624 1625 func (FaceCrop) transformationType() string { 1626 return "FaceCrop" 1627 } 1628 1629 func (FeatureCrop) transformationType() string { 1630 return "FeatureCrop" 1631 } 1632 1633 func (FitAndFill) transformationType() string { 1634 return "FitAndFill" 1635 } 1636 1637 func (Goop) transformationType() string { 1638 return "Goop" 1639 } 1640 1641 func (Grayscale) transformationType() string { 1642 return "Grayscale" 1643 } 1644 1645 func (HSL) transformationType() string { 1646 return "HSL" 1647 } 1648 1649 func (HSV) transformationType() string { 1650 return "HSV" 1651 } 1652 1653 func (IfDimension) transformationType() string { 1654 return "IfDimension" 1655 } 1656 1657 func (IfOrientation) transformationType() string { 1658 return "IfOrientation" 1659 } 1660 1661 func (ImQuery) transformationType() string { 1662 return "ImQuery" 1663 } 1664 1665 func (MaxColors) transformationType() string { 1666 return "MaxColors" 1667 } 1668 1669 func (Mirror) transformationType() string { 1670 return "Mirror" 1671 } 1672 1673 func (MonoHue) transformationType() string { 1674 return "MonoHue" 1675 } 1676 1677 func (Opacity) transformationType() string { 1678 return "Opacity" 1679 } 1680 1681 func (PointShapeType) shapeType() string { 1682 return "PointShapeType" 1683 } 1684 1685 func (PolygonShapeType) shapeType() string { 1686 return "PolygonShapeType" 1687 } 1688 1689 func (RectangleShapeType) shapeType() string { 1690 return "RectangleShapeType" 1691 } 1692 1693 func (RegionOfInterestCrop) transformationType() string { 1694 return "RegionOfInterestCrop" 1695 } 1696 1697 func (RelativeCrop) transformationType() string { 1698 return "RelativeCrop" 1699 } 1700 1701 func (RemoveColor) transformationType() string { 1702 return "RemoveColor" 1703 } 1704 1705 func (Resize) transformationType() string { 1706 return "Resize" 1707 } 1708 1709 func (Rotate) transformationType() string { 1710 return "Rotate" 1711 } 1712 1713 func (Scale) transformationType() string { 1714 return "Scale" 1715 } 1716 1717 func (Shear) transformationType() string { 1718 return "Shear" 1719 } 1720 1721 func (TextImageType) imageType() string { 1722 return "TextImageType" 1723 } 1724 1725 func (TextImageTypePost) imageTypePost() string { 1726 return "TextImageTypePost" 1727 } 1728 1729 func (Trim) transformationType() string { 1730 return "Trim" 1731 } 1732 1733 func (URLImageType) imageType() string { 1734 return "URLImageType" 1735 } 1736 1737 func (URLImageTypePost) imageTypePost() string { 1738 return "URLImageTypePost" 1739 } 1740 1741 func (UnionShapeType) shapeType() string { 1742 return "UnionShapeType" 1743 } 1744 1745 func (UnsharpMask) transformationType() string { 1746 return "UnsharpMask" 1747 } 1748 1749 func (BackgroundColor) transformationTypePost() string { 1750 return "BackgroundColor" 1751 } 1752 1753 func (Blur) transformationTypePost() string { 1754 return "Blur" 1755 } 1756 1757 func (ChromaKey) transformationTypePost() string { 1758 return "ChromaKey" 1759 } 1760 1761 func (CompositePost) transformationTypePost() string { 1762 return "CompositePost" 1763 } 1764 1765 func (CompoundPost) transformationTypePost() string { 1766 return "CompoundPost" 1767 } 1768 1769 func (Contrast) transformationTypePost() string { 1770 return "Contrast" 1771 } 1772 1773 func (Goop) transformationTypePost() string { 1774 return "Goop" 1775 } 1776 1777 func (Grayscale) transformationTypePost() string { 1778 return "Grayscale" 1779 } 1780 1781 func (HSL) transformationTypePost() string { 1782 return "HSL" 1783 } 1784 1785 func (HSV) transformationTypePost() string { 1786 return "HSV" 1787 } 1788 1789 func (IfDimensionPost) transformationTypePost() string { 1790 return "IfDimensionPost" 1791 } 1792 1793 func (IfOrientationPost) transformationTypePost() string { 1794 return "IfOrientationPost" 1795 } 1796 1797 func (MaxColors) transformationTypePost() string { 1798 return "MaxColors" 1799 } 1800 1801 func (Mirror) transformationTypePost() string { 1802 return "Mirror" 1803 } 1804 1805 func (MonoHue) transformationTypePost() string { 1806 return "MonoHue" 1807 } 1808 1809 func (Opacity) transformationTypePost() string { 1810 return "Opacity" 1811 } 1812 1813 func (RemoveColor) transformationTypePost() string { 1814 return "RemoveColor" 1815 } 1816 1817 func (UnsharpMask) transformationTypePost() string { 1818 return "UnsharpMask" 1819 } 1820 1821 /*-----------------------------------------------*/ 1822 //////////////// Pointer functions //////////////// 1823 /*-----------------------------------------------*/ 1824 1825 // AppendGravityPriorityPtr returns pointer of AppendGravityPriority 1826 func AppendGravityPriorityPtr(v AppendGravityPriority) *AppendGravityPriority { 1827 return &v 1828 } 1829 1830 // AppendTransformationPtr returns pointer of AppendTransformation 1831 func AppendTransformationPtr(v AppendTransformation) *AppendTransformation { 1832 return &v 1833 } 1834 1835 // AspectCropTransformationPtr returns pointer of AspectCropTransformation 1836 func AspectCropTransformationPtr(v AspectCropTransformation) *AspectCropTransformation { 1837 return &v 1838 } 1839 1840 // BackgroundColorTransformationPtr returns pointer of BackgroundColorTransformation 1841 func BackgroundColorTransformationPtr(v BackgroundColorTransformation) *BackgroundColorTransformation { 1842 return &v 1843 } 1844 1845 // BlurTransformationPtr returns pointer of BlurTransformation 1846 func BlurTransformationPtr(v BlurTransformation) *BlurTransformation { 1847 return &v 1848 } 1849 1850 // BoxImageTypePostTypePtr returns pointer of BoxImageTypePostType 1851 func BoxImageTypePostTypePtr(v BoxImageTypePostType) *BoxImageTypePostType { 1852 return &v 1853 } 1854 1855 // BoxImageTypeTypePtr returns pointer of BoxImageTypeType 1856 func BoxImageTypeTypePtr(v BoxImageTypeType) *BoxImageTypeType { 1857 return &v 1858 } 1859 1860 // ChromaKeyTransformationPtr returns pointer of ChromaKeyTransformation 1861 func ChromaKeyTransformationPtr(v ChromaKeyTransformation) *ChromaKeyTransformation { 1862 return &v 1863 } 1864 1865 // CircleImageTypePostTypePtr returns pointer of CircleImageTypePostType 1866 func CircleImageTypePostTypePtr(v CircleImageTypePostType) *CircleImageTypePostType { 1867 return &v 1868 } 1869 1870 // CircleImageTypeTypePtr returns pointer of CircleImageTypeType 1871 func CircleImageTypeTypePtr(v CircleImageTypeType) *CircleImageTypeType { 1872 return &v 1873 } 1874 1875 // CompositePlacementPtr returns pointer of CompositePlacement 1876 func CompositePlacementPtr(v CompositePlacement) *CompositePlacement { 1877 return &v 1878 } 1879 1880 // CompositePostPlacementPtr returns pointer of CompositePostPlacement 1881 func CompositePostPlacementPtr(v CompositePostPlacement) *CompositePostPlacement { 1882 return &v 1883 } 1884 1885 // CompositePostScaleDimensionPtr returns pointer of CompositePostScaleDimension 1886 func CompositePostScaleDimensionPtr(v CompositePostScaleDimension) *CompositePostScaleDimension { 1887 return &v 1888 } 1889 1890 // CompositePostTransformationPtr returns pointer of CompositePostTransformation 1891 func CompositePostTransformationPtr(v CompositePostTransformation) *CompositePostTransformation { 1892 return &v 1893 } 1894 1895 // CompositeScaleDimensionPtr returns pointer of CompositeScaleDimension 1896 func CompositeScaleDimensionPtr(v CompositeScaleDimension) *CompositeScaleDimension { 1897 return &v 1898 } 1899 1900 // CompositeTransformationPtr returns pointer of CompositeTransformation 1901 func CompositeTransformationPtr(v CompositeTransformation) *CompositeTransformation { 1902 return &v 1903 } 1904 1905 // CompoundPostTransformationPtr returns pointer of CompoundPostTransformation 1906 func CompoundPostTransformationPtr(v CompoundPostTransformation) *CompoundPostTransformation { 1907 return &v 1908 } 1909 1910 // CompoundTransformationPtr returns pointer of CompoundTransformation 1911 func CompoundTransformationPtr(v CompoundTransformation) *CompoundTransformation { 1912 return &v 1913 } 1914 1915 // ContrastTransformationPtr returns pointer of ContrastTransformation 1916 func ContrastTransformationPtr(v ContrastTransformation) *ContrastTransformation { 1917 return &v 1918 } 1919 1920 // CropTransformationPtr returns pointer of CropTransformation 1921 func CropTransformationPtr(v CropTransformation) *CropTransformation { 1922 return &v 1923 } 1924 1925 // FaceCropAlgorithmPtr returns pointer of FaceCropAlgorithm 1926 func FaceCropAlgorithmPtr(v FaceCropAlgorithm) *FaceCropAlgorithm { 1927 return &v 1928 } 1929 1930 // FaceCropFocusPtr returns pointer of FaceCropFocus 1931 func FaceCropFocusPtr(v FaceCropFocus) *FaceCropFocus { 1932 return &v 1933 } 1934 1935 // FaceCropStylePtr returns pointer of FaceCropStyle 1936 func FaceCropStylePtr(v FaceCropStyle) *FaceCropStyle { 1937 return &v 1938 } 1939 1940 // FaceCropTransformationPtr returns pointer of FaceCropTransformation 1941 func FaceCropTransformationPtr(v FaceCropTransformation) *FaceCropTransformation { 1942 return &v 1943 } 1944 1945 // FeatureCropStylePtr returns pointer of FeatureCropStyle 1946 func FeatureCropStylePtr(v FeatureCropStyle) *FeatureCropStyle { 1947 return &v 1948 } 1949 1950 // FeatureCropTransformationPtr returns pointer of FeatureCropTransformation 1951 func FeatureCropTransformationPtr(v FeatureCropTransformation) *FeatureCropTransformation { 1952 return &v 1953 } 1954 1955 // FitAndFillTransformationPtr returns pointer of FitAndFillTransformation 1956 func FitAndFillTransformationPtr(v FitAndFillTransformation) *FitAndFillTransformation { 1957 return &v 1958 } 1959 1960 // GoopTransformationPtr returns pointer of GoopTransformation 1961 func GoopTransformationPtr(v GoopTransformation) *GoopTransformation { 1962 return &v 1963 } 1964 1965 // GravityPtr returns pointer of Gravity 1966 func GravityPtr(v Gravity) *Gravity { 1967 return &v 1968 } 1969 1970 // GravityPostPtr returns pointer of GravityPost 1971 func GravityPostPtr(v GravityPost) *GravityPost { 1972 return &v 1973 } 1974 1975 // GrayscaleTransformationPtr returns pointer of GrayscaleTransformation 1976 func GrayscaleTransformationPtr(v GrayscaleTransformation) *GrayscaleTransformation { 1977 return &v 1978 } 1979 1980 // GrayscaleTypePtr returns pointer of GrayscaleType 1981 func GrayscaleTypePtr(v GrayscaleType) *GrayscaleType { 1982 return &v 1983 } 1984 1985 // HSLTransformationPtr returns pointer of HSLTransformation 1986 func HSLTransformationPtr(v HSLTransformation) *HSLTransformation { 1987 return &v 1988 } 1989 1990 // HSVTransformationPtr returns pointer of HSVTransformation 1991 func HSVTransformationPtr(v HSVTransformation) *HSVTransformation { 1992 return &v 1993 } 1994 1995 // IfDimensionDimensionPtr returns pointer of IfDimensionDimension 1996 func IfDimensionDimensionPtr(v IfDimensionDimension) *IfDimensionDimension { 1997 return &v 1998 } 1999 2000 // IfDimensionPostDimensionPtr returns pointer of IfDimensionPostDimension 2001 func IfDimensionPostDimensionPtr(v IfDimensionPostDimension) *IfDimensionPostDimension { 2002 return &v 2003 } 2004 2005 // IfDimensionPostTransformationPtr returns pointer of IfDimensionPostTransformation 2006 func IfDimensionPostTransformationPtr(v IfDimensionPostTransformation) *IfDimensionPostTransformation { 2007 return &v 2008 } 2009 2010 // IfDimensionTransformationPtr returns pointer of IfDimensionTransformation 2011 func IfDimensionTransformationPtr(v IfDimensionTransformation) *IfDimensionTransformation { 2012 return &v 2013 } 2014 2015 // IfOrientationPostTransformationPtr returns pointer of IfOrientationPostTransformation 2016 func IfOrientationPostTransformationPtr(v IfOrientationPostTransformation) *IfOrientationPostTransformation { 2017 return &v 2018 } 2019 2020 // IfOrientationTransformationPtr returns pointer of IfOrientationTransformation 2021 func IfOrientationTransformationPtr(v IfOrientationTransformation) *IfOrientationTransformation { 2022 return &v 2023 } 2024 2025 // ImQueryAllowedTransformationsPtr returns pointer of ImQueryAllowedTransformations 2026 func ImQueryAllowedTransformationsPtr(v ImQueryAllowedTransformations) *ImQueryAllowedTransformations { 2027 return &v 2028 } 2029 2030 // ImQueryTransformationPtr returns pointer of ImQueryTransformation 2031 func ImQueryTransformationPtr(v ImQueryTransformation) *ImQueryTransformation { 2032 return &v 2033 } 2034 2035 // MaxColorsTransformationPtr returns pointer of MaxColorsTransformation 2036 func MaxColorsTransformationPtr(v MaxColorsTransformation) *MaxColorsTransformation { 2037 return &v 2038 } 2039 2040 // MirrorTransformationPtr returns pointer of MirrorTransformation 2041 func MirrorTransformationPtr(v MirrorTransformation) *MirrorTransformation { 2042 return &v 2043 } 2044 2045 // MonoHueTransformationPtr returns pointer of MonoHueTransformation 2046 func MonoHueTransformationPtr(v MonoHueTransformation) *MonoHueTransformation { 2047 return &v 2048 } 2049 2050 // OpacityTransformationPtr returns pointer of OpacityTransformation 2051 func OpacityTransformationPtr(v OpacityTransformation) *OpacityTransformation { 2052 return &v 2053 } 2054 2055 // OutputImageAllowedFormatsPtr returns pointer of OutputImageAllowedFormats 2056 func OutputImageAllowedFormatsPtr(v OutputImageAllowedFormats) *OutputImageAllowedFormats { 2057 return &v 2058 } 2059 2060 // OutputImageForcedFormatsPtr returns pointer of OutputImageForcedFormats 2061 func OutputImageForcedFormatsPtr(v OutputImageForcedFormats) *OutputImageForcedFormats { 2062 return &v 2063 } 2064 2065 // OutputImagePerceptualQualityPtr returns pointer of OutputImagePerceptualQuality 2066 func OutputImagePerceptualQualityPtr(v OutputImagePerceptualQuality) *OutputImagePerceptualQuality { 2067 return &v 2068 } 2069 2070 // RegionOfInterestCropStylePtr returns pointer of RegionOfInterestCropStyle 2071 func RegionOfInterestCropStylePtr(v RegionOfInterestCropStyle) *RegionOfInterestCropStyle { 2072 return &v 2073 } 2074 2075 // RegionOfInterestCropTransformationPtr returns pointer of RegionOfInterestCropTransformation 2076 func RegionOfInterestCropTransformationPtr(v RegionOfInterestCropTransformation) *RegionOfInterestCropTransformation { 2077 return &v 2078 } 2079 2080 // RelativeCropTransformationPtr returns pointer of RelativeCropTransformation 2081 func RelativeCropTransformationPtr(v RelativeCropTransformation) *RelativeCropTransformation { 2082 return &v 2083 } 2084 2085 // RemoveColorTransformationPtr returns pointer of RemoveColorTransformation 2086 func RemoveColorTransformationPtr(v RemoveColorTransformation) *RemoveColorTransformation { 2087 return &v 2088 } 2089 2090 // ResizeAspectPtr returns pointer of ResizeAspect 2091 func ResizeAspectPtr(v ResizeAspect) *ResizeAspect { 2092 return &v 2093 } 2094 2095 // ResizeTransformationPtr returns pointer of ResizeTransformation 2096 func ResizeTransformationPtr(v ResizeTransformation) *ResizeTransformation { 2097 return &v 2098 } 2099 2100 // ResizeTypePtr returns pointer of ResizeType 2101 func ResizeTypePtr(v ResizeType) *ResizeType { 2102 return &v 2103 } 2104 2105 // RotateTransformationPtr returns pointer of RotateTransformation 2106 func RotateTransformationPtr(v RotateTransformation) *RotateTransformation { 2107 return &v 2108 } 2109 2110 // ScaleTransformationPtr returns pointer of ScaleTransformation 2111 func ScaleTransformationPtr(v ScaleTransformation) *ScaleTransformation { 2112 return &v 2113 } 2114 2115 // ShearTransformationPtr returns pointer of ShearTransformation 2116 func ShearTransformationPtr(v ShearTransformation) *ShearTransformation { 2117 return &v 2118 } 2119 2120 // TextImageTypePostTypePtr returns pointer of TextImageTypePostType 2121 func TextImageTypePostTypePtr(v TextImageTypePostType) *TextImageTypePostType { 2122 return &v 2123 } 2124 2125 // TextImageTypeTypePtr returns pointer of TextImageTypeType 2126 func TextImageTypeTypePtr(v TextImageTypeType) *TextImageTypeType { 2127 return &v 2128 } 2129 2130 // TrimTransformationPtr returns pointer of TrimTransformation 2131 func TrimTransformationPtr(v TrimTransformation) *TrimTransformation { 2132 return &v 2133 } 2134 2135 // URLImageTypePostTypePtr returns pointer of URLImageTypePostType 2136 func URLImageTypePostTypePtr(v URLImageTypePostType) *URLImageTypePostType { 2137 return &v 2138 } 2139 2140 // URLImageTypeTypePtr returns pointer of URLImageTypeType 2141 func URLImageTypeTypePtr(v URLImageTypeType) *URLImageTypeType { 2142 return &v 2143 } 2144 2145 // UnsharpMaskTransformationPtr returns pointer of UnsharpMaskTransformation 2146 func UnsharpMaskTransformationPtr(v UnsharpMaskTransformation) *UnsharpMaskTransformation { 2147 return &v 2148 } 2149 2150 // VariableTypePtr returns pointer of VariableType 2151 func VariableTypePtr(v VariableType) *VariableType { 2152 return &v 2153 } 2154 2155 // OutputVideoPerceptualQualityPtr returns pointer of OutputVideoPerceptualQuality 2156 func OutputVideoPerceptualQualityPtr(v OutputVideoPerceptualQuality) *OutputVideoPerceptualQuality { 2157 return &v 2158 } 2159 2160 // OutputVideoVideoAdaptiveQualityPtr returns pointer of OutputVideoVideoAdaptiveQuality 2161 func OutputVideoVideoAdaptiveQualityPtr(v OutputVideoVideoAdaptiveQuality) *OutputVideoVideoAdaptiveQuality { 2162 return &v 2163 } 2164 2165 /*-----------------------------------------------*/ 2166 /////////////////// Validators //////////////////// 2167 /*-----------------------------------------------*/ 2168 2169 // Validate validates Append 2170 func (a Append) Validate() error { 2171 return validation.Errors{ 2172 "Gravity": validation.Validate(a.Gravity), 2173 "GravityPriority": validation.Validate(a.GravityPriority), 2174 "Image": validation.Validate(a.Image, 2175 validation.Required, 2176 ), 2177 "PreserveMinorDimension": validation.Validate(a.PreserveMinorDimension), 2178 "Transformation": validation.Validate(a.Transformation, 2179 validation.Required, 2180 validation.In(AppendTransformationAppend), 2181 ), 2182 }.Filter() 2183 } 2184 2185 // Validate validates AppendGravityPriorityVariableInline 2186 func (a AppendGravityPriorityVariableInline) Validate() error { 2187 return validation.Errors{ 2188 "Name": validation.Validate(a.Name), 2189 "Value": validation.Validate(a.Value, 2190 validation.In(AppendGravityPriorityHorizontal, AppendGravityPriorityVertical), 2191 ), 2192 }.Filter() 2193 } 2194 2195 // Validate validates AspectCrop 2196 func (a AspectCrop) Validate() error { 2197 return validation.Errors{ 2198 "AllowExpansion": validation.Validate(a.AllowExpansion), 2199 "Height": validation.Validate(a.Height), 2200 "Transformation": validation.Validate(a.Transformation, 2201 validation.Required, 2202 validation.In(AspectCropTransformationAspectCrop), 2203 ), 2204 "Width": validation.Validate(a.Width), 2205 "XPosition": validation.Validate(a.XPosition), 2206 "YPosition": validation.Validate(a.YPosition), 2207 }.Filter() 2208 } 2209 2210 // Validate validates BackgroundColor 2211 func (b BackgroundColor) Validate() error { 2212 return validation.Errors{ 2213 "Color": validation.Validate(b.Color, 2214 validation.Required, 2215 ), 2216 "Transformation": validation.Validate(b.Transformation, 2217 validation.Required, 2218 validation.In(BackgroundColorTransformationBackgroundColor), 2219 ), 2220 }.Filter() 2221 } 2222 2223 // Validate validates Blur 2224 func (b Blur) Validate() error { 2225 return validation.Errors{ 2226 "Sigma": validation.Validate(b.Sigma), 2227 "Transformation": validation.Validate(b.Transformation, 2228 validation.Required, 2229 validation.In(BlurTransformationBlur), 2230 ), 2231 }.Filter() 2232 } 2233 2234 // Validate validates BooleanVariableInline 2235 func (b BooleanVariableInline) Validate() error { 2236 return validation.Errors{ 2237 "Name": validation.Validate(b.Name), 2238 "Value": validation.Validate(b.Value), 2239 }.Filter() 2240 } 2241 2242 // Validate validates BoxImageType 2243 func (b BoxImageType) Validate() error { 2244 return validation.Errors{ 2245 "Color": validation.Validate(b.Color), 2246 "Height": validation.Validate(b.Height), 2247 "Transformation": validation.Validate(b.Transformation), 2248 "Type": validation.Validate(b.Type, 2249 validation.Required, 2250 validation.In(BoxImageTypeTypeBox), 2251 ), 2252 "Width": validation.Validate(b.Width), 2253 }.Filter() 2254 } 2255 2256 // Validate validates BoxImageTypePost 2257 func (b BoxImageTypePost) Validate() error { 2258 return validation.Errors{ 2259 "Color": validation.Validate(b.Color), 2260 "Height": validation.Validate(b.Height), 2261 "Transformation": validation.Validate(b.Transformation), 2262 "Type": validation.Validate(b.Type, 2263 validation.Required, 2264 validation.In(BoxImageTypePostTypeBox), 2265 ), 2266 "Width": validation.Validate(b.Width), 2267 }.Filter() 2268 } 2269 2270 // Validate validates Breakpoints 2271 func (b Breakpoints) Validate() error { 2272 return validation.Errors{ 2273 "Widths": validation.Validate(b.Widths, validation.Each()), 2274 }.Filter() 2275 } 2276 2277 // Validate validates ChromaKey 2278 func (c ChromaKey) Validate() error { 2279 return validation.Errors{ 2280 "Hue": validation.Validate(c.Hue), 2281 "HueFeather": validation.Validate(c.HueFeather), 2282 "HueTolerance": validation.Validate(c.HueTolerance), 2283 "LightnessFeather": validation.Validate(c.LightnessFeather), 2284 "LightnessTolerance": validation.Validate(c.LightnessTolerance), 2285 "SaturationFeather": validation.Validate(c.SaturationFeather), 2286 "SaturationTolerance": validation.Validate(c.SaturationTolerance), 2287 "Transformation": validation.Validate(c.Transformation, 2288 validation.Required, 2289 validation.In(ChromaKeyTransformationChromaKey), 2290 ), 2291 }.Filter() 2292 } 2293 2294 // Validate validates CircleImageType 2295 func (c CircleImageType) Validate() error { 2296 return validation.Errors{ 2297 "Color": validation.Validate(c.Color), 2298 "Diameter": validation.Validate(c.Diameter), 2299 "Transformation": validation.Validate(c.Transformation), 2300 "Type": validation.Validate(c.Type, 2301 validation.Required, 2302 validation.In(CircleImageTypeTypeCircle), 2303 ), 2304 "Width": validation.Validate(c.Width), 2305 }.Filter() 2306 } 2307 2308 // Validate validates CircleImageTypePost 2309 func (c CircleImageTypePost) Validate() error { 2310 return validation.Errors{ 2311 "Color": validation.Validate(c.Color), 2312 "Diameter": validation.Validate(c.Diameter), 2313 "Transformation": validation.Validate(c.Transformation), 2314 "Type": validation.Validate(c.Type, 2315 validation.Required, 2316 validation.In(CircleImageTypePostTypeCircle), 2317 ), 2318 "Width": validation.Validate(c.Width), 2319 }.Filter() 2320 } 2321 2322 // Validate validates CircleShapeType 2323 func (c CircleShapeType) Validate() error { 2324 return validation.Errors{ 2325 "Center": validation.Validate(c.Center, 2326 validation.Required, 2327 ), 2328 "Radius": validation.Validate(c.Radius, 2329 validation.Required, 2330 ), 2331 }.Filter() 2332 } 2333 2334 // Validate validates Composite 2335 func (c Composite) Validate() error { 2336 return validation.Errors{ 2337 "Gravity": validation.Validate(c.Gravity), 2338 "Image": validation.Validate(c.Image, 2339 validation.Required, 2340 ), 2341 "Placement": validation.Validate(c.Placement), 2342 "Scale": validation.Validate(c.Scale), 2343 "ScaleDimension": validation.Validate(c.ScaleDimension), 2344 "Transformation": validation.Validate(c.Transformation, 2345 validation.Required, 2346 validation.In(CompositeTransformationComposite), 2347 ), 2348 "XPosition": validation.Validate(c.XPosition), 2349 "YPosition": validation.Validate(c.YPosition), 2350 }.Filter() 2351 } 2352 2353 // Validate validates CompositePlacementVariableInline 2354 func (c CompositePlacementVariableInline) Validate() error { 2355 return validation.Errors{ 2356 "Name": validation.Validate(c.Name), 2357 "Value": validation.Validate(c.Value, 2358 validation.In(CompositePlacementOver, 2359 CompositePlacementUnder, 2360 CompositePlacementMask, 2361 CompositePlacementStencil), 2362 ), 2363 }.Filter() 2364 } 2365 2366 // Validate validates CompositePost 2367 func (c CompositePost) Validate() error { 2368 return validation.Errors{ 2369 "Gravity": validation.Validate(c.Gravity), 2370 "Image": validation.Validate(c.Image, 2371 validation.Required, 2372 ), 2373 "Placement": validation.Validate(c.Placement), 2374 "Scale": validation.Validate(c.Scale), 2375 "ScaleDimension": validation.Validate(c.ScaleDimension), 2376 "Transformation": validation.Validate(c.Transformation, 2377 validation.Required, 2378 validation.In(CompositePostTransformationComposite), 2379 ), 2380 "XPosition": validation.Validate(c.XPosition), 2381 "YPosition": validation.Validate(c.YPosition), 2382 }.Filter() 2383 } 2384 2385 // Validate validates CompositePostPlacementVariableInline 2386 func (c CompositePostPlacementVariableInline) Validate() error { 2387 return validation.Errors{ 2388 "Name": validation.Validate(c.Name), 2389 "Value": validation.Validate(c.Value, 2390 validation.In(CompositePostPlacementOver, 2391 CompositePostPlacementUnder, 2392 CompositePostPlacementMask, 2393 CompositePostPlacementStencil), 2394 ), 2395 }.Filter() 2396 } 2397 2398 // Validate validates CompositePostScaleDimensionVariableInline 2399 func (c CompositePostScaleDimensionVariableInline) Validate() error { 2400 return validation.Errors{ 2401 "Name": validation.Validate(c.Name), 2402 "Value": validation.Validate(c.Value, 2403 validation.In(CompositePostScaleDimensionWidth, CompositePostScaleDimensionHeight), 2404 ), 2405 }.Filter() 2406 } 2407 2408 // Validate validates CompositeScaleDimensionVariableInline 2409 func (c CompositeScaleDimensionVariableInline) Validate() error { 2410 return validation.Errors{ 2411 "Name": validation.Validate(c.Name), 2412 "Value": validation.Validate(c.Value, 2413 validation.In(CompositeScaleDimensionWidth, CompositeScaleDimensionHeight), 2414 ), 2415 }.Filter() 2416 } 2417 2418 // Validate validates Compound 2419 func (c Compound) Validate() error { 2420 return validation.Errors{ 2421 "Transformation": validation.Validate(c.Transformation, 2422 validation.Required, 2423 validation.In(CompoundTransformationCompound), 2424 ), 2425 "Transformations": validation.Validate(c.Transformations), 2426 }.Filter() 2427 } 2428 2429 // Validate validates CompoundPost 2430 func (c CompoundPost) Validate() error { 2431 return validation.Errors{ 2432 "Transformation": validation.Validate(c.Transformation, 2433 validation.Required, 2434 validation.In(CompoundPostTransformationCompound), 2435 ), 2436 "Transformations": validation.Validate(c.Transformations), 2437 }.Filter() 2438 } 2439 2440 // Validate validates Contrast 2441 func (c Contrast) Validate() error { 2442 return validation.Errors{ 2443 "Brightness": validation.Validate(c.Brightness), 2444 "Contrast": validation.Validate(c.Contrast), 2445 "Transformation": validation.Validate(c.Transformation, 2446 validation.Required, 2447 validation.In(ContrastTransformationContrast), 2448 ), 2449 }.Filter() 2450 } 2451 2452 // Validate validates Crop 2453 func (c Crop) Validate() error { 2454 return validation.Errors{ 2455 "AllowExpansion": validation.Validate(c.AllowExpansion), 2456 "Gravity": validation.Validate(c.Gravity), 2457 "Height": validation.Validate(c.Height, 2458 validation.Required, 2459 ), 2460 "Transformation": validation.Validate(c.Transformation, 2461 validation.Required, 2462 validation.In(CropTransformationCrop), 2463 ), 2464 "Width": validation.Validate(c.Width, 2465 validation.Required, 2466 ), 2467 "XPosition": validation.Validate(c.XPosition), 2468 "YPosition": validation.Validate(c.YPosition), 2469 }.Filter() 2470 } 2471 2472 // Validate validates EnumOptions 2473 func (e EnumOptions) Validate() error { 2474 return validation.Errors{ 2475 "ID": validation.Validate(e.ID, 2476 validation.Required, 2477 ), 2478 "Value": validation.Validate(e.Value, 2479 validation.Required, 2480 ), 2481 }.Filter() 2482 } 2483 2484 // Validate validates FaceCrop 2485 func (f FaceCrop) Validate() error { 2486 return validation.Errors{ 2487 "Algorithm": validation.Validate(f.Algorithm), 2488 "Confidence": validation.Validate(f.Confidence), 2489 "FailGravity": validation.Validate(f.FailGravity), 2490 "Focus": validation.Validate(f.Focus), 2491 "Gravity": validation.Validate(f.Gravity), 2492 "Height": validation.Validate(f.Height, 2493 validation.Required, 2494 ), 2495 "Padding": validation.Validate(f.Padding), 2496 "Style": validation.Validate(f.Style), 2497 "Transformation": validation.Validate(f.Transformation, 2498 validation.Required, 2499 validation.In(FaceCropTransformationFaceCrop), 2500 ), 2501 "Width": validation.Validate(f.Width, 2502 validation.Required, 2503 ), 2504 }.Filter() 2505 } 2506 2507 // Validate validates FaceCropAlgorithmVariableInline 2508 func (f FaceCropAlgorithmVariableInline) Validate() error { 2509 return validation.Errors{ 2510 "Name": validation.Validate(f.Name), 2511 "Value": validation.Validate(f.Value, 2512 validation.In(FaceCropAlgorithmCascade, FaceCropAlgorithmDnn), 2513 ), 2514 }.Filter() 2515 } 2516 2517 // Validate validates FaceCropFocusVariableInline 2518 func (f FaceCropFocusVariableInline) Validate() error { 2519 return validation.Errors{ 2520 "Name": validation.Validate(f.Name), 2521 "Value": validation.Validate(f.Value, 2522 validation.In(FaceCropFocusAllFaces, FaceCropFocusBiggestFace), 2523 ), 2524 }.Filter() 2525 } 2526 2527 // Validate validates FaceCropStyleVariableInline 2528 func (f FaceCropStyleVariableInline) Validate() error { 2529 return validation.Errors{ 2530 "Name": validation.Validate(f.Name), 2531 "Value": validation.Validate(f.Value, 2532 validation.In(FaceCropStyleCrop, FaceCropStyleFill, FaceCropStyleZoom), 2533 ), 2534 }.Filter() 2535 } 2536 2537 // Validate validates FeatureCrop 2538 func (f FeatureCrop) Validate() error { 2539 return validation.Errors{ 2540 "FailGravity": validation.Validate(f.FailGravity), 2541 "FeatureRadius": validation.Validate(f.FeatureRadius), 2542 "Gravity": validation.Validate(f.Gravity), 2543 "Height": validation.Validate(f.Height, 2544 validation.Required, 2545 ), 2546 "MaxFeatures": validation.Validate(f.MaxFeatures), 2547 "MinFeatureQuality": validation.Validate(f.MinFeatureQuality), 2548 "Padding": validation.Validate(f.Padding), 2549 "Style": validation.Validate(f.Style), 2550 "Transformation": validation.Validate(f.Transformation, 2551 validation.Required, 2552 validation.In(FeatureCropTransformationFeatureCrop), 2553 ), 2554 "Width": validation.Validate(f.Width, 2555 validation.Required, 2556 ), 2557 }.Filter() 2558 } 2559 2560 // Validate validates FeatureCropStyleVariableInline 2561 func (f FeatureCropStyleVariableInline) Validate() error { 2562 return validation.Errors{ 2563 "Name": validation.Validate(f.Name), 2564 "Value": validation.Validate(f.Value, 2565 validation.In(FeatureCropStyleCrop, FeatureCropStyleFill, FeatureCropStyleZoom), 2566 ), 2567 }.Filter() 2568 } 2569 2570 // Validate validates FitAndFill 2571 func (f FitAndFill) Validate() error { 2572 return validation.Errors{ 2573 "FillTransformation": validation.Validate(f.FillTransformation), 2574 "Height": validation.Validate(f.Height, 2575 validation.Required, 2576 ), 2577 "Transformation": validation.Validate(f.Transformation, 2578 validation.Required, 2579 validation.In(FitAndFillTransformationFitAndFill), 2580 ), 2581 "Width": validation.Validate(f.Width, 2582 validation.Required, 2583 ), 2584 }.Filter() 2585 } 2586 2587 // Validate validates Goop 2588 func (g Goop) Validate() error { 2589 return validation.Errors{ 2590 "Chaos": validation.Validate(g.Chaos), 2591 "Density": validation.Validate(g.Density), 2592 "Power": validation.Validate(g.Power), 2593 "Seed": validation.Validate(g.Seed), 2594 "Transformation": validation.Validate(g.Transformation, 2595 validation.Required, 2596 validation.In(GoopTransformationGoop), 2597 ), 2598 }.Filter() 2599 } 2600 2601 // Validate validates GravityPostVariableInline 2602 func (g GravityPostVariableInline) Validate() error { 2603 return validation.Errors{ 2604 "Name": validation.Validate(g.Name), 2605 "Value": validation.Validate(g.Value, 2606 validation.In(GravityPostNorth, 2607 GravityPostNorthEast, 2608 GravityPostNorthWest, 2609 GravityPostSouth, 2610 GravityPostSouthEast, 2611 GravityPostSouthWest, 2612 GravityPostCenter, 2613 GravityPostEast, 2614 GravityPostWest), 2615 ), 2616 }.Filter() 2617 } 2618 2619 // Validate validates GravityVariableInline 2620 func (g GravityVariableInline) Validate() error { 2621 return validation.Errors{ 2622 "Name": validation.Validate(g.Name), 2623 "Value": validation.Validate(g.Value, 2624 validation.In(GravityNorth, 2625 GravityNorthEast, 2626 GravityNorthWest, 2627 GravitySouth, 2628 GravitySouthEast, 2629 GravitySouthWest, 2630 GravityCenter, 2631 GravityEast, 2632 GravityWest), 2633 ), 2634 }.Filter() 2635 } 2636 2637 // Validate validates Grayscale 2638 func (g Grayscale) Validate() error { 2639 return validation.Errors{ 2640 "Transformation": validation.Validate(g.Transformation, 2641 validation.Required, 2642 validation.In(GrayscaleTransformationGrayscale), 2643 ), 2644 "Type": validation.Validate(g.Type), 2645 }.Filter() 2646 } 2647 2648 // Validate validates GrayscaleTypeVariableInline 2649 func (g GrayscaleTypeVariableInline) Validate() error { 2650 return validation.Errors{ 2651 "Name": validation.Validate(g.Name), 2652 "Value": validation.Validate(g.Value, 2653 validation.In(GrayscaleTypeRec601, 2654 GrayscaleTypeRec709, 2655 GrayscaleTypeBrightness, 2656 GrayscaleTypeLightness), 2657 ), 2658 }.Filter() 2659 } 2660 2661 // Validate validates HSL 2662 func (h HSL) Validate() error { 2663 return validation.Errors{ 2664 "Hue": validation.Validate(h.Hue), 2665 "Lightness": validation.Validate(h.Lightness), 2666 "Saturation": validation.Validate(h.Saturation), 2667 "Transformation": validation.Validate(h.Transformation, 2668 validation.Required, 2669 validation.In(HSLTransformationHSL), 2670 ), 2671 }.Filter() 2672 } 2673 2674 // Validate validates HSV 2675 func (h HSV) Validate() error { 2676 return validation.Errors{ 2677 "Hue": validation.Validate(h.Hue), 2678 "Saturation": validation.Validate(h.Saturation), 2679 "Transformation": validation.Validate(h.Transformation, 2680 validation.Required, 2681 validation.In(HSVTransformationHSV), 2682 ), 2683 "Value": validation.Validate(h.Value), 2684 }.Filter() 2685 } 2686 2687 // Validate validates IfDimension 2688 func (i IfDimension) Validate() error { 2689 return validation.Errors{ 2690 "Default": validation.Validate(i.Default), 2691 "Dimension": validation.Validate(i.Dimension), 2692 "Equal": validation.Validate(i.Equal), 2693 "GreaterThan": validation.Validate(i.GreaterThan), 2694 "LessThan": validation.Validate(i.LessThan), 2695 "Transformation": validation.Validate(i.Transformation, 2696 validation.Required, 2697 validation.In(IfDimensionTransformationIfDimension), 2698 ), 2699 "Value": validation.Validate(i.Value, 2700 validation.Required, 2701 ), 2702 }.Filter() 2703 } 2704 2705 // Validate validates IfDimensionDimensionVariableInline 2706 func (i IfDimensionDimensionVariableInline) Validate() error { 2707 return validation.Errors{ 2708 "Name": validation.Validate(i.Name), 2709 "Value": validation.Validate(i.Value, 2710 validation.In(IfDimensionDimensionWidth, IfDimensionDimensionHeight, IfDimensionDimensionBoth), 2711 ), 2712 }.Filter() 2713 } 2714 2715 // Validate validates IfDimensionPost 2716 func (i IfDimensionPost) Validate() error { 2717 return validation.Errors{ 2718 "Default": validation.Validate(i.Default), 2719 "Dimension": validation.Validate(i.Dimension), 2720 "Equal": validation.Validate(i.Equal), 2721 "GreaterThan": validation.Validate(i.GreaterThan), 2722 "LessThan": validation.Validate(i.LessThan), 2723 "Transformation": validation.Validate(i.Transformation, 2724 validation.Required, 2725 validation.In(IfDimensionPostTransformationIfDimension), 2726 ), 2727 "Value": validation.Validate(i.Value, 2728 validation.Required, 2729 ), 2730 }.Filter() 2731 } 2732 2733 // Validate validates IfDimensionPostDimensionVariableInline 2734 func (i IfDimensionPostDimensionVariableInline) Validate() error { 2735 return validation.Errors{ 2736 "Name": validation.Validate(i.Name), 2737 "Value": validation.Validate(i.Value, 2738 validation.In(IfDimensionPostDimensionWidth, IfDimensionPostDimensionHeight, IfDimensionPostDimensionBoth), 2739 ), 2740 }.Filter() 2741 } 2742 2743 // Validate validates IfOrientation 2744 func (i IfOrientation) Validate() error { 2745 return validation.Errors{ 2746 "Default": validation.Validate(i.Default), 2747 "Landscape": validation.Validate(i.Landscape), 2748 "Portrait": validation.Validate(i.Portrait), 2749 "Square": validation.Validate(i.Square), 2750 "Transformation": validation.Validate(i.Transformation, 2751 validation.Required, 2752 validation.In(IfOrientationTransformationIfOrientation), 2753 ), 2754 }.Filter() 2755 } 2756 2757 // Validate validates IfOrientationPost 2758 func (i IfOrientationPost) Validate() error { 2759 return validation.Errors{ 2760 "Default": validation.Validate(i.Default), 2761 "Landscape": validation.Validate(i.Landscape), 2762 "Portrait": validation.Validate(i.Portrait), 2763 "Square": validation.Validate(i.Square), 2764 "Transformation": validation.Validate(i.Transformation, 2765 validation.Required, 2766 validation.In(IfOrientationPostTransformationIfOrientation), 2767 ), 2768 }.Filter() 2769 } 2770 2771 // Validate validates ImQuery 2772 func (i ImQuery) Validate() error { 2773 return validation.Errors{ 2774 "AllowedTransformations": validation.Validate(i.AllowedTransformations, 2775 validation.Required, validation.Each( 2776 validation.In(ImQueryAllowedTransformationsAppend, 2777 ImQueryAllowedTransformationsAspectCrop, 2778 ImQueryAllowedTransformationsBackgroundColor, 2779 ImQueryAllowedTransformationsBlur, 2780 ImQueryAllowedTransformationsComposite, 2781 ImQueryAllowedTransformationsContrast, 2782 ImQueryAllowedTransformationsCrop, 2783 ImQueryAllowedTransformationsChromaKey, 2784 ImQueryAllowedTransformationsFaceCrop, 2785 ImQueryAllowedTransformationsFeatureCrop, 2786 ImQueryAllowedTransformationsFitAndFill, 2787 ImQueryAllowedTransformationsGoop, 2788 ImQueryAllowedTransformationsGrayscale, 2789 ImQueryAllowedTransformationsHSL, 2790 ImQueryAllowedTransformationsHSV, 2791 ImQueryAllowedTransformationsMaxColors, 2792 ImQueryAllowedTransformationsMirror, 2793 ImQueryAllowedTransformationsMonoHue, 2794 ImQueryAllowedTransformationsOpacity, 2795 ImQueryAllowedTransformationsRegionOfInterestCrop, 2796 ImQueryAllowedTransformationsRelativeCrop, 2797 ImQueryAllowedTransformationsRemoveColor, 2798 ImQueryAllowedTransformationsResize, 2799 ImQueryAllowedTransformationsRotate, 2800 ImQueryAllowedTransformationsScale, 2801 ImQueryAllowedTransformationsShear, 2802 ImQueryAllowedTransformationsTrim, 2803 ImQueryAllowedTransformationsUnsharpMask, 2804 ImQueryAllowedTransformationsIfDimension, 2805 ImQueryAllowedTransformationsIfOrientation)), 2806 ), 2807 "Query": validation.Validate(i.Query, 2808 validation.Required, 2809 ), 2810 "Transformation": validation.Validate(i.Transformation, 2811 validation.Required, 2812 validation.In(ImQueryTransformationImQuery), 2813 ), 2814 }.Filter() 2815 } 2816 2817 // Validate validates IntegerVariableInline 2818 func (i IntegerVariableInline) Validate() error { 2819 return validation.Errors{ 2820 "Name": validation.Validate(i.Name), 2821 "Value": validation.Validate(i.Value), 2822 }.Filter() 2823 } 2824 2825 // Validate validates MaxColors 2826 func (m MaxColors) Validate() error { 2827 return validation.Errors{ 2828 "Colors": validation.Validate(m.Colors, 2829 validation.Required, 2830 ), 2831 "Transformation": validation.Validate(m.Transformation, 2832 validation.Required, 2833 validation.In(MaxColorsTransformationMaxColors), 2834 ), 2835 }.Filter() 2836 } 2837 2838 // Validate validates Mirror 2839 func (m Mirror) Validate() error { 2840 return validation.Errors{ 2841 "Horizontal": validation.Validate(m.Horizontal), 2842 "Transformation": validation.Validate(m.Transformation, 2843 validation.Required, 2844 validation.In(MirrorTransformationMirror), 2845 ), 2846 "Vertical": validation.Validate(m.Vertical), 2847 }.Filter() 2848 } 2849 2850 // Validate validates MonoHue 2851 func (m MonoHue) Validate() error { 2852 return validation.Errors{ 2853 "Hue": validation.Validate(m.Hue), 2854 "Transformation": validation.Validate(m.Transformation, 2855 validation.Required, 2856 validation.In(MonoHueTransformationMonoHue), 2857 ), 2858 }.Filter() 2859 } 2860 2861 // Validate validates NumberVariableInline 2862 func (n NumberVariableInline) Validate() error { 2863 return validation.Errors{ 2864 "Name": validation.Validate(n.Name), 2865 "Value": validation.Validate(n.Value), 2866 }.Filter() 2867 } 2868 2869 // Validate validates Opacity 2870 func (o Opacity) Validate() error { 2871 return validation.Errors{ 2872 "Opacity": validation.Validate(o.Opacity, 2873 validation.Required, 2874 ), 2875 "Transformation": validation.Validate(o.Transformation, 2876 validation.Required, 2877 validation.In(OpacityTransformationOpacity), 2878 ), 2879 }.Filter() 2880 } 2881 2882 // Validate validates OutputImage 2883 func (o OutputImage) Validate() error { 2884 return validation.Errors{ 2885 "AdaptiveQuality": validation.Validate(o.AdaptiveQuality, 2886 validation.Min(1), 2887 validation.Max(100), 2888 ), 2889 "AllowedFormats": validation.Validate(o.AllowedFormats, validation.Each( 2890 validation.In(OutputImageAllowedFormatsGif, 2891 OutputImageAllowedFormatsJpeg, 2892 OutputImageAllowedFormatsPng, 2893 OutputImageAllowedFormatsWebp, 2894 OutputImageAllowedFormatsJpegxr, 2895 OutputImageAllowedFormatsJpeg2000, 2896 OutputImageAllowedFormatsAvif)), 2897 ), 2898 "ForcedFormats": validation.Validate(o.ForcedFormats, validation.Each( 2899 validation.In(OutputImageForcedFormatsGif, 2900 OutputImageForcedFormatsJpeg, 2901 OutputImageForcedFormatsPng, 2902 OutputImageForcedFormatsWebp, 2903 OutputImageForcedFormatsJpegxr, 2904 OutputImageForcedFormatsJpeg2000, 2905 OutputImageForcedFormatsAvif)), 2906 ), 2907 "PerceptualQuality": validation.Validate(o.PerceptualQuality), 2908 "PerceptualQualityFloor": validation.Validate(o.PerceptualQualityFloor, 2909 validation.Min(1), 2910 validation.Max(100), 2911 ), 2912 "Quality": validation.Validate(o.Quality), 2913 }.Filter() 2914 } 2915 2916 // Validate validates OutputImagePerceptualQualityVariableInline 2917 func (o OutputImagePerceptualQualityVariableInline) Validate() error { 2918 return validation.Errors{ 2919 "Name": validation.Validate(o.Name), 2920 "Value": validation.Validate(o.Value, 2921 validation.In(OutputImagePerceptualQualityHigh, 2922 OutputImagePerceptualQualityMediumHigh, 2923 OutputImagePerceptualQualityMedium, 2924 OutputImagePerceptualQualityMediumLow, 2925 OutputImagePerceptualQualityLow), 2926 ), 2927 }.Filter() 2928 } 2929 2930 // Validate validates PointShapeType 2931 func (p PointShapeType) Validate() error { 2932 return validation.Errors{ 2933 "X": validation.Validate(p.X, 2934 validation.Required, 2935 ), 2936 "Y": validation.Validate(p.Y, 2937 validation.Required, 2938 ), 2939 }.Filter() 2940 } 2941 2942 // Validate validates PolicyOutputImage 2943 func (p PolicyOutputImage) Validate() error { 2944 return validation.Errors{ 2945 "Breakpoints": validation.Validate(p.Breakpoints), 2946 "DateCreated": validation.Validate(p.DateCreated, 2947 validation.Required, 2948 ), 2949 "Hosts": validation.Validate(p.Hosts, validation.Each()), 2950 "ID": validation.Validate(p.ID, 2951 validation.Required, 2952 ), 2953 "Output": validation.Validate(p.Output), 2954 "PostBreakpointTransformations": validation.Validate(p.PostBreakpointTransformations), 2955 "PreviousVersion": validation.Validate(p.PreviousVersion, 2956 validation.Required, 2957 ), 2958 "RolloutInfo": validation.Validate(p.RolloutInfo, 2959 validation.Required, 2960 ), 2961 "Transformations": validation.Validate(p.Transformations), 2962 "User": validation.Validate(p.User, 2963 validation.Required, 2964 ), 2965 "Variables": validation.Validate(p.Variables, validation.Each()), 2966 "Version": validation.Validate(p.Version, 2967 validation.Required, 2968 ), 2969 "Video": validation.Validate(p.Video, 2970 validation.In(PolicyOutputImageVideoFalse), 2971 ), 2972 }.Filter() 2973 } 2974 2975 // Validate validates PolygonShapeType 2976 func (p PolygonShapeType) Validate() error { 2977 return validation.Errors{ 2978 "Points": validation.Validate(p.Points, 2979 validation.Required, validation.Each(), 2980 ), 2981 }.Filter() 2982 } 2983 2984 // Validate validates QueryVariableInline 2985 func (q QueryVariableInline) Validate() error { 2986 return validation.Errors{ 2987 "Name": validation.Validate(q.Name, 2988 validation.Required, 2989 ), 2990 }.Filter() 2991 } 2992 2993 // Validate validates RectangleShapeType 2994 func (r RectangleShapeType) Validate() error { 2995 return validation.Errors{ 2996 "Anchor": validation.Validate(r.Anchor, 2997 validation.Required, 2998 ), 2999 "Height": validation.Validate(r.Height, 3000 validation.Required, 3001 ), 3002 "Width": validation.Validate(r.Width, 3003 validation.Required, 3004 ), 3005 }.Filter() 3006 } 3007 3008 // Validate validates RegionOfInterestCrop 3009 func (r RegionOfInterestCrop) Validate() error { 3010 return validation.Errors{ 3011 "Gravity": validation.Validate(r.Gravity), 3012 "Height": validation.Validate(r.Height, 3013 validation.Required, 3014 ), 3015 "RegionOfInterest": validation.Validate(r.RegionOfInterest, 3016 validation.Required, 3017 ), 3018 "Style": validation.Validate(r.Style), 3019 "Transformation": validation.Validate(r.Transformation, 3020 validation.Required, 3021 validation.In(RegionOfInterestCropTransformationRegionOfInterestCrop), 3022 ), 3023 "Width": validation.Validate(r.Width, 3024 validation.Required, 3025 ), 3026 }.Filter() 3027 } 3028 3029 // Validate validates RegionOfInterestCropStyleVariableInline 3030 func (r RegionOfInterestCropStyleVariableInline) Validate() error { 3031 return validation.Errors{ 3032 "Name": validation.Validate(r.Name), 3033 "Value": validation.Validate(r.Value, 3034 validation.In(RegionOfInterestCropStyleCrop, RegionOfInterestCropStyleFill, RegionOfInterestCropStyleZoom), 3035 ), 3036 }.Filter() 3037 } 3038 3039 // Validate validates RelativeCrop 3040 func (r RelativeCrop) Validate() error { 3041 return validation.Errors{ 3042 "East": validation.Validate(r.East), 3043 "North": validation.Validate(r.North), 3044 "South": validation.Validate(r.South), 3045 "Transformation": validation.Validate(r.Transformation, 3046 validation.Required, 3047 validation.In(RelativeCropTransformationRelativeCrop), 3048 ), 3049 "West": validation.Validate(r.West), 3050 }.Filter() 3051 } 3052 3053 // Validate validates RemoveColor 3054 func (r RemoveColor) Validate() error { 3055 return validation.Errors{ 3056 "Color": validation.Validate(r.Color, 3057 validation.Required, 3058 ), 3059 "Feather": validation.Validate(r.Feather), 3060 "Tolerance": validation.Validate(r.Tolerance), 3061 "Transformation": validation.Validate(r.Transformation, 3062 validation.Required, 3063 validation.In(RemoveColorTransformationRemoveColor), 3064 ), 3065 }.Filter() 3066 } 3067 3068 // Validate validates Resize 3069 func (r Resize) Validate() error { 3070 return validation.Errors{ 3071 "Aspect": validation.Validate(r.Aspect), 3072 "Height": validation.Validate(r.Height), 3073 "Transformation": validation.Validate(r.Transformation, 3074 validation.Required, 3075 validation.In(ResizeTransformationResize), 3076 ), 3077 "Type": validation.Validate(r.Type), 3078 "Width": validation.Validate(r.Width), 3079 }.Filter() 3080 } 3081 3082 // Validate validates ResizeAspectVariableInline 3083 func (r ResizeAspectVariableInline) Validate() error { 3084 return validation.Errors{ 3085 "Name": validation.Validate(r.Name), 3086 "Value": validation.Validate(r.Value, 3087 validation.In(ResizeAspectFit, ResizeAspectFill, ResizeAspectIgnore), 3088 ), 3089 }.Filter() 3090 } 3091 3092 // Validate validates ResizeTypeVariableInline 3093 func (r ResizeTypeVariableInline) Validate() error { 3094 return validation.Errors{ 3095 "Name": validation.Validate(r.Name), 3096 "Value": validation.Validate(r.Value, 3097 validation.In(ResizeTypeNormal, ResizeTypeUpsize, ResizeTypeDownsize), 3098 ), 3099 }.Filter() 3100 } 3101 3102 // Validate validates RolloutInfo 3103 func (r RolloutInfo) Validate() error { 3104 return validation.Errors{ 3105 "EndTime": validation.Validate(r.EndTime, 3106 validation.Required, 3107 ), 3108 "RolloutDuration": validation.Validate(r.RolloutDuration, 3109 validation.Required, 3110 validation.Min(3600), 3111 validation.Max(604800), 3112 ), 3113 "StartTime": validation.Validate(r.StartTime, 3114 validation.Required, 3115 ), 3116 }.Filter() 3117 } 3118 3119 // Validate validates Rotate 3120 func (r Rotate) Validate() error { 3121 return validation.Errors{ 3122 "Degrees": validation.Validate(r.Degrees, 3123 validation.Required, 3124 ), 3125 "Transformation": validation.Validate(r.Transformation, 3126 validation.Required, 3127 validation.In(RotateTransformationRotate), 3128 ), 3129 }.Filter() 3130 } 3131 3132 // Validate validates Scale 3133 func (s Scale) Validate() error { 3134 return validation.Errors{ 3135 "Height": validation.Validate(s.Height, 3136 validation.Required, 3137 ), 3138 "Transformation": validation.Validate(s.Transformation, 3139 validation.Required, 3140 validation.In(ScaleTransformationScale), 3141 ), 3142 "Width": validation.Validate(s.Width, 3143 validation.Required, 3144 ), 3145 }.Filter() 3146 } 3147 3148 // Validate validates Shear 3149 func (s Shear) Validate() error { 3150 return validation.Errors{ 3151 "Transformation": validation.Validate(s.Transformation, 3152 validation.Required, 3153 validation.In(ShearTransformationShear), 3154 ), 3155 "XShear": validation.Validate(s.XShear), 3156 "YShear": validation.Validate(s.YShear), 3157 }.Filter() 3158 } 3159 3160 // Validate validates StringVariableInline 3161 func (s StringVariableInline) Validate() error { 3162 return validation.Errors{ 3163 "Name": validation.Validate(s.Name), 3164 "Value": validation.Validate(s.Value), 3165 }.Filter() 3166 } 3167 3168 // Validate validates TextImageType 3169 func (t TextImageType) Validate() error { 3170 return validation.Errors{ 3171 "Fill": validation.Validate(t.Fill), 3172 "Size": validation.Validate(t.Size), 3173 "Stroke": validation.Validate(t.Stroke), 3174 "StrokeSize": validation.Validate(t.StrokeSize), 3175 "Text": validation.Validate(t.Text, 3176 validation.Required, 3177 ), 3178 "Transformation": validation.Validate(t.Transformation), 3179 "Type": validation.Validate(t.Type, 3180 validation.Required, 3181 validation.In(TextImageTypeTypeText), 3182 ), 3183 "Typeface": validation.Validate(t.Typeface), 3184 }.Filter() 3185 } 3186 3187 // Validate validates TextImageTypePost 3188 func (t TextImageTypePost) Validate() error { 3189 return validation.Errors{ 3190 "Fill": validation.Validate(t.Fill), 3191 "Size": validation.Validate(t.Size), 3192 "Stroke": validation.Validate(t.Stroke), 3193 "StrokeSize": validation.Validate(t.StrokeSize), 3194 "Text": validation.Validate(t.Text, 3195 validation.Required, 3196 ), 3197 "Transformation": validation.Validate(t.Transformation), 3198 "Type": validation.Validate(t.Type, 3199 validation.Required, 3200 validation.In(TextImageTypePostTypeText), 3201 ), 3202 "Typeface": validation.Validate(t.Typeface), 3203 }.Filter() 3204 } 3205 3206 // Validate validates Trim 3207 func (t Trim) Validate() error { 3208 return validation.Errors{ 3209 "Fuzz": validation.Validate(t.Fuzz, 3210 validation.Max(1), 3211 ), 3212 "Padding": validation.Validate(t.Padding), 3213 "Transformation": validation.Validate(t.Transformation, 3214 validation.Required, 3215 validation.In(TrimTransformationTrim), 3216 ), 3217 }.Filter() 3218 } 3219 3220 // Validate validates URLImageType 3221 func (u URLImageType) Validate() error { 3222 return validation.Errors{ 3223 "Transformation": validation.Validate(u.Transformation), 3224 "Type": validation.Validate(u.Type, 3225 validation.In(URLImageTypeTypeURL), 3226 ), 3227 "URL": validation.Validate(u.URL, 3228 validation.Required, 3229 ), 3230 }.Filter() 3231 } 3232 3233 // Validate validates URLImageTypePost 3234 func (u URLImageTypePost) Validate() error { 3235 return validation.Errors{ 3236 "Transformation": validation.Validate(u.Transformation), 3237 "Type": validation.Validate(u.Type, 3238 validation.In(URLImageTypePostTypeURL), 3239 ), 3240 "URL": validation.Validate(u.URL, 3241 validation.Required, 3242 ), 3243 }.Filter() 3244 } 3245 3246 // Validate validates UnionShapeType 3247 func (u UnionShapeType) Validate() error { 3248 return validation.Errors{ 3249 "Shapes": validation.Validate(u.Shapes, 3250 validation.Required, validation.Each(), 3251 ), 3252 }.Filter() 3253 } 3254 3255 // Validate validates UnsharpMask 3256 func (u UnsharpMask) Validate() error { 3257 return validation.Errors{ 3258 "Gain": validation.Validate(u.Gain), 3259 "Sigma": validation.Validate(u.Sigma), 3260 "Threshold": validation.Validate(u.Threshold), 3261 "Transformation": validation.Validate(u.Transformation, 3262 validation.Required, 3263 validation.In(UnsharpMaskTransformationUnsharpMask), 3264 ), 3265 }.Filter() 3266 } 3267 3268 // Validate validates Variable 3269 func (v Variable) Validate() error { 3270 return validation.Errors{ 3271 "DefaultValue": validation.Validate(v.DefaultValue, 3272 validation.Required.When(v.Type != VariableTypeString), 3273 ), 3274 "EnumOptions": validation.Validate(v.EnumOptions, validation.Each()), 3275 "Name": validation.Validate(v.Name, 3276 validation.Required, 3277 ), 3278 "Postfix": validation.Validate(v.Postfix), 3279 "Prefix": validation.Validate(v.Prefix), 3280 "Type": validation.Validate(v.Type, 3281 validation.Required, 3282 validation.In(VariableTypeBool, 3283 VariableTypeNumber, 3284 VariableTypeURL, 3285 VariableTypeColor, 3286 VariableTypeGravity, 3287 VariableTypePlacement, 3288 VariableTypeScaleDimension, 3289 VariableTypeGrayscaleType, 3290 VariableTypeAspect, 3291 VariableTypeResizeType, 3292 VariableTypeDimension, 3293 VariableTypePerceptualQuality, 3294 VariableTypeString, 3295 VariableTypeFocus), 3296 ), 3297 }.Filter() 3298 } 3299 3300 // Validate validates VariableInline 3301 func (v VariableInline) Validate() error { 3302 return validation.Errors{ 3303 "Var": validation.Validate(v.Var, 3304 validation.Required, 3305 ), 3306 }.Filter() 3307 } 3308 3309 // Validate validates OutputVideo 3310 func (o OutputVideo) Validate() error { 3311 return validation.Errors{ 3312 "PerceptualQuality": validation.Validate(o.PerceptualQuality), 3313 "PlaceholderVideoURL": validation.Validate(o.PlaceholderVideoURL), 3314 "VideoAdaptiveQuality": validation.Validate(o.VideoAdaptiveQuality), 3315 }.Filter() 3316 } 3317 3318 // Validate validates OutputVideoPerceptualQualityVariableInline 3319 func (o OutputVideoPerceptualQualityVariableInline) Validate() error { 3320 return validation.Errors{ 3321 "Name": validation.Validate(o.Name), 3322 "Value": validation.Validate(o.Value, 3323 validation.In(OutputVideoPerceptualQualityHigh, 3324 OutputVideoPerceptualQualityMediumHigh, 3325 OutputVideoPerceptualQualityMedium, 3326 OutputVideoPerceptualQualityMediumLow, 3327 OutputVideoPerceptualQualityLow), 3328 ), 3329 }.Filter() 3330 } 3331 3332 // Validate validates OutputVideoVideoAdaptiveQualityVariableInline 3333 func (o OutputVideoVideoAdaptiveQualityVariableInline) Validate() error { 3334 return validation.Errors{ 3335 "Name": validation.Validate(o.Name), 3336 "Value": validation.Validate(o.Value, 3337 validation.In(OutputVideoVideoAdaptiveQualityHigh, 3338 OutputVideoVideoAdaptiveQualityMediumHigh, 3339 OutputVideoVideoAdaptiveQualityMedium, 3340 OutputVideoVideoAdaptiveQualityMediumLow, 3341 OutputVideoVideoAdaptiveQualityLow), 3342 ), 3343 }.Filter() 3344 } 3345 3346 // Validate validates PolicyOutputVideo 3347 func (p PolicyOutputVideo) Validate() error { 3348 return validation.Errors{ 3349 "Breakpoints": validation.Validate(p.Breakpoints), 3350 "DateCreated": validation.Validate(p.DateCreated, 3351 validation.Required, 3352 ), 3353 "Hosts": validation.Validate(p.Hosts, validation.Each()), 3354 "ID": validation.Validate(p.ID, 3355 validation.Required, 3356 ), 3357 "Output": validation.Validate(p.Output), 3358 "PreviousVersion": validation.Validate(p.PreviousVersion, 3359 validation.Required, 3360 ), 3361 "RolloutInfo": validation.Validate(p.RolloutInfo, 3362 validation.Required, 3363 ), 3364 "User": validation.Validate(p.User, 3365 validation.Required, 3366 ), 3367 "Variables": validation.Validate(p.Variables, validation.Each()), 3368 "Version": validation.Validate(p.Version, 3369 validation.Required, 3370 ), 3371 "Video": validation.Validate(p.Video, 3372 validation.In(PolicyOutputVideoVideoTrue), 3373 ), 3374 }.Filter() 3375 } 3376 3377 /*-----------------------------------------------*/ 3378 //// Variable type marshalers and unmarshalers //// 3379 /*-----------------------------------------------*/ 3380 var ( 3381 3382 // ErrUnmarshalVariableAppendGravityPriorityVariableInline represents an error while unmarshalling AppendGravityPriorityVariableInline 3383 ErrUnmarshalVariableAppendGravityPriorityVariableInline = errors.New("unmarshalling AppendGravityPriorityVariableInline") 3384 // ErrUnmarshalVariableBooleanVariableInline represents an error while unmarshalling BooleanVariableInline 3385 ErrUnmarshalVariableBooleanVariableInline = errors.New("unmarshalling BooleanVariableInline") 3386 // ErrUnmarshalVariableCompositePlacementVariableInline represents an error while unmarshalling CompositePlacementVariableInline 3387 ErrUnmarshalVariableCompositePlacementVariableInline = errors.New("unmarshalling CompositePlacementVariableInline") 3388 // ErrUnmarshalVariableCompositePostPlacementVariableInline represents an error while unmarshalling CompositePostPlacementVariableInline 3389 ErrUnmarshalVariableCompositePostPlacementVariableInline = errors.New("unmarshalling CompositePostPlacementVariableInline") 3390 // ErrUnmarshalVariableCompositePostScaleDimensionVariableInline represents an error while unmarshalling CompositePostScaleDimensionVariableInline 3391 ErrUnmarshalVariableCompositePostScaleDimensionVariableInline = errors.New("unmarshalling CompositePostScaleDimensionVariableInline") 3392 // ErrUnmarshalVariableCompositeScaleDimensionVariableInline represents an error while unmarshalling CompositeScaleDimensionVariableInline 3393 ErrUnmarshalVariableCompositeScaleDimensionVariableInline = errors.New("unmarshalling CompositeScaleDimensionVariableInline") 3394 // ErrUnmarshalVariableFaceCropAlgorithmVariableInline represents an error while unmarshalling FaceCropAlgorithmVariableInline 3395 ErrUnmarshalVariableFaceCropAlgorithmVariableInline = errors.New("unmarshalling FaceCropAlgorithmVariableInline") 3396 // ErrUnmarshalVariableFaceCropFocusVariableInline represents an error while unmarshalling FaceCropFocusVariableInline 3397 ErrUnmarshalVariableFaceCropFocusVariableInline = errors.New("unmarshalling FaceCropFocusVariableInline") 3398 // ErrUnmarshalVariableFaceCropStyleVariableInline represents an error while unmarshalling FaceCropStyleVariableInline 3399 ErrUnmarshalVariableFaceCropStyleVariableInline = errors.New("unmarshalling FaceCropStyleVariableInline") 3400 // ErrUnmarshalVariableFeatureCropStyleVariableInline represents an error while unmarshalling FeatureCropStyleVariableInline 3401 ErrUnmarshalVariableFeatureCropStyleVariableInline = errors.New("unmarshalling FeatureCropStyleVariableInline") 3402 // ErrUnmarshalVariableGravityPostVariableInline represents an error while unmarshalling GravityPostVariableInline 3403 ErrUnmarshalVariableGravityPostVariableInline = errors.New("unmarshalling GravityPostVariableInline") 3404 // ErrUnmarshalVariableGravityVariableInline represents an error while unmarshalling GravityVariableInline 3405 ErrUnmarshalVariableGravityVariableInline = errors.New("unmarshalling GravityVariableInline") 3406 // ErrUnmarshalVariableGrayscaleTypeVariableInline represents an error while unmarshalling GrayscaleTypeVariableInline 3407 ErrUnmarshalVariableGrayscaleTypeVariableInline = errors.New("unmarshalling GrayscaleTypeVariableInline") 3408 // ErrUnmarshalVariableIfDimensionDimensionVariableInline represents an error while unmarshalling IfDimensionDimensionVariableInline 3409 ErrUnmarshalVariableIfDimensionDimensionVariableInline = errors.New("unmarshalling IfDimensionDimensionVariableInline") 3410 // ErrUnmarshalVariableIfDimensionPostDimensionVariableInline represents an error while unmarshalling IfDimensionPostDimensionVariableInline 3411 ErrUnmarshalVariableIfDimensionPostDimensionVariableInline = errors.New("unmarshalling IfDimensionPostDimensionVariableInline") 3412 // ErrUnmarshalVariableIntegerVariableInline represents an error while unmarshalling IntegerVariableInline 3413 ErrUnmarshalVariableIntegerVariableInline = errors.New("unmarshalling IntegerVariableInline") 3414 // ErrUnmarshalVariableNumberVariableInline represents an error while unmarshalling NumberVariableInline 3415 ErrUnmarshalVariableNumberVariableInline = errors.New("unmarshalling NumberVariableInline") 3416 // ErrUnmarshalVariableOutputImagePerceptualQualityVariableInline represents an error while unmarshalling OutputImagePerceptualQualityVariableInline 3417 ErrUnmarshalVariableOutputImagePerceptualQualityVariableInline = errors.New("unmarshalling OutputImagePerceptualQualityVariableInline") 3418 // ErrUnmarshalVariableQueryVariableInline represents an error while unmarshalling QueryVariableInline 3419 ErrUnmarshalVariableQueryVariableInline = errors.New("unmarshalling QueryVariableInline") 3420 // ErrUnmarshalVariableRegionOfInterestCropStyleVariableInline represents an error while unmarshalling RegionOfInterestCropStyleVariableInline 3421 ErrUnmarshalVariableRegionOfInterestCropStyleVariableInline = errors.New("unmarshalling RegionOfInterestCropStyleVariableInline") 3422 // ErrUnmarshalVariableResizeAspectVariableInline represents an error while unmarshalling ResizeAspectVariableInline 3423 ErrUnmarshalVariableResizeAspectVariableInline = errors.New("unmarshalling ResizeAspectVariableInline") 3424 // ErrUnmarshalVariableResizeTypeVariableInline represents an error while unmarshalling ResizeTypeVariableInline 3425 ErrUnmarshalVariableResizeTypeVariableInline = errors.New("unmarshalling ResizeTypeVariableInline") 3426 // ErrUnmarshalVariableStringVariableInline represents an error while unmarshalling StringVariableInline 3427 ErrUnmarshalVariableStringVariableInline = errors.New("unmarshalling StringVariableInline") 3428 // ErrUnmarshalVariableOutputVideoPerceptualQualityVariableInline represents an error while unmarshalling OutputVideoPerceptualQualityVariableInline 3429 ErrUnmarshalVariableOutputVideoPerceptualQualityVariableInline = errors.New("unmarshalling OutputVideoPerceptualQualityVariableInline") 3430 // ErrUnmarshalVariableOutputVideoVideoAdaptiveQualityVariableInline represents an error while unmarshalling OutputVideoVideoAdaptiveQualityVariableInline 3431 ErrUnmarshalVariableOutputVideoVideoAdaptiveQualityVariableInline = errors.New("unmarshalling OutputVideoVideoAdaptiveQualityVariableInline") 3432 ) 3433 3434 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3435 func (a *AppendGravityPriorityVariableInline) UnmarshalJSON(in []byte) error { 3436 var err error 3437 var variable InlineVariable 3438 if err = json.Unmarshal(in, &variable); err == nil { 3439 a.Name = &variable.Var 3440 a.Value = nil 3441 return nil 3442 } 3443 var value AppendGravityPriority 3444 if err = json.Unmarshal(in, &value); err == nil { 3445 a.Name = nil 3446 a.Value = &value 3447 return nil 3448 } 3449 return fmt.Errorf("%w: %s", ErrUnmarshalVariableAppendGravityPriorityVariableInline, err) 3450 } 3451 3452 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3453 func (a *AppendGravityPriorityVariableInline) MarshalJSON() ([]byte, error) { 3454 if a.Value != nil { 3455 return json.Marshal(*a.Value) 3456 } 3457 if a.Name != nil { 3458 return json.Marshal(VariableInline{Var: *a.Name}) 3459 } 3460 return nil, nil 3461 } 3462 3463 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3464 func (b *BooleanVariableInline) UnmarshalJSON(in []byte) error { 3465 var err error 3466 var variable InlineVariable 3467 if err = json.Unmarshal(in, &variable); err == nil { 3468 b.Name = &variable.Var 3469 b.Value = nil 3470 return nil 3471 } 3472 var value bool 3473 if err = json.Unmarshal(in, &value); err == nil { 3474 b.Name = nil 3475 b.Value = &value 3476 return nil 3477 } 3478 return fmt.Errorf("%w: %s", ErrUnmarshalVariableBooleanVariableInline, err) 3479 } 3480 3481 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3482 func (b *BooleanVariableInline) MarshalJSON() ([]byte, error) { 3483 if b.Value != nil { 3484 return json.Marshal(*b.Value) 3485 } 3486 if b.Name != nil { 3487 return json.Marshal(VariableInline{Var: *b.Name}) 3488 } 3489 return nil, nil 3490 } 3491 3492 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3493 func (c *CompositePlacementVariableInline) UnmarshalJSON(in []byte) error { 3494 var err error 3495 var variable InlineVariable 3496 if err = json.Unmarshal(in, &variable); err == nil { 3497 c.Name = &variable.Var 3498 c.Value = nil 3499 return nil 3500 } 3501 var value CompositePlacement 3502 if err = json.Unmarshal(in, &value); err == nil { 3503 c.Name = nil 3504 c.Value = &value 3505 return nil 3506 } 3507 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositePlacementVariableInline, err) 3508 } 3509 3510 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3511 func (c *CompositePlacementVariableInline) MarshalJSON() ([]byte, error) { 3512 if c.Value != nil { 3513 return json.Marshal(*c.Value) 3514 } 3515 if c.Name != nil { 3516 return json.Marshal(VariableInline{Var: *c.Name}) 3517 } 3518 return nil, nil 3519 } 3520 3521 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3522 func (c *CompositePostPlacementVariableInline) UnmarshalJSON(in []byte) error { 3523 var err error 3524 var variable InlineVariable 3525 if err = json.Unmarshal(in, &variable); err == nil { 3526 c.Name = &variable.Var 3527 c.Value = nil 3528 return nil 3529 } 3530 var value CompositePostPlacement 3531 if err = json.Unmarshal(in, &value); err == nil { 3532 c.Name = nil 3533 c.Value = &value 3534 return nil 3535 } 3536 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositePostPlacementVariableInline, err) 3537 } 3538 3539 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3540 func (c *CompositePostPlacementVariableInline) MarshalJSON() ([]byte, error) { 3541 if c.Value != nil { 3542 return json.Marshal(*c.Value) 3543 } 3544 if c.Name != nil { 3545 return json.Marshal(VariableInline{Var: *c.Name}) 3546 } 3547 return nil, nil 3548 } 3549 3550 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3551 func (c *CompositePostScaleDimensionVariableInline) UnmarshalJSON(in []byte) error { 3552 var err error 3553 var variable InlineVariable 3554 if err = json.Unmarshal(in, &variable); err == nil { 3555 c.Name = &variable.Var 3556 c.Value = nil 3557 return nil 3558 } 3559 var value CompositePostScaleDimension 3560 if err = json.Unmarshal(in, &value); err == nil { 3561 c.Name = nil 3562 c.Value = &value 3563 return nil 3564 } 3565 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositePostScaleDimensionVariableInline, err) 3566 } 3567 3568 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3569 func (c *CompositePostScaleDimensionVariableInline) MarshalJSON() ([]byte, error) { 3570 if c.Value != nil { 3571 return json.Marshal(*c.Value) 3572 } 3573 if c.Name != nil { 3574 return json.Marshal(VariableInline{Var: *c.Name}) 3575 } 3576 return nil, nil 3577 } 3578 3579 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3580 func (c *CompositeScaleDimensionVariableInline) UnmarshalJSON(in []byte) error { 3581 var err error 3582 var variable InlineVariable 3583 if err = json.Unmarshal(in, &variable); err == nil { 3584 c.Name = &variable.Var 3585 c.Value = nil 3586 return nil 3587 } 3588 var value CompositeScaleDimension 3589 if err = json.Unmarshal(in, &value); err == nil { 3590 c.Name = nil 3591 c.Value = &value 3592 return nil 3593 } 3594 return fmt.Errorf("%w: %s", ErrUnmarshalVariableCompositeScaleDimensionVariableInline, err) 3595 } 3596 3597 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3598 func (c *CompositeScaleDimensionVariableInline) MarshalJSON() ([]byte, error) { 3599 if c.Value != nil { 3600 return json.Marshal(*c.Value) 3601 } 3602 if c.Name != nil { 3603 return json.Marshal(VariableInline{Var: *c.Name}) 3604 } 3605 return nil, nil 3606 } 3607 3608 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3609 func (f *FaceCropAlgorithmVariableInline) UnmarshalJSON(in []byte) error { 3610 var err error 3611 var variable InlineVariable 3612 if err = json.Unmarshal(in, &variable); err == nil { 3613 f.Name = &variable.Var 3614 f.Value = nil 3615 return nil 3616 } 3617 var value FaceCropAlgorithm 3618 if err = json.Unmarshal(in, &value); err == nil { 3619 f.Name = nil 3620 f.Value = &value 3621 return nil 3622 } 3623 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFaceCropAlgorithmVariableInline, err) 3624 } 3625 3626 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3627 func (f *FaceCropAlgorithmVariableInline) MarshalJSON() ([]byte, error) { 3628 if f.Value != nil { 3629 return json.Marshal(*f.Value) 3630 } 3631 if f.Name != nil { 3632 return json.Marshal(VariableInline{Var: *f.Name}) 3633 } 3634 return nil, nil 3635 } 3636 3637 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3638 func (f *FaceCropFocusVariableInline) UnmarshalJSON(in []byte) error { 3639 var err error 3640 var variable InlineVariable 3641 if err = json.Unmarshal(in, &variable); err == nil { 3642 f.Name = &variable.Var 3643 f.Value = nil 3644 return nil 3645 } 3646 var value FaceCropFocus 3647 if err = json.Unmarshal(in, &value); err == nil { 3648 f.Name = nil 3649 f.Value = &value 3650 return nil 3651 } 3652 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFaceCropFocusVariableInline, err) 3653 } 3654 3655 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3656 func (f *FaceCropFocusVariableInline) MarshalJSON() ([]byte, error) { 3657 if f.Value != nil { 3658 return json.Marshal(*f.Value) 3659 } 3660 if f.Name != nil { 3661 return json.Marshal(VariableInline{Var: *f.Name}) 3662 } 3663 return nil, nil 3664 } 3665 3666 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3667 func (f *FaceCropStyleVariableInline) UnmarshalJSON(in []byte) error { 3668 var err error 3669 var variable InlineVariable 3670 if err = json.Unmarshal(in, &variable); err == nil { 3671 f.Name = &variable.Var 3672 f.Value = nil 3673 return nil 3674 } 3675 var value FaceCropStyle 3676 if err = json.Unmarshal(in, &value); err == nil { 3677 f.Name = nil 3678 f.Value = &value 3679 return nil 3680 } 3681 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFaceCropStyleVariableInline, err) 3682 } 3683 3684 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3685 func (f *FaceCropStyleVariableInline) MarshalJSON() ([]byte, error) { 3686 if f.Value != nil { 3687 return json.Marshal(*f.Value) 3688 } 3689 if f.Name != nil { 3690 return json.Marshal(VariableInline{Var: *f.Name}) 3691 } 3692 return nil, nil 3693 } 3694 3695 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3696 func (f *FeatureCropStyleVariableInline) UnmarshalJSON(in []byte) error { 3697 var err error 3698 var variable InlineVariable 3699 if err = json.Unmarshal(in, &variable); err == nil { 3700 f.Name = &variable.Var 3701 f.Value = nil 3702 return nil 3703 } 3704 var value FeatureCropStyle 3705 if err = json.Unmarshal(in, &value); err == nil { 3706 f.Name = nil 3707 f.Value = &value 3708 return nil 3709 } 3710 return fmt.Errorf("%w: %s", ErrUnmarshalVariableFeatureCropStyleVariableInline, err) 3711 } 3712 3713 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3714 func (f *FeatureCropStyleVariableInline) MarshalJSON() ([]byte, error) { 3715 if f.Value != nil { 3716 return json.Marshal(*f.Value) 3717 } 3718 if f.Name != nil { 3719 return json.Marshal(VariableInline{Var: *f.Name}) 3720 } 3721 return nil, nil 3722 } 3723 3724 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3725 func (g *GravityPostVariableInline) UnmarshalJSON(in []byte) error { 3726 var err error 3727 var variable InlineVariable 3728 if err = json.Unmarshal(in, &variable); err == nil { 3729 g.Name = &variable.Var 3730 g.Value = nil 3731 return nil 3732 } 3733 var value GravityPost 3734 if err = json.Unmarshal(in, &value); err == nil { 3735 g.Name = nil 3736 g.Value = &value 3737 return nil 3738 } 3739 return fmt.Errorf("%w: %s", ErrUnmarshalVariableGravityPostVariableInline, err) 3740 } 3741 3742 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3743 func (g *GravityPostVariableInline) MarshalJSON() ([]byte, error) { 3744 if g.Value != nil { 3745 return json.Marshal(*g.Value) 3746 } 3747 if g.Name != nil { 3748 return json.Marshal(VariableInline{Var: *g.Name}) 3749 } 3750 return nil, nil 3751 } 3752 3753 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3754 func (g *GravityVariableInline) UnmarshalJSON(in []byte) error { 3755 var err error 3756 var variable InlineVariable 3757 if err = json.Unmarshal(in, &variable); err == nil { 3758 g.Name = &variable.Var 3759 g.Value = nil 3760 return nil 3761 } 3762 var value Gravity 3763 if err = json.Unmarshal(in, &value); err == nil { 3764 g.Name = nil 3765 g.Value = &value 3766 return nil 3767 } 3768 return fmt.Errorf("%w: %s", ErrUnmarshalVariableGravityVariableInline, err) 3769 } 3770 3771 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3772 func (g *GravityVariableInline) MarshalJSON() ([]byte, error) { 3773 if g.Value != nil { 3774 return json.Marshal(*g.Value) 3775 } 3776 if g.Name != nil { 3777 return json.Marshal(VariableInline{Var: *g.Name}) 3778 } 3779 return nil, nil 3780 } 3781 3782 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3783 func (g *GrayscaleTypeVariableInline) UnmarshalJSON(in []byte) error { 3784 var err error 3785 var variable InlineVariable 3786 if err = json.Unmarshal(in, &variable); err == nil { 3787 g.Name = &variable.Var 3788 g.Value = nil 3789 return nil 3790 } 3791 var value GrayscaleType 3792 if err = json.Unmarshal(in, &value); err == nil { 3793 g.Name = nil 3794 g.Value = &value 3795 return nil 3796 } 3797 return fmt.Errorf("%w: %s", ErrUnmarshalVariableGrayscaleTypeVariableInline, err) 3798 } 3799 3800 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3801 func (g *GrayscaleTypeVariableInline) MarshalJSON() ([]byte, error) { 3802 if g.Value != nil { 3803 return json.Marshal(*g.Value) 3804 } 3805 if g.Name != nil { 3806 return json.Marshal(VariableInline{Var: *g.Name}) 3807 } 3808 return nil, nil 3809 } 3810 3811 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3812 func (i *IfDimensionDimensionVariableInline) UnmarshalJSON(in []byte) error { 3813 var err error 3814 var variable InlineVariable 3815 if err = json.Unmarshal(in, &variable); err == nil { 3816 i.Name = &variable.Var 3817 i.Value = nil 3818 return nil 3819 } 3820 var value IfDimensionDimension 3821 if err = json.Unmarshal(in, &value); err == nil { 3822 i.Name = nil 3823 i.Value = &value 3824 return nil 3825 } 3826 return fmt.Errorf("%w: %s", ErrUnmarshalVariableIfDimensionDimensionVariableInline, err) 3827 } 3828 3829 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3830 func (i *IfDimensionDimensionVariableInline) MarshalJSON() ([]byte, error) { 3831 if i.Value != nil { 3832 return json.Marshal(*i.Value) 3833 } 3834 if i.Name != nil { 3835 return json.Marshal(VariableInline{Var: *i.Name}) 3836 } 3837 return nil, nil 3838 } 3839 3840 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3841 func (i *IfDimensionPostDimensionVariableInline) UnmarshalJSON(in []byte) error { 3842 var err error 3843 var variable InlineVariable 3844 if err = json.Unmarshal(in, &variable); err == nil { 3845 i.Name = &variable.Var 3846 i.Value = nil 3847 return nil 3848 } 3849 var value IfDimensionPostDimension 3850 if err = json.Unmarshal(in, &value); err == nil { 3851 i.Name = nil 3852 i.Value = &value 3853 return nil 3854 } 3855 return fmt.Errorf("%w: %s", ErrUnmarshalVariableIfDimensionPostDimensionVariableInline, err) 3856 } 3857 3858 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3859 func (i *IfDimensionPostDimensionVariableInline) MarshalJSON() ([]byte, error) { 3860 if i.Value != nil { 3861 return json.Marshal(*i.Value) 3862 } 3863 if i.Name != nil { 3864 return json.Marshal(VariableInline{Var: *i.Name}) 3865 } 3866 return nil, nil 3867 } 3868 3869 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3870 func (i *IntegerVariableInline) UnmarshalJSON(in []byte) error { 3871 var err error 3872 var variable InlineVariable 3873 if err = json.Unmarshal(in, &variable); err == nil { 3874 i.Name = &variable.Var 3875 i.Value = nil 3876 return nil 3877 } 3878 var value int 3879 if err = json.Unmarshal(in, &value); err == nil { 3880 i.Name = nil 3881 i.Value = &value 3882 return nil 3883 } 3884 return fmt.Errorf("%w: %s", ErrUnmarshalVariableIntegerVariableInline, err) 3885 } 3886 3887 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3888 func (i *IntegerVariableInline) MarshalJSON() ([]byte, error) { 3889 if i.Value != nil { 3890 return json.Marshal(*i.Value) 3891 } 3892 if i.Name != nil { 3893 return json.Marshal(VariableInline{Var: *i.Name}) 3894 } 3895 return nil, nil 3896 } 3897 3898 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3899 func (n *NumberVariableInline) UnmarshalJSON(in []byte) error { 3900 var err error 3901 var variable InlineVariable 3902 if err = json.Unmarshal(in, &variable); err == nil { 3903 n.Name = &variable.Var 3904 n.Value = nil 3905 return nil 3906 } 3907 var value float64 3908 if err = json.Unmarshal(in, &value); err == nil { 3909 n.Name = nil 3910 n.Value = &value 3911 return nil 3912 } 3913 return fmt.Errorf("%w: %s", ErrUnmarshalVariableNumberVariableInline, err) 3914 } 3915 3916 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3917 func (n *NumberVariableInline) MarshalJSON() ([]byte, error) { 3918 if n.Value != nil { 3919 return json.Marshal(*n.Value) 3920 } 3921 if n.Name != nil { 3922 return json.Marshal(VariableInline{Var: *n.Name}) 3923 } 3924 return nil, nil 3925 } 3926 3927 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3928 func (o *OutputImagePerceptualQualityVariableInline) UnmarshalJSON(in []byte) error { 3929 var err error 3930 var variable InlineVariable 3931 if err = json.Unmarshal(in, &variable); err == nil { 3932 o.Name = &variable.Var 3933 o.Value = nil 3934 return nil 3935 } 3936 var value OutputImagePerceptualQuality 3937 if err = json.Unmarshal(in, &value); err == nil { 3938 o.Name = nil 3939 o.Value = &value 3940 return nil 3941 } 3942 return fmt.Errorf("%w: %s", ErrUnmarshalVariableOutputImagePerceptualQualityVariableInline, err) 3943 } 3944 3945 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3946 func (o *OutputImagePerceptualQualityVariableInline) MarshalJSON() ([]byte, error) { 3947 if o.Value != nil { 3948 return json.Marshal(*o.Value) 3949 } 3950 if o.Name != nil { 3951 return json.Marshal(VariableInline{Var: *o.Name}) 3952 } 3953 return nil, nil 3954 } 3955 3956 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3957 func (q *QueryVariableInline) UnmarshalJSON(in []byte) error { 3958 var err error 3959 var variable InlineVariable 3960 if err = json.Unmarshal(in, &variable); err == nil { 3961 q.Name = &variable.Var 3962 return nil 3963 } 3964 return fmt.Errorf("%w: %s", ErrUnmarshalVariableQueryVariableInline, err) 3965 } 3966 3967 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3968 func (q *QueryVariableInline) MarshalJSON() ([]byte, error) { 3969 if q.Name != nil { 3970 return json.Marshal(VariableInline{Var: *q.Name}) 3971 } 3972 return nil, nil 3973 } 3974 3975 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 3976 func (r *RegionOfInterestCropStyleVariableInline) UnmarshalJSON(in []byte) error { 3977 var err error 3978 var variable InlineVariable 3979 if err = json.Unmarshal(in, &variable); err == nil { 3980 r.Name = &variable.Var 3981 r.Value = nil 3982 return nil 3983 } 3984 var value RegionOfInterestCropStyle 3985 if err = json.Unmarshal(in, &value); err == nil { 3986 r.Name = nil 3987 r.Value = &value 3988 return nil 3989 } 3990 return fmt.Errorf("%w: %s", ErrUnmarshalVariableRegionOfInterestCropStyleVariableInline, err) 3991 } 3992 3993 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 3994 func (r *RegionOfInterestCropStyleVariableInline) MarshalJSON() ([]byte, error) { 3995 if r.Value != nil { 3996 return json.Marshal(*r.Value) 3997 } 3998 if r.Name != nil { 3999 return json.Marshal(VariableInline{Var: *r.Name}) 4000 } 4001 return nil, nil 4002 } 4003 4004 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4005 func (r *ResizeAspectVariableInline) UnmarshalJSON(in []byte) error { 4006 var err error 4007 var variable InlineVariable 4008 if err = json.Unmarshal(in, &variable); err == nil { 4009 r.Name = &variable.Var 4010 r.Value = nil 4011 return nil 4012 } 4013 var value ResizeAspect 4014 if err = json.Unmarshal(in, &value); err == nil { 4015 r.Name = nil 4016 r.Value = &value 4017 return nil 4018 } 4019 return fmt.Errorf("%w: %s", ErrUnmarshalVariableResizeAspectVariableInline, err) 4020 } 4021 4022 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4023 func (r *ResizeAspectVariableInline) MarshalJSON() ([]byte, error) { 4024 if r.Value != nil { 4025 return json.Marshal(*r.Value) 4026 } 4027 if r.Name != nil { 4028 return json.Marshal(VariableInline{Var: *r.Name}) 4029 } 4030 return nil, nil 4031 } 4032 4033 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4034 func (r *ResizeTypeVariableInline) UnmarshalJSON(in []byte) error { 4035 var err error 4036 var variable InlineVariable 4037 if err = json.Unmarshal(in, &variable); err == nil { 4038 r.Name = &variable.Var 4039 r.Value = nil 4040 return nil 4041 } 4042 var value ResizeType 4043 if err = json.Unmarshal(in, &value); err == nil { 4044 r.Name = nil 4045 r.Value = &value 4046 return nil 4047 } 4048 return fmt.Errorf("%w: %s", ErrUnmarshalVariableResizeTypeVariableInline, err) 4049 } 4050 4051 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4052 func (r *ResizeTypeVariableInline) MarshalJSON() ([]byte, error) { 4053 if r.Value != nil { 4054 return json.Marshal(*r.Value) 4055 } 4056 if r.Name != nil { 4057 return json.Marshal(VariableInline{Var: *r.Name}) 4058 } 4059 return nil, nil 4060 } 4061 4062 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4063 func (s *StringVariableInline) UnmarshalJSON(in []byte) error { 4064 var err error 4065 var variable InlineVariable 4066 if err = json.Unmarshal(in, &variable); err == nil { 4067 s.Name = &variable.Var 4068 s.Value = nil 4069 return nil 4070 } 4071 var value string 4072 if err = json.Unmarshal(in, &value); err == nil { 4073 s.Name = nil 4074 s.Value = &value 4075 return nil 4076 } 4077 return fmt.Errorf("%w: %s", ErrUnmarshalVariableStringVariableInline, err) 4078 } 4079 4080 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4081 func (s *StringVariableInline) MarshalJSON() ([]byte, error) { 4082 if s.Value != nil { 4083 return json.Marshal(*s.Value) 4084 } 4085 if s.Name != nil { 4086 return json.Marshal(VariableInline{Var: *s.Name}) 4087 } 4088 return nil, nil 4089 } 4090 4091 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4092 func (o *OutputVideoPerceptualQualityVariableInline) UnmarshalJSON(in []byte) error { 4093 var err error 4094 var variable InlineVariable 4095 if err = json.Unmarshal(in, &variable); err == nil { 4096 o.Name = &variable.Var 4097 o.Value = nil 4098 return nil 4099 } 4100 var value OutputVideoPerceptualQuality 4101 if err = json.Unmarshal(in, &value); err == nil { 4102 o.Name = nil 4103 o.Value = &value 4104 return nil 4105 } 4106 return fmt.Errorf("%w: %s", ErrUnmarshalVariableOutputVideoPerceptualQualityVariableInline, err) 4107 } 4108 4109 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4110 func (o *OutputVideoPerceptualQualityVariableInline) MarshalJSON() ([]byte, error) { 4111 if o.Value != nil { 4112 return json.Marshal(*o.Value) 4113 } 4114 if o.Name != nil { 4115 return json.Marshal(VariableInline{Var: *o.Name}) 4116 } 4117 return nil, nil 4118 } 4119 4120 // UnmarshalJSON is a custom unmarshaler used to decode a variable which can be either a value or a variable object 4121 func (o *OutputVideoVideoAdaptiveQualityVariableInline) UnmarshalJSON(in []byte) error { 4122 var err error 4123 var variable InlineVariable 4124 if err = json.Unmarshal(in, &variable); err == nil { 4125 o.Name = &variable.Var 4126 o.Value = nil 4127 return nil 4128 } 4129 var value OutputVideoVideoAdaptiveQuality 4130 if err = json.Unmarshal(in, &value); err == nil { 4131 o.Name = nil 4132 o.Value = &value 4133 return nil 4134 } 4135 return fmt.Errorf("%w: %s", ErrUnmarshalVariableOutputVideoVideoAdaptiveQualityVariableInline, err) 4136 } 4137 4138 // MarshalJSON is a custom marshaler used to encode a variable which can be either a value or a variable object 4139 func (o *OutputVideoVideoAdaptiveQualityVariableInline) MarshalJSON() ([]byte, error) { 4140 if o.Value != nil { 4141 return json.Marshal(*o.Value) 4142 } 4143 if o.Name != nil { 4144 return json.Marshal(VariableInline{Var: *o.Name}) 4145 } 4146 return nil, nil 4147 } 4148 4149 /*-----------------------------------------------*/ 4150 ///////////// Image type unmarshalers ///////////// 4151 /*-----------------------------------------------*/ 4152 4153 // ImageTypeValueHandlers is a map of available image types 4154 var ImageTypeValueHandlers = map[string]func() ImageType{ 4155 "box": func() ImageType { return &BoxImageType{} }, 4156 "text": func() ImageType { return &TextImageType{} }, 4157 "url": func() ImageType { return &URLImageType{} }, 4158 "circle": func() ImageType { return &CircleImageType{} }, 4159 } 4160 4161 // ImageTypePostValueHandlers is a map of available image post types 4162 var ImageTypePostValueHandlers = map[string]func() ImageTypePost{ 4163 "box": func() ImageTypePost { return &BoxImageTypePost{} }, 4164 "text": func() ImageTypePost { return &TextImageTypePost{} }, 4165 "url": func() ImageTypePost { return &URLImageTypePost{} }, 4166 "circle": func() ImageTypePost { return &CircleImageTypePost{} }, 4167 } 4168 4169 var ( 4170 4171 // ErrUnmarshalImageTypeAppend represents an error while unmarshalling Append 4172 ErrUnmarshalImageTypeAppend = errors.New("unmarshalling Append") 4173 // ErrUnmarshalImageTypeComposite represents an error while unmarshalling Composite 4174 ErrUnmarshalImageTypeComposite = errors.New("unmarshalling Composite") 4175 ) 4176 4177 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ImageType interface 4178 func (a *Append) UnmarshalJSON(in []byte) error { 4179 data := make(map[string]interface{}) 4180 type AppendT Append 4181 err := json.Unmarshal(in, &data) 4182 if err != nil { 4183 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeAppend, err) 4184 } 4185 image, ok := data["image"] 4186 if !ok { 4187 var target AppendT 4188 err = json.Unmarshal(in, &target) 4189 if err != nil { 4190 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeAppend, err) 4191 } 4192 *a = Append(target) 4193 return nil 4194 } 4195 imageMap := image.(map[string]interface{}) 4196 imageType, ok := imageMap["type"] 4197 if !ok { 4198 _, ok := imageMap["url"] 4199 if !ok { 4200 return fmt.Errorf("%w: missing image type", ErrUnmarshalImageTypeAppend) 4201 } 4202 imageType = "URL" 4203 } 4204 typeName, ok := imageType.(string) 4205 if !ok { 4206 return fmt.Errorf("%w: 'type' field on image should be a string", ErrUnmarshalImageTypeAppend) 4207 } 4208 var target AppendT 4209 targetImage, ok := ImageTypeValueHandlers[strings.ToLower(typeName)] 4210 if !ok { 4211 return fmt.Errorf("%w: invalid image type: %s", ErrUnmarshalImageTypeAppend, imageType) 4212 } 4213 target.Image = targetImage() 4214 err = json.Unmarshal(in, &target) 4215 if err != nil { 4216 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeAppend, err) 4217 } 4218 *a = Append(target) 4219 return nil 4220 } 4221 4222 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ImageType interface 4223 func (c *Composite) UnmarshalJSON(in []byte) error { 4224 data := make(map[string]interface{}) 4225 type CompositeT Composite 4226 err := json.Unmarshal(in, &data) 4227 if err != nil { 4228 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeComposite, err) 4229 } 4230 image, ok := data["image"] 4231 if !ok { 4232 var target CompositeT 4233 err = json.Unmarshal(in, &target) 4234 if err != nil { 4235 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeComposite, err) 4236 } 4237 *c = Composite(target) 4238 return nil 4239 } 4240 imageMap := image.(map[string]interface{}) 4241 imageType, ok := imageMap["type"] 4242 if !ok { 4243 _, ok := imageMap["url"] 4244 if !ok { 4245 return fmt.Errorf("%w: missing image type", ErrUnmarshalImageTypeComposite) 4246 } 4247 imageType = "URL" 4248 } 4249 typeName, ok := imageType.(string) 4250 if !ok { 4251 return fmt.Errorf("%w: 'type' field on image should be a string", ErrUnmarshalImageTypeComposite) 4252 } 4253 var target CompositeT 4254 targetImage, ok := ImageTypeValueHandlers[strings.ToLower(typeName)] 4255 if !ok { 4256 return fmt.Errorf("%w: invalid image type: %s", ErrUnmarshalImageTypeComposite, imageType) 4257 } 4258 target.Image = targetImage() 4259 err = json.Unmarshal(in, &target) 4260 if err != nil { 4261 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeComposite, err) 4262 } 4263 *c = Composite(target) 4264 return nil 4265 } 4266 4267 var ( 4268 4269 // ErrUnmarshalImageTypeCompositePost represents an error while unmarshalling CompositePost 4270 ErrUnmarshalImageTypeCompositePost = errors.New("unmarshalling CompositePost") 4271 ) 4272 4273 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ImageType interface 4274 func (c *CompositePost) UnmarshalJSON(in []byte) error { 4275 data := make(map[string]interface{}) 4276 type CompositePostT CompositePost 4277 err := json.Unmarshal(in, &data) 4278 if err != nil { 4279 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeCompositePost, err) 4280 } 4281 image, ok := data["image"] 4282 if !ok { 4283 var target CompositePostT 4284 err = json.Unmarshal(in, &target) 4285 if err != nil { 4286 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeCompositePost, err) 4287 } 4288 *c = CompositePost(target) 4289 return nil 4290 } 4291 imageMap := image.(map[string]interface{}) 4292 imageType, ok := imageMap["type"] 4293 if !ok { 4294 _, ok := imageMap["url"] 4295 if !ok { 4296 return fmt.Errorf("%w: missing image type", ErrUnmarshalImageTypeCompositePost) 4297 } 4298 imageType = "URL" 4299 } 4300 typeName, ok := imageType.(string) 4301 if !ok { 4302 return fmt.Errorf("%w: 'type' field on image should be a string", ErrUnmarshalImageTypeCompositePost) 4303 } 4304 var target CompositePostT 4305 targetImage, ok := ImageTypePostValueHandlers[strings.ToLower(typeName)] 4306 if !ok { 4307 return fmt.Errorf("%w: invalid image type: %s", ErrUnmarshalImageTypeCompositePost, imageType) 4308 } 4309 target.Image = targetImage() 4310 err = json.Unmarshal(in, &target) 4311 if err != nil { 4312 return fmt.Errorf("%w: %s", ErrUnmarshalImageTypeCompositePost, err) 4313 } 4314 *c = CompositePost(target) 4315 return nil 4316 } 4317 4318 /*-----------------------------------------------*/ 4319 ///////////// Shape type unmarshalers ///////////// 4320 /*-----------------------------------------------*/ 4321 4322 // ShapeTypes is a map of available shape types 4323 var ShapeTypes = map[string]func() ShapeType{ 4324 "circle": func() ShapeType { return &CircleShapeType{} }, 4325 "point": func() ShapeType { return &PointShapeType{} }, 4326 "polygon": func() ShapeType { return &PolygonShapeType{} }, 4327 "rectangle": func() ShapeType { return &RectangleShapeType{} }, 4328 "union": func() ShapeType { return &UnionShapeType{} }, 4329 } 4330 4331 // ShapeTypeValueHandlers returns a ShapeType based on fields specific for a concrete ShapeType 4332 var ShapeTypeValueHandlers = func(m map[string]interface{}) ShapeType { 4333 if _, ok := m["radius"]; ok { 4334 return ShapeTypes["circle"]() 4335 } 4336 if _, ok := m["x"]; ok { 4337 return ShapeTypes["point"]() 4338 } 4339 if _, ok := m["points"]; ok { 4340 return ShapeTypes["polygon"]() 4341 } 4342 if _, ok := m["anchor"]; ok { 4343 return ShapeTypes["rectangle"]() 4344 } 4345 if _, ok := m["shapes"]; ok { 4346 return ShapeTypes["union"]() 4347 } 4348 return nil 4349 } 4350 4351 var ( 4352 4353 // ErrUnmarshalShapeTypeRegionOfInterestCrop represents an error while unmarshalling {$compositeType}} 4354 ErrUnmarshalShapeTypeRegionOfInterestCrop = errors.New("unmarshalling RegionOfInterestCrop") 4355 ) 4356 4357 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to ShapeType interface 4358 func (r *RegionOfInterestCrop) UnmarshalJSON(in []byte) error { 4359 data := make(map[string]interface{}) 4360 type RegionOfInterestCropT RegionOfInterestCrop 4361 err := json.Unmarshal(in, &data) 4362 if err != nil { 4363 return fmt.Errorf("%w: %s", ErrUnmarshalShapeTypeRegionOfInterestCrop, err) 4364 } 4365 shape, ok := data["regionOfInterest"] 4366 if !ok { 4367 var target RegionOfInterestCropT 4368 err = json.Unmarshal(in, &target) 4369 if err != nil { 4370 return fmt.Errorf("%w: %s", ErrUnmarshalShapeTypeRegionOfInterestCrop, err) 4371 } 4372 *r = RegionOfInterestCrop(target) 4373 return nil 4374 } 4375 shapeMap := shape.(map[string]interface{}) 4376 var target RegionOfInterestCropT 4377 targetShape := ShapeTypeValueHandlers(shapeMap) 4378 if targetShape == nil { 4379 return fmt.Errorf("%w: invalid shape type", ErrUnmarshalShapeTypeRegionOfInterestCrop) 4380 } 4381 target.RegionOfInterest = targetShape 4382 err = json.Unmarshal(in, &target) 4383 if err != nil { 4384 return fmt.Errorf("%w: %s", ErrUnmarshalShapeTypeRegionOfInterestCrop, err) 4385 } 4386 *r = RegionOfInterestCrop(target) 4387 return nil 4388 } 4389 4390 /*-----------------------------------------------*/ 4391 ////////// Transformation unmarshallers /////////// 4392 /*-----------------------------------------------*/ 4393 4394 var ( 4395 4396 // ErrUnmarshalTransformationBoxImageType represents an error while unmarshalling {$compositeType}} 4397 ErrUnmarshalTransformationBoxImageType = errors.New("unmarshalling BoxImageType") 4398 // ErrUnmarshalTransformationCircleImageType represents an error while unmarshalling {$compositeType}} 4399 ErrUnmarshalTransformationCircleImageType = errors.New("unmarshalling CircleImageType") 4400 // ErrUnmarshalTransformationFitAndFill represents an error while unmarshalling {$compositeType}} 4401 ErrUnmarshalTransformationFitAndFill = errors.New("unmarshalling FitAndFill") 4402 // ErrUnmarshalTransformationIfDimension represents an error while unmarshalling {$compositeType}} 4403 ErrUnmarshalTransformationIfDimension = errors.New("unmarshalling IfDimension") 4404 // ErrUnmarshalTransformationIfOrientation represents an error while unmarshalling {$compositeType}} 4405 ErrUnmarshalTransformationIfOrientation = errors.New("unmarshalling IfOrientation") 4406 // ErrUnmarshalTransformationTextImageType represents an error while unmarshalling {$compositeType}} 4407 ErrUnmarshalTransformationTextImageType = errors.New("unmarshalling TextImageType") 4408 // ErrUnmarshalTransformationURLImageType represents an error while unmarshalling {$compositeType}} 4409 ErrUnmarshalTransformationURLImageType = errors.New("unmarshalling URLImageType") 4410 ) 4411 4412 var ( 4413 4414 // ErrUnmarshalPostBreakpointTransformationBoxImageTypePost represents an error while unmarshalling {$compositeType}} 4415 ErrUnmarshalPostBreakpointTransformationBoxImageTypePost = errors.New("unmarshalling BoxImageTypePost") 4416 // ErrUnmarshalPostBreakpointTransformationCircleImageTypePost represents an error while unmarshalling {$compositeType}} 4417 ErrUnmarshalPostBreakpointTransformationCircleImageTypePost = errors.New("unmarshalling CircleImageTypePost") 4418 // ErrUnmarshalPostBreakpointTransformationIfDimensionPost represents an error while unmarshalling {$compositeType}} 4419 ErrUnmarshalPostBreakpointTransformationIfDimensionPost = errors.New("unmarshalling IfDimensionPost") 4420 // ErrUnmarshalPostBreakpointTransformationIfOrientationPost represents an error while unmarshalling {$compositeType}} 4421 ErrUnmarshalPostBreakpointTransformationIfOrientationPost = errors.New("unmarshalling IfOrientationPost") 4422 // ErrUnmarshalPostBreakpointTransformationTextImageTypePost represents an error while unmarshalling {$compositeType}} 4423 ErrUnmarshalPostBreakpointTransformationTextImageTypePost = errors.New("unmarshalling TextImageTypePost") 4424 // ErrUnmarshalPostBreakpointTransformationURLImageTypePost represents an error while unmarshalling {$compositeType}} 4425 ErrUnmarshalPostBreakpointTransformationURLImageTypePost = errors.New("unmarshalling URLImageTypePost") 4426 ) 4427 4428 // TransformationHandlers is a map of available transformations 4429 var TransformationHandlers = map[string]func() TransformationType{ 4430 "Append": func() TransformationType { return &Append{} }, 4431 "AspectCrop": func() TransformationType { return &AspectCrop{} }, 4432 "BackgroundColor": func() TransformationType { return &BackgroundColor{} }, 4433 "Blur": func() TransformationType { return &Blur{} }, 4434 "ChromaKey": func() TransformationType { return &ChromaKey{} }, 4435 "Composite": func() TransformationType { return &Composite{} }, 4436 "Compound": func() TransformationType { return &Compound{} }, 4437 "Contrast": func() TransformationType { return &Contrast{} }, 4438 "Crop": func() TransformationType { return &Crop{} }, 4439 "FaceCrop": func() TransformationType { return &FaceCrop{} }, 4440 "FeatureCrop": func() TransformationType { return &FeatureCrop{} }, 4441 "FitAndFill": func() TransformationType { return &FitAndFill{} }, 4442 "Goop": func() TransformationType { return &Goop{} }, 4443 "Grayscale": func() TransformationType { return &Grayscale{} }, 4444 "HSL": func() TransformationType { return &HSL{} }, 4445 "HSV": func() TransformationType { return &HSV{} }, 4446 "IfDimension": func() TransformationType { return &IfDimension{} }, 4447 "IfOrientation": func() TransformationType { return &IfOrientation{} }, 4448 "ImQuery": func() TransformationType { return &ImQuery{} }, 4449 "MaxColors": func() TransformationType { return &MaxColors{} }, 4450 "Mirror": func() TransformationType { return &Mirror{} }, 4451 "MonoHue": func() TransformationType { return &MonoHue{} }, 4452 "Opacity": func() TransformationType { return &Opacity{} }, 4453 "RegionOfInterestCrop": func() TransformationType { return &RegionOfInterestCrop{} }, 4454 "RelativeCrop": func() TransformationType { return &RelativeCrop{} }, 4455 "RemoveColor": func() TransformationType { return &RemoveColor{} }, 4456 "Resize": func() TransformationType { return &Resize{} }, 4457 "Rotate": func() TransformationType { return &Rotate{} }, 4458 "Scale": func() TransformationType { return &Scale{} }, 4459 "Shear": func() TransformationType { return &Shear{} }, 4460 "Trim": func() TransformationType { return &Trim{} }, 4461 "UnsharpMask": func() TransformationType { return &UnsharpMask{} }, 4462 } 4463 4464 // PostBreakpointTransformationHandlers is a map of available PostBreakpointTransformations 4465 var PostBreakpointTransformationHandlers = map[string]func() TransformationTypePost{ 4466 "BackgroundColor": func() TransformationTypePost { return &BackgroundColor{} }, 4467 "Blur": func() TransformationTypePost { return &Blur{} }, 4468 "ChromaKey": func() TransformationTypePost { return &ChromaKey{} }, 4469 "Compound": func() TransformationTypePost { return &CompoundPost{} }, 4470 "Composite": func() TransformationTypePost { return &CompositePost{} }, 4471 "Contrast": func() TransformationTypePost { return &Contrast{} }, 4472 "Goop": func() TransformationTypePost { return &Goop{} }, 4473 "Grayscale": func() TransformationTypePost { return &Grayscale{} }, 4474 "HSL": func() TransformationTypePost { return &HSL{} }, 4475 "HSV": func() TransformationTypePost { return &HSV{} }, 4476 "IfDimension": func() TransformationTypePost { return &IfDimensionPost{} }, 4477 "IfOrientation": func() TransformationTypePost { return &IfOrientationPost{} }, 4478 "MaxColors": func() TransformationTypePost { return &MaxColors{} }, 4479 "Mirror": func() TransformationTypePost { return &Mirror{} }, 4480 "MonoHue": func() TransformationTypePost { return &MonoHue{} }, 4481 "Opacity": func() TransformationTypePost { return &Opacity{} }, 4482 "RemoveColor": func() TransformationTypePost { return &RemoveColor{} }, 4483 "UnsharpMask": func() TransformationTypePost { return &UnsharpMask{} }, 4484 } 4485 4486 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4487 func (b *BoxImageType) UnmarshalJSON(in []byte) error { 4488 data := make(map[string]interface{}) 4489 type BoxImageTypeT BoxImageType 4490 err := json.Unmarshal(in, &data) 4491 if err != nil { 4492 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationBoxImageType, err) 4493 } 4494 var target BoxImageTypeT 4495 4496 transformationParam, ok := data["transformation"] 4497 if ok { 4498 transformationMap, ok := transformationParam.(map[string]interface{}) 4499 if !ok { 4500 return fmt.Errorf("%w: 'transformation' field on BoxImageType should be a map", ErrUnmarshalTransformationBoxImageType) 4501 } 4502 typeName := transformationMap["transformation"].(string) 4503 transformationTarget, ok := TransformationHandlers[typeName] 4504 if !ok { 4505 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationBoxImageType, typeName) 4506 } 4507 target.Transformation = transformationTarget() 4508 } 4509 4510 err = json.Unmarshal(in, &target) 4511 if err != nil { 4512 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationBoxImageType, err) 4513 } 4514 *b = BoxImageType(target) 4515 return nil 4516 } 4517 4518 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4519 func (c *CircleImageType) UnmarshalJSON(in []byte) error { 4520 data := make(map[string]interface{}) 4521 type CircleImageTypeT CircleImageType 4522 err := json.Unmarshal(in, &data) 4523 if err != nil { 4524 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationCircleImageType, err) 4525 } 4526 var target CircleImageTypeT 4527 4528 transformationParam, ok := data["transformation"] 4529 if ok { 4530 transformationMap, ok := transformationParam.(map[string]interface{}) 4531 if !ok { 4532 return fmt.Errorf("%w: 'transformation' field on CircleImageType should be a map", ErrUnmarshalTransformationCircleImageType) 4533 } 4534 typeName := transformationMap["transformation"].(string) 4535 transformationTarget, ok := TransformationHandlers[typeName] 4536 if !ok { 4537 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationCircleImageType, typeName) 4538 } 4539 target.Transformation = transformationTarget() 4540 } 4541 4542 err = json.Unmarshal(in, &target) 4543 if err != nil { 4544 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationCircleImageType, err) 4545 } 4546 *c = CircleImageType(target) 4547 return nil 4548 } 4549 4550 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4551 func (f *FitAndFill) UnmarshalJSON(in []byte) error { 4552 data := make(map[string]interface{}) 4553 type FitAndFillT FitAndFill 4554 err := json.Unmarshal(in, &data) 4555 if err != nil { 4556 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationFitAndFill, err) 4557 } 4558 var target FitAndFillT 4559 4560 fillTransformationParam, ok := data["fillTransformation"] 4561 if ok { 4562 fillTransformationMap, ok := fillTransformationParam.(map[string]interface{}) 4563 if !ok { 4564 return fmt.Errorf("%w: 'fillTransformation' field on FitAndFill should be a map", ErrUnmarshalTransformationFitAndFill) 4565 } 4566 typeName := fillTransformationMap["transformation"].(string) 4567 fillTransformationTarget, ok := TransformationHandlers[typeName] 4568 if !ok { 4569 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationFitAndFill, typeName) 4570 } 4571 target.FillTransformation = fillTransformationTarget() 4572 } 4573 4574 err = json.Unmarshal(in, &target) 4575 if err != nil { 4576 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationFitAndFill, err) 4577 } 4578 *f = FitAndFill(target) 4579 return nil 4580 } 4581 4582 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4583 func (i *IfDimension) UnmarshalJSON(in []byte) error { 4584 data := make(map[string]interface{}) 4585 type IfDimensionT IfDimension 4586 err := json.Unmarshal(in, &data) 4587 if err != nil { 4588 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfDimension, err) 4589 } 4590 var target IfDimensionT 4591 4592 defaultParam, ok := data["default"] 4593 if ok { 4594 defaultMap, ok := defaultParam.(map[string]interface{}) 4595 if !ok { 4596 return fmt.Errorf("%w: 'default' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4597 } 4598 typeName := defaultMap["transformation"].(string) 4599 defaultTarget, ok := TransformationHandlers[typeName] 4600 if !ok { 4601 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4602 } 4603 target.Default = defaultTarget() 4604 } 4605 4606 equalParam, ok := data["equal"] 4607 if ok { 4608 equalMap, ok := equalParam.(map[string]interface{}) 4609 if !ok { 4610 return fmt.Errorf("%w: 'equal' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4611 } 4612 typeName := equalMap["transformation"].(string) 4613 equalTarget, ok := TransformationHandlers[typeName] 4614 if !ok { 4615 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4616 } 4617 target.Equal = equalTarget() 4618 } 4619 4620 greaterThanParam, ok := data["greaterThan"] 4621 if ok { 4622 greaterThanMap, ok := greaterThanParam.(map[string]interface{}) 4623 if !ok { 4624 return fmt.Errorf("%w: 'greaterThan' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4625 } 4626 typeName := greaterThanMap["transformation"].(string) 4627 greaterThanTarget, ok := TransformationHandlers[typeName] 4628 if !ok { 4629 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4630 } 4631 target.GreaterThan = greaterThanTarget() 4632 } 4633 4634 lessThanParam, ok := data["lessThan"] 4635 if ok { 4636 lessThanMap, ok := lessThanParam.(map[string]interface{}) 4637 if !ok { 4638 return fmt.Errorf("%w: 'lessThan' field on IfDimension should be a map", ErrUnmarshalTransformationIfDimension) 4639 } 4640 typeName := lessThanMap["transformation"].(string) 4641 lessThanTarget, ok := TransformationHandlers[typeName] 4642 if !ok { 4643 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfDimension, typeName) 4644 } 4645 target.LessThan = lessThanTarget() 4646 } 4647 4648 err = json.Unmarshal(in, &target) 4649 if err != nil { 4650 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfDimension, err) 4651 } 4652 *i = IfDimension(target) 4653 return nil 4654 } 4655 4656 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4657 func (i *IfOrientation) UnmarshalJSON(in []byte) error { 4658 data := make(map[string]interface{}) 4659 type IfOrientationT IfOrientation 4660 err := json.Unmarshal(in, &data) 4661 if err != nil { 4662 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfOrientation, err) 4663 } 4664 var target IfOrientationT 4665 4666 defaultParam, ok := data["default"] 4667 if ok { 4668 defaultMap, ok := defaultParam.(map[string]interface{}) 4669 if !ok { 4670 return fmt.Errorf("%w: 'default' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4671 } 4672 typeName := defaultMap["transformation"].(string) 4673 defaultTarget, ok := TransformationHandlers[typeName] 4674 if !ok { 4675 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4676 } 4677 target.Default = defaultTarget() 4678 } 4679 4680 landscapeParam, ok := data["landscape"] 4681 if ok { 4682 landscapeMap, ok := landscapeParam.(map[string]interface{}) 4683 if !ok { 4684 return fmt.Errorf("%w: 'landscape' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4685 } 4686 typeName := landscapeMap["transformation"].(string) 4687 landscapeTarget, ok := TransformationHandlers[typeName] 4688 if !ok { 4689 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4690 } 4691 target.Landscape = landscapeTarget() 4692 } 4693 4694 portraitParam, ok := data["portrait"] 4695 if ok { 4696 portraitMap, ok := portraitParam.(map[string]interface{}) 4697 if !ok { 4698 return fmt.Errorf("%w: 'portrait' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4699 } 4700 typeName := portraitMap["transformation"].(string) 4701 portraitTarget, ok := TransformationHandlers[typeName] 4702 if !ok { 4703 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4704 } 4705 target.Portrait = portraitTarget() 4706 } 4707 4708 squareParam, ok := data["square"] 4709 if ok { 4710 squareMap, ok := squareParam.(map[string]interface{}) 4711 if !ok { 4712 return fmt.Errorf("%w: 'square' field on IfOrientation should be a map", ErrUnmarshalTransformationIfOrientation) 4713 } 4714 typeName := squareMap["transformation"].(string) 4715 squareTarget, ok := TransformationHandlers[typeName] 4716 if !ok { 4717 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationIfOrientation, typeName) 4718 } 4719 target.Square = squareTarget() 4720 } 4721 4722 err = json.Unmarshal(in, &target) 4723 if err != nil { 4724 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationIfOrientation, err) 4725 } 4726 *i = IfOrientation(target) 4727 return nil 4728 } 4729 4730 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4731 func (t *TextImageType) UnmarshalJSON(in []byte) error { 4732 data := make(map[string]interface{}) 4733 type TextImageTypeT TextImageType 4734 err := json.Unmarshal(in, &data) 4735 if err != nil { 4736 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationTextImageType, err) 4737 } 4738 var target TextImageTypeT 4739 4740 transformationParam, ok := data["transformation"] 4741 if ok { 4742 transformationMap, ok := transformationParam.(map[string]interface{}) 4743 if !ok { 4744 return fmt.Errorf("%w: 'transformation' field on TextImageType should be a map", ErrUnmarshalTransformationTextImageType) 4745 } 4746 typeName := transformationMap["transformation"].(string) 4747 transformationTarget, ok := TransformationHandlers[typeName] 4748 if !ok { 4749 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationTextImageType, typeName) 4750 } 4751 target.Transformation = transformationTarget() 4752 } 4753 4754 err = json.Unmarshal(in, &target) 4755 if err != nil { 4756 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationTextImageType, err) 4757 } 4758 *t = TextImageType(target) 4759 return nil 4760 } 4761 4762 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to Transformation interface 4763 func (u *URLImageType) UnmarshalJSON(in []byte) error { 4764 data := make(map[string]interface{}) 4765 type URLImageTypeT URLImageType 4766 err := json.Unmarshal(in, &data) 4767 if err != nil { 4768 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationURLImageType, err) 4769 } 4770 var target URLImageTypeT 4771 4772 transformationParam, ok := data["transformation"] 4773 if ok { 4774 transformationMap, ok := transformationParam.(map[string]interface{}) 4775 if !ok { 4776 return fmt.Errorf("%w: 'transformation' field on URLImageType should be a map", ErrUnmarshalTransformationURLImageType) 4777 } 4778 typeName := transformationMap["transformation"].(string) 4779 transformationTarget, ok := TransformationHandlers[typeName] 4780 if !ok { 4781 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalTransformationURLImageType, typeName) 4782 } 4783 target.Transformation = transformationTarget() 4784 } 4785 4786 err = json.Unmarshal(in, &target) 4787 if err != nil { 4788 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationURLImageType, err) 4789 } 4790 *u = URLImageType(target) 4791 return nil 4792 } 4793 4794 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4795 func (b *BoxImageTypePost) UnmarshalJSON(in []byte) error { 4796 data := make(map[string]interface{}) 4797 type BoxImageTypePostT BoxImageTypePost 4798 err := json.Unmarshal(in, &data) 4799 if err != nil { 4800 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost, err) 4801 } 4802 var target BoxImageTypePostT 4803 4804 transformationParam, ok := data["transformation"] 4805 if ok { 4806 transformationMap, ok := transformationParam.(map[string]interface{}) 4807 if !ok { 4808 return fmt.Errorf("%w: 'transformation' field on BoxImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost) 4809 } 4810 typeName := transformationMap["transformation"].(string) 4811 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 4812 if !ok { 4813 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost, typeName) 4814 } 4815 target.Transformation = transformationTarget() 4816 } 4817 4818 err = json.Unmarshal(in, &target) 4819 if err != nil { 4820 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationBoxImageTypePost, err) 4821 } 4822 *b = BoxImageTypePost(target) 4823 return nil 4824 } 4825 4826 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4827 func (c *CircleImageTypePost) UnmarshalJSON(in []byte) error { 4828 data := make(map[string]interface{}) 4829 type CircleImageTypePostT CircleImageTypePost 4830 err := json.Unmarshal(in, &data) 4831 if err != nil { 4832 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost, err) 4833 } 4834 var target CircleImageTypePostT 4835 4836 transformationParam, ok := data["transformation"] 4837 if ok { 4838 transformationMap, ok := transformationParam.(map[string]interface{}) 4839 if !ok { 4840 return fmt.Errorf("%w: 'transformation' field on CircleImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost) 4841 } 4842 typeName := transformationMap["transformation"].(string) 4843 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 4844 if !ok { 4845 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost, typeName) 4846 } 4847 target.Transformation = transformationTarget() 4848 } 4849 4850 err = json.Unmarshal(in, &target) 4851 if err != nil { 4852 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationCircleImageTypePost, err) 4853 } 4854 *c = CircleImageTypePost(target) 4855 return nil 4856 } 4857 4858 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4859 func (i *IfDimensionPost) UnmarshalJSON(in []byte) error { 4860 data := make(map[string]interface{}) 4861 type IfDimensionPostT IfDimensionPost 4862 err := json.Unmarshal(in, &data) 4863 if err != nil { 4864 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, err) 4865 } 4866 var target IfDimensionPostT 4867 4868 defaultParam, ok := data["default"] 4869 if ok { 4870 defaultMap, ok := defaultParam.(map[string]interface{}) 4871 if !ok { 4872 return fmt.Errorf("%w: 'default' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 4873 } 4874 typeName := defaultMap["transformation"].(string) 4875 defaultTarget, ok := PostBreakpointTransformationHandlers[typeName] 4876 if !ok { 4877 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 4878 } 4879 target.Default = defaultTarget() 4880 } 4881 4882 equalParam, ok := data["equal"] 4883 if ok { 4884 equalMap, ok := equalParam.(map[string]interface{}) 4885 if !ok { 4886 return fmt.Errorf("%w: 'equal' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 4887 } 4888 typeName := equalMap["transformation"].(string) 4889 equalTarget, ok := PostBreakpointTransformationHandlers[typeName] 4890 if !ok { 4891 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 4892 } 4893 target.Equal = equalTarget() 4894 } 4895 4896 greaterThanParam, ok := data["greaterThan"] 4897 if ok { 4898 greaterThanMap, ok := greaterThanParam.(map[string]interface{}) 4899 if !ok { 4900 return fmt.Errorf("%w: 'greaterThan' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 4901 } 4902 typeName := greaterThanMap["transformation"].(string) 4903 greaterThanTarget, ok := PostBreakpointTransformationHandlers[typeName] 4904 if !ok { 4905 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 4906 } 4907 target.GreaterThan = greaterThanTarget() 4908 } 4909 4910 lessThanParam, ok := data["lessThan"] 4911 if ok { 4912 lessThanMap, ok := lessThanParam.(map[string]interface{}) 4913 if !ok { 4914 return fmt.Errorf("%w: 'lessThan' field on IfDimensionPost should be a map", ErrUnmarshalPostBreakpointTransformationIfDimensionPost) 4915 } 4916 typeName := lessThanMap["transformation"].(string) 4917 lessThanTarget, ok := PostBreakpointTransformationHandlers[typeName] 4918 if !ok { 4919 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, typeName) 4920 } 4921 target.LessThan = lessThanTarget() 4922 } 4923 4924 err = json.Unmarshal(in, &target) 4925 if err != nil { 4926 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfDimensionPost, err) 4927 } 4928 *i = IfDimensionPost(target) 4929 return nil 4930 } 4931 4932 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 4933 func (i *IfOrientationPost) UnmarshalJSON(in []byte) error { 4934 data := make(map[string]interface{}) 4935 type IfOrientationPostT IfOrientationPost 4936 err := json.Unmarshal(in, &data) 4937 if err != nil { 4938 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, err) 4939 } 4940 var target IfOrientationPostT 4941 4942 defaultParam, ok := data["default"] 4943 if ok { 4944 defaultMap, ok := defaultParam.(map[string]interface{}) 4945 if !ok { 4946 return fmt.Errorf("%w: 'default' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 4947 } 4948 typeName := defaultMap["transformation"].(string) 4949 defaultTarget, ok := PostBreakpointTransformationHandlers[typeName] 4950 if !ok { 4951 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 4952 } 4953 target.Default = defaultTarget() 4954 } 4955 4956 landscapeParam, ok := data["landscape"] 4957 if ok { 4958 landscapeMap, ok := landscapeParam.(map[string]interface{}) 4959 if !ok { 4960 return fmt.Errorf("%w: 'landscape' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 4961 } 4962 typeName := landscapeMap["transformation"].(string) 4963 landscapeTarget, ok := PostBreakpointTransformationHandlers[typeName] 4964 if !ok { 4965 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 4966 } 4967 target.Landscape = landscapeTarget() 4968 } 4969 4970 portraitParam, ok := data["portrait"] 4971 if ok { 4972 portraitMap, ok := portraitParam.(map[string]interface{}) 4973 if !ok { 4974 return fmt.Errorf("%w: 'portrait' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 4975 } 4976 typeName := portraitMap["transformation"].(string) 4977 portraitTarget, ok := PostBreakpointTransformationHandlers[typeName] 4978 if !ok { 4979 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 4980 } 4981 target.Portrait = portraitTarget() 4982 } 4983 4984 squareParam, ok := data["square"] 4985 if ok { 4986 squareMap, ok := squareParam.(map[string]interface{}) 4987 if !ok { 4988 return fmt.Errorf("%w: 'square' field on IfOrientationPost should be a map", ErrUnmarshalPostBreakpointTransformationIfOrientationPost) 4989 } 4990 typeName := squareMap["transformation"].(string) 4991 squareTarget, ok := PostBreakpointTransformationHandlers[typeName] 4992 if !ok { 4993 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, typeName) 4994 } 4995 target.Square = squareTarget() 4996 } 4997 4998 err = json.Unmarshal(in, &target) 4999 if err != nil { 5000 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationIfOrientationPost, err) 5001 } 5002 *i = IfOrientationPost(target) 5003 return nil 5004 } 5005 5006 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 5007 func (t *TextImageTypePost) UnmarshalJSON(in []byte) error { 5008 data := make(map[string]interface{}) 5009 type TextImageTypePostT TextImageTypePost 5010 err := json.Unmarshal(in, &data) 5011 if err != nil { 5012 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationTextImageTypePost, err) 5013 } 5014 var target TextImageTypePostT 5015 5016 transformationParam, ok := data["transformation"] 5017 if ok { 5018 transformationMap, ok := transformationParam.(map[string]interface{}) 5019 if !ok { 5020 return fmt.Errorf("%w: 'transformation' field on TextImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationTextImageTypePost) 5021 } 5022 typeName := transformationMap["transformation"].(string) 5023 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 5024 if !ok { 5025 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationTextImageTypePost, typeName) 5026 } 5027 target.Transformation = transformationTarget() 5028 } 5029 5030 err = json.Unmarshal(in, &target) 5031 if err != nil { 5032 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationTextImageTypePost, err) 5033 } 5034 *t = TextImageTypePost(target) 5035 return nil 5036 } 5037 5038 // UnmarshalJSON is a custom unmarshaler used to decode a type containing a reference to PostBreakpointTransformation interface 5039 func (u *URLImageTypePost) UnmarshalJSON(in []byte) error { 5040 data := make(map[string]interface{}) 5041 type URLImageTypePostT URLImageTypePost 5042 err := json.Unmarshal(in, &data) 5043 if err != nil { 5044 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationURLImageTypePost, err) 5045 } 5046 var target URLImageTypePostT 5047 5048 transformationParam, ok := data["transformation"] 5049 if ok { 5050 transformationMap, ok := transformationParam.(map[string]interface{}) 5051 if !ok { 5052 return fmt.Errorf("%w: 'transformation' field on URLImageTypePost should be a map", ErrUnmarshalPostBreakpointTransformationURLImageTypePost) 5053 } 5054 typeName := transformationMap["transformation"].(string) 5055 transformationTarget, ok := PostBreakpointTransformationHandlers[typeName] 5056 if !ok { 5057 return fmt.Errorf("%w: invalid transformation type: %s", ErrUnmarshalPostBreakpointTransformationURLImageTypePost, typeName) 5058 } 5059 target.Transformation = transformationTarget() 5060 } 5061 5062 err = json.Unmarshal(in, &target) 5063 if err != nil { 5064 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationURLImageTypePost, err) 5065 } 5066 *u = URLImageTypePost(target) 5067 return nil 5068 } 5069 5070 // ErrUnmarshalTransformationList represents an error while unmarshalling transformation list 5071 var ErrUnmarshalTransformationList = errors.New("unmarshalling transformation list") 5072 5073 // ErrUnmarshalPostBreakpointTransformationList represents an error while unmarshalling post breakpoint transformation list 5074 var ErrUnmarshalPostBreakpointTransformationList = errors.New("unmarshalling post breakpoint transformation list") 5075 5076 // UnmarshalJSON is a custom unmarshaler used to decode a slice of Transformation interfaces 5077 func (t *Transformations) UnmarshalJSON(in []byte) error { 5078 data := make([]map[string]interface{}, 0) 5079 if err := json.Unmarshal(in, &data); err != nil { 5080 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationList, err) 5081 } 5082 for _, transformation := range data { 5083 transformationType, ok := transformation["transformation"] 5084 if !ok { 5085 return fmt.Errorf("%w: transformation should contain 'transformation' field", ErrUnmarshalTransformationList) 5086 } 5087 transformationTypeName, ok := transformationType.(string) 5088 if !ok { 5089 return fmt.Errorf("%w: 'transformation' field on transformation entry should be a string", ErrUnmarshalTransformationList) 5090 } 5091 5092 bytes, err := json.Marshal(transformation) 5093 if err != nil { 5094 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationList, err) 5095 } 5096 5097 indicatedTransformationType, ok := TransformationHandlers[transformationTypeName] 5098 if !ok { 5099 return fmt.Errorf("%w: unsupported transformation type: %s", ErrUnmarshalTransformationList, transformationTypeName) 5100 } 5101 ipt := indicatedTransformationType() 5102 err = json.Unmarshal(bytes, ipt) 5103 if err != nil { 5104 return fmt.Errorf("%w: %s", ErrUnmarshalTransformationList, err) 5105 } 5106 *t = append(*t, ipt) 5107 } 5108 return nil 5109 } 5110 5111 // UnmarshalJSON is a custom unmarshaler used to decode a slice of PostBreakpointTransformation interfaces 5112 func (t *PostBreakpointTransformations) UnmarshalJSON(in []byte) error { 5113 data := make([]map[string]interface{}, 0) 5114 if err := json.Unmarshal(in, &data); err != nil { 5115 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationList, err) 5116 } 5117 for _, transformation := range data { 5118 transformationType, ok := transformation["transformation"] 5119 if !ok { 5120 return fmt.Errorf("%w: transformation should contain 'transformation' field", ErrUnmarshalPostBreakpointTransformationList) 5121 } 5122 transformationTypeName, ok := transformationType.(string) 5123 if !ok { 5124 return fmt.Errorf("%w: 'transformation' field on transformation entry should be a string", ErrUnmarshalPostBreakpointTransformationList) 5125 } 5126 5127 bytes, err := json.Marshal(transformation) 5128 if err != nil { 5129 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationList, err) 5130 } 5131 5132 indicatedTransformationType, ok := PostBreakpointTransformationHandlers[transformationTypeName] 5133 if !ok { 5134 return fmt.Errorf("%w: unsupported transformation type: %s", ErrUnmarshalPostBreakpointTransformationList, transformationTypeName) 5135 } 5136 ipt := indicatedTransformationType() 5137 err = json.Unmarshal(bytes, ipt) 5138 if err != nil { 5139 return fmt.Errorf("%w: %s", ErrUnmarshalPostBreakpointTransformationList, err) 5140 } 5141 *t = append(*t, ipt) 5142 } 5143 return nil 5144 }