github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/artifact/copy_artifact_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package artifact 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 // CopyArtifactReader is a Reader for the CopyArtifact structure. 19 type CopyArtifactReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *CopyArtifactReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 201: 27 result := NewCopyArtifactCreated() 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 := NewCopyArtifactBadRequest() 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 := NewCopyArtifactUnauthorized() 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 := NewCopyArtifactForbidden() 46 if err := result.readResponse(response, consumer, o.formats); err != nil { 47 return nil, err 48 } 49 return nil, result 50 case 404: 51 result := NewCopyArtifactNotFound() 52 if err := result.readResponse(response, consumer, o.formats); err != nil { 53 return nil, err 54 } 55 return nil, result 56 case 405: 57 result := NewCopyArtifactMethodNotAllowed() 58 if err := result.readResponse(response, consumer, o.formats); err != nil { 59 return nil, err 60 } 61 return nil, result 62 case 500: 63 result := NewCopyArtifactInternalServerError() 64 if err := result.readResponse(response, consumer, o.formats); err != nil { 65 return nil, err 66 } 67 return nil, result 68 default: 69 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 70 } 71 } 72 73 // NewCopyArtifactCreated creates a CopyArtifactCreated with default headers values 74 func NewCopyArtifactCreated() *CopyArtifactCreated { 75 return &CopyArtifactCreated{} 76 } 77 78 /* 79 CopyArtifactCreated describes a response with status code 201, with default header values. 80 81 Created 82 */ 83 type CopyArtifactCreated struct { 84 85 /* The location of the resource 86 */ 87 Location string 88 89 /* The ID of the corresponding request for the response 90 */ 91 XRequestID string 92 } 93 94 // IsSuccess returns true when this copy artifact created response has a 2xx status code 95 func (o *CopyArtifactCreated) IsSuccess() bool { 96 return true 97 } 98 99 // IsRedirect returns true when this copy artifact created response has a 3xx status code 100 func (o *CopyArtifactCreated) IsRedirect() bool { 101 return false 102 } 103 104 // IsClientError returns true when this copy artifact created response has a 4xx status code 105 func (o *CopyArtifactCreated) IsClientError() bool { 106 return false 107 } 108 109 // IsServerError returns true when this copy artifact created response has a 5xx status code 110 func (o *CopyArtifactCreated) IsServerError() bool { 111 return false 112 } 113 114 // IsCode returns true when this copy artifact created response a status code equal to that given 115 func (o *CopyArtifactCreated) IsCode(code int) bool { 116 return code == 201 117 } 118 119 func (o *CopyArtifactCreated) Error() string { 120 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactCreated ", 201) 121 } 122 123 func (o *CopyArtifactCreated) String() string { 124 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactCreated ", 201) 125 } 126 127 func (o *CopyArtifactCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 128 129 // hydrates response header Location 130 hdrLocation := response.GetHeader("Location") 131 132 if hdrLocation != "" { 133 o.Location = hdrLocation 134 } 135 136 // hydrates response header X-Request-Id 137 hdrXRequestID := response.GetHeader("X-Request-Id") 138 139 if hdrXRequestID != "" { 140 o.XRequestID = hdrXRequestID 141 } 142 143 return nil 144 } 145 146 // NewCopyArtifactBadRequest creates a CopyArtifactBadRequest with default headers values 147 func NewCopyArtifactBadRequest() *CopyArtifactBadRequest { 148 return &CopyArtifactBadRequest{} 149 } 150 151 /* 152 CopyArtifactBadRequest describes a response with status code 400, with default header values. 153 154 Bad request 155 */ 156 type CopyArtifactBadRequest struct { 157 158 /* The ID of the corresponding request for the response 159 */ 160 XRequestID string 161 162 Payload *models.Errors 163 } 164 165 // IsSuccess returns true when this copy artifact bad request response has a 2xx status code 166 func (o *CopyArtifactBadRequest) IsSuccess() bool { 167 return false 168 } 169 170 // IsRedirect returns true when this copy artifact bad request response has a 3xx status code 171 func (o *CopyArtifactBadRequest) IsRedirect() bool { 172 return false 173 } 174 175 // IsClientError returns true when this copy artifact bad request response has a 4xx status code 176 func (o *CopyArtifactBadRequest) IsClientError() bool { 177 return true 178 } 179 180 // IsServerError returns true when this copy artifact bad request response has a 5xx status code 181 func (o *CopyArtifactBadRequest) IsServerError() bool { 182 return false 183 } 184 185 // IsCode returns true when this copy artifact bad request response a status code equal to that given 186 func (o *CopyArtifactBadRequest) IsCode(code int) bool { 187 return code == 400 188 } 189 190 func (o *CopyArtifactBadRequest) Error() string { 191 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactBadRequest %+v", 400, o.Payload) 192 } 193 194 func (o *CopyArtifactBadRequest) String() string { 195 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactBadRequest %+v", 400, o.Payload) 196 } 197 198 func (o *CopyArtifactBadRequest) GetPayload() *models.Errors { 199 return o.Payload 200 } 201 202 func (o *CopyArtifactBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 203 204 // hydrates response header X-Request-Id 205 hdrXRequestID := response.GetHeader("X-Request-Id") 206 207 if hdrXRequestID != "" { 208 o.XRequestID = hdrXRequestID 209 } 210 211 o.Payload = new(models.Errors) 212 213 // response payload 214 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 215 return err 216 } 217 218 return nil 219 } 220 221 // NewCopyArtifactUnauthorized creates a CopyArtifactUnauthorized with default headers values 222 func NewCopyArtifactUnauthorized() *CopyArtifactUnauthorized { 223 return &CopyArtifactUnauthorized{} 224 } 225 226 /* 227 CopyArtifactUnauthorized describes a response with status code 401, with default header values. 228 229 Unauthorized 230 */ 231 type CopyArtifactUnauthorized struct { 232 233 /* The ID of the corresponding request for the response 234 */ 235 XRequestID string 236 237 Payload *models.Errors 238 } 239 240 // IsSuccess returns true when this copy artifact unauthorized response has a 2xx status code 241 func (o *CopyArtifactUnauthorized) IsSuccess() bool { 242 return false 243 } 244 245 // IsRedirect returns true when this copy artifact unauthorized response has a 3xx status code 246 func (o *CopyArtifactUnauthorized) IsRedirect() bool { 247 return false 248 } 249 250 // IsClientError returns true when this copy artifact unauthorized response has a 4xx status code 251 func (o *CopyArtifactUnauthorized) IsClientError() bool { 252 return true 253 } 254 255 // IsServerError returns true when this copy artifact unauthorized response has a 5xx status code 256 func (o *CopyArtifactUnauthorized) IsServerError() bool { 257 return false 258 } 259 260 // IsCode returns true when this copy artifact unauthorized response a status code equal to that given 261 func (o *CopyArtifactUnauthorized) IsCode(code int) bool { 262 return code == 401 263 } 264 265 func (o *CopyArtifactUnauthorized) Error() string { 266 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactUnauthorized %+v", 401, o.Payload) 267 } 268 269 func (o *CopyArtifactUnauthorized) String() string { 270 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactUnauthorized %+v", 401, o.Payload) 271 } 272 273 func (o *CopyArtifactUnauthorized) GetPayload() *models.Errors { 274 return o.Payload 275 } 276 277 func (o *CopyArtifactUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 278 279 // hydrates response header X-Request-Id 280 hdrXRequestID := response.GetHeader("X-Request-Id") 281 282 if hdrXRequestID != "" { 283 o.XRequestID = hdrXRequestID 284 } 285 286 o.Payload = new(models.Errors) 287 288 // response payload 289 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 290 return err 291 } 292 293 return nil 294 } 295 296 // NewCopyArtifactForbidden creates a CopyArtifactForbidden with default headers values 297 func NewCopyArtifactForbidden() *CopyArtifactForbidden { 298 return &CopyArtifactForbidden{} 299 } 300 301 /* 302 CopyArtifactForbidden describes a response with status code 403, with default header values. 303 304 Forbidden 305 */ 306 type CopyArtifactForbidden struct { 307 308 /* The ID of the corresponding request for the response 309 */ 310 XRequestID string 311 312 Payload *models.Errors 313 } 314 315 // IsSuccess returns true when this copy artifact forbidden response has a 2xx status code 316 func (o *CopyArtifactForbidden) IsSuccess() bool { 317 return false 318 } 319 320 // IsRedirect returns true when this copy artifact forbidden response has a 3xx status code 321 func (o *CopyArtifactForbidden) IsRedirect() bool { 322 return false 323 } 324 325 // IsClientError returns true when this copy artifact forbidden response has a 4xx status code 326 func (o *CopyArtifactForbidden) IsClientError() bool { 327 return true 328 } 329 330 // IsServerError returns true when this copy artifact forbidden response has a 5xx status code 331 func (o *CopyArtifactForbidden) IsServerError() bool { 332 return false 333 } 334 335 // IsCode returns true when this copy artifact forbidden response a status code equal to that given 336 func (o *CopyArtifactForbidden) IsCode(code int) bool { 337 return code == 403 338 } 339 340 func (o *CopyArtifactForbidden) Error() string { 341 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactForbidden %+v", 403, o.Payload) 342 } 343 344 func (o *CopyArtifactForbidden) String() string { 345 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactForbidden %+v", 403, o.Payload) 346 } 347 348 func (o *CopyArtifactForbidden) GetPayload() *models.Errors { 349 return o.Payload 350 } 351 352 func (o *CopyArtifactForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 353 354 // hydrates response header X-Request-Id 355 hdrXRequestID := response.GetHeader("X-Request-Id") 356 357 if hdrXRequestID != "" { 358 o.XRequestID = hdrXRequestID 359 } 360 361 o.Payload = new(models.Errors) 362 363 // response payload 364 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 365 return err 366 } 367 368 return nil 369 } 370 371 // NewCopyArtifactNotFound creates a CopyArtifactNotFound with default headers values 372 func NewCopyArtifactNotFound() *CopyArtifactNotFound { 373 return &CopyArtifactNotFound{} 374 } 375 376 /* 377 CopyArtifactNotFound describes a response with status code 404, with default header values. 378 379 Not found 380 */ 381 type CopyArtifactNotFound struct { 382 383 /* The ID of the corresponding request for the response 384 */ 385 XRequestID string 386 387 Payload *models.Errors 388 } 389 390 // IsSuccess returns true when this copy artifact not found response has a 2xx status code 391 func (o *CopyArtifactNotFound) IsSuccess() bool { 392 return false 393 } 394 395 // IsRedirect returns true when this copy artifact not found response has a 3xx status code 396 func (o *CopyArtifactNotFound) IsRedirect() bool { 397 return false 398 } 399 400 // IsClientError returns true when this copy artifact not found response has a 4xx status code 401 func (o *CopyArtifactNotFound) IsClientError() bool { 402 return true 403 } 404 405 // IsServerError returns true when this copy artifact not found response has a 5xx status code 406 func (o *CopyArtifactNotFound) IsServerError() bool { 407 return false 408 } 409 410 // IsCode returns true when this copy artifact not found response a status code equal to that given 411 func (o *CopyArtifactNotFound) IsCode(code int) bool { 412 return code == 404 413 } 414 415 func (o *CopyArtifactNotFound) Error() string { 416 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactNotFound %+v", 404, o.Payload) 417 } 418 419 func (o *CopyArtifactNotFound) String() string { 420 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactNotFound %+v", 404, o.Payload) 421 } 422 423 func (o *CopyArtifactNotFound) GetPayload() *models.Errors { 424 return o.Payload 425 } 426 427 func (o *CopyArtifactNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 428 429 // hydrates response header X-Request-Id 430 hdrXRequestID := response.GetHeader("X-Request-Id") 431 432 if hdrXRequestID != "" { 433 o.XRequestID = hdrXRequestID 434 } 435 436 o.Payload = new(models.Errors) 437 438 // response payload 439 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 440 return err 441 } 442 443 return nil 444 } 445 446 // NewCopyArtifactMethodNotAllowed creates a CopyArtifactMethodNotAllowed with default headers values 447 func NewCopyArtifactMethodNotAllowed() *CopyArtifactMethodNotAllowed { 448 return &CopyArtifactMethodNotAllowed{} 449 } 450 451 /* 452 CopyArtifactMethodNotAllowed describes a response with status code 405, with default header values. 453 454 Method not allowed 455 */ 456 type CopyArtifactMethodNotAllowed struct { 457 458 /* The ID of the corresponding request for the response 459 */ 460 XRequestID string 461 462 Payload *models.Errors 463 } 464 465 // IsSuccess returns true when this copy artifact method not allowed response has a 2xx status code 466 func (o *CopyArtifactMethodNotAllowed) IsSuccess() bool { 467 return false 468 } 469 470 // IsRedirect returns true when this copy artifact method not allowed response has a 3xx status code 471 func (o *CopyArtifactMethodNotAllowed) IsRedirect() bool { 472 return false 473 } 474 475 // IsClientError returns true when this copy artifact method not allowed response has a 4xx status code 476 func (o *CopyArtifactMethodNotAllowed) IsClientError() bool { 477 return true 478 } 479 480 // IsServerError returns true when this copy artifact method not allowed response has a 5xx status code 481 func (o *CopyArtifactMethodNotAllowed) IsServerError() bool { 482 return false 483 } 484 485 // IsCode returns true when this copy artifact method not allowed response a status code equal to that given 486 func (o *CopyArtifactMethodNotAllowed) IsCode(code int) bool { 487 return code == 405 488 } 489 490 func (o *CopyArtifactMethodNotAllowed) Error() string { 491 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactMethodNotAllowed %+v", 405, o.Payload) 492 } 493 494 func (o *CopyArtifactMethodNotAllowed) String() string { 495 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactMethodNotAllowed %+v", 405, o.Payload) 496 } 497 498 func (o *CopyArtifactMethodNotAllowed) GetPayload() *models.Errors { 499 return o.Payload 500 } 501 502 func (o *CopyArtifactMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 503 504 // hydrates response header X-Request-Id 505 hdrXRequestID := response.GetHeader("X-Request-Id") 506 507 if hdrXRequestID != "" { 508 o.XRequestID = hdrXRequestID 509 } 510 511 o.Payload = new(models.Errors) 512 513 // response payload 514 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 515 return err 516 } 517 518 return nil 519 } 520 521 // NewCopyArtifactInternalServerError creates a CopyArtifactInternalServerError with default headers values 522 func NewCopyArtifactInternalServerError() *CopyArtifactInternalServerError { 523 return &CopyArtifactInternalServerError{} 524 } 525 526 /* 527 CopyArtifactInternalServerError describes a response with status code 500, with default header values. 528 529 Internal server error 530 */ 531 type CopyArtifactInternalServerError struct { 532 533 /* The ID of the corresponding request for the response 534 */ 535 XRequestID string 536 537 Payload *models.Errors 538 } 539 540 // IsSuccess returns true when this copy artifact internal server error response has a 2xx status code 541 func (o *CopyArtifactInternalServerError) IsSuccess() bool { 542 return false 543 } 544 545 // IsRedirect returns true when this copy artifact internal server error response has a 3xx status code 546 func (o *CopyArtifactInternalServerError) IsRedirect() bool { 547 return false 548 } 549 550 // IsClientError returns true when this copy artifact internal server error response has a 4xx status code 551 func (o *CopyArtifactInternalServerError) IsClientError() bool { 552 return false 553 } 554 555 // IsServerError returns true when this copy artifact internal server error response has a 5xx status code 556 func (o *CopyArtifactInternalServerError) IsServerError() bool { 557 return true 558 } 559 560 // IsCode returns true when this copy artifact internal server error response a status code equal to that given 561 func (o *CopyArtifactInternalServerError) IsCode(code int) bool { 562 return code == 500 563 } 564 565 func (o *CopyArtifactInternalServerError) Error() string { 566 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactInternalServerError %+v", 500, o.Payload) 567 } 568 569 func (o *CopyArtifactInternalServerError) String() string { 570 return fmt.Sprintf("[POST /projects/{project_name}/repositories/{repository_name}/artifacts][%d] copyArtifactInternalServerError %+v", 500, o.Payload) 571 } 572 573 func (o *CopyArtifactInternalServerError) GetPayload() *models.Errors { 574 return o.Payload 575 } 576 577 func (o *CopyArtifactInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 578 579 // hydrates response header X-Request-Id 580 hdrXRequestID := response.GetHeader("X-Request-Id") 581 582 if hdrXRequestID != "" { 583 o.XRequestID = hdrXRequestID 584 } 585 586 o.Payload = new(models.Errors) 587 588 // response payload 589 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 590 return err 591 } 592 593 return nil 594 }