github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/order.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package mono_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  	"context"
    10  	"strconv"
    11  
    12  	"github.com/go-openapi/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // Order order
    19  //
    20  // swagger:model Order
    21  type Order struct {
    22  
    23  	// annotations
    24  	Annotations interface{} `json:"annotations,omitempty"`
    25  
    26  	// Platform build flags
    27  	BuildFlags []*BuildFlag `json:"build_flags"`
    28  
    29  	// Flags for camel
    30  	CamelFlags []string `json:"camel_flags"`
    31  
    32  	// Identifier for the order, currently arbitrary
    33  	// Format: uuid
    34  	OrderID strfmt.UUID `json:"order_id,omitempty"`
    35  
    36  	// inventory API's UUIDs of requested platforms
    37  	Platforms []strfmt.UUID `json:"platforms"`
    38  
    39  	// requirements
    40  	Requirements []*SolverRequirement `json:"requirements"`
    41  
    42  	// solver version
    43  	SolverVersion *int64 `json:"solver_version,omitempty"`
    44  
    45  	// timestamp
    46  	// Format: date-time
    47  	Timestamp strfmt.DateTime `json:"timestamp,omitempty"`
    48  }
    49  
    50  // Validate validates this order
    51  func (m *Order) Validate(formats strfmt.Registry) error {
    52  	var res []error
    53  
    54  	if err := m.validateBuildFlags(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if err := m.validateOrderID(formats); err != nil {
    59  		res = append(res, err)
    60  	}
    61  
    62  	if err := m.validatePlatforms(formats); err != nil {
    63  		res = append(res, err)
    64  	}
    65  
    66  	if err := m.validateRequirements(formats); err != nil {
    67  		res = append(res, err)
    68  	}
    69  
    70  	if err := m.validateTimestamp(formats); err != nil {
    71  		res = append(res, err)
    72  	}
    73  
    74  	if len(res) > 0 {
    75  		return errors.CompositeValidationError(res...)
    76  	}
    77  	return nil
    78  }
    79  
    80  func (m *Order) validateBuildFlags(formats strfmt.Registry) error {
    81  	if swag.IsZero(m.BuildFlags) { // not required
    82  		return nil
    83  	}
    84  
    85  	for i := 0; i < len(m.BuildFlags); i++ {
    86  		if swag.IsZero(m.BuildFlags[i]) { // not required
    87  			continue
    88  		}
    89  
    90  		if m.BuildFlags[i] != nil {
    91  			if err := m.BuildFlags[i].Validate(formats); err != nil {
    92  				if ve, ok := err.(*errors.Validation); ok {
    93  					return ve.ValidateName("build_flags" + "." + strconv.Itoa(i))
    94  				}
    95  				return err
    96  			}
    97  		}
    98  
    99  	}
   100  
   101  	return nil
   102  }
   103  
   104  func (m *Order) validateOrderID(formats strfmt.Registry) error {
   105  	if swag.IsZero(m.OrderID) { // not required
   106  		return nil
   107  	}
   108  
   109  	if err := validate.FormatOf("order_id", "body", "uuid", m.OrderID.String(), formats); err != nil {
   110  		return err
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  func (m *Order) validatePlatforms(formats strfmt.Registry) error {
   117  	if swag.IsZero(m.Platforms) { // not required
   118  		return nil
   119  	}
   120  
   121  	for i := 0; i < len(m.Platforms); i++ {
   122  
   123  		if err := validate.FormatOf("platforms"+"."+strconv.Itoa(i), "body", "uuid", m.Platforms[i].String(), formats); err != nil {
   124  			return err
   125  		}
   126  
   127  	}
   128  
   129  	return nil
   130  }
   131  
   132  func (m *Order) validateRequirements(formats strfmt.Registry) error {
   133  	if swag.IsZero(m.Requirements) { // not required
   134  		return nil
   135  	}
   136  
   137  	for i := 0; i < len(m.Requirements); i++ {
   138  		if swag.IsZero(m.Requirements[i]) { // not required
   139  			continue
   140  		}
   141  
   142  		if m.Requirements[i] != nil {
   143  			if err := m.Requirements[i].Validate(formats); err != nil {
   144  				if ve, ok := err.(*errors.Validation); ok {
   145  					return ve.ValidateName("requirements" + "." + strconv.Itoa(i))
   146  				}
   147  				return err
   148  			}
   149  		}
   150  
   151  	}
   152  
   153  	return nil
   154  }
   155  
   156  func (m *Order) validateTimestamp(formats strfmt.Registry) error {
   157  	if swag.IsZero(m.Timestamp) { // not required
   158  		return nil
   159  	}
   160  
   161  	if err := validate.FormatOf("timestamp", "body", "date-time", m.Timestamp.String(), formats); err != nil {
   162  		return err
   163  	}
   164  
   165  	return nil
   166  }
   167  
   168  // ContextValidate validate this order based on the context it is used
   169  func (m *Order) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   170  	var res []error
   171  
   172  	if err := m.contextValidateBuildFlags(ctx, formats); err != nil {
   173  		res = append(res, err)
   174  	}
   175  
   176  	if err := m.contextValidateRequirements(ctx, formats); err != nil {
   177  		res = append(res, err)
   178  	}
   179  
   180  	if len(res) > 0 {
   181  		return errors.CompositeValidationError(res...)
   182  	}
   183  	return nil
   184  }
   185  
   186  func (m *Order) contextValidateBuildFlags(ctx context.Context, formats strfmt.Registry) error {
   187  
   188  	for i := 0; i < len(m.BuildFlags); i++ {
   189  
   190  		if m.BuildFlags[i] != nil {
   191  			if err := m.BuildFlags[i].ContextValidate(ctx, formats); err != nil {
   192  				if ve, ok := err.(*errors.Validation); ok {
   193  					return ve.ValidateName("build_flags" + "." + strconv.Itoa(i))
   194  				}
   195  				return err
   196  			}
   197  		}
   198  
   199  	}
   200  
   201  	return nil
   202  }
   203  
   204  func (m *Order) contextValidateRequirements(ctx context.Context, formats strfmt.Registry) error {
   205  
   206  	for i := 0; i < len(m.Requirements); i++ {
   207  
   208  		if m.Requirements[i] != nil {
   209  			if err := m.Requirements[i].ContextValidate(ctx, formats); err != nil {
   210  				if ve, ok := err.(*errors.Validation); ok {
   211  					return ve.ValidateName("requirements" + "." + strconv.Itoa(i))
   212  				}
   213  				return err
   214  			}
   215  		}
   216  
   217  	}
   218  
   219  	return nil
   220  }
   221  
   222  // MarshalBinary interface implementation
   223  func (m *Order) MarshalBinary() ([]byte, error) {
   224  	if m == nil {
   225  		return nil, nil
   226  	}
   227  	return swag.WriteJSON(m)
   228  }
   229  
   230  // UnmarshalBinary interface implementation
   231  func (m *Order) UnmarshalBinary(b []byte) error {
   232  	var res Order
   233  	if err := swag.ReadJSON(b, &res); err != nil {
   234  		return err
   235  	}
   236  	*m = res
   237  	return nil
   238  }