github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/v1_artifact.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 // V1Artifact Artifact (V1) 20 // 21 // The result of building a single ingredient is an artifact, which contains the files created by the build. 22 // swagger:model V1Artifact 23 type V1Artifact struct { 24 25 // Artifact ID 26 // Required: true 27 // Format: uuid 28 ArtifactID *strfmt.UUID `json:"artifact_id"` 29 30 // Indicates where in the build process the artifact currently is. 31 // Required: true 32 // Enum: [blocked doomed failed ready running skipped starting succeeded] 33 BuildState *string `json:"build_state"` 34 35 // Timestamp for when the artifact was created 36 // Required: true 37 // Format: date-time 38 BuildTimestamp *strfmt.DateTime `json:"build_timestamp"` 39 40 // checksum 41 Checksum string `json:"checksum,omitempty"` 42 43 // dependency ids 44 DependencyIds []strfmt.UUID `json:"dependency_ids"` 45 46 // The error that happened which caused the artifact to fail to build. Only non-null if 'build_state' is 'failed'. 47 Error string `json:"error,omitempty"` 48 49 // Ingredient Version ID 50 // 51 // Source Ingredient Version ID for the artifact. Null if the artifact was not built directly from an ingredient (i.e. a packager artifact) 52 // Format: uuid 53 IngredientVersionID strfmt.UUID `json:"ingredient_version_id,omitempty"` 54 55 // URI for the storage location of the artifact's build log. Only artifacts that have finished building with the 'alternative' build engine have artifact logs. For all other cases this field is always null. 56 // Format: uri 57 LogURI strfmt.URI `json:"log_uri,omitempty"` 58 59 // The MIME type of the file stored at the artifact's URI. Only artifacts built with the 'alternative' build engine have MIME types. For all other build engines this field is always null. 60 MimeType string `json:"mime_type,omitempty"` 61 62 // Platform ID for the artifact 63 // Required: true 64 // Format: uuid 65 PlatformID *strfmt.UUID `json:"platform_id"` 66 67 // URI for the storage location of the artifact. Only non-null if 'build_state' is 'succeeded'. 68 // Format: uri 69 URI strfmt.URI `json:"uri,omitempty"` 70 } 71 72 // Validate validates this v1 artifact 73 func (m *V1Artifact) Validate(formats strfmt.Registry) error { 74 var res []error 75 76 if err := m.validateArtifactID(formats); err != nil { 77 res = append(res, err) 78 } 79 80 if err := m.validateBuildState(formats); err != nil { 81 res = append(res, err) 82 } 83 84 if err := m.validateBuildTimestamp(formats); err != nil { 85 res = append(res, err) 86 } 87 88 if err := m.validateDependencyIds(formats); err != nil { 89 res = append(res, err) 90 } 91 92 if err := m.validateIngredientVersionID(formats); err != nil { 93 res = append(res, err) 94 } 95 96 if err := m.validateLogURI(formats); err != nil { 97 res = append(res, err) 98 } 99 100 if err := m.validatePlatformID(formats); err != nil { 101 res = append(res, err) 102 } 103 104 if err := m.validateURI(formats); err != nil { 105 res = append(res, err) 106 } 107 108 if len(res) > 0 { 109 return errors.CompositeValidationError(res...) 110 } 111 return nil 112 } 113 114 func (m *V1Artifact) validateArtifactID(formats strfmt.Registry) error { 115 116 if err := validate.Required("artifact_id", "body", m.ArtifactID); err != nil { 117 return err 118 } 119 120 if err := validate.FormatOf("artifact_id", "body", "uuid", m.ArtifactID.String(), formats); err != nil { 121 return err 122 } 123 124 return nil 125 } 126 127 var v1ArtifactTypeBuildStatePropEnum []interface{} 128 129 func init() { 130 var res []string 131 if err := json.Unmarshal([]byte(`["blocked","doomed","failed","ready","running","skipped","starting","succeeded"]`), &res); err != nil { 132 panic(err) 133 } 134 for _, v := range res { 135 v1ArtifactTypeBuildStatePropEnum = append(v1ArtifactTypeBuildStatePropEnum, v) 136 } 137 } 138 139 const ( 140 141 // V1ArtifactBuildStateBlocked captures enum value "blocked" 142 V1ArtifactBuildStateBlocked string = "blocked" 143 144 // V1ArtifactBuildStateDoomed captures enum value "doomed" 145 V1ArtifactBuildStateDoomed string = "doomed" 146 147 // V1ArtifactBuildStateFailed captures enum value "failed" 148 V1ArtifactBuildStateFailed string = "failed" 149 150 // V1ArtifactBuildStateReady captures enum value "ready" 151 V1ArtifactBuildStateReady string = "ready" 152 153 // V1ArtifactBuildStateRunning captures enum value "running" 154 V1ArtifactBuildStateRunning string = "running" 155 156 // V1ArtifactBuildStateSkipped captures enum value "skipped" 157 V1ArtifactBuildStateSkipped string = "skipped" 158 159 // V1ArtifactBuildStateStarting captures enum value "starting" 160 V1ArtifactBuildStateStarting string = "starting" 161 162 // V1ArtifactBuildStateSucceeded captures enum value "succeeded" 163 V1ArtifactBuildStateSucceeded string = "succeeded" 164 ) 165 166 // prop value enum 167 func (m *V1Artifact) validateBuildStateEnum(path, location string, value string) error { 168 if err := validate.Enum(path, location, value, v1ArtifactTypeBuildStatePropEnum); err != nil { 169 return err 170 } 171 return nil 172 } 173 174 func (m *V1Artifact) validateBuildState(formats strfmt.Registry) error { 175 176 if err := validate.Required("build_state", "body", m.BuildState); err != nil { 177 return err 178 } 179 180 // value enum 181 if err := m.validateBuildStateEnum("build_state", "body", *m.BuildState); err != nil { 182 return err 183 } 184 185 return nil 186 } 187 188 func (m *V1Artifact) validateBuildTimestamp(formats strfmt.Registry) error { 189 190 if err := validate.Required("build_timestamp", "body", m.BuildTimestamp); err != nil { 191 return err 192 } 193 194 if err := validate.FormatOf("build_timestamp", "body", "date-time", m.BuildTimestamp.String(), formats); err != nil { 195 return err 196 } 197 198 return nil 199 } 200 201 func (m *V1Artifact) validateDependencyIds(formats strfmt.Registry) error { 202 203 if swag.IsZero(m.DependencyIds) { // not required 204 return nil 205 } 206 207 for i := 0; i < len(m.DependencyIds); i++ { 208 209 if err := validate.FormatOf("dependency_ids"+"."+strconv.Itoa(i), "body", "uuid", m.DependencyIds[i].String(), formats); err != nil { 210 return err 211 } 212 213 } 214 215 return nil 216 } 217 218 func (m *V1Artifact) validateIngredientVersionID(formats strfmt.Registry) error { 219 220 if swag.IsZero(m.IngredientVersionID) { // not required 221 return nil 222 } 223 224 if err := validate.FormatOf("ingredient_version_id", "body", "uuid", m.IngredientVersionID.String(), formats); err != nil { 225 return err 226 } 227 228 return nil 229 } 230 231 func (m *V1Artifact) validateLogURI(formats strfmt.Registry) error { 232 233 if swag.IsZero(m.LogURI) { // not required 234 return nil 235 } 236 237 if err := validate.FormatOf("log_uri", "body", "uri", m.LogURI.String(), formats); err != nil { 238 return err 239 } 240 241 return nil 242 } 243 244 func (m *V1Artifact) validatePlatformID(formats strfmt.Registry) error { 245 246 if err := validate.Required("platform_id", "body", m.PlatformID); err != nil { 247 return err 248 } 249 250 if err := validate.FormatOf("platform_id", "body", "uuid", m.PlatformID.String(), formats); err != nil { 251 return err 252 } 253 254 return nil 255 } 256 257 func (m *V1Artifact) validateURI(formats strfmt.Registry) error { 258 259 if swag.IsZero(m.URI) { // not required 260 return nil 261 } 262 263 if err := validate.FormatOf("uri", "body", "uri", m.URI.String(), formats); err != nil { 264 return err 265 } 266 267 return nil 268 } 269 270 // MarshalBinary interface implementation 271 func (m *V1Artifact) MarshalBinary() ([]byte, error) { 272 if m == nil { 273 return nil, nil 274 } 275 return swag.WriteJSON(m) 276 } 277 278 // UnmarshalBinary interface implementation 279 func (m *V1Artifact) UnmarshalBinary(b []byte) error { 280 var res V1Artifact 281 if err := swag.ReadJSON(b, &res); err != nil { 282 return err 283 } 284 *m = res 285 return nil 286 }