UNPKG

3.33 kBTypeScriptView Raw
1import { HttpOperationResponse } from "../httpOperationResponse";
2import { HttpPipelineLogger } from "../httpPipelineLogger";
3import { HttpPipelineLogLevel } from "../httpPipelineLogLevel";
4import { WebResourceLike } from "../webResource";
5/**
6 * Creates a new RequestPolicy per-request that uses the provided nextPolicy.
7 */
8export declare type RequestPolicyFactory = {
9 create(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike): RequestPolicy;
10};
11export interface RequestPolicy {
12 sendRequest(httpRequest: WebResourceLike): Promise<HttpOperationResponse>;
13}
14export declare abstract class BaseRequestPolicy implements RequestPolicy {
15 readonly _nextPolicy: RequestPolicy;
16 readonly _options: RequestPolicyOptionsLike;
17 protected constructor(_nextPolicy: RequestPolicy, _options: RequestPolicyOptionsLike);
18 abstract sendRequest(webResource: WebResourceLike): Promise<HttpOperationResponse>;
19 /**
20 * Get whether or not a log with the provided log level should be logged.
21 * @param logLevel The log level of the log that will be logged.
22 * @returns Whether or not a log with the provided log level should be logged.
23 */
24 shouldLog(logLevel: HttpPipelineLogLevel): boolean;
25 /**
26 * Attempt to log the provided message to the provided logger. If no logger was provided or if
27 * the log level does not meat the logger's threshold, then nothing will be logged.
28 * @param logLevel The log level of this log.
29 * @param message The message of this log.
30 */
31 log(logLevel: HttpPipelineLogLevel, message: string): void;
32}
33/**
34 * Optional properties that can be used when creating a RequestPolicy.
35 */
36export interface RequestPolicyOptionsLike {
37 /**
38 * Get whether or not a log with the provided log level should be logged.
39 * @param logLevel The log level of the log that will be logged.
40 * @returns Whether or not a log with the provided log level should be logged.
41 */
42 shouldLog(logLevel: HttpPipelineLogLevel): boolean;
43 /**
44 * Attempt to log the provided message to the provided logger. If no logger was provided or if
45 * the log level does not meet the logger's threshold, then nothing will be logged.
46 * @param logLevel The log level of this log.
47 * @param message The message of this log.
48 */
49 log(logLevel: HttpPipelineLogLevel, message: string): void;
50}
51/**
52 * Optional properties that can be used when creating a RequestPolicy.
53 */
54export declare class RequestPolicyOptions implements RequestPolicyOptionsLike {
55 private _logger?;
56 constructor(_logger?: HttpPipelineLogger | undefined);
57 /**
58 * Get whether or not a log with the provided log level should be logged.
59 * @param logLevel The log level of the log that will be logged.
60 * @returns Whether or not a log with the provided log level should be logged.
61 */
62 shouldLog(logLevel: HttpPipelineLogLevel): boolean;
63 /**
64 * Attempt to log the provided message to the provided logger. If no logger was provided or if
65 * the log level does not meat the logger's threshold, then nothing will be logged.
66 * @param logLevel The log level of this log.
67 * @param message The message of this log.
68 */
69 log(logLevel: HttpPipelineLogLevel, message: string): void;
70}
71//# sourceMappingURL=requestPolicy.d.ts.map
\No newline at end of file