|
| 1 | +// smithy-typescript generated code |
| 2 | +import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; |
| 3 | +import { getSerdePlugin } from "@smithy/middleware-serde"; |
| 4 | +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; |
| 5 | +import { Command as $Command } from "@smithy/smithy-client"; |
| 6 | +import { |
| 7 | + FinalizeHandlerArguments, |
| 8 | + Handler, |
| 9 | + HandlerExecutionContext, |
| 10 | + HttpHandlerOptions as __HttpHandlerOptions, |
| 11 | + MetadataBearer as __MetadataBearer, |
| 12 | + MiddlewareStack, |
| 13 | + SerdeContext as __SerdeContext, |
| 14 | + SMITHY_CONTEXT_KEY, |
| 15 | +} from "@smithy/types"; |
| 16 | + |
| 17 | +import { |
| 18 | + BatchGetSecretValueRequest, |
| 19 | + BatchGetSecretValueResponse, |
| 20 | + BatchGetSecretValueResponseFilterSensitiveLog, |
| 21 | +} from "../models/models_0"; |
| 22 | +import { de_BatchGetSecretValueCommand, se_BatchGetSecretValueCommand } from "../protocols/Aws_json1_1"; |
| 23 | +import { SecretsManagerClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../SecretsManagerClient"; |
| 24 | + |
| 25 | +/** |
| 26 | + * @public |
| 27 | + */ |
| 28 | +export { __MetadataBearer, $Command }; |
| 29 | +/** |
| 30 | + * @public |
| 31 | + * |
| 32 | + * The input for {@link BatchGetSecretValueCommand}. |
| 33 | + */ |
| 34 | +export interface BatchGetSecretValueCommandInput extends BatchGetSecretValueRequest {} |
| 35 | +/** |
| 36 | + * @public |
| 37 | + * |
| 38 | + * The output of {@link BatchGetSecretValueCommand}. |
| 39 | + */ |
| 40 | +export interface BatchGetSecretValueCommandOutput extends BatchGetSecretValueResponse, __MetadataBearer {} |
| 41 | + |
| 42 | +/** |
| 43 | + * @public |
| 44 | + * <p>Retrieves the contents of the encrypted fields <code>SecretString</code> or <code>SecretBinary</code> for up to 20 secrets. To retrieve a single secret, call <a>GetSecretValue</a>. </p> |
| 45 | + * <p>To choose which secrets to retrieve, you can specify a list of secrets by name or ARN, or you can use filters. If Secrets Manager encounters errors such as <code>AccessDeniedException</code> while attempting to retrieve any of the secrets, you can see the errors in <code>Errors</code> in the response.</p> |
| 46 | + * <p>Secrets Manager generates CloudTrail <code>GetSecretValue</code> log entries for each secret you request when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html">Logging Secrets Manager events with CloudTrail</a>.</p> |
| 47 | + * <p> |
| 48 | + * <b>Required permissions: </b> |
| 49 | + * <code>secretsmanager:BatchGetSecretValue</code>, and you must have <code>secretsmanager:GetSecretValue</code> for each secret. If you use filters, you must also have <code>secretsmanager:ListSecrets</code>. If the secrets are encrypted using customer-managed keys instead of the Amazon Web Services managed key |
| 50 | + * <code>aws/secretsmanager</code>, then you also need <code>kms:Decrypt</code> permissions for the keys. |
| 51 | + * For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions"> |
| 52 | + * IAM policy actions for Secrets Manager</a> and <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html">Authentication |
| 53 | + * and access control in Secrets Manager</a>. </p> |
| 54 | + * @example |
| 55 | + * Use a bare-bones client and the command you need to make an API call. |
| 56 | + * ```javascript |
| 57 | + * import { SecretsManagerClient, BatchGetSecretValueCommand } from "@aws-sdk/client-secrets-manager"; // ES Modules import |
| 58 | + * // const { SecretsManagerClient, BatchGetSecretValueCommand } = require("@aws-sdk/client-secrets-manager"); // CommonJS import |
| 59 | + * const client = new SecretsManagerClient(config); |
| 60 | + * const input = { // BatchGetSecretValueRequest |
| 61 | + * SecretIdList: [ // SecretIdListType |
| 62 | + * "STRING_VALUE", |
| 63 | + * ], |
| 64 | + * Filters: [ // FiltersListType |
| 65 | + * { // Filter |
| 66 | + * Key: "description" || "name" || "tag-key" || "tag-value" || "primary-region" || "owning-service" || "all", |
| 67 | + * Values: [ // FilterValuesStringList |
| 68 | + * "STRING_VALUE", |
| 69 | + * ], |
| 70 | + * }, |
| 71 | + * ], |
| 72 | + * MaxResults: Number("int"), |
| 73 | + * NextToken: "STRING_VALUE", |
| 74 | + * }; |
| 75 | + * const command = new BatchGetSecretValueCommand(input); |
| 76 | + * const response = await client.send(command); |
| 77 | + * // { // BatchGetSecretValueResponse |
| 78 | + * // SecretValues: [ // SecretValuesType |
| 79 | + * // { // SecretValueEntry |
| 80 | + * // ARN: "STRING_VALUE", |
| 81 | + * // Name: "STRING_VALUE", |
| 82 | + * // VersionId: "STRING_VALUE", |
| 83 | + * // SecretBinary: "BLOB_VALUE", |
| 84 | + * // SecretString: "STRING_VALUE", |
| 85 | + * // VersionStages: [ // SecretVersionStagesType |
| 86 | + * // "STRING_VALUE", |
| 87 | + * // ], |
| 88 | + * // CreatedDate: new Date("TIMESTAMP"), |
| 89 | + * // }, |
| 90 | + * // ], |
| 91 | + * // NextToken: "STRING_VALUE", |
| 92 | + * // Errors: [ // APIErrorListType |
| 93 | + * // { // APIErrorType |
| 94 | + * // SecretId: "STRING_VALUE", |
| 95 | + * // ErrorCode: "STRING_VALUE", |
| 96 | + * // Message: "STRING_VALUE", |
| 97 | + * // }, |
| 98 | + * // ], |
| 99 | + * // }; |
| 100 | + * |
| 101 | + * ``` |
| 102 | + * |
| 103 | + * @param BatchGetSecretValueCommandInput - {@link BatchGetSecretValueCommandInput} |
| 104 | + * @returns {@link BatchGetSecretValueCommandOutput} |
| 105 | + * @see {@link BatchGetSecretValueCommandInput} for command's `input` shape. |
| 106 | + * @see {@link BatchGetSecretValueCommandOutput} for command's `response` shape. |
| 107 | + * @see {@link SecretsManagerClientResolvedConfig | config} for SecretsManagerClient's `config` shape. |
| 108 | + * |
| 109 | + * @throws {@link DecryptionFailure} (client fault) |
| 110 | + * <p>Secrets Manager can't decrypt the protected secret text using the provided KMS key. </p> |
| 111 | + * |
| 112 | + * @throws {@link InternalServiceError} (server fault) |
| 113 | + * <p>An error occurred on the server side.</p> |
| 114 | + * |
| 115 | + * @throws {@link InvalidNextTokenException} (client fault) |
| 116 | + * <p>The <code>NextToken</code> value is invalid.</p> |
| 117 | + * |
| 118 | + * @throws {@link InvalidParameterException} (client fault) |
| 119 | + * <p>The parameter name or value is invalid.</p> |
| 120 | + * |
| 121 | + * @throws {@link InvalidRequestException} (client fault) |
| 122 | + * <p>A parameter value is not valid for the current state of the |
| 123 | + * resource.</p> |
| 124 | + * <p>Possible causes:</p> |
| 125 | + * <ul> |
| 126 | + * <li> |
| 127 | + * <p>The secret is scheduled for deletion.</p> |
| 128 | + * </li> |
| 129 | + * <li> |
| 130 | + * <p>You tried to enable rotation on a secret that doesn't already have a Lambda function |
| 131 | + * ARN configured and you didn't include such an ARN as a parameter in this call. </p> |
| 132 | + * </li> |
| 133 | + * <li> |
| 134 | + * <p>The secret is managed by another service, and you must use that service to update it. |
| 135 | + * For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/service-linked-secrets.html">Secrets managed by other Amazon Web Services services</a>.</p> |
| 136 | + * </li> |
| 137 | + * </ul> |
| 138 | + * |
| 139 | + * @throws {@link ResourceNotFoundException} (client fault) |
| 140 | + * <p>Secrets Manager can't find the resource that you asked for.</p> |
| 141 | + * |
| 142 | + * @throws {@link SecretsManagerServiceException} |
| 143 | + * <p>Base exception class for all service exceptions from SecretsManager service.</p> |
| 144 | + * |
| 145 | + */ |
| 146 | +export class BatchGetSecretValueCommand extends $Command< |
| 147 | + BatchGetSecretValueCommandInput, |
| 148 | + BatchGetSecretValueCommandOutput, |
| 149 | + SecretsManagerClientResolvedConfig |
| 150 | +> { |
| 151 | + public static getEndpointParameterInstructions(): EndpointParameterInstructions { |
| 152 | + return { |
| 153 | + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, |
| 154 | + Endpoint: { type: "builtInParams", name: "endpoint" }, |
| 155 | + Region: { type: "builtInParams", name: "region" }, |
| 156 | + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, |
| 157 | + }; |
| 158 | + } |
| 159 | + |
| 160 | + /** |
| 161 | + * @public |
| 162 | + */ |
| 163 | + constructor(readonly input: BatchGetSecretValueCommandInput) { |
| 164 | + super(); |
| 165 | + } |
| 166 | + |
| 167 | + /** |
| 168 | + * @internal |
| 169 | + */ |
| 170 | + resolveMiddleware( |
| 171 | + clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, |
| 172 | + configuration: SecretsManagerClientResolvedConfig, |
| 173 | + options?: __HttpHandlerOptions |
| 174 | + ): Handler<BatchGetSecretValueCommandInput, BatchGetSecretValueCommandOutput> { |
| 175 | + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); |
| 176 | + this.middlewareStack.use( |
| 177 | + getEndpointPlugin(configuration, BatchGetSecretValueCommand.getEndpointParameterInstructions()) |
| 178 | + ); |
| 179 | + |
| 180 | + const stack = clientStack.concat(this.middlewareStack); |
| 181 | + |
| 182 | + const { logger } = configuration; |
| 183 | + const clientName = "SecretsManagerClient"; |
| 184 | + const commandName = "BatchGetSecretValueCommand"; |
| 185 | + const handlerExecutionContext: HandlerExecutionContext = { |
| 186 | + logger, |
| 187 | + clientName, |
| 188 | + commandName, |
| 189 | + inputFilterSensitiveLog: (_: any) => _, |
| 190 | + outputFilterSensitiveLog: BatchGetSecretValueResponseFilterSensitiveLog, |
| 191 | + [SMITHY_CONTEXT_KEY]: { |
| 192 | + service: "secretsmanager", |
| 193 | + operation: "BatchGetSecretValue", |
| 194 | + }, |
| 195 | + }; |
| 196 | + const { requestHandler } = configuration; |
| 197 | + return stack.resolve( |
| 198 | + (request: FinalizeHandlerArguments<any>) => |
| 199 | + requestHandler.handle(request.request as __HttpRequest, options || {}), |
| 200 | + handlerExecutionContext |
| 201 | + ); |
| 202 | + } |
| 203 | + |
| 204 | + /** |
| 205 | + * @internal |
| 206 | + */ |
| 207 | + private serialize(input: BatchGetSecretValueCommandInput, context: __SerdeContext): Promise<__HttpRequest> { |
| 208 | + return se_BatchGetSecretValueCommand(input, context); |
| 209 | + } |
| 210 | + |
| 211 | + /** |
| 212 | + * @internal |
| 213 | + */ |
| 214 | + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<BatchGetSecretValueCommandOutput> { |
| 215 | + return de_BatchGetSecretValueCommand(output, context); |
| 216 | + } |
| 217 | +} |
0 commit comments