src

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

api_op_GetCallerIdentity.go (7165B)


      1 // Code generated by smithy-go-codegen DO NOT EDIT.
      2 
      3 package sts
      4 
      5 import (
      6 	"context"
      7 	"fmt"
      8 	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
      9 	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
     10 	"github.com/aws/smithy-go/middleware"
     11 	smithyhttp "github.com/aws/smithy-go/transport/http"
     12 )
     13 
     14 // Returns details about the IAM user or role whose credentials are used to call
     15 // the operation.
     16 //
     17 // No permissions are required to perform this operation. If an administrator
     18 // attaches a policy to your identity that explicitly denies access to the
     19 // sts:GetCallerIdentity action, you can still perform this operation. Permissions
     20 // are not required because the same information is returned when access is denied.
     21 // To view an example response, see [I Am Not Authorized to Perform: iam:DeleteVirtualMFADevice]in the IAM User Guide.
     22 //
     23 // [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
     24 func (c *Client) GetCallerIdentity(ctx context.Context, params *GetCallerIdentityInput, optFns ...func(*Options)) (*GetCallerIdentityOutput, error) {
     25 	if params == nil {
     26 		params = &GetCallerIdentityInput{}
     27 	}
     28 
     29 	result, metadata, err := c.invokeOperation(ctx, "GetCallerIdentity", params, optFns, c.addOperationGetCallerIdentityMiddlewares)
     30 	if err != nil {
     31 		return nil, err
     32 	}
     33 
     34 	out := result.(*GetCallerIdentityOutput)
     35 	out.ResultMetadata = metadata
     36 	return out, nil
     37 }
     38 
     39 type GetCallerIdentityInput struct {
     40 	noSmithyDocumentSerde
     41 }
     42 
     43 // Contains the response to a successful GetCallerIdentity request, including information about the
     44 // entity making the request.
     45 type GetCallerIdentityOutput struct {
     46 
     47 	// The Amazon Web Services account ID number of the account that owns or contains
     48 	// the calling entity.
     49 	Account *string
     50 
     51 	// The Amazon Web Services ARN associated with the calling entity.
     52 	Arn *string
     53 
     54 	// The unique identifier of the calling entity. The exact value depends on the
     55 	// type of entity that is making the call. The values returned are those listed in
     56 	// the aws:userid column in the [Principal table]found on the Policy Variables reference page in
     57 	// the IAM User Guide.
     58 	//
     59 	// [Principal table]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html#principaltable
     60 	UserId *string
     61 
     62 	// Metadata pertaining to the operation's result.
     63 	ResultMetadata middleware.Metadata
     64 
     65 	noSmithyDocumentSerde
     66 }
     67 
     68 func (c *Client) addOperationGetCallerIdentityMiddlewares(stack *middleware.Stack, options Options) (err error) {
     69 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
     70 		return err
     71 	}
     72 	err = stack.Serialize.Add(&awsAwsquery_serializeOpGetCallerIdentity{}, middleware.After)
     73 	if err != nil {
     74 		return err
     75 	}
     76 	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpGetCallerIdentity{}, middleware.After)
     77 	if err != nil {
     78 		return err
     79 	}
     80 	if err := addProtocolFinalizerMiddlewares(stack, options, "GetCallerIdentity"); err != nil {
     81 		return fmt.Errorf("add protocol finalizers: %v", err)
     82 	}
     83 
     84 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
     85 		return err
     86 	}
     87 	if err = addSetLoggerMiddleware(stack, options); err != nil {
     88 		return err
     89 	}
     90 	if err = addClientRequestID(stack); err != nil {
     91 		return err
     92 	}
     93 	if err = addComputeContentLength(stack); err != nil {
     94 		return err
     95 	}
     96 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
     97 		return err
     98 	}
     99 	if err = addComputePayloadSHA256(stack); err != nil {
    100 		return err
    101 	}
    102 	if err = addRetry(stack, options); err != nil {
    103 		return err
    104 	}
    105 	if err = addRawResponseToMetadata(stack); err != nil {
    106 		return err
    107 	}
    108 	if err = addRecordResponseTiming(stack); err != nil {
    109 		return err
    110 	}
    111 	if err = addSpanRetryLoop(stack, options); err != nil {
    112 		return err
    113 	}
    114 	if err = addClientUserAgent(stack, options); err != nil {
    115 		return err
    116 	}
    117 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    118 		return err
    119 	}
    120 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    121 		return err
    122 	}
    123 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    124 		return err
    125 	}
    126 	if err = addTimeOffsetBuild(stack, c); err != nil {
    127 		return err
    128 	}
    129 	if err = addUserAgentRetryMode(stack, options); err != nil {
    130 		return err
    131 	}
    132 	if err = addCredentialSource(stack, options); err != nil {
    133 		return err
    134 	}
    135 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCallerIdentity(options.Region), middleware.Before); err != nil {
    136 		return err
    137 	}
    138 	if err = addRecursionDetection(stack); err != nil {
    139 		return err
    140 	}
    141 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    142 		return err
    143 	}
    144 	if err = addResponseErrorMiddleware(stack); err != nil {
    145 		return err
    146 	}
    147 	if err = addRequestResponseLogging(stack, options); err != nil {
    148 		return err
    149 	}
    150 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    151 		return err
    152 	}
    153 	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
    154 		return err
    155 	}
    156 	if err = addInterceptAttempt(stack, options); err != nil {
    157 		return err
    158 	}
    159 	if err = addInterceptExecution(stack, options); err != nil {
    160 		return err
    161 	}
    162 	if err = addInterceptBeforeSerialization(stack, options); err != nil {
    163 		return err
    164 	}
    165 	if err = addInterceptAfterSerialization(stack, options); err != nil {
    166 		return err
    167 	}
    168 	if err = addInterceptBeforeSigning(stack, options); err != nil {
    169 		return err
    170 	}
    171 	if err = addInterceptAfterSigning(stack, options); err != nil {
    172 		return err
    173 	}
    174 	if err = addInterceptTransmit(stack, options); err != nil {
    175 		return err
    176 	}
    177 	if err = addInterceptBeforeDeserialization(stack, options); err != nil {
    178 		return err
    179 	}
    180 	if err = addInterceptAfterDeserialization(stack, options); err != nil {
    181 		return err
    182 	}
    183 	if err = addSpanInitializeStart(stack); err != nil {
    184 		return err
    185 	}
    186 	if err = addSpanInitializeEnd(stack); err != nil {
    187 		return err
    188 	}
    189 	if err = addSpanBuildRequestStart(stack); err != nil {
    190 		return err
    191 	}
    192 	if err = addSpanBuildRequestEnd(stack); err != nil {
    193 		return err
    194 	}
    195 	return nil
    196 }
    197 
    198 func newServiceMetadataMiddleware_opGetCallerIdentity(region string) *awsmiddleware.RegisterServiceMetadata {
    199 	return &awsmiddleware.RegisterServiceMetadata{
    200 		Region:        region,
    201 		ServiceID:     ServiceID,
    202 		OperationName: "GetCallerIdentity",
    203 	}
    204 }
    205 
    206 // PresignGetCallerIdentity is used to generate a presigned HTTP Request which
    207 // contains presigned URL, signed headers and HTTP method used.
    208 func (c *PresignClient) PresignGetCallerIdentity(ctx context.Context, params *GetCallerIdentityInput, optFns ...func(*PresignOptions)) (*v4.PresignedHTTPRequest, error) {
    209 	if params == nil {
    210 		params = &GetCallerIdentityInput{}
    211 	}
    212 	options := c.options.copy()
    213 	for _, fn := range optFns {
    214 		fn(&options)
    215 	}
    216 	clientOptFns := append(options.ClientOptions, withNopHTTPClientAPIOption)
    217 
    218 	result, _, err := c.client.invokeOperation(ctx, "GetCallerIdentity", params, clientOptFns,
    219 		c.client.addOperationGetCallerIdentityMiddlewares,
    220 		presignConverter(options).convertToPresignMiddleware,
    221 	)
    222 	if err != nil {
    223 		return nil, err
    224 	}
    225 
    226 	out := result.(*v4.PresignedHTTPRequest)
    227 	return out, nil
    228 }