github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/recipe_response.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 // RecipeResponse Recipe Response 19 // 20 // The response to an order. It is a list of recipes satisfying the order. 21 // 22 // swagger:model recipeResponse 23 type RecipeResponse struct { 24 25 // UUID of the order for which this is a response. 26 // Required: true 27 // Format: uuid 28 OrderID *strfmt.UUID `json:"order_id"` 29 30 // List of resolved recipes by platform for a given order 31 // Required: true 32 // Min Items: 1 33 Recipes []*Recipe `json:"recipes"` 34 } 35 36 // Validate validates this recipe response 37 func (m *RecipeResponse) Validate(formats strfmt.Registry) error { 38 var res []error 39 40 if err := m.validateOrderID(formats); err != nil { 41 res = append(res, err) 42 } 43 44 if err := m.validateRecipes(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if len(res) > 0 { 49 return errors.CompositeValidationError(res...) 50 } 51 return nil 52 } 53 54 func (m *RecipeResponse) validateOrderID(formats strfmt.Registry) error { 55 56 if err := validate.Required("order_id", "body", m.OrderID); err != nil { 57 return err 58 } 59 60 if err := validate.FormatOf("order_id", "body", "uuid", m.OrderID.String(), formats); err != nil { 61 return err 62 } 63 64 return nil 65 } 66 67 func (m *RecipeResponse) validateRecipes(formats strfmt.Registry) error { 68 69 if err := validate.Required("recipes", "body", m.Recipes); err != nil { 70 return err 71 } 72 73 iRecipesSize := int64(len(m.Recipes)) 74 75 if err := validate.MinItems("recipes", "body", iRecipesSize, 1); err != nil { 76 return err 77 } 78 79 for i := 0; i < len(m.Recipes); i++ { 80 if swag.IsZero(m.Recipes[i]) { // not required 81 continue 82 } 83 84 if m.Recipes[i] != nil { 85 if err := m.Recipes[i].Validate(formats); err != nil { 86 if ve, ok := err.(*errors.Validation); ok { 87 return ve.ValidateName("recipes" + "." + strconv.Itoa(i)) 88 } 89 return err 90 } 91 } 92 93 } 94 95 return nil 96 } 97 98 // ContextValidate validate this recipe response based on the context it is used 99 func (m *RecipeResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 100 var res []error 101 102 if err := m.contextValidateRecipes(ctx, formats); err != nil { 103 res = append(res, err) 104 } 105 106 if len(res) > 0 { 107 return errors.CompositeValidationError(res...) 108 } 109 return nil 110 } 111 112 func (m *RecipeResponse) contextValidateRecipes(ctx context.Context, formats strfmt.Registry) error { 113 114 for i := 0; i < len(m.Recipes); i++ { 115 116 if m.Recipes[i] != nil { 117 if err := m.Recipes[i].ContextValidate(ctx, formats); err != nil { 118 if ve, ok := err.(*errors.Validation); ok { 119 return ve.ValidateName("recipes" + "." + strconv.Itoa(i)) 120 } 121 return err 122 } 123 } 124 125 } 126 127 return nil 128 } 129 130 // MarshalBinary interface implementation 131 func (m *RecipeResponse) MarshalBinary() ([]byte, error) { 132 if m == nil { 133 return nil, nil 134 } 135 return swag.WriteJSON(m) 136 } 137 138 // UnmarshalBinary interface implementation 139 func (m *RecipeResponse) UnmarshalBinary(b []byte) error { 140 var res RecipeResponse 141 if err := swag.ReadJSON(b, &res); err != nil { 142 return err 143 } 144 *m = res 145 return nil 146 }