examples_test.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package sqs_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/aws/session"
  9. "github.com/aws/aws-sdk-go/service/sqs"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleSQS_AddPermission() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := sqs.New(sess)
  20. params := &sqs.AddPermissionInput{
  21. AWSAccountIds: []*string{ // Required
  22. aws.String("String"), // Required
  23. // More values...
  24. },
  25. Actions: []*string{ // Required
  26. aws.String("String"), // Required
  27. // More values...
  28. },
  29. Label: aws.String("String"), // Required
  30. QueueUrl: aws.String("String"), // Required
  31. }
  32. resp, err := svc.AddPermission(params)
  33. if err != nil {
  34. // Print the error, cast err to awserr.Error to get the Code and
  35. // Message from an error.
  36. fmt.Println(err.Error())
  37. return
  38. }
  39. // Pretty-print the response data.
  40. fmt.Println(resp)
  41. }
  42. func ExampleSQS_ChangeMessageVisibility() {
  43. sess, err := session.NewSession()
  44. if err != nil {
  45. fmt.Println("failed to create session,", err)
  46. return
  47. }
  48. svc := sqs.New(sess)
  49. params := &sqs.ChangeMessageVisibilityInput{
  50. QueueUrl: aws.String("String"), // Required
  51. ReceiptHandle: aws.String("String"), // Required
  52. VisibilityTimeout: aws.Int64(1), // Required
  53. }
  54. resp, err := svc.ChangeMessageVisibility(params)
  55. if err != nil {
  56. // Print the error, cast err to awserr.Error to get the Code and
  57. // Message from an error.
  58. fmt.Println(err.Error())
  59. return
  60. }
  61. // Pretty-print the response data.
  62. fmt.Println(resp)
  63. }
  64. func ExampleSQS_ChangeMessageVisibilityBatch() {
  65. sess, err := session.NewSession()
  66. if err != nil {
  67. fmt.Println("failed to create session,", err)
  68. return
  69. }
  70. svc := sqs.New(sess)
  71. params := &sqs.ChangeMessageVisibilityBatchInput{
  72. Entries: []*sqs.ChangeMessageVisibilityBatchRequestEntry{ // Required
  73. { // Required
  74. Id: aws.String("String"), // Required
  75. ReceiptHandle: aws.String("String"), // Required
  76. VisibilityTimeout: aws.Int64(1),
  77. },
  78. // More values...
  79. },
  80. QueueUrl: aws.String("String"), // Required
  81. }
  82. resp, err := svc.ChangeMessageVisibilityBatch(params)
  83. if err != nil {
  84. // Print the error, cast err to awserr.Error to get the Code and
  85. // Message from an error.
  86. fmt.Println(err.Error())
  87. return
  88. }
  89. // Pretty-print the response data.
  90. fmt.Println(resp)
  91. }
  92. func ExampleSQS_CreateQueue() {
  93. sess, err := session.NewSession()
  94. if err != nil {
  95. fmt.Println("failed to create session,", err)
  96. return
  97. }
  98. svc := sqs.New(sess)
  99. params := &sqs.CreateQueueInput{
  100. QueueName: aws.String("String"), // Required
  101. Attributes: map[string]*string{
  102. "Key": aws.String("String"), // Required
  103. // More values...
  104. },
  105. }
  106. resp, err := svc.CreateQueue(params)
  107. if err != nil {
  108. // Print the error, cast err to awserr.Error to get the Code and
  109. // Message from an error.
  110. fmt.Println(err.Error())
  111. return
  112. }
  113. // Pretty-print the response data.
  114. fmt.Println(resp)
  115. }
  116. func ExampleSQS_DeleteMessage() {
  117. sess, err := session.NewSession()
  118. if err != nil {
  119. fmt.Println("failed to create session,", err)
  120. return
  121. }
  122. svc := sqs.New(sess)
  123. params := &sqs.DeleteMessageInput{
  124. QueueUrl: aws.String("String"), // Required
  125. ReceiptHandle: aws.String("String"), // Required
  126. }
  127. resp, err := svc.DeleteMessage(params)
  128. if err != nil {
  129. // Print the error, cast err to awserr.Error to get the Code and
  130. // Message from an error.
  131. fmt.Println(err.Error())
  132. return
  133. }
  134. // Pretty-print the response data.
  135. fmt.Println(resp)
  136. }
  137. func ExampleSQS_DeleteMessageBatch() {
  138. sess, err := session.NewSession()
  139. if err != nil {
  140. fmt.Println("failed to create session,", err)
  141. return
  142. }
  143. svc := sqs.New(sess)
  144. params := &sqs.DeleteMessageBatchInput{
  145. Entries: []*sqs.DeleteMessageBatchRequestEntry{ // Required
  146. { // Required
  147. Id: aws.String("String"), // Required
  148. ReceiptHandle: aws.String("String"), // Required
  149. },
  150. // More values...
  151. },
  152. QueueUrl: aws.String("String"), // Required
  153. }
  154. resp, err := svc.DeleteMessageBatch(params)
  155. if err != nil {
  156. // Print the error, cast err to awserr.Error to get the Code and
  157. // Message from an error.
  158. fmt.Println(err.Error())
  159. return
  160. }
  161. // Pretty-print the response data.
  162. fmt.Println(resp)
  163. }
  164. func ExampleSQS_DeleteQueue() {
  165. sess, err := session.NewSession()
  166. if err != nil {
  167. fmt.Println("failed to create session,", err)
  168. return
  169. }
  170. svc := sqs.New(sess)
  171. params := &sqs.DeleteQueueInput{
  172. QueueUrl: aws.String("String"), // Required
  173. }
  174. resp, err := svc.DeleteQueue(params)
  175. if err != nil {
  176. // Print the error, cast err to awserr.Error to get the Code and
  177. // Message from an error.
  178. fmt.Println(err.Error())
  179. return
  180. }
  181. // Pretty-print the response data.
  182. fmt.Println(resp)
  183. }
  184. func ExampleSQS_GetQueueAttributes() {
  185. sess, err := session.NewSession()
  186. if err != nil {
  187. fmt.Println("failed to create session,", err)
  188. return
  189. }
  190. svc := sqs.New(sess)
  191. params := &sqs.GetQueueAttributesInput{
  192. QueueUrl: aws.String("String"), // Required
  193. AttributeNames: []*string{
  194. aws.String("QueueAttributeName"), // Required
  195. // More values...
  196. },
  197. }
  198. resp, err := svc.GetQueueAttributes(params)
  199. if err != nil {
  200. // Print the error, cast err to awserr.Error to get the Code and
  201. // Message from an error.
  202. fmt.Println(err.Error())
  203. return
  204. }
  205. // Pretty-print the response data.
  206. fmt.Println(resp)
  207. }
  208. func ExampleSQS_GetQueueUrl() {
  209. sess, err := session.NewSession()
  210. if err != nil {
  211. fmt.Println("failed to create session,", err)
  212. return
  213. }
  214. svc := sqs.New(sess)
  215. params := &sqs.GetQueueUrlInput{
  216. QueueName: aws.String("String"), // Required
  217. QueueOwnerAWSAccountId: aws.String("String"),
  218. }
  219. resp, err := svc.GetQueueUrl(params)
  220. if err != nil {
  221. // Print the error, cast err to awserr.Error to get the Code and
  222. // Message from an error.
  223. fmt.Println(err.Error())
  224. return
  225. }
  226. // Pretty-print the response data.
  227. fmt.Println(resp)
  228. }
  229. func ExampleSQS_ListDeadLetterSourceQueues() {
  230. sess, err := session.NewSession()
  231. if err != nil {
  232. fmt.Println("failed to create session,", err)
  233. return
  234. }
  235. svc := sqs.New(sess)
  236. params := &sqs.ListDeadLetterSourceQueuesInput{
  237. QueueUrl: aws.String("String"), // Required
  238. }
  239. resp, err := svc.ListDeadLetterSourceQueues(params)
  240. if err != nil {
  241. // Print the error, cast err to awserr.Error to get the Code and
  242. // Message from an error.
  243. fmt.Println(err.Error())
  244. return
  245. }
  246. // Pretty-print the response data.
  247. fmt.Println(resp)
  248. }
  249. func ExampleSQS_ListQueues() {
  250. sess, err := session.NewSession()
  251. if err != nil {
  252. fmt.Println("failed to create session,", err)
  253. return
  254. }
  255. svc := sqs.New(sess)
  256. params := &sqs.ListQueuesInput{
  257. QueueNamePrefix: aws.String("String"),
  258. }
  259. resp, err := svc.ListQueues(params)
  260. if err != nil {
  261. // Print the error, cast err to awserr.Error to get the Code and
  262. // Message from an error.
  263. fmt.Println(err.Error())
  264. return
  265. }
  266. // Pretty-print the response data.
  267. fmt.Println(resp)
  268. }
  269. func ExampleSQS_PurgeQueue() {
  270. sess, err := session.NewSession()
  271. if err != nil {
  272. fmt.Println("failed to create session,", err)
  273. return
  274. }
  275. svc := sqs.New(sess)
  276. params := &sqs.PurgeQueueInput{
  277. QueueUrl: aws.String("String"), // Required
  278. }
  279. resp, err := svc.PurgeQueue(params)
  280. if err != nil {
  281. // Print the error, cast err to awserr.Error to get the Code and
  282. // Message from an error.
  283. fmt.Println(err.Error())
  284. return
  285. }
  286. // Pretty-print the response data.
  287. fmt.Println(resp)
  288. }
  289. func ExampleSQS_ReceiveMessage() {
  290. sess, err := session.NewSession()
  291. if err != nil {
  292. fmt.Println("failed to create session,", err)
  293. return
  294. }
  295. svc := sqs.New(sess)
  296. params := &sqs.ReceiveMessageInput{
  297. QueueUrl: aws.String("String"), // Required
  298. AttributeNames: []*string{
  299. aws.String("QueueAttributeName"), // Required
  300. // More values...
  301. },
  302. MaxNumberOfMessages: aws.Int64(1),
  303. MessageAttributeNames: []*string{
  304. aws.String("MessageAttributeName"), // Required
  305. // More values...
  306. },
  307. VisibilityTimeout: aws.Int64(1),
  308. WaitTimeSeconds: aws.Int64(1),
  309. }
  310. resp, err := svc.ReceiveMessage(params)
  311. if err != nil {
  312. // Print the error, cast err to awserr.Error to get the Code and
  313. // Message from an error.
  314. fmt.Println(err.Error())
  315. return
  316. }
  317. // Pretty-print the response data.
  318. fmt.Println(resp)
  319. }
  320. func ExampleSQS_RemovePermission() {
  321. sess, err := session.NewSession()
  322. if err != nil {
  323. fmt.Println("failed to create session,", err)
  324. return
  325. }
  326. svc := sqs.New(sess)
  327. params := &sqs.RemovePermissionInput{
  328. Label: aws.String("String"), // Required
  329. QueueUrl: aws.String("String"), // Required
  330. }
  331. resp, err := svc.RemovePermission(params)
  332. if err != nil {
  333. // Print the error, cast err to awserr.Error to get the Code and
  334. // Message from an error.
  335. fmt.Println(err.Error())
  336. return
  337. }
  338. // Pretty-print the response data.
  339. fmt.Println(resp)
  340. }
  341. func ExampleSQS_SendMessage() {
  342. sess, err := session.NewSession()
  343. if err != nil {
  344. fmt.Println("failed to create session,", err)
  345. return
  346. }
  347. svc := sqs.New(sess)
  348. params := &sqs.SendMessageInput{
  349. MessageBody: aws.String("String"), // Required
  350. QueueUrl: aws.String("String"), // Required
  351. DelaySeconds: aws.Int64(1),
  352. MessageAttributes: map[string]*sqs.MessageAttributeValue{
  353. "Key": { // Required
  354. DataType: aws.String("String"), // Required
  355. BinaryListValues: [][]byte{
  356. []byte("PAYLOAD"), // Required
  357. // More values...
  358. },
  359. BinaryValue: []byte("PAYLOAD"),
  360. StringListValues: []*string{
  361. aws.String("String"), // Required
  362. // More values...
  363. },
  364. StringValue: aws.String("String"),
  365. },
  366. // More values...
  367. },
  368. }
  369. resp, err := svc.SendMessage(params)
  370. if err != nil {
  371. // Print the error, cast err to awserr.Error to get the Code and
  372. // Message from an error.
  373. fmt.Println(err.Error())
  374. return
  375. }
  376. // Pretty-print the response data.
  377. fmt.Println(resp)
  378. }
  379. func ExampleSQS_SendMessageBatch() {
  380. sess, err := session.NewSession()
  381. if err != nil {
  382. fmt.Println("failed to create session,", err)
  383. return
  384. }
  385. svc := sqs.New(sess)
  386. params := &sqs.SendMessageBatchInput{
  387. Entries: []*sqs.SendMessageBatchRequestEntry{ // Required
  388. { // Required
  389. Id: aws.String("String"), // Required
  390. MessageBody: aws.String("String"), // Required
  391. DelaySeconds: aws.Int64(1),
  392. MessageAttributes: map[string]*sqs.MessageAttributeValue{
  393. "Key": { // Required
  394. DataType: aws.String("String"), // Required
  395. BinaryListValues: [][]byte{
  396. []byte("PAYLOAD"), // Required
  397. // More values...
  398. },
  399. BinaryValue: []byte("PAYLOAD"),
  400. StringListValues: []*string{
  401. aws.String("String"), // Required
  402. // More values...
  403. },
  404. StringValue: aws.String("String"),
  405. },
  406. // More values...
  407. },
  408. },
  409. // More values...
  410. },
  411. QueueUrl: aws.String("String"), // Required
  412. }
  413. resp, err := svc.SendMessageBatch(params)
  414. if err != nil {
  415. // Print the error, cast err to awserr.Error to get the Code and
  416. // Message from an error.
  417. fmt.Println(err.Error())
  418. return
  419. }
  420. // Pretty-print the response data.
  421. fmt.Println(resp)
  422. }
  423. func ExampleSQS_SetQueueAttributes() {
  424. sess, err := session.NewSession()
  425. if err != nil {
  426. fmt.Println("failed to create session,", err)
  427. return
  428. }
  429. svc := sqs.New(sess)
  430. params := &sqs.SetQueueAttributesInput{
  431. Attributes: map[string]*string{ // Required
  432. "Key": aws.String("String"), // Required
  433. // More values...
  434. },
  435. QueueUrl: aws.String("String"), // Required
  436. }
  437. resp, err := svc.SetQueueAttributes(params)
  438. if err != nil {
  439. // Print the error, cast err to awserr.Error to get the Code and
  440. // Message from an error.
  441. fmt.Println(err.Error())
  442. return
  443. }
  444. // Pretty-print the response data.
  445. fmt.Println(resp)
  446. }