<commit_before>import * as stream from 'stream';
import * as http from 'http';

/**
 * REST request options
 *
 * @property {object.<string, string>} customHeaders - Any additional HTTP headers to be added to the request
 * @proprerty {boolean} [jar] - If true, remember cookies for future use
 */
export interface RequestOptions {
  customHeaders?: { [headerName: string]: string; };
}

export interface ClientRequestOptions extends RequestOptions {
  jar?: boolean;
}

/**
 * HttpResponse wrapper that encapsulates the
 * response stream plus available status codes/messages
 *
 * @property {Object} headers       - response headers returned from the server, duplicate filtered
 *                                    as described in https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_message_headers
 * @property {Array} [rawHeaders]   - Original unprocessed response headers
 * @property {Number} statusCode    - HTTP status code for response
 * @property {String} statusMessage - HTTP status response message
 */
export interface Response extends stream.Readable {
  headers: any;
  rawHeaders: string[];
  statusCode: number;
  statusMessage: string;
}

/**
 * HttpOperationResponse wrapper that provides the raw request, raw response and the deserialized response body.
 *
 * @property {WebResource} request  - The raw request object
 * @property {stream} response - The response stream
 * @property {T} body - The deserialized response body of the expected type.
 */
export interface HttpOperationResponse<T> {
  request: WebResource;
  response: Response;
  body: T;
}

/**
 * Service client options, used for all REST requests initiated by the service client.
 *
 * @property {Array} [filters]                  - Filters to be added to the request pipeline
 * @property {ClientRequestOptions} requestOptions    - Default ClientRequestOptions to use for requests
 * @property {boolean}  noRetryPolicy           - If set to true, turn off default retry policy
 */
export interface ServiceClientOptions {
  filters?: any[];
  requestOptions?: ClientRequestOptions;
  noRetryPolicy?: boolean;
}

export class ServiceClient {
  /**
   * Initializes a new instance of the ServiceClient class.
   *
   * @param {ServiceClientCredentials} [credentials]    - BasicAuthenticationCredentials or
   * TokenCredentials object used for authentication.
   * @param {ServiceClientOptions} [options] The parameter options
   */
  constructor(credentials?: ServiceClientCredentials, options?: ServiceClientOptions);

  /**
   * Attempts to find package.json for the given azure nodejs package.
   * If found, returns the name and version of the package by reading the package.json
   * If package.json is not found, returns a default value.
   * @param {string} managementClientDir - pass the directory of the specific azure management client.
   * @returns {object} packageJsonInfo - "name" and "version" of the desired package.
   */
  getPackageJsonInfo(managementClientDir: string): { name: string, version: string };

  /**
   * Adds custom information to user agent header
   * @param {any} additionalUserAgentInfo - information to be added to user agent header, as string.
   */
  addUserAgentInfo(additionalUserAgentInfo: any): void;

  sendRequest<TResult>(options: PathTemplateBasedRequestPrepareOptions | UrlBasedRequestPrepareOptions, callback: ServiceCallback<TResult>): void;
  sendRequest<TResult>(options: PathTemplateBasedRequestPrepareOptions | UrlBasedRequestPrepareOptions): Promise<TResult>;
  sendRequestWithHttpOperationResponse<TResult>(options: PathTemplateBasedRequestPrepareOptions | UrlBasedRequestPrepareOptions): Promise<HttpOperationResponse<TResult>>;
}

/**
 * Service Error that is returned when an error occurrs in executing the REST request initiated by the service client.
 *
 * @property {number} [statusCode]             - The response status code received from the server as a result of making the request.
 * @property {WebResource} request             - The raw/actual request sent to the server.
 * @property {http.IncomingMessage}  response  - The raw/actual response from the server.<commit_msg>Updated as per review comments<commit_after>import * as stream from 'stream';
import * as http from 'http';
export { IncomingMessage } from 'http';

/**
 * REST request options
 *
 * @property {object.<string, string>} customHeaders - Any additional HTTP headers to be added to the request
 * @proprerty {boolean} [jar] - If true, remember cookies for future use
 */
export interface RequestOptions {
  customHeaders?: { [headerName: string]: string; };
}

export interface ClientRequestOptions extends RequestOptions {
  jar?: boolean;
}

/**
 * HttpOperationResponse wrapper that provides the raw request, raw response and the deserialized response body.
 *
 * @property {WebResource} request  - The raw request object
 * @property {http.IncomingMessage} response - The response from the http call
 * @property {T} body - The deserialized response body of the expected type.
 */
export interface HttpOperationResponse<T> {
  request: WebResource;
  response: http.IncomingMessage;
  body: T;
}

/**
 * Service client options, used for all REST requests initiated by the service client.
 *
 * @property {Array} [filters]                  - Filters to be added to the request pipeline
 * @property {ClientRequestOptions} requestOptions    - Default ClientRequestOptions to use for requests
 * @property {boolean}  noRetryPolicy           - If set to true, turn off default retry policy
 */
export interface ServiceClientOptions {
  filters?: any[];
  requestOptions?: ClientRequestOptions;
  noRetryPolicy?: boolean;
}

export class ServiceClient {
  /**
   * Initializes a new instance of the ServiceClient class.
   *
   * @param {ServiceClientCredentials} [credentials]    - BasicAuthenticationCredentials or
   * TokenCredentials object used for authentication.
   * @param {ServiceClientOptions} [options] The parameter options
   */
  constructor(credentials?: ServiceClientCredentials, options?: ServiceClientOptions);

  /**
   * Attempts to find package.json for the given azure nodejs package.
   * If found, returns the name and version of the package by reading the package.json
   * If package.json is not found, returns a default value.
   * @param {string} managementClientDir - pass the directory of the specific azure management client.
   * @returns {object} packageJsonInfo - "name" and "version" of the desired package.
   */
  getPackageJsonInfo(managementClientDir: string): { name: string, version: string };

  /**
   * Adds custom information to user agent header
   * @param {any} additionalUserAgentInfo - information to be added to user agent header, as string.
   */
  addUserAgentInfo(additionalUserAgentInfo: any): void;

  sendRequest<TResult>(options: PathTemplateBasedRequestPrepareOptions | UrlBasedRequestPrepareOptions, callback: ServiceCallback<TResult>): void;
  sendRequest<TResult>(options: PathTemplateBasedRequestPrepareOptions | UrlBasedRequestPrepareOptions): Promise<TResult>;
  sendRequestWithHttpOperationResponse<TResult>(options: PathTemplateBasedRequestPrepareOptions | UrlBasedRequestPrepareOptions): Promise<HttpOperationResponse<TResult>>;
}

/**
 * Service Error that is returned when an error occurrs in executing the REST request initiated by the service client.
 *
 * @property {number} [statusCode]             - The response status code received from the server as a result of making the request.
 * @property {WebResource} request             - The raw/actual request sent to the server.
 * @property {http.IncomingMessage} response   - The raw/actual response from the server.
{'fraction_non_alphanumeric': 0.08206330597889801, 'fraction_numerical': 0.00013025921583952066, 'mean_word_length': 4.3171745152354575, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5294241', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1901, 'n_words': 745}