import { checkExceptions , createWaiter , WaiterConfiguration , WaiterResult , WaiterState } from "@aws-sdk/util-waiter" ; import { AmpClient } from "../AmpClient" ; import { DescribeWorkspaceCommand , DescribeWorkspaceCommandInput } from "../commands/DescribeWorkspaceCommand" ; const checkState = async ( client , input ) : Promise < WaiterResult > => { let reason ; try { const result = await client . send ( new DescribeWorkspaceCommand ( input ) ) ; reason = result ; try { const returnComparator = ( ) => { return result . workspace . status . statusCode ; } ; if ( returnComparator ( ) === "ACTIVE" ) { return { state : WaiterState . SUCCESS , reason } ; } } catch ( e ) { } try { const returnComparator = ( ) => { return result . workspace . status . statusCode ; } ; if ( returnComparator ( ) === "UPDATING" ) { return { state : WaiterState . RETRY , reason } ; } } catch ( e ) { } try { const returnComparator = ( ) => { return result . workspace . status . statusCode ; } ; if ( returnComparator ( ) === "CREATING" ) { return { state : WaiterState . RETRY , reason } ; } } catch ( e ) { } } catch ( exception ) { reason = exception ; } return { state : WaiterState . RETRY , reason } ; } ; deprecated export const waitForWorkspaceActive = async ( params , input ) : Promise < WaiterResult > => { const serviceDefaults = { minDelay : 2 , maxDelay : 120 } ; return createWaiter ( { ... serviceDefaults , ... params } , input , checkState ) ; } ; param params param input export const waitUntilWorkspaceActive = async ( params , input ) : Promise < WaiterResult > => { const serviceDefaults = { minDelay : 2 , maxDelay : 120 } ; const result = await createWaiter ( { ... serviceDefaults , ... params } , input , checkState ) ; return checkExceptions ( result ) ; } ;