1 | import { HttpOperationResponse, RequestOptionsBase, RestError, WebResource } from "@azure/ms-rest-js";
|
2 | import { AzureServiceClient } from "./azureServiceClient";
|
3 | import { LongRunningOperationStates } from "./util/constants";
|
4 | export declare type LROPollStrategyType = "AzureAsyncOperation" | "Location" | "GetResource";
|
5 | export interface LROPollState {
|
6 | pollStrategyType: LROPollStrategyType;
|
7 | initialResponse: HttpOperationResponse;
|
8 | state: LongRunningOperationStates;
|
9 | mostRecentRequest: WebResource;
|
10 | mostRecentResponse: HttpOperationResponse;
|
11 | resource: any;
|
12 | azureAsyncOperationHeaderValue?: string;
|
13 | locationHeaderValue?: string;
|
14 | options?: RequestOptionsBase;
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 | export declare abstract class LROPollStrategy {
|
20 | private readonly _azureServiceClient;
|
21 | protected readonly _pollState: LROPollState;
|
22 | constructor(_azureServiceClient: AzureServiceClient, _pollState: LROPollState);
|
23 | getOperationStatus(): LongRunningOperationStates;
|
24 | /**
|
25 | * Get whether or not this poll strategy's LRO is finished.
|
26 | * @returns Whether or not this poll strategy's LRO is finished.
|
27 | */
|
28 | isFinished(): boolean;
|
29 | /**
|
30 | * Send poll requests that check the LRO's status until it is determined that the LRO is finished.
|
31 | * @returns Whether or not the LRO succeeded.
|
32 | */
|
33 | pollUntilFinished(): Promise<boolean>;
|
34 | /**
|
35 | * Send a single poll request that checks the LRO's status and return the response. If the LRO is
|
36 | * finished, then no request will be sent and the last response received will be returned.
|
37 | */
|
38 | abstract sendPollRequest(): Promise<void>;
|
39 | abstract isFinalStatusAcceptable(): boolean;
|
40 | protected shouldDoFinalGetResourceRequest(): boolean;
|
41 | protected abstract doFinalGetResourceRequest(): Promise<void>;
|
42 | getMostRecentResponse(): HttpOperationResponse;
|
43 | getOperationResponse(): Promise<HttpOperationResponse>;
|
44 | getRestError(): RestError;
|
45 | protected updateState(url: string, shouldDeserialize: boolean | ((response: HttpOperationResponse) => boolean)): Promise<void>;
|
46 | /**
|
47 | * Retrieves operation status by querying the operation URL.
|
48 | * @param {string} statusUrl URL used to poll operation result.
|
49 | */
|
50 | protected updateOperationStatus(statusUrl: string, shouldDeserialize: boolean | ((response: HttpOperationResponse) => boolean)): Promise<HttpOperationResponse>;
|
51 | getPollState(): LROPollState;
|
52 | }
|
53 | export declare function getDelayInSeconds(azureServiceClient: AzureServiceClient, previousResponse: HttpOperationResponse): number;
|
54 | /**
|
55 | * Get whether or not a long-running operation with the provided status is finished.
|
56 | * @param status The current status of a long-running operation.
|
57 | * @returns Whether or not a long-running operation with the provided status is finished.
|
58 | */
|
59 | export declare function isFinished(status: LongRunningOperationStates): boolean;
|
60 | export declare function longRunningOperationStatesEqual(lhs: LongRunningOperationStates, rhs: LongRunningOperationStates): boolean;
|
61 | /**
|
62 | * Create a new long-running operation polling strategy based on the provided initial response.
|
63 | * @param initialResponse The initial response to the long-running operation's initial request.
|
64 | * @param azureServiceClient The AzureServiceClient that was used to send the initial request.
|
65 | * @param options Any options that were provided to the initial request.
|
66 | */
|
67 | export declare function createLROPollStrategyFromInitialResponse(initialResponse: HttpOperationResponse, azureServiceClient: AzureServiceClient, options?: RequestOptionsBase): LROPollStrategy | undefined;
|
68 | export declare function createLROPollStrategyFromPollState(azureServiceClient: AzureServiceClient, lroPollState: LROPollState): LROPollStrategy | undefined;
|
69 | //# sourceMappingURL=lroPollStrategy.d.ts.map |
\ | No newline at end of file |