github.com/circl-dev/go-swagger@v0.31.0/examples/task-tracker/client/tasks/create_task_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 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/strfmt" 14 "github.com/circl-dev/runtime" 15 16 "github.com/circl-dev/go-swagger/examples/task-tracker/models" 17 ) 18 19 // CreateTaskReader is a Reader for the CreateTask structure. 20 type CreateTaskReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *CreateTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 case 201: 28 result := NewCreateTaskCreated() 29 if err := result.readResponse(response, consumer, o.formats); err != nil { 30 return nil, err 31 } 32 return result, nil 33 default: 34 result := NewCreateTaskDefault(response.Code()) 35 if err := result.readResponse(response, consumer, o.formats); err != nil { 36 return nil, err 37 } 38 if response.Code()/100 == 2 { 39 return result, nil 40 } 41 return nil, result 42 } 43 } 44 45 // NewCreateTaskCreated creates a CreateTaskCreated with default headers values 46 func NewCreateTaskCreated() *CreateTaskCreated { 47 return &CreateTaskCreated{} 48 } 49 50 /* CreateTaskCreated describes a response with status code 201, with default header values. 51 52 Task created 53 */ 54 type CreateTaskCreated struct { 55 56 /* URL to the newly added Task 57 58 Format: uri 59 */ 60 Location strfmt.URI 61 } 62 63 func (o *CreateTaskCreated) Error() string { 64 return fmt.Sprintf("[POST /tasks][%d] createTaskCreated ", 201) 65 } 66 67 func (o *CreateTaskCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 68 69 // hydrates response header Location 70 hdrLocation := response.GetHeader("Location") 71 72 if hdrLocation != "" { 73 vallocation, err := formats.Parse("uri", hdrLocation) 74 if err != nil { 75 return errors.InvalidType("Location", "header", "strfmt.URI", hdrLocation) 76 } 77 o.Location = *(vallocation.(*strfmt.URI)) 78 } 79 80 return nil 81 } 82 83 // NewCreateTaskDefault creates a CreateTaskDefault with default headers values 84 func NewCreateTaskDefault(code int) *CreateTaskDefault { 85 return &CreateTaskDefault{ 86 _statusCode: code, 87 } 88 } 89 90 /* CreateTaskDefault describes a response with status code -1, with default header values. 91 92 Error response 93 */ 94 type CreateTaskDefault struct { 95 _statusCode int 96 XErrorCode string 97 98 Payload *models.Error 99 } 100 101 // Code gets the status code for the create task default response 102 func (o *CreateTaskDefault) Code() int { 103 return o._statusCode 104 } 105 106 func (o *CreateTaskDefault) Error() string { 107 return fmt.Sprintf("[POST /tasks][%d] createTask default %+v", o._statusCode, o.Payload) 108 } 109 func (o *CreateTaskDefault) GetPayload() *models.Error { 110 return o.Payload 111 } 112 113 func (o *CreateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 114 115 // hydrates response header X-Error-Code 116 hdrXErrorCode := response.GetHeader("X-Error-Code") 117 118 if hdrXErrorCode != "" { 119 o.XErrorCode = hdrXErrorCode 120 } 121 122 o.Payload = new(models.Error) 123 124 // response payload 125 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 126 return err 127 } 128 129 return nil 130 }