github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/buildlogstream/buildlogstream_models/artifact.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package buildlogstream_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 "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 // Artifact Artifact 19 // 20 // The result of building a single ingredient is an artifact, which contains the files created by the build. 21 // 22 // swagger:model Artifact 23 type Artifact 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 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 // dependency ids 41 DependencyIds []strfmt.UUID `json:"dependency_ids"` 42 43 // The error that happened which caused the artifact to fail to build. Only non-null if 'build_state' is 'failed'. 44 Error string `json:"error,omitempty"` 45 46 // Ingredient Version ID 47 // 48 // Source Ingredient Version ID for the artifact. Null if the artifact was not built directly from an ingredient (i.e. a packager artifact) 49 // Format: uuid 50 IngredientVersionID strfmt.UUID `json:"ingredient_version_id,omitempty"` 51 52 // Platform ID for the artifact 53 // Required: true 54 // Format: uuid 55 PlatformID *strfmt.UUID `json:"platform_id"` 56 57 // URI for the storage location of the artifact. Only non-null if 'build_state' is 'succeeded'. 58 // Format: uri 59 URI strfmt.URI `json:"uri,omitempty"` 60 } 61 62 // Validate validates this artifact 63 func (m *Artifact) Validate(formats strfmt.Registry) error { 64 var res []error 65 66 if err := m.validateArtifactID(formats); err != nil { 67 res = append(res, err) 68 } 69 70 if err := m.validateBuildState(formats); err != nil { 71 res = append(res, err) 72 } 73 74 if err := m.validateBuildTimestamp(formats); err != nil { 75 res = append(res, err) 76 } 77 78 if err := m.validateDependencyIds(formats); err != nil { 79 res = append(res, err) 80 } 81 82 if err := m.validateIngredientVersionID(formats); err != nil { 83 res = append(res, err) 84 } 85 86 if err := m.validatePlatformID(formats); err != nil { 87 res = append(res, err) 88 } 89 90 if err := m.validateURI(formats); err != nil { 91 res = append(res, err) 92 } 93 94 if len(res) > 0 { 95 return errors.CompositeValidationError(res...) 96 } 97 return nil 98 } 99 100 func (m *Artifact) validateArtifactID(formats strfmt.Registry) error { 101 102 if err := validate.Required("artifact_id", "body", m.ArtifactID); err != nil { 103 return err 104 } 105 106 if err := validate.FormatOf("artifact_id", "body", "uuid", m.ArtifactID.String(), formats); err != nil { 107 return err 108 } 109 110 return nil 111 } 112 113 var artifactTypeBuildStatePropEnum []interface{} 114 115 func init() { 116 var res []string 117 if err := json.Unmarshal([]byte(`["blocked","doomed","failed","ready","running","starting","succeeded"]`), &res); err != nil { 118 panic(err) 119 } 120 for _, v := range res { 121 artifactTypeBuildStatePropEnum = append(artifactTypeBuildStatePropEnum, v) 122 } 123 } 124 125 const ( 126 127 // ArtifactBuildStateBlocked captures enum value "blocked" 128 ArtifactBuildStateBlocked string = "blocked" 129 130 // ArtifactBuildStateDoomed captures enum value "doomed" 131 ArtifactBuildStateDoomed string = "doomed" 132 133 // ArtifactBuildStateFailed captures enum value "failed" 134 ArtifactBuildStateFailed string = "failed" 135 136 // ArtifactBuildStateReady captures enum value "ready" 137 ArtifactBuildStateReady string = "ready" 138 139 // ArtifactBuildStateRunning captures enum value "running" 140 ArtifactBuildStateRunning string = "running" 141 142 // ArtifactBuildStateStarting captures enum value "starting" 143 ArtifactBuildStateStarting string = "starting" 144 145 // ArtifactBuildStateSucceeded captures enum value "succeeded" 146 ArtifactBuildStateSucceeded string = "succeeded" 147 ) 148 149 // prop value enum 150 func (m *Artifact) validateBuildStateEnum(path, location string, value string) error { 151 if err := validate.Enum(path, location, value, artifactTypeBuildStatePropEnum); err != nil { 152 return err 153 } 154 return nil 155 } 156 157 func (m *Artifact) validateBuildState(formats strfmt.Registry) error { 158 159 if err := validate.Required("build_state", "body", m.BuildState); err != nil { 160 return err 161 } 162 163 // value enum 164 if err := m.validateBuildStateEnum("build_state", "body", *m.BuildState); err != nil { 165 return err 166 } 167 168 return nil 169 } 170 171 func (m *Artifact) validateBuildTimestamp(formats strfmt.Registry) error { 172 173 if err := validate.Required("build_timestamp", "body", m.BuildTimestamp); err != nil { 174 return err 175 } 176 177 if err := validate.FormatOf("build_timestamp", "body", "date-time", m.BuildTimestamp.String(), formats); err != nil { 178 return err 179 } 180 181 return nil 182 } 183 184 func (m *Artifact) validateDependencyIds(formats strfmt.Registry) error { 185 186 if swag.IsZero(m.DependencyIds) { // not required 187 return nil 188 } 189 190 for i := 0; i < len(m.DependencyIds); i++ { 191 192 if err := validate.FormatOf("dependency_ids"+"."+strconv.Itoa(i), "body", "uuid", m.DependencyIds[i].String(), formats); err != nil { 193 return err 194 } 195 196 } 197 198 return nil 199 } 200 201 func (m *Artifact) validateIngredientVersionID(formats strfmt.Registry) error { 202 203 if swag.IsZero(m.IngredientVersionID) { // not required 204 return nil 205 } 206 207 if err := validate.FormatOf("ingredient_version_id", "body", "uuid", m.IngredientVersionID.String(), formats); err != nil { 208 return err 209 } 210 211 return nil 212 } 213 214 func (m *Artifact) validatePlatformID(formats strfmt.Registry) error { 215 216 if err := validate.Required("platform_id", "body", m.PlatformID); err != nil { 217 return err 218 } 219 220 if err := validate.FormatOf("platform_id", "body", "uuid", m.PlatformID.String(), formats); err != nil { 221 return err 222 } 223 224 return nil 225 } 226 227 func (m *Artifact) validateURI(formats strfmt.Registry) error { 228 229 if swag.IsZero(m.URI) { // not required 230 return nil 231 } 232 233 if err := validate.FormatOf("uri", "body", "uri", m.URI.String(), formats); err != nil { 234 return err 235 } 236 237 return nil 238 } 239 240 // MarshalBinary interface implementation 241 func (m *Artifact) MarshalBinary() ([]byte, error) { 242 if m == nil { 243 return nil, nil 244 } 245 return swag.WriteJSON(m) 246 } 247 248 // UnmarshalBinary interface implementation 249 func (m *Artifact) UnmarshalBinary(b []byte) error { 250 var res Artifact 251 if err := swag.ReadJSON(b, &res); err != nil { 252 return err 253 } 254 *m = res 255 return nil 256 }