|
| 1 | +/** |
| 2 | + * Blockchain Platform Control Plane API |
| 3 | + * Blockchain Platform Plane API |
| 4 | + * OpenAPI spec version: 20191010 |
| 5 | + * |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OracleSDKGenerator. |
| 8 | + * Do not edit the class manually. |
| 9 | + * |
| 10 | + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
| 11 | + * This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. |
| 12 | + */ |
| 13 | + |
| 14 | +import * as serviceRequests from "./request"; |
| 15 | +import * as serviceResponses from "./response"; |
| 16 | +import * as models from "./model"; |
| 17 | +import { BlockchainPlatformClient } from "./client"; |
| 18 | +import { genericWaiter, genericTerminalConditionWaiter, WaiterConfiguration } from "oci-common"; |
| 19 | + |
| 20 | +export class BlockchainPlatformWaiter { |
| 21 | + public constructor( |
| 22 | + private client: BlockchainPlatformClient, |
| 23 | + private readonly config?: WaiterConfiguration |
| 24 | + ) {} |
| 25 | + |
| 26 | + /** |
| 27 | + * Waits forBlockchainPlatform till it reaches any of the provided states |
| 28 | + * |
| 29 | + * @param request the request to send |
| 30 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 31 | + * @return response returns GetBlockchainPlatformResponse | null (null in case of 404 response) |
| 32 | + */ |
| 33 | + public async forBlockchainPlatform( |
| 34 | + request: serviceRequests.GetBlockchainPlatformRequest, |
| 35 | + ...targetStates: models.BlockchainPlatform.LifecycleState[] |
| 36 | + ): Promise<serviceResponses.GetBlockchainPlatformResponse | null> { |
| 37 | + return genericTerminalConditionWaiter( |
| 38 | + this.config, |
| 39 | + () => this.client.getBlockchainPlatform(request), |
| 40 | + response => targetStates.exists(response.blockchainPlatform.lifecycleState), |
| 41 | + targetStates.includes(models.BlockchainPlatform.LifecycleState.DELETED) |
| 42 | + ); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Waits forOsn till it reaches any of the provided states |
| 47 | + * |
| 48 | + * @param request the request to send |
| 49 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 50 | + * @return response returns GetOsnResponse |
| 51 | + */ |
| 52 | + public async forOsn( |
| 53 | + request: serviceRequests.GetOsnRequest, |
| 54 | + ...targetStates: models.Osn.LifecycleState[] |
| 55 | + ): Promise<serviceResponses.GetOsnResponse> { |
| 56 | + return genericWaiter( |
| 57 | + this.config, |
| 58 | + () => this.client.getOsn(request), |
| 59 | + response => targetStates.exists(response.osn.lifecycleState) |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Waits forPeer till it reaches any of the provided states |
| 65 | + * |
| 66 | + * @param request the request to send |
| 67 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 68 | + * @return response returns GetPeerResponse |
| 69 | + */ |
| 70 | + public async forPeer( |
| 71 | + request: serviceRequests.GetPeerRequest, |
| 72 | + ...targetStates: models.Peer.LifecycleState[] |
| 73 | + ): Promise<serviceResponses.GetPeerResponse> { |
| 74 | + return genericWaiter( |
| 75 | + this.config, |
| 76 | + () => this.client.getPeer(request), |
| 77 | + response => targetStates.exists(response.peer.lifecycleState) |
| 78 | + ); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Waits forWorkRequest |
| 83 | + * |
| 84 | + * @param request the request to send |
| 85 | + * @return response returns GetWorkRequestResponse |
| 86 | + */ |
| 87 | + public async forWorkRequest( |
| 88 | + request: serviceRequests.GetWorkRequestRequest |
| 89 | + ): Promise<serviceResponses.GetWorkRequestResponse> { |
| 90 | + return genericWaiter( |
| 91 | + this.config, |
| 92 | + () => this.client.getWorkRequest(request), |
| 93 | + response => (response.workRequest.timeFinished ? true : false) |
| 94 | + ); |
| 95 | + } |
| 96 | +} |
0 commit comments