github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/order_info.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  // OrderInfo order info
    19  //
    20  // swagger:model OrderInfo
    21  type OrderInfo struct {
    22  
    23  	// annotations
    24  	Annotations interface{} `json:"annotations,omitempty"`
    25  
    26  	// checkpoint
    27  	Checkpoint []*Checkpoint `json:"checkpoint"`
    28  
    29  	// timestamp
    30  	// Format: date-time
    31  	Timestamp strfmt.DateTime `json:"timestamp,omitempty"`
    32  }
    33  
    34  // Validate validates this order info
    35  func (m *OrderInfo) Validate(formats strfmt.Registry) error {
    36  	var res []error
    37  
    38  	if err := m.validateCheckpoint(formats); err != nil {
    39  		res = append(res, err)
    40  	}
    41  
    42  	if err := m.validateTimestamp(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 *OrderInfo) validateCheckpoint(formats strfmt.Registry) error {
    53  	if swag.IsZero(m.Checkpoint) { // not required
    54  		return nil
    55  	}
    56  
    57  	for i := 0; i < len(m.Checkpoint); i++ {
    58  		if swag.IsZero(m.Checkpoint[i]) { // not required
    59  			continue
    60  		}
    61  
    62  		if m.Checkpoint[i] != nil {
    63  			if err := m.Checkpoint[i].Validate(formats); err != nil {
    64  				if ve, ok := err.(*errors.Validation); ok {
    65  					return ve.ValidateName("checkpoint" + "." + strconv.Itoa(i))
    66  				}
    67  				return err
    68  			}
    69  		}
    70  
    71  	}
    72  
    73  	return nil
    74  }
    75  
    76  func (m *OrderInfo) validateTimestamp(formats strfmt.Registry) error {
    77  	if swag.IsZero(m.Timestamp) { // not required
    78  		return nil
    79  	}
    80  
    81  	if err := validate.FormatOf("timestamp", "body", "date-time", m.Timestamp.String(), formats); err != nil {
    82  		return err
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  // ContextValidate validate this order info based on the context it is used
    89  func (m *OrderInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    90  	var res []error
    91  
    92  	if err := m.contextValidateCheckpoint(ctx, formats); err != nil {
    93  		res = append(res, err)
    94  	}
    95  
    96  	if len(res) > 0 {
    97  		return errors.CompositeValidationError(res...)
    98  	}
    99  	return nil
   100  }
   101  
   102  func (m *OrderInfo) contextValidateCheckpoint(ctx context.Context, formats strfmt.Registry) error {
   103  
   104  	for i := 0; i < len(m.Checkpoint); i++ {
   105  
   106  		if m.Checkpoint[i] != nil {
   107  			if err := m.Checkpoint[i].ContextValidate(ctx, formats); err != nil {
   108  				if ve, ok := err.(*errors.Validation); ok {
   109  					return ve.ValidateName("checkpoint" + "." + strconv.Itoa(i))
   110  				}
   111  				return err
   112  			}
   113  		}
   114  
   115  	}
   116  
   117  	return nil
   118  }
   119  
   120  // MarshalBinary interface implementation
   121  func (m *OrderInfo) MarshalBinary() ([]byte, error) {
   122  	if m == nil {
   123  		return nil, nil
   124  	}
   125  	return swag.WriteJSON(m)
   126  }
   127  
   128  // UnmarshalBinary interface implementation
   129  func (m *OrderInfo) UnmarshalBinary(b []byte) error {
   130  	var res OrderInfo
   131  	if err := swag.ReadJSON(b, &res); err != nil {
   132  		return err
   133  	}
   134  	*m = res
   135  	return nil
   136  }