github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/ingredient_version.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 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 ) 15 16 // IngredientVersion Ingredient Version 17 // 18 // The full ingredient version data model. Returned from all read requests. 19 // 20 // swagger:model ingredientVersion 21 type IngredientVersion struct { 22 IngredientVersionAllOf0 23 24 RevisionedResource 25 26 IngredientVersionCore 27 28 IngredientVersionRevisionCore 29 } 30 31 // UnmarshalJSON unmarshals this object from a JSON structure 32 func (m *IngredientVersion) UnmarshalJSON(raw []byte) error { 33 // AO0 34 var aO0 IngredientVersionAllOf0 35 if err := swag.ReadJSON(raw, &aO0); err != nil { 36 return err 37 } 38 m.IngredientVersionAllOf0 = aO0 39 40 // AO1 41 var aO1 RevisionedResource 42 if err := swag.ReadJSON(raw, &aO1); err != nil { 43 return err 44 } 45 m.RevisionedResource = aO1 46 47 // AO2 48 var aO2 IngredientVersionCore 49 if err := swag.ReadJSON(raw, &aO2); err != nil { 50 return err 51 } 52 m.IngredientVersionCore = aO2 53 54 // AO3 55 var aO3 IngredientVersionRevisionCore 56 if err := swag.ReadJSON(raw, &aO3); err != nil { 57 return err 58 } 59 m.IngredientVersionRevisionCore = aO3 60 61 return nil 62 } 63 64 // MarshalJSON marshals this object to a JSON structure 65 func (m IngredientVersion) MarshalJSON() ([]byte, error) { 66 _parts := make([][]byte, 0, 4) 67 68 aO0, err := swag.WriteJSON(m.IngredientVersionAllOf0) 69 if err != nil { 70 return nil, err 71 } 72 _parts = append(_parts, aO0) 73 74 aO1, err := swag.WriteJSON(m.RevisionedResource) 75 if err != nil { 76 return nil, err 77 } 78 _parts = append(_parts, aO1) 79 80 aO2, err := swag.WriteJSON(m.IngredientVersionCore) 81 if err != nil { 82 return nil, err 83 } 84 _parts = append(_parts, aO2) 85 86 aO3, err := swag.WriteJSON(m.IngredientVersionRevisionCore) 87 if err != nil { 88 return nil, err 89 } 90 _parts = append(_parts, aO3) 91 return swag.ConcatJSON(_parts...), nil 92 } 93 94 // Validate validates this ingredient version 95 func (m *IngredientVersion) Validate(formats strfmt.Registry) error { 96 var res []error 97 98 // validation for a type composition with IngredientVersionAllOf0 99 if err := m.IngredientVersionAllOf0.Validate(formats); err != nil { 100 res = append(res, err) 101 } 102 // validation for a type composition with RevisionedResource 103 if err := m.RevisionedResource.Validate(formats); err != nil { 104 res = append(res, err) 105 } 106 // validation for a type composition with IngredientVersionCore 107 if err := m.IngredientVersionCore.Validate(formats); err != nil { 108 res = append(res, err) 109 } 110 // validation for a type composition with IngredientVersionRevisionCore 111 if err := m.IngredientVersionRevisionCore.Validate(formats); err != nil { 112 res = append(res, err) 113 } 114 115 if len(res) > 0 { 116 return errors.CompositeValidationError(res...) 117 } 118 return nil 119 } 120 121 // ContextValidate validate this ingredient version based on the context it is used 122 func (m *IngredientVersion) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 123 var res []error 124 125 // validation for a type composition with IngredientVersionAllOf0 126 if err := m.IngredientVersionAllOf0.ContextValidate(ctx, formats); err != nil { 127 res = append(res, err) 128 } 129 // validation for a type composition with RevisionedResource 130 if err := m.RevisionedResource.ContextValidate(ctx, formats); err != nil { 131 res = append(res, err) 132 } 133 // validation for a type composition with IngredientVersionCore 134 if err := m.IngredientVersionCore.ContextValidate(ctx, formats); err != nil { 135 res = append(res, err) 136 } 137 // validation for a type composition with IngredientVersionRevisionCore 138 if err := m.IngredientVersionRevisionCore.ContextValidate(ctx, formats); err != nil { 139 res = append(res, err) 140 } 141 142 if len(res) > 0 { 143 return errors.CompositeValidationError(res...) 144 } 145 return nil 146 } 147 148 // MarshalBinary interface implementation 149 func (m *IngredientVersion) MarshalBinary() ([]byte, error) { 150 if m == nil { 151 return nil, nil 152 } 153 return swag.WriteJSON(m) 154 } 155 156 // UnmarshalBinary interface implementation 157 func (m *IngredientVersion) UnmarshalBinary(b []byte) error { 158 var res IngredientVersion 159 if err := swag.ReadJSON(b, &res); err != nil { 160 return err 161 } 162 *m = res 163 return nil 164 }