Skip to content

Commit

Permalink
feat(client-database-migration-service): New api to migrate event sub…
Browse files Browse the repository at this point in the history
…scriptions to event bridge rules
  • Loading branch information
awstools committed Jul 7, 2022
1 parent 0dd0bdd commit 6ed4f9b
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ import {
TestConnectionCommandInput,
TestConnectionCommandOutput,
} from "./commands/TestConnectionCommand";
import {
UpdateSubscriptionsToEventBridgeCommand,
UpdateSubscriptionsToEventBridgeCommandInput,
UpdateSubscriptionsToEventBridgeCommandOutput,
} from "./commands/UpdateSubscriptionsToEventBridgeCommand";
import { DatabaseMigrationServiceClient } from "./DatabaseMigrationServiceClient";

/**
Expand Down Expand Up @@ -2558,4 +2563,44 @@ export class DatabaseMigrationService extends DatabaseMigrationServiceClient {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Migrates 10 active and enabled Amazon SNS subscriptions at a time and converts them to corresponding Amazon EventBridge rules.
* By default, this operation migrates subscriptions only when all your replication instance versions are 3.4.6 or higher.
* If any replication instances are from versions earlier than 3.4.6, the operation raises an error and tells you
* to upgrade these instances to version 3.4.6 or higher. To enable migration regardless of version, set the <code>Force</code>
* option to true. However, if you don't upgrade instances earlier than version 3.4.6, some types of events might not be
* available when you use Amazon EventBridge.</p>
* <p>To call this operation, make sure that you have certain permissions added to your user account.
* For more information, see <a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Events.html#CHAP_Events-migrate-to-eventbridge">Migrating event subscriptions to Amazon EventBridge</a>
* in the <i>Amazon Web Services Database Migration Service User Guide</i>.</p>
*/
public updateSubscriptionsToEventBridge(
args: UpdateSubscriptionsToEventBridgeCommandInput,
options?: __HttpHandlerOptions
): Promise<UpdateSubscriptionsToEventBridgeCommandOutput>;
public updateSubscriptionsToEventBridge(
args: UpdateSubscriptionsToEventBridgeCommandInput,
cb: (err: any, data?: UpdateSubscriptionsToEventBridgeCommandOutput) => void
): void;
public updateSubscriptionsToEventBridge(
args: UpdateSubscriptionsToEventBridgeCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: UpdateSubscriptionsToEventBridgeCommandOutput) => void
): void;
public updateSubscriptionsToEventBridge(
args: UpdateSubscriptionsToEventBridgeCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UpdateSubscriptionsToEventBridgeCommandOutput) => void),
cb?: (err: any, data?: UpdateSubscriptionsToEventBridgeCommandOutput) => void
): Promise<UpdateSubscriptionsToEventBridgeCommandOutput> | void {
const command = new UpdateSubscriptionsToEventBridgeCommand(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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ import {
StopReplicationTaskCommandOutput,
} from "./commands/StopReplicationTaskCommand";
import { TestConnectionCommandInput, TestConnectionCommandOutput } from "./commands/TestConnectionCommand";
import {
UpdateSubscriptionsToEventBridgeCommandInput,
UpdateSubscriptionsToEventBridgeCommandOutput,
} from "./commands/UpdateSubscriptionsToEventBridgeCommand";
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";

export type ServiceInputTypes =
Expand Down Expand Up @@ -336,7 +340,8 @@ export type ServiceInputTypes =
| StartReplicationTaskAssessmentRunCommandInput
| StartReplicationTaskCommandInput
| StopReplicationTaskCommandInput
| TestConnectionCommandInput;
| TestConnectionCommandInput
| UpdateSubscriptionsToEventBridgeCommandInput;

export type ServiceOutputTypes =
| AddTagsToResourceCommandOutput
Expand Down Expand Up @@ -402,7 +407,8 @@ export type ServiceOutputTypes =
| StartReplicationTaskAssessmentRunCommandOutput
| StartReplicationTaskCommandOutput
| StopReplicationTaskCommandOutput
| TestConnectionCommandOutput;
| TestConnectionCommandOutput
| UpdateSubscriptionsToEventBridgeCommandOutput;

export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// smithy-typescript generated code
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 {
DatabaseMigrationServiceClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes,
} from "../DatabaseMigrationServiceClient";
import { UpdateSubscriptionsToEventBridgeMessage, UpdateSubscriptionsToEventBridgeResponse } from "../models/models_0";
import {
deserializeAws_json1_1UpdateSubscriptionsToEventBridgeCommand,
serializeAws_json1_1UpdateSubscriptionsToEventBridgeCommand,
} from "../protocols/Aws_json1_1";

export interface UpdateSubscriptionsToEventBridgeCommandInput extends UpdateSubscriptionsToEventBridgeMessage {}
export interface UpdateSubscriptionsToEventBridgeCommandOutput
extends UpdateSubscriptionsToEventBridgeResponse,
__MetadataBearer {}

/**
* <p>Migrates 10 active and enabled Amazon SNS subscriptions at a time and converts them to corresponding Amazon EventBridge rules.
* By default, this operation migrates subscriptions only when all your replication instance versions are 3.4.6 or higher.
* If any replication instances are from versions earlier than 3.4.6, the operation raises an error and tells you
* to upgrade these instances to version 3.4.6 or higher. To enable migration regardless of version, set the <code>Force</code>
* option to true. However, if you don't upgrade instances earlier than version 3.4.6, some types of events might not be
* available when you use Amazon EventBridge.</p>
* <p>To call this operation, make sure that you have certain permissions added to your user account.
* For more information, see <a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Events.html#CHAP_Events-migrate-to-eventbridge">Migrating event subscriptions to Amazon EventBridge</a>
* in the <i>Amazon Web Services Database Migration Service User Guide</i>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { DatabaseMigrationServiceClient, UpdateSubscriptionsToEventBridgeCommand } from "@aws-sdk/client-database-migration-service"; // ES Modules import
* // const { DatabaseMigrationServiceClient, UpdateSubscriptionsToEventBridgeCommand } = require("@aws-sdk/client-database-migration-service"); // CommonJS import
* const client = new DatabaseMigrationServiceClient(config);
* const command = new UpdateSubscriptionsToEventBridgeCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link UpdateSubscriptionsToEventBridgeCommandInput} for command's `input` shape.
* @see {@link UpdateSubscriptionsToEventBridgeCommandOutput} for command's `response` shape.
* @see {@link DatabaseMigrationServiceClientResolvedConfig | config} for DatabaseMigrationServiceClient's `config` shape.
*
*/
export class UpdateSubscriptionsToEventBridgeCommand extends $Command<
UpdateSubscriptionsToEventBridgeCommandInput,
UpdateSubscriptionsToEventBridgeCommandOutput,
DatabaseMigrationServiceClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: DatabaseMigrationServiceClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<UpdateSubscriptionsToEventBridgeCommandInput, UpdateSubscriptionsToEventBridgeCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

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

const { logger } = configuration;
const clientName = "DatabaseMigrationServiceClient";
const commandName = "UpdateSubscriptionsToEventBridgeCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: UpdateSubscriptionsToEventBridgeMessage.filterSensitiveLog,
outputFilterSensitiveLog: UpdateSubscriptionsToEventBridgeResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ export * from "./StartReplicationTaskAssessmentRunCommand";
export * from "./StartReplicationTaskCommand";
export * from "./StopReplicationTaskCommand";
export * from "./TestConnectionCommand";
export * from "./UpdateSubscriptionsToEventBridgeCommand";
42 changes: 42 additions & 0 deletions clients/client-database-migration-service/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10443,3 +10443,45 @@ export namespace TestConnectionResponse {
...obj,
});
}

/**
* <p></p>
*/
export interface UpdateSubscriptionsToEventBridgeMessage {
/**
* <p>When set to true, this operation migrates DMS subscriptions for Amazon SNS
* notifications no matter what your replication instance version is. If not set or set to
* false, this operation runs only when all your replication instances are from DMS
* version 3.4.6 or higher.
* </p>
*/
ForceMove?: boolean;
}

export namespace UpdateSubscriptionsToEventBridgeMessage {
/**
* @internal
*/
export const filterSensitiveLog = (obj: UpdateSubscriptionsToEventBridgeMessage): any => ({
...obj,
});
}

/**
* <p></p>
*/
export interface UpdateSubscriptionsToEventBridgeResponse {
/**
* <p>A string that indicates how many event subscriptions were migrated and how many remain to be migrated.</p>
*/
Result?: string;
}

export namespace UpdateSubscriptionsToEventBridgeResponse {
/**
* @internal
*/
export const filterSensitiveLog = (obj: UpdateSubscriptionsToEventBridgeResponse): any => ({
...obj,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ import {
StopReplicationTaskCommandOutput,
} from "../commands/StopReplicationTaskCommand";
import { TestConnectionCommandInput, TestConnectionCommandOutput } from "../commands/TestConnectionCommand";
import {
UpdateSubscriptionsToEventBridgeCommandInput,
UpdateSubscriptionsToEventBridgeCommandOutput,
} from "../commands/UpdateSubscriptionsToEventBridgeCommand";
import { DatabaseMigrationServiceServiceException as __BaseException } from "../models/DatabaseMigrationServiceServiceException";
import {
AccessDeniedFault,
Expand Down Expand Up @@ -446,6 +450,8 @@ import {
Tag,
TestConnectionMessage,
TestConnectionResponse,
UpdateSubscriptionsToEventBridgeMessage,
UpdateSubscriptionsToEventBridgeResponse,
UpgradeDependencyFailureFault,
VpcSecurityGroupMembership,
} from "../models/models_0";
Expand Down Expand Up @@ -1281,6 +1287,19 @@ export const serializeAws_json1_1TestConnectionCommand = async (
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

export const serializeAws_json1_1UpdateSubscriptionsToEventBridgeCommand = async (
input: UpdateSubscriptionsToEventBridgeCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: __HeaderBag = {
"content-type": "application/x-amz-json-1.1",
"x-amz-target": "AmazonDMSv20160101.UpdateSubscriptionsToEventBridge",
};
let body: any;
body = JSON.stringify(serializeAws_json1_1UpdateSubscriptionsToEventBridgeMessage(input, context));
return buildHttpRpcRequest(context, headers, "/", undefined, body);
};

export const deserializeAws_json1_1AddTagsToResourceCommand = async (
output: __HttpResponse,
context: __SerdeContext
Expand Down Expand Up @@ -4421,6 +4440,53 @@ const deserializeAws_json1_1TestConnectionCommandError = async (
}
};

export const deserializeAws_json1_1UpdateSubscriptionsToEventBridgeCommand = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<UpdateSubscriptionsToEventBridgeCommandOutput> => {
if (output.statusCode >= 300) {
return deserializeAws_json1_1UpdateSubscriptionsToEventBridgeCommandError(output, context);
}
const data: any = await parseBody(output.body, context);
let contents: any = {};
contents = deserializeAws_json1_1UpdateSubscriptionsToEventBridgeResponse(data, context);
const response: UpdateSubscriptionsToEventBridgeCommandOutput = {
$metadata: deserializeMetadata(output),
...contents,
};
return Promise.resolve(response);
};

const deserializeAws_json1_1UpdateSubscriptionsToEventBridgeCommandError = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<UpdateSubscriptionsToEventBridgeCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
};
let response: __BaseException;
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "AccessDeniedFault":
case "com.amazonaws.databasemigrationservice#AccessDeniedFault":
throw await deserializeAws_json1_1AccessDeniedFaultResponse(parsedOutput, context);
case "InvalidResourceStateFault":
case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault":
throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
const $metadata = deserializeMetadata(output);
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
response = new __BaseException({
name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
$fault: "client",
$metadata,
});
throw __decorateServiceException(response, parsedBody);
}
};

const deserializeAws_json1_1AccessDeniedFaultResponse = async (
parsedOutput: any,
context: __SerdeContext
Expand Down Expand Up @@ -6463,6 +6529,15 @@ const serializeAws_json1_1TestConnectionMessage = (input: TestConnectionMessage,
};
};

const serializeAws_json1_1UpdateSubscriptionsToEventBridgeMessage = (
input: UpdateSubscriptionsToEventBridgeMessage,
context: __SerdeContext
): any => {
return {
...(input.ForceMove !== undefined && input.ForceMove !== null && { ForceMove: input.ForceMove }),
};
};

const serializeAws_json1_1VpcSecurityGroupIdList = (input: string[], context: __SerdeContext): any => {
return input
.filter((e: any) => e != null)
Expand Down Expand Up @@ -8988,6 +9063,15 @@ const deserializeAws_json1_1TestConnectionResponse = (output: any, context: __Se
} as any;
};

const deserializeAws_json1_1UpdateSubscriptionsToEventBridgeResponse = (
output: any,
context: __SerdeContext
): UpdateSubscriptionsToEventBridgeResponse => {
return {
Result: __expectString(output.Result),
} as any;
};

const deserializeAws_json1_1UpgradeDependencyFailureFault = (
output: any,
context: __SerdeContext
Expand Down
Loading

0 comments on commit 6ed4f9b

Please sign in to comment.