github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/client/tasks/tasks_client.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 "github.com/go-openapi/runtime" 10 11 strfmt "github.com/go-openapi/strfmt" 12 ) 13 14 // New creates a new tasks API client. 15 func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { 16 return &Client{transport: transport, formats: formats} 17 } 18 19 /* 20 Client for tasks API 21 */ 22 type Client struct { 23 transport runtime.ClientTransport 24 formats strfmt.Registry 25 } 26 27 /* 28 AddCommentToTask adds a comment to a task 29 30 The comment can contain ___github markdown___ syntax. 31 Fenced codeblocks etc are supported through pygments. 32 33 */ 34 func (a *Client) AddCommentToTask(params *AddCommentToTaskParams, authInfo runtime.ClientAuthInfoWriter) (*AddCommentToTaskCreated, error) { 35 // TODO: Validate the params before sending 36 if params == nil { 37 params = NewAddCommentToTaskParams() 38 } 39 40 result, err := a.transport.Submit(&runtime.ClientOperation{ 41 ID: "addCommentToTask", 42 Method: "POST", 43 PathPattern: "/tasks/{id}/comments", 44 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 45 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 46 Schemes: []string{"http", "https"}, 47 Params: params, 48 Reader: &AddCommentToTaskReader{formats: a.formats}, 49 AuthInfo: authInfo, 50 Context: params.Context, 51 Client: params.HTTPClient, 52 }) 53 if err != nil { 54 return nil, err 55 } 56 success, ok := result.(*AddCommentToTaskCreated) 57 if ok { 58 return success, nil 59 } 60 // unexpected success response 61 unexpectedSuccess := result.(*AddCommentToTaskDefault) 62 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 63 } 64 65 /* 66 CreateTask creates a task object 67 68 Allows for creating a task. 69 This operation requires authentication so that we know which user 70 created the task. 71 72 */ 73 func (a *Client) CreateTask(params *CreateTaskParams, authInfo runtime.ClientAuthInfoWriter) (*CreateTaskCreated, error) { 74 // TODO: Validate the params before sending 75 if params == nil { 76 params = NewCreateTaskParams() 77 } 78 79 result, err := a.transport.Submit(&runtime.ClientOperation{ 80 ID: "createTask", 81 Method: "POST", 82 PathPattern: "/tasks", 83 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 84 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 85 Schemes: []string{"http", "https"}, 86 Params: params, 87 Reader: &CreateTaskReader{formats: a.formats}, 88 AuthInfo: authInfo, 89 Context: params.Context, 90 Client: params.HTTPClient, 91 }) 92 if err != nil { 93 return nil, err 94 } 95 success, ok := result.(*CreateTaskCreated) 96 if ok { 97 return success, nil 98 } 99 // unexpected success response 100 unexpectedSuccess := result.(*CreateTaskDefault) 101 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 102 } 103 104 /* 105 DeleteTask deletes a task 106 107 This is a soft delete and changes the task status to ignored. 108 109 */ 110 func (a *Client) DeleteTask(params *DeleteTaskParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteTaskNoContent, error) { 111 // TODO: Validate the params before sending 112 if params == nil { 113 params = NewDeleteTaskParams() 114 } 115 116 result, err := a.transport.Submit(&runtime.ClientOperation{ 117 ID: "deleteTask", 118 Method: "DELETE", 119 PathPattern: "/tasks/{id}", 120 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 121 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 122 Schemes: []string{"http", "https"}, 123 Params: params, 124 Reader: &DeleteTaskReader{formats: a.formats}, 125 AuthInfo: authInfo, 126 Context: params.Context, 127 Client: params.HTTPClient, 128 }) 129 if err != nil { 130 return nil, err 131 } 132 success, ok := result.(*DeleteTaskNoContent) 133 if ok { 134 return success, nil 135 } 136 // unexpected success response 137 unexpectedSuccess := result.(*DeleteTaskDefault) 138 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 139 } 140 141 /* 142 GetTaskComments gets the comments for a task 143 144 The comments require a size parameter. 145 146 */ 147 func (a *Client) GetTaskComments(params *GetTaskCommentsParams) (*GetTaskCommentsOK, error) { 148 // TODO: Validate the params before sending 149 if params == nil { 150 params = NewGetTaskCommentsParams() 151 } 152 153 result, err := a.transport.Submit(&runtime.ClientOperation{ 154 ID: "getTaskComments", 155 Method: "GET", 156 PathPattern: "/tasks/{id}/comments", 157 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 158 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 159 Schemes: []string{"http", "https"}, 160 Params: params, 161 Reader: &GetTaskCommentsReader{formats: a.formats}, 162 Context: params.Context, 163 Client: params.HTTPClient, 164 }) 165 if err != nil { 166 return nil, err 167 } 168 success, ok := result.(*GetTaskCommentsOK) 169 if ok { 170 return success, nil 171 } 172 // unexpected success response 173 unexpectedSuccess := result.(*GetTaskCommentsDefault) 174 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 175 } 176 177 /* 178 GetTaskDetails gets the details for a task 179 180 The details view has more information than the card view. 181 You can see who reported the issue and who last updated it when. 182 183 There are also comments for each issue. 184 185 */ 186 func (a *Client) GetTaskDetails(params *GetTaskDetailsParams) (*GetTaskDetailsOK, error) { 187 // TODO: Validate the params before sending 188 if params == nil { 189 params = NewGetTaskDetailsParams() 190 } 191 192 result, err := a.transport.Submit(&runtime.ClientOperation{ 193 ID: "getTaskDetails", 194 Method: "GET", 195 PathPattern: "/tasks/{id}", 196 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 197 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 198 Schemes: []string{"http", "https"}, 199 Params: params, 200 Reader: &GetTaskDetailsReader{formats: a.formats}, 201 Context: params.Context, 202 Client: params.HTTPClient, 203 }) 204 if err != nil { 205 return nil, err 206 } 207 success, ok := result.(*GetTaskDetailsOK) 208 if ok { 209 return success, nil 210 } 211 // unexpected success response 212 unexpectedSuccess := result.(*GetTaskDetailsDefault) 213 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 214 } 215 216 /* 217 ListTasks lists the tasks 218 219 Allows for specifying a number of filter parameters to 220 narrow down the results. 221 Also allows for specifying a **sinceId** and **pageSize** parameter 222 to page through large result sets. 223 224 */ 225 func (a *Client) ListTasks(params *ListTasksParams) (*ListTasksOK, error) { 226 // TODO: Validate the params before sending 227 if params == nil { 228 params = NewListTasksParams() 229 } 230 231 result, err := a.transport.Submit(&runtime.ClientOperation{ 232 ID: "listTasks", 233 Method: "GET", 234 PathPattern: "/tasks", 235 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 236 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 237 Schemes: []string{"http", "https"}, 238 Params: params, 239 Reader: &ListTasksReader{formats: a.formats}, 240 Context: params.Context, 241 Client: params.HTTPClient, 242 }) 243 if err != nil { 244 return nil, err 245 } 246 success, ok := result.(*ListTasksOK) 247 if ok { 248 return success, nil 249 } 250 // unexpected success response 251 unexpectedSuccess := result.(*ListTasksDefault) 252 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 253 } 254 255 /* 256 UpdateTask updates the details for a task 257 258 Allows for updating a task. 259 This operation requires authentication so that we know which user 260 last updated the task. 261 262 */ 263 func (a *Client) UpdateTask(params *UpdateTaskParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateTaskOK, error) { 264 // TODO: Validate the params before sending 265 if params == nil { 266 params = NewUpdateTaskParams() 267 } 268 269 result, err := a.transport.Submit(&runtime.ClientOperation{ 270 ID: "updateTask", 271 Method: "PUT", 272 PathPattern: "/tasks/{id}", 273 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 274 ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 275 Schemes: []string{"http", "https"}, 276 Params: params, 277 Reader: &UpdateTaskReader{formats: a.formats}, 278 AuthInfo: authInfo, 279 Context: params.Context, 280 Client: params.HTTPClient, 281 }) 282 if err != nil { 283 return nil, err 284 } 285 success, ok := result.(*UpdateTaskOK) 286 if ok { 287 return success, nil 288 } 289 // unexpected success response 290 unexpectedSuccess := result.(*UpdateTaskDefault) 291 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 292 } 293 294 /* 295 UploadTaskFile adds a file to a task 296 297 The file can't be larger than **5MB** 298 */ 299 func (a *Client) UploadTaskFile(params *UploadTaskFileParams, authInfo runtime.ClientAuthInfoWriter) (*UploadTaskFileCreated, error) { 300 // TODO: Validate the params before sending 301 if params == nil { 302 params = NewUploadTaskFileParams() 303 } 304 305 result, err := a.transport.Submit(&runtime.ClientOperation{ 306 ID: "uploadTaskFile", 307 Method: "POST", 308 PathPattern: "/tasks/{id}/files", 309 ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"}, 310 ConsumesMediaTypes: []string{"multipart/form-data"}, 311 Schemes: []string{"http", "https"}, 312 Params: params, 313 Reader: &UploadTaskFileReader{formats: a.formats}, 314 AuthInfo: authInfo, 315 Context: params.Context, 316 Client: params.HTTPClient, 317 }) 318 if err != nil { 319 return nil, err 320 } 321 success, ok := result.(*UploadTaskFileCreated) 322 if ok { 323 return success, nil 324 } 325 // unexpected success response 326 unexpectedSuccess := result.(*UploadTaskFileDefault) 327 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 328 } 329 330 // SetTransport changes the transport on the client 331 func (a *Client) SetTransport(transport runtime.ClientTransport) { 332 a.transport = transport 333 }