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