requestPolicy.d.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { HttpOperationResponse } from "../httpOperationResponse";
  2. import { HttpPipelineLogger } from "../httpPipelineLogger";
  3. import { HttpPipelineLogLevel } from "../httpPipelineLogLevel";
  4. import { WebResource } from "../webResource";
  5. /**
  6. * Creates a new RequestPolicy per-request that uses the provided nextPolicy.
  7. */
  8. export declare type RequestPolicyFactory = {
  9. create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): RequestPolicy;
  10. };
  11. export interface RequestPolicy {
  12. sendRequest(httpRequest: WebResource): Promise<HttpOperationResponse>;
  13. }
  14. export declare abstract class BaseRequestPolicy implements RequestPolicy {
  15. readonly _nextPolicy: RequestPolicy;
  16. readonly _options: RequestPolicyOptions;
  17. protected constructor(_nextPolicy: RequestPolicy, _options: RequestPolicyOptions);
  18. abstract sendRequest(webResource: WebResource): 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. */
  36. export declare class RequestPolicyOptions {
  37. private _logger?;
  38. constructor(_logger?: HttpPipelineLogger | undefined);
  39. /**
  40. * Get whether or not a log with the provided log level should be logged.
  41. * @param logLevel The log level of the log that will be logged.
  42. * @returns Whether or not a log with the provided log level should be logged.
  43. */
  44. shouldLog(logLevel: HttpPipelineLogLevel): boolean;
  45. /**
  46. * Attempt to log the provided message to the provided logger. If no logger was provided or if
  47. * the log level does not meat the logger's threshold, then nothing will be logged.
  48. * @param logLevel The log level of this log.
  49. * @param message The message of this log.
  50. */
  51. log(logLevel: HttpPipelineLogLevel, message: string): void;
  52. }
  53. //# sourceMappingURL=requestPolicy.d.ts.map