Skip to content

Commit 38838fa

Browse files
author
awstools
committed
feat(client-grafana): This release adds tagging support to the Managed Grafana service. New APIs: TagResource, UntagResource and ListTagsForResource. Updates: add optional field tags to support tagging while calling CreateWorkspace.
1 parent ac15087 commit 38838fa

File tree

9 files changed

+3396
-2314
lines changed

9 files changed

+3396
-2314
lines changed

clients/client-grafana/src/Grafana.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,22 @@ import {
3535
ListPermissionsCommandInput,
3636
ListPermissionsCommandOutput,
3737
} from "./commands/ListPermissionsCommand";
38+
import {
39+
ListTagsForResourceCommand,
40+
ListTagsForResourceCommandInput,
41+
ListTagsForResourceCommandOutput,
42+
} from "./commands/ListTagsForResourceCommand";
3843
import {
3944
ListWorkspacesCommand,
4045
ListWorkspacesCommandInput,
4146
ListWorkspacesCommandOutput,
4247
} from "./commands/ListWorkspacesCommand";
48+
import { TagResourceCommand, TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
49+
import {
50+
UntagResourceCommand,
51+
UntagResourceCommandInput,
52+
UntagResourceCommandOutput,
53+
} from "./commands/UntagResourceCommand";
4354
import {
4455
UpdatePermissionsCommand,
4556
UpdatePermissionsCommandInput,
@@ -303,6 +314,40 @@ export class Grafana extends GrafanaClient {
303314
}
304315
}
305316

317+
/**
318+
* <p>The <code>ListTagsForResource</code> operation returns the tags that
319+
* are associated with the Amazon Managed Service for Grafana resource specified by the <code>resourceArn</code>.
320+
* Currently, the only resource that can be tagged is a workspace. </p>
321+
*/
322+
public listTagsForResource(
323+
args: ListTagsForResourceCommandInput,
324+
options?: __HttpHandlerOptions
325+
): Promise<ListTagsForResourceCommandOutput>;
326+
public listTagsForResource(
327+
args: ListTagsForResourceCommandInput,
328+
cb: (err: any, data?: ListTagsForResourceCommandOutput) => void
329+
): void;
330+
public listTagsForResource(
331+
args: ListTagsForResourceCommandInput,
332+
options: __HttpHandlerOptions,
333+
cb: (err: any, data?: ListTagsForResourceCommandOutput) => void
334+
): void;
335+
public listTagsForResource(
336+
args: ListTagsForResourceCommandInput,
337+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListTagsForResourceCommandOutput) => void),
338+
cb?: (err: any, data?: ListTagsForResourceCommandOutput) => void
339+
): Promise<ListTagsForResourceCommandOutput> | void {
340+
const command = new ListTagsForResourceCommand(args);
341+
if (typeof optionsOrCb === "function") {
342+
this.send(command, optionsOrCb);
343+
} else if (typeof cb === "function") {
344+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
345+
this.send(command, optionsOrCb || {}, cb);
346+
} else {
347+
return this.send(command, optionsOrCb);
348+
}
349+
}
350+
306351
/**
307352
* <p>Returns a list of Amazon Managed Grafana workspaces in the account, with some information
308353
* 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>
@@ -336,6 +381,69 @@ export class Grafana extends GrafanaClient {
336381
}
337382
}
338383

384+
/**
385+
* <p>The <code>TagResource</code> operation associates tags with an Amazon Managed Grafana resource.
386+
* Currently, the only resource that can be tagged is workspaces. </p>
387+
* <p>If you specify a new tag key for the resource, this tag is appended to the list of tags associated
388+
* with the resource. If you specify a tag key that is already associated with the resource, the new tag
389+
* value that you specify replaces the previous value for that tag.</p>
390+
*/
391+
public tagResource(args: TagResourceCommandInput, options?: __HttpHandlerOptions): Promise<TagResourceCommandOutput>;
392+
public tagResource(args: TagResourceCommandInput, cb: (err: any, data?: TagResourceCommandOutput) => void): void;
393+
public tagResource(
394+
args: TagResourceCommandInput,
395+
options: __HttpHandlerOptions,
396+
cb: (err: any, data?: TagResourceCommandOutput) => void
397+
): void;
398+
public tagResource(
399+
args: TagResourceCommandInput,
400+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: TagResourceCommandOutput) => void),
401+
cb?: (err: any, data?: TagResourceCommandOutput) => void
402+
): Promise<TagResourceCommandOutput> | void {
403+
const command = new TagResourceCommand(args);
404+
if (typeof optionsOrCb === "function") {
405+
this.send(command, optionsOrCb);
406+
} else if (typeof cb === "function") {
407+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
408+
this.send(command, optionsOrCb || {}, cb);
409+
} else {
410+
return this.send(command, optionsOrCb);
411+
}
412+
}
413+
414+
/**
415+
* <p>The <code>UntagResource</code> operation removes the association of the tag with the Amazon Managed Grafana resource.
416+
* </p>
417+
*/
418+
public untagResource(
419+
args: UntagResourceCommandInput,
420+
options?: __HttpHandlerOptions
421+
): Promise<UntagResourceCommandOutput>;
422+
public untagResource(
423+
args: UntagResourceCommandInput,
424+
cb: (err: any, data?: UntagResourceCommandOutput) => void
425+
): void;
426+
public untagResource(
427+
args: UntagResourceCommandInput,
428+
options: __HttpHandlerOptions,
429+
cb: (err: any, data?: UntagResourceCommandOutput) => void
430+
): void;
431+
public untagResource(
432+
args: UntagResourceCommandInput,
433+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UntagResourceCommandOutput) => void),
434+
cb?: (err: any, data?: UntagResourceCommandOutput) => void
435+
): Promise<UntagResourceCommandOutput> | void {
436+
const command = new UntagResourceCommand(args);
437+
if (typeof optionsOrCb === "function") {
438+
this.send(command, optionsOrCb);
439+
} else if (typeof cb === "function") {
440+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
441+
this.send(command, optionsOrCb || {}, cb);
442+
} else {
443+
return this.send(command, optionsOrCb);
444+
}
445+
}
446+
339447
/**
340448
* <p>Updates which users in a workspace have the Grafana <code>Admin</code> or <code>Editor</code> roles.</p>
341449
*/

clients/client-grafana/src/GrafanaClient.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ import {
6464
DisassociateLicenseCommandOutput,
6565
} from "./commands/DisassociateLicenseCommand";
6666
import { ListPermissionsCommandInput, ListPermissionsCommandOutput } from "./commands/ListPermissionsCommand";
67+
import {
68+
ListTagsForResourceCommandInput,
69+
ListTagsForResourceCommandOutput,
70+
} from "./commands/ListTagsForResourceCommand";
6771
import { ListWorkspacesCommandInput, ListWorkspacesCommandOutput } from "./commands/ListWorkspacesCommand";
72+
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
73+
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
6874
import { UpdatePermissionsCommandInput, UpdatePermissionsCommandOutput } from "./commands/UpdatePermissionsCommand";
6975
import {
7076
UpdateWorkspaceAuthenticationCommandInput,
@@ -81,7 +87,10 @@ export type ServiceInputTypes =
8187
| DescribeWorkspaceCommandInput
8288
| DisassociateLicenseCommandInput
8389
| ListPermissionsCommandInput
90+
| ListTagsForResourceCommandInput
8491
| ListWorkspacesCommandInput
92+
| TagResourceCommandInput
93+
| UntagResourceCommandInput
8594
| UpdatePermissionsCommandInput
8695
| UpdateWorkspaceAuthenticationCommandInput
8796
| UpdateWorkspaceCommandInput;
@@ -94,7 +103,10 @@ export type ServiceOutputTypes =
94103
| DescribeWorkspaceCommandOutput
95104
| DisassociateLicenseCommandOutput
96105
| ListPermissionsCommandOutput
106+
| ListTagsForResourceCommandOutput
97107
| ListWorkspacesCommandOutput
108+
| TagResourceCommandOutput
109+
| UntagResourceCommandOutput
98110
| UpdatePermissionsCommandOutput
99111
| UpdateWorkspaceAuthenticationCommandOutput
100112
| UpdateWorkspaceCommandOutput;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
15+
import { ListTagsForResourceRequest, ListTagsForResourceResponse } from "../models/models_0";
16+
import {
17+
deserializeAws_restJson1ListTagsForResourceCommand,
18+
serializeAws_restJson1ListTagsForResourceCommand,
19+
} from "../protocols/Aws_restJson1";
20+
21+
export interface ListTagsForResourceCommandInput extends ListTagsForResourceRequest {}
22+
export interface ListTagsForResourceCommandOutput extends ListTagsForResourceResponse, __MetadataBearer {}
23+
24+
/**
25+
* <p>The <code>ListTagsForResource</code> operation returns the tags that
26+
* are associated with the Amazon Managed Service for Grafana resource specified by the <code>resourceArn</code>.
27+
* Currently, the only resource that can be tagged is a workspace. </p>
28+
* @example
29+
* Use a bare-bones client and the command you need to make an API call.
30+
* ```javascript
31+
* import { GrafanaClient, ListTagsForResourceCommand } from "@aws-sdk/client-grafana"; // ES Modules import
32+
* // const { GrafanaClient, ListTagsForResourceCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
33+
* const client = new GrafanaClient(config);
34+
* const command = new ListTagsForResourceCommand(input);
35+
* const response = await client.send(command);
36+
* ```
37+
*
38+
* @see {@link ListTagsForResourceCommandInput} for command's `input` shape.
39+
* @see {@link ListTagsForResourceCommandOutput} for command's `response` shape.
40+
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
41+
*
42+
*/
43+
export class ListTagsForResourceCommand extends $Command<
44+
ListTagsForResourceCommandInput,
45+
ListTagsForResourceCommandOutput,
46+
GrafanaClientResolvedConfig
47+
> {
48+
// Start section: command_properties
49+
// End section: command_properties
50+
51+
constructor(readonly input: ListTagsForResourceCommandInput) {
52+
// Start section: command_constructor
53+
super();
54+
// End section: command_constructor
55+
}
56+
57+
/**
58+
* @internal
59+
*/
60+
resolveMiddleware(
61+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
62+
configuration: GrafanaClientResolvedConfig,
63+
options?: __HttpHandlerOptions
64+
): Handler<ListTagsForResourceCommandInput, ListTagsForResourceCommandOutput> {
65+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
66+
67+
const stack = clientStack.concat(this.middlewareStack);
68+
69+
const { logger } = configuration;
70+
const clientName = "GrafanaClient";
71+
const commandName = "ListTagsForResourceCommand";
72+
const handlerExecutionContext: HandlerExecutionContext = {
73+
logger,
74+
clientName,
75+
commandName,
76+
inputFilterSensitiveLog: ListTagsForResourceRequest.filterSensitiveLog,
77+
outputFilterSensitiveLog: ListTagsForResourceResponse.filterSensitiveLog,
78+
};
79+
const { requestHandler } = configuration;
80+
return stack.resolve(
81+
(request: FinalizeHandlerArguments<any>) =>
82+
requestHandler.handle(request.request as __HttpRequest, options || {}),
83+
handlerExecutionContext
84+
);
85+
}
86+
87+
private serialize(input: ListTagsForResourceCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
88+
return serializeAws_restJson1ListTagsForResourceCommand(input, context);
89+
}
90+
91+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListTagsForResourceCommandOutput> {
92+
return deserializeAws_restJson1ListTagsForResourceCommand(output, context);
93+
}
94+
95+
// Start section: command_body_extra
96+
// End section: command_body_extra
97+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
15+
import { TagResourceRequest, TagResourceResponse } from "../models/models_0";
16+
import {
17+
deserializeAws_restJson1TagResourceCommand,
18+
serializeAws_restJson1TagResourceCommand,
19+
} from "../protocols/Aws_restJson1";
20+
21+
export interface TagResourceCommandInput extends TagResourceRequest {}
22+
export interface TagResourceCommandOutput extends TagResourceResponse, __MetadataBearer {}
23+
24+
/**
25+
* <p>The <code>TagResource</code> operation associates tags with an Amazon Managed Grafana resource.
26+
* Currently, the only resource that can be tagged is workspaces. </p>
27+
* <p>If you specify a new tag key for the resource, this tag is appended to the list of tags associated
28+
* with the resource. If you specify a tag key that is already associated with the resource, the new tag
29+
* value that you specify replaces the previous value for that tag.</p>
30+
* @example
31+
* Use a bare-bones client and the command you need to make an API call.
32+
* ```javascript
33+
* import { GrafanaClient, TagResourceCommand } from "@aws-sdk/client-grafana"; // ES Modules import
34+
* // const { GrafanaClient, TagResourceCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
35+
* const client = new GrafanaClient(config);
36+
* const command = new TagResourceCommand(input);
37+
* const response = await client.send(command);
38+
* ```
39+
*
40+
* @see {@link TagResourceCommandInput} for command's `input` shape.
41+
* @see {@link TagResourceCommandOutput} for command's `response` shape.
42+
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
43+
*
44+
*/
45+
export class TagResourceCommand extends $Command<
46+
TagResourceCommandInput,
47+
TagResourceCommandOutput,
48+
GrafanaClientResolvedConfig
49+
> {
50+
// Start section: command_properties
51+
// End section: command_properties
52+
53+
constructor(readonly input: TagResourceCommandInput) {
54+
// Start section: command_constructor
55+
super();
56+
// End section: command_constructor
57+
}
58+
59+
/**
60+
* @internal
61+
*/
62+
resolveMiddleware(
63+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
64+
configuration: GrafanaClientResolvedConfig,
65+
options?: __HttpHandlerOptions
66+
): Handler<TagResourceCommandInput, TagResourceCommandOutput> {
67+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
68+
69+
const stack = clientStack.concat(this.middlewareStack);
70+
71+
const { logger } = configuration;
72+
const clientName = "GrafanaClient";
73+
const commandName = "TagResourceCommand";
74+
const handlerExecutionContext: HandlerExecutionContext = {
75+
logger,
76+
clientName,
77+
commandName,
78+
inputFilterSensitiveLog: TagResourceRequest.filterSensitiveLog,
79+
outputFilterSensitiveLog: TagResourceResponse.filterSensitiveLog,
80+
};
81+
const { requestHandler } = configuration;
82+
return stack.resolve(
83+
(request: FinalizeHandlerArguments<any>) =>
84+
requestHandler.handle(request.request as __HttpRequest, options || {}),
85+
handlerExecutionContext
86+
);
87+
}
88+
89+
private serialize(input: TagResourceCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
90+
return serializeAws_restJson1TagResourceCommand(input, context);
91+
}
92+
93+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<TagResourceCommandOutput> {
94+
return deserializeAws_restJson1TagResourceCommand(output, context);
95+
}
96+
97+
// Start section: command_body_extra
98+
// End section: command_body_extra
99+
}

0 commit comments

Comments
 (0)