Skip to content

Commit

Permalink
feat(client-grafana): This release adds APIs for creating and deletin…
Browse files Browse the repository at this point in the history
…g API keys in an Amazon Managed Grafana workspace.
  • Loading branch information
awstools committed May 13, 2022
1 parent 35d9f84 commit 091f6df
Show file tree
Hide file tree
Showing 8 changed files with 1,151 additions and 333 deletions.
77 changes: 77 additions & 0 deletions clients/client-grafana/src/Grafana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ import {
AssociateLicenseCommandInput,
AssociateLicenseCommandOutput,
} from "./commands/AssociateLicenseCommand";
import {
CreateWorkspaceApiKeyCommand,
CreateWorkspaceApiKeyCommandInput,
CreateWorkspaceApiKeyCommandOutput,
} from "./commands/CreateWorkspaceApiKeyCommand";
import {
CreateWorkspaceCommand,
CreateWorkspaceCommandInput,
CreateWorkspaceCommandOutput,
} from "./commands/CreateWorkspaceCommand";
import {
DeleteWorkspaceApiKeyCommand,
DeleteWorkspaceApiKeyCommandInput,
DeleteWorkspaceApiKeyCommandOutput,
} from "./commands/DeleteWorkspaceApiKeyCommand";
import {
DeleteWorkspaceCommand,
DeleteWorkspaceCommandInput,
Expand Down Expand Up @@ -149,6 +159,41 @@ export class Grafana extends GrafanaClient {
}
}

/**
* <p>Creates an API key for the workspace. This key can be used to authenticate
* requests sent to the workspace's HTTP API. See
* <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>
* for available APIs and example requests.</p>
*/
public createWorkspaceApiKey(
args: CreateWorkspaceApiKeyCommandInput,
options?: __HttpHandlerOptions
): Promise<CreateWorkspaceApiKeyCommandOutput>;
public createWorkspaceApiKey(
args: CreateWorkspaceApiKeyCommandInput,
cb: (err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void
): void;
public createWorkspaceApiKey(
args: CreateWorkspaceApiKeyCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void
): void;
public createWorkspaceApiKey(
args: CreateWorkspaceApiKeyCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void),
cb?: (err: any, data?: CreateWorkspaceApiKeyCommandOutput) => void
): Promise<CreateWorkspaceApiKeyCommandOutput> | void {
const command = new CreateWorkspaceApiKeyCommand(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>Deletes an Amazon Managed Grafana workspace.</p>
*/
Expand Down Expand Up @@ -181,6 +226,38 @@ export class Grafana extends GrafanaClient {
}
}

/**
* <p>Deletes an API key for a workspace.</p>
*/
public deleteWorkspaceApiKey(
args: DeleteWorkspaceApiKeyCommandInput,
options?: __HttpHandlerOptions
): Promise<DeleteWorkspaceApiKeyCommandOutput>;
public deleteWorkspaceApiKey(
args: DeleteWorkspaceApiKeyCommandInput,
cb: (err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void
): void;
public deleteWorkspaceApiKey(
args: DeleteWorkspaceApiKeyCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void
): void;
public deleteWorkspaceApiKey(
args: DeleteWorkspaceApiKeyCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void),
cb?: (err: any, data?: DeleteWorkspaceApiKeyCommandOutput) => void
): Promise<DeleteWorkspaceApiKeyCommandOutput> | void {
const command = new DeleteWorkspaceApiKeyCommand(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>Displays information about one Amazon Managed Grafana workspace.</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 @@ -53,7 +53,15 @@ import {
} from "@aws-sdk/types";

import { AssociateLicenseCommandInput, AssociateLicenseCommandOutput } from "./commands/AssociateLicenseCommand";
import {
CreateWorkspaceApiKeyCommandInput,
CreateWorkspaceApiKeyCommandOutput,
} from "./commands/CreateWorkspaceApiKeyCommand";
import { CreateWorkspaceCommandInput, CreateWorkspaceCommandOutput } from "./commands/CreateWorkspaceCommand";
import {
DeleteWorkspaceApiKeyCommandInput,
DeleteWorkspaceApiKeyCommandOutput,
} from "./commands/DeleteWorkspaceApiKeyCommand";
import { DeleteWorkspaceCommandInput, DeleteWorkspaceCommandOutput } from "./commands/DeleteWorkspaceCommand";
import {
DescribeWorkspaceAuthenticationCommandInput,
Expand Down Expand Up @@ -82,7 +90,9 @@ import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";

export type ServiceInputTypes =
| AssociateLicenseCommandInput
| CreateWorkspaceApiKeyCommandInput
| CreateWorkspaceCommandInput
| DeleteWorkspaceApiKeyCommandInput
| DeleteWorkspaceCommandInput
| DescribeWorkspaceAuthenticationCommandInput
| DescribeWorkspaceCommandInput
Expand All @@ -98,7 +108,9 @@ export type ServiceInputTypes =

export type ServiceOutputTypes =
| AssociateLicenseCommandOutput
| CreateWorkspaceApiKeyCommandOutput
| CreateWorkspaceCommandOutput
| DeleteWorkspaceApiKeyCommandOutput
| DeleteWorkspaceCommandOutput
| DescribeWorkspaceAuthenticationCommandOutput
| DescribeWorkspaceCommandOutput
Expand Down
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 { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
import { CreateWorkspaceApiKeyRequest, CreateWorkspaceApiKeyResponse } from "../models/models_0";
import {
deserializeAws_restJson1CreateWorkspaceApiKeyCommand,
serializeAws_restJson1CreateWorkspaceApiKeyCommand,
} from "../protocols/Aws_restJson1";

export interface CreateWorkspaceApiKeyCommandInput extends CreateWorkspaceApiKeyRequest {}
export interface CreateWorkspaceApiKeyCommandOutput extends CreateWorkspaceApiKeyResponse, __MetadataBearer {}

/**
* <p>Creates an API key for the workspace. This key can be used to authenticate
* requests sent to the workspace's HTTP API. See
* <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>
* for available APIs and example requests.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { GrafanaClient, CreateWorkspaceApiKeyCommand } from "@aws-sdk/client-grafana"; // ES Modules import
* // const { GrafanaClient, CreateWorkspaceApiKeyCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
* const client = new GrafanaClient(config);
* const command = new CreateWorkspaceApiKeyCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link CreateWorkspaceApiKeyCommandInput} for command's `input` shape.
* @see {@link CreateWorkspaceApiKeyCommandOutput} for command's `response` shape.
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
*
*/
export class CreateWorkspaceApiKeyCommand extends $Command<
CreateWorkspaceApiKeyCommandInput,
CreateWorkspaceApiKeyCommandOutput,
GrafanaClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

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

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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 { GrafanaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../GrafanaClient";
import { DeleteWorkspaceApiKeyRequest, DeleteWorkspaceApiKeyResponse } from "../models/models_0";
import {
deserializeAws_restJson1DeleteWorkspaceApiKeyCommand,
serializeAws_restJson1DeleteWorkspaceApiKeyCommand,
} from "../protocols/Aws_restJson1";

export interface DeleteWorkspaceApiKeyCommandInput extends DeleteWorkspaceApiKeyRequest {}
export interface DeleteWorkspaceApiKeyCommandOutput extends DeleteWorkspaceApiKeyResponse, __MetadataBearer {}

/**
* <p>Deletes an API key for a workspace.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { GrafanaClient, DeleteWorkspaceApiKeyCommand } from "@aws-sdk/client-grafana"; // ES Modules import
* // const { GrafanaClient, DeleteWorkspaceApiKeyCommand } = require("@aws-sdk/client-grafana"); // CommonJS import
* const client = new GrafanaClient(config);
* const command = new DeleteWorkspaceApiKeyCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link DeleteWorkspaceApiKeyCommandInput} for command's `input` shape.
* @see {@link DeleteWorkspaceApiKeyCommandOutput} for command's `response` shape.
* @see {@link GrafanaClientResolvedConfig | config} for GrafanaClient's `config` shape.
*
*/
export class DeleteWorkspaceApiKeyCommand extends $Command<
DeleteWorkspaceApiKeyCommandInput,
DeleteWorkspaceApiKeyCommandOutput,
GrafanaClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

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

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
2 changes: 2 additions & 0 deletions clients/client-grafana/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// smithy-typescript generated code
export * from "./AssociateLicenseCommand";
export * from "./CreateWorkspaceApiKeyCommand";
export * from "./CreateWorkspaceCommand";
export * from "./DeleteWorkspaceApiKeyCommand";
export * from "./DeleteWorkspaceCommand";
export * from "./DescribeWorkspaceAuthenticationCommand";
export * from "./DescribeWorkspaceCommand";
Expand Down
Loading

0 comments on commit 091f6df

Please sign in to comment.