examples_test.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package sts_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/sts"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleSTS_AssumeRole() {
  13. svc := sts.New(nil)
  14. params := &sts.AssumeRoleInput{
  15. RoleArn: aws.String("arnType"), // Required
  16. RoleSessionName: aws.String("userNameType"), // Required
  17. DurationSeconds: aws.Int64(1),
  18. ExternalId: aws.String("externalIdType"),
  19. Policy: aws.String("sessionPolicyDocumentType"),
  20. SerialNumber: aws.String("serialNumberType"),
  21. TokenCode: aws.String("tokenCodeType"),
  22. }
  23. resp, err := svc.AssumeRole(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 ExampleSTS_AssumeRoleWithSAML() {
  34. svc := sts.New(nil)
  35. params := &sts.AssumeRoleWithSAMLInput{
  36. PrincipalArn: aws.String("arnType"), // Required
  37. RoleArn: aws.String("arnType"), // Required
  38. SAMLAssertion: aws.String("SAMLAssertionType"), // Required
  39. DurationSeconds: aws.Int64(1),
  40. Policy: aws.String("sessionPolicyDocumentType"),
  41. }
  42. resp, err := svc.AssumeRoleWithSAML(params)
  43. if err != nil {
  44. // Print the error, cast err to awserr.Error to get the Code and
  45. // Message from an error.
  46. fmt.Println(err.Error())
  47. return
  48. }
  49. // Pretty-print the response data.
  50. fmt.Println(resp)
  51. }
  52. func ExampleSTS_AssumeRoleWithWebIdentity() {
  53. svc := sts.New(nil)
  54. params := &sts.AssumeRoleWithWebIdentityInput{
  55. RoleArn: aws.String("arnType"), // Required
  56. RoleSessionName: aws.String("userNameType"), // Required
  57. WebIdentityToken: aws.String("clientTokenType"), // Required
  58. DurationSeconds: aws.Int64(1),
  59. Policy: aws.String("sessionPolicyDocumentType"),
  60. ProviderId: aws.String("urlType"),
  61. }
  62. resp, err := svc.AssumeRoleWithWebIdentity(params)
  63. if err != nil {
  64. // Print the error, cast err to awserr.Error to get the Code and
  65. // Message from an error.
  66. fmt.Println(err.Error())
  67. return
  68. }
  69. // Pretty-print the response data.
  70. fmt.Println(resp)
  71. }
  72. func ExampleSTS_DecodeAuthorizationMessage() {
  73. svc := sts.New(nil)
  74. params := &sts.DecodeAuthorizationMessageInput{
  75. EncodedMessage: aws.String("encodedMessageType"), // Required
  76. }
  77. resp, err := svc.DecodeAuthorizationMessage(params)
  78. if err != nil {
  79. // Print the error, cast err to awserr.Error to get the Code and
  80. // Message from an error.
  81. fmt.Println(err.Error())
  82. return
  83. }
  84. // Pretty-print the response data.
  85. fmt.Println(resp)
  86. }
  87. func ExampleSTS_GetFederationToken() {
  88. svc := sts.New(nil)
  89. params := &sts.GetFederationTokenInput{
  90. Name: aws.String("userNameType"), // Required
  91. DurationSeconds: aws.Int64(1),
  92. Policy: aws.String("sessionPolicyDocumentType"),
  93. }
  94. resp, err := svc.GetFederationToken(params)
  95. if err != nil {
  96. // Print the error, cast err to awserr.Error to get the Code and
  97. // Message from an error.
  98. fmt.Println(err.Error())
  99. return
  100. }
  101. // Pretty-print the response data.
  102. fmt.Println(resp)
  103. }
  104. func ExampleSTS_GetSessionToken() {
  105. svc := sts.New(nil)
  106. params := &sts.GetSessionTokenInput{
  107. DurationSeconds: aws.Int64(1),
  108. SerialNumber: aws.String("serialNumberType"),
  109. TokenCode: aws.String("tokenCodeType"),
  110. }
  111. resp, err := svc.GetSessionToken(params)
  112. if err != nil {
  113. // Print the error, cast err to awserr.Error to get the Code and
  114. // Message from an error.
  115. fmt.Println(err.Error())
  116. return
  117. }
  118. // Pretty-print the response data.
  119. fmt.Println(resp)
  120. }