examples_test.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cognitosync_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/cognitosync"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleCognitoSync_BulkPublish() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := cognitosync.New(sess)
  20. params := &cognitosync.BulkPublishInput{
  21. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  22. }
  23. resp, err := svc.BulkPublish(params)
  24. if err != nil {
  25. // Print the error, cast err to awserr.Error to get the Code and
  26. // Message from an error.
  27. fmt.Println(err.Error())
  28. return
  29. }
  30. // Pretty-print the response data.
  31. fmt.Println(resp)
  32. }
  33. func ExampleCognitoSync_DeleteDataset() {
  34. sess, err := session.NewSession()
  35. if err != nil {
  36. fmt.Println("failed to create session,", err)
  37. return
  38. }
  39. svc := cognitosync.New(sess)
  40. params := &cognitosync.DeleteDatasetInput{
  41. DatasetName: aws.String("DatasetName"), // Required
  42. IdentityId: aws.String("IdentityId"), // Required
  43. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  44. }
  45. resp, err := svc.DeleteDataset(params)
  46. if err != nil {
  47. // Print the error, cast err to awserr.Error to get the Code and
  48. // Message from an error.
  49. fmt.Println(err.Error())
  50. return
  51. }
  52. // Pretty-print the response data.
  53. fmt.Println(resp)
  54. }
  55. func ExampleCognitoSync_DescribeDataset() {
  56. sess, err := session.NewSession()
  57. if err != nil {
  58. fmt.Println("failed to create session,", err)
  59. return
  60. }
  61. svc := cognitosync.New(sess)
  62. params := &cognitosync.DescribeDatasetInput{
  63. DatasetName: aws.String("DatasetName"), // Required
  64. IdentityId: aws.String("IdentityId"), // Required
  65. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  66. }
  67. resp, err := svc.DescribeDataset(params)
  68. if err != nil {
  69. // Print the error, cast err to awserr.Error to get the Code and
  70. // Message from an error.
  71. fmt.Println(err.Error())
  72. return
  73. }
  74. // Pretty-print the response data.
  75. fmt.Println(resp)
  76. }
  77. func ExampleCognitoSync_DescribeIdentityPoolUsage() {
  78. sess, err := session.NewSession()
  79. if err != nil {
  80. fmt.Println("failed to create session,", err)
  81. return
  82. }
  83. svc := cognitosync.New(sess)
  84. params := &cognitosync.DescribeIdentityPoolUsageInput{
  85. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  86. }
  87. resp, err := svc.DescribeIdentityPoolUsage(params)
  88. if err != nil {
  89. // Print the error, cast err to awserr.Error to get the Code and
  90. // Message from an error.
  91. fmt.Println(err.Error())
  92. return
  93. }
  94. // Pretty-print the response data.
  95. fmt.Println(resp)
  96. }
  97. func ExampleCognitoSync_DescribeIdentityUsage() {
  98. sess, err := session.NewSession()
  99. if err != nil {
  100. fmt.Println("failed to create session,", err)
  101. return
  102. }
  103. svc := cognitosync.New(sess)
  104. params := &cognitosync.DescribeIdentityUsageInput{
  105. IdentityId: aws.String("IdentityId"), // Required
  106. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  107. }
  108. resp, err := svc.DescribeIdentityUsage(params)
  109. if err != nil {
  110. // Print the error, cast err to awserr.Error to get the Code and
  111. // Message from an error.
  112. fmt.Println(err.Error())
  113. return
  114. }
  115. // Pretty-print the response data.
  116. fmt.Println(resp)
  117. }
  118. func ExampleCognitoSync_GetBulkPublishDetails() {
  119. sess, err := session.NewSession()
  120. if err != nil {
  121. fmt.Println("failed to create session,", err)
  122. return
  123. }
  124. svc := cognitosync.New(sess)
  125. params := &cognitosync.GetBulkPublishDetailsInput{
  126. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  127. }
  128. resp, err := svc.GetBulkPublishDetails(params)
  129. if err != nil {
  130. // Print the error, cast err to awserr.Error to get the Code and
  131. // Message from an error.
  132. fmt.Println(err.Error())
  133. return
  134. }
  135. // Pretty-print the response data.
  136. fmt.Println(resp)
  137. }
  138. func ExampleCognitoSync_GetCognitoEvents() {
  139. sess, err := session.NewSession()
  140. if err != nil {
  141. fmt.Println("failed to create session,", err)
  142. return
  143. }
  144. svc := cognitosync.New(sess)
  145. params := &cognitosync.GetCognitoEventsInput{
  146. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  147. }
  148. resp, err := svc.GetCognitoEvents(params)
  149. if err != nil {
  150. // Print the error, cast err to awserr.Error to get the Code and
  151. // Message from an error.
  152. fmt.Println(err.Error())
  153. return
  154. }
  155. // Pretty-print the response data.
  156. fmt.Println(resp)
  157. }
  158. func ExampleCognitoSync_GetIdentityPoolConfiguration() {
  159. sess, err := session.NewSession()
  160. if err != nil {
  161. fmt.Println("failed to create session,", err)
  162. return
  163. }
  164. svc := cognitosync.New(sess)
  165. params := &cognitosync.GetIdentityPoolConfigurationInput{
  166. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  167. }
  168. resp, err := svc.GetIdentityPoolConfiguration(params)
  169. if err != nil {
  170. // Print the error, cast err to awserr.Error to get the Code and
  171. // Message from an error.
  172. fmt.Println(err.Error())
  173. return
  174. }
  175. // Pretty-print the response data.
  176. fmt.Println(resp)
  177. }
  178. func ExampleCognitoSync_ListDatasets() {
  179. sess, err := session.NewSession()
  180. if err != nil {
  181. fmt.Println("failed to create session,", err)
  182. return
  183. }
  184. svc := cognitosync.New(sess)
  185. params := &cognitosync.ListDatasetsInput{
  186. IdentityId: aws.String("IdentityId"), // Required
  187. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  188. MaxResults: aws.Int64(1),
  189. NextToken: aws.String("String"),
  190. }
  191. resp, err := svc.ListDatasets(params)
  192. if err != nil {
  193. // Print the error, cast err to awserr.Error to get the Code and
  194. // Message from an error.
  195. fmt.Println(err.Error())
  196. return
  197. }
  198. // Pretty-print the response data.
  199. fmt.Println(resp)
  200. }
  201. func ExampleCognitoSync_ListIdentityPoolUsage() {
  202. sess, err := session.NewSession()
  203. if err != nil {
  204. fmt.Println("failed to create session,", err)
  205. return
  206. }
  207. svc := cognitosync.New(sess)
  208. params := &cognitosync.ListIdentityPoolUsageInput{
  209. MaxResults: aws.Int64(1),
  210. NextToken: aws.String("String"),
  211. }
  212. resp, err := svc.ListIdentityPoolUsage(params)
  213. if err != nil {
  214. // Print the error, cast err to awserr.Error to get the Code and
  215. // Message from an error.
  216. fmt.Println(err.Error())
  217. return
  218. }
  219. // Pretty-print the response data.
  220. fmt.Println(resp)
  221. }
  222. func ExampleCognitoSync_ListRecords() {
  223. sess, err := session.NewSession()
  224. if err != nil {
  225. fmt.Println("failed to create session,", err)
  226. return
  227. }
  228. svc := cognitosync.New(sess)
  229. params := &cognitosync.ListRecordsInput{
  230. DatasetName: aws.String("DatasetName"), // Required
  231. IdentityId: aws.String("IdentityId"), // Required
  232. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  233. LastSyncCount: aws.Int64(1),
  234. MaxResults: aws.Int64(1),
  235. NextToken: aws.String("String"),
  236. SyncSessionToken: aws.String("SyncSessionToken"),
  237. }
  238. resp, err := svc.ListRecords(params)
  239. if err != nil {
  240. // Print the error, cast err to awserr.Error to get the Code and
  241. // Message from an error.
  242. fmt.Println(err.Error())
  243. return
  244. }
  245. // Pretty-print the response data.
  246. fmt.Println(resp)
  247. }
  248. func ExampleCognitoSync_RegisterDevice() {
  249. sess, err := session.NewSession()
  250. if err != nil {
  251. fmt.Println("failed to create session,", err)
  252. return
  253. }
  254. svc := cognitosync.New(sess)
  255. params := &cognitosync.RegisterDeviceInput{
  256. IdentityId: aws.String("IdentityId"), // Required
  257. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  258. Platform: aws.String("Platform"), // Required
  259. Token: aws.String("PushToken"), // Required
  260. }
  261. resp, err := svc.RegisterDevice(params)
  262. if err != nil {
  263. // Print the error, cast err to awserr.Error to get the Code and
  264. // Message from an error.
  265. fmt.Println(err.Error())
  266. return
  267. }
  268. // Pretty-print the response data.
  269. fmt.Println(resp)
  270. }
  271. func ExampleCognitoSync_SetCognitoEvents() {
  272. sess, err := session.NewSession()
  273. if err != nil {
  274. fmt.Println("failed to create session,", err)
  275. return
  276. }
  277. svc := cognitosync.New(sess)
  278. params := &cognitosync.SetCognitoEventsInput{
  279. Events: map[string]*string{ // Required
  280. "Key": aws.String("LambdaFunctionArn"), // Required
  281. // More values...
  282. },
  283. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  284. }
  285. resp, err := svc.SetCognitoEvents(params)
  286. if err != nil {
  287. // Print the error, cast err to awserr.Error to get the Code and
  288. // Message from an error.
  289. fmt.Println(err.Error())
  290. return
  291. }
  292. // Pretty-print the response data.
  293. fmt.Println(resp)
  294. }
  295. func ExampleCognitoSync_SetIdentityPoolConfiguration() {
  296. sess, err := session.NewSession()
  297. if err != nil {
  298. fmt.Println("failed to create session,", err)
  299. return
  300. }
  301. svc := cognitosync.New(sess)
  302. params := &cognitosync.SetIdentityPoolConfigurationInput{
  303. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  304. CognitoStreams: &cognitosync.CognitoStreams{
  305. RoleArn: aws.String("AssumeRoleArn"),
  306. StreamName: aws.String("StreamName"),
  307. StreamingStatus: aws.String("StreamingStatus"),
  308. },
  309. PushSync: &cognitosync.PushSync{
  310. ApplicationArns: []*string{
  311. aws.String("ApplicationArn"), // Required
  312. // More values...
  313. },
  314. RoleArn: aws.String("AssumeRoleArn"),
  315. },
  316. }
  317. resp, err := svc.SetIdentityPoolConfiguration(params)
  318. if err != nil {
  319. // Print the error, cast err to awserr.Error to get the Code and
  320. // Message from an error.
  321. fmt.Println(err.Error())
  322. return
  323. }
  324. // Pretty-print the response data.
  325. fmt.Println(resp)
  326. }
  327. func ExampleCognitoSync_SubscribeToDataset() {
  328. sess, err := session.NewSession()
  329. if err != nil {
  330. fmt.Println("failed to create session,", err)
  331. return
  332. }
  333. svc := cognitosync.New(sess)
  334. params := &cognitosync.SubscribeToDatasetInput{
  335. DatasetName: aws.String("DatasetName"), // Required
  336. DeviceId: aws.String("DeviceId"), // Required
  337. IdentityId: aws.String("IdentityId"), // Required
  338. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  339. }
  340. resp, err := svc.SubscribeToDataset(params)
  341. if err != nil {
  342. // Print the error, cast err to awserr.Error to get the Code and
  343. // Message from an error.
  344. fmt.Println(err.Error())
  345. return
  346. }
  347. // Pretty-print the response data.
  348. fmt.Println(resp)
  349. }
  350. func ExampleCognitoSync_UnsubscribeFromDataset() {
  351. sess, err := session.NewSession()
  352. if err != nil {
  353. fmt.Println("failed to create session,", err)
  354. return
  355. }
  356. svc := cognitosync.New(sess)
  357. params := &cognitosync.UnsubscribeFromDatasetInput{
  358. DatasetName: aws.String("DatasetName"), // Required
  359. DeviceId: aws.String("DeviceId"), // Required
  360. IdentityId: aws.String("IdentityId"), // Required
  361. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  362. }
  363. resp, err := svc.UnsubscribeFromDataset(params)
  364. if err != nil {
  365. // Print the error, cast err to awserr.Error to get the Code and
  366. // Message from an error.
  367. fmt.Println(err.Error())
  368. return
  369. }
  370. // Pretty-print the response data.
  371. fmt.Println(resp)
  372. }
  373. func ExampleCognitoSync_UpdateRecords() {
  374. sess, err := session.NewSession()
  375. if err != nil {
  376. fmt.Println("failed to create session,", err)
  377. return
  378. }
  379. svc := cognitosync.New(sess)
  380. params := &cognitosync.UpdateRecordsInput{
  381. DatasetName: aws.String("DatasetName"), // Required
  382. IdentityId: aws.String("IdentityId"), // Required
  383. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  384. SyncSessionToken: aws.String("SyncSessionToken"), // Required
  385. ClientContext: aws.String("ClientContext"),
  386. DeviceId: aws.String("DeviceId"),
  387. RecordPatches: []*cognitosync.RecordPatch{
  388. { // Required
  389. Key: aws.String("RecordKey"), // Required
  390. Op: aws.String("Operation"), // Required
  391. SyncCount: aws.Int64(1), // Required
  392. DeviceLastModifiedDate: aws.Time(time.Now()),
  393. Value: aws.String("RecordValue"),
  394. },
  395. // More values...
  396. },
  397. }
  398. resp, err := svc.UpdateRecords(params)
  399. if err != nil {
  400. // Print the error, cast err to awserr.Error to get the Code and
  401. // Message from an error.
  402. fmt.Println(err.Error())
  403. return
  404. }
  405. // Pretty-print the response data.
  406. fmt.Println(resp)
  407. }