github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/v1_build_request.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 "encoding/json" 10 "strconv" 11 12 strfmt "github.com/go-openapi/strfmt" 13 14 "github.com/go-openapi/errors" 15 "github.com/go-openapi/swag" 16 "github.com/go-openapi/validate" 17 ) 18 19 // V1BuildRequest Build Request V1 20 // 21 // A build request (v1) which is submitted to the Head Chef REST API. A build request may contain either a full recipe or just the ID of a recipe stored in the inventory API. 22 // swagger:model v1BuildRequest 23 type V1BuildRequest struct { 24 25 // Additional metadata about the build which should be included in any metrics about the build. This field has no schema validation and is passed through without parsing by Head Chef. 26 Annotations interface{} `json:"annotations,omitempty"` 27 28 // The version of camel to use when running setup-builds.pl. NOTE: this is temporary until the camel version is included in the recipe. 29 CamelCommit string `json:"camel_commit,omitempty"` 30 31 // OBSOLETE. Head Chef still accepts this field to not break old clients but does nothing with these values. Use the camel_flags field in the recipe. 32 // Unique: true 33 CamelFlags []string `json:"camel_flags"` 34 35 // NOTE: This field is deprecated and will be removed in the future. 36 // Enum: [7zip dmg msi raw tarball zip] 37 Format *string `json:"format,omitempty"` 38 39 // recipe 40 Recipe *V1BuildRequestRecipe `json:"recipe,omitempty"` 41 42 // The ID of a recipe solved using the inventory API solutions endpoint 43 // Format: uuid 44 RecipeID strfmt.UUID `json:"recipe_id,omitempty"` 45 46 // requester 47 Requester *V1BuildRequestRequester `json:"requester,omitempty"` 48 } 49 50 // Validate validates this v1 build request 51 func (m *V1BuildRequest) Validate(formats strfmt.Registry) error { 52 var res []error 53 54 if err := m.validateCamelFlags(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if err := m.validateFormat(formats); err != nil { 59 res = append(res, err) 60 } 61 62 if err := m.validateRecipe(formats); err != nil { 63 res = append(res, err) 64 } 65 66 if err := m.validateRecipeID(formats); err != nil { 67 res = append(res, err) 68 } 69 70 if err := m.validateRequester(formats); err != nil { 71 res = append(res, err) 72 } 73 74 if len(res) > 0 { 75 return errors.CompositeValidationError(res...) 76 } 77 return nil 78 } 79 80 var v1BuildRequestCamelFlagsItemsEnum []interface{} 81 82 func init() { 83 var res []string 84 if err := json.Unmarshal([]byte(`["--dynamic-core","--python-debug","--tcl-debug","--tcl-disable-threads"]`), &res); err != nil { 85 panic(err) 86 } 87 for _, v := range res { 88 v1BuildRequestCamelFlagsItemsEnum = append(v1BuildRequestCamelFlagsItemsEnum, v) 89 } 90 } 91 92 func (m *V1BuildRequest) validateCamelFlagsItemsEnum(path, location string, value string) error { 93 if err := validate.Enum(path, location, value, v1BuildRequestCamelFlagsItemsEnum); err != nil { 94 return err 95 } 96 return nil 97 } 98 99 func (m *V1BuildRequest) validateCamelFlags(formats strfmt.Registry) error { 100 101 if swag.IsZero(m.CamelFlags) { // not required 102 return nil 103 } 104 105 if err := validate.UniqueItems("camel_flags", "body", m.CamelFlags); err != nil { 106 return err 107 } 108 109 for i := 0; i < len(m.CamelFlags); i++ { 110 111 // value enum 112 if err := m.validateCamelFlagsItemsEnum("camel_flags"+"."+strconv.Itoa(i), "body", m.CamelFlags[i]); err != nil { 113 return err 114 } 115 116 } 117 118 return nil 119 } 120 121 var v1BuildRequestTypeFormatPropEnum []interface{} 122 123 func init() { 124 var res []string 125 if err := json.Unmarshal([]byte(`["7zip","dmg","msi","raw","tarball","zip"]`), &res); err != nil { 126 panic(err) 127 } 128 for _, v := range res { 129 v1BuildRequestTypeFormatPropEnum = append(v1BuildRequestTypeFormatPropEnum, v) 130 } 131 } 132 133 const ( 134 135 // V1BuildRequestFormatNr7zip captures enum value "7zip" 136 V1BuildRequestFormatNr7zip string = "7zip" 137 138 // V1BuildRequestFormatDmg captures enum value "dmg" 139 V1BuildRequestFormatDmg string = "dmg" 140 141 // V1BuildRequestFormatMsi captures enum value "msi" 142 V1BuildRequestFormatMsi string = "msi" 143 144 // V1BuildRequestFormatRaw captures enum value "raw" 145 V1BuildRequestFormatRaw string = "raw" 146 147 // V1BuildRequestFormatTarball captures enum value "tarball" 148 V1BuildRequestFormatTarball string = "tarball" 149 150 // V1BuildRequestFormatZip captures enum value "zip" 151 V1BuildRequestFormatZip string = "zip" 152 ) 153 154 // prop value enum 155 func (m *V1BuildRequest) validateFormatEnum(path, location string, value string) error { 156 if err := validate.Enum(path, location, value, v1BuildRequestTypeFormatPropEnum); err != nil { 157 return err 158 } 159 return nil 160 } 161 162 func (m *V1BuildRequest) validateFormat(formats strfmt.Registry) error { 163 164 if swag.IsZero(m.Format) { // not required 165 return nil 166 } 167 168 // value enum 169 if err := m.validateFormatEnum("format", "body", *m.Format); err != nil { 170 return err 171 } 172 173 return nil 174 } 175 176 func (m *V1BuildRequest) validateRecipe(formats strfmt.Registry) error { 177 178 if swag.IsZero(m.Recipe) { // not required 179 return nil 180 } 181 182 if m.Recipe != nil { 183 if err := m.Recipe.Validate(formats); err != nil { 184 if ve, ok := err.(*errors.Validation); ok { 185 return ve.ValidateName("recipe") 186 } 187 return err 188 } 189 } 190 191 return nil 192 } 193 194 func (m *V1BuildRequest) validateRecipeID(formats strfmt.Registry) error { 195 196 if swag.IsZero(m.RecipeID) { // not required 197 return nil 198 } 199 200 if err := validate.FormatOf("recipe_id", "body", "uuid", m.RecipeID.String(), formats); err != nil { 201 return err 202 } 203 204 return nil 205 } 206 207 func (m *V1BuildRequest) validateRequester(formats strfmt.Registry) error { 208 209 if swag.IsZero(m.Requester) { // not required 210 return nil 211 } 212 213 if m.Requester != nil { 214 if err := m.Requester.Validate(formats); err != nil { 215 if ve, ok := err.(*errors.Validation); ok { 216 return ve.ValidateName("requester") 217 } 218 return err 219 } 220 } 221 222 return nil 223 } 224 225 // MarshalBinary interface implementation 226 func (m *V1BuildRequest) MarshalBinary() ([]byte, error) { 227 if m == nil { 228 return nil, nil 229 } 230 return swag.WriteJSON(m) 231 } 232 233 // UnmarshalBinary interface implementation 234 func (m *V1BuildRequest) UnmarshalBinary(b []byte) error { 235 var res V1BuildRequest 236 if err := swag.ReadJSON(b, &res); err != nil { 237 return err 238 } 239 *m = res 240 return nil 241 }