examples_test.go 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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/service/cognitosync"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleCognitoSync_BulkPublish() {
  13. svc := cognitosync.New(nil)
  14. params := &cognitosync.BulkPublishInput{
  15. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  16. }
  17. resp, err := svc.BulkPublish(params)
  18. if err != nil {
  19. // Print the error, cast err to awserr.Error to get the Code and
  20. // Message from an error.
  21. fmt.Println(err.Error())
  22. return
  23. }
  24. // Pretty-print the response data.
  25. fmt.Println(resp)
  26. }
  27. func ExampleCognitoSync_DeleteDataset() {
  28. svc := cognitosync.New(nil)
  29. params := &cognitosync.DeleteDatasetInput{
  30. DatasetName: aws.String("DatasetName"), // Required
  31. IdentityId: aws.String("IdentityId"), // Required
  32. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  33. }
  34. resp, err := svc.DeleteDataset(params)
  35. if err != nil {
  36. // Print the error, cast err to awserr.Error to get the Code and
  37. // Message from an error.
  38. fmt.Println(err.Error())
  39. return
  40. }
  41. // Pretty-print the response data.
  42. fmt.Println(resp)
  43. }
  44. func ExampleCognitoSync_DescribeDataset() {
  45. svc := cognitosync.New(nil)
  46. params := &cognitosync.DescribeDatasetInput{
  47. DatasetName: aws.String("DatasetName"), // Required
  48. IdentityId: aws.String("IdentityId"), // Required
  49. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  50. }
  51. resp, err := svc.DescribeDataset(params)
  52. if err != nil {
  53. // Print the error, cast err to awserr.Error to get the Code and
  54. // Message from an error.
  55. fmt.Println(err.Error())
  56. return
  57. }
  58. // Pretty-print the response data.
  59. fmt.Println(resp)
  60. }
  61. func ExampleCognitoSync_DescribeIdentityPoolUsage() {
  62. svc := cognitosync.New(nil)
  63. params := &cognitosync.DescribeIdentityPoolUsageInput{
  64. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  65. }
  66. resp, err := svc.DescribeIdentityPoolUsage(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 ExampleCognitoSync_DescribeIdentityUsage() {
  77. svc := cognitosync.New(nil)
  78. params := &cognitosync.DescribeIdentityUsageInput{
  79. IdentityId: aws.String("IdentityId"), // Required
  80. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  81. }
  82. resp, err := svc.DescribeIdentityUsage(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 ExampleCognitoSync_GetBulkPublishDetails() {
  93. svc := cognitosync.New(nil)
  94. params := &cognitosync.GetBulkPublishDetailsInput{
  95. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  96. }
  97. resp, err := svc.GetBulkPublishDetails(params)
  98. if err != nil {
  99. // Print the error, cast err to awserr.Error to get the Code and
  100. // Message from an error.
  101. fmt.Println(err.Error())
  102. return
  103. }
  104. // Pretty-print the response data.
  105. fmt.Println(resp)
  106. }
  107. func ExampleCognitoSync_GetCognitoEvents() {
  108. svc := cognitosync.New(nil)
  109. params := &cognitosync.GetCognitoEventsInput{
  110. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  111. }
  112. resp, err := svc.GetCognitoEvents(params)
  113. if err != nil {
  114. // Print the error, cast err to awserr.Error to get the Code and
  115. // Message from an error.
  116. fmt.Println(err.Error())
  117. return
  118. }
  119. // Pretty-print the response data.
  120. fmt.Println(resp)
  121. }
  122. func ExampleCognitoSync_GetIdentityPoolConfiguration() {
  123. svc := cognitosync.New(nil)
  124. params := &cognitosync.GetIdentityPoolConfigurationInput{
  125. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  126. }
  127. resp, err := svc.GetIdentityPoolConfiguration(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 ExampleCognitoSync_ListDatasets() {
  138. svc := cognitosync.New(nil)
  139. params := &cognitosync.ListDatasetsInput{
  140. IdentityId: aws.String("IdentityId"), // Required
  141. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  142. MaxResults: aws.Int64(1),
  143. NextToken: aws.String("String"),
  144. }
  145. resp, err := svc.ListDatasets(params)
  146. if err != nil {
  147. // Print the error, cast err to awserr.Error to get the Code and
  148. // Message from an error.
  149. fmt.Println(err.Error())
  150. return
  151. }
  152. // Pretty-print the response data.
  153. fmt.Println(resp)
  154. }
  155. func ExampleCognitoSync_ListIdentityPoolUsage() {
  156. svc := cognitosync.New(nil)
  157. params := &cognitosync.ListIdentityPoolUsageInput{
  158. MaxResults: aws.Int64(1),
  159. NextToken: aws.String("String"),
  160. }
  161. resp, err := svc.ListIdentityPoolUsage(params)
  162. if err != nil {
  163. // Print the error, cast err to awserr.Error to get the Code and
  164. // Message from an error.
  165. fmt.Println(err.Error())
  166. return
  167. }
  168. // Pretty-print the response data.
  169. fmt.Println(resp)
  170. }
  171. func ExampleCognitoSync_ListRecords() {
  172. svc := cognitosync.New(nil)
  173. params := &cognitosync.ListRecordsInput{
  174. DatasetName: aws.String("DatasetName"), // Required
  175. IdentityId: aws.String("IdentityId"), // Required
  176. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  177. LastSyncCount: aws.Int64(1),
  178. MaxResults: aws.Int64(1),
  179. NextToken: aws.String("String"),
  180. SyncSessionToken: aws.String("SyncSessionToken"),
  181. }
  182. resp, err := svc.ListRecords(params)
  183. if err != nil {
  184. // Print the error, cast err to awserr.Error to get the Code and
  185. // Message from an error.
  186. fmt.Println(err.Error())
  187. return
  188. }
  189. // Pretty-print the response data.
  190. fmt.Println(resp)
  191. }
  192. func ExampleCognitoSync_RegisterDevice() {
  193. svc := cognitosync.New(nil)
  194. params := &cognitosync.RegisterDeviceInput{
  195. IdentityId: aws.String("IdentityId"), // Required
  196. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  197. Platform: aws.String("Platform"), // Required
  198. Token: aws.String("PushToken"), // Required
  199. }
  200. resp, err := svc.RegisterDevice(params)
  201. if err != nil {
  202. // Print the error, cast err to awserr.Error to get the Code and
  203. // Message from an error.
  204. fmt.Println(err.Error())
  205. return
  206. }
  207. // Pretty-print the response data.
  208. fmt.Println(resp)
  209. }
  210. func ExampleCognitoSync_SetCognitoEvents() {
  211. svc := cognitosync.New(nil)
  212. params := &cognitosync.SetCognitoEventsInput{
  213. Events: map[string]*string{ // Required
  214. "Key": aws.String("LambdaFunctionArn"), // Required
  215. // More values...
  216. },
  217. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  218. }
  219. resp, err := svc.SetCognitoEvents(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 ExampleCognitoSync_SetIdentityPoolConfiguration() {
  230. svc := cognitosync.New(nil)
  231. params := &cognitosync.SetIdentityPoolConfigurationInput{
  232. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  233. CognitoStreams: &cognitosync.CognitoStreams{
  234. RoleArn: aws.String("AssumeRoleArn"),
  235. StreamName: aws.String("StreamName"),
  236. StreamingStatus: aws.String("StreamingStatus"),
  237. },
  238. PushSync: &cognitosync.PushSync{
  239. ApplicationArns: []*string{
  240. aws.String("ApplicationArn"), // Required
  241. // More values...
  242. },
  243. RoleArn: aws.String("AssumeRoleArn"),
  244. },
  245. }
  246. resp, err := svc.SetIdentityPoolConfiguration(params)
  247. if err != nil {
  248. // Print the error, cast err to awserr.Error to get the Code and
  249. // Message from an error.
  250. fmt.Println(err.Error())
  251. return
  252. }
  253. // Pretty-print the response data.
  254. fmt.Println(resp)
  255. }
  256. func ExampleCognitoSync_SubscribeToDataset() {
  257. svc := cognitosync.New(nil)
  258. params := &cognitosync.SubscribeToDatasetInput{
  259. DatasetName: aws.String("DatasetName"), // Required
  260. DeviceId: aws.String("DeviceId"), // Required
  261. IdentityId: aws.String("IdentityId"), // Required
  262. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  263. }
  264. resp, err := svc.SubscribeToDataset(params)
  265. if err != nil {
  266. // Print the error, cast err to awserr.Error to get the Code and
  267. // Message from an error.
  268. fmt.Println(err.Error())
  269. return
  270. }
  271. // Pretty-print the response data.
  272. fmt.Println(resp)
  273. }
  274. func ExampleCognitoSync_UnsubscribeFromDataset() {
  275. svc := cognitosync.New(nil)
  276. params := &cognitosync.UnsubscribeFromDatasetInput{
  277. DatasetName: aws.String("DatasetName"), // Required
  278. DeviceId: aws.String("DeviceId"), // Required
  279. IdentityId: aws.String("IdentityId"), // Required
  280. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  281. }
  282. resp, err := svc.UnsubscribeFromDataset(params)
  283. if err != nil {
  284. // Print the error, cast err to awserr.Error to get the Code and
  285. // Message from an error.
  286. fmt.Println(err.Error())
  287. return
  288. }
  289. // Pretty-print the response data.
  290. fmt.Println(resp)
  291. }
  292. func ExampleCognitoSync_UpdateRecords() {
  293. svc := cognitosync.New(nil)
  294. params := &cognitosync.UpdateRecordsInput{
  295. DatasetName: aws.String("DatasetName"), // Required
  296. IdentityId: aws.String("IdentityId"), // Required
  297. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  298. SyncSessionToken: aws.String("SyncSessionToken"), // Required
  299. ClientContext: aws.String("ClientContext"),
  300. DeviceId: aws.String("DeviceId"),
  301. RecordPatches: []*cognitosync.RecordPatch{
  302. { // Required
  303. Key: aws.String("RecordKey"), // Required
  304. Op: aws.String("Operation"), // Required
  305. SyncCount: aws.Int64(1), // Required
  306. DeviceLastModifiedDate: aws.Time(time.Now()),
  307. Value: aws.String("RecordValue"),
  308. },
  309. // More values...
  310. },
  311. }
  312. resp, err := svc.UpdateRecords(params)
  313. if err != nil {
  314. // Print the error, cast err to awserr.Error to get the Code and
  315. // Message from an error.
  316. fmt.Println(err.Error())
  317. return
  318. }
  319. // Pretty-print the response data.
  320. fmt.Println(resp)
  321. }