src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

api_op_GetCallerIdentity.go (4344B)


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