github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/task-tracker/client/tasks/get_task_comments_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 "github.com/go-openapi/strfmt" 14 15 "github.com/go-swagger/go-swagger/examples/task-tracker/models" 16 ) 17 18 // GetTaskCommentsReader is a Reader for the GetTaskComments structure. 19 type GetTaskCommentsReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *GetTaskCommentsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewGetTaskCommentsOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 default: 33 result := NewGetTaskCommentsDefault(response.Code()) 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 if response.Code()/100 == 2 { 38 return result, nil 39 } 40 return nil, result 41 } 42 } 43 44 // NewGetTaskCommentsOK creates a GetTaskCommentsOK with default headers values 45 func NewGetTaskCommentsOK() *GetTaskCommentsOK { 46 return &GetTaskCommentsOK{} 47 } 48 49 /* 50 GetTaskCommentsOK describes a response with status code 200, with default header values. 51 52 The list of comments 53 */ 54 type GetTaskCommentsOK struct { 55 Payload []*models.Comment 56 } 57 58 // IsSuccess returns true when this get task comments o k response has a 2xx status code 59 func (o *GetTaskCommentsOK) IsSuccess() bool { 60 return true 61 } 62 63 // IsRedirect returns true when this get task comments o k response has a 3xx status code 64 func (o *GetTaskCommentsOK) IsRedirect() bool { 65 return false 66 } 67 68 // IsClientError returns true when this get task comments o k response has a 4xx status code 69 func (o *GetTaskCommentsOK) IsClientError() bool { 70 return false 71 } 72 73 // IsServerError returns true when this get task comments o k response has a 5xx status code 74 func (o *GetTaskCommentsOK) IsServerError() bool { 75 return false 76 } 77 78 // IsCode returns true when this get task comments o k response a status code equal to that given 79 func (o *GetTaskCommentsOK) IsCode(code int) bool { 80 return code == 200 81 } 82 83 // Code gets the status code for the get task comments o k response 84 func (o *GetTaskCommentsOK) Code() int { 85 return 200 86 } 87 88 func (o *GetTaskCommentsOK) Error() string { 89 return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskCommentsOK %+v", 200, o.Payload) 90 } 91 92 func (o *GetTaskCommentsOK) String() string { 93 return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskCommentsOK %+v", 200, o.Payload) 94 } 95 96 func (o *GetTaskCommentsOK) GetPayload() []*models.Comment { 97 return o.Payload 98 } 99 100 func (o *GetTaskCommentsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 // response payload 103 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 104 return err 105 } 106 107 return nil 108 } 109 110 // NewGetTaskCommentsDefault creates a GetTaskCommentsDefault with default headers values 111 func NewGetTaskCommentsDefault(code int) *GetTaskCommentsDefault { 112 return &GetTaskCommentsDefault{ 113 _statusCode: code, 114 } 115 } 116 117 /* 118 GetTaskCommentsDefault describes a response with status code -1, with default header values. 119 120 Error response 121 */ 122 type GetTaskCommentsDefault struct { 123 _statusCode int 124 XErrorCode string 125 126 Payload *models.Error 127 } 128 129 // IsSuccess returns true when this get task comments default response has a 2xx status code 130 func (o *GetTaskCommentsDefault) IsSuccess() bool { 131 return o._statusCode/100 == 2 132 } 133 134 // IsRedirect returns true when this get task comments default response has a 3xx status code 135 func (o *GetTaskCommentsDefault) IsRedirect() bool { 136 return o._statusCode/100 == 3 137 } 138 139 // IsClientError returns true when this get task comments default response has a 4xx status code 140 func (o *GetTaskCommentsDefault) IsClientError() bool { 141 return o._statusCode/100 == 4 142 } 143 144 // IsServerError returns true when this get task comments default response has a 5xx status code 145 func (o *GetTaskCommentsDefault) IsServerError() bool { 146 return o._statusCode/100 == 5 147 } 148 149 // IsCode returns true when this get task comments default response a status code equal to that given 150 func (o *GetTaskCommentsDefault) IsCode(code int) bool { 151 return o._statusCode == code 152 } 153 154 // Code gets the status code for the get task comments default response 155 func (o *GetTaskCommentsDefault) Code() int { 156 return o._statusCode 157 } 158 159 func (o *GetTaskCommentsDefault) Error() string { 160 return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskComments default %+v", o._statusCode, o.Payload) 161 } 162 163 func (o *GetTaskCommentsDefault) String() string { 164 return fmt.Sprintf("[GET /tasks/{id}/comments][%d] getTaskComments default %+v", o._statusCode, o.Payload) 165 } 166 167 func (o *GetTaskCommentsDefault) GetPayload() *models.Error { 168 return o.Payload 169 } 170 171 func (o *GetTaskCommentsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 172 173 // hydrates response header X-Error-Code 174 hdrXErrorCode := response.GetHeader("X-Error-Code") 175 176 if hdrXErrorCode != "" { 177 o.XErrorCode = hdrXErrorCode 178 } 179 180 o.Payload = new(models.Error) 181 182 // response payload 183 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 184 return err 185 } 186 187 return nil 188 }