github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/commit_change_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 "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 // CommitChangeEditable commit change editable 19 // 20 // swagger:model CommitChangeEditable 21 type CommitChangeEditable 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 // version constraints 37 VersionConstraints Constraints `json:"version_constraints,omitempty"` 38 } 39 40 // Validate validates this commit change editable 41 func (m *CommitChangeEditable) Validate(formats strfmt.Registry) error { 42 var res []error 43 44 if err := m.validateOperation(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if err := m.validateVersionConstraints(formats); err != nil { 49 res = append(res, err) 50 } 51 52 if len(res) > 0 { 53 return errors.CompositeValidationError(res...) 54 } 55 return nil 56 } 57 58 var commitChangeEditableTypeOperationPropEnum []interface{} 59 60 func init() { 61 var res []string 62 if err := json.Unmarshal([]byte(`["added","removed","updated"]`), &res); err != nil { 63 panic(err) 64 } 65 for _, v := range res { 66 commitChangeEditableTypeOperationPropEnum = append(commitChangeEditableTypeOperationPropEnum, v) 67 } 68 } 69 70 const ( 71 72 // CommitChangeEditableOperationAdded captures enum value "added" 73 CommitChangeEditableOperationAdded string = "added" 74 75 // CommitChangeEditableOperationRemoved captures enum value "removed" 76 CommitChangeEditableOperationRemoved string = "removed" 77 78 // CommitChangeEditableOperationUpdated captures enum value "updated" 79 CommitChangeEditableOperationUpdated string = "updated" 80 ) 81 82 // prop value enum 83 func (m *CommitChangeEditable) validateOperationEnum(path, location string, value string) error { 84 if err := validate.EnumCase(path, location, value, commitChangeEditableTypeOperationPropEnum, true); err != nil { 85 return err 86 } 87 return nil 88 } 89 90 func (m *CommitChangeEditable) validateOperation(formats strfmt.Registry) error { 91 if swag.IsZero(m.Operation) { // not required 92 return nil 93 } 94 95 // value enum 96 if err := m.validateOperationEnum("operation", "body", m.Operation); err != nil { 97 return err 98 } 99 100 return nil 101 } 102 103 func (m *CommitChangeEditable) validateVersionConstraints(formats strfmt.Registry) error { 104 if swag.IsZero(m.VersionConstraints) { // not required 105 return nil 106 } 107 108 if err := m.VersionConstraints.Validate(formats); err != nil { 109 if ve, ok := err.(*errors.Validation); ok { 110 return ve.ValidateName("version_constraints") 111 } 112 return err 113 } 114 115 return nil 116 } 117 118 // ContextValidate validate this commit change editable based on the context it is used 119 func (m *CommitChangeEditable) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 120 var res []error 121 122 if err := m.contextValidateVersionConstraints(ctx, formats); err != nil { 123 res = append(res, err) 124 } 125 126 if len(res) > 0 { 127 return errors.CompositeValidationError(res...) 128 } 129 return nil 130 } 131 132 func (m *CommitChangeEditable) contextValidateVersionConstraints(ctx context.Context, formats strfmt.Registry) error { 133 134 if err := m.VersionConstraints.ContextValidate(ctx, formats); err != nil { 135 if ve, ok := err.(*errors.Validation); ok { 136 return ve.ValidateName("version_constraints") 137 } 138 return err 139 } 140 141 return nil 142 } 143 144 // MarshalBinary interface implementation 145 func (m *CommitChangeEditable) MarshalBinary() ([]byte, error) { 146 if m == nil { 147 return nil, nil 148 } 149 return swag.WriteJSON(m) 150 } 151 152 // UnmarshalBinary interface implementation 153 func (m *CommitChangeEditable) UnmarshalBinary(b []byte) error { 154 var res CommitChangeEditable 155 if err := swag.ReadJSON(b, &res); err != nil { 156 return err 157 } 158 *m = res 159 return nil 160 }