github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/quota_update_req.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package 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 // QuotaUpdateReq quota update req 17 // 18 // swagger:model QuotaUpdateReq 19 type QuotaUpdateReq struct { 20 21 // The new hard limits for the quota 22 Hard ResourceList `json:"hard,omitempty"` 23 } 24 25 // Validate validates this quota update req 26 func (m *QuotaUpdateReq) Validate(formats strfmt.Registry) error { 27 var res []error 28 29 if err := m.validateHard(formats); err != nil { 30 res = append(res, err) 31 } 32 33 if len(res) > 0 { 34 return errors.CompositeValidationError(res...) 35 } 36 return nil 37 } 38 39 func (m *QuotaUpdateReq) validateHard(formats strfmt.Registry) error { 40 if swag.IsZero(m.Hard) { // not required 41 return nil 42 } 43 44 if m.Hard != nil { 45 if err := m.Hard.Validate(formats); err != nil { 46 if ve, ok := err.(*errors.Validation); ok { 47 return ve.ValidateName("hard") 48 } else if ce, ok := err.(*errors.CompositeError); ok { 49 return ce.ValidateName("hard") 50 } 51 return err 52 } 53 } 54 55 return nil 56 } 57 58 // ContextValidate validate this quota update req based on the context it is used 59 func (m *QuotaUpdateReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 60 var res []error 61 62 if err := m.contextValidateHard(ctx, formats); err != nil { 63 res = append(res, err) 64 } 65 66 if len(res) > 0 { 67 return errors.CompositeValidationError(res...) 68 } 69 return nil 70 } 71 72 func (m *QuotaUpdateReq) contextValidateHard(ctx context.Context, formats strfmt.Registry) error { 73 74 if err := m.Hard.ContextValidate(ctx, formats); err != nil { 75 if ve, ok := err.(*errors.Validation); ok { 76 return ve.ValidateName("hard") 77 } else if ce, ok := err.(*errors.CompositeError); ok { 78 return ce.ValidateName("hard") 79 } 80 return err 81 } 82 83 return nil 84 } 85 86 // MarshalBinary interface implementation 87 func (m *QuotaUpdateReq) MarshalBinary() ([]byte, error) { 88 if m == nil { 89 return nil, nil 90 } 91 return swag.WriteJSON(m) 92 } 93 94 // UnmarshalBinary interface implementation 95 func (m *QuotaUpdateReq) UnmarshalBinary(b []byte) error { 96 var res QuotaUpdateReq 97 if err := swag.ReadJSON(b, &res); err != nil { 98 return err 99 } 100 *m = res 101 return nil 102 }