github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/order.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package inventory_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 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // Order Order 19 // 20 // An order to create recipes for a set of requirements, for one or more platforms. 21 // 22 // swagger:model order 23 type Order struct { 24 25 // Additional information about the request that may be logged for debugging 26 Annotations interface{} `json:"annotations,omitempty"` 27 28 // The builds flags to include in this order and their values. 29 BuildFlags []*OrderBuildFlag `json:"build_flags"` 30 31 // Camel-specific flags for controlling the build. 32 CamelFlags []string `json:"camel_flags"` 33 34 // Order UUID, supplied by client to be copied to all resulting recipes 35 // Required: true 36 // Format: uuid 37 OrderID *strfmt.UUID `json:"order_id"` 38 39 // List of platform IDs for the order 40 // Required: true 41 // Unique: true 42 Platforms []strfmt.UUID `json:"platforms"` 43 44 // The list of required features needed to satisfy this order 45 // Required: true 46 // Min Items: 1 47 Requirements []*OrderRequirement `json:"requirements"` 48 49 // The version of the solver to use to solve this order. If not specified, the solver version will be selected automatically. 50 // Maximum: 2 51 // Minimum: 0 52 SolverVersion *int64 `json:"solver_version,omitempty"` 53 54 // The date and time that the order was originally submitted 55 // Required: true 56 // Format: date-time 57 Timestamp *strfmt.DateTime `json:"timestamp"` 58 } 59 60 // Validate validates this order 61 func (m *Order) Validate(formats strfmt.Registry) error { 62 var res []error 63 64 if err := m.validateBuildFlags(formats); err != nil { 65 res = append(res, err) 66 } 67 68 if err := m.validateOrderID(formats); err != nil { 69 res = append(res, err) 70 } 71 72 if err := m.validatePlatforms(formats); err != nil { 73 res = append(res, err) 74 } 75 76 if err := m.validateRequirements(formats); err != nil { 77 res = append(res, err) 78 } 79 80 if err := m.validateSolverVersion(formats); err != nil { 81 res = append(res, err) 82 } 83 84 if err := m.validateTimestamp(formats); err != nil { 85 res = append(res, err) 86 } 87 88 if len(res) > 0 { 89 return errors.CompositeValidationError(res...) 90 } 91 return nil 92 } 93 94 func (m *Order) validateBuildFlags(formats strfmt.Registry) error { 95 if swag.IsZero(m.BuildFlags) { // not required 96 return nil 97 } 98 99 for i := 0; i < len(m.BuildFlags); i++ { 100 if swag.IsZero(m.BuildFlags[i]) { // not required 101 continue 102 } 103 104 if m.BuildFlags[i] != nil { 105 if err := m.BuildFlags[i].Validate(formats); err != nil { 106 if ve, ok := err.(*errors.Validation); ok { 107 return ve.ValidateName("build_flags" + "." + strconv.Itoa(i)) 108 } 109 return err 110 } 111 } 112 113 } 114 115 return nil 116 } 117 118 func (m *Order) validateOrderID(formats strfmt.Registry) error { 119 120 if err := validate.Required("order_id", "body", m.OrderID); err != nil { 121 return err 122 } 123 124 if err := validate.FormatOf("order_id", "body", "uuid", m.OrderID.String(), formats); err != nil { 125 return err 126 } 127 128 return nil 129 } 130 131 func (m *Order) validatePlatforms(formats strfmt.Registry) error { 132 133 if err := validate.Required("platforms", "body", m.Platforms); err != nil { 134 return err 135 } 136 137 if err := validate.UniqueItems("platforms", "body", m.Platforms); err != nil { 138 return err 139 } 140 141 for i := 0; i < len(m.Platforms); i++ { 142 143 if err := validate.FormatOf("platforms"+"."+strconv.Itoa(i), "body", "uuid", m.Platforms[i].String(), formats); err != nil { 144 return err 145 } 146 147 } 148 149 return nil 150 } 151 152 func (m *Order) validateRequirements(formats strfmt.Registry) error { 153 154 if err := validate.Required("requirements", "body", m.Requirements); err != nil { 155 return err 156 } 157 158 iRequirementsSize := int64(len(m.Requirements)) 159 160 if err := validate.MinItems("requirements", "body", iRequirementsSize, 1); err != nil { 161 return err 162 } 163 164 for i := 0; i < len(m.Requirements); i++ { 165 if swag.IsZero(m.Requirements[i]) { // not required 166 continue 167 } 168 169 if m.Requirements[i] != nil { 170 if err := m.Requirements[i].Validate(formats); err != nil { 171 if ve, ok := err.(*errors.Validation); ok { 172 return ve.ValidateName("requirements" + "." + strconv.Itoa(i)) 173 } 174 return err 175 } 176 } 177 178 } 179 180 return nil 181 } 182 183 func (m *Order) validateSolverVersion(formats strfmt.Registry) error { 184 if swag.IsZero(m.SolverVersion) { // not required 185 return nil 186 } 187 188 if err := validate.MinimumInt("solver_version", "body", *m.SolverVersion, 0, false); err != nil { 189 return err 190 } 191 192 if err := validate.MaximumInt("solver_version", "body", *m.SolverVersion, 2, false); err != nil { 193 return err 194 } 195 196 return nil 197 } 198 199 func (m *Order) validateTimestamp(formats strfmt.Registry) error { 200 201 if err := validate.Required("timestamp", "body", m.Timestamp); err != nil { 202 return err 203 } 204 205 if err := validate.FormatOf("timestamp", "body", "date-time", m.Timestamp.String(), formats); err != nil { 206 return err 207 } 208 209 return nil 210 } 211 212 // ContextValidate validate this order based on the context it is used 213 func (m *Order) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 214 var res []error 215 216 if err := m.contextValidateBuildFlags(ctx, formats); err != nil { 217 res = append(res, err) 218 } 219 220 if err := m.contextValidateRequirements(ctx, formats); err != nil { 221 res = append(res, err) 222 } 223 224 if len(res) > 0 { 225 return errors.CompositeValidationError(res...) 226 } 227 return nil 228 } 229 230 func (m *Order) contextValidateBuildFlags(ctx context.Context, formats strfmt.Registry) error { 231 232 for i := 0; i < len(m.BuildFlags); i++ { 233 234 if m.BuildFlags[i] != nil { 235 if err := m.BuildFlags[i].ContextValidate(ctx, formats); err != nil { 236 if ve, ok := err.(*errors.Validation); ok { 237 return ve.ValidateName("build_flags" + "." + strconv.Itoa(i)) 238 } 239 return err 240 } 241 } 242 243 } 244 245 return nil 246 } 247 248 func (m *Order) contextValidateRequirements(ctx context.Context, formats strfmt.Registry) error { 249 250 for i := 0; i < len(m.Requirements); i++ { 251 252 if m.Requirements[i] != nil { 253 if err := m.Requirements[i].ContextValidate(ctx, formats); err != nil { 254 if ve, ok := err.(*errors.Validation); ok { 255 return ve.ValidateName("requirements" + "." + strconv.Itoa(i)) 256 } 257 return err 258 } 259 } 260 261 } 262 263 return nil 264 } 265 266 // MarshalBinary interface implementation 267 func (m *Order) MarshalBinary() ([]byte, error) { 268 if m == nil { 269 return nil, nil 270 } 271 return swag.WriteJSON(m) 272 } 273 274 // UnmarshalBinary interface implementation 275 func (m *Order) UnmarshalBinary(b []byte) error { 276 var res Order 277 if err := swag.ReadJSON(b, &res); err != nil { 278 return err 279 } 280 *m = res 281 return nil 282 }