github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/buildlogstream/buildlogstream_models/pkg_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  	"github.com/go-openapi/errors"
    10  	"github.com/go-openapi/strfmt"
    11  	"github.com/go-openapi/swag"
    12  	"github.com/go-openapi/validate"
    13  )
    14  
    15  // PkgBuildCompleted Package Build Completed
    16  //
    17  // A message indicating that a requested package build has completed.
    18  //
    19  // swagger:model pkgBuildCompleted
    20  type PkgBuildCompleted struct {
    21  
    22  	// artifact
    23  	// Required: true
    24  	Artifact *Artifact `json:"artifact"`
    25  
    26  	// ingredient id
    27  	// Required: true
    28  	// Format: uuid
    29  	IngredientID *strfmt.UUID `json:"ingredient_id"`
    30  
    31  	// ingredient version
    32  	// Required: true
    33  	IngredientVersion *string `json:"ingredient_version"`
    34  
    35  	// The percentage through the total number of packages to be built in the current tast
    36  	// Maximum: 100
    37  	// Minimum: 0
    38  	Percent *int64 `json:"percent,omitempty"`
    39  
    40  	// The current position in the list of packages to be built in the current task
    41  	// Minimum: 0
    42  	Sequence *int64 `json:"sequence,omitempty"`
    43  
    44  	// The current total number of packages to be built in the current task
    45  	// Minimum: 0
    46  	Total *int64 `json:"total,omitempty"`
    47  }
    48  
    49  // Validate validates this pkg build completed
    50  func (m *PkgBuildCompleted) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateArtifact(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateIngredientID(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateIngredientVersion(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validatePercent(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateSequence(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateTotal(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if len(res) > 0 {
    78  		return errors.CompositeValidationError(res...)
    79  	}
    80  	return nil
    81  }
    82  
    83  func (m *PkgBuildCompleted) validateArtifact(formats strfmt.Registry) error {
    84  
    85  	if err := validate.Required("artifact", "body", m.Artifact); err != nil {
    86  		return err
    87  	}
    88  
    89  	if m.Artifact != nil {
    90  		if err := m.Artifact.Validate(formats); err != nil {
    91  			if ve, ok := err.(*errors.Validation); ok {
    92  				return ve.ValidateName("artifact")
    93  			}
    94  			return err
    95  		}
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  func (m *PkgBuildCompleted) validateIngredientID(formats strfmt.Registry) error {
   102  
   103  	if err := validate.Required("ingredient_id", "body", m.IngredientID); err != nil {
   104  		return err
   105  	}
   106  
   107  	if err := validate.FormatOf("ingredient_id", "body", "uuid", m.IngredientID.String(), formats); err != nil {
   108  		return err
   109  	}
   110  
   111  	return nil
   112  }
   113  
   114  func (m *PkgBuildCompleted) validateIngredientVersion(formats strfmt.Registry) error {
   115  
   116  	if err := validate.Required("ingredient_version", "body", m.IngredientVersion); err != nil {
   117  		return err
   118  	}
   119  
   120  	return nil
   121  }
   122  
   123  func (m *PkgBuildCompleted) validatePercent(formats strfmt.Registry) error {
   124  
   125  	if swag.IsZero(m.Percent) { // not required
   126  		return nil
   127  	}
   128  
   129  	if err := validate.MinimumInt("percent", "body", int64(*m.Percent), 0, false); err != nil {
   130  		return err
   131  	}
   132  
   133  	if err := validate.MaximumInt("percent", "body", int64(*m.Percent), 100, false); err != nil {
   134  		return err
   135  	}
   136  
   137  	return nil
   138  }
   139  
   140  func (m *PkgBuildCompleted) validateSequence(formats strfmt.Registry) error {
   141  
   142  	if swag.IsZero(m.Sequence) { // not required
   143  		return nil
   144  	}
   145  
   146  	if err := validate.MinimumInt("sequence", "body", int64(*m.Sequence), 0, false); err != nil {
   147  		return err
   148  	}
   149  
   150  	return nil
   151  }
   152  
   153  func (m *PkgBuildCompleted) validateTotal(formats strfmt.Registry) error {
   154  
   155  	if swag.IsZero(m.Total) { // not required
   156  		return nil
   157  	}
   158  
   159  	if err := validate.MinimumInt("total", "body", int64(*m.Total), 0, false); err != nil {
   160  		return err
   161  	}
   162  
   163  	return nil
   164  }
   165  
   166  // MarshalBinary interface implementation
   167  func (m *PkgBuildCompleted) MarshalBinary() ([]byte, error) {
   168  	if m == nil {
   169  		return nil, nil
   170  	}
   171  	return swag.WriteJSON(m)
   172  }
   173  
   174  // UnmarshalBinary interface implementation
   175  func (m *PkgBuildCompleted) UnmarshalBinary(b []byte) error {
   176  	var res PkgBuildCompleted
   177  	if err := swag.ReadJSON(b, &res); err != nil {
   178  		return err
   179  	}
   180  	*m = res
   181  	return nil
   182  }