github.com/minio/console@v1.4.1/models/set_policy_name_request.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // This file is part of MinIO Console Server 4 // Copyright (c) 2023 MinIO, Inc. 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU Affero General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Affero General Public License for more details. 15 // 16 // You should have received a copy of the GNU Affero General Public License 17 // along with this program. If not, see <http://www.gnu.org/licenses/>. 18 // 19 20 package models 21 22 // This file was generated by the swagger tool. 23 // Editing this file might prove futile when you re-run the swagger generate command 24 25 import ( 26 "context" 27 28 "github.com/go-openapi/errors" 29 "github.com/go-openapi/strfmt" 30 "github.com/go-openapi/swag" 31 "github.com/go-openapi/validate" 32 ) 33 34 // SetPolicyNameRequest set policy name request 35 // 36 // swagger:model setPolicyNameRequest 37 type SetPolicyNameRequest struct { 38 39 // entity name 40 // Required: true 41 EntityName *string `json:"entityName"` 42 43 // entity type 44 // Required: true 45 EntityType *PolicyEntity `json:"entityType"` 46 47 // name 48 // Required: true 49 Name []string `json:"name"` 50 } 51 52 // Validate validates this set policy name request 53 func (m *SetPolicyNameRequest) Validate(formats strfmt.Registry) error { 54 var res []error 55 56 if err := m.validateEntityName(formats); err != nil { 57 res = append(res, err) 58 } 59 60 if err := m.validateEntityType(formats); err != nil { 61 res = append(res, err) 62 } 63 64 if err := m.validateName(formats); err != nil { 65 res = append(res, err) 66 } 67 68 if len(res) > 0 { 69 return errors.CompositeValidationError(res...) 70 } 71 return nil 72 } 73 74 func (m *SetPolicyNameRequest) validateEntityName(formats strfmt.Registry) error { 75 76 if err := validate.Required("entityName", "body", m.EntityName); err != nil { 77 return err 78 } 79 80 return nil 81 } 82 83 func (m *SetPolicyNameRequest) validateEntityType(formats strfmt.Registry) error { 84 85 if err := validate.Required("entityType", "body", m.EntityType); err != nil { 86 return err 87 } 88 89 if err := validate.Required("entityType", "body", m.EntityType); err != nil { 90 return err 91 } 92 93 if m.EntityType != nil { 94 if err := m.EntityType.Validate(formats); err != nil { 95 if ve, ok := err.(*errors.Validation); ok { 96 return ve.ValidateName("entityType") 97 } else if ce, ok := err.(*errors.CompositeError); ok { 98 return ce.ValidateName("entityType") 99 } 100 return err 101 } 102 } 103 104 return nil 105 } 106 107 func (m *SetPolicyNameRequest) validateName(formats strfmt.Registry) error { 108 109 if err := validate.Required("name", "body", m.Name); err != nil { 110 return err 111 } 112 113 return nil 114 } 115 116 // ContextValidate validate this set policy name request based on the context it is used 117 func (m *SetPolicyNameRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 118 var res []error 119 120 if err := m.contextValidateEntityType(ctx, formats); err != nil { 121 res = append(res, err) 122 } 123 124 if len(res) > 0 { 125 return errors.CompositeValidationError(res...) 126 } 127 return nil 128 } 129 130 func (m *SetPolicyNameRequest) contextValidateEntityType(ctx context.Context, formats strfmt.Registry) error { 131 132 if m.EntityType != nil { 133 134 if err := m.EntityType.ContextValidate(ctx, formats); err != nil { 135 if ve, ok := err.(*errors.Validation); ok { 136 return ve.ValidateName("entityType") 137 } else if ce, ok := err.(*errors.CompositeError); ok { 138 return ce.ValidateName("entityType") 139 } 140 return err 141 } 142 } 143 144 return nil 145 } 146 147 // MarshalBinary interface implementation 148 func (m *SetPolicyNameRequest) MarshalBinary() ([]byte, error) { 149 if m == nil { 150 return nil, nil 151 } 152 return swag.WriteJSON(m) 153 } 154 155 // UnmarshalBinary interface implementation 156 func (m *SetPolicyNameRequest) UnmarshalBinary(b []byte) error { 157 var res SetPolicyNameRequest 158 if err := swag.ReadJSON(b, &res); err != nil { 159 return err 160 } 161 *m = res 162 return nil 163 }