|
| 1 | +/** |
| 2 | + * Language API |
| 3 | + * OCI Language Service solutions can help enterprise customers integrate AI into their products immediately using our proven, |
| 4 | +pre-trained and custom models or containers, without a need to set up an house team of AI and ML experts. |
| 5 | +This allows enterprises to focus on business drivers and development work rather than AI and ML operations, which shortens the time to market. |
| 6 | +
|
| 7 | + * OpenAPI spec version: 20221001 |
| 8 | + * |
| 9 | + * |
| 10 | + * NOTE: This class is auto generated by OracleSDKGenerator. |
| 11 | + * Do not edit the class manually. |
| 12 | + * |
| 13 | + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. |
| 14 | + * 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. |
| 15 | + */ |
| 16 | + |
| 17 | +import * as serviceRequests from "./request"; |
| 18 | +import * as serviceResponses from "./response"; |
| 19 | +import * as models from "./model"; |
| 20 | +import { AIServiceLanguageClient } from "./client"; |
| 21 | +import { genericWaiter, genericTerminalConditionWaiter, WaiterConfiguration } from "oci-common"; |
| 22 | + |
| 23 | +export class AIServiceLanguageWaiter { |
| 24 | + public constructor( |
| 25 | + private client: AIServiceLanguageClient, |
| 26 | + private readonly config?: WaiterConfiguration |
| 27 | + ) {} |
| 28 | + |
| 29 | + /** |
| 30 | + * Waits forEndpoint till it reaches any of the provided states |
| 31 | + * |
| 32 | + * @param request the request to send |
| 33 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 34 | + * @return response returns GetEndpointResponse | null (null in case of 404 response) |
| 35 | + */ |
| 36 | + public async forEndpoint( |
| 37 | + request: serviceRequests.GetEndpointRequest, |
| 38 | + ...targetStates: models.Endpoint.LifecycleState[] |
| 39 | + ): Promise<serviceResponses.GetEndpointResponse | null> { |
| 40 | + return genericTerminalConditionWaiter( |
| 41 | + this.config, |
| 42 | + () => this.client.getEndpoint(request), |
| 43 | + response => targetStates.includes(response.endpoint.lifecycleState!), |
| 44 | + targetStates.includes(models.Endpoint.LifecycleState.Deleted) |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Waits forModel till it reaches any of the provided states |
| 50 | + * |
| 51 | + * @param request the request to send |
| 52 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 53 | + * @return response returns GetModelResponse | null (null in case of 404 response) |
| 54 | + */ |
| 55 | + public async forModel( |
| 56 | + request: serviceRequests.GetModelRequest, |
| 57 | + ...targetStates: models.Model.LifecycleState[] |
| 58 | + ): Promise<serviceResponses.GetModelResponse | null> { |
| 59 | + return genericTerminalConditionWaiter( |
| 60 | + this.config, |
| 61 | + () => this.client.getModel(request), |
| 62 | + response => targetStates.includes(response.model.lifecycleState!), |
| 63 | + targetStates.includes(models.Model.LifecycleState.Deleted) |
| 64 | + ); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Waits forProject till it reaches any of the provided states |
| 69 | + * |
| 70 | + * @param request the request to send |
| 71 | + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states |
| 72 | + * @return response returns GetProjectResponse | null (null in case of 404 response) |
| 73 | + */ |
| 74 | + public async forProject( |
| 75 | + request: serviceRequests.GetProjectRequest, |
| 76 | + ...targetStates: models.Project.LifecycleState[] |
| 77 | + ): Promise<serviceResponses.GetProjectResponse | null> { |
| 78 | + return genericTerminalConditionWaiter( |
| 79 | + this.config, |
| 80 | + () => this.client.getProject(request), |
| 81 | + response => targetStates.includes(response.project.lifecycleState!), |
| 82 | + targetStates.includes(models.Project.LifecycleState.Deleted) |
| 83 | + ); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Waits forWorkRequest |
| 88 | + * |
| 89 | + * @param request the request to send |
| 90 | + * @return response returns GetWorkRequestResponse |
| 91 | + */ |
| 92 | + public async forWorkRequest( |
| 93 | + request: serviceRequests.GetWorkRequestRequest |
| 94 | + ): Promise<serviceResponses.GetWorkRequestResponse> { |
| 95 | + return genericWaiter( |
| 96 | + this.config, |
| 97 | + () => this.client.getWorkRequest(request), |
| 98 | + response => (response.workRequest.timeFinished ? true : false) |
| 99 | + ); |
| 100 | + } |
| 101 | +} |
0 commit comments