examples_test.go 9.7 KB

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