github.com/jamescostian/go-swagger@v0.30.4-0.20221130163922-68364d6b567b/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  	"github.com/go-openapi/strfmt"
    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  
    55  Fenced codeblocks etc are supported through pygments.
    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  
    97  This operation requires authentication so that we know which user
    98  created the task.
    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  func (a *Client) DeleteTask(params *DeleteTaskParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteTaskNoContent, error) {
   141  	// TODO: Validate the params before sending
   142  	if params == nil {
   143  		params = NewDeleteTaskParams()
   144  	}
   145  	op := &runtime.ClientOperation{
   146  		ID:                 "deleteTask",
   147  		Method:             "DELETE",
   148  		PathPattern:        "/tasks/{id}",
   149  		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   150  		ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   151  		Schemes:            []string{"http", "https"},
   152  		Params:             params,
   153  		Reader:             &DeleteTaskReader{formats: a.formats},
   154  		AuthInfo:           authInfo,
   155  		Context:            params.Context,
   156  		Client:             params.HTTPClient,
   157  	}
   158  	for _, opt := range opts {
   159  		opt(op)
   160  	}
   161  
   162  	result, err := a.transport.Submit(op)
   163  	if err != nil {
   164  		return nil, err
   165  	}
   166  	success, ok := result.(*DeleteTaskNoContent)
   167  	if ok {
   168  		return success, nil
   169  	}
   170  	// unexpected success response
   171  	unexpectedSuccess := result.(*DeleteTaskDefault)
   172  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   173  }
   174  
   175  /*
   176  GetTaskComments gets the comments for a task
   177  
   178  The comments require a size parameter.
   179  */
   180  func (a *Client) GetTaskComments(params *GetTaskCommentsParams, opts ...ClientOption) (*GetTaskCommentsOK, error) {
   181  	// TODO: Validate the params before sending
   182  	if params == nil {
   183  		params = NewGetTaskCommentsParams()
   184  	}
   185  	op := &runtime.ClientOperation{
   186  		ID:                 "getTaskComments",
   187  		Method:             "GET",
   188  		PathPattern:        "/tasks/{id}/comments",
   189  		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   190  		ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   191  		Schemes:            []string{"http", "https"},
   192  		Params:             params,
   193  		Reader:             &GetTaskCommentsReader{formats: a.formats},
   194  		Context:            params.Context,
   195  		Client:             params.HTTPClient,
   196  	}
   197  	for _, opt := range opts {
   198  		opt(op)
   199  	}
   200  
   201  	result, err := a.transport.Submit(op)
   202  	if err != nil {
   203  		return nil, err
   204  	}
   205  	success, ok := result.(*GetTaskCommentsOK)
   206  	if ok {
   207  		return success, nil
   208  	}
   209  	// unexpected success response
   210  	unexpectedSuccess := result.(*GetTaskCommentsDefault)
   211  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   212  }
   213  
   214  /*
   215  	GetTaskDetails gets the details for a task
   216  
   217  	The details view has more information than the card view.
   218  
   219  You can see who reported the issue and who last updated it when.
   220  
   221  There are also comments for each issue.
   222  */
   223  func (a *Client) GetTaskDetails(params *GetTaskDetailsParams, opts ...ClientOption) (*GetTaskDetailsOK, error) {
   224  	// TODO: Validate the params before sending
   225  	if params == nil {
   226  		params = NewGetTaskDetailsParams()
   227  	}
   228  	op := &runtime.ClientOperation{
   229  		ID:                 "getTaskDetails",
   230  		Method:             "GET",
   231  		PathPattern:        "/tasks/{id}",
   232  		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   233  		ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   234  		Schemes:            []string{"http", "https"},
   235  		Params:             params,
   236  		Reader:             &GetTaskDetailsReader{formats: a.formats},
   237  		Context:            params.Context,
   238  		Client:             params.HTTPClient,
   239  	}
   240  	for _, opt := range opts {
   241  		opt(op)
   242  	}
   243  
   244  	result, err := a.transport.Submit(op)
   245  	if err != nil {
   246  		return nil, err
   247  	}
   248  	success, ok := result.(*GetTaskDetailsOK)
   249  	if ok {
   250  		return success, nil
   251  	}
   252  	// unexpected success response
   253  	unexpectedSuccess := result.(*GetTaskDetailsDefault)
   254  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   255  }
   256  
   257  /*
   258  	ListTasks lists the tasks
   259  
   260  	Allows for specifying a number of filter parameters to
   261  
   262  narrow down the results.
   263  Also allows for specifying a **sinceId** and **pageSize** parameter
   264  to page through large result sets.
   265  */
   266  func (a *Client) ListTasks(params *ListTasksParams, opts ...ClientOption) (*ListTasksOK, error) {
   267  	// TODO: Validate the params before sending
   268  	if params == nil {
   269  		params = NewListTasksParams()
   270  	}
   271  	op := &runtime.ClientOperation{
   272  		ID:                 "listTasks",
   273  		Method:             "GET",
   274  		PathPattern:        "/tasks",
   275  		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   276  		ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   277  		Schemes:            []string{"http", "https"},
   278  		Params:             params,
   279  		Reader:             &ListTasksReader{formats: a.formats},
   280  		Context:            params.Context,
   281  		Client:             params.HTTPClient,
   282  	}
   283  	for _, opt := range opts {
   284  		opt(op)
   285  	}
   286  
   287  	result, err := a.transport.Submit(op)
   288  	if err != nil {
   289  		return nil, err
   290  	}
   291  	success, ok := result.(*ListTasksOK)
   292  	if ok {
   293  		return success, nil
   294  	}
   295  	// unexpected success response
   296  	unexpectedSuccess := result.(*ListTasksDefault)
   297  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   298  }
   299  
   300  /*
   301  	UpdateTask updates the details for a task
   302  
   303  	Allows for updating a task.
   304  
   305  This operation requires authentication so that we know which user
   306  last updated the task.
   307  */
   308  func (a *Client) UpdateTask(params *UpdateTaskParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateTaskOK, error) {
   309  	// TODO: Validate the params before sending
   310  	if params == nil {
   311  		params = NewUpdateTaskParams()
   312  	}
   313  	op := &runtime.ClientOperation{
   314  		ID:                 "updateTask",
   315  		Method:             "PUT",
   316  		PathPattern:        "/tasks/{id}",
   317  		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   318  		ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   319  		Schemes:            []string{"http", "https"},
   320  		Params:             params,
   321  		Reader:             &UpdateTaskReader{formats: a.formats},
   322  		AuthInfo:           authInfo,
   323  		Context:            params.Context,
   324  		Client:             params.HTTPClient,
   325  	}
   326  	for _, opt := range opts {
   327  		opt(op)
   328  	}
   329  
   330  	result, err := a.transport.Submit(op)
   331  	if err != nil {
   332  		return nil, err
   333  	}
   334  	success, ok := result.(*UpdateTaskOK)
   335  	if ok {
   336  		return success, nil
   337  	}
   338  	// unexpected success response
   339  	unexpectedSuccess := result.(*UpdateTaskDefault)
   340  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   341  }
   342  
   343  /*
   344  UploadTaskFile adds a file to a task
   345  
   346  The file can't be larger than **5MB**
   347  */
   348  func (a *Client) UploadTaskFile(params *UploadTaskFileParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UploadTaskFileCreated, error) {
   349  	// TODO: Validate the params before sending
   350  	if params == nil {
   351  		params = NewUploadTaskFileParams()
   352  	}
   353  	op := &runtime.ClientOperation{
   354  		ID:                 "uploadTaskFile",
   355  		Method:             "POST",
   356  		PathPattern:        "/tasks/{id}/files",
   357  		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
   358  		ConsumesMediaTypes: []string{"multipart/form-data"},
   359  		Schemes:            []string{"http", "https"},
   360  		Params:             params,
   361  		Reader:             &UploadTaskFileReader{formats: a.formats},
   362  		AuthInfo:           authInfo,
   363  		Context:            params.Context,
   364  		Client:             params.HTTPClient,
   365  	}
   366  	for _, opt := range opts {
   367  		opt(op)
   368  	}
   369  
   370  	result, err := a.transport.Submit(op)
   371  	if err != nil {
   372  		return nil, err
   373  	}
   374  	success, ok := result.(*UploadTaskFileCreated)
   375  	if ok {
   376  		return success, nil
   377  	}
   378  	// unexpected success response
   379  	unexpectedSuccess := result.(*UploadTaskFileDefault)
   380  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   381  }
   382  
   383  // SetTransport changes the transport on the client
   384  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   385  	a.transport = transport
   386  }