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