examples_test.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cognitoidentity_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/cognitoidentity"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleCognitoIdentity_CreateIdentityPool() {
  13. svc := cognitoidentity.New(nil)
  14. params := &cognitoidentity.CreateIdentityPoolInput{
  15. AllowUnauthenticatedIdentities: aws.Bool(true), // Required
  16. IdentityPoolName: aws.String("IdentityPoolName"), // Required
  17. DeveloperProviderName: aws.String("DeveloperProviderName"),
  18. OpenIdConnectProviderARNs: []*string{
  19. aws.String("ARNString"), // Required
  20. // More values...
  21. },
  22. SupportedLoginProviders: map[string]*string{
  23. "Key": aws.String("IdentityProviderId"), // Required
  24. // More values...
  25. },
  26. }
  27. resp, err := svc.CreateIdentityPool(params)
  28. if err != nil {
  29. // Print the error, cast err to awserr.Error to get the Code and
  30. // Message from an error.
  31. fmt.Println(err.Error())
  32. return
  33. }
  34. // Pretty-print the response data.
  35. fmt.Println(resp)
  36. }
  37. func ExampleCognitoIdentity_DeleteIdentities() {
  38. svc := cognitoidentity.New(nil)
  39. params := &cognitoidentity.DeleteIdentitiesInput{
  40. IdentityIdsToDelete: []*string{ // Required
  41. aws.String("IdentityId"), // Required
  42. // More values...
  43. },
  44. }
  45. resp, err := svc.DeleteIdentities(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 ExampleCognitoIdentity_DeleteIdentityPool() {
  56. svc := cognitoidentity.New(nil)
  57. params := &cognitoidentity.DeleteIdentityPoolInput{
  58. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  59. }
  60. resp, err := svc.DeleteIdentityPool(params)
  61. if err != nil {
  62. // Print the error, cast err to awserr.Error to get the Code and
  63. // Message from an error.
  64. fmt.Println(err.Error())
  65. return
  66. }
  67. // Pretty-print the response data.
  68. fmt.Println(resp)
  69. }
  70. func ExampleCognitoIdentity_DescribeIdentity() {
  71. svc := cognitoidentity.New(nil)
  72. params := &cognitoidentity.DescribeIdentityInput{
  73. IdentityId: aws.String("IdentityId"), // Required
  74. }
  75. resp, err := svc.DescribeIdentity(params)
  76. if err != nil {
  77. // Print the error, cast err to awserr.Error to get the Code and
  78. // Message from an error.
  79. fmt.Println(err.Error())
  80. return
  81. }
  82. // Pretty-print the response data.
  83. fmt.Println(resp)
  84. }
  85. func ExampleCognitoIdentity_DescribeIdentityPool() {
  86. svc := cognitoidentity.New(nil)
  87. params := &cognitoidentity.DescribeIdentityPoolInput{
  88. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  89. }
  90. resp, err := svc.DescribeIdentityPool(params)
  91. if err != nil {
  92. // Print the error, cast err to awserr.Error to get the Code and
  93. // Message from an error.
  94. fmt.Println(err.Error())
  95. return
  96. }
  97. // Pretty-print the response data.
  98. fmt.Println(resp)
  99. }
  100. func ExampleCognitoIdentity_GetCredentialsForIdentity() {
  101. svc := cognitoidentity.New(nil)
  102. params := &cognitoidentity.GetCredentialsForIdentityInput{
  103. IdentityId: aws.String("IdentityId"), // Required
  104. Logins: map[string]*string{
  105. "Key": aws.String("IdentityProviderToken"), // Required
  106. // More values...
  107. },
  108. }
  109. resp, err := svc.GetCredentialsForIdentity(params)
  110. if err != nil {
  111. // Print the error, cast err to awserr.Error to get the Code and
  112. // Message from an error.
  113. fmt.Println(err.Error())
  114. return
  115. }
  116. // Pretty-print the response data.
  117. fmt.Println(resp)
  118. }
  119. func ExampleCognitoIdentity_GetId() {
  120. svc := cognitoidentity.New(nil)
  121. params := &cognitoidentity.GetIdInput{
  122. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  123. AccountId: aws.String("AccountId"),
  124. Logins: map[string]*string{
  125. "Key": aws.String("IdentityProviderToken"), // Required
  126. // More values...
  127. },
  128. }
  129. resp, err := svc.GetId(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 ExampleCognitoIdentity_GetIdentityPoolRoles() {
  140. svc := cognitoidentity.New(nil)
  141. params := &cognitoidentity.GetIdentityPoolRolesInput{
  142. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  143. }
  144. resp, err := svc.GetIdentityPoolRoles(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 ExampleCognitoIdentity_GetOpenIdToken() {
  155. svc := cognitoidentity.New(nil)
  156. params := &cognitoidentity.GetOpenIdTokenInput{
  157. IdentityId: aws.String("IdentityId"), // Required
  158. Logins: map[string]*string{
  159. "Key": aws.String("IdentityProviderToken"), // Required
  160. // More values...
  161. },
  162. }
  163. resp, err := svc.GetOpenIdToken(params)
  164. if err != nil {
  165. // Print the error, cast err to awserr.Error to get the Code and
  166. // Message from an error.
  167. fmt.Println(err.Error())
  168. return
  169. }
  170. // Pretty-print the response data.
  171. fmt.Println(resp)
  172. }
  173. func ExampleCognitoIdentity_GetOpenIdTokenForDeveloperIdentity() {
  174. svc := cognitoidentity.New(nil)
  175. params := &cognitoidentity.GetOpenIdTokenForDeveloperIdentityInput{
  176. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  177. Logins: map[string]*string{ // Required
  178. "Key": aws.String("IdentityProviderToken"), // Required
  179. // More values...
  180. },
  181. IdentityId: aws.String("IdentityId"),
  182. TokenDuration: aws.Int64(1),
  183. }
  184. resp, err := svc.GetOpenIdTokenForDeveloperIdentity(params)
  185. if err != nil {
  186. // Print the error, cast err to awserr.Error to get the Code and
  187. // Message from an error.
  188. fmt.Println(err.Error())
  189. return
  190. }
  191. // Pretty-print the response data.
  192. fmt.Println(resp)
  193. }
  194. func ExampleCognitoIdentity_ListIdentities() {
  195. svc := cognitoidentity.New(nil)
  196. params := &cognitoidentity.ListIdentitiesInput{
  197. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  198. MaxResults: aws.Int64(1), // Required
  199. HideDisabled: aws.Bool(true),
  200. NextToken: aws.String("PaginationKey"),
  201. }
  202. resp, err := svc.ListIdentities(params)
  203. if err != nil {
  204. // Print the error, cast err to awserr.Error to get the Code and
  205. // Message from an error.
  206. fmt.Println(err.Error())
  207. return
  208. }
  209. // Pretty-print the response data.
  210. fmt.Println(resp)
  211. }
  212. func ExampleCognitoIdentity_ListIdentityPools() {
  213. svc := cognitoidentity.New(nil)
  214. params := &cognitoidentity.ListIdentityPoolsInput{
  215. MaxResults: aws.Int64(1), // Required
  216. NextToken: aws.String("PaginationKey"),
  217. }
  218. resp, err := svc.ListIdentityPools(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 ExampleCognitoIdentity_LookupDeveloperIdentity() {
  229. svc := cognitoidentity.New(nil)
  230. params := &cognitoidentity.LookupDeveloperIdentityInput{
  231. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  232. DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"),
  233. IdentityId: aws.String("IdentityId"),
  234. MaxResults: aws.Int64(1),
  235. NextToken: aws.String("PaginationKey"),
  236. }
  237. resp, err := svc.LookupDeveloperIdentity(params)
  238. if err != nil {
  239. // Print the error, cast err to awserr.Error to get the Code and
  240. // Message from an error.
  241. fmt.Println(err.Error())
  242. return
  243. }
  244. // Pretty-print the response data.
  245. fmt.Println(resp)
  246. }
  247. func ExampleCognitoIdentity_MergeDeveloperIdentities() {
  248. svc := cognitoidentity.New(nil)
  249. params := &cognitoidentity.MergeDeveloperIdentitiesInput{
  250. DestinationUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
  251. DeveloperProviderName: aws.String("DeveloperProviderName"), // Required
  252. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  253. SourceUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
  254. }
  255. resp, err := svc.MergeDeveloperIdentities(params)
  256. if err != nil {
  257. // Print the error, cast err to awserr.Error to get the Code and
  258. // Message from an error.
  259. fmt.Println(err.Error())
  260. return
  261. }
  262. // Pretty-print the response data.
  263. fmt.Println(resp)
  264. }
  265. func ExampleCognitoIdentity_SetIdentityPoolRoles() {
  266. svc := cognitoidentity.New(nil)
  267. params := &cognitoidentity.SetIdentityPoolRolesInput{
  268. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  269. Roles: map[string]*string{ // Required
  270. "Key": aws.String("ARNString"), // Required
  271. // More values...
  272. },
  273. }
  274. resp, err := svc.SetIdentityPoolRoles(params)
  275. if err != nil {
  276. // Print the error, cast err to awserr.Error to get the Code and
  277. // Message from an error.
  278. fmt.Println(err.Error())
  279. return
  280. }
  281. // Pretty-print the response data.
  282. fmt.Println(resp)
  283. }
  284. func ExampleCognitoIdentity_UnlinkDeveloperIdentity() {
  285. svc := cognitoidentity.New(nil)
  286. params := &cognitoidentity.UnlinkDeveloperIdentityInput{
  287. DeveloperProviderName: aws.String("DeveloperProviderName"), // Required
  288. DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
  289. IdentityId: aws.String("IdentityId"), // Required
  290. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  291. }
  292. resp, err := svc.UnlinkDeveloperIdentity(params)
  293. if err != nil {
  294. // Print the error, cast err to awserr.Error to get the Code and
  295. // Message from an error.
  296. fmt.Println(err.Error())
  297. return
  298. }
  299. // Pretty-print the response data.
  300. fmt.Println(resp)
  301. }
  302. func ExampleCognitoIdentity_UnlinkIdentity() {
  303. svc := cognitoidentity.New(nil)
  304. params := &cognitoidentity.UnlinkIdentityInput{
  305. IdentityId: aws.String("IdentityId"), // Required
  306. Logins: map[string]*string{ // Required
  307. "Key": aws.String("IdentityProviderToken"), // Required
  308. // More values...
  309. },
  310. LoginsToRemove: []*string{ // Required
  311. aws.String("IdentityProviderName"), // Required
  312. // More values...
  313. },
  314. }
  315. resp, err := svc.UnlinkIdentity(params)
  316. if err != nil {
  317. // Print the error, cast err to awserr.Error to get the Code and
  318. // Message from an error.
  319. fmt.Println(err.Error())
  320. return
  321. }
  322. // Pretty-print the response data.
  323. fmt.Println(resp)
  324. }
  325. func ExampleCognitoIdentity_UpdateIdentityPool() {
  326. svc := cognitoidentity.New(nil)
  327. params := &cognitoidentity.IdentityPool{
  328. AllowUnauthenticatedIdentities: aws.Bool(true), // Required
  329. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  330. IdentityPoolName: aws.String("IdentityPoolName"), // Required
  331. DeveloperProviderName: aws.String("DeveloperProviderName"),
  332. OpenIdConnectProviderARNs: []*string{
  333. aws.String("ARNString"), // Required
  334. // More values...
  335. },
  336. SupportedLoginProviders: map[string]*string{
  337. "Key": aws.String("IdentityProviderId"), // Required
  338. // More values...
  339. },
  340. }
  341. resp, err := svc.UpdateIdentityPool(params)
  342. if err != nil {
  343. // Print the error, cast err to awserr.Error to get the Code and
  344. // Message from an error.
  345. fmt.Println(err.Error())
  346. return
  347. }
  348. // Pretty-print the response data.
  349. fmt.Println(resp)
  350. }