github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/v2_build_request.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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  )
    15  
    16  // V2BuildRequest Build Request V2
    17  //
    18  // A build request (v2) which is submitted to the Head Chef REST API to start a build from a build plan.
    19  // swagger:model v2BuildRequest
    20  type V2BuildRequest struct {
    21  
    22  	// Additional metadata about the build which should be included in any metrics about the build. This field has no schema validation and is passed through without parsing by Head Chef.
    23  	Annotations interface{} `json:"annotations,omitempty"`
    24  
    25  	// The ID of a recipe to generate a build plan from for the build
    26  	// Required: true
    27  	// Format: uuid
    28  	RecipeID *strfmt.UUID `json:"recipe_id"`
    29  
    30  	// requester
    31  	Requester *V2BuildRequestRequester `json:"requester,omitempty"`
    32  }
    33  
    34  // Validate validates this v2 build request
    35  func (m *V2BuildRequest) Validate(formats strfmt.Registry) error {
    36  	var res []error
    37  
    38  	if err := m.validateRecipeID(formats); err != nil {
    39  		res = append(res, err)
    40  	}
    41  
    42  	if err := m.validateRequester(formats); err != nil {
    43  		res = append(res, err)
    44  	}
    45  
    46  	if len(res) > 0 {
    47  		return errors.CompositeValidationError(res...)
    48  	}
    49  	return nil
    50  }
    51  
    52  func (m *V2BuildRequest) validateRecipeID(formats strfmt.Registry) error {
    53  
    54  	if err := validate.Required("recipe_id", "body", m.RecipeID); err != nil {
    55  		return err
    56  	}
    57  
    58  	if err := validate.FormatOf("recipe_id", "body", "uuid", m.RecipeID.String(), formats); err != nil {
    59  		return err
    60  	}
    61  
    62  	return nil
    63  }
    64  
    65  func (m *V2BuildRequest) validateRequester(formats strfmt.Registry) error {
    66  
    67  	if swag.IsZero(m.Requester) { // not required
    68  		return nil
    69  	}
    70  
    71  	if m.Requester != nil {
    72  		if err := m.Requester.Validate(formats); err != nil {
    73  			if ve, ok := err.(*errors.Validation); ok {
    74  				return ve.ValidateName("requester")
    75  			}
    76  			return err
    77  		}
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  // MarshalBinary interface implementation
    84  func (m *V2BuildRequest) MarshalBinary() ([]byte, error) {
    85  	if m == nil {
    86  		return nil, nil
    87  	}
    88  	return swag.WriteJSON(m)
    89  }
    90  
    91  // UnmarshalBinary interface implementation
    92  func (m *V2BuildRequest) UnmarshalBinary(b []byte) error {
    93  	var res V2BuildRequest
    94  	if err := swag.ReadJSON(b, &res); err != nil {
    95  		return err
    96  	}
    97  	*m = res
    98  	return nil
    99  }