github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/v1_build_status_response.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  // V1BuildStatusResponse Build Status Response (V1)
    20  //
    21  // A response describing status of a build: started, completed or failed.
    22  // swagger:model V1BuildStatusResponse
    23  type V1BuildStatusResponse struct {
    24  
    25  	// An array containing all the artifacts that make up this build. When 'build_engine' is 'camel', this array is empty for all response types other than 'build_completed'
    26  	Artifacts []*V1Artifact `json:"artifacts"`
    27  
    28  	// Name of the system that orchestrates the build
    29  	// Required: true
    30  	// Enum: [alternative camel]
    31  	BuildEngine *string `json:"build_engine"`
    32  
    33  	// Echoed back from the request if the request asked for a build status by build request ID, otherwise null
    34  	// Format: uuid
    35  	BuildRequestID strfmt.UUID `json:"build_request_id,omitempty"`
    36  
    37  	// All of the errors from the failed build. Will be null unless 'type' is 'build_failed'. Note that these errors may not be suitable for presenting to users and should simply be logged for further investigation.
    38  	Errors []string `json:"errors"`
    39  
    40  	// If true this failed build can be retried and it may succeed. If false, retrying this failed build will not change the outcome. This field's value is only valid when 'type' is 'build_failed'.
    41  	// Required: true
    42  	IsRetryable bool `json:"is_retryable"`
    43  
    44  	// An S3 URI containing the log for this build. Always null for builds where 'build_engine' is not 'camel'
    45  	// Format: uri
    46  	LogURI strfmt.URI `json:"log_uri,omitempty"`
    47  
    48  	// A user-facing message describing the build results.
    49  	Message string `json:"message,omitempty"`
    50  
    51  	// recipe id
    52  	// Required: true
    53  	// Format: uuid
    54  	RecipeID *strfmt.UUID `json:"recipe_id"`
    55  
    56  	// The timestamp for the message.
    57  	// Required: true
    58  	// Format: date-time
    59  	Timestamp *strfmt.DateTime `json:"timestamp"`
    60  
    61  	// Indicates the type of the contained message.
    62  	// Required: true
    63  	// Enum: [build_completed build_failed build_started]
    64  	Type *string `json:"type"`
    65  }
    66  
    67  // Validate validates this v1 build status response
    68  func (m *V1BuildStatusResponse) Validate(formats strfmt.Registry) error {
    69  	var res []error
    70  
    71  	if err := m.validateArtifacts(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if err := m.validateBuildEngine(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateBuildRequestID(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if err := m.validateIsRetryable(formats); err != nil {
    84  		res = append(res, err)
    85  	}
    86  
    87  	if err := m.validateLogURI(formats); err != nil {
    88  		res = append(res, err)
    89  	}
    90  
    91  	if err := m.validateRecipeID(formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if err := m.validateTimestamp(formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if err := m.validateType(formats); err != nil {
   100  		res = append(res, err)
   101  	}
   102  
   103  	if len(res) > 0 {
   104  		return errors.CompositeValidationError(res...)
   105  	}
   106  	return nil
   107  }
   108  
   109  func (m *V1BuildStatusResponse) validateArtifacts(formats strfmt.Registry) error {
   110  
   111  	if swag.IsZero(m.Artifacts) { // not required
   112  		return nil
   113  	}
   114  
   115  	for i := 0; i < len(m.Artifacts); i++ {
   116  		if swag.IsZero(m.Artifacts[i]) { // not required
   117  			continue
   118  		}
   119  
   120  		if m.Artifacts[i] != nil {
   121  			if err := m.Artifacts[i].Validate(formats); err != nil {
   122  				if ve, ok := err.(*errors.Validation); ok {
   123  					return ve.ValidateName("artifacts" + "." + strconv.Itoa(i))
   124  				}
   125  				return err
   126  			}
   127  		}
   128  
   129  	}
   130  
   131  	return nil
   132  }
   133  
   134  var v1BuildStatusResponseTypeBuildEnginePropEnum []interface{}
   135  
   136  func init() {
   137  	var res []string
   138  	if err := json.Unmarshal([]byte(`["alternative","camel"]`), &res); err != nil {
   139  		panic(err)
   140  	}
   141  	for _, v := range res {
   142  		v1BuildStatusResponseTypeBuildEnginePropEnum = append(v1BuildStatusResponseTypeBuildEnginePropEnum, v)
   143  	}
   144  }
   145  
   146  const (
   147  
   148  	// V1BuildStatusResponseBuildEngineAlternative captures enum value "alternative"
   149  	V1BuildStatusResponseBuildEngineAlternative string = "alternative"
   150  
   151  	// V1BuildStatusResponseBuildEngineCamel captures enum value "camel"
   152  	V1BuildStatusResponseBuildEngineCamel string = "camel"
   153  )
   154  
   155  // prop value enum
   156  func (m *V1BuildStatusResponse) validateBuildEngineEnum(path, location string, value string) error {
   157  	if err := validate.Enum(path, location, value, v1BuildStatusResponseTypeBuildEnginePropEnum); err != nil {
   158  		return err
   159  	}
   160  	return nil
   161  }
   162  
   163  func (m *V1BuildStatusResponse) validateBuildEngine(formats strfmt.Registry) error {
   164  
   165  	if err := validate.Required("build_engine", "body", m.BuildEngine); err != nil {
   166  		return err
   167  	}
   168  
   169  	// value enum
   170  	if err := m.validateBuildEngineEnum("build_engine", "body", *m.BuildEngine); err != nil {
   171  		return err
   172  	}
   173  
   174  	return nil
   175  }
   176  
   177  func (m *V1BuildStatusResponse) validateBuildRequestID(formats strfmt.Registry) error {
   178  
   179  	if swag.IsZero(m.BuildRequestID) { // not required
   180  		return nil
   181  	}
   182  
   183  	if err := validate.FormatOf("build_request_id", "body", "uuid", m.BuildRequestID.String(), formats); err != nil {
   184  		return err
   185  	}
   186  
   187  	return nil
   188  }
   189  
   190  func (m *V1BuildStatusResponse) validateIsRetryable(formats strfmt.Registry) error {
   191  
   192  	if err := validate.Required("is_retryable", "body", bool(m.IsRetryable)); err != nil {
   193  		return err
   194  	}
   195  
   196  	return nil
   197  }
   198  
   199  func (m *V1BuildStatusResponse) validateLogURI(formats strfmt.Registry) error {
   200  
   201  	if swag.IsZero(m.LogURI) { // not required
   202  		return nil
   203  	}
   204  
   205  	if err := validate.FormatOf("log_uri", "body", "uri", m.LogURI.String(), formats); err != nil {
   206  		return err
   207  	}
   208  
   209  	return nil
   210  }
   211  
   212  func (m *V1BuildStatusResponse) validateRecipeID(formats strfmt.Registry) error {
   213  
   214  	if err := validate.Required("recipe_id", "body", m.RecipeID); err != nil {
   215  		return err
   216  	}
   217  
   218  	if err := validate.FormatOf("recipe_id", "body", "uuid", m.RecipeID.String(), formats); err != nil {
   219  		return err
   220  	}
   221  
   222  	return nil
   223  }
   224  
   225  func (m *V1BuildStatusResponse) validateTimestamp(formats strfmt.Registry) error {
   226  
   227  	if err := validate.Required("timestamp", "body", m.Timestamp); err != nil {
   228  		return err
   229  	}
   230  
   231  	if err := validate.FormatOf("timestamp", "body", "date-time", m.Timestamp.String(), formats); err != nil {
   232  		return err
   233  	}
   234  
   235  	return nil
   236  }
   237  
   238  var v1BuildStatusResponseTypeTypePropEnum []interface{}
   239  
   240  func init() {
   241  	var res []string
   242  	if err := json.Unmarshal([]byte(`["build_completed","build_failed","build_started"]`), &res); err != nil {
   243  		panic(err)
   244  	}
   245  	for _, v := range res {
   246  		v1BuildStatusResponseTypeTypePropEnum = append(v1BuildStatusResponseTypeTypePropEnum, v)
   247  	}
   248  }
   249  
   250  const (
   251  
   252  	// V1BuildStatusResponseTypeBuildCompleted captures enum value "build_completed"
   253  	V1BuildStatusResponseTypeBuildCompleted string = "build_completed"
   254  
   255  	// V1BuildStatusResponseTypeBuildFailed captures enum value "build_failed"
   256  	V1BuildStatusResponseTypeBuildFailed string = "build_failed"
   257  
   258  	// V1BuildStatusResponseTypeBuildStarted captures enum value "build_started"
   259  	V1BuildStatusResponseTypeBuildStarted string = "build_started"
   260  )
   261  
   262  // prop value enum
   263  func (m *V1BuildStatusResponse) validateTypeEnum(path, location string, value string) error {
   264  	if err := validate.Enum(path, location, value, v1BuildStatusResponseTypeTypePropEnum); err != nil {
   265  		return err
   266  	}
   267  	return nil
   268  }
   269  
   270  func (m *V1BuildStatusResponse) validateType(formats strfmt.Registry) error {
   271  
   272  	if err := validate.Required("type", "body", m.Type); err != nil {
   273  		return err
   274  	}
   275  
   276  	// value enum
   277  	if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
   278  		return err
   279  	}
   280  
   281  	return nil
   282  }
   283  
   284  // MarshalBinary interface implementation
   285  func (m *V1BuildStatusResponse) MarshalBinary() ([]byte, error) {
   286  	if m == nil {
   287  		return nil, nil
   288  	}
   289  	return swag.WriteJSON(m)
   290  }
   291  
   292  // UnmarshalBinary interface implementation
   293  func (m *V1BuildStatusResponse) UnmarshalBinary(b []byte) error {
   294  	var res V1BuildStatusResponse
   295  	if err := swag.ReadJSON(b, &res); err != nil {
   296  		return err
   297  	}
   298  	*m = res
   299  	return nil
   300  }