Skip to content

Commit 091f6df

Browse files
author
awstools
committed
feat(client-grafana): This release adds APIs for creating and deleting API keys in an Amazon Managed Grafana workspace.
1 parent 35d9f84 commit 091f6df

File tree

8 files changed

+1151
-333
lines changed

8 files changed

+1151
-333
lines changed

clients/client-grafana/src/Grafana.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ import {
66
AssociateLicenseCommandInput,
77
AssociateLicenseCommandOutput,
88
} from "./commands/AssociateLicenseCommand";
9+
import {
10+
CreateWorkspaceApiKeyCommand,
11+
CreateWorkspaceApiKeyCommandInput,
12+
CreateWorkspaceApiKeyCommandOutput,
13+
} from "./commands/CreateWorkspaceApiKeyCommand";
914
import {
1015
CreateWorkspaceCommand,
1116
CreateWorkspaceCommandInput,
1217
CreateWorkspaceCommandOutput,
1318
} from "./commands/CreateWorkspaceCommand";
19+
import {
20+
DeleteWorkspaceApiKeyCommand,
21+
DeleteWorkspaceApiKeyCommandInput,
22+
DeleteWorkspaceApiKeyCommandOutput,
23+
} from "./commands/DeleteWorkspaceApiKeyCommand";
1424
import {
1525
DeleteWorkspaceCommand,
1626
DeleteWorkspaceCommandInput,
@@ -149,6 +159,41 @@ export class Grafana extends GrafanaClient {
149159
}
150160
}
151161

162+
/**
163+
* <p>Creates an API key for the workspace. This key can be used to authenticate
164+
* requests sent to the workspace's HTTP API. See
165+
* <a href=" https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html"> https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html</a>
166+
* for available APIs and example requests.</p>
167+
*/
168+
public createWorkspaceApiKey(
169+
args: CreateWorkspaceApiKeyCommandInput,
170+
options?: __HttpHandlerOptions
171+
): Promise<CreateWorkspaceApiKeyCommandOutput>;
172+
public createWorkspaceApiKey(
173+
args: CreateWorkspaceApiKeyCommandInput,
174+
cb: (err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void
175+
): void;
176+
public createWorkspaceApiKey(
177+
args: CreateWorkspaceApiKeyCommandInput,
178+
options: __HttpHandlerOptions,
179+
cb: (err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void
180+
): void;
181+
public createWorkspaceApiKey(
182+
args: CreateWorkspaceApiKeyCommandInput,
183+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void),
184+
cb?: (err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void
185+
): Promise<CreateWorkspaceApiKeyCommandOutput> | void {
186+
const command = new CreateWorkspaceApiKeyCommand(args);
187+
if (typeof optionsOrCb === "function") {
188+
this.send(command, optionsOrCb);
189+
} else if (typeof cb === "function") {
190+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
191+
this.send(command, optionsOrCb || {}, cb);
192+
} else {
193+
return this.send(command, optionsOrCb);
194+
}
195+
}
196+
152197
/**
153198
* <p>Deletes an Amazon Managed Grafana workspace.</p>
154199
*/
@@ -181,6 +226,38 @@ export class Grafana extends GrafanaClient {
181226
}
182227
}
183228

229+
/**
230+
* <p>Deletes an API key for a workspace.</p>
231+
*/
232+
public deleteWorkspaceApiKey(
233+
args: DeleteWorkspaceApiKeyCommandInput,
234+
options?: __HttpHandlerOptions
235+
): Promise<DeleteWorkspaceApiKeyCommandOutput>;
236+
public deleteWorkspaceApiKey(
237+
args: DeleteWorkspaceApiKeyCommandInput,
238+
cb: (err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void
239+
): void;
240+
public deleteWorkspaceApiKey(
241+
args: DeleteWorkspaceApiKeyCommandInput,
242+
options: __HttpHandlerOptions,
243+
cb: (err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void
244+
): void;
245+
public deleteWorkspaceApiKey(
246+
args: DeleteWorkspaceApiKeyCommandInput,
247+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void),
248+
cb?: (err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void
249+
): Promise<DeleteWorkspaceApiKeyCommandOutput> | void {
250+
const command = new DeleteWorkspaceApiKeyCommand(args);
251+
if (typeof optionsOrCb === "function") {
252+
this.send(command, optionsOrCb);
253+
} else if (typeof cb === "function") {
254+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
255+
this.send(command, optionsOrCb || {}, cb);
256+
} else {
257+
return this.send(command, optionsOrCb);
258+
}
259+
}
260+
184261
/**
185262
* <p>Displays information about one Amazon Managed Grafana workspace.</p>
186263
*/

clients/client-grafana/src/GrafanaClient.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ import {
5353
} from "@aws-sdk/types";
5454

5555
import { AssociateLicenseCommandInput, AssociateLicenseCommandOutput } from "./commands/AssociateLicenseCommand";
56+
import {
57+
CreateWorkspaceApiKeyCommandInput,
58+
CreateWorkspaceApiKeyCommandOutput,
59+
} from "./commands/CreateWorkspaceApiKeyCommand";
5660
import { CreateWorkspaceCommandInput, CreateWorkspaceCommandOutput } from "./commands/CreateWorkspaceCommand";
61+
import {
62+
DeleteWorkspaceApiKeyCommandInput,
63+
DeleteWorkspaceApiKeyCommandOutput,
64+
} from "./commands/DeleteWorkspaceApiKeyCommand";
5765
import { DeleteWorkspaceCommandInput, DeleteWorkspaceCommandOutput } from "./commands/DeleteWorkspaceCommand";
5866
import {
5967
DescribeWorkspaceAuthenticationCommandInput,
@@ -82,7 +90,9 @@ import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
8290

8391
export type ServiceInputTypes =
8492
| AssociateLicenseCommandInput
93+
| CreateWorkspaceApiKeyCommandInput
8594
| CreateWorkspaceCommandInput
95+
| DeleteWorkspaceApiKeyCommandInput
8696
| DeleteWorkspaceCommandInput
8797
| DescribeWorkspaceAuthenticationCommandInput
8898
| DescribeWorkspaceCommandInput
@@ -98,7 +108,9 @@ export type ServiceInputTypes =
98108

99109
export type ServiceOutputTypes =
100110
| AssociateLicenseCommandOutput
111+
| CreateWorkspaceApiKeyCommandOutput
101112
| CreateWorkspaceCommandOutput
113+
| DeleteWorkspaceApiKeyCommandOutput
102114
| DeleteWorkspaceCommandOutput
103115
| DescribeWorkspaceAuthenticationCommandOutput
104116
| DescribeWorkspaceCommandOutput
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
16+
import { CreateWorkspaceApiKeyRequest, CreateWorkspaceApiKeyResponse } from "../models/models_0";
17+
import {
18+
deserializeAws_restJson1CreateWorkspaceApiKeyCommand,
19+
serializeAws_restJson1CreateWorkspaceApiKeyCommand,
20+
} from "../protocols/Aws_restJson1";
21+
22+
export interface CreateWorkspaceApiKeyCommandInput extends CreateWorkspaceApiKeyRequest {}
23+
export interface CreateWorkspaceApiKeyCommandOutput extends CreateWorkspaceApiKeyResponse, __MetadataBearer {}
24+
25+
/**
26+
* <p>Creates an API key for the workspace. This key can be used to authenticate
27+
* requests sent to the workspace's HTTP API. See
28+
* <a href=" https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html"> https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html</a>
29+
* for available APIs and example requests.</p>
30+
* @example
31+
* Use a bare-bones client and the command you need to make an API call.
32+
* ```javascript
33+
* import { GrafanaClient, CreateWorkspaceApiKeyCommand } from "@aws-sdk/client-grafana"; // ES Modules import
34+
* // const { GrafanaClient, CreateWorkspaceApiKeyCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
35+
* const client = new GrafanaClient(config);
36+
* const command = new CreateWorkspaceApiKeyCommand(input);
37+
* const response = await client.send(command);
38+
* ```
39+
*
40+
* @see {@link CreateWorkspaceApiKeyCommandInput} for command's `input` shape.
41+
* @see {@link CreateWorkspaceApiKeyCommandOutput} for command's `response` shape.
42+
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
43+
*
44+
*/
45+
export class CreateWorkspaceApiKeyCommand extends $Command<
46+
CreateWorkspaceApiKeyCommandInput,
47+
CreateWorkspaceApiKeyCommandOutput,
48+
GrafanaClientResolvedConfig
49+
> {
50+
// Start section: command_properties
51+
// End section: command_properties
52+
53+
constructor(readonly input: CreateWorkspaceApiKeyCommandInput) {
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<CreateWorkspaceApiKeyCommandInput, CreateWorkspaceApiKeyCommandOutput> {
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 = "CreateWorkspaceApiKeyCommand";
74+
const handlerExecutionContext: HandlerExecutionContext = {
75+
logger,
76+
clientName,
77+
commandName,
78+
inputFilterSensitiveLog: CreateWorkspaceApiKeyRequest.filterSensitiveLog,
79+
outputFilterSensitiveLog: CreateWorkspaceApiKeyResponse.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: CreateWorkspaceApiKeyCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
90+
return serializeAws_restJson1CreateWorkspaceApiKeyCommand(input, context);
91+
}
92+
93+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<CreateWorkspaceApiKeyCommandOutput> {
94+
return deserializeAws_restJson1CreateWorkspaceApiKeyCommand(output, context);
95+
}
96+
97+
// Start section: command_body_extra
98+
// End section: command_body_extra
99+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
16+
import { DeleteWorkspaceApiKeyRequest, DeleteWorkspaceApiKeyResponse } from "../models/models_0";
17+
import {
18+
deserializeAws_restJson1DeleteWorkspaceApiKeyCommand,
19+
serializeAws_restJson1DeleteWorkspaceApiKeyCommand,
20+
} from "../protocols/Aws_restJson1";
21+
22+
export interface DeleteWorkspaceApiKeyCommandInput extends DeleteWorkspaceApiKeyRequest {}
23+
export interface DeleteWorkspaceApiKeyCommandOutput extends DeleteWorkspaceApiKeyResponse, __MetadataBearer {}
24+
25+
/**
26+
* <p>Deletes an API key for a workspace.</p>
27+
* @example
28+
* Use a bare-bones client and the command you need to make an API call.
29+
* ```javascript
30+
* import { GrafanaClient, DeleteWorkspaceApiKeyCommand } from "@aws-sdk/client-grafana"; // ES Modules import
31+
* // const { GrafanaClient, DeleteWorkspaceApiKeyCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
32+
* const client = new GrafanaClient(config);
33+
* const command = new DeleteWorkspaceApiKeyCommand(input);
34+
* const response = await client.send(command);
35+
* ```
36+
*
37+
* @see {@link DeleteWorkspaceApiKeyCommandInput} for command's `input` shape.
38+
* @see {@link DeleteWorkspaceApiKeyCommandOutput} for command's `response` shape.
39+
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
40+
*
41+
*/
42+
export class DeleteWorkspaceApiKeyCommand extends $Command<
43+
DeleteWorkspaceApiKeyCommandInput,
44+
DeleteWorkspaceApiKeyCommandOutput,
45+
GrafanaClientResolvedConfig
46+
> {
47+
// Start section: command_properties
48+
// End section: command_properties
49+
50+
constructor(readonly input: DeleteWorkspaceApiKeyCommandInput) {
51+
// Start section: command_constructor
52+
super();
53+
// End section: command_constructor
54+
}
55+
56+
/**
57+
* @internal
58+
*/
59+
resolveMiddleware(
60+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
61+
configuration: GrafanaClientResolvedConfig,
62+
options?: __HttpHandlerOptions
63+
): Handler<DeleteWorkspaceApiKeyCommandInput, DeleteWorkspaceApiKeyCommandOutput> {
64+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
65+
66+
const stack = clientStack.concat(this.middlewareStack);
67+
68+
const { logger } = configuration;
69+
const clientName = "GrafanaClient";
70+
const commandName = "DeleteWorkspaceApiKeyCommand";
71+
const handlerExecutionContext: HandlerExecutionContext = {
72+
logger,
73+
clientName,
74+
commandName,
75+
inputFilterSensitiveLog: DeleteWorkspaceApiKeyRequest.filterSensitiveLog,
76+
outputFilterSensitiveLog: DeleteWorkspaceApiKeyResponse.filterSensitiveLog,
77+
};
78+
const { requestHandler } = configuration;
79+
return stack.resolve(
80+
(request: FinalizeHandlerArguments<any>) =>
81+
requestHandler.handle(request.request as __HttpRequest, options || {}),
82+
handlerExecutionContext
83+
);
84+
}
85+
86+
private serialize(input: DeleteWorkspaceApiKeyCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
87+
return serializeAws_restJson1DeleteWorkspaceApiKeyCommand(input, context);
88+
}
89+
90+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<DeleteWorkspaceApiKeyCommandOutput> {
91+
return deserializeAws_restJson1DeleteWorkspaceApiKeyCommand(output, context);
92+
}
93+
94+
// Start section: command_body_extra
95+
// End section: command_body_extra
96+
}

clients/client-grafana/src/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// smithy-typescript generated code
22
export * from "./AssociateLicenseCommand";
3+
export * from "./CreateWorkspaceApiKeyCommand";
34
export * from "./CreateWorkspaceCommand";
5+
export * from "./DeleteWorkspaceApiKeyCommand";
46
export * from "./DeleteWorkspaceCommand";
57
export * from "./DescribeWorkspaceAuthenticationCommand";
68
export * from "./DescribeWorkspaceCommand";

0 commit comments

Comments
 (0)