examples_test.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package sns_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/sns"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleSNS_AddPermission() {
  13. svc := sns.New(nil)
  14. params := &sns.AddPermissionInput{
  15. AWSAccountId: []*string{ // Required
  16. aws.String("delegate"), // Required
  17. // More values...
  18. },
  19. ActionName: []*string{ // Required
  20. aws.String("action"), // Required
  21. // More values...
  22. },
  23. Label: aws.String("label"), // Required
  24. TopicArn: aws.String("topicARN"), // 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 ExampleSNS_ConfirmSubscription() {
  37. svc := sns.New(nil)
  38. params := &sns.ConfirmSubscriptionInput{
  39. Token: aws.String("token"), // Required
  40. TopicArn: aws.String("topicARN"), // Required
  41. AuthenticateOnUnsubscribe: aws.String("authenticateOnUnsubscribe"),
  42. }
  43. resp, err := svc.ConfirmSubscription(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 ExampleSNS_CreatePlatformApplication() {
  54. svc := sns.New(nil)
  55. params := &sns.CreatePlatformApplicationInput{
  56. Attributes: map[string]*string{ // Required
  57. "Key": aws.String("String"), // Required
  58. // More values...
  59. },
  60. Name: aws.String("String"), // Required
  61. Platform: aws.String("String"), // Required
  62. }
  63. resp, err := svc.CreatePlatformApplication(params)
  64. if err != nil {
  65. // Print the error, cast err to awserr.Error to get the Code and
  66. // Message from an error.
  67. fmt.Println(err.Error())
  68. return
  69. }
  70. // Pretty-print the response data.
  71. fmt.Println(resp)
  72. }
  73. func ExampleSNS_CreatePlatformEndpoint() {
  74. svc := sns.New(nil)
  75. params := &sns.CreatePlatformEndpointInput{
  76. PlatformApplicationArn: aws.String("String"), // Required
  77. Token: aws.String("String"), // Required
  78. Attributes: map[string]*string{
  79. "Key": aws.String("String"), // Required
  80. // More values...
  81. },
  82. CustomUserData: aws.String("String"),
  83. }
  84. resp, err := svc.CreatePlatformEndpoint(params)
  85. if err != nil {
  86. // Print the error, cast err to awserr.Error to get the Code and
  87. // Message from an error.
  88. fmt.Println(err.Error())
  89. return
  90. }
  91. // Pretty-print the response data.
  92. fmt.Println(resp)
  93. }
  94. func ExampleSNS_CreateTopic() {
  95. svc := sns.New(nil)
  96. params := &sns.CreateTopicInput{
  97. Name: aws.String("topicName"), // Required
  98. }
  99. resp, err := svc.CreateTopic(params)
  100. if err != nil {
  101. // Print the error, cast err to awserr.Error to get the Code and
  102. // Message from an error.
  103. fmt.Println(err.Error())
  104. return
  105. }
  106. // Pretty-print the response data.
  107. fmt.Println(resp)
  108. }
  109. func ExampleSNS_DeleteEndpoint() {
  110. svc := sns.New(nil)
  111. params := &sns.DeleteEndpointInput{
  112. EndpointArn: aws.String("String"), // Required
  113. }
  114. resp, err := svc.DeleteEndpoint(params)
  115. if err != nil {
  116. // Print the error, cast err to awserr.Error to get the Code and
  117. // Message from an error.
  118. fmt.Println(err.Error())
  119. return
  120. }
  121. // Pretty-print the response data.
  122. fmt.Println(resp)
  123. }
  124. func ExampleSNS_DeletePlatformApplication() {
  125. svc := sns.New(nil)
  126. params := &sns.DeletePlatformApplicationInput{
  127. PlatformApplicationArn: aws.String("String"), // Required
  128. }
  129. resp, err := svc.DeletePlatformApplication(params)
  130. if err != nil {
  131. // Print the error, cast err to awserr.Error to get the Code and
  132. // Message from an error.
  133. fmt.Println(err.Error())
  134. return
  135. }
  136. // Pretty-print the response data.
  137. fmt.Println(resp)
  138. }
  139. func ExampleSNS_DeleteTopic() {
  140. svc := sns.New(nil)
  141. params := &sns.DeleteTopicInput{
  142. TopicArn: aws.String("topicARN"), // Required
  143. }
  144. resp, err := svc.DeleteTopic(params)
  145. if err != nil {
  146. // Print the error, cast err to awserr.Error to get the Code and
  147. // Message from an error.
  148. fmt.Println(err.Error())
  149. return
  150. }
  151. // Pretty-print the response data.
  152. fmt.Println(resp)
  153. }
  154. func ExampleSNS_GetEndpointAttributes() {
  155. svc := sns.New(nil)
  156. params := &sns.GetEndpointAttributesInput{
  157. EndpointArn: aws.String("String"), // Required
  158. }
  159. resp, err := svc.GetEndpointAttributes(params)
  160. if err != nil {
  161. // Print the error, cast err to awserr.Error to get the Code and
  162. // Message from an error.
  163. fmt.Println(err.Error())
  164. return
  165. }
  166. // Pretty-print the response data.
  167. fmt.Println(resp)
  168. }
  169. func ExampleSNS_GetPlatformApplicationAttributes() {
  170. svc := sns.New(nil)
  171. params := &sns.GetPlatformApplicationAttributesInput{
  172. PlatformApplicationArn: aws.String("String"), // Required
  173. }
  174. resp, err := svc.GetPlatformApplicationAttributes(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 ExampleSNS_GetSubscriptionAttributes() {
  185. svc := sns.New(nil)
  186. params := &sns.GetSubscriptionAttributesInput{
  187. SubscriptionArn: aws.String("subscriptionARN"), // Required
  188. }
  189. resp, err := svc.GetSubscriptionAttributes(params)
  190. if err != nil {
  191. // Print the error, cast err to awserr.Error to get the Code and
  192. // Message from an error.
  193. fmt.Println(err.Error())
  194. return
  195. }
  196. // Pretty-print the response data.
  197. fmt.Println(resp)
  198. }
  199. func ExampleSNS_GetTopicAttributes() {
  200. svc := sns.New(nil)
  201. params := &sns.GetTopicAttributesInput{
  202. TopicArn: aws.String("topicARN"), // Required
  203. }
  204. resp, err := svc.GetTopicAttributes(params)
  205. if err != nil {
  206. // Print the error, cast err to awserr.Error to get the Code and
  207. // Message from an error.
  208. fmt.Println(err.Error())
  209. return
  210. }
  211. // Pretty-print the response data.
  212. fmt.Println(resp)
  213. }
  214. func ExampleSNS_ListEndpointsByPlatformApplication() {
  215. svc := sns.New(nil)
  216. params := &sns.ListEndpointsByPlatformApplicationInput{
  217. PlatformApplicationArn: aws.String("String"), // Required
  218. NextToken: aws.String("String"),
  219. }
  220. resp, err := svc.ListEndpointsByPlatformApplication(params)
  221. if err != nil {
  222. // Print the error, cast err to awserr.Error to get the Code and
  223. // Message from an error.
  224. fmt.Println(err.Error())
  225. return
  226. }
  227. // Pretty-print the response data.
  228. fmt.Println(resp)
  229. }
  230. func ExampleSNS_ListPlatformApplications() {
  231. svc := sns.New(nil)
  232. params := &sns.ListPlatformApplicationsInput{
  233. NextToken: aws.String("String"),
  234. }
  235. resp, err := svc.ListPlatformApplications(params)
  236. if err != nil {
  237. // Print the error, cast err to awserr.Error to get the Code and
  238. // Message from an error.
  239. fmt.Println(err.Error())
  240. return
  241. }
  242. // Pretty-print the response data.
  243. fmt.Println(resp)
  244. }
  245. func ExampleSNS_ListSubscriptions() {
  246. svc := sns.New(nil)
  247. params := &sns.ListSubscriptionsInput{
  248. NextToken: aws.String("nextToken"),
  249. }
  250. resp, err := svc.ListSubscriptions(params)
  251. if err != nil {
  252. // Print the error, cast err to awserr.Error to get the Code and
  253. // Message from an error.
  254. fmt.Println(err.Error())
  255. return
  256. }
  257. // Pretty-print the response data.
  258. fmt.Println(resp)
  259. }
  260. func ExampleSNS_ListSubscriptionsByTopic() {
  261. svc := sns.New(nil)
  262. params := &sns.ListSubscriptionsByTopicInput{
  263. TopicArn: aws.String("topicARN"), // Required
  264. NextToken: aws.String("nextToken"),
  265. }
  266. resp, err := svc.ListSubscriptionsByTopic(params)
  267. if err != nil {
  268. // Print the error, cast err to awserr.Error to get the Code and
  269. // Message from an error.
  270. fmt.Println(err.Error())
  271. return
  272. }
  273. // Pretty-print the response data.
  274. fmt.Println(resp)
  275. }
  276. func ExampleSNS_ListTopics() {
  277. svc := sns.New(nil)
  278. params := &sns.ListTopicsInput{
  279. NextToken: aws.String("nextToken"),
  280. }
  281. resp, err := svc.ListTopics(params)
  282. if err != nil {
  283. // Print the error, cast err to awserr.Error to get the Code and
  284. // Message from an error.
  285. fmt.Println(err.Error())
  286. return
  287. }
  288. // Pretty-print the response data.
  289. fmt.Println(resp)
  290. }
  291. func ExampleSNS_Publish() {
  292. svc := sns.New(nil)
  293. params := &sns.PublishInput{
  294. Message: aws.String("message"), // Required
  295. MessageAttributes: map[string]*sns.MessageAttributeValue{
  296. "Key": { // Required
  297. DataType: aws.String("String"), // Required
  298. BinaryValue: []byte("PAYLOAD"),
  299. StringValue: aws.String("String"),
  300. },
  301. // More values...
  302. },
  303. MessageStructure: aws.String("messageStructure"),
  304. Subject: aws.String("subject"),
  305. TargetArn: aws.String("String"),
  306. TopicArn: aws.String("topicARN"),
  307. }
  308. resp, err := svc.Publish(params)
  309. if err != nil {
  310. // Print the error, cast err to awserr.Error to get the Code and
  311. // Message from an error.
  312. fmt.Println(err.Error())
  313. return
  314. }
  315. // Pretty-print the response data.
  316. fmt.Println(resp)
  317. }
  318. func ExampleSNS_RemovePermission() {
  319. svc := sns.New(nil)
  320. params := &sns.RemovePermissionInput{
  321. Label: aws.String("label"), // Required
  322. TopicArn: aws.String("topicARN"), // Required
  323. }
  324. resp, err := svc.RemovePermission(params)
  325. if err != nil {
  326. // Print the error, cast err to awserr.Error to get the Code and
  327. // Message from an error.
  328. fmt.Println(err.Error())
  329. return
  330. }
  331. // Pretty-print the response data.
  332. fmt.Println(resp)
  333. }
  334. func ExampleSNS_SetEndpointAttributes() {
  335. svc := sns.New(nil)
  336. params := &sns.SetEndpointAttributesInput{
  337. Attributes: map[string]*string{ // Required
  338. "Key": aws.String("String"), // Required
  339. // More values...
  340. },
  341. EndpointArn: aws.String("String"), // Required
  342. }
  343. resp, err := svc.SetEndpointAttributes(params)
  344. if err != nil {
  345. // Print the error, cast err to awserr.Error to get the Code and
  346. // Message from an error.
  347. fmt.Println(err.Error())
  348. return
  349. }
  350. // Pretty-print the response data.
  351. fmt.Println(resp)
  352. }
  353. func ExampleSNS_SetPlatformApplicationAttributes() {
  354. svc := sns.New(nil)
  355. params := &sns.SetPlatformApplicationAttributesInput{
  356. Attributes: map[string]*string{ // Required
  357. "Key": aws.String("String"), // Required
  358. // More values...
  359. },
  360. PlatformApplicationArn: aws.String("String"), // Required
  361. }
  362. resp, err := svc.SetPlatformApplicationAttributes(params)
  363. if err != nil {
  364. // Print the error, cast err to awserr.Error to get the Code and
  365. // Message from an error.
  366. fmt.Println(err.Error())
  367. return
  368. }
  369. // Pretty-print the response data.
  370. fmt.Println(resp)
  371. }
  372. func ExampleSNS_SetSubscriptionAttributes() {
  373. svc := sns.New(nil)
  374. params := &sns.SetSubscriptionAttributesInput{
  375. AttributeName: aws.String("attributeName"), // Required
  376. SubscriptionArn: aws.String("subscriptionARN"), // Required
  377. AttributeValue: aws.String("attributeValue"),
  378. }
  379. resp, err := svc.SetSubscriptionAttributes(params)
  380. if err != nil {
  381. // Print the error, cast err to awserr.Error to get the Code and
  382. // Message from an error.
  383. fmt.Println(err.Error())
  384. return
  385. }
  386. // Pretty-print the response data.
  387. fmt.Println(resp)
  388. }
  389. func ExampleSNS_SetTopicAttributes() {
  390. svc := sns.New(nil)
  391. params := &sns.SetTopicAttributesInput{
  392. AttributeName: aws.String("attributeName"), // Required
  393. TopicArn: aws.String("topicARN"), // Required
  394. AttributeValue: aws.String("attributeValue"),
  395. }
  396. resp, err := svc.SetTopicAttributes(params)
  397. if err != nil {
  398. // Print the error, cast err to awserr.Error to get the Code and
  399. // Message from an error.
  400. fmt.Println(err.Error())
  401. return
  402. }
  403. // Pretty-print the response data.
  404. fmt.Println(resp)
  405. }
  406. func ExampleSNS_Subscribe() {
  407. svc := sns.New(nil)
  408. params := &sns.SubscribeInput{
  409. Protocol: aws.String("protocol"), // Required
  410. TopicArn: aws.String("topicARN"), // Required
  411. Endpoint: aws.String("endpoint"),
  412. }
  413. resp, err := svc.Subscribe(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 ExampleSNS_Unsubscribe() {
  424. svc := sns.New(nil)
  425. params := &sns.UnsubscribeInput{
  426. SubscriptionArn: aws.String("subscriptionARN"), // Required
  427. }
  428. resp, err := svc.Unsubscribe(params)
  429. if err != nil {
  430. // Print the error, cast err to awserr.Error to get the Code and
  431. // Message from an error.
  432. fmt.Println(err.Error())
  433. return
  434. }
  435. // Pretty-print the response data.
  436. fmt.Println(resp)
  437. }