github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/project_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 "github.com/go-openapi/validate" 15 ) 16 17 // ProjectReq project req 18 // 19 // swagger:model ProjectReq 20 type ProjectReq struct { 21 22 // The CVE allowlist of the project. 23 CVEAllowlist *CVEAllowlist `json:"cve_allowlist,omitempty"` 24 25 // The metadata of the project. 26 Metadata *ProjectMetadata `json:"metadata,omitempty"` 27 28 // The name of the project. 29 // Max Length: 255 30 ProjectName string `json:"project_name,omitempty"` 31 32 // deprecated, reserved for project creation in replication 33 Public *bool `json:"public,omitempty"` 34 35 // The ID of referenced registry when creating the proxy cache project 36 RegistryID *int64 `json:"registry_id,omitempty"` 37 38 // The storage quota of the project. 39 StorageLimit *int64 `json:"storage_limit,omitempty"` 40 } 41 42 // Validate validates this project req 43 func (m *ProjectReq) Validate(formats strfmt.Registry) error { 44 var res []error 45 46 if err := m.validateCVEAllowlist(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if err := m.validateMetadata(formats); err != nil { 51 res = append(res, err) 52 } 53 54 if err := m.validateProjectName(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if len(res) > 0 { 59 return errors.CompositeValidationError(res...) 60 } 61 return nil 62 } 63 64 func (m *ProjectReq) validateCVEAllowlist(formats strfmt.Registry) error { 65 if swag.IsZero(m.CVEAllowlist) { // not required 66 return nil 67 } 68 69 if m.CVEAllowlist != nil { 70 if err := m.CVEAllowlist.Validate(formats); err != nil { 71 if ve, ok := err.(*errors.Validation); ok { 72 return ve.ValidateName("cve_allowlist") 73 } else if ce, ok := err.(*errors.CompositeError); ok { 74 return ce.ValidateName("cve_allowlist") 75 } 76 return err 77 } 78 } 79 80 return nil 81 } 82 83 func (m *ProjectReq) validateMetadata(formats strfmt.Registry) error { 84 if swag.IsZero(m.Metadata) { // not required 85 return nil 86 } 87 88 if m.Metadata != nil { 89 if err := m.Metadata.Validate(formats); err != nil { 90 if ve, ok := err.(*errors.Validation); ok { 91 return ve.ValidateName("metadata") 92 } else if ce, ok := err.(*errors.CompositeError); ok { 93 return ce.ValidateName("metadata") 94 } 95 return err 96 } 97 } 98 99 return nil 100 } 101 102 func (m *ProjectReq) validateProjectName(formats strfmt.Registry) error { 103 if swag.IsZero(m.ProjectName) { // not required 104 return nil 105 } 106 107 if err := validate.MaxLength("project_name", "body", m.ProjectName, 255); err != nil { 108 return err 109 } 110 111 return nil 112 } 113 114 // ContextValidate validate this project req based on the context it is used 115 func (m *ProjectReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 116 var res []error 117 118 if err := m.contextValidateCVEAllowlist(ctx, formats); err != nil { 119 res = append(res, err) 120 } 121 122 if err := m.contextValidateMetadata(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 *ProjectReq) contextValidateCVEAllowlist(ctx context.Context, formats strfmt.Registry) error { 133 134 if m.CVEAllowlist != nil { 135 if err := m.CVEAllowlist.ContextValidate(ctx, formats); err != nil { 136 if ve, ok := err.(*errors.Validation); ok { 137 return ve.ValidateName("cve_allowlist") 138 } else if ce, ok := err.(*errors.CompositeError); ok { 139 return ce.ValidateName("cve_allowlist") 140 } 141 return err 142 } 143 } 144 145 return nil 146 } 147 148 func (m *ProjectReq) contextValidateMetadata(ctx context.Context, formats strfmt.Registry) error { 149 150 if m.Metadata != nil { 151 if err := m.Metadata.ContextValidate(ctx, formats); err != nil { 152 if ve, ok := err.(*errors.Validation); ok { 153 return ve.ValidateName("metadata") 154 } else if ce, ok := err.(*errors.CompositeError); ok { 155 return ce.ValidateName("metadata") 156 } 157 return err 158 } 159 } 160 161 return nil 162 } 163 164 // MarshalBinary interface implementation 165 func (m *ProjectReq) MarshalBinary() ([]byte, error) { 166 if m == nil { 167 return nil, nil 168 } 169 return swag.WriteJSON(m) 170 } 171 172 // UnmarshalBinary interface implementation 173 func (m *ProjectReq) UnmarshalBinary(b []byte) error { 174 var res ProjectReq 175 if err := swag.ReadJSON(b, &res); err != nil { 176 return err 177 } 178 *m = res 179 return nil 180 }