|
| 1 | +/** |
| 2 | + * Batch API |
| 3 | + * Use the Batch Control Plane API to encapsulate and manage all aspects of computationally intensive jobs. |
| 4 | + * OpenAPI spec version: 20251031 |
| 5 | + * |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OracleSDKGenerator. |
| 8 | + * Do not edit the class manually. |
| 9 | + * |
| 10 | + * Copyright (c) 2020, 2025, 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 { BatchComputingClient } from "./client"; |
| 18 | +import { genericWaiter, genericTerminalConditionWaiter, WaiterConfiguration } from "oci-common"; |
| 19 | + |
| 20 | +export class BatchComputingWaiter { |
| 21 | + public constructor( |
| 22 | + private client: BatchComputingClient, |
| 23 | + private readonly config?: WaiterConfiguration |
| 24 | + ) {} |
| 25 | + |
| 26 | + /** |
| 27 | + * Waits forBatchContext 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 GetBatchContextResponse | null (null in case of 404 response) |
| 32 | + */ |
| 33 | + public async forBatchContext( |
| 34 | + request: serviceRequests.GetBatchContextRequest, |
| 35 | + ...targetStates: models.BatchContext.LifecycleState[] |
| 36 | + ): Promise<serviceResponses.GetBatchContextResponse | null> { |
| 37 | + return genericTerminalConditionWaiter( |
| 38 | + this.config, |
| 39 | + () => this.client.getBatchContext(request), |
| 40 | + response => targetStates.includes(response.batchContext.lifecycleState!), |
| 41 | + targetStates.includes(models.BatchContext.LifecycleState.Deleted) |
| 42 | + ); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Waits forBatchJob 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 GetBatchJobResponse |
| 51 | + */ |
| 52 | + public async forBatchJob( |
| 53 | + request: serviceRequests.GetBatchJobRequest, |
| 54 | + ...targetStates: models.BatchJob.LifecycleState[] |
| 55 | + ): Promise<serviceResponses.GetBatchJobResponse> { |
| 56 | + return genericWaiter( |
| 57 | + this.config, |
| 58 | + () => this.client.getBatchJob(request), |
| 59 | + response => targetStates.includes(response.batchJob.lifecycleState!) |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Waits forBatchJobPool 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 GetBatchJobPoolResponse | null (null in case of 404 response) |
| 69 | + */ |
| 70 | + public async forBatchJobPool( |
| 71 | + request: serviceRequests.GetBatchJobPoolRequest, |
| 72 | + ...targetStates: models.BatchJobPool.LifecycleState[] |
| 73 | + ): Promise<serviceResponses.GetBatchJobPoolResponse | null> { |
| 74 | + return genericTerminalConditionWaiter( |
| 75 | + this.config, |
| 76 | + () => this.client.getBatchJobPool(request), |
| 77 | + response => targetStates.includes(response.batchJobPool.lifecycleState!), |
| 78 | + targetStates.includes(models.BatchJobPool.LifecycleState.Deleted) |
| 79 | + ); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Waits forBatchTask till it reaches any of the provided states |
| 84 | + * |
| 85 | + * @param request the request to send |
| 86 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 87 | + * @return response returns GetBatchTaskResponse |
| 88 | + */ |
| 89 | + public async forBatchTask( |
| 90 | + request: serviceRequests.GetBatchTaskRequest, |
| 91 | + ...targetStates: models.BatchTask.LifecycleState[] |
| 92 | + ): Promise<serviceResponses.GetBatchTaskResponse> { |
| 93 | + return genericWaiter( |
| 94 | + this.config, |
| 95 | + () => this.client.getBatchTask(request), |
| 96 | + response => targetStates.includes(response.batchTask.lifecycleState!) |
| 97 | + ); |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Waits forBatchTaskEnvironment till it reaches any of the provided states |
| 102 | + * |
| 103 | + * @param request the request to send |
| 104 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 105 | + * @return response returns GetBatchTaskEnvironmentResponse | null (null in case of 404 response) |
| 106 | + */ |
| 107 | + public async forBatchTaskEnvironment( |
| 108 | + request: serviceRequests.GetBatchTaskEnvironmentRequest, |
| 109 | + ...targetStates: models.BatchTaskEnvironment.LifecycleState[] |
| 110 | + ): Promise<serviceResponses.GetBatchTaskEnvironmentResponse | null> { |
| 111 | + return genericTerminalConditionWaiter( |
| 112 | + this.config, |
| 113 | + () => this.client.getBatchTaskEnvironment(request), |
| 114 | + response => targetStates.includes(response.batchTaskEnvironment.lifecycleState!), |
| 115 | + targetStates.includes(models.BatchTaskEnvironment.LifecycleState.Deleted) |
| 116 | + ); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Waits forBatchTaskProfile till it reaches any of the provided states |
| 121 | + * |
| 122 | + * @param request the request to send |
| 123 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 124 | + * @return response returns GetBatchTaskProfileResponse | null (null in case of 404 response) |
| 125 | + */ |
| 126 | + public async forBatchTaskProfile( |
| 127 | + request: serviceRequests.GetBatchTaskProfileRequest, |
| 128 | + ...targetStates: models.BatchTaskProfile.LifecycleState[] |
| 129 | + ): Promise<serviceResponses.GetBatchTaskProfileResponse | null> { |
| 130 | + return genericTerminalConditionWaiter( |
| 131 | + this.config, |
| 132 | + () => this.client.getBatchTaskProfile(request), |
| 133 | + response => targetStates.includes(response.batchTaskProfile.lifecycleState!), |
| 134 | + targetStates.includes(models.BatchTaskProfile.LifecycleState.Deleted) |
| 135 | + ); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Waits forWorkRequest |
| 140 | + * |
| 141 | + * @param request the request to send |
| 142 | + * @return response returns GetWorkRequestResponse |
| 143 | + */ |
| 144 | + public async forWorkRequest( |
| 145 | + request: serviceRequests.GetWorkRequestRequest |
| 146 | + ): Promise<serviceResponses.GetWorkRequestResponse> { |
| 147 | + return genericWaiter( |
| 148 | + this.config, |
| 149 | + () => this.client.getWorkRequest(request), |
| 150 | + response => (response.workRequest.timeFinished ? true : false) |
| 151 | + ); |
| 152 | + } |
| 153 | +} |
0 commit comments