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