github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/latest_timestamp.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 // LatestTimestamp LatestTimestamp 18 // 19 // The latest timestamp that should be used with other inventory service requests, such as solve requests 20 // 21 // swagger:model latestTimestamp 22 type LatestTimestamp struct { 23 24 // links 25 // Required: true 26 Links *SelfLink `json:"links"` 27 28 // timestamp 29 // Required: true 30 // Format: date-time 31 Timestamp *strfmt.DateTime `json:"timestamp"` 32 } 33 34 // Validate validates this latest timestamp 35 func (m *LatestTimestamp) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateLinks(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 *LatestTimestamp) validateLinks(formats strfmt.Registry) error { 53 54 if err := validate.Required("links", "body", m.Links); err != nil { 55 return err 56 } 57 58 if m.Links != nil { 59 if err := m.Links.Validate(formats); err != nil { 60 if ve, ok := err.(*errors.Validation); ok { 61 return ve.ValidateName("links") 62 } 63 return err 64 } 65 } 66 67 return nil 68 } 69 70 func (m *LatestTimestamp) validateTimestamp(formats strfmt.Registry) error { 71 72 if err := validate.Required("timestamp", "body", m.Timestamp); err != nil { 73 return err 74 } 75 76 if err := validate.FormatOf("timestamp", "body", "date-time", m.Timestamp.String(), formats); err != nil { 77 return err 78 } 79 80 return nil 81 } 82 83 // ContextValidate validate this latest timestamp based on the context it is used 84 func (m *LatestTimestamp) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 85 var res []error 86 87 if err := m.contextValidateLinks(ctx, formats); err != nil { 88 res = append(res, err) 89 } 90 91 if len(res) > 0 { 92 return errors.CompositeValidationError(res...) 93 } 94 return nil 95 } 96 97 func (m *LatestTimestamp) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { 98 99 if m.Links != nil { 100 if err := m.Links.ContextValidate(ctx, formats); err != nil { 101 if ve, ok := err.(*errors.Validation); ok { 102 return ve.ValidateName("links") 103 } 104 return err 105 } 106 } 107 108 return nil 109 } 110 111 // MarshalBinary interface implementation 112 func (m *LatestTimestamp) MarshalBinary() ([]byte, error) { 113 if m == nil { 114 return nil, nil 115 } 116 return swag.WriteJSON(m) 117 } 118 119 // UnmarshalBinary interface implementation 120 func (m *LatestTimestamp) UnmarshalBinary(b []byte) error { 121 var res LatestTimestamp 122 if err := swag.ReadJSON(b, &res); err != nil { 123 return err 124 } 125 *m = res 126 return nil 127 }