Skip to content

Commit

Permalink
feat(client-wafv2): You can now delete an API key that you've created…
Browse files Browse the repository at this point in the history
… for use with your CAPTCHA JavaScript integration API.
  • Loading branch information
awstools committed Feb 6, 2024
1 parent 93b5aca commit 900da98
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 6 deletions.
8 changes: 8 additions & 0 deletions clients/client-wafv2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ CreateWebACL

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/wafv2/command/CreateWebACLCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-wafv2/Interface/CreateWebACLCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-wafv2/Interface/CreateWebACLCommandOutput/)

</details>
<details>
<summary>
DeleteAPIKey
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/wafv2/command/DeleteAPIKeyCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-wafv2/Interface/DeleteAPIKeyCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-wafv2/Interface/DeleteAPIKeyCommandOutput/)

</details>
<details>
<summary>
Expand Down
17 changes: 17 additions & 0 deletions clients/client-wafv2/src/WAFV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ import {
CreateWebACLCommandInput,
CreateWebACLCommandOutput,
} from "./commands/CreateWebACLCommand";
import {
DeleteAPIKeyCommand,
DeleteAPIKeyCommandInput,
DeleteAPIKeyCommandOutput,
} from "./commands/DeleteAPIKeyCommand";
import {
DeleteFirewallManagerRuleGroupsCommand,
DeleteFirewallManagerRuleGroupsCommandInput,
Expand Down Expand Up @@ -241,6 +246,7 @@ const commands = {
CreateRegexPatternSetCommand,
CreateRuleGroupCommand,
CreateWebACLCommand,
DeleteAPIKeyCommand,
DeleteFirewallManagerRuleGroupsCommand,
DeleteIPSetCommand,
DeleteLoggingConfigurationCommand,
Expand Down Expand Up @@ -379,6 +385,17 @@ export interface WAFV2 {
cb: (err: any, data?: CreateWebACLCommandOutput) => void
): void;

/**
* @see {@link DeleteAPIKeyCommand}
*/
deleteAPIKey(args: DeleteAPIKeyCommandInput, options?: __HttpHandlerOptions): Promise<DeleteAPIKeyCommandOutput>;
deleteAPIKey(args: DeleteAPIKeyCommandInput, cb: (err: any, data?: DeleteAPIKeyCommandOutput) => void): void;
deleteAPIKey(
args: DeleteAPIKeyCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: DeleteAPIKeyCommandOutput) => void
): void;

/**
* @see {@link DeleteFirewallManagerRuleGroupsCommand}
*/
Expand Down
3 changes: 3 additions & 0 deletions clients/client-wafv2/src/WAFV2Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
} from "./commands/CreateRegexPatternSetCommand";
import { CreateRuleGroupCommandInput, CreateRuleGroupCommandOutput } from "./commands/CreateRuleGroupCommand";
import { CreateWebACLCommandInput, CreateWebACLCommandOutput } from "./commands/CreateWebACLCommand";
import { DeleteAPIKeyCommandInput, DeleteAPIKeyCommandOutput } from "./commands/DeleteAPIKeyCommand";
import {
DeleteFirewallManagerRuleGroupsCommandInput,
DeleteFirewallManagerRuleGroupsCommandOutput,
Expand Down Expand Up @@ -204,6 +205,7 @@ export type ServiceInputTypes =
| CreateRegexPatternSetCommandInput
| CreateRuleGroupCommandInput
| CreateWebACLCommandInput
| DeleteAPIKeyCommandInput
| DeleteFirewallManagerRuleGroupsCommandInput
| DeleteIPSetCommandInput
| DeleteLoggingConfigurationCommandInput
Expand Down Expand Up @@ -262,6 +264,7 @@ export type ServiceOutputTypes =
| CreateRegexPatternSetCommandOutput
| CreateRuleGroupCommandOutput
| CreateWebACLCommandOutput
| DeleteAPIKeyCommandOutput
| DeleteFirewallManagerRuleGroupsCommandOutput
| DeleteIPSetCommandOutput
| DeleteLoggingConfigurationCommandOutput
Expand Down
120 changes: 120 additions & 0 deletions clients/client-wafv2/src/commands/DeleteAPIKeyCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { commonParams } from "../endpoint/EndpointParameters";
import { DeleteAPIKeyRequest, DeleteAPIKeyResponse } from "../models/models_0";
import { de_DeleteAPIKeyCommand, se_DeleteAPIKeyCommand } from "../protocols/Aws_json1_1";
import { ServiceInputTypes, ServiceOutputTypes, WAFV2ClientResolvedConfig } from "../WAFV2Client";

/**
* @public
*/
export { __MetadataBearer, $Command };
/**
* @public
*
* The input for {@link DeleteAPIKeyCommand}.
*/
export interface DeleteAPIKeyCommandInput extends DeleteAPIKeyRequest {}
/**
* @public
*
* The output of {@link DeleteAPIKeyCommand}.
*/
export interface DeleteAPIKeyCommandOutput extends DeleteAPIKeyResponse, __MetadataBearer {}

/**
* @public
* <p>Deletes the specified API key. </p>
* <p>After you delete a key, it can take up to 24 hours for WAF to disallow use of the key in all regions. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { WAFV2Client, DeleteAPIKeyCommand } from "@aws-sdk/client-wafv2"; // ES Modules import
* // const { WAFV2Client, DeleteAPIKeyCommand } = require("@aws-sdk/client-wafv2"); // CommonJS import
* const client = new WAFV2Client(config);
* const input = { // DeleteAPIKeyRequest
* Scope: "CLOUDFRONT" || "REGIONAL", // required
* APIKey: "STRING_VALUE", // required
* };
* const command = new DeleteAPIKeyCommand(input);
* const response = await client.send(command);
* // {};
*
* ```
*
* @param DeleteAPIKeyCommandInput - {@link DeleteAPIKeyCommandInput}
* @returns {@link DeleteAPIKeyCommandOutput}
* @see {@link DeleteAPIKeyCommandInput} for command's `input` shape.
* @see {@link DeleteAPIKeyCommandOutput} for command's `response` shape.
* @see {@link WAFV2ClientResolvedConfig | config} for WAFV2Client's `config` shape.
*
* @throws {@link WAFInternalErrorException} (server fault)
* <p>Your request is valid, but WAF couldn’t perform the operation because of a system
* problem. Retry your request. </p>
*
* @throws {@link WAFInvalidOperationException} (client fault)
* <p>The operation isn't valid. </p>
*
* @throws {@link WAFInvalidParameterException} (client fault)
* <p>The operation failed because WAF didn't recognize a parameter in the request. For
* example: </p>
* <ul>
* <li>
* <p>You specified a parameter name or value that isn't valid.</p>
* </li>
* <li>
* <p>Your nested statement isn't valid. You might have tried to nest a statement that
* can’t be nested. </p>
* </li>
* <li>
* <p>You tried to update a <code>WebACL</code> with a <code>DefaultAction</code> that
* isn't among the types available at <a>DefaultAction</a>.</p>
* </li>
* <li>
* <p>Your request references an ARN that is malformed, or corresponds to a resource
* with which a web ACL can't be associated.</p>
* </li>
* </ul>
*
* @throws {@link WAFNonexistentItemException} (client fault)
* <p>WAF couldn’t perform the operation because your resource doesn't exist.
* If you've just created a resource that you're using in this operation, you might
* just need to wait a few minutes. It can take from a few seconds to a number of minutes
* for changes to propagate. </p>
*
* @throws {@link WAFOptimisticLockException} (client fault)
* <p>WAF couldn’t save your changes because you tried to update or delete a resource
* that has changed since you last retrieved it. Get the resource again, make any changes you
* need to make to the new copy, and retry your operation. </p>
*
* @throws {@link WAFV2ServiceException}
* <p>Base exception class for all service exceptions from WAFV2 service.</p>
*
*/
export class DeleteAPIKeyCommand extends $Command
.classBuilder<
DeleteAPIKeyCommandInput,
DeleteAPIKeyCommandOutput,
WAFV2ClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep({
...commonParams,
})
.m(function (this: any, Command: any, cs: any, config: WAFV2ClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("AWSWAF_20190729", "DeleteAPIKey", {})
.n("WAFV2Client", "DeleteAPIKeyCommand")
.f(void 0, void 0)
.ser(se_DeleteAPIKeyCommand)
.de(de_DeleteAPIKeyCommand)
.build() {}
1 change: 1 addition & 0 deletions clients/client-wafv2/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from "./CreateIPSetCommand";
export * from "./CreateRegexPatternSetCommand";
export * from "./CreateRuleGroupCommand";
export * from "./CreateWebACLCommand";
export * from "./DeleteAPIKeyCommand";
export * from "./DeleteFirewallManagerRuleGroupsCommand";
export * from "./DeleteIPSetCommand";
export * from "./DeleteLoggingConfigurationCommand";
Expand Down
37 changes: 34 additions & 3 deletions clients/client-wafv2/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,7 @@ export interface CreateAPIKeyRequest {
* <p>The client application domains that you want to use this API key for. </p>
* <p>Example JSON: <code>"TokenDomains": ["abc.com", "store.abc.com"]</code>
* </p>
* <p>Public suffixes aren't allowed. For example, you can't use <code>usa.gov</code> or <code>co.uk</code> as token domains.</p>
* <p>Public suffixes aren't allowed. For example, you can't use <code>gov.au</code> or <code>co.uk</code> as token domains.</p>
*/
TokenDomains: string[] | undefined;
}
Expand Down Expand Up @@ -4167,6 +4167,37 @@ export class WAFConfigurationWarningException extends __BaseException {
}
}

/**
* @public
*/
export interface DeleteAPIKeyRequest {
/**
* @public
* <p>Specifies whether this is for an Amazon CloudFront distribution or for a regional application. A regional application can be an Application Load Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API, an Amazon Cognito user pool, an App Runner service, or an Amazon Web Services Verified Access instance. </p>
* <p>To work with CloudFront, you must also specify the Region US East (N. Virginia) as follows: </p>
* <ul>
* <li>
* <p>CLI - Specify the Region when you use the CloudFront scope: <code>--scope=CLOUDFRONT --region=us-east-1</code>. </p>
* </li>
* <li>
* <p>API and SDKs - For all calls, use the Region endpoint us-east-1. </p>
* </li>
* </ul>
*/
Scope: Scope | undefined;

/**
* @public
* <p>The encrypted API key that you want to delete. </p>
*/
APIKey: string | undefined;
}

/**
* @public
*/
export interface DeleteAPIKeyResponse {}

/**
* @public
*/
Expand Down Expand Up @@ -8319,7 +8350,7 @@ export interface CreateWebACLRequest {
* <p>Specifies the domains that WAF should accept in a web request token. This enables the use of tokens across multiple protected websites. When WAF provides a token, it uses the domain of the Amazon Web Services resource that the web ACL is protecting. If you don't specify a list of token domains, WAF accepts tokens only for the domain of the protected resource. With a token domain list, WAF accepts the resource's host domain plus all domains in the token domain list, including their prefixed subdomains.</p>
* <p>Example JSON: <code>"TokenDomains": \{ "mywebsite.com", "myotherwebsite.com" \}</code>
* </p>
* <p>Public suffixes aren't allowed. For example, you can't use <code>usa.gov</code> or <code>co.uk</code> as token domains.</p>
* <p>Public suffixes aren't allowed. For example, you can't use <code>gov.au</code> or <code>co.uk</code> as token domains.</p>
*/
TokenDomains?: string[];

Expand Down Expand Up @@ -8602,7 +8633,7 @@ export interface UpdateWebACLRequest {
* <p>Specifies the domains that WAF should accept in a web request token. This enables the use of tokens across multiple protected websites. When WAF provides a token, it uses the domain of the Amazon Web Services resource that the web ACL is protecting. If you don't specify a list of token domains, WAF accepts tokens only for the domain of the protected resource. With a token domain list, WAF accepts the resource's host domain plus all domains in the token domain list, including their prefixed subdomains.</p>
* <p>Example JSON: <code>"TokenDomains": \{ "mywebsite.com", "myotherwebsite.com" \}</code>
* </p>
* <p>Public suffixes aren't allowed. For example, you can't use <code>usa.gov</code> or <code>co.uk</code> as token domains.</p>
* <p>Public suffixes aren't allowed. For example, you can't use <code>gov.au</code> or <code>co.uk</code> as token domains.</p>
*/
TokenDomains?: string[];

Expand Down
39 changes: 39 additions & 0 deletions clients/client-wafv2/src/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from "../commands/CreateRegexPatternSetCommand";
import { CreateRuleGroupCommandInput, CreateRuleGroupCommandOutput } from "../commands/CreateRuleGroupCommand";
import { CreateWebACLCommandInput, CreateWebACLCommandOutput } from "../commands/CreateWebACLCommand";
import { DeleteAPIKeyCommandInput, DeleteAPIKeyCommandOutput } from "../commands/DeleteAPIKeyCommand";
import {
DeleteFirewallManagerRuleGroupsCommandInput,
DeleteFirewallManagerRuleGroupsCommandOutput,
Expand Down Expand Up @@ -192,6 +193,7 @@ import {
CustomResponse,
CustomResponseBody,
DefaultAction,
DeleteAPIKeyRequest,
DeleteFirewallManagerRuleGroupsRequest,
DeleteIPSetRequest,
DeleteLoggingConfigurationRequest,
Expand Down Expand Up @@ -441,6 +443,19 @@ export const se_CreateWebACLCommand = async (
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

/**
* serializeAws_json1_1DeleteAPIKeyCommand
*/
export const se_DeleteAPIKeyCommand = async (
input: DeleteAPIKeyCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: __HeaderBag = sharedHeaders("DeleteAPIKey");
let body: any;
body = JSON.stringify(_json(input));
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

/**
* serializeAws_json1_1DeleteFirewallManagerRuleGroupsCommand
*/
Expand Down Expand Up @@ -1179,6 +1194,26 @@ export const de_CreateWebACLCommand = async (
return response;
};

/**
* deserializeAws_json1_1DeleteAPIKeyCommand
*/
export const de_DeleteAPIKeyCommand = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<DeleteAPIKeyCommandOutput> => {
if (output.statusCode >= 300) {
return de_CommandError(output, context);
}
const data: any = await parseBody(output.body, context);
let contents: any = {};
contents = _json(data);
const response: DeleteAPIKeyCommandOutput = {
$metadata: deserializeMetadata(output),
...contents,
};
return response;
};

/**
* deserializeAws_json1_1DeleteFirewallManagerRuleGroupsCommand
*/
Expand Down Expand Up @@ -2617,6 +2652,8 @@ const se_CreateWebACLRequest = (input: CreateWebACLRequest, context: __SerdeCont

// se_DefaultAction omitted.

// se_DeleteAPIKeyRequest omitted.

// se_DeleteFirewallManagerRuleGroupsRequest omitted.

// se_DeleteIPSetRequest omitted.
Expand Down Expand Up @@ -3187,6 +3224,8 @@ const de_ByteMatchStatement = (output: any, context: __SerdeContext): ByteMatchS

// de_DefaultAction omitted.

// de_DeleteAPIKeyResponse omitted.

// de_DeleteFirewallManagerRuleGroupsResponse omitted.

// de_DeleteIPSetResponse omitted.
Expand Down
Loading

0 comments on commit 900da98

Please sign in to comment.