github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/user/create_user_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package user 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/runtime" 13 "github.com/go-openapi/strfmt" 14 15 "github.com/goharbor/go-client/pkg/sdk/v2.0/models" 16 ) 17 18 // CreateUserReader is a Reader for the CreateUser structure. 19 type CreateUserReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *CreateUserReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 201: 27 result := NewCreateUserCreated() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 400: 33 result := NewCreateUserBadRequest() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 case 401: 39 result := NewCreateUserUnauthorized() 40 if err := result.readResponse(response, consumer, o.formats); err != nil { 41 return nil, err 42 } 43 return nil, result 44 case 403: 45 result := NewCreateUserForbidden() 46 if err := result.readResponse(response, consumer, o.formats); err != nil { 47 return nil, err 48 } 49 return nil, result 50 case 409: 51 result := NewCreateUserConflict() 52 if err := result.readResponse(response, consumer, o.formats); err != nil { 53 return nil, err 54 } 55 return nil, result 56 case 500: 57 result := NewCreateUserInternalServerError() 58 if err := result.readResponse(response, consumer, o.formats); err != nil { 59 return nil, err 60 } 61 return nil, result 62 default: 63 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 64 } 65 } 66 67 // NewCreateUserCreated creates a CreateUserCreated with default headers values 68 func NewCreateUserCreated() *CreateUserCreated { 69 return &CreateUserCreated{} 70 } 71 72 /* 73 CreateUserCreated describes a response with status code 201, with default header values. 74 75 Created 76 */ 77 type CreateUserCreated struct { 78 79 /* The location of the resource 80 */ 81 Location string 82 83 /* The ID of the corresponding request for the response 84 */ 85 XRequestID string 86 } 87 88 // IsSuccess returns true when this create user created response has a 2xx status code 89 func (o *CreateUserCreated) IsSuccess() bool { 90 return true 91 } 92 93 // IsRedirect returns true when this create user created response has a 3xx status code 94 func (o *CreateUserCreated) IsRedirect() bool { 95 return false 96 } 97 98 // IsClientError returns true when this create user created response has a 4xx status code 99 func (o *CreateUserCreated) IsClientError() bool { 100 return false 101 } 102 103 // IsServerError returns true when this create user created response has a 5xx status code 104 func (o *CreateUserCreated) IsServerError() bool { 105 return false 106 } 107 108 // IsCode returns true when this create user created response a status code equal to that given 109 func (o *CreateUserCreated) IsCode(code int) bool { 110 return code == 201 111 } 112 113 func (o *CreateUserCreated) Error() string { 114 return fmt.Sprintf("[POST /users][%d] createUserCreated ", 201) 115 } 116 117 func (o *CreateUserCreated) String() string { 118 return fmt.Sprintf("[POST /users][%d] createUserCreated ", 201) 119 } 120 121 func (o *CreateUserCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 122 123 // hydrates response header Location 124 hdrLocation := response.GetHeader("Location") 125 126 if hdrLocation != "" { 127 o.Location = hdrLocation 128 } 129 130 // hydrates response header X-Request-Id 131 hdrXRequestID := response.GetHeader("X-Request-Id") 132 133 if hdrXRequestID != "" { 134 o.XRequestID = hdrXRequestID 135 } 136 137 return nil 138 } 139 140 // NewCreateUserBadRequest creates a CreateUserBadRequest with default headers values 141 func NewCreateUserBadRequest() *CreateUserBadRequest { 142 return &CreateUserBadRequest{} 143 } 144 145 /* 146 CreateUserBadRequest describes a response with status code 400, with default header values. 147 148 Bad request 149 */ 150 type CreateUserBadRequest struct { 151 152 /* The ID of the corresponding request for the response 153 */ 154 XRequestID string 155 156 Payload *models.Errors 157 } 158 159 // IsSuccess returns true when this create user bad request response has a 2xx status code 160 func (o *CreateUserBadRequest) IsSuccess() bool { 161 return false 162 } 163 164 // IsRedirect returns true when this create user bad request response has a 3xx status code 165 func (o *CreateUserBadRequest) IsRedirect() bool { 166 return false 167 } 168 169 // IsClientError returns true when this create user bad request response has a 4xx status code 170 func (o *CreateUserBadRequest) IsClientError() bool { 171 return true 172 } 173 174 // IsServerError returns true when this create user bad request response has a 5xx status code 175 func (o *CreateUserBadRequest) IsServerError() bool { 176 return false 177 } 178 179 // IsCode returns true when this create user bad request response a status code equal to that given 180 func (o *CreateUserBadRequest) IsCode(code int) bool { 181 return code == 400 182 } 183 184 func (o *CreateUserBadRequest) Error() string { 185 return fmt.Sprintf("[POST /users][%d] createUserBadRequest %+v", 400, o.Payload) 186 } 187 188 func (o *CreateUserBadRequest) String() string { 189 return fmt.Sprintf("[POST /users][%d] createUserBadRequest %+v", 400, o.Payload) 190 } 191 192 func (o *CreateUserBadRequest) GetPayload() *models.Errors { 193 return o.Payload 194 } 195 196 func (o *CreateUserBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 197 198 // hydrates response header X-Request-Id 199 hdrXRequestID := response.GetHeader("X-Request-Id") 200 201 if hdrXRequestID != "" { 202 o.XRequestID = hdrXRequestID 203 } 204 205 o.Payload = new(models.Errors) 206 207 // response payload 208 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 209 return err 210 } 211 212 return nil 213 } 214 215 // NewCreateUserUnauthorized creates a CreateUserUnauthorized with default headers values 216 func NewCreateUserUnauthorized() *CreateUserUnauthorized { 217 return &CreateUserUnauthorized{} 218 } 219 220 /* 221 CreateUserUnauthorized describes a response with status code 401, with default header values. 222 223 Unauthorized 224 */ 225 type CreateUserUnauthorized struct { 226 227 /* The ID of the corresponding request for the response 228 */ 229 XRequestID string 230 231 Payload *models.Errors 232 } 233 234 // IsSuccess returns true when this create user unauthorized response has a 2xx status code 235 func (o *CreateUserUnauthorized) IsSuccess() bool { 236 return false 237 } 238 239 // IsRedirect returns true when this create user unauthorized response has a 3xx status code 240 func (o *CreateUserUnauthorized) IsRedirect() bool { 241 return false 242 } 243 244 // IsClientError returns true when this create user unauthorized response has a 4xx status code 245 func (o *CreateUserUnauthorized) IsClientError() bool { 246 return true 247 } 248 249 // IsServerError returns true when this create user unauthorized response has a 5xx status code 250 func (o *CreateUserUnauthorized) IsServerError() bool { 251 return false 252 } 253 254 // IsCode returns true when this create user unauthorized response a status code equal to that given 255 func (o *CreateUserUnauthorized) IsCode(code int) bool { 256 return code == 401 257 } 258 259 func (o *CreateUserUnauthorized) Error() string { 260 return fmt.Sprintf("[POST /users][%d] createUserUnauthorized %+v", 401, o.Payload) 261 } 262 263 func (o *CreateUserUnauthorized) String() string { 264 return fmt.Sprintf("[POST /users][%d] createUserUnauthorized %+v", 401, o.Payload) 265 } 266 267 func (o *CreateUserUnauthorized) GetPayload() *models.Errors { 268 return o.Payload 269 } 270 271 func (o *CreateUserUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 272 273 // hydrates response header X-Request-Id 274 hdrXRequestID := response.GetHeader("X-Request-Id") 275 276 if hdrXRequestID != "" { 277 o.XRequestID = hdrXRequestID 278 } 279 280 o.Payload = new(models.Errors) 281 282 // response payload 283 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 284 return err 285 } 286 287 return nil 288 } 289 290 // NewCreateUserForbidden creates a CreateUserForbidden with default headers values 291 func NewCreateUserForbidden() *CreateUserForbidden { 292 return &CreateUserForbidden{} 293 } 294 295 /* 296 CreateUserForbidden describes a response with status code 403, with default header values. 297 298 When the self registration is disabled, non-admin does not have permission to create user. When self registration is enabled, this API can only be called from UI portal, calling it via script will get a 403 error. 299 */ 300 type CreateUserForbidden struct { 301 } 302 303 // IsSuccess returns true when this create user forbidden response has a 2xx status code 304 func (o *CreateUserForbidden) IsSuccess() bool { 305 return false 306 } 307 308 // IsRedirect returns true when this create user forbidden response has a 3xx status code 309 func (o *CreateUserForbidden) IsRedirect() bool { 310 return false 311 } 312 313 // IsClientError returns true when this create user forbidden response has a 4xx status code 314 func (o *CreateUserForbidden) IsClientError() bool { 315 return true 316 } 317 318 // IsServerError returns true when this create user forbidden response has a 5xx status code 319 func (o *CreateUserForbidden) IsServerError() bool { 320 return false 321 } 322 323 // IsCode returns true when this create user forbidden response a status code equal to that given 324 func (o *CreateUserForbidden) IsCode(code int) bool { 325 return code == 403 326 } 327 328 func (o *CreateUserForbidden) Error() string { 329 return fmt.Sprintf("[POST /users][%d] createUserForbidden ", 403) 330 } 331 332 func (o *CreateUserForbidden) String() string { 333 return fmt.Sprintf("[POST /users][%d] createUserForbidden ", 403) 334 } 335 336 func (o *CreateUserForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 337 338 return nil 339 } 340 341 // NewCreateUserConflict creates a CreateUserConflict with default headers values 342 func NewCreateUserConflict() *CreateUserConflict { 343 return &CreateUserConflict{} 344 } 345 346 /* 347 CreateUserConflict describes a response with status code 409, with default header values. 348 349 Conflict 350 */ 351 type CreateUserConflict struct { 352 353 /* The ID of the corresponding request for the response 354 */ 355 XRequestID string 356 357 Payload *models.Errors 358 } 359 360 // IsSuccess returns true when this create user conflict response has a 2xx status code 361 func (o *CreateUserConflict) IsSuccess() bool { 362 return false 363 } 364 365 // IsRedirect returns true when this create user conflict response has a 3xx status code 366 func (o *CreateUserConflict) IsRedirect() bool { 367 return false 368 } 369 370 // IsClientError returns true when this create user conflict response has a 4xx status code 371 func (o *CreateUserConflict) IsClientError() bool { 372 return true 373 } 374 375 // IsServerError returns true when this create user conflict response has a 5xx status code 376 func (o *CreateUserConflict) IsServerError() bool { 377 return false 378 } 379 380 // IsCode returns true when this create user conflict response a status code equal to that given 381 func (o *CreateUserConflict) IsCode(code int) bool { 382 return code == 409 383 } 384 385 func (o *CreateUserConflict) Error() string { 386 return fmt.Sprintf("[POST /users][%d] createUserConflict %+v", 409, o.Payload) 387 } 388 389 func (o *CreateUserConflict) String() string { 390 return fmt.Sprintf("[POST /users][%d] createUserConflict %+v", 409, o.Payload) 391 } 392 393 func (o *CreateUserConflict) GetPayload() *models.Errors { 394 return o.Payload 395 } 396 397 func (o *CreateUserConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 398 399 // hydrates response header X-Request-Id 400 hdrXRequestID := response.GetHeader("X-Request-Id") 401 402 if hdrXRequestID != "" { 403 o.XRequestID = hdrXRequestID 404 } 405 406 o.Payload = new(models.Errors) 407 408 // response payload 409 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 410 return err 411 } 412 413 return nil 414 } 415 416 // NewCreateUserInternalServerError creates a CreateUserInternalServerError with default headers values 417 func NewCreateUserInternalServerError() *CreateUserInternalServerError { 418 return &CreateUserInternalServerError{} 419 } 420 421 /* 422 CreateUserInternalServerError describes a response with status code 500, with default header values. 423 424 Internal server error 425 */ 426 type CreateUserInternalServerError struct { 427 428 /* The ID of the corresponding request for the response 429 */ 430 XRequestID string 431 432 Payload *models.Errors 433 } 434 435 // IsSuccess returns true when this create user internal server error response has a 2xx status code 436 func (o *CreateUserInternalServerError) IsSuccess() bool { 437 return false 438 } 439 440 // IsRedirect returns true when this create user internal server error response has a 3xx status code 441 func (o *CreateUserInternalServerError) IsRedirect() bool { 442 return false 443 } 444 445 // IsClientError returns true when this create user internal server error response has a 4xx status code 446 func (o *CreateUserInternalServerError) IsClientError() bool { 447 return false 448 } 449 450 // IsServerError returns true when this create user internal server error response has a 5xx status code 451 func (o *CreateUserInternalServerError) IsServerError() bool { 452 return true 453 } 454 455 // IsCode returns true when this create user internal server error response a status code equal to that given 456 func (o *CreateUserInternalServerError) IsCode(code int) bool { 457 return code == 500 458 } 459 460 func (o *CreateUserInternalServerError) Error() string { 461 return fmt.Sprintf("[POST /users][%d] createUserInternalServerError %+v", 500, o.Payload) 462 } 463 464 func (o *CreateUserInternalServerError) String() string { 465 return fmt.Sprintf("[POST /users][%d] createUserInternalServerError %+v", 500, o.Payload) 466 } 467 468 func (o *CreateUserInternalServerError) GetPayload() *models.Errors { 469 return o.Payload 470 } 471 472 func (o *CreateUserInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 473 474 // hydrates response header X-Request-Id 475 hdrXRequestID := response.GetHeader("X-Request-Id") 476 477 if hdrXRequestID != "" { 478 o.XRequestID = hdrXRequestID 479 } 480 481 o.Payload = new(models.Errors) 482 483 // response payload 484 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 485 return err 486 } 487 488 return nil 489 }