github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list-strict/client/todos/todos_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package todos
     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 todos 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 todos API
    20  */
    21  type Client struct {
    22  	transport runtime.ClientTransport
    23  	formats   strfmt.Registry
    24  }
    25  
    26  // ClientService is the interface for Client methods
    27  type ClientService interface {
    28  	AddOne(params *AddOneParams, authInfo runtime.ClientAuthInfoWriter) (*AddOneCreated, error)
    29  
    30  	DestroyOne(params *DestroyOneParams, authInfo runtime.ClientAuthInfoWriter) (*DestroyOneNoContent, error)
    31  
    32  	Find(params *FindParams, authInfo runtime.ClientAuthInfoWriter) (*FindOK, error)
    33  
    34  	UpdateOne(params *UpdateOneParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateOneOK, error)
    35  
    36  	SetTransport(transport runtime.ClientTransport)
    37  }
    38  
    39  /*
    40    AddOne add one API
    41  */
    42  func (a *Client) AddOne(params *AddOneParams, authInfo runtime.ClientAuthInfoWriter) (*AddOneCreated, error) {
    43  	// TODO: Validate the params before sending
    44  	if params == nil {
    45  		params = NewAddOneParams()
    46  	}
    47  
    48  	result, err := a.transport.Submit(&runtime.ClientOperation{
    49  		ID:                 "addOne",
    50  		Method:             "POST",
    51  		PathPattern:        "/",
    52  		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
    53  		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
    54  		Schemes:            []string{"http", "https"},
    55  		Params:             params,
    56  		Reader:             &AddOneReader{formats: a.formats},
    57  		AuthInfo:           authInfo,
    58  		Context:            params.Context,
    59  		Client:             params.HTTPClient,
    60  	})
    61  	if err != nil {
    62  		return nil, err
    63  	}
    64  	success, ok := result.(*AddOneCreated)
    65  	if ok {
    66  		return success, nil
    67  	}
    68  	// unexpected success response
    69  	unexpectedSuccess := result.(*AddOneDefault)
    70  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
    71  }
    72  
    73  /*
    74    DestroyOne destroy one API
    75  */
    76  func (a *Client) DestroyOne(params *DestroyOneParams, authInfo runtime.ClientAuthInfoWriter) (*DestroyOneNoContent, error) {
    77  	// TODO: Validate the params before sending
    78  	if params == nil {
    79  		params = NewDestroyOneParams()
    80  	}
    81  
    82  	result, err := a.transport.Submit(&runtime.ClientOperation{
    83  		ID:                 "destroyOne",
    84  		Method:             "DELETE",
    85  		PathPattern:        "/{id}",
    86  		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
    87  		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
    88  		Schemes:            []string{"http", "https"},
    89  		Params:             params,
    90  		Reader:             &DestroyOneReader{formats: a.formats},
    91  		AuthInfo:           authInfo,
    92  		Context:            params.Context,
    93  		Client:             params.HTTPClient,
    94  	})
    95  	if err != nil {
    96  		return nil, err
    97  	}
    98  	success, ok := result.(*DestroyOneNoContent)
    99  	if ok {
   100  		return success, nil
   101  	}
   102  	// unexpected success response
   103  	unexpectedSuccess := result.(*DestroyOneDefault)
   104  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   105  }
   106  
   107  /*
   108    Find find API
   109  */
   110  func (a *Client) Find(params *FindParams, authInfo runtime.ClientAuthInfoWriter) (*FindOK, error) {
   111  	// TODO: Validate the params before sending
   112  	if params == nil {
   113  		params = NewFindParams()
   114  	}
   115  
   116  	result, err := a.transport.Submit(&runtime.ClientOperation{
   117  		ID:                 "find",
   118  		Method:             "GET",
   119  		PathPattern:        "/",
   120  		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
   121  		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
   122  		Schemes:            []string{"http", "https"},
   123  		Params:             params,
   124  		Reader:             &FindReader{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.(*FindOK)
   133  	if ok {
   134  		return success, nil
   135  	}
   136  	// unexpected success response
   137  	unexpectedSuccess := result.(*FindDefault)
   138  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   139  }
   140  
   141  /*
   142    UpdateOne update one API
   143  */
   144  func (a *Client) UpdateOne(params *UpdateOneParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateOneOK, error) {
   145  	// TODO: Validate the params before sending
   146  	if params == nil {
   147  		params = NewUpdateOneParams()
   148  	}
   149  
   150  	result, err := a.transport.Submit(&runtime.ClientOperation{
   151  		ID:                 "updateOne",
   152  		Method:             "PUT",
   153  		PathPattern:        "/{id}",
   154  		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
   155  		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
   156  		Schemes:            []string{"http", "https"},
   157  		Params:             params,
   158  		Reader:             &UpdateOneReader{formats: a.formats},
   159  		AuthInfo:           authInfo,
   160  		Context:            params.Context,
   161  		Client:             params.HTTPClient,
   162  	})
   163  	if err != nil {
   164  		return nil, err
   165  	}
   166  	success, ok := result.(*UpdateOneOK)
   167  	if ok {
   168  		return success, nil
   169  	}
   170  	// unexpected success response
   171  	unexpectedSuccess := result.(*UpdateOneDefault)
   172  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   173  }
   174  
   175  // SetTransport changes the transport on the client
   176  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   177  	a.transport = transport
   178  }