github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/checkpoint.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 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 ) 15 16 // Checkpoint checkpoint 17 // 18 // swagger:model Checkpoint 19 type Checkpoint struct { 20 21 // The namespace for this requirement, this lets us identify the type, as well as any additional information (eg. what language a package belongs to) 22 Namespace string `json:"namespace,omitempty"` 23 24 // The name of the requirement (a requirement can be a package, a language, a clib, etc) 25 Requirement string `json:"requirement,omitempty"` 26 27 // Deprecated; use version_constraints instead. 28 VersionConstraint string `json:"version_constraint,omitempty"` 29 30 // version constraints 31 VersionConstraints Constraints `json:"version_constraints,omitempty"` 32 } 33 34 // Validate validates this checkpoint 35 func (m *Checkpoint) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateVersionConstraints(formats); err != nil { 39 res = append(res, err) 40 } 41 42 if len(res) > 0 { 43 return errors.CompositeValidationError(res...) 44 } 45 return nil 46 } 47 48 func (m *Checkpoint) validateVersionConstraints(formats strfmt.Registry) error { 49 if swag.IsZero(m.VersionConstraints) { // not required 50 return nil 51 } 52 53 if err := m.VersionConstraints.Validate(formats); err != nil { 54 if ve, ok := err.(*errors.Validation); ok { 55 return ve.ValidateName("version_constraints") 56 } 57 return err 58 } 59 60 return nil 61 } 62 63 // ContextValidate validate this checkpoint based on the context it is used 64 func (m *Checkpoint) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 65 var res []error 66 67 if err := m.contextValidateVersionConstraints(ctx, formats); err != nil { 68 res = append(res, err) 69 } 70 71 if len(res) > 0 { 72 return errors.CompositeValidationError(res...) 73 } 74 return nil 75 } 76 77 func (m *Checkpoint) contextValidateVersionConstraints(ctx context.Context, formats strfmt.Registry) error { 78 79 if err := m.VersionConstraints.ContextValidate(ctx, formats); err != nil { 80 if ve, ok := err.(*errors.Validation); ok { 81 return ve.ValidateName("version_constraints") 82 } 83 return err 84 } 85 86 return nil 87 } 88 89 // MarshalBinary interface implementation 90 func (m *Checkpoint) MarshalBinary() ([]byte, error) { 91 if m == nil { 92 return nil, nil 93 } 94 return swag.WriteJSON(m) 95 } 96 97 // UnmarshalBinary interface implementation 98 func (m *Checkpoint) UnmarshalBinary(b []byte) error { 99 var res Checkpoint 100 if err := swag.ReadJSON(b, &res); err != nil { 101 return err 102 } 103 *m = res 104 return nil 105 }