github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/buildlogstream/buildlogstream_models/build_completed.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  	"strconv"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // BuildCompleted Build Completed
    18  //
    19  // A message indicating that a requested build has been completed.
    20  //
    21  // swagger:model BuildCompleted
    22  type BuildCompleted struct {
    23  
    24  	// An array containing all the artifacts that make up this build.
    25  	// Required: true
    26  	Artifacts []*Artifact `json:"artifacts"`
    27  
    28  	// An S3 URI containing the log for this build.
    29  	// Format: uri
    30  	LogURI strfmt.URI `json:"log_uri,omitempty"`
    31  
    32  	// A user-facing message describing the build results.
    33  	Message string `json:"message,omitempty"`
    34  }
    35  
    36  // Validate validates this build completed
    37  func (m *BuildCompleted) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	if err := m.validateArtifacts(formats); err != nil {
    41  		res = append(res, err)
    42  	}
    43  
    44  	if err := m.validateLogURI(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if len(res) > 0 {
    49  		return errors.CompositeValidationError(res...)
    50  	}
    51  	return nil
    52  }
    53  
    54  func (m *BuildCompleted) validateArtifacts(formats strfmt.Registry) error {
    55  
    56  	if err := validate.Required("artifacts", "body", m.Artifacts); err != nil {
    57  		return err
    58  	}
    59  
    60  	for i := 0; i < len(m.Artifacts); i++ {
    61  		if swag.IsZero(m.Artifacts[i]) { // not required
    62  			continue
    63  		}
    64  
    65  		if m.Artifacts[i] != nil {
    66  			if err := m.Artifacts[i].Validate(formats); err != nil {
    67  				if ve, ok := err.(*errors.Validation); ok {
    68  					return ve.ValidateName("artifacts" + "." + strconv.Itoa(i))
    69  				}
    70  				return err
    71  			}
    72  		}
    73  
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  func (m *BuildCompleted) validateLogURI(formats strfmt.Registry) error {
    80  
    81  	if swag.IsZero(m.LogURI) { // not required
    82  		return nil
    83  	}
    84  
    85  	if err := validate.FormatOf("log_uri", "body", "uri", m.LogURI.String(), formats); err != nil {
    86  		return err
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  // MarshalBinary interface implementation
    93  func (m *BuildCompleted) MarshalBinary() ([]byte, error) {
    94  	if m == nil {
    95  		return nil, nil
    96  	}
    97  	return swag.WriteJSON(m)
    98  }
    99  
   100  // UnmarshalBinary interface implementation
   101  func (m *BuildCompleted) UnmarshalBinary(b []byte) error {
   102  	var res BuildCompleted
   103  	if err := swag.ReadJSON(b, &res); err != nil {
   104  		return err
   105  	}
   106  	*m = res
   107  	return nil
   108  }