github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/branch.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 // Branch branch 19 // 20 // swagger:model Branch 21 type Branch struct { 22 23 // The branch id 24 // Format: uuid 25 BranchID strfmt.UUID `json:"branchID,omitempty"` 26 27 // The commit that this branch is currently pointing at 28 // Format: uuid 29 CommitID *strfmt.UUID `json:"commitID,omitempty"` 30 31 // Whether this is the default branch for this project 32 Default bool `json:"default,omitempty"` 33 34 // label 35 Label string `json:"label,omitempty"` 36 37 // The project that this branch belongs to 38 // Format: uuid 39 ProjectID strfmt.UUID `json:"projectID,omitempty"` 40 41 // The tracking method used 42 // Enum: [ignore auto_update notify] 43 TrackingType *string `json:"tracking_type,omitempty"` 44 45 // The branch_id of the branch that this branch tracks 46 // Format: uuid 47 Tracks *strfmt.UUID `json:"tracks,omitempty"` 48 49 // The commit in the upstream branch that this branch forked from 50 // Format: uuid 51 UpstreamCommitID *strfmt.UUID `json:"upstream_commit_id,omitempty"` 52 } 53 54 // Validate validates this branch 55 func (m *Branch) Validate(formats strfmt.Registry) error { 56 var res []error 57 58 if err := m.validateBranchID(formats); err != nil { 59 res = append(res, err) 60 } 61 62 if err := m.validateCommitID(formats); err != nil { 63 res = append(res, err) 64 } 65 66 if err := m.validateProjectID(formats); err != nil { 67 res = append(res, err) 68 } 69 70 if err := m.validateTrackingType(formats); err != nil { 71 res = append(res, err) 72 } 73 74 if err := m.validateTracks(formats); err != nil { 75 res = append(res, err) 76 } 77 78 if err := m.validateUpstreamCommitID(formats); err != nil { 79 res = append(res, err) 80 } 81 82 if len(res) > 0 { 83 return errors.CompositeValidationError(res...) 84 } 85 return nil 86 } 87 88 func (m *Branch) validateBranchID(formats strfmt.Registry) error { 89 if swag.IsZero(m.BranchID) { // not required 90 return nil 91 } 92 93 if err := validate.FormatOf("branchID", "body", "uuid", m.BranchID.String(), formats); err != nil { 94 return err 95 } 96 97 return nil 98 } 99 100 func (m *Branch) validateCommitID(formats strfmt.Registry) error { 101 if swag.IsZero(m.CommitID) { // not required 102 return nil 103 } 104 105 if err := validate.FormatOf("commitID", "body", "uuid", m.CommitID.String(), formats); err != nil { 106 return err 107 } 108 109 return nil 110 } 111 112 func (m *Branch) validateProjectID(formats strfmt.Registry) error { 113 if swag.IsZero(m.ProjectID) { // not required 114 return nil 115 } 116 117 if err := validate.FormatOf("projectID", "body", "uuid", m.ProjectID.String(), formats); err != nil { 118 return err 119 } 120 121 return nil 122 } 123 124 var branchTypeTrackingTypePropEnum []interface{} 125 126 func init() { 127 var res []string 128 if err := json.Unmarshal([]byte(`["ignore","auto_update","notify"]`), &res); err != nil { 129 panic(err) 130 } 131 for _, v := range res { 132 branchTypeTrackingTypePropEnum = append(branchTypeTrackingTypePropEnum, v) 133 } 134 } 135 136 const ( 137 138 // BranchTrackingTypeIgnore captures enum value "ignore" 139 BranchTrackingTypeIgnore string = "ignore" 140 141 // BranchTrackingTypeAutoUpdate captures enum value "auto_update" 142 BranchTrackingTypeAutoUpdate string = "auto_update" 143 144 // BranchTrackingTypeNotify captures enum value "notify" 145 BranchTrackingTypeNotify string = "notify" 146 ) 147 148 // prop value enum 149 func (m *Branch) validateTrackingTypeEnum(path, location string, value string) error { 150 if err := validate.EnumCase(path, location, value, branchTypeTrackingTypePropEnum, true); err != nil { 151 return err 152 } 153 return nil 154 } 155 156 func (m *Branch) validateTrackingType(formats strfmt.Registry) error { 157 if swag.IsZero(m.TrackingType) { // not required 158 return nil 159 } 160 161 // value enum 162 if err := m.validateTrackingTypeEnum("tracking_type", "body", *m.TrackingType); err != nil { 163 return err 164 } 165 166 return nil 167 } 168 169 func (m *Branch) validateTracks(formats strfmt.Registry) error { 170 if swag.IsZero(m.Tracks) { // not required 171 return nil 172 } 173 174 if err := validate.FormatOf("tracks", "body", "uuid", m.Tracks.String(), formats); err != nil { 175 return err 176 } 177 178 return nil 179 } 180 181 func (m *Branch) validateUpstreamCommitID(formats strfmt.Registry) error { 182 if swag.IsZero(m.UpstreamCommitID) { // not required 183 return nil 184 } 185 186 if err := validate.FormatOf("upstream_commit_id", "body", "uuid", m.UpstreamCommitID.String(), formats); err != nil { 187 return err 188 } 189 190 return nil 191 } 192 193 // ContextValidate validates this branch based on context it is used 194 func (m *Branch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 195 return nil 196 } 197 198 // MarshalBinary interface implementation 199 func (m *Branch) MarshalBinary() ([]byte, error) { 200 if m == nil { 201 return nil, nil 202 } 203 return swag.WriteJSON(m) 204 } 205 206 // UnmarshalBinary interface implementation 207 func (m *Branch) UnmarshalBinary(b []byte) error { 208 var res Branch 209 if err := swag.ReadJSON(b, &res); err != nil { 210 return err 211 } 212 *m = res 213 return nil 214 }