github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/v1_build_request_recipe.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package headchef_models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "strconv" 10 11 strfmt "github.com/go-openapi/strfmt" 12 13 "github.com/go-openapi/errors" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // V1BuildRequestRecipe Recipe 19 // 20 // A recipe contains all required information (ingredient versions, platform, build options, etc.) to build a project for a single platform. 21 // swagger:model v1BuildRequestRecipe 22 type V1BuildRequestRecipe struct { 23 24 // Camel-specific flags for controlling the build. 25 CamelFlags []string `json:"camel_flags"` 26 27 // Indicates whether this recipe came from the recipe store or not 28 // Required: true 29 FromRecipeStore *bool `json:"from_recipe_store"` 30 31 // image 32 // Required: true 33 Image *V1BuildRequestRecipeImage `json:"image"` 34 35 // If all of the resolved ingredients resolved to indemnified versions, then this will be true. 36 IsIndemnified *bool `json:"is_indemnified,omitempty"` 37 38 // The timestamp of the order that produced this recipe. This field is for internal use only, and may be removed in the future. 39 // Required: true 40 // Format: date-time 41 OrderTimestamp *strfmt.DateTime `json:"order_timestamp"` 42 43 // platform 44 // Required: true 45 Platform *V1BuildRequestRecipePlatform `json:"platform"` 46 47 // This recipe's ID. Identical recipes will have the same ID. 48 // Required: true 49 // Format: uuid 50 RecipeID *strfmt.UUID `json:"recipe_id"` 51 52 // If the recipe came from the recipe store, this will contain the recipe's timestamp. Otherwise this field will be omitted 53 // Format: date-time 54 RecipeStoreTimestamp *strfmt.DateTime `json:"recipe_store_timestamp,omitempty"` 55 56 // The resolved ingredients that comprise this recipe. 57 // Required: true 58 // Min Items: 1 59 // Unique: true 60 ResolvedIngredients []*V1BuildRequestRecipeResolvedIngredientsItems `json:"resolved_ingredients"` 61 62 // The version of the solver that was used to create this recipe 63 // Required: true 64 SolverVersion *int64 `json:"solver_version"` 65 } 66 67 // Validate validates this v1 build request recipe 68 func (m *V1BuildRequestRecipe) Validate(formats strfmt.Registry) error { 69 var res []error 70 71 if err := m.validateFromRecipeStore(formats); err != nil { 72 res = append(res, err) 73 } 74 75 if err := m.validateImage(formats); err != nil { 76 res = append(res, err) 77 } 78 79 if err := m.validateOrderTimestamp(formats); err != nil { 80 res = append(res, err) 81 } 82 83 if err := m.validatePlatform(formats); err != nil { 84 res = append(res, err) 85 } 86 87 if err := m.validateRecipeID(formats); err != nil { 88 res = append(res, err) 89 } 90 91 if err := m.validateRecipeStoreTimestamp(formats); err != nil { 92 res = append(res, err) 93 } 94 95 if err := m.validateResolvedIngredients(formats); err != nil { 96 res = append(res, err) 97 } 98 99 if err := m.validateSolverVersion(formats); err != nil { 100 res = append(res, err) 101 } 102 103 if len(res) > 0 { 104 return errors.CompositeValidationError(res...) 105 } 106 return nil 107 } 108 109 func (m *V1BuildRequestRecipe) validateFromRecipeStore(formats strfmt.Registry) error { 110 111 if err := validate.Required("from_recipe_store", "body", m.FromRecipeStore); err != nil { 112 return err 113 } 114 115 return nil 116 } 117 118 func (m *V1BuildRequestRecipe) validateImage(formats strfmt.Registry) error { 119 120 if err := validate.Required("image", "body", m.Image); err != nil { 121 return err 122 } 123 124 if m.Image != nil { 125 if err := m.Image.Validate(formats); err != nil { 126 if ve, ok := err.(*errors.Validation); ok { 127 return ve.ValidateName("image") 128 } 129 return err 130 } 131 } 132 133 return nil 134 } 135 136 func (m *V1BuildRequestRecipe) validateOrderTimestamp(formats strfmt.Registry) error { 137 138 if err := validate.Required("order_timestamp", "body", m.OrderTimestamp); err != nil { 139 return err 140 } 141 142 if err := validate.FormatOf("order_timestamp", "body", "date-time", m.OrderTimestamp.String(), formats); err != nil { 143 return err 144 } 145 146 return nil 147 } 148 149 func (m *V1BuildRequestRecipe) validatePlatform(formats strfmt.Registry) error { 150 151 if err := validate.Required("platform", "body", m.Platform); err != nil { 152 return err 153 } 154 155 if m.Platform != nil { 156 if err := m.Platform.Validate(formats); err != nil { 157 if ve, ok := err.(*errors.Validation); ok { 158 return ve.ValidateName("platform") 159 } 160 return err 161 } 162 } 163 164 return nil 165 } 166 167 func (m *V1BuildRequestRecipe) validateRecipeID(formats strfmt.Registry) error { 168 169 if err := validate.Required("recipe_id", "body", m.RecipeID); err != nil { 170 return err 171 } 172 173 if err := validate.FormatOf("recipe_id", "body", "uuid", m.RecipeID.String(), formats); err != nil { 174 return err 175 } 176 177 return nil 178 } 179 180 func (m *V1BuildRequestRecipe) validateRecipeStoreTimestamp(formats strfmt.Registry) error { 181 182 if swag.IsZero(m.RecipeStoreTimestamp) { // not required 183 return nil 184 } 185 186 if err := validate.FormatOf("recipe_store_timestamp", "body", "date-time", m.RecipeStoreTimestamp.String(), formats); err != nil { 187 return err 188 } 189 190 return nil 191 } 192 193 func (m *V1BuildRequestRecipe) validateResolvedIngredients(formats strfmt.Registry) error { 194 195 if err := validate.Required("resolved_ingredients", "body", m.ResolvedIngredients); err != nil { 196 return err 197 } 198 199 iResolvedIngredientsSize := int64(len(m.ResolvedIngredients)) 200 201 if err := validate.MinItems("resolved_ingredients", "body", iResolvedIngredientsSize, 1); err != nil { 202 return err 203 } 204 205 if err := validate.UniqueItems("resolved_ingredients", "body", m.ResolvedIngredients); err != nil { 206 return err 207 } 208 209 for i := 0; i < len(m.ResolvedIngredients); i++ { 210 if swag.IsZero(m.ResolvedIngredients[i]) { // not required 211 continue 212 } 213 214 if m.ResolvedIngredients[i] != nil { 215 if err := m.ResolvedIngredients[i].Validate(formats); err != nil { 216 if ve, ok := err.(*errors.Validation); ok { 217 return ve.ValidateName("resolved_ingredients" + "." + strconv.Itoa(i)) 218 } 219 return err 220 } 221 } 222 223 } 224 225 return nil 226 } 227 228 func (m *V1BuildRequestRecipe) validateSolverVersion(formats strfmt.Registry) error { 229 230 if err := validate.Required("solver_version", "body", m.SolverVersion); err != nil { 231 return err 232 } 233 234 return nil 235 } 236 237 // MarshalBinary interface implementation 238 func (m *V1BuildRequestRecipe) MarshalBinary() ([]byte, error) { 239 if m == nil { 240 return nil, nil 241 } 242 return swag.WriteJSON(m) 243 } 244 245 // UnmarshalBinary interface implementation 246 func (m *V1BuildRequestRecipe) UnmarshalBinary(b []byte) error { 247 var res V1BuildRequestRecipe 248 if err := swag.ReadJSON(b, &res); err != nil { 249 return err 250 } 251 *m = res 252 return nil 253 }