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