Skip to content

Commit

Permalink
feat(client-grafana): This release adds tagging support to the Manage…
Browse files Browse the repository at this point in the history
…d Grafana service. New APIs: TagResource, UntagResource and ListTagsForResource. Updates: add optional field tags to support tagging while calling CreateWorkspace.
  • Loading branch information
awstools committed Mar 31, 2022
1 parent ac15087 commit 38838fa
Show file tree
Hide file tree
Showing 9 changed files with 3,396 additions and 2,314 deletions.
108 changes: 108 additions & 0 deletions clients/client-grafana/src/Grafana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,22 @@ import {
ListPermissionsCommandInput,
ListPermissionsCommandOutput,
} from "./commands/ListPermissionsCommand";
import {
ListTagsForResourceCommand,
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
} from "./commands/ListTagsForResourceCommand";
import {
ListWorkspacesCommand,
ListWorkspacesCommandInput,
ListWorkspacesCommandOutput,
} from "./commands/ListWorkspacesCommand";
import { TagResourceCommand, TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import {
UntagResourceCommand,
UntagResourceCommandInput,
UntagResourceCommandOutput,
} from "./commands/UntagResourceCommand";
import {
UpdatePermissionsCommand,
UpdatePermissionsCommandInput,
Expand Down Expand Up @@ -303,6 +314,40 @@ export class Grafana extends GrafanaClient {
}
}

/**
* <p>The <code>ListTagsForResource</code> operation returns the tags that
* are associated with the Amazon Managed Service for Grafana resource specified by the <code>resourceArn</code>.
* Currently, the only resource that can be tagged is a workspace. </p>
*/
public listTagsForResource(
args: ListTagsForResourceCommandInput,
options?: __HttpHandlerOptions
): Promise<ListTagsForResourceCommandOutput>;
public listTagsForResource(
args: ListTagsForResourceCommandInput,
cb: (err: any, data?: ListTagsForResourceCommandOutput) => void
): void;
public listTagsForResource(
args: ListTagsForResourceCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: ListTagsForResourceCommandOutput) => void
): void;
public listTagsForResource(
args: ListTagsForResourceCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListTagsForResourceCommandOutput) => void),
cb?: (err: any, data?: ListTagsForResourceCommandOutput) => void
): Promise<ListTagsForResourceCommandOutput> | void {
const command = new ListTagsForResourceCommand(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>Returns a list of Amazon Managed Grafana workspaces in the account, with some information
* about each workspace. For more complete information about one workspace, use <a href="https://docs.aws.amazon.com/AAMG/latest/APIReference/API_DescribeWorkspace.html">DescribeWorkspace</a>.</p>
Expand Down Expand Up @@ -336,6 +381,69 @@ export class Grafana extends GrafanaClient {
}
}

/**
* <p>The <code>TagResource</code> operation associates tags with an Amazon Managed Grafana resource.
* Currently, the only resource that can be tagged is workspaces. </p>
* <p>If you specify a new tag key for the resource, this tag is appended to the list of tags associated
* with the resource. If you specify a tag key that is already associated with the resource, the new tag
* value that you specify replaces the previous value for that tag.</p>
*/
public tagResource(args: TagResourceCommandInput, options?: __HttpHandlerOptions): Promise<TagResourceCommandOutput>;
public tagResource(args: TagResourceCommandInput, cb: (err: any, data?: TagResourceCommandOutput) => void): void;
public tagResource(
args: TagResourceCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: TagResourceCommandOutput) => void
): void;
public tagResource(
args: TagResourceCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: TagResourceCommandOutput) => void),
cb?: (err: any, data?: TagResourceCommandOutput) => void
): Promise<TagResourceCommandOutput> | void {
const command = new TagResourceCommand(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>The <code>UntagResource</code> operation removes the association of the tag with the Amazon Managed Grafana resource.
* </p>
*/
public untagResource(
args: UntagResourceCommandInput,
options?: __HttpHandlerOptions
): Promise<UntagResourceCommandOutput>;
public untagResource(
args: UntagResourceCommandInput,
cb: (err: any, data?: UntagResourceCommandOutput) => void
): void;
public untagResource(
args: UntagResourceCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: UntagResourceCommandOutput) => void
): void;
public untagResource(
args: UntagResourceCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UntagResourceCommandOutput) => void),
cb?: (err: any, data?: UntagResourceCommandOutput) => void
): Promise<UntagResourceCommandOutput> | void {
const command = new UntagResourceCommand(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>Updates which users in a workspace have the Grafana <code>Admin</code> or <code>Editor</code> roles.</p>
*/
Expand Down
12 changes: 12 additions & 0 deletions clients/client-grafana/src/GrafanaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ import {
DisassociateLicenseCommandOutput,
} from "./commands/DisassociateLicenseCommand";
import { ListPermissionsCommandInput, ListPermissionsCommandOutput } from "./commands/ListPermissionsCommand";
import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
} from "./commands/ListTagsForResourceCommand";
import { ListWorkspacesCommandInput, ListWorkspacesCommandOutput } from "./commands/ListWorkspacesCommand";
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
import { UpdatePermissionsCommandInput, UpdatePermissionsCommandOutput } from "./commands/UpdatePermissionsCommand";
import {
UpdateWorkspaceAuthenticationCommandInput,
Expand All @@ -81,7 +87,10 @@ export type ServiceInputTypes =
| DescribeWorkspaceCommandInput
| DisassociateLicenseCommandInput
| ListPermissionsCommandInput
| ListTagsForResourceCommandInput
| ListWorkspacesCommandInput
| TagResourceCommandInput
| UntagResourceCommandInput
| UpdatePermissionsCommandInput
| UpdateWorkspaceAuthenticationCommandInput
| UpdateWorkspaceCommandInput;
Expand All @@ -94,7 +103,10 @@ export type ServiceOutputTypes =
| DescribeWorkspaceCommandOutput
| DisassociateLicenseCommandOutput
| ListPermissionsCommandOutput
| ListTagsForResourceCommandOutput
| ListWorkspacesCommandOutput
| TagResourceCommandOutput
| UntagResourceCommandOutput
| UpdatePermissionsCommandOutput
| UpdateWorkspaceAuthenticationCommandOutput
| UpdateWorkspaceCommandOutput;
Expand Down
97 changes: 97 additions & 0 deletions clients/client-grafana/src/commands/ListTagsForResourceCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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 { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
import { ListTagsForResourceRequest, ListTagsForResourceResponse } from "../models/models_0";
import {
deserializeAws_restJson1ListTagsForResourceCommand,
serializeAws_restJson1ListTagsForResourceCommand,
} from "../protocols/Aws_restJson1";

export interface ListTagsForResourceCommandInput extends ListTagsForResourceRequest {}
export interface ListTagsForResourceCommandOutput extends ListTagsForResourceResponse, __MetadataBearer {}

/**
* <p>The <code>ListTagsForResource</code> operation returns the tags that
* are associated with the Amazon Managed Service for Grafana resource specified by the <code>resourceArn</code>.
* Currently, the only resource that can be tagged is a workspace. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { GrafanaClient, ListTagsForResourceCommand } from "@aws-sdk/client-grafana"; // ES Modules import
* // const { GrafanaClient, ListTagsForResourceCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
* const client = new GrafanaClient(config);
* const command = new ListTagsForResourceCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link ListTagsForResourceCommandInput} for command's `input` shape.
* @see {@link ListTagsForResourceCommandOutput} for command's `response` shape.
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
*
*/
export class ListTagsForResourceCommand extends $Command<
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
GrafanaClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

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

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
99 changes: 99 additions & 0 deletions clients/client-grafana/src/commands/TagResourceCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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 { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
import { TagResourceRequest, TagResourceResponse } from "../models/models_0";
import {
deserializeAws_restJson1TagResourceCommand,
serializeAws_restJson1TagResourceCommand,
} from "../protocols/Aws_restJson1";

export interface TagResourceCommandInput extends TagResourceRequest {}
export interface TagResourceCommandOutput extends TagResourceResponse, __MetadataBearer {}

/**
* <p>The <code>TagResource</code> operation associates tags with an Amazon Managed Grafana resource.
* Currently, the only resource that can be tagged is workspaces. </p>
* <p>If you specify a new tag key for the resource, this tag is appended to the list of tags associated
* with the resource. If you specify a tag key that is already associated with the resource, the new tag
* value that you specify replaces the previous value for that tag.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { GrafanaClient, TagResourceCommand } from "@aws-sdk/client-grafana"; // ES Modules import
* // const { GrafanaClient, TagResourceCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
* const client = new GrafanaClient(config);
* const command = new TagResourceCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link TagResourceCommandInput} for command's `input` shape.
* @see {@link TagResourceCommandOutput} for command's `response` shape.
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
*
*/
export class TagResourceCommand extends $Command<
TagResourceCommandInput,
TagResourceCommandOutput,
GrafanaClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

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

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
Loading

0 comments on commit 38838fa

Please sign in to comment.