unmarshal_test.go 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. package jsonrpc_test
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "encoding/xml"
  6. "fmt"
  7. "io"
  8. "io/ioutil"
  9. "net/http"
  10. "net/url"
  11. "testing"
  12. "time"
  13. "github.com/aws/aws-sdk-go/aws"
  14. "github.com/aws/aws-sdk-go/aws/client"
  15. "github.com/aws/aws-sdk-go/aws/client/metadata"
  16. "github.com/aws/aws-sdk-go/aws/request"
  17. "github.com/aws/aws-sdk-go/aws/signer/v4"
  18. "github.com/aws/aws-sdk-go/awstesting"
  19. "github.com/aws/aws-sdk-go/awstesting/unit"
  20. "github.com/aws/aws-sdk-go/private/protocol"
  21. "github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
  22. "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil"
  23. "github.com/aws/aws-sdk-go/private/util"
  24. "github.com/stretchr/testify/assert"
  25. )
  26. var _ bytes.Buffer // always import bytes
  27. var _ http.Request
  28. var _ json.Marshaler
  29. var _ time.Time
  30. var _ xmlutil.XMLNode
  31. var _ xml.Attr
  32. var _ = ioutil.Discard
  33. var _ = util.Trim("")
  34. var _ = url.Values{}
  35. var _ = io.EOF
  36. var _ = aws.String
  37. var _ = fmt.Println
  38. func init() {
  39. protocol.RandReader = &awstesting.ZeroReader{}
  40. }
  41. //The service client's operations are safe to be used concurrently.
  42. // It is not safe to mutate any of the client's properties though.
  43. type OutputService1ProtocolTest struct {
  44. *client.Client
  45. }
  46. // New creates a new instance of the OutputService1ProtocolTest client with a session.
  47. // If additional configuration is needed for the client instance use the optional
  48. // aws.Config parameter to add your extra config.
  49. //
  50. // Example:
  51. // // Create a OutputService1ProtocolTest client from just a session.
  52. // svc := outputservice1protocoltest.New(mySession)
  53. //
  54. // // Create a OutputService1ProtocolTest client with additional configuration
  55. // svc := outputservice1protocoltest.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  56. func NewOutputService1ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *OutputService1ProtocolTest {
  57. c := p.ClientConfig("outputservice1protocoltest", cfgs...)
  58. return newOutputService1ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  59. }
  60. // newClient creates, initializes and returns a new service client instance.
  61. func newOutputService1ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *OutputService1ProtocolTest {
  62. svc := &OutputService1ProtocolTest{
  63. Client: client.New(
  64. cfg,
  65. metadata.ClientInfo{
  66. ServiceName: "outputservice1protocoltest",
  67. SigningRegion: signingRegion,
  68. Endpoint: endpoint,
  69. APIVersion: "",
  70. JSONVersion: "",
  71. TargetPrefix: "",
  72. },
  73. handlers,
  74. ),
  75. }
  76. // Handlers
  77. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  78. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  79. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  80. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  81. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  82. return svc
  83. }
  84. // newRequest creates a new request for a OutputService1ProtocolTest operation and runs any
  85. // custom request initialization.
  86. func (c *OutputService1ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  87. req := c.NewRequest(op, params, data)
  88. return req
  89. }
  90. const opOutputService1TestCaseOperation1 = "OperationName"
  91. // OutputService1TestCaseOperation1Request generates a "aws/request.Request" representing the
  92. // client's request for the OutputService1TestCaseOperation1 operation. The "output" return
  93. // value can be used to capture response data after the request's "Send" method
  94. // is called.
  95. //
  96. // Creating a request object using this method should be used when you want to inject
  97. // custom logic into the request's lifecycle using a custom handler, or if you want to
  98. // access properties on the request object before or after sending the request. If
  99. // you just want the service response, call the OutputService1TestCaseOperation1 method directly
  100. // instead.
  101. //
  102. // Note: You must call the "Send" method on the returned request object in order
  103. // to execute the request.
  104. //
  105. // // Example sending a request using the OutputService1TestCaseOperation1Request method.
  106. // req, resp := client.OutputService1TestCaseOperation1Request(params)
  107. //
  108. // err := req.Send()
  109. // if err == nil { // resp is now filled
  110. // fmt.Println(resp)
  111. // }
  112. //
  113. func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1Request(input *OutputService1TestShapeOutputService1TestCaseOperation1Input) (req *request.Request, output *OutputService1TestShapeOutputService1TestCaseOperation1Output) {
  114. op := &request.Operation{
  115. Name: opOutputService1TestCaseOperation1,
  116. HTTPPath: "/",
  117. }
  118. if input == nil {
  119. input = &OutputService1TestShapeOutputService1TestCaseOperation1Input{}
  120. }
  121. req = c.newRequest(op, input, output)
  122. output = &OutputService1TestShapeOutputService1TestCaseOperation1Output{}
  123. req.Data = output
  124. return
  125. }
  126. func (c *OutputService1ProtocolTest) OutputService1TestCaseOperation1(input *OutputService1TestShapeOutputService1TestCaseOperation1Input) (*OutputService1TestShapeOutputService1TestCaseOperation1Output, error) {
  127. req, out := c.OutputService1TestCaseOperation1Request(input)
  128. err := req.Send()
  129. return out, err
  130. }
  131. type OutputService1TestShapeOutputService1TestCaseOperation1Input struct {
  132. _ struct{} `type:"structure"`
  133. }
  134. type OutputService1TestShapeOutputService1TestCaseOperation1Output struct {
  135. _ struct{} `type:"structure"`
  136. Char *string `type:"character"`
  137. Double *float64 `type:"double"`
  138. FalseBool *bool `type:"boolean"`
  139. Float *float64 `type:"float"`
  140. Long *int64 `type:"long"`
  141. Num *int64 `type:"integer"`
  142. Str *string `type:"string"`
  143. TrueBool *bool `type:"boolean"`
  144. }
  145. //The service client's operations are safe to be used concurrently.
  146. // It is not safe to mutate any of the client's properties though.
  147. type OutputService2ProtocolTest struct {
  148. *client.Client
  149. }
  150. // New creates a new instance of the OutputService2ProtocolTest client with a session.
  151. // If additional configuration is needed for the client instance use the optional
  152. // aws.Config parameter to add your extra config.
  153. //
  154. // Example:
  155. // // Create a OutputService2ProtocolTest client from just a session.
  156. // svc := outputservice2protocoltest.New(mySession)
  157. //
  158. // // Create a OutputService2ProtocolTest client with additional configuration
  159. // svc := outputservice2protocoltest.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  160. func NewOutputService2ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *OutputService2ProtocolTest {
  161. c := p.ClientConfig("outputservice2protocoltest", cfgs...)
  162. return newOutputService2ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  163. }
  164. // newClient creates, initializes and returns a new service client instance.
  165. func newOutputService2ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *OutputService2ProtocolTest {
  166. svc := &OutputService2ProtocolTest{
  167. Client: client.New(
  168. cfg,
  169. metadata.ClientInfo{
  170. ServiceName: "outputservice2protocoltest",
  171. SigningRegion: signingRegion,
  172. Endpoint: endpoint,
  173. APIVersion: "",
  174. JSONVersion: "",
  175. TargetPrefix: "",
  176. },
  177. handlers,
  178. ),
  179. }
  180. // Handlers
  181. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  182. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  183. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  184. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  185. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  186. return svc
  187. }
  188. // newRequest creates a new request for a OutputService2ProtocolTest operation and runs any
  189. // custom request initialization.
  190. func (c *OutputService2ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  191. req := c.NewRequest(op, params, data)
  192. return req
  193. }
  194. const opOutputService2TestCaseOperation1 = "OperationName"
  195. // OutputService2TestCaseOperation1Request generates a "aws/request.Request" representing the
  196. // client's request for the OutputService2TestCaseOperation1 operation. The "output" return
  197. // value can be used to capture response data after the request's "Send" method
  198. // is called.
  199. //
  200. // Creating a request object using this method should be used when you want to inject
  201. // custom logic into the request's lifecycle using a custom handler, or if you want to
  202. // access properties on the request object before or after sending the request. If
  203. // you just want the service response, call the OutputService2TestCaseOperation1 method directly
  204. // instead.
  205. //
  206. // Note: You must call the "Send" method on the returned request object in order
  207. // to execute the request.
  208. //
  209. // // Example sending a request using the OutputService2TestCaseOperation1Request method.
  210. // req, resp := client.OutputService2TestCaseOperation1Request(params)
  211. //
  212. // err := req.Send()
  213. // if err == nil { // resp is now filled
  214. // fmt.Println(resp)
  215. // }
  216. //
  217. func (c *OutputService2ProtocolTest) OutputService2TestCaseOperation1Request(input *OutputService2TestShapeOutputService2TestCaseOperation1Input) (req *request.Request, output *OutputService2TestShapeOutputService2TestCaseOperation1Output) {
  218. op := &request.Operation{
  219. Name: opOutputService2TestCaseOperation1,
  220. HTTPPath: "/",
  221. }
  222. if input == nil {
  223. input = &OutputService2TestShapeOutputService2TestCaseOperation1Input{}
  224. }
  225. req = c.newRequest(op, input, output)
  226. output = &OutputService2TestShapeOutputService2TestCaseOperation1Output{}
  227. req.Data = output
  228. return
  229. }
  230. func (c *OutputService2ProtocolTest) OutputService2TestCaseOperation1(input *OutputService2TestShapeOutputService2TestCaseOperation1Input) (*OutputService2TestShapeOutputService2TestCaseOperation1Output, error) {
  231. req, out := c.OutputService2TestCaseOperation1Request(input)
  232. err := req.Send()
  233. return out, err
  234. }
  235. type OutputService2TestShapeBlobContainer struct {
  236. _ struct{} `type:"structure"`
  237. // Foo is automatically base64 encoded/decoded by the SDK.
  238. Foo []byte `locationName:"foo" type:"blob"`
  239. }
  240. type OutputService2TestShapeOutputService2TestCaseOperation1Input struct {
  241. _ struct{} `type:"structure"`
  242. }
  243. type OutputService2TestShapeOutputService2TestCaseOperation1Output struct {
  244. _ struct{} `type:"structure"`
  245. // BlobMember is automatically base64 encoded/decoded by the SDK.
  246. BlobMember []byte `type:"blob"`
  247. StructMember *OutputService2TestShapeBlobContainer `type:"structure"`
  248. }
  249. //The service client's operations are safe to be used concurrently.
  250. // It is not safe to mutate any of the client's properties though.
  251. type OutputService3ProtocolTest struct {
  252. *client.Client
  253. }
  254. // New creates a new instance of the OutputService3ProtocolTest client with a session.
  255. // If additional configuration is needed for the client instance use the optional
  256. // aws.Config parameter to add your extra config.
  257. //
  258. // Example:
  259. // // Create a OutputService3ProtocolTest client from just a session.
  260. // svc := outputservice3protocoltest.New(mySession)
  261. //
  262. // // Create a OutputService3ProtocolTest client with additional configuration
  263. // svc := outputservice3protocoltest.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  264. func NewOutputService3ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *OutputService3ProtocolTest {
  265. c := p.ClientConfig("outputservice3protocoltest", cfgs...)
  266. return newOutputService3ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  267. }
  268. // newClient creates, initializes and returns a new service client instance.
  269. func newOutputService3ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *OutputService3ProtocolTest {
  270. svc := &OutputService3ProtocolTest{
  271. Client: client.New(
  272. cfg,
  273. metadata.ClientInfo{
  274. ServiceName: "outputservice3protocoltest",
  275. SigningRegion: signingRegion,
  276. Endpoint: endpoint,
  277. APIVersion: "",
  278. JSONVersion: "",
  279. TargetPrefix: "",
  280. },
  281. handlers,
  282. ),
  283. }
  284. // Handlers
  285. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  286. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  287. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  288. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  289. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  290. return svc
  291. }
  292. // newRequest creates a new request for a OutputService3ProtocolTest operation and runs any
  293. // custom request initialization.
  294. func (c *OutputService3ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  295. req := c.NewRequest(op, params, data)
  296. return req
  297. }
  298. const opOutputService3TestCaseOperation1 = "OperationName"
  299. // OutputService3TestCaseOperation1Request generates a "aws/request.Request" representing the
  300. // client's request for the OutputService3TestCaseOperation1 operation. The "output" return
  301. // value can be used to capture response data after the request's "Send" method
  302. // is called.
  303. //
  304. // Creating a request object using this method should be used when you want to inject
  305. // custom logic into the request's lifecycle using a custom handler, or if you want to
  306. // access properties on the request object before or after sending the request. If
  307. // you just want the service response, call the OutputService3TestCaseOperation1 method directly
  308. // instead.
  309. //
  310. // Note: You must call the "Send" method on the returned request object in order
  311. // to execute the request.
  312. //
  313. // // Example sending a request using the OutputService3TestCaseOperation1Request method.
  314. // req, resp := client.OutputService3TestCaseOperation1Request(params)
  315. //
  316. // err := req.Send()
  317. // if err == nil { // resp is now filled
  318. // fmt.Println(resp)
  319. // }
  320. //
  321. func (c *OutputService3ProtocolTest) OutputService3TestCaseOperation1Request(input *OutputService3TestShapeOutputService3TestCaseOperation1Input) (req *request.Request, output *OutputService3TestShapeOutputService3TestCaseOperation1Output) {
  322. op := &request.Operation{
  323. Name: opOutputService3TestCaseOperation1,
  324. HTTPPath: "/",
  325. }
  326. if input == nil {
  327. input = &OutputService3TestShapeOutputService3TestCaseOperation1Input{}
  328. }
  329. req = c.newRequest(op, input, output)
  330. output = &OutputService3TestShapeOutputService3TestCaseOperation1Output{}
  331. req.Data = output
  332. return
  333. }
  334. func (c *OutputService3ProtocolTest) OutputService3TestCaseOperation1(input *OutputService3TestShapeOutputService3TestCaseOperation1Input) (*OutputService3TestShapeOutputService3TestCaseOperation1Output, error) {
  335. req, out := c.OutputService3TestCaseOperation1Request(input)
  336. err := req.Send()
  337. return out, err
  338. }
  339. type OutputService3TestShapeOutputService3TestCaseOperation1Input struct {
  340. _ struct{} `type:"structure"`
  341. }
  342. type OutputService3TestShapeOutputService3TestCaseOperation1Output struct {
  343. _ struct{} `type:"structure"`
  344. StructMember *OutputService3TestShapeTimeContainer `type:"structure"`
  345. TimeMember *time.Time `type:"timestamp" timestampFormat:"unix"`
  346. }
  347. type OutputService3TestShapeTimeContainer struct {
  348. _ struct{} `type:"structure"`
  349. Foo *time.Time `locationName:"foo" type:"timestamp" timestampFormat:"unix"`
  350. }
  351. //The service client's operations are safe to be used concurrently.
  352. // It is not safe to mutate any of the client's properties though.
  353. type OutputService4ProtocolTest struct {
  354. *client.Client
  355. }
  356. // New creates a new instance of the OutputService4ProtocolTest client with a session.
  357. // If additional configuration is needed for the client instance use the optional
  358. // aws.Config parameter to add your extra config.
  359. //
  360. // Example:
  361. // // Create a OutputService4ProtocolTest client from just a session.
  362. // svc := outputservice4protocoltest.New(mySession)
  363. //
  364. // // Create a OutputService4ProtocolTest client with additional configuration
  365. // svc := outputservice4protocoltest.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  366. func NewOutputService4ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *OutputService4ProtocolTest {
  367. c := p.ClientConfig("outputservice4protocoltest", cfgs...)
  368. return newOutputService4ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  369. }
  370. // newClient creates, initializes and returns a new service client instance.
  371. func newOutputService4ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *OutputService4ProtocolTest {
  372. svc := &OutputService4ProtocolTest{
  373. Client: client.New(
  374. cfg,
  375. metadata.ClientInfo{
  376. ServiceName: "outputservice4protocoltest",
  377. SigningRegion: signingRegion,
  378. Endpoint: endpoint,
  379. APIVersion: "",
  380. JSONVersion: "",
  381. TargetPrefix: "",
  382. },
  383. handlers,
  384. ),
  385. }
  386. // Handlers
  387. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  388. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  389. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  390. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  391. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  392. return svc
  393. }
  394. // newRequest creates a new request for a OutputService4ProtocolTest operation and runs any
  395. // custom request initialization.
  396. func (c *OutputService4ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  397. req := c.NewRequest(op, params, data)
  398. return req
  399. }
  400. const opOutputService4TestCaseOperation1 = "OperationName"
  401. // OutputService4TestCaseOperation1Request generates a "aws/request.Request" representing the
  402. // client's request for the OutputService4TestCaseOperation1 operation. The "output" return
  403. // value can be used to capture response data after the request's "Send" method
  404. // is called.
  405. //
  406. // Creating a request object using this method should be used when you want to inject
  407. // custom logic into the request's lifecycle using a custom handler, or if you want to
  408. // access properties on the request object before or after sending the request. If
  409. // you just want the service response, call the OutputService4TestCaseOperation1 method directly
  410. // instead.
  411. //
  412. // Note: You must call the "Send" method on the returned request object in order
  413. // to execute the request.
  414. //
  415. // // Example sending a request using the OutputService4TestCaseOperation1Request method.
  416. // req, resp := client.OutputService4TestCaseOperation1Request(params)
  417. //
  418. // err := req.Send()
  419. // if err == nil { // resp is now filled
  420. // fmt.Println(resp)
  421. // }
  422. //
  423. func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation1Request(input *OutputService4TestShapeOutputService4TestCaseOperation1Input) (req *request.Request, output *OutputService4TestShapeOutputShape) {
  424. op := &request.Operation{
  425. Name: opOutputService4TestCaseOperation1,
  426. HTTPPath: "/",
  427. }
  428. if input == nil {
  429. input = &OutputService4TestShapeOutputService4TestCaseOperation1Input{}
  430. }
  431. req = c.newRequest(op, input, output)
  432. output = &OutputService4TestShapeOutputShape{}
  433. req.Data = output
  434. return
  435. }
  436. func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation1(input *OutputService4TestShapeOutputService4TestCaseOperation1Input) (*OutputService4TestShapeOutputShape, error) {
  437. req, out := c.OutputService4TestCaseOperation1Request(input)
  438. err := req.Send()
  439. return out, err
  440. }
  441. const opOutputService4TestCaseOperation2 = "OperationName"
  442. // OutputService4TestCaseOperation2Request generates a "aws/request.Request" representing the
  443. // client's request for the OutputService4TestCaseOperation2 operation. The "output" return
  444. // value can be used to capture response data after the request's "Send" method
  445. // is called.
  446. //
  447. // Creating a request object using this method should be used when you want to inject
  448. // custom logic into the request's lifecycle using a custom handler, or if you want to
  449. // access properties on the request object before or after sending the request. If
  450. // you just want the service response, call the OutputService4TestCaseOperation2 method directly
  451. // instead.
  452. //
  453. // Note: You must call the "Send" method on the returned request object in order
  454. // to execute the request.
  455. //
  456. // // Example sending a request using the OutputService4TestCaseOperation2Request method.
  457. // req, resp := client.OutputService4TestCaseOperation2Request(params)
  458. //
  459. // err := req.Send()
  460. // if err == nil { // resp is now filled
  461. // fmt.Println(resp)
  462. // }
  463. //
  464. func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation2Request(input *OutputService4TestShapeOutputService4TestCaseOperation2Input) (req *request.Request, output *OutputService4TestShapeOutputShape) {
  465. op := &request.Operation{
  466. Name: opOutputService4TestCaseOperation2,
  467. HTTPPath: "/",
  468. }
  469. if input == nil {
  470. input = &OutputService4TestShapeOutputService4TestCaseOperation2Input{}
  471. }
  472. req = c.newRequest(op, input, output)
  473. output = &OutputService4TestShapeOutputShape{}
  474. req.Data = output
  475. return
  476. }
  477. func (c *OutputService4ProtocolTest) OutputService4TestCaseOperation2(input *OutputService4TestShapeOutputService4TestCaseOperation2Input) (*OutputService4TestShapeOutputShape, error) {
  478. req, out := c.OutputService4TestCaseOperation2Request(input)
  479. err := req.Send()
  480. return out, err
  481. }
  482. type OutputService4TestShapeOutputService4TestCaseOperation1Input struct {
  483. _ struct{} `type:"structure"`
  484. }
  485. type OutputService4TestShapeOutputService4TestCaseOperation2Input struct {
  486. _ struct{} `type:"structure"`
  487. }
  488. type OutputService4TestShapeOutputShape struct {
  489. _ struct{} `type:"structure"`
  490. ListMember []*string `type:"list"`
  491. ListMemberMap []map[string]*string `type:"list"`
  492. ListMemberStruct []*OutputService4TestShapeStructType `type:"list"`
  493. }
  494. type OutputService4TestShapeStructType struct {
  495. _ struct{} `type:"structure"`
  496. }
  497. //The service client's operations are safe to be used concurrently.
  498. // It is not safe to mutate any of the client's properties though.
  499. type OutputService5ProtocolTest struct {
  500. *client.Client
  501. }
  502. // New creates a new instance of the OutputService5ProtocolTest client with a session.
  503. // If additional configuration is needed for the client instance use the optional
  504. // aws.Config parameter to add your extra config.
  505. //
  506. // Example:
  507. // // Create a OutputService5ProtocolTest client from just a session.
  508. // svc := outputservice5protocoltest.New(mySession)
  509. //
  510. // // Create a OutputService5ProtocolTest client with additional configuration
  511. // svc := outputservice5protocoltest.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  512. func NewOutputService5ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *OutputService5ProtocolTest {
  513. c := p.ClientConfig("outputservice5protocoltest", cfgs...)
  514. return newOutputService5ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  515. }
  516. // newClient creates, initializes and returns a new service client instance.
  517. func newOutputService5ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *OutputService5ProtocolTest {
  518. svc := &OutputService5ProtocolTest{
  519. Client: client.New(
  520. cfg,
  521. metadata.ClientInfo{
  522. ServiceName: "outputservice5protocoltest",
  523. SigningRegion: signingRegion,
  524. Endpoint: endpoint,
  525. APIVersion: "",
  526. JSONVersion: "",
  527. TargetPrefix: "",
  528. },
  529. handlers,
  530. ),
  531. }
  532. // Handlers
  533. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  534. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  535. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  536. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  537. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  538. return svc
  539. }
  540. // newRequest creates a new request for a OutputService5ProtocolTest operation and runs any
  541. // custom request initialization.
  542. func (c *OutputService5ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  543. req := c.NewRequest(op, params, data)
  544. return req
  545. }
  546. const opOutputService5TestCaseOperation1 = "OperationName"
  547. // OutputService5TestCaseOperation1Request generates a "aws/request.Request" representing the
  548. // client's request for the OutputService5TestCaseOperation1 operation. The "output" return
  549. // value can be used to capture response data after the request's "Send" method
  550. // is called.
  551. //
  552. // Creating a request object using this method should be used when you want to inject
  553. // custom logic into the request's lifecycle using a custom handler, or if you want to
  554. // access properties on the request object before or after sending the request. If
  555. // you just want the service response, call the OutputService5TestCaseOperation1 method directly
  556. // instead.
  557. //
  558. // Note: You must call the "Send" method on the returned request object in order
  559. // to execute the request.
  560. //
  561. // // Example sending a request using the OutputService5TestCaseOperation1Request method.
  562. // req, resp := client.OutputService5TestCaseOperation1Request(params)
  563. //
  564. // err := req.Send()
  565. // if err == nil { // resp is now filled
  566. // fmt.Println(resp)
  567. // }
  568. //
  569. func (c *OutputService5ProtocolTest) OutputService5TestCaseOperation1Request(input *OutputService5TestShapeOutputService5TestCaseOperation1Input) (req *request.Request, output *OutputService5TestShapeOutputService5TestCaseOperation1Output) {
  570. op := &request.Operation{
  571. Name: opOutputService5TestCaseOperation1,
  572. HTTPPath: "/",
  573. }
  574. if input == nil {
  575. input = &OutputService5TestShapeOutputService5TestCaseOperation1Input{}
  576. }
  577. req = c.newRequest(op, input, output)
  578. output = &OutputService5TestShapeOutputService5TestCaseOperation1Output{}
  579. req.Data = output
  580. return
  581. }
  582. func (c *OutputService5ProtocolTest) OutputService5TestCaseOperation1(input *OutputService5TestShapeOutputService5TestCaseOperation1Input) (*OutputService5TestShapeOutputService5TestCaseOperation1Output, error) {
  583. req, out := c.OutputService5TestCaseOperation1Request(input)
  584. err := req.Send()
  585. return out, err
  586. }
  587. type OutputService5TestShapeOutputService5TestCaseOperation1Input struct {
  588. _ struct{} `type:"structure"`
  589. }
  590. type OutputService5TestShapeOutputService5TestCaseOperation1Output struct {
  591. _ struct{} `type:"structure"`
  592. MapMember map[string][]*int64 `type:"map"`
  593. }
  594. //The service client's operations are safe to be used concurrently.
  595. // It is not safe to mutate any of the client's properties though.
  596. type OutputService6ProtocolTest struct {
  597. *client.Client
  598. }
  599. // New creates a new instance of the OutputService6ProtocolTest client with a session.
  600. // If additional configuration is needed for the client instance use the optional
  601. // aws.Config parameter to add your extra config.
  602. //
  603. // Example:
  604. // // Create a OutputService6ProtocolTest client from just a session.
  605. // svc := outputservice6protocoltest.New(mySession)
  606. //
  607. // // Create a OutputService6ProtocolTest client with additional configuration
  608. // svc := outputservice6protocoltest.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  609. func NewOutputService6ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *OutputService6ProtocolTest {
  610. c := p.ClientConfig("outputservice6protocoltest", cfgs...)
  611. return newOutputService6ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  612. }
  613. // newClient creates, initializes and returns a new service client instance.
  614. func newOutputService6ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *OutputService6ProtocolTest {
  615. svc := &OutputService6ProtocolTest{
  616. Client: client.New(
  617. cfg,
  618. metadata.ClientInfo{
  619. ServiceName: "outputservice6protocoltest",
  620. SigningRegion: signingRegion,
  621. Endpoint: endpoint,
  622. APIVersion: "",
  623. JSONVersion: "",
  624. TargetPrefix: "",
  625. },
  626. handlers,
  627. ),
  628. }
  629. // Handlers
  630. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  631. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  632. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  633. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  634. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  635. return svc
  636. }
  637. // newRequest creates a new request for a OutputService6ProtocolTest operation and runs any
  638. // custom request initialization.
  639. func (c *OutputService6ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  640. req := c.NewRequest(op, params, data)
  641. return req
  642. }
  643. const opOutputService6TestCaseOperation1 = "OperationName"
  644. // OutputService6TestCaseOperation1Request generates a "aws/request.Request" representing the
  645. // client's request for the OutputService6TestCaseOperation1 operation. The "output" return
  646. // value can be used to capture response data after the request's "Send" method
  647. // is called.
  648. //
  649. // Creating a request object using this method should be used when you want to inject
  650. // custom logic into the request's lifecycle using a custom handler, or if you want to
  651. // access properties on the request object before or after sending the request. If
  652. // you just want the service response, call the OutputService6TestCaseOperation1 method directly
  653. // instead.
  654. //
  655. // Note: You must call the "Send" method on the returned request object in order
  656. // to execute the request.
  657. //
  658. // // Example sending a request using the OutputService6TestCaseOperation1Request method.
  659. // req, resp := client.OutputService6TestCaseOperation1Request(params)
  660. //
  661. // err := req.Send()
  662. // if err == nil { // resp is now filled
  663. // fmt.Println(resp)
  664. // }
  665. //
  666. func (c *OutputService6ProtocolTest) OutputService6TestCaseOperation1Request(input *OutputService6TestShapeOutputService6TestCaseOperation1Input) (req *request.Request, output *OutputService6TestShapeOutputService6TestCaseOperation1Output) {
  667. op := &request.Operation{
  668. Name: opOutputService6TestCaseOperation1,
  669. HTTPPath: "/",
  670. }
  671. if input == nil {
  672. input = &OutputService6TestShapeOutputService6TestCaseOperation1Input{}
  673. }
  674. req = c.newRequest(op, input, output)
  675. output = &OutputService6TestShapeOutputService6TestCaseOperation1Output{}
  676. req.Data = output
  677. return
  678. }
  679. func (c *OutputService6ProtocolTest) OutputService6TestCaseOperation1(input *OutputService6TestShapeOutputService6TestCaseOperation1Input) (*OutputService6TestShapeOutputService6TestCaseOperation1Output, error) {
  680. req, out := c.OutputService6TestCaseOperation1Request(input)
  681. err := req.Send()
  682. return out, err
  683. }
  684. type OutputService6TestShapeOutputService6TestCaseOperation1Input struct {
  685. _ struct{} `type:"structure"`
  686. }
  687. type OutputService6TestShapeOutputService6TestCaseOperation1Output struct {
  688. _ struct{} `type:"structure"`
  689. StrType *string `type:"string"`
  690. }
  691. //
  692. // Tests begin here
  693. //
  694. func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
  695. svc := NewOutputService1ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  696. buf := bytes.NewReader([]byte("{\"Str\": \"myname\", \"Num\": 123, \"FalseBool\": false, \"TrueBool\": true, \"Float\": 1.2, \"Double\": 1.3, \"Long\": 200, \"Char\": \"a\"}"))
  697. req, out := svc.OutputService1TestCaseOperation1Request(nil)
  698. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  699. // set headers
  700. // unmarshal response
  701. jsonrpc.UnmarshalMeta(req)
  702. jsonrpc.Unmarshal(req)
  703. assert.NoError(t, req.Error)
  704. // assert response
  705. assert.NotNil(t, out) // ensure out variable is used
  706. assert.Equal(t, "a", *out.Char)
  707. assert.Equal(t, 1.3, *out.Double)
  708. assert.Equal(t, false, *out.FalseBool)
  709. assert.Equal(t, 1.2, *out.Float)
  710. assert.Equal(t, int64(200), *out.Long)
  711. assert.Equal(t, int64(123), *out.Num)
  712. assert.Equal(t, "myname", *out.Str)
  713. assert.Equal(t, true, *out.TrueBool)
  714. }
  715. func TestOutputService2ProtocolTestBlobMembersCase1(t *testing.T) {
  716. svc := NewOutputService2ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  717. buf := bytes.NewReader([]byte("{\"BlobMember\": \"aGkh\", \"StructMember\": {\"foo\": \"dGhlcmUh\"}}"))
  718. req, out := svc.OutputService2TestCaseOperation1Request(nil)
  719. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  720. // set headers
  721. // unmarshal response
  722. jsonrpc.UnmarshalMeta(req)
  723. jsonrpc.Unmarshal(req)
  724. assert.NoError(t, req.Error)
  725. // assert response
  726. assert.NotNil(t, out) // ensure out variable is used
  727. assert.Equal(t, "hi!", string(out.BlobMember))
  728. assert.Equal(t, "there!", string(out.StructMember.Foo))
  729. }
  730. func TestOutputService3ProtocolTestTimestampMembersCase1(t *testing.T) {
  731. svc := NewOutputService3ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  732. buf := bytes.NewReader([]byte("{\"TimeMember\": 1398796238, \"StructMember\": {\"foo\": 1398796238}}"))
  733. req, out := svc.OutputService3TestCaseOperation1Request(nil)
  734. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  735. // set headers
  736. // unmarshal response
  737. jsonrpc.UnmarshalMeta(req)
  738. jsonrpc.Unmarshal(req)
  739. assert.NoError(t, req.Error)
  740. // assert response
  741. assert.NotNil(t, out) // ensure out variable is used
  742. assert.Equal(t, time.Unix(1.398796238e+09, 0).UTC().String(), out.StructMember.Foo.String())
  743. assert.Equal(t, time.Unix(1.398796238e+09, 0).UTC().String(), out.TimeMember.String())
  744. }
  745. func TestOutputService4ProtocolTestListsCase1(t *testing.T) {
  746. svc := NewOutputService4ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  747. buf := bytes.NewReader([]byte("{\"ListMember\": [\"a\", \"b\"]}"))
  748. req, out := svc.OutputService4TestCaseOperation1Request(nil)
  749. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  750. // set headers
  751. // unmarshal response
  752. jsonrpc.UnmarshalMeta(req)
  753. jsonrpc.Unmarshal(req)
  754. assert.NoError(t, req.Error)
  755. // assert response
  756. assert.NotNil(t, out) // ensure out variable is used
  757. assert.Equal(t, "a", *out.ListMember[0])
  758. assert.Equal(t, "b", *out.ListMember[1])
  759. }
  760. func TestOutputService4ProtocolTestListsCase2(t *testing.T) {
  761. svc := NewOutputService4ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  762. buf := bytes.NewReader([]byte("{\"ListMember\": [\"a\", null], \"ListMemberMap\": [{}, null, null, {}], \"ListMemberStruct\": [{}, null, null, {}]}"))
  763. req, out := svc.OutputService4TestCaseOperation2Request(nil)
  764. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  765. // set headers
  766. // unmarshal response
  767. jsonrpc.UnmarshalMeta(req)
  768. jsonrpc.Unmarshal(req)
  769. assert.NoError(t, req.Error)
  770. // assert response
  771. assert.NotNil(t, out) // ensure out variable is used
  772. assert.Equal(t, "a", *out.ListMember[0])
  773. assert.Nil(t, out.ListMember[1])
  774. assert.Nil(t, out.ListMemberMap[1])
  775. assert.Nil(t, out.ListMemberMap[2])
  776. assert.Nil(t, out.ListMemberStruct[1])
  777. assert.Nil(t, out.ListMemberStruct[2])
  778. }
  779. func TestOutputService5ProtocolTestMapsCase1(t *testing.T) {
  780. svc := NewOutputService5ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  781. buf := bytes.NewReader([]byte("{\"MapMember\": {\"a\": [1, 2], \"b\": [3, 4]}}"))
  782. req, out := svc.OutputService5TestCaseOperation1Request(nil)
  783. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  784. // set headers
  785. // unmarshal response
  786. jsonrpc.UnmarshalMeta(req)
  787. jsonrpc.Unmarshal(req)
  788. assert.NoError(t, req.Error)
  789. // assert response
  790. assert.NotNil(t, out) // ensure out variable is used
  791. assert.Equal(t, int64(1), *out.MapMember["a"][0])
  792. assert.Equal(t, int64(2), *out.MapMember["a"][1])
  793. assert.Equal(t, int64(3), *out.MapMember["b"][0])
  794. assert.Equal(t, int64(4), *out.MapMember["b"][1])
  795. }
  796. func TestOutputService6ProtocolTestIgnoresExtraDataCase1(t *testing.T) {
  797. svc := NewOutputService6ProtocolTest(unit.Session, &aws.Config{Endpoint: aws.String("https://test")})
  798. buf := bytes.NewReader([]byte("{\"foo\": \"bar\"}"))
  799. req, out := svc.OutputService6TestCaseOperation1Request(nil)
  800. req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
  801. // set headers
  802. // unmarshal response
  803. jsonrpc.UnmarshalMeta(req)
  804. jsonrpc.Unmarshal(req)
  805. assert.NoError(t, req.Error)
  806. // assert response
  807. assert.NotNil(t, out) // ensure out variable is used
  808. }