api_op_GetCallerIdentity.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package sts
  3. import (
  4. "context"
  5. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  6. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  7. "github.com/aws/smithy-go/middleware"
  8. smithyhttp "github.com/aws/smithy-go/transport/http"
  9. )
  10. // Returns details about the IAM user or role whose credentials are used to call
  11. // the operation. No permissions are required to perform this operation. If an
  12. // administrator adds a policy to your IAM user or role that explicitly denies
  13. // access to the sts:GetCallerIdentity action, you can still perform this
  14. // operation. Permissions are not required because the same information is returned
  15. // when an IAM user or role is denied access. To view an example response, see I Am
  16. // Not Authorized to Perform: iam:DeleteVirtualMFADevice
  17. // (https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_access-denied-delete-mfa)
  18. // in the IAM User Guide.
  19. func (c *Client) GetCallerIdentity(ctx context.Context, params *GetCallerIdentityInput, optFns ...func(*Options)) (*GetCallerIdentityOutput, error) {
  20. if params == nil {
  21. params = &GetCallerIdentityInput{}
  22. }
  23. result, metadata, err := c.invokeOperation(ctx, "GetCallerIdentity", params, optFns, c.addOperationGetCallerIdentityMiddlewares)
  24. if err != nil {
  25. return nil, err
  26. }
  27. out := result.(*GetCallerIdentityOutput)
  28. out.ResultMetadata = metadata
  29. return out, nil
  30. }
  31. type GetCallerIdentityInput struct {
  32. noSmithyDocumentSerde
  33. }
  34. // Contains the response to a successful GetCallerIdentity request, including
  35. // information about the entity making the request.
  36. type GetCallerIdentityOutput struct {
  37. // The Amazon Web Services account ID number of the account that owns or contains
  38. // the calling entity.
  39. Account *string
  40. // The Amazon Web Services ARN associated with the calling entity.
  41. Arn *string
  42. // The unique identifier of the calling entity. The exact value depends on the type
  43. // of entity that is making the call. The values returned are those listed in the
  44. // aws:userid column in the Principal table
  45. // (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html#principaltable)
  46. // found on the Policy Variables reference page in the IAM User Guide.
  47. UserId *string
  48. // Metadata pertaining to the operation's result.
  49. ResultMetadata middleware.Metadata
  50. noSmithyDocumentSerde
  51. }
  52. func (c *Client) addOperationGetCallerIdentityMiddlewares(stack *middleware.Stack, options Options) (err error) {
  53. err = stack.Serialize.Add(&awsAwsquery_serializeOpGetCallerIdentity{}, middleware.After)
  54. if err != nil {
  55. return err
  56. }
  57. err = stack.Deserialize.Add(&awsAwsquery_deserializeOpGetCallerIdentity{}, middleware.After)
  58. if err != nil {
  59. return err
  60. }
  61. if err = addSetLoggerMiddleware(stack, options); err != nil {
  62. return err
  63. }
  64. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  65. return err
  66. }
  67. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  68. return err
  69. }
  70. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  71. return err
  72. }
  73. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  74. return err
  75. }
  76. if err = addRetryMiddlewares(stack, options); err != nil {
  77. return err
  78. }
  79. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  80. return err
  81. }
  82. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  83. return err
  84. }
  85. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  86. return err
  87. }
  88. if err = addClientUserAgent(stack); err != nil {
  89. return err
  90. }
  91. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  92. return err
  93. }
  94. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  95. return err
  96. }
  97. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCallerIdentity(options.Region), middleware.Before); err != nil {
  98. return err
  99. }
  100. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  101. return err
  102. }
  103. if err = addResponseErrorMiddleware(stack); err != nil {
  104. return err
  105. }
  106. if err = addRequestResponseLogging(stack, options); err != nil {
  107. return err
  108. }
  109. return nil
  110. }
  111. func newServiceMetadataMiddleware_opGetCallerIdentity(region string) *awsmiddleware.RegisterServiceMetadata {
  112. return &awsmiddleware.RegisterServiceMetadata{
  113. Region: region,
  114. ServiceID: ServiceID,
  115. SigningName: "sts",
  116. OperationName: "GetCallerIdentity",
  117. }
  118. }
  119. // PresignGetCallerIdentity is used to generate a presigned HTTP Request which
  120. // contains presigned URL, signed headers and HTTP method used.
  121. func (c *PresignClient) PresignGetCallerIdentity(ctx context.Context, params *GetCallerIdentityInput, optFns ...func(*PresignOptions)) (*v4.PresignedHTTPRequest, error) {
  122. if params == nil {
  123. params = &GetCallerIdentityInput{}
  124. }
  125. options := c.options.copy()
  126. for _, fn := range optFns {
  127. fn(&options)
  128. }
  129. clientOptFns := append(options.ClientOptions, withNopHTTPClientAPIOption)
  130. result, _, err := c.client.invokeOperation(ctx, "GetCallerIdentity", params, clientOptFns,
  131. c.client.addOperationGetCallerIdentityMiddlewares,
  132. presignConverter(options).convertToPresignMiddleware,
  133. )
  134. if err != nil {
  135. return nil, err
  136. }
  137. out := result.(*v4.PresignedHTTPRequest)
  138. return out, nil
  139. }