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