github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/usergroup/search_user_groups_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package usergroup 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 "fmt" 10 "io" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/runtime" 14 "github.com/go-openapi/strfmt" 15 "github.com/go-openapi/swag" 16 17 "github.com/goharbor/go-client/pkg/sdk/v2.0/models" 18 ) 19 20 // SearchUserGroupsReader is a Reader for the SearchUserGroups structure. 21 type SearchUserGroupsReader struct { 22 formats strfmt.Registry 23 } 24 25 // ReadResponse reads a server response into the received o. 26 func (o *SearchUserGroupsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 27 switch response.Code() { 28 case 200: 29 result := NewSearchUserGroupsOK() 30 if err := result.readResponse(response, consumer, o.formats); err != nil { 31 return nil, err 32 } 33 return result, nil 34 case 401: 35 result := NewSearchUserGroupsUnauthorized() 36 if err := result.readResponse(response, consumer, o.formats); err != nil { 37 return nil, err 38 } 39 return nil, result 40 case 500: 41 result := NewSearchUserGroupsInternalServerError() 42 if err := result.readResponse(response, consumer, o.formats); err != nil { 43 return nil, err 44 } 45 return nil, result 46 default: 47 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 48 } 49 } 50 51 // NewSearchUserGroupsOK creates a SearchUserGroupsOK with default headers values 52 func NewSearchUserGroupsOK() *SearchUserGroupsOK { 53 return &SearchUserGroupsOK{} 54 } 55 56 /* 57 SearchUserGroupsOK describes a response with status code 200, with default header values. 58 59 Search groups successfully. 60 */ 61 type SearchUserGroupsOK struct { 62 63 /* Link to previous page and next page 64 */ 65 Link string 66 67 /* The total count of available items 68 */ 69 XTotalCount int64 70 71 Payload []*models.UserGroupSearchItem 72 } 73 74 // IsSuccess returns true when this search user groups o k response has a 2xx status code 75 func (o *SearchUserGroupsOK) IsSuccess() bool { 76 return true 77 } 78 79 // IsRedirect returns true when this search user groups o k response has a 3xx status code 80 func (o *SearchUserGroupsOK) IsRedirect() bool { 81 return false 82 } 83 84 // IsClientError returns true when this search user groups o k response has a 4xx status code 85 func (o *SearchUserGroupsOK) IsClientError() bool { 86 return false 87 } 88 89 // IsServerError returns true when this search user groups o k response has a 5xx status code 90 func (o *SearchUserGroupsOK) IsServerError() bool { 91 return false 92 } 93 94 // IsCode returns true when this search user groups o k response a status code equal to that given 95 func (o *SearchUserGroupsOK) IsCode(code int) bool { 96 return code == 200 97 } 98 99 func (o *SearchUserGroupsOK) Error() string { 100 return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsOK %+v", 200, o.Payload) 101 } 102 103 func (o *SearchUserGroupsOK) String() string { 104 return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsOK %+v", 200, o.Payload) 105 } 106 107 func (o *SearchUserGroupsOK) GetPayload() []*models.UserGroupSearchItem { 108 return o.Payload 109 } 110 111 func (o *SearchUserGroupsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 112 113 // hydrates response header Link 114 hdrLink := response.GetHeader("Link") 115 116 if hdrLink != "" { 117 o.Link = hdrLink 118 } 119 120 // hydrates response header X-Total-Count 121 hdrXTotalCount := response.GetHeader("X-Total-Count") 122 123 if hdrXTotalCount != "" { 124 valxTotalCount, err := swag.ConvertInt64(hdrXTotalCount) 125 if err != nil { 126 return errors.InvalidType("X-Total-Count", "header", "int64", hdrXTotalCount) 127 } 128 o.XTotalCount = valxTotalCount 129 } 130 131 // response payload 132 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 133 return err 134 } 135 136 return nil 137 } 138 139 // NewSearchUserGroupsUnauthorized creates a SearchUserGroupsUnauthorized with default headers values 140 func NewSearchUserGroupsUnauthorized() *SearchUserGroupsUnauthorized { 141 return &SearchUserGroupsUnauthorized{} 142 } 143 144 /* 145 SearchUserGroupsUnauthorized describes a response with status code 401, with default header values. 146 147 Unauthorized 148 */ 149 type SearchUserGroupsUnauthorized struct { 150 151 /* The ID of the corresponding request for the response 152 */ 153 XRequestID string 154 155 Payload *models.Errors 156 } 157 158 // IsSuccess returns true when this search user groups unauthorized response has a 2xx status code 159 func (o *SearchUserGroupsUnauthorized) IsSuccess() bool { 160 return false 161 } 162 163 // IsRedirect returns true when this search user groups unauthorized response has a 3xx status code 164 func (o *SearchUserGroupsUnauthorized) IsRedirect() bool { 165 return false 166 } 167 168 // IsClientError returns true when this search user groups unauthorized response has a 4xx status code 169 func (o *SearchUserGroupsUnauthorized) IsClientError() bool { 170 return true 171 } 172 173 // IsServerError returns true when this search user groups unauthorized response has a 5xx status code 174 func (o *SearchUserGroupsUnauthorized) IsServerError() bool { 175 return false 176 } 177 178 // IsCode returns true when this search user groups unauthorized response a status code equal to that given 179 func (o *SearchUserGroupsUnauthorized) IsCode(code int) bool { 180 return code == 401 181 } 182 183 func (o *SearchUserGroupsUnauthorized) Error() string { 184 return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsUnauthorized %+v", 401, o.Payload) 185 } 186 187 func (o *SearchUserGroupsUnauthorized) String() string { 188 return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsUnauthorized %+v", 401, o.Payload) 189 } 190 191 func (o *SearchUserGroupsUnauthorized) GetPayload() *models.Errors { 192 return o.Payload 193 } 194 195 func (o *SearchUserGroupsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 196 197 // hydrates response header X-Request-Id 198 hdrXRequestID := response.GetHeader("X-Request-Id") 199 200 if hdrXRequestID != "" { 201 o.XRequestID = hdrXRequestID 202 } 203 204 o.Payload = new(models.Errors) 205 206 // response payload 207 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 208 return err 209 } 210 211 return nil 212 } 213 214 // NewSearchUserGroupsInternalServerError creates a SearchUserGroupsInternalServerError with default headers values 215 func NewSearchUserGroupsInternalServerError() *SearchUserGroupsInternalServerError { 216 return &SearchUserGroupsInternalServerError{} 217 } 218 219 /* 220 SearchUserGroupsInternalServerError describes a response with status code 500, with default header values. 221 222 Internal server error 223 */ 224 type SearchUserGroupsInternalServerError struct { 225 226 /* The ID of the corresponding request for the response 227 */ 228 XRequestID string 229 230 Payload *models.Errors 231 } 232 233 // IsSuccess returns true when this search user groups internal server error response has a 2xx status code 234 func (o *SearchUserGroupsInternalServerError) IsSuccess() bool { 235 return false 236 } 237 238 // IsRedirect returns true when this search user groups internal server error response has a 3xx status code 239 func (o *SearchUserGroupsInternalServerError) IsRedirect() bool { 240 return false 241 } 242 243 // IsClientError returns true when this search user groups internal server error response has a 4xx status code 244 func (o *SearchUserGroupsInternalServerError) IsClientError() bool { 245 return false 246 } 247 248 // IsServerError returns true when this search user groups internal server error response has a 5xx status code 249 func (o *SearchUserGroupsInternalServerError) IsServerError() bool { 250 return true 251 } 252 253 // IsCode returns true when this search user groups internal server error response a status code equal to that given 254 func (o *SearchUserGroupsInternalServerError) IsCode(code int) bool { 255 return code == 500 256 } 257 258 func (o *SearchUserGroupsInternalServerError) Error() string { 259 return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsInternalServerError %+v", 500, o.Payload) 260 } 261 262 func (o *SearchUserGroupsInternalServerError) String() string { 263 return fmt.Sprintf("[GET /usergroups/search][%d] searchUserGroupsInternalServerError %+v", 500, o.Payload) 264 } 265 266 func (o *SearchUserGroupsInternalServerError) GetPayload() *models.Errors { 267 return o.Payload 268 } 269 270 func (o *SearchUserGroupsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 271 272 // hydrates response header X-Request-Id 273 hdrXRequestID := response.GetHeader("X-Request-Id") 274 275 if hdrXRequestID != "" { 276 o.XRequestID = hdrXRequestID 277 } 278 279 o.Payload = new(models.Errors) 280 281 // response payload 282 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 283 return err 284 } 285 286 return nil 287 }