github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/revisioned_resource.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package inventory_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  
    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  // RevisionedResource Revisioned Resource
    18  //
    19  // Properties shared by all revisioned resources
    20  //
    21  // swagger:model revisionedResource
    22  type RevisionedResource struct {
    23  
    24  	// The revision number of this revision of the resource. This number increases monotonically with each new revision.
    25  	// Required: true
    26  	// Minimum: 1
    27  	Revision *int64 `json:"revision"`
    28  
    29  	// The date and time at which this revision of the resource was created
    30  	// Required: true
    31  	// Format: date-time
    32  	RevisionTimestamp *strfmt.DateTime `json:"revision_timestamp"`
    33  }
    34  
    35  // Validate validates this revisioned resource
    36  func (m *RevisionedResource) Validate(formats strfmt.Registry) error {
    37  	var res []error
    38  
    39  	if err := m.validateRevision(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if err := m.validateRevisionTimestamp(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if len(res) > 0 {
    48  		return errors.CompositeValidationError(res...)
    49  	}
    50  	return nil
    51  }
    52  
    53  func (m *RevisionedResource) validateRevision(formats strfmt.Registry) error {
    54  
    55  	if err := validate.Required("revision", "body", m.Revision); err != nil {
    56  		return err
    57  	}
    58  
    59  	if err := validate.MinimumInt("revision", "body", *m.Revision, 1, false); err != nil {
    60  		return err
    61  	}
    62  
    63  	return nil
    64  }
    65  
    66  func (m *RevisionedResource) validateRevisionTimestamp(formats strfmt.Registry) error {
    67  
    68  	if err := validate.Required("revision_timestamp", "body", m.RevisionTimestamp); err != nil {
    69  		return err
    70  	}
    71  
    72  	if err := validate.FormatOf("revision_timestamp", "body", "date-time", m.RevisionTimestamp.String(), formats); err != nil {
    73  		return err
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  // ContextValidate validates this revisioned resource based on context it is used
    80  func (m *RevisionedResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    81  	return nil
    82  }
    83  
    84  // MarshalBinary interface implementation
    85  func (m *RevisionedResource) MarshalBinary() ([]byte, error) {
    86  	if m == nil {
    87  		return nil, nil
    88  	}
    89  	return swag.WriteJSON(m)
    90  }
    91  
    92  // UnmarshalBinary interface implementation
    93  func (m *RevisionedResource) UnmarshalBinary(b []byte) error {
    94  	var res RevisionedResource
    95  	if err := swag.ReadJSON(b, &res); err != nil {
    96  		return err
    97  	}
    98  	*m = res
    99  	return nil
   100  }