Skip to content

Commit

Permalink
feat(client-mwaa): Introducing InvokeRestApi which allows users to in…
Browse files Browse the repository at this point in the history
…voke the Apache Airflow REST API on the webserver with the specified inputs.
  • Loading branch information
awstools committed Oct 23, 2024
1 parent aa53886 commit 180dd23
Show file tree
Hide file tree
Showing 11 changed files with 735 additions and 17 deletions.
15 changes: 14 additions & 1 deletion clients/client-mwaa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ AWS SDK for JavaScript MWAA Client for Node.js, Browser and React Native.
<a href="https://docs.aws.amazon.com/mwaa/latest/API/API_CreateWebLoginToken.html">CreateWebLoginToken</a>
</p>
</li>
<li>
<p>
<a href="https://docs.aws.amazon.com/mwaa/latest/API/API_InvokeRestApi.html">InvokeRestApi</a>
</p>
</li>
</ul>
</li>
</ul>
Expand All @@ -83,7 +88,7 @@ AWS SDK for JavaScript MWAA Client for Node.js, Browser and React Native.

## Installing

To install the this package, simply type add or install @aws-sdk/client-mwaa
To install this package, simply type add or install @aws-sdk/client-mwaa
using your favorite package manager:

- `npm install @aws-sdk/client-mwaa`
Expand Down Expand Up @@ -315,6 +320,14 @@ GetEnvironment

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/mwaa/command/GetEnvironmentCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-mwaa/Interface/GetEnvironmentCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-mwaa/Interface/GetEnvironmentCommandOutput/)

</details>
<details>
<summary>
InvokeRestApi
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/mwaa/command/InvokeRestApiCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-mwaa/Interface/InvokeRestApiCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-mwaa/Interface/InvokeRestApiCommandOutput/)

</details>
<details>
<summary>
Expand Down
22 changes: 22 additions & 0 deletions clients/client-mwaa/src/MWAA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import {
GetEnvironmentCommandInput,
GetEnvironmentCommandOutput,
} from "./commands/GetEnvironmentCommand";
import {
InvokeRestApiCommand,
InvokeRestApiCommandInput,
InvokeRestApiCommandOutput,
} from "./commands/InvokeRestApiCommand";
import {
ListEnvironmentsCommand,
ListEnvironmentsCommandInput,
Expand Down Expand Up @@ -61,6 +66,7 @@ const commands = {
CreateWebLoginTokenCommand,
DeleteEnvironmentCommand,
GetEnvironmentCommand,
InvokeRestApiCommand,
ListEnvironmentsCommand,
ListTagsForResourceCommand,
PublishMetricsCommand,
Expand Down Expand Up @@ -149,6 +155,17 @@ export interface MWAA {
cb: (err: any, data?: GetEnvironmentCommandOutput) => void
): void;

/**
* @see {@link InvokeRestApiCommand}
*/
invokeRestApi(args: InvokeRestApiCommandInput, options?: __HttpHandlerOptions): Promise<InvokeRestApiCommandOutput>;
invokeRestApi(args: InvokeRestApiCommandInput, cb: (err: any, data?: InvokeRestApiCommandOutput) => void): void;
invokeRestApi(
args: InvokeRestApiCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: InvokeRestApiCommandOutput) => void
): void;

/**
* @see {@link ListEnvironmentsCommand}
*/
Expand Down Expand Up @@ -305,6 +322,11 @@ export interface MWAA {
* <a href="https://docs.aws.amazon.com/mwaa/latest/API/API_CreateWebLoginToken.html">CreateWebLoginToken</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/mwaa/latest/API/API_InvokeRestApi.html">InvokeRestApi</a>
* </p>
* </li>
* </ul>
* </li>
* </ul>
Expand Down
8 changes: 8 additions & 0 deletions clients/client-mwaa/src/MWAAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
} from "./commands/CreateWebLoginTokenCommand";
import { DeleteEnvironmentCommandInput, DeleteEnvironmentCommandOutput } from "./commands/DeleteEnvironmentCommand";
import { GetEnvironmentCommandInput, GetEnvironmentCommandOutput } from "./commands/GetEnvironmentCommand";
import { InvokeRestApiCommandInput, InvokeRestApiCommandOutput } from "./commands/InvokeRestApiCommand";
import { ListEnvironmentsCommandInput, ListEnvironmentsCommandOutput } from "./commands/ListEnvironmentsCommand";
import {
ListTagsForResourceCommandInput,
Expand Down Expand Up @@ -90,6 +91,7 @@ export type ServiceInputTypes =
| CreateWebLoginTokenCommandInput
| DeleteEnvironmentCommandInput
| GetEnvironmentCommandInput
| InvokeRestApiCommandInput
| ListEnvironmentsCommandInput
| ListTagsForResourceCommandInput
| PublishMetricsCommandInput
Expand All @@ -106,6 +108,7 @@ export type ServiceOutputTypes =
| CreateWebLoginTokenCommandOutput
| DeleteEnvironmentCommandOutput
| GetEnvironmentCommandOutput
| InvokeRestApiCommandOutput
| ListEnvironmentsCommandOutput
| ListTagsForResourceCommandOutput
| PublishMetricsCommandOutput
Expand Down Expand Up @@ -351,6 +354,11 @@ export interface MWAAClientResolvedConfig extends MWAAClientResolvedConfigType {
* <a href="https://docs.aws.amazon.com/mwaa/latest/API/API_CreateWebLoginToken.html">CreateWebLoginToken</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/mwaa/latest/API/API_InvokeRestApi.html">InvokeRestApi</a>
* </p>
* </li>
* </ul>
* </li>
* </ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface CreateEnvironmentCommandInput extends CreateEnvironmentInput {}
export interface CreateEnvironmentCommandOutput extends CreateEnvironmentOutput, __MetadataBearer {}

/**
* <p>Creates an Amazon Managed Workflows for Apache Airflow (MWAA) environment.</p>
* <p>Creates an Amazon Managed Workflows for Apache Airflow (Amazon MWAA) environment.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface DeleteEnvironmentCommandInput extends DeleteEnvironmentInput {}
export interface DeleteEnvironmentCommandOutput extends DeleteEnvironmentOutput, __MetadataBearer {}

/**
* <p>Deletes an Amazon Managed Workflows for Apache Airflow (MWAA) environment.</p>
* <p>Deletes an Amazon Managed Workflows for Apache Airflow (Amazon MWAA) environment.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
152 changes: 152 additions & 0 deletions clients/client-mwaa/src/commands/InvokeRestApiCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { commonParams } from "../endpoint/EndpointParameters";
import {
InvokeRestApiRequest,
InvokeRestApiRequestFilterSensitiveLog,
InvokeRestApiResponse,
InvokeRestApiResponseFilterSensitiveLog,
} from "../models/models_0";
import { MWAAClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../MWAAClient";
import { de_InvokeRestApiCommand, se_InvokeRestApiCommand } from "../protocols/Aws_restJson1";

/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link InvokeRestApiCommand}.
*/
export interface InvokeRestApiCommandInput extends InvokeRestApiRequest {}
/**
* @public
*
* The output of {@link InvokeRestApiCommand}.
*/
export interface InvokeRestApiCommandOutput extends InvokeRestApiResponse, __MetadataBearer {}

/**
* <p>Invokes the Apache Airflow REST API on the webserver with the specified inputs. To
* learn more, see <a href="https://docs.aws.amazon.com/mwaa/latest/userguide/access-mwaa-apache-airflow-rest-api.html">Using the Apache Airflow REST API</a>
* </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { MWAAClient, InvokeRestApiCommand } from "@aws-sdk/client-mwaa"; // ES Modules import
* // const { MWAAClient, InvokeRestApiCommand } = require("@aws-sdk/client-mwaa"); // CommonJS import
* const client = new MWAAClient(config);
* const input = { // InvokeRestApiRequest
* Name: "STRING_VALUE", // required
* Path: "STRING_VALUE", // required
* Method: "STRING_VALUE", // required
* QueryParameters: "DOCUMENT_VALUE",
* Body: "DOCUMENT_VALUE",
* };
* const command = new InvokeRestApiCommand(input);
* const response = await client.send(command);
* // { // InvokeRestApiResponse
* // RestApiStatusCode: Number("int"),
* // RestApiResponse: "DOCUMENT_VALUE",
* // };
*
* ```
*
* @param InvokeRestApiCommandInput - {@link InvokeRestApiCommandInput}
* @returns {@link InvokeRestApiCommandOutput}
* @see {@link InvokeRestApiCommandInput} for command's `input` shape.
* @see {@link InvokeRestApiCommandOutput} for command's `response` shape.
* @see {@link MWAAClientResolvedConfig | config} for MWAAClient's `config` shape.
*
* @throws {@link AccessDeniedException} (client fault)
* <p>Access to the Apache Airflow Web UI or CLI has been denied due to insufficient permissions. To learn more, see <a href="https://docs.aws.amazon.com/mwaa/latest/userguide/access-policies.html">Accessing an Amazon MWAA environment</a>.</p>
*
* @throws {@link InternalServerException} (server fault)
* <p>InternalServerException: An internal error has occurred.</p>
*
* @throws {@link ResourceNotFoundException} (client fault)
* <p>ResourceNotFoundException: The resource is not available.</p>
*
* @throws {@link RestApiClientException} (client fault)
* <p>An exception indicating that a client-side error occurred during the Apache Airflow
* REST API call.</p>
*
* @throws {@link RestApiServerException} (client fault)
* <p>An exception indicating that a server-side error occurred during the Apache Airflow
* REST API call.</p>
*
* @throws {@link ValidationException} (client fault)
* <p>ValidationException: The provided input is not valid.</p>
*
* @throws {@link MWAAServiceException}
* <p>Base exception class for all service exceptions from MWAA service.</p>
*
* @public
* @example Listing Airflow variables.
* ```javascript
* //
* const input = {
* "Method": "GET",
* "Name": "MyEnvironment",
* "Path": "/variables"
* };
* const command = new InvokeRestApiCommand(input);
* const response = await client.send(command);
* /* response ==
* {
* "RestApiResponse": {
* "total_entries": 1,
* "variables": [
* {
* "key": "test-variable",
* "value": "123",
* "description": "Example variable"
* }
* ]
* },
* "RestApiStatusCode": 200
* }
* *\/
* // example id: example-1
* ```
*
*/
export class InvokeRestApiCommand extends $Command
.classBuilder<
InvokeRestApiCommandInput,
InvokeRestApiCommandOutput,
MWAAClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: MWAAClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("AmazonMWAA", "InvokeRestApi", {})
.n("MWAAClient", "InvokeRestApiCommand")
.f(InvokeRestApiRequestFilterSensitiveLog, InvokeRestApiResponseFilterSensitiveLog)
.ser(se_InvokeRestApiCommand)
.de(de_InvokeRestApiCommand)
.build() {
/** @internal type navigation helper, not in runtime. */
protected declare static __types: {
api: {
input: InvokeRestApiRequest;
output: InvokeRestApiResponse;
};
sdk: {
input: InvokeRestApiCommandInput;
output: InvokeRestApiCommandOutput;
};
};
}
1 change: 1 addition & 0 deletions clients/client-mwaa/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from "./CreateEnvironmentCommand";
export * from "./CreateWebLoginTokenCommand";
export * from "./DeleteEnvironmentCommand";
export * from "./GetEnvironmentCommand";
export * from "./InvokeRestApiCommand";
export * from "./ListEnvironmentsCommand";
export * from "./ListTagsForResourceCommand";
export * from "./PublishMetricsCommand";
Expand Down
5 changes: 5 additions & 0 deletions clients/client-mwaa/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
* <a href="https://docs.aws.amazon.com/mwaa/latest/API/API_CreateWebLoginToken.html">CreateWebLoginToken</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/mwaa/latest/API/API_InvokeRestApi.html">InvokeRestApi</a>
* </p>
* </li>
* </ul>
* </li>
* </ul>
Expand Down
Loading

0 comments on commit 180dd23

Please sign in to comment.