Skip to content

Commit

Permalink
feat(client-neptune-graph): Adds Waiters for successful creation and …
Browse files Browse the repository at this point in the history
…deletion of Graph, Graph Snapshot, Import Task and Private Endpoints for Neptune Analytics
  • Loading branch information
awstools committed Dec 21, 2023
1 parent 64c731e commit d4176b5
Show file tree
Hide file tree
Showing 12 changed files with 776 additions and 0 deletions.
1 change: 1 addition & 0 deletions clients/client-neptune-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@smithy/util-endpoints": "^1.0.7",
"@smithy/util-retry": "^2.0.8",
"@smithy/util-utf8": "^2.0.2",
"@smithy/util-waiter": "^2.0.15",
"tslib": "^2.5.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions clients/client-neptune-graph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { RuntimeExtension } from "./runtimeExtensions";
export { NeptuneGraphExtensionConfiguration } from "./extensionConfiguration";
export * from "./commands";
export * from "./pagination";
export * from "./waiters";
export * from "./models";

import "@aws-sdk/util-endpoints";
Expand Down
9 changes: 9 additions & 0 deletions clients/client-neptune-graph/src/waiters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// smithy-typescript generated code
export * from "./waitForGraphAvailable";
export * from "./waitForGraphDeleted";
export * from "./waitForGraphSnapshotAvailable";
export * from "./waitForGraphSnapshotDeleted";
export * from "./waitForImportTaskCancelled";
export * from "./waitForImportTaskSuccessful";
export * from "./waitForPrivateGraphEndpointAvailable";
export * from "./waitForPrivateGraphEndpointDeleted";
64 changes: 64 additions & 0 deletions clients/client-neptune-graph/src/waiters/waitForGraphAvailable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";

import { GetGraphCommand, GetGraphCommandInput } from "../commands/GetGraphCommand";
import { NeptuneGraphClient } from "../NeptuneGraphClient";

const checkState = async (client: NeptuneGraphClient, input: GetGraphCommandInput): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new GetGraphCommand(input));
reason = result;
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "DELETING") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "FAILED") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "AVAILABLE") {
return { state: WaiterState.SUCCESS, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
}
return { state: WaiterState.RETRY, reason };
};
/**
* Wait until Graph is Available
* @deprecated Use waitUntilGraphAvailable instead. waitForGraphAvailable does not throw error in non-success cases.
*/
export const waitForGraphAvailable = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 28800 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
* Wait until Graph is Available
* @param params - Waiter configuration options.
* @param input - The input to GetGraphCommand for polling.
*/
export const waitUntilGraphAvailable = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 28800 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};
51 changes: 51 additions & 0 deletions clients/client-neptune-graph/src/waiters/waitForGraphDeleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";

import { GetGraphCommand, GetGraphCommandInput } from "../commands/GetGraphCommand";
import { NeptuneGraphClient } from "../NeptuneGraphClient";

const checkState = async (client: NeptuneGraphClient, input: GetGraphCommandInput): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new GetGraphCommand(input));
reason = result;
try {
const returnComparator = () => {
return result.status != "DELETING";
};
if (returnComparator() == true) {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
if (exception.name && exception.name == "ResourceNotFoundException") {
return { state: WaiterState.SUCCESS, reason };
}
}
return { state: WaiterState.RETRY, reason };
};
/**
* Wait until Graph is Deleted
* @deprecated Use waitUntilGraphDeleted instead. waitForGraphDeleted does not throw error in non-success cases.
*/
export const waitForGraphDeleted = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 3600 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
* Wait until Graph is Deleted
* @param params - Waiter configuration options.
* @param input - The input to GetGraphCommand for polling.
*/
export const waitUntilGraphDeleted = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 3600 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";

import { GetGraphSnapshotCommand, GetGraphSnapshotCommandInput } from "../commands/GetGraphSnapshotCommand";
import { NeptuneGraphClient } from "../NeptuneGraphClient";

const checkState = async (client: NeptuneGraphClient, input: GetGraphSnapshotCommandInput): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new GetGraphSnapshotCommand(input));
reason = result;
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "DELETING") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "FAILED") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "AVAILABLE") {
return { state: WaiterState.SUCCESS, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
}
return { state: WaiterState.RETRY, reason };
};
/**
* Wait until GraphSnapshot is Available
* @deprecated Use waitUntilGraphSnapshotAvailable instead. waitForGraphSnapshotAvailable does not throw error in non-success cases.
*/
export const waitForGraphSnapshotAvailable = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphSnapshotCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 7200 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
* Wait until GraphSnapshot is Available
* @param params - Waiter configuration options.
* @param input - The input to GetGraphSnapshotCommand for polling.
*/
export const waitUntilGraphSnapshotAvailable = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphSnapshotCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 7200 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";

import { GetGraphSnapshotCommand, GetGraphSnapshotCommandInput } from "../commands/GetGraphSnapshotCommand";
import { NeptuneGraphClient } from "../NeptuneGraphClient";

const checkState = async (client: NeptuneGraphClient, input: GetGraphSnapshotCommandInput): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new GetGraphSnapshotCommand(input));
reason = result;
try {
const returnComparator = () => {
return result.status != "DELETING";
};
if (returnComparator() == true) {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
if (exception.name && exception.name == "ResourceNotFoundException") {
return { state: WaiterState.SUCCESS, reason };
}
}
return { state: WaiterState.RETRY, reason };
};
/**
* Wait until GraphSnapshot is Deleted
* @deprecated Use waitUntilGraphSnapshotDeleted instead. waitForGraphSnapshotDeleted does not throw error in non-success cases.
*/
export const waitForGraphSnapshotDeleted = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphSnapshotCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 3600 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
* Wait until GraphSnapshot is Deleted
* @param params - Waiter configuration options.
* @param input - The input to GetGraphSnapshotCommand for polling.
*/
export const waitUntilGraphSnapshotDeleted = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetGraphSnapshotCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 3600 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";

import { GetImportTaskCommand, GetImportTaskCommandInput } from "../commands/GetImportTaskCommand";
import { NeptuneGraphClient } from "../NeptuneGraphClient";

const checkState = async (client: NeptuneGraphClient, input: GetImportTaskCommandInput): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new GetImportTaskCommand(input));
reason = result;
try {
const returnComparator = () => {
return result.status != "CANCELLING";
};
if (returnComparator() == true) {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "CANCELLED") {
return { state: WaiterState.SUCCESS, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
}
return { state: WaiterState.RETRY, reason };
};
/**
* Wait until Import Task is Cancelled
* @deprecated Use waitUntilImportTaskCancelled instead. waitForImportTaskCancelled does not throw error in non-success cases.
*/
export const waitForImportTaskCancelled = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetImportTaskCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 3600 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
* Wait until Import Task is Cancelled
* @param params - Waiter configuration options.
* @param input - The input to GetImportTaskCommand for polling.
*/
export const waitUntilImportTaskCancelled = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetImportTaskCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 3600 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";

import { GetImportTaskCommand, GetImportTaskCommandInput } from "../commands/GetImportTaskCommand";
import { NeptuneGraphClient } from "../NeptuneGraphClient";

const checkState = async (client: NeptuneGraphClient, input: GetImportTaskCommandInput): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new GetImportTaskCommand(input));
reason = result;
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "CANCELLING") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "CANCELLED") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "ROLLING_BACK") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "FAILED") {
return { state: WaiterState.FAILURE, reason };
}
} catch (e) {}
try {
const returnComparator = () => {
return result.status;
};
if (returnComparator() === "SUCCEEDED") {
return { state: WaiterState.SUCCESS, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
}
return { state: WaiterState.RETRY, reason };
};
/**
* Wait until Import Task is Successful
* @deprecated Use waitUntilImportTaskSuccessful instead. waitForImportTaskSuccessful does not throw error in non-success cases.
*/
export const waitForImportTaskSuccessful = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetImportTaskCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 28800 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
* Wait until Import Task is Successful
* @param params - Waiter configuration options.
* @param input - The input to GetImportTaskCommand for polling.
*/
export const waitUntilImportTaskSuccessful = async (
params: WaiterConfiguration<NeptuneGraphClient>,
input: GetImportTaskCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 60, maxDelay: 28800 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};
Loading

0 comments on commit d4176b5

Please sign in to comment.