github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/commit_change.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 "encoding/json" 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 // CommitChange commit change 19 // 20 // swagger:model CommitChange 21 type CommitChange struct { 22 23 // The namespace for this requirement, this lets us identify the type, as well as any additional information (eg. what language a package belongs to) 24 Namespace string `json:"namespace,omitempty"` 25 26 // operation 27 // Enum: [added removed updated] 28 Operation string `json:"operation,omitempty"` 29 30 // The name of the requirement (a requirement can be a package, a language, a clib, etc) 31 Requirement string `json:"requirement,omitempty"` 32 33 // Deprecated; use version_constraints instead. 34 VersionConstraint string `json:"version_constraint,omitempty"` 35 36 // Deprecated; use version_constraints_old instead. 37 VersionConstraintOld string `json:"version_constraint_old,omitempty"` 38 39 // version constraints 40 VersionConstraints Constraints `json:"version_constraints,omitempty"` 41 42 // version constraints old 43 VersionConstraintsOld Constraints `json:"version_constraints_old,omitempty"` 44 } 45 46 // Validate validates this commit change 47 func (m *CommitChange) Validate(formats strfmt.Registry) error { 48 var res []error 49 50 if err := m.validateOperation(formats); err != nil { 51 res = append(res, err) 52 } 53 54 if err := m.validateVersionConstraints(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if err := m.validateVersionConstraintsOld(formats); err != nil { 59 res = append(res, err) 60 } 61 62 if len(res) > 0 { 63 return errors.CompositeValidationError(res...) 64 } 65 return nil 66 } 67 68 var commitChangeTypeOperationPropEnum []interface{} 69 70 func init() { 71 var res []string 72 if err := json.Unmarshal([]byte(`["added","removed","updated"]`), &res); err != nil { 73 panic(err) 74 } 75 for _, v := range res { 76 commitChangeTypeOperationPropEnum = append(commitChangeTypeOperationPropEnum, v) 77 } 78 } 79 80 const ( 81 82 // CommitChangeOperationAdded captures enum value "added" 83 CommitChangeOperationAdded string = "added" 84 85 // CommitChangeOperationRemoved captures enum value "removed" 86 CommitChangeOperationRemoved string = "removed" 87 88 // CommitChangeOperationUpdated captures enum value "updated" 89 CommitChangeOperationUpdated string = "updated" 90 ) 91 92 // prop value enum 93 func (m *CommitChange) validateOperationEnum(path, location string, value string) error { 94 if err := validate.EnumCase(path, location, value, commitChangeTypeOperationPropEnum, true); err != nil { 95 return err 96 } 97 return nil 98 } 99 100 func (m *CommitChange) validateOperation(formats strfmt.Registry) error { 101 if swag.IsZero(m.Operation) { // not required 102 return nil 103 } 104 105 // value enum 106 if err := m.validateOperationEnum("operation", "body", m.Operation); err != nil { 107 return err 108 } 109 110 return nil 111 } 112 113 func (m *CommitChange) validateVersionConstraints(formats strfmt.Registry) error { 114 if swag.IsZero(m.VersionConstraints) { // not required 115 return nil 116 } 117 118 if err := m.VersionConstraints.Validate(formats); err != nil { 119 if ve, ok := err.(*errors.Validation); ok { 120 return ve.ValidateName("version_constraints") 121 } 122 return err 123 } 124 125 return nil 126 } 127 128 func (m *CommitChange) validateVersionConstraintsOld(formats strfmt.Registry) error { 129 if swag.IsZero(m.VersionConstraintsOld) { // not required 130 return nil 131 } 132 133 if err := m.VersionConstraintsOld.Validate(formats); err != nil { 134 if ve, ok := err.(*errors.Validation); ok { 135 return ve.ValidateName("version_constraints_old") 136 } 137 return err 138 } 139 140 return nil 141 } 142 143 // ContextValidate validate this commit change based on the context it is used 144 func (m *CommitChange) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 145 var res []error 146 147 if err := m.contextValidateVersionConstraints(ctx, formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.contextValidateVersionConstraintsOld(ctx, formats); err != nil { 152 res = append(res, err) 153 } 154 155 if len(res) > 0 { 156 return errors.CompositeValidationError(res...) 157 } 158 return nil 159 } 160 161 func (m *CommitChange) contextValidateVersionConstraints(ctx context.Context, formats strfmt.Registry) error { 162 163 if err := m.VersionConstraints.ContextValidate(ctx, formats); err != nil { 164 if ve, ok := err.(*errors.Validation); ok { 165 return ve.ValidateName("version_constraints") 166 } 167 return err 168 } 169 170 return nil 171 } 172 173 func (m *CommitChange) contextValidateVersionConstraintsOld(ctx context.Context, formats strfmt.Registry) error { 174 175 if err := m.VersionConstraintsOld.ContextValidate(ctx, formats); err != nil { 176 if ve, ok := err.(*errors.Validation); ok { 177 return ve.ValidateName("version_constraints_old") 178 } 179 return err 180 } 181 182 return nil 183 } 184 185 // MarshalBinary interface implementation 186 func (m *CommitChange) MarshalBinary() ([]byte, error) { 187 if m == nil { 188 return nil, nil 189 } 190 return swag.WriteJSON(m) 191 } 192 193 // UnmarshalBinary interface implementation 194 func (m *CommitChange) UnmarshalBinary(b []byte) error { 195 var res CommitChange 196 if err := swag.ReadJSON(b, &res); err != nil { 197 return err 198 } 199 *m = res 200 return nil 201 }