github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/commit_editable.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 // CommitEditable commit editable 19 // 20 // swagger:model CommitEditable 21 type CommitEditable struct { 22 23 // An anonymous id used to help track the creator of headless commits. 24 AnonID string `json:"anonID,omitempty"` 25 26 // When resolving dependencies, updates made after this time will be ignored. 27 // Format: date-time 28 AtTime *strfmt.DateTime `json:"atTime,omitempty"` 29 30 // What changed in this commit. 31 Changeset []*CommitChangeEditable `json:"changeset"` 32 33 // A message that describes what was changed in this commit. 34 Message string `json:"message,omitempty"` 35 36 // The parent commit ID that this commit originates from. 37 // Format: uuid 38 ParentCommitID strfmt.UUID `json:"parentCommitID,omitempty"` 39 40 // An id populated by the state tool. 41 UniqueDeviceID string `json:"uniqueDeviceID,omitempty"` 42 } 43 44 // Validate validates this commit editable 45 func (m *CommitEditable) Validate(formats strfmt.Registry) error { 46 var res []error 47 48 if err := m.validateAtTime(formats); err != nil { 49 res = append(res, err) 50 } 51 52 if err := m.validateChangeset(formats); err != nil { 53 res = append(res, err) 54 } 55 56 if err := m.validateParentCommitID(formats); err != nil { 57 res = append(res, err) 58 } 59 60 if len(res) > 0 { 61 return errors.CompositeValidationError(res...) 62 } 63 return nil 64 } 65 66 func (m *CommitEditable) validateAtTime(formats strfmt.Registry) error { 67 if swag.IsZero(m.AtTime) { // not required 68 return nil 69 } 70 71 if err := validate.FormatOf("atTime", "body", "date-time", m.AtTime.String(), formats); err != nil { 72 return err 73 } 74 75 return nil 76 } 77 78 func (m *CommitEditable) validateChangeset(formats strfmt.Registry) error { 79 if swag.IsZero(m.Changeset) { // not required 80 return nil 81 } 82 83 for i := 0; i < len(m.Changeset); i++ { 84 if swag.IsZero(m.Changeset[i]) { // not required 85 continue 86 } 87 88 if m.Changeset[i] != nil { 89 if err := m.Changeset[i].Validate(formats); err != nil { 90 if ve, ok := err.(*errors.Validation); ok { 91 return ve.ValidateName("changeset" + "." + strconv.Itoa(i)) 92 } 93 return err 94 } 95 } 96 97 } 98 99 return nil 100 } 101 102 func (m *CommitEditable) validateParentCommitID(formats strfmt.Registry) error { 103 if swag.IsZero(m.ParentCommitID) { // not required 104 return nil 105 } 106 107 if err := validate.FormatOf("parentCommitID", "body", "uuid", m.ParentCommitID.String(), formats); err != nil { 108 return err 109 } 110 111 return nil 112 } 113 114 // ContextValidate validate this commit editable based on the context it is used 115 func (m *CommitEditable) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 116 var res []error 117 118 if err := m.contextValidateChangeset(ctx, formats); err != nil { 119 res = append(res, err) 120 } 121 122 if len(res) > 0 { 123 return errors.CompositeValidationError(res...) 124 } 125 return nil 126 } 127 128 func (m *CommitEditable) contextValidateChangeset(ctx context.Context, formats strfmt.Registry) error { 129 130 for i := 0; i < len(m.Changeset); i++ { 131 132 if m.Changeset[i] != nil { 133 if err := m.Changeset[i].ContextValidate(ctx, formats); err != nil { 134 if ve, ok := err.(*errors.Validation); ok { 135 return ve.ValidateName("changeset" + "." + strconv.Itoa(i)) 136 } 137 return err 138 } 139 } 140 141 } 142 143 return nil 144 } 145 146 // MarshalBinary interface implementation 147 func (m *CommitEditable) MarshalBinary() ([]byte, error) { 148 if m == nil { 149 return nil, nil 150 } 151 return swag.WriteJSON(m) 152 } 153 154 // UnmarshalBinary interface implementation 155 func (m *CommitEditable) UnmarshalBinary(b []byte) error { 156 var res CommitEditable 157 if err := swag.ReadJSON(b, &res); err != nil { 158 return err 159 } 160 *m = res 161 return nil 162 }