UNPKG

4.61 kBPlain TextView Raw
1import { STSClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../STSClient";
2import { GetCallerIdentityRequest, GetCallerIdentityResponse } from "../models/models_0";
3import {
4 deserializeAws_queryGetCallerIdentityCommand,
5 serializeAws_queryGetCallerIdentityCommand,
6} from "../protocols/Aws_query";
7import { getSerdePlugin } from "@aws-sdk/middleware-serde";
8import { getAwsAuthPlugin } from "@aws-sdk/middleware-signing";
9import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
10import { Command as $Command } from "@aws-sdk/smithy-client";
11import {
12 FinalizeHandlerArguments,
13 Handler,
14 HandlerExecutionContext,
15 MiddlewareStack,
16 HttpHandlerOptions as __HttpHandlerOptions,
17 MetadataBearer as __MetadataBearer,
18 SerdeContext as __SerdeContext,
19} from "@aws-sdk/types";
20
21export interface GetCallerIdentityCommandInput extends GetCallerIdentityRequest {}
22export interface GetCallerIdentityCommandOutput extends GetCallerIdentityResponse, __MetadataBearer {}
23
24/**
25 * <p>Returns details about the IAM user or role whose credentials are used to call the
26 * operation.</p>
27 * <note>
28 * <p>No permissions are required to perform this operation. If an administrator adds a
29 * policy to your IAM user or role that explicitly denies access to the
30 * <code>sts:GetCallerIdentity</code> action, you can still perform this operation.
31 * Permissions are not required because the same information is returned when an IAM
32 * user or role is denied access. To view an example response, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_access-denied-delete-mfa">I Am Not Authorized to Perform: iam:DeleteVirtualMFADevice</a> in the
33 * <i>IAM User Guide</i>.</p>
34 * </note>
35 * @example
36 * Use a bare-bones client and the command you need to make an API call.
37 * ```javascript
38 * import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts"; // ES Modules import
39 * // const { STSClient, GetCallerIdentityCommand } = require("@aws-sdk/client-sts"); // CommonJS import
40 * const client = new STSClient(config);
41 * const command = new GetCallerIdentityCommand(input);
42 * const response = await client.send(command);
43 * ```
44 *
45 * @see {@link GetCallerIdentityCommandInput} for command's `input` shape.
46 * @see {@link GetCallerIdentityCommandOutput} for command's `response` shape.
47 * @see {@link STSClientResolvedConfig | config} for command's `input` shape.
48 *
49 */
50export class GetCallerIdentityCommand extends $Command<
51 GetCallerIdentityCommandInput,
52 GetCallerIdentityCommandOutput,
53 STSClientResolvedConfig
54> {
55 // Start section: command_properties
56 // End section: command_properties
57
58 constructor(readonly input: GetCallerIdentityCommandInput) {
59 // Start section: command_constructor
60 super();
61 // End section: command_constructor
62 }
63
64 /**
65 * @internal
66 */
67 resolveMiddleware(
68 clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
69 configuration: STSClientResolvedConfig,
70 options?: __HttpHandlerOptions
71 ): Handler<GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput> {
72 this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
73 this.middlewareStack.use(getAwsAuthPlugin(configuration));
74
75 const stack = clientStack.concat(this.middlewareStack);
76
77 const { logger } = configuration;
78 const clientName = "STSClient";
79 const commandName = "GetCallerIdentityCommand";
80 const handlerExecutionContext: HandlerExecutionContext = {
81 logger,
82 clientName,
83 commandName,
84 inputFilterSensitiveLog: GetCallerIdentityRequest.filterSensitiveLog,
85 outputFilterSensitiveLog: GetCallerIdentityResponse.filterSensitiveLog,
86 };
87 const { requestHandler } = configuration;
88 return stack.resolve(
89 (request: FinalizeHandlerArguments<any>) =>
90 requestHandler.handle(request.request as __HttpRequest, options || {}),
91 handlerExecutionContext
92 );
93 }
94
95 private serialize(input: GetCallerIdentityCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
96 return serializeAws_queryGetCallerIdentityCommand(input, context);
97 }
98
99 private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetCallerIdentityCommandOutput> {
100 return deserializeAws_queryGetCallerIdentityCommand(output, context);
101 }
102
103 // Start section: command_body_extra
104 // End section: command_body_extra
105}