examples_test.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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/aws/session"
  9. "github.com/aws/aws-sdk-go/service/cognitoidentity"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleCognitoIdentity_CreateIdentityPool() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := cognitoidentity.New(sess)
  20. params := &cognitoidentity.CreateIdentityPoolInput{
  21. AllowUnauthenticatedIdentities: aws.Bool(true), // Required
  22. IdentityPoolName: aws.String("IdentityPoolName"), // Required
  23. CognitoIdentityProviders: []*cognitoidentity.Provider{
  24. { // Required
  25. ClientId: aws.String("ProviderClientId"),
  26. ProviderName: aws.String("ProviderName"),
  27. },
  28. // More values...
  29. },
  30. DeveloperProviderName: aws.String("DeveloperProviderName"),
  31. OpenIdConnectProviderARNs: []*string{
  32. aws.String("ARNString"), // Required
  33. // More values...
  34. },
  35. SamlProviderARNs: []*string{
  36. aws.String("ARNString"), // Required
  37. // More values...
  38. },
  39. SupportedLoginProviders: map[string]*string{
  40. "Key": aws.String("IdentityProviderId"), // Required
  41. // More values...
  42. },
  43. }
  44. resp, err := svc.CreateIdentityPool(params)
  45. if err != nil {
  46. // Print the error, cast err to awserr.Error to get the Code and
  47. // Message from an error.
  48. fmt.Println(err.Error())
  49. return
  50. }
  51. // Pretty-print the response data.
  52. fmt.Println(resp)
  53. }
  54. func ExampleCognitoIdentity_DeleteIdentities() {
  55. sess, err := session.NewSession()
  56. if err != nil {
  57. fmt.Println("failed to create session,", err)
  58. return
  59. }
  60. svc := cognitoidentity.New(sess)
  61. params := &cognitoidentity.DeleteIdentitiesInput{
  62. IdentityIdsToDelete: []*string{ // Required
  63. aws.String("IdentityId"), // Required
  64. // More values...
  65. },
  66. }
  67. resp, err := svc.DeleteIdentities(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 ExampleCognitoIdentity_DeleteIdentityPool() {
  78. sess, err := session.NewSession()
  79. if err != nil {
  80. fmt.Println("failed to create session,", err)
  81. return
  82. }
  83. svc := cognitoidentity.New(sess)
  84. params := &cognitoidentity.DeleteIdentityPoolInput{
  85. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  86. }
  87. resp, err := svc.DeleteIdentityPool(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 ExampleCognitoIdentity_DescribeIdentity() {
  98. sess, err := session.NewSession()
  99. if err != nil {
  100. fmt.Println("failed to create session,", err)
  101. return
  102. }
  103. svc := cognitoidentity.New(sess)
  104. params := &cognitoidentity.DescribeIdentityInput{
  105. IdentityId: aws.String("IdentityId"), // Required
  106. }
  107. resp, err := svc.DescribeIdentity(params)
  108. if err != nil {
  109. // Print the error, cast err to awserr.Error to get the Code and
  110. // Message from an error.
  111. fmt.Println(err.Error())
  112. return
  113. }
  114. // Pretty-print the response data.
  115. fmt.Println(resp)
  116. }
  117. func ExampleCognitoIdentity_DescribeIdentityPool() {
  118. sess, err := session.NewSession()
  119. if err != nil {
  120. fmt.Println("failed to create session,", err)
  121. return
  122. }
  123. svc := cognitoidentity.New(sess)
  124. params := &cognitoidentity.DescribeIdentityPoolInput{
  125. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  126. }
  127. resp, err := svc.DescribeIdentityPool(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 ExampleCognitoIdentity_GetCredentialsForIdentity() {
  138. sess, err := session.NewSession()
  139. if err != nil {
  140. fmt.Println("failed to create session,", err)
  141. return
  142. }
  143. svc := cognitoidentity.New(sess)
  144. params := &cognitoidentity.GetCredentialsForIdentityInput{
  145. IdentityId: aws.String("IdentityId"), // Required
  146. CustomRoleArn: aws.String("ARNString"),
  147. Logins: map[string]*string{
  148. "Key": aws.String("IdentityProviderToken"), // Required
  149. // More values...
  150. },
  151. }
  152. resp, err := svc.GetCredentialsForIdentity(params)
  153. if err != nil {
  154. // Print the error, cast err to awserr.Error to get the Code and
  155. // Message from an error.
  156. fmt.Println(err.Error())
  157. return
  158. }
  159. // Pretty-print the response data.
  160. fmt.Println(resp)
  161. }
  162. func ExampleCognitoIdentity_GetId() {
  163. sess, err := session.NewSession()
  164. if err != nil {
  165. fmt.Println("failed to create session,", err)
  166. return
  167. }
  168. svc := cognitoidentity.New(sess)
  169. params := &cognitoidentity.GetIdInput{
  170. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  171. AccountId: aws.String("AccountId"),
  172. Logins: map[string]*string{
  173. "Key": aws.String("IdentityProviderToken"), // Required
  174. // More values...
  175. },
  176. }
  177. resp, err := svc.GetId(params)
  178. if err != nil {
  179. // Print the error, cast err to awserr.Error to get the Code and
  180. // Message from an error.
  181. fmt.Println(err.Error())
  182. return
  183. }
  184. // Pretty-print the response data.
  185. fmt.Println(resp)
  186. }
  187. func ExampleCognitoIdentity_GetIdentityPoolRoles() {
  188. sess, err := session.NewSession()
  189. if err != nil {
  190. fmt.Println("failed to create session,", err)
  191. return
  192. }
  193. svc := cognitoidentity.New(sess)
  194. params := &cognitoidentity.GetIdentityPoolRolesInput{
  195. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  196. }
  197. resp, err := svc.GetIdentityPoolRoles(params)
  198. if err != nil {
  199. // Print the error, cast err to awserr.Error to get the Code and
  200. // Message from an error.
  201. fmt.Println(err.Error())
  202. return
  203. }
  204. // Pretty-print the response data.
  205. fmt.Println(resp)
  206. }
  207. func ExampleCognitoIdentity_GetOpenIdToken() {
  208. sess, err := session.NewSession()
  209. if err != nil {
  210. fmt.Println("failed to create session,", err)
  211. return
  212. }
  213. svc := cognitoidentity.New(sess)
  214. params := &cognitoidentity.GetOpenIdTokenInput{
  215. IdentityId: aws.String("IdentityId"), // Required
  216. Logins: map[string]*string{
  217. "Key": aws.String("IdentityProviderToken"), // Required
  218. // More values...
  219. },
  220. }
  221. resp, err := svc.GetOpenIdToken(params)
  222. if err != nil {
  223. // Print the error, cast err to awserr.Error to get the Code and
  224. // Message from an error.
  225. fmt.Println(err.Error())
  226. return
  227. }
  228. // Pretty-print the response data.
  229. fmt.Println(resp)
  230. }
  231. func ExampleCognitoIdentity_GetOpenIdTokenForDeveloperIdentity() {
  232. sess, err := session.NewSession()
  233. if err != nil {
  234. fmt.Println("failed to create session,", err)
  235. return
  236. }
  237. svc := cognitoidentity.New(sess)
  238. params := &cognitoidentity.GetOpenIdTokenForDeveloperIdentityInput{
  239. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  240. Logins: map[string]*string{ // Required
  241. "Key": aws.String("IdentityProviderToken"), // Required
  242. // More values...
  243. },
  244. IdentityId: aws.String("IdentityId"),
  245. TokenDuration: aws.Int64(1),
  246. }
  247. resp, err := svc.GetOpenIdTokenForDeveloperIdentity(params)
  248. if err != nil {
  249. // Print the error, cast err to awserr.Error to get the Code and
  250. // Message from an error.
  251. fmt.Println(err.Error())
  252. return
  253. }
  254. // Pretty-print the response data.
  255. fmt.Println(resp)
  256. }
  257. func ExampleCognitoIdentity_ListIdentities() {
  258. sess, err := session.NewSession()
  259. if err != nil {
  260. fmt.Println("failed to create session,", err)
  261. return
  262. }
  263. svc := cognitoidentity.New(sess)
  264. params := &cognitoidentity.ListIdentitiesInput{
  265. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  266. MaxResults: aws.Int64(1), // Required
  267. HideDisabled: aws.Bool(true),
  268. NextToken: aws.String("PaginationKey"),
  269. }
  270. resp, err := svc.ListIdentities(params)
  271. if err != nil {
  272. // Print the error, cast err to awserr.Error to get the Code and
  273. // Message from an error.
  274. fmt.Println(err.Error())
  275. return
  276. }
  277. // Pretty-print the response data.
  278. fmt.Println(resp)
  279. }
  280. func ExampleCognitoIdentity_ListIdentityPools() {
  281. sess, err := session.NewSession()
  282. if err != nil {
  283. fmt.Println("failed to create session,", err)
  284. return
  285. }
  286. svc := cognitoidentity.New(sess)
  287. params := &cognitoidentity.ListIdentityPoolsInput{
  288. MaxResults: aws.Int64(1), // Required
  289. NextToken: aws.String("PaginationKey"),
  290. }
  291. resp, err := svc.ListIdentityPools(params)
  292. if err != nil {
  293. // Print the error, cast err to awserr.Error to get the Code and
  294. // Message from an error.
  295. fmt.Println(err.Error())
  296. return
  297. }
  298. // Pretty-print the response data.
  299. fmt.Println(resp)
  300. }
  301. func ExampleCognitoIdentity_LookupDeveloperIdentity() {
  302. sess, err := session.NewSession()
  303. if err != nil {
  304. fmt.Println("failed to create session,", err)
  305. return
  306. }
  307. svc := cognitoidentity.New(sess)
  308. params := &cognitoidentity.LookupDeveloperIdentityInput{
  309. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  310. DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"),
  311. IdentityId: aws.String("IdentityId"),
  312. MaxResults: aws.Int64(1),
  313. NextToken: aws.String("PaginationKey"),
  314. }
  315. resp, err := svc.LookupDeveloperIdentity(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_MergeDeveloperIdentities() {
  326. sess, err := session.NewSession()
  327. if err != nil {
  328. fmt.Println("failed to create session,", err)
  329. return
  330. }
  331. svc := cognitoidentity.New(sess)
  332. params := &cognitoidentity.MergeDeveloperIdentitiesInput{
  333. DestinationUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
  334. DeveloperProviderName: aws.String("DeveloperProviderName"), // Required
  335. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  336. SourceUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
  337. }
  338. resp, err := svc.MergeDeveloperIdentities(params)
  339. if err != nil {
  340. // Print the error, cast err to awserr.Error to get the Code and
  341. // Message from an error.
  342. fmt.Println(err.Error())
  343. return
  344. }
  345. // Pretty-print the response data.
  346. fmt.Println(resp)
  347. }
  348. func ExampleCognitoIdentity_SetIdentityPoolRoles() {
  349. sess, err := session.NewSession()
  350. if err != nil {
  351. fmt.Println("failed to create session,", err)
  352. return
  353. }
  354. svc := cognitoidentity.New(sess)
  355. params := &cognitoidentity.SetIdentityPoolRolesInput{
  356. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  357. Roles: map[string]*string{ // Required
  358. "Key": aws.String("ARNString"), // Required
  359. // More values...
  360. },
  361. }
  362. resp, err := svc.SetIdentityPoolRoles(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 ExampleCognitoIdentity_UnlinkDeveloperIdentity() {
  373. sess, err := session.NewSession()
  374. if err != nil {
  375. fmt.Println("failed to create session,", err)
  376. return
  377. }
  378. svc := cognitoidentity.New(sess)
  379. params := &cognitoidentity.UnlinkDeveloperIdentityInput{
  380. DeveloperProviderName: aws.String("DeveloperProviderName"), // Required
  381. DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
  382. IdentityId: aws.String("IdentityId"), // Required
  383. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  384. }
  385. resp, err := svc.UnlinkDeveloperIdentity(params)
  386. if err != nil {
  387. // Print the error, cast err to awserr.Error to get the Code and
  388. // Message from an error.
  389. fmt.Println(err.Error())
  390. return
  391. }
  392. // Pretty-print the response data.
  393. fmt.Println(resp)
  394. }
  395. func ExampleCognitoIdentity_UnlinkIdentity() {
  396. sess, err := session.NewSession()
  397. if err != nil {
  398. fmt.Println("failed to create session,", err)
  399. return
  400. }
  401. svc := cognitoidentity.New(sess)
  402. params := &cognitoidentity.UnlinkIdentityInput{
  403. IdentityId: aws.String("IdentityId"), // Required
  404. Logins: map[string]*string{ // Required
  405. "Key": aws.String("IdentityProviderToken"), // Required
  406. // More values...
  407. },
  408. LoginsToRemove: []*string{ // Required
  409. aws.String("IdentityProviderName"), // Required
  410. // More values...
  411. },
  412. }
  413. resp, err := svc.UnlinkIdentity(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 ExampleCognitoIdentity_UpdateIdentityPool() {
  424. sess, err := session.NewSession()
  425. if err != nil {
  426. fmt.Println("failed to create session,", err)
  427. return
  428. }
  429. svc := cognitoidentity.New(sess)
  430. params := &cognitoidentity.IdentityPool{
  431. AllowUnauthenticatedIdentities: aws.Bool(true), // Required
  432. IdentityPoolId: aws.String("IdentityPoolId"), // Required
  433. IdentityPoolName: aws.String("IdentityPoolName"), // Required
  434. CognitoIdentityProviders: []*cognitoidentity.Provider{
  435. { // Required
  436. ClientId: aws.String("ProviderClientId"),
  437. ProviderName: aws.String("ProviderName"),
  438. },
  439. // More values...
  440. },
  441. DeveloperProviderName: aws.String("DeveloperProviderName"),
  442. OpenIdConnectProviderARNs: []*string{
  443. aws.String("ARNString"), // Required
  444. // More values...
  445. },
  446. SamlProviderARNs: []*string{
  447. aws.String("ARNString"), // Required
  448. // More values...
  449. },
  450. SupportedLoginProviders: map[string]*string{
  451. "Key": aws.String("IdentityProviderId"), // Required
  452. // More values...
  453. },
  454. }
  455. resp, err := svc.UpdateIdentityPool(params)
  456. if err != nil {
  457. // Print the error, cast err to awserr.Error to get the Code and
  458. // Message from an error.
  459. fmt.Println(err.Error())
  460. return
  461. }
  462. // Pretty-print the response data.
  463. fmt.Println(resp)
  464. }