Skip to content

Commit

Permalink
feat(client-synthetics): This release introduces Group feature, which…
Browse files Browse the repository at this point in the history
… enables users to group cross-region canaries.
  • Loading branch information
awstools committed Jul 6, 2022
1 parent 8ed0e09 commit 5e37998
Show file tree
Hide file tree
Showing 26 changed files with 3,676 additions and 275 deletions.
14 changes: 7 additions & 7 deletions clients/client-synthetics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ using your favorite package manager:

The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the `SyntheticsClient` and
the commands you need, for example `CreateCanaryCommand`:
the commands you need, for example `AssociateResourceCommand`:

```js
// ES5 example
const { SyntheticsClient, CreateCanaryCommand } = require("@aws-sdk/client-synthetics");
const { SyntheticsClient, AssociateResourceCommand } = require("@aws-sdk/client-synthetics");
```

```ts
// ES6+ example
import { SyntheticsClient, CreateCanaryCommand } from "@aws-sdk/client-synthetics";
import { SyntheticsClient, AssociateResourceCommand } from "@aws-sdk/client-synthetics";
```

### Usage
Expand All @@ -70,7 +70,7 @@ const client = new SyntheticsClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new CreateCanaryCommand(params);
const command = new AssociateResourceCommand(params);
```

#### Async/await
Expand Down Expand Up @@ -149,15 +149,15 @@ const client = new AWS.Synthetics({ region: "REGION" });

// async/await.
try {
const data = await client.createCanary(params);
const data = await client.associateResource(params);
// process data.
} catch (error) {
// error handling.
}

// Promises.
client
.createCanary(params)
.associateResource(params)
.then((data) => {
// process data.
})
Expand All @@ -166,7 +166,7 @@ client
});

// callbacks.
client.createCanary(params, (err, data) => {
client.associateResource(params, (err, data) => {
// process err and data.
});
```
Expand Down
301 changes: 290 additions & 11 deletions clients/client-synthetics/src/Synthetics.ts

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions clients/client-synthetics/src/SyntheticsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ import {
UserAgent as __UserAgent,
} from "@aws-sdk/types";

import { AssociateResourceCommandInput, AssociateResourceCommandOutput } from "./commands/AssociateResourceCommand";
import { CreateCanaryCommandInput, CreateCanaryCommandOutput } from "./commands/CreateCanaryCommand";
import { CreateGroupCommandInput, CreateGroupCommandOutput } from "./commands/CreateGroupCommand";
import { DeleteCanaryCommandInput, DeleteCanaryCommandOutput } from "./commands/DeleteCanaryCommand";
import { DeleteGroupCommandInput, DeleteGroupCommandOutput } from "./commands/DeleteGroupCommand";
import { DescribeCanariesCommandInput, DescribeCanariesCommandOutput } from "./commands/DescribeCanariesCommand";
import {
DescribeCanariesLastRunCommandInput,
Expand All @@ -64,8 +67,19 @@ import {
DescribeRuntimeVersionsCommandInput,
DescribeRuntimeVersionsCommandOutput,
} from "./commands/DescribeRuntimeVersionsCommand";
import {
DisassociateResourceCommandInput,
DisassociateResourceCommandOutput,
} from "./commands/DisassociateResourceCommand";
import { GetCanaryCommandInput, GetCanaryCommandOutput } from "./commands/GetCanaryCommand";
import { GetCanaryRunsCommandInput, GetCanaryRunsCommandOutput } from "./commands/GetCanaryRunsCommand";
import { GetGroupCommandInput, GetGroupCommandOutput } from "./commands/GetGroupCommand";
import {
ListAssociatedGroupsCommandInput,
ListAssociatedGroupsCommandOutput,
} from "./commands/ListAssociatedGroupsCommand";
import { ListGroupResourcesCommandInput, ListGroupResourcesCommandOutput } from "./commands/ListGroupResourcesCommand";
import { ListGroupsCommandInput, ListGroupsCommandOutput } from "./commands/ListGroupsCommand";
import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
Expand All @@ -78,13 +92,21 @@ import { UpdateCanaryCommandInput, UpdateCanaryCommandOutput } from "./commands/
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";

export type ServiceInputTypes =
| AssociateResourceCommandInput
| CreateCanaryCommandInput
| CreateGroupCommandInput
| DeleteCanaryCommandInput
| DeleteGroupCommandInput
| DescribeCanariesCommandInput
| DescribeCanariesLastRunCommandInput
| DescribeRuntimeVersionsCommandInput
| DisassociateResourceCommandInput
| GetCanaryCommandInput
| GetCanaryRunsCommandInput
| GetGroupCommandInput
| ListAssociatedGroupsCommandInput
| ListGroupResourcesCommandInput
| ListGroupsCommandInput
| ListTagsForResourceCommandInput
| StartCanaryCommandInput
| StopCanaryCommandInput
Expand All @@ -93,13 +115,21 @@ export type ServiceInputTypes =
| UpdateCanaryCommandInput;

export type ServiceOutputTypes =
| AssociateResourceCommandOutput
| CreateCanaryCommandOutput
| CreateGroupCommandOutput
| DeleteCanaryCommandOutput
| DeleteGroupCommandOutput
| DescribeCanariesCommandOutput
| DescribeCanariesLastRunCommandOutput
| DescribeRuntimeVersionsCommandOutput
| DisassociateResourceCommandOutput
| GetCanaryCommandOutput
| GetCanaryRunsCommandOutput
| GetGroupCommandOutput
| ListAssociatedGroupsCommandOutput
| ListGroupResourcesCommandOutput
| ListGroupsCommandOutput
| ListTagsForResourceCommandOutput
| StartCanaryCommandOutput
| StopCanaryCommandOutput
Expand Down
99 changes: 99 additions & 0 deletions clients/client-synthetics/src/commands/AssociateResourceCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// 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 { AssociateResourceRequest, AssociateResourceResponse } from "../models/models_0";
import {
deserializeAws_restJson1AssociateResourceCommand,
serializeAws_restJson1AssociateResourceCommand,
} from "../protocols/Aws_restJson1";
import { ServiceInputTypes, ServiceOutputTypes, SyntheticsClientResolvedConfig } from "../SyntheticsClient";

export interface AssociateResourceCommandInput extends AssociateResourceRequest {}
export interface AssociateResourceCommandOutput extends AssociateResourceResponse, __MetadataBearer {}

/**
* <p>Associates a canary with a group. Using groups can help you with
* managing and automating your canaries, and you can also view aggregated run results and statistics
* for all canaries in a group. </p>
* <p>You must run this operation in the Region where the canary exists.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { SyntheticsClient, AssociateResourceCommand } from "@aws-sdk/client-synthetics"; // ES Modules import
* // const { SyntheticsClient, AssociateResourceCommand } = require("@aws-sdk/client-synthetics"); // CommonJS import
* const client = new SyntheticsClient(config);
* const command = new AssociateResourceCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link AssociateResourceCommandInput} for command's `input` shape.
* @see {@link AssociateResourceCommandOutput} for command's `response` shape.
* @see {@link SyntheticsClientResolvedConfig | config} for SyntheticsClient's `config` shape.
*
*/
export class AssociateResourceCommand extends $Command<
AssociateResourceCommandInput,
AssociateResourceCommandOutput,
SyntheticsClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

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

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface CreateCanaryCommandOutput extends CreateCanaryResponse, __Metad
* <p>Do not use <code>CreateCanary</code> to modify an existing canary. Use <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_UpdateCanary.html">UpdateCanary</a> instead.</p>
* <p>To create canaries, you must have the <code>CloudWatchSyntheticsFullAccess</code> policy.
* If you are creating a new IAM role for the canary, you also need the
* the <code>iam:CreateRole</code>, <code>iam:CreatePolicy</code> and
* <code>iam:CreateRole</code>, <code>iam:CreatePolicy</code> and
* <code>iam:AttachRolePolicy</code> permissions. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Roles">Necessary
* Roles and Permissions</a>.</p>
* <p>Do not include secrets or proprietary information in your canary names. The canary name
Expand Down
108 changes: 108 additions & 0 deletions clients/client-synthetics/src/commands/CreateGroupCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// 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 { CreateGroupRequest, CreateGroupResponse } from "../models/models_0";
import {
deserializeAws_restJson1CreateGroupCommand,
serializeAws_restJson1CreateGroupCommand,
} from "../protocols/Aws_restJson1";
import { ServiceInputTypes, ServiceOutputTypes, SyntheticsClientResolvedConfig } from "../SyntheticsClient";

export interface CreateGroupCommandInput extends CreateGroupRequest {}
export interface CreateGroupCommandOutput extends CreateGroupResponse, __MetadataBearer {}

/**
* <p>Creates a group which you can use to associate canaries with each other, including cross-Region
* canaries. Using groups can help you with
* managing and automating your canaries, and you can also view aggregated run results and statistics
* for all canaries in a group. </p>
* <p>Groups are global resources. When you create a group, it is replicated across Amazon Web Services Regions, and
* you can view it and add canaries to it from any Region.
* Although the group ARN format reflects the Region name where it was created, a group is not constrained to any Region.
* This means that you can put canaries from multiple Regions into the same group, and then use
* that group to view and manage all of those canaries in a single view.</p>
* <p>Groups are supported in all Regions except the Regions that are disabled by default. For more information
* about these Regions, see <a href="https://docs.aws.amazon.com/general/latest/gr/rande-manage.html#rande-manage-enable">Enabling a Region</a>.</p>
* <p>Each group can contain as many as 10 canaries. You can have as many as 20 groups in your account. Any single canary
* can be a member of up to 10 groups.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { SyntheticsClient, CreateGroupCommand } from "@aws-sdk/client-synthetics"; // ES Modules import
* // const { SyntheticsClient, CreateGroupCommand } = require("@aws-sdk/client-synthetics"); // CommonJS import
* const client = new SyntheticsClient(config);
* const command = new CreateGroupCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link CreateGroupCommandInput} for command's `input` shape.
* @see {@link CreateGroupCommandOutput} for command's `response` shape.
* @see {@link SyntheticsClientResolvedConfig | config} for SyntheticsClient's `config` shape.
*
*/
export class CreateGroupCommand extends $Command<
CreateGroupCommandInput,
CreateGroupCommandOutput,
SyntheticsClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

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

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface DeleteCanaryCommandOutput extends DeleteCanaryResponse, __Metad
* <p>Permanently deletes the specified canary.</p>
* <p>If you specify <code>DeleteLambda</code> to <code>true</code>, CloudWatch Synthetics also deletes
* the Lambda functions and layers that are used by the canary.</p>
* <p>Other esources used and created by the canary are not automatically deleted.
* <p>Other resources used and created by the canary are not automatically deleted.
* After you delete a canary that you do not intend to
* use again, you
* should also delete the following:</p>
Expand Down
Loading

0 comments on commit 5e37998

Please sign in to comment.