Skip to content

Commit

Permalink
feat(client-rbin): This release adds support for Rule Lock for Recycl…
Browse files Browse the repository at this point in the history
…e Bin, which allows you to lock retention rules so that they can no longer be modified or deleted.
  • Loading branch information
awstools committed Nov 23, 2022
1 parent b6cf732 commit cf212da
Show file tree
Hide file tree
Showing 11 changed files with 1,690 additions and 312 deletions.
59 changes: 58 additions & 1 deletion clients/client-rbin/src/Rbin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
} from "./commands/ListTagsForResourceCommand";
import { LockRuleCommand, LockRuleCommandInput, LockRuleCommandOutput } from "./commands/LockRuleCommand";
import { TagResourceCommand, TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import { UnlockRuleCommand, UnlockRuleCommandInput, UnlockRuleCommandOutput } from "./commands/UnlockRuleCommand";
import {
UntagResourceCommand,
UntagResourceCommandInput,
Expand Down Expand Up @@ -174,6 +176,32 @@ export class Rbin extends RbinClient {
}
}

/**
* <p>Locks a retention rule. A locked retention rule can't be modified or deleted.</p>
*/
public lockRule(args: LockRuleCommandInput, options?: __HttpHandlerOptions): Promise<LockRuleCommandOutput>;
public lockRule(args: LockRuleCommandInput, cb: (err: any, data?: LockRuleCommandOutput) => void): void;
public lockRule(
args: LockRuleCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: LockRuleCommandOutput) => void
): void;
public lockRule(
args: LockRuleCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: LockRuleCommandOutput) => void),
cb?: (err: any, data?: LockRuleCommandOutput) => void
): Promise<LockRuleCommandOutput> | void {
const command = new LockRuleCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Assigns tags to the specified retention rule.</p>
*/
Expand All @@ -200,6 +228,33 @@ export class Rbin extends RbinClient {
}
}

/**
* <p>Unlocks a retention rule. After a retention rule is unlocked, it can be modified or deleted
* only after the unlock delay period expires.</p>
*/
public unlockRule(args: UnlockRuleCommandInput, options?: __HttpHandlerOptions): Promise<UnlockRuleCommandOutput>;
public unlockRule(args: UnlockRuleCommandInput, cb: (err: any, data?: UnlockRuleCommandOutput) => void): void;
public unlockRule(
args: UnlockRuleCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: UnlockRuleCommandOutput) => void
): void;
public unlockRule(
args: UnlockRuleCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UnlockRuleCommandOutput) => void),
cb?: (err: any, data?: UnlockRuleCommandOutput) => void
): Promise<UnlockRuleCommandOutput> | void {
const command = new UnlockRuleCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Unassigns a tag from a retention rule.</p>
*/
Expand Down Expand Up @@ -233,7 +288,9 @@ export class Rbin extends RbinClient {
}

/**
* <p>Updates an existing Recycle Bin retention rule. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-update-rule">
* <p>Updates an existing Recycle Bin retention rule. You can update a retention rule's description,
* resource tags, and retention period at any time after creation. You can't update a retention rule's
* resource type after creation. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-update-rule">
* Update Recycle Bin retention rules</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
*/
public updateRule(args: UpdateRuleCommandInput, options?: __HttpHandlerOptions): Promise<UpdateRuleCommandOutput>;
Expand Down
6 changes: 6 additions & 0 deletions clients/client-rbin/src/RbinClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
} from "./commands/ListTagsForResourceCommand";
import { LockRuleCommandInput, LockRuleCommandOutput } from "./commands/LockRuleCommand";
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import { UnlockRuleCommandInput, UnlockRuleCommandOutput } from "./commands/UnlockRuleCommand";
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
import { UpdateRuleCommandInput, UpdateRuleCommandOutput } from "./commands/UpdateRuleCommand";
import {
Expand All @@ -72,7 +74,9 @@ export type ServiceInputTypes =
| GetRuleCommandInput
| ListRulesCommandInput
| ListTagsForResourceCommandInput
| LockRuleCommandInput
| TagResourceCommandInput
| UnlockRuleCommandInput
| UntagResourceCommandInput
| UpdateRuleCommandInput;

Expand All @@ -82,7 +86,9 @@ export type ServiceOutputTypes =
| GetRuleCommandOutput
| ListRulesCommandOutput
| ListTagsForResourceCommandOutput
| LockRuleCommandOutput
| TagResourceCommandOutput
| UnlockRuleCommandOutput
| UntagResourceCommandOutput
| UpdateRuleCommandOutput;

Expand Down
108 changes: 108 additions & 0 deletions clients/client-rbin/src/commands/LockRuleCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// smithy-typescript generated code
import { EndpointParameterInstructions, getEndpointPlugin } from "@aws-sdk/middleware-endpoint";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import {
LockRuleRequest,
LockRuleRequestFilterSensitiveLog,
LockRuleResponse,
LockRuleResponseFilterSensitiveLog,
} from "../models/models_0";
import {
deserializeAws_restJson1LockRuleCommand,
serializeAws_restJson1LockRuleCommand,
} from "../protocols/Aws_restJson1";
import { RbinClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RbinClient";

export interface LockRuleCommandInput extends LockRuleRequest {}
export interface LockRuleCommandOutput extends LockRuleResponse, __MetadataBearer {}

/**
* <p>Locks a retention rule. A locked retention rule can't be modified or deleted.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { RbinClient, LockRuleCommand } from "@aws-sdk/client-rbin"; // ES Modules import
* // const { RbinClient, LockRuleCommand } = require("@aws-sdk/client-rbin"); // CommonJS import
* const client = new RbinClient(config);
* const command = new LockRuleCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link LockRuleCommandInput} for command's `input` shape.
* @see {@link LockRuleCommandOutput} for command's `response` shape.
* @see {@link RbinClientResolvedConfig | config} for RbinClient's `config` shape.
*
*/
export class LockRuleCommand extends $Command<LockRuleCommandInput, LockRuleCommandOutput, RbinClientResolvedConfig> {
// Start section: command_properties
// End section: command_properties

public static getEndpointParameterInstructions(): EndpointParameterInstructions {
return {
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
Endpoint: { type: "builtInParams", name: "endpoint" },
Region: { type: "builtInParams", name: "region" },
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
};
}

constructor(readonly input: LockRuleCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: RbinClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<LockRuleCommandInput, LockRuleCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(getEndpointPlugin(configuration, LockRuleCommand.getEndpointParameterInstructions()));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "RbinClient";
const commandName = "LockRuleCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: LockRuleRequestFilterSensitiveLog,
outputFilterSensitiveLog: LockRuleResponseFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: LockRuleCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1LockRuleCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<LockRuleCommandOutput> {
return deserializeAws_restJson1LockRuleCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
113 changes: 113 additions & 0 deletions clients/client-rbin/src/commands/UnlockRuleCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// smithy-typescript generated code
import { EndpointParameterInstructions, getEndpointPlugin } from "@aws-sdk/middleware-endpoint";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import {
UnlockRuleRequest,
UnlockRuleRequestFilterSensitiveLog,
UnlockRuleResponse,
UnlockRuleResponseFilterSensitiveLog,
} from "../models/models_0";
import {
deserializeAws_restJson1UnlockRuleCommand,
serializeAws_restJson1UnlockRuleCommand,
} from "../protocols/Aws_restJson1";
import { RbinClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RbinClient";

export interface UnlockRuleCommandInput extends UnlockRuleRequest {}
export interface UnlockRuleCommandOutput extends UnlockRuleResponse, __MetadataBearer {}

/**
* <p>Unlocks a retention rule. After a retention rule is unlocked, it can be modified or deleted
* only after the unlock delay period expires.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { RbinClient, UnlockRuleCommand } from "@aws-sdk/client-rbin"; // ES Modules import
* // const { RbinClient, UnlockRuleCommand } = require("@aws-sdk/client-rbin"); // CommonJS import
* const client = new RbinClient(config);
* const command = new UnlockRuleCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link UnlockRuleCommandInput} for command's `input` shape.
* @see {@link UnlockRuleCommandOutput} for command's `response` shape.
* @see {@link RbinClientResolvedConfig | config} for RbinClient's `config` shape.
*
*/
export class UnlockRuleCommand extends $Command<
UnlockRuleCommandInput,
UnlockRuleCommandOutput,
RbinClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

public static getEndpointParameterInstructions(): EndpointParameterInstructions {
return {
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
Endpoint: { type: "builtInParams", name: "endpoint" },
Region: { type: "builtInParams", name: "region" },
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
};
}

constructor(readonly input: UnlockRuleCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: RbinClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<UnlockRuleCommandInput, UnlockRuleCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(getEndpointPlugin(configuration, UnlockRuleCommand.getEndpointParameterInstructions()));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "RbinClient";
const commandName = "UnlockRuleCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: UnlockRuleRequestFilterSensitiveLog,
outputFilterSensitiveLog: UnlockRuleResponseFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: UnlockRuleCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1UnlockRuleCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<UnlockRuleCommandOutput> {
return deserializeAws_restJson1UnlockRuleCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
4 changes: 3 additions & 1 deletion clients/client-rbin/src/commands/UpdateRuleCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export interface UpdateRuleCommandInput extends UpdateRuleRequest {}
export interface UpdateRuleCommandOutput extends UpdateRuleResponse, __MetadataBearer {}

/**
* <p>Updates an existing Recycle Bin retention rule. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-update-rule">
* <p>Updates an existing Recycle Bin retention rule. You can update a retention rule's description,
* resource tags, and retention period at any time after creation. You can't update a retention rule's
* resource type after creation. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-update-rule">
* Update Recycle Bin retention rules</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
2 changes: 2 additions & 0 deletions clients/client-rbin/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export * from "./DeleteRuleCommand";
export * from "./GetRuleCommand";
export * from "./ListRulesCommand";
export * from "./ListTagsForResourceCommand";
export * from "./LockRuleCommand";
export * from "./TagResourceCommand";
export * from "./UnlockRuleCommand";
export * from "./UntagResourceCommand";
export * from "./UpdateRuleCommand";
2 changes: 1 addition & 1 deletion clients/client-rbin/src/endpoint/EndpointParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const resolveClientEndpointParameters = <T>(
};

export interface EndpointParameters extends __EndpointParameters {
Region?: string;
Region: string;
UseDualStack?: boolean;
UseFIPS?: boolean;
Endpoint?: string;
Expand Down
2 changes: 1 addition & 1 deletion clients/client-rbin/src/endpoint/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ruleSet: RuleSetObject = {
parameters: {
Region: {
builtIn: "AWS::Region",
required: false,
required: true,
documentation: "The AWS region used to dispatch the request.",
type: "String",
},
Expand Down
Loading

0 comments on commit cf212da

Please sign in to comment.