-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client-neptune-graph): Adds Waiters for successful creation and …
…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
Showing
12 changed files
with
776 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
64
clients/client-neptune-graph/src/waiters/waitForGraphAvailable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
51
clients/client-neptune-graph/src/waiters/waitForGraphDeleted.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
64 changes: 64 additions & 0 deletions
64
clients/client-neptune-graph/src/waiters/waitForGraphSnapshotAvailable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
51 changes: 51 additions & 0 deletions
51
clients/client-neptune-graph/src/waiters/waitForGraphSnapshotDeleted.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
56 changes: 56 additions & 0 deletions
56
clients/client-neptune-graph/src/waiters/waitForImportTaskCancelled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
80 changes: 80 additions & 0 deletions
80
clients/client-neptune-graph/src/waiters/waitForImportTaskSuccessful.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
Oops, something went wrong.