github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/v2_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  // V2Artifact Artifact (V2)
    20  //
    21  // An output of a build step
    22  // swagger:model V2Artifact
    23  type V2Artifact struct {
    24  
    25  	// Artifact ID
    26  	// Required: true
    27  	// Format: uuid
    28  	ArtifactID *strfmt.UUID `json:"artifact_id"`
    29  
    30  	// The artifact IDs of other artifacts in this build that must be built before this one.
    31  	BuildDependencyIds []strfmt.UUID `json:"build_dependency_ids"`
    32  
    33  	// Indicates where in the build process the artifact currently is.
    34  	// Required: true
    35  	// Enum: [blocked doomed failed ready running skipped starting succeeded]
    36  	BuildState *string `json:"build_state"`
    37  
    38  	// Timestamp of the most recent change to the build state of this artifact
    39  	// Required: true
    40  	// Format: date-time
    41  	BuildTimestamp *strfmt.DateTime `json:"build_timestamp"`
    42  
    43  	// checksum
    44  	Checksum string `json:"checksum,omitempty"`
    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  	// URI for the storage location of the artifact's build log. Will be non-null if 'build_state' is 'succeeded' and possibly non-null if 'build_state' is 'failed' (depending on the nature of the failure).
    50  	// Format: uri
    51  	LogURI strfmt.URI `json:"log_uri,omitempty"`
    52  
    53  	// The MIME type of the file stored at the artifact's URI.
    54  	// Required: true
    55  	MimeType *string `json:"mime_type"`
    56  
    57  	// UUID of the platform this artifact is built on
    58  	// Required: true
    59  	// Format: uuid
    60  	PlatformID *strfmt.UUID `json:"platform_id"`
    61  
    62  	// source
    63  	Source *V2BuildStatusResponseArtifactsItemsSource `json:"source,omitempty"`
    64  
    65  	// URI for the storage location of the artifact. Only non-null if 'build_state' is 'succeeded'.
    66  	// Format: uri
    67  	URI strfmt.URI `json:"uri,omitempty"`
    68  }
    69  
    70  // Validate validates this v2 artifact
    71  func (m *V2Artifact) Validate(formats strfmt.Registry) error {
    72  	var res []error
    73  
    74  	if err := m.validateArtifactID(formats); err != nil {
    75  		res = append(res, err)
    76  	}
    77  
    78  	if err := m.validateBuildDependencyIds(formats); err != nil {
    79  		res = append(res, err)
    80  	}
    81  
    82  	if err := m.validateBuildState(formats); err != nil {
    83  		res = append(res, err)
    84  	}
    85  
    86  	if err := m.validateBuildTimestamp(formats); err != nil {
    87  		res = append(res, err)
    88  	}
    89  
    90  	if err := m.validateLogURI(formats); err != nil {
    91  		res = append(res, err)
    92  	}
    93  
    94  	if err := m.validateMimeType(formats); err != nil {
    95  		res = append(res, err)
    96  	}
    97  
    98  	if err := m.validatePlatformID(formats); err != nil {
    99  		res = append(res, err)
   100  	}
   101  
   102  	if err := m.validateSource(formats); err != nil {
   103  		res = append(res, err)
   104  	}
   105  
   106  	if err := m.validateURI(formats); err != nil {
   107  		res = append(res, err)
   108  	}
   109  
   110  	if len(res) > 0 {
   111  		return errors.CompositeValidationError(res...)
   112  	}
   113  	return nil
   114  }
   115  
   116  func (m *V2Artifact) validateArtifactID(formats strfmt.Registry) error {
   117  
   118  	if err := validate.Required("artifact_id", "body", m.ArtifactID); err != nil {
   119  		return err
   120  	}
   121  
   122  	if err := validate.FormatOf("artifact_id", "body", "uuid", m.ArtifactID.String(), formats); err != nil {
   123  		return err
   124  	}
   125  
   126  	return nil
   127  }
   128  
   129  func (m *V2Artifact) validateBuildDependencyIds(formats strfmt.Registry) error {
   130  
   131  	if swag.IsZero(m.BuildDependencyIds) { // not required
   132  		return nil
   133  	}
   134  
   135  	for i := 0; i < len(m.BuildDependencyIds); i++ {
   136  
   137  		if err := validate.FormatOf("build_dependency_ids"+"."+strconv.Itoa(i), "body", "uuid", m.BuildDependencyIds[i].String(), formats); err != nil {
   138  			return err
   139  		}
   140  
   141  	}
   142  
   143  	return nil
   144  }
   145  
   146  var v2ArtifactTypeBuildStatePropEnum []interface{}
   147  
   148  func init() {
   149  	var res []string
   150  	if err := json.Unmarshal([]byte(`["blocked","doomed","failed","ready","running","skipped","starting","succeeded"]`), &res); err != nil {
   151  		panic(err)
   152  	}
   153  	for _, v := range res {
   154  		v2ArtifactTypeBuildStatePropEnum = append(v2ArtifactTypeBuildStatePropEnum, v)
   155  	}
   156  }
   157  
   158  const (
   159  
   160  	// V2ArtifactBuildStateBlocked captures enum value "blocked"
   161  	V2ArtifactBuildStateBlocked string = "blocked"
   162  
   163  	// V2ArtifactBuildStateDoomed captures enum value "doomed"
   164  	V2ArtifactBuildStateDoomed string = "doomed"
   165  
   166  	// V2ArtifactBuildStateFailed captures enum value "failed"
   167  	V2ArtifactBuildStateFailed string = "failed"
   168  
   169  	// V2ArtifactBuildStateReady captures enum value "ready"
   170  	V2ArtifactBuildStateReady string = "ready"
   171  
   172  	// V2ArtifactBuildStateRunning captures enum value "running"
   173  	V2ArtifactBuildStateRunning string = "running"
   174  
   175  	// V2ArtifactBuildStateSkipped captures enum value "skipped"
   176  	V2ArtifactBuildStateSkipped string = "skipped"
   177  
   178  	// V2ArtifactBuildStateStarting captures enum value "starting"
   179  	V2ArtifactBuildStateStarting string = "starting"
   180  
   181  	// V2ArtifactBuildStateSucceeded captures enum value "succeeded"
   182  	V2ArtifactBuildStateSucceeded string = "succeeded"
   183  )
   184  
   185  // prop value enum
   186  func (m *V2Artifact) validateBuildStateEnum(path, location string, value string) error {
   187  	if err := validate.Enum(path, location, value, v2ArtifactTypeBuildStatePropEnum); err != nil {
   188  		return err
   189  	}
   190  	return nil
   191  }
   192  
   193  func (m *V2Artifact) validateBuildState(formats strfmt.Registry) error {
   194  
   195  	if err := validate.Required("build_state", "body", m.BuildState); err != nil {
   196  		return err
   197  	}
   198  
   199  	// value enum
   200  	if err := m.validateBuildStateEnum("build_state", "body", *m.BuildState); err != nil {
   201  		return err
   202  	}
   203  
   204  	return nil
   205  }
   206  
   207  func (m *V2Artifact) validateBuildTimestamp(formats strfmt.Registry) error {
   208  
   209  	if err := validate.Required("build_timestamp", "body", m.BuildTimestamp); err != nil {
   210  		return err
   211  	}
   212  
   213  	if err := validate.FormatOf("build_timestamp", "body", "date-time", m.BuildTimestamp.String(), formats); err != nil {
   214  		return err
   215  	}
   216  
   217  	return nil
   218  }
   219  
   220  func (m *V2Artifact) validateLogURI(formats strfmt.Registry) error {
   221  
   222  	if swag.IsZero(m.LogURI) { // not required
   223  		return nil
   224  	}
   225  
   226  	if err := validate.FormatOf("log_uri", "body", "uri", m.LogURI.String(), formats); err != nil {
   227  		return err
   228  	}
   229  
   230  	return nil
   231  }
   232  
   233  func (m *V2Artifact) validateMimeType(formats strfmt.Registry) error {
   234  
   235  	if err := validate.Required("mime_type", "body", m.MimeType); err != nil {
   236  		return err
   237  	}
   238  
   239  	return nil
   240  }
   241  
   242  func (m *V2Artifact) validatePlatformID(formats strfmt.Registry) error {
   243  
   244  	if err := validate.Required("platform_id", "body", m.PlatformID); err != nil {
   245  		return err
   246  	}
   247  
   248  	if err := validate.FormatOf("platform_id", "body", "uuid", m.PlatformID.String(), formats); err != nil {
   249  		return err
   250  	}
   251  
   252  	return nil
   253  }
   254  
   255  func (m *V2Artifact) validateSource(formats strfmt.Registry) error {
   256  
   257  	if swag.IsZero(m.Source) { // not required
   258  		return nil
   259  	}
   260  
   261  	if m.Source != nil {
   262  		if err := m.Source.Validate(formats); err != nil {
   263  			if ve, ok := err.(*errors.Validation); ok {
   264  				return ve.ValidateName("source")
   265  			}
   266  			return err
   267  		}
   268  	}
   269  
   270  	return nil
   271  }
   272  
   273  func (m *V2Artifact) validateURI(formats strfmt.Registry) error {
   274  
   275  	if swag.IsZero(m.URI) { // not required
   276  		return nil
   277  	}
   278  
   279  	if err := validate.FormatOf("uri", "body", "uri", m.URI.String(), formats); err != nil {
   280  		return err
   281  	}
   282  
   283  	return nil
   284  }
   285  
   286  // MarshalBinary interface implementation
   287  func (m *V2Artifact) MarshalBinary() ([]byte, error) {
   288  	if m == nil {
   289  		return nil, nil
   290  	}
   291  	return swag.WriteJSON(m)
   292  }
   293  
   294  // UnmarshalBinary interface implementation
   295  func (m *V2Artifact) UnmarshalBinary(b []byte) error {
   296  	var res V2Artifact
   297  	if err := swag.ReadJSON(b, &res); err != nil {
   298  		return err
   299  	}
   300  	*m = res
   301  	return nil
   302  }