github.com/circl-dev/go-swagger@v0.31.0/examples/cli/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 // 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 AddOne(params *AddOneParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AddOneCreated, error) 32 33 DestroyOne(params *DestroyOneParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DestroyOneNoContent, error) 34 35 FindTodos(params *FindTodosParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*FindTodosOK, error) 36 37 UpdateOne(params *UpdateOneParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOneOK, error) 38 39 SetTransport(transport runtime.ClientTransport) 40 } 41 42 /* 43 AddOne add one API 44 */ 45 func (a *Client) AddOne(params *AddOneParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AddOneCreated, error) { 46 // TODO: Validate the params before sending 47 if params == nil { 48 params = NewAddOneParams() 49 } 50 op := &runtime.ClientOperation{ 51 ID: "addOne", 52 Method: "POST", 53 PathPattern: "/", 54 ProducesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 55 ConsumesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 56 Schemes: []string{"http"}, 57 Params: params, 58 Reader: &AddOneReader{formats: a.formats}, 59 AuthInfo: authInfo, 60 Context: params.Context, 61 Client: params.HTTPClient, 62 } 63 for _, opt := range opts { 64 opt(op) 65 } 66 67 result, err := a.transport.Submit(op) 68 if err != nil { 69 return nil, err 70 } 71 success, ok := result.(*AddOneCreated) 72 if ok { 73 return success, nil 74 } 75 // unexpected success response 76 unexpectedSuccess := result.(*AddOneDefault) 77 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 78 } 79 80 /* 81 DestroyOne destroy one API 82 */ 83 func (a *Client) DestroyOne(params *DestroyOneParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DestroyOneNoContent, error) { 84 // TODO: Validate the params before sending 85 if params == nil { 86 params = NewDestroyOneParams() 87 } 88 op := &runtime.ClientOperation{ 89 ID: "destroyOne", 90 Method: "DELETE", 91 PathPattern: "/{id}", 92 ProducesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 93 ConsumesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 94 Schemes: []string{"http"}, 95 Params: params, 96 Reader: &DestroyOneReader{formats: a.formats}, 97 AuthInfo: authInfo, 98 Context: params.Context, 99 Client: params.HTTPClient, 100 } 101 for _, opt := range opts { 102 opt(op) 103 } 104 105 result, err := a.transport.Submit(op) 106 if err != nil { 107 return nil, err 108 } 109 success, ok := result.(*DestroyOneNoContent) 110 if ok { 111 return success, nil 112 } 113 // unexpected success response 114 unexpectedSuccess := result.(*DestroyOneDefault) 115 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 116 } 117 118 /* 119 FindTodos find todos API 120 */ 121 func (a *Client) FindTodos(params *FindTodosParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*FindTodosOK, error) { 122 // TODO: Validate the params before sending 123 if params == nil { 124 params = NewFindTodosParams() 125 } 126 op := &runtime.ClientOperation{ 127 ID: "findTodos", 128 Method: "GET", 129 PathPattern: "/", 130 ProducesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 131 ConsumesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 132 Schemes: []string{"http"}, 133 Params: params, 134 Reader: &FindTodosReader{formats: a.formats}, 135 AuthInfo: authInfo, 136 Context: params.Context, 137 Client: params.HTTPClient, 138 } 139 for _, opt := range opts { 140 opt(op) 141 } 142 143 result, err := a.transport.Submit(op) 144 if err != nil { 145 return nil, err 146 } 147 success, ok := result.(*FindTodosOK) 148 if ok { 149 return success, nil 150 } 151 // unexpected success response 152 unexpectedSuccess := result.(*FindTodosDefault) 153 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 154 } 155 156 /* 157 UpdateOne update one API 158 */ 159 func (a *Client) UpdateOne(params *UpdateOneParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateOneOK, error) { 160 // TODO: Validate the params before sending 161 if params == nil { 162 params = NewUpdateOneParams() 163 } 164 op := &runtime.ClientOperation{ 165 ID: "updateOne", 166 Method: "PUT", 167 PathPattern: "/{id}", 168 ProducesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 169 ConsumesMediaTypes: []string{"application/io.goswagger.examples.todo-list.v1+json"}, 170 Schemes: []string{"http"}, 171 Params: params, 172 Reader: &UpdateOneReader{formats: a.formats}, 173 AuthInfo: authInfo, 174 Context: params.Context, 175 Client: params.HTTPClient, 176 } 177 for _, opt := range opts { 178 opt(op) 179 } 180 181 result, err := a.transport.Submit(op) 182 if err != nil { 183 return nil, err 184 } 185 success, ok := result.(*UpdateOneOK) 186 if ok { 187 return success, nil 188 } 189 // unexpected success response 190 unexpectedSuccess := result.(*UpdateOneDefault) 191 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 192 } 193 194 // SetTransport changes the transport on the client 195 func (a *Client) SetTransport(transport runtime.ClientTransport) { 196 a.transport = transport 197 }