github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/client/tasks/delete_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/runtime" 13 14 strfmt "github.com/go-openapi/strfmt" 15 16 models "github.com/go-swagger/go-swagger/examples/task-tracker/models" 17 ) 18 19 // DeleteTaskReader is a Reader for the DeleteTask structure. 20 type DeleteTaskReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *DeleteTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 case 204: 28 result := NewDeleteTaskNoContent() 29 if err := result.readResponse(response, consumer, o.formats); err != nil { 30 return nil, err 31 } 32 return result, nil 33 default: 34 result := NewDeleteTaskDefault(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 // NewDeleteTaskNoContent creates a DeleteTaskNoContent with default headers values 46 func NewDeleteTaskNoContent() *DeleteTaskNoContent { 47 return &DeleteTaskNoContent{} 48 } 49 50 /*DeleteTaskNoContent handles this case with default header values. 51 52 Task deleted 53 */ 54 type DeleteTaskNoContent struct { 55 } 56 57 func (o *DeleteTaskNoContent) Error() string { 58 return fmt.Sprintf("[DELETE /tasks/{id}][%d] deleteTaskNoContent ", 204) 59 } 60 61 func (o *DeleteTaskNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 62 63 return nil 64 } 65 66 // NewDeleteTaskDefault creates a DeleteTaskDefault with default headers values 67 func NewDeleteTaskDefault(code int) *DeleteTaskDefault { 68 return &DeleteTaskDefault{ 69 _statusCode: code, 70 } 71 } 72 73 /*DeleteTaskDefault handles this case with default header values. 74 75 Error response 76 */ 77 type DeleteTaskDefault struct { 78 _statusCode int 79 80 XErrorCode string 81 82 Payload *models.Error 83 } 84 85 // Code gets the status code for the delete task default response 86 func (o *DeleteTaskDefault) Code() int { 87 return o._statusCode 88 } 89 90 func (o *DeleteTaskDefault) Error() string { 91 return fmt.Sprintf("[DELETE /tasks/{id}][%d] deleteTask default %+v", o._statusCode, o.Payload) 92 } 93 94 func (o *DeleteTaskDefault) GetPayload() *models.Error { 95 return o.Payload 96 } 97 98 func (o *DeleteTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 99 100 // response header X-Error-Code 101 o.XErrorCode = response.GetHeader("X-Error-Code") 102 103 o.Payload = new(models.Error) 104 105 // response payload 106 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 107 return err 108 } 109 110 return nil 111 }