@azure-rest/core-client
Advanced tools
Comparing version 1.0.0-alpha.20220204.4 to 1.0.0-alpha.20220211.1
@@ -30,28 +30,28 @@ // Copyright (c) Microsoft Corporation. | ||
} | ||
const { allowInsecureConnection } = clientOptions; | ||
const { allowInsecureConnection, httpClient } = clientOptions; | ||
const client = (path, ...args) => { | ||
return { | ||
get: (options = {}) => { | ||
return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
post: (options = {}) => { | ||
return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
put: (options = {}) => { | ||
return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
patch: (options = {}) => { | ||
return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
delete: (options = {}) => { | ||
return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
head: (options = {}) => { | ||
return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
options: (options = {}) => { | ||
return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
trace: (options = {}) => { | ||
return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
@@ -66,6 +66,6 @@ }; | ||
} | ||
function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = []) { | ||
function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = [], httpClient) { | ||
// If the client has an api-version and the request doesn't specify one, inject the one in the client options | ||
const url = buildRequestUrl(baseUrl, path, args, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions, httpClient); | ||
} | ||
@@ -72,0 +72,0 @@ function isCredential(param) { |
@@ -12,6 +12,7 @@ // Copyright (c) Microsoft Corporation. | ||
* @param options - request options | ||
* @param customHttpClient - a custom HttpClient to use when making the request | ||
* @returns returns and HttpResponse | ||
*/ | ||
export async function sendRequest(method, url, pipeline, options = {}) { | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
export async function sendRequest(method, url, pipeline, options = {}, customHttpClient) { | ||
const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient(); | ||
const request = buildPipelineRequest(method, url, options); | ||
@@ -18,0 +19,0 @@ const response = await pipeline.sendRequest(httpClient, request); |
@@ -199,6 +199,7 @@ 'use strict'; | ||
* @param options - request options | ||
* @param customHttpClient - a custom HttpClient to use when making the request | ||
* @returns returns and HttpResponse | ||
*/ | ||
async function sendRequest(method, url, pipeline, options = {}) { | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
async function sendRequest(method, url, pipeline, options = {}, customHttpClient) { | ||
const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient(); | ||
const request = buildPipelineRequest(method, url, options); | ||
@@ -455,28 +456,28 @@ const response = await pipeline.sendRequest(httpClient, request); | ||
} | ||
const { allowInsecureConnection } = clientOptions; | ||
const { allowInsecureConnection, httpClient } = clientOptions; | ||
const client = (path, ...args) => { | ||
return { | ||
get: (options = {}) => { | ||
return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("GET", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
post: (options = {}) => { | ||
return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("POST", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
put: (options = {}) => { | ||
return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PUT", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
patch: (options = {}) => { | ||
return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("PATCH", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
delete: (options = {}) => { | ||
return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("DELETE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
head: (options = {}) => { | ||
return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("HEAD", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
options: (options = {}) => { | ||
return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("OPTIONS", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
trace: (options = {}) => { | ||
return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args); | ||
return buildSendRequest("TRACE", baseUrl, path, pipeline, Object.assign({ allowInsecureConnection }, options), args, httpClient); | ||
}, | ||
@@ -491,6 +492,6 @@ }; | ||
} | ||
function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = []) { | ||
function buildSendRequest(method, baseUrl, path, pipeline, requestOptions = {}, args = [], httpClient) { | ||
// If the client has an api-version and the request doesn't specify one, inject the one in the client options | ||
const url = buildRequestUrl(baseUrl, path, args, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions); | ||
return sendRequest(method, url, pipeline, requestOptions, httpClient); | ||
} | ||
@@ -497,0 +498,0 @@ function isCredential(param) { |
{ | ||
"name": "@azure-rest/core-client", | ||
"version": "1.0.0-alpha.20220204.4", | ||
"version": "1.0.0-alpha.20220211.1", | ||
"description": "Core library for interfacing with AutoRest rest level generated code", | ||
@@ -5,0 +5,0 @@ "sdk-type": "client", |
@@ -6,2 +6,3 @@ /** | ||
import { HttpClient } from '@azure/core-rest-pipeline'; | ||
import { KeyCredential } from '@azure/core-auth'; | ||
@@ -106,2 +107,6 @@ import { Pipeline } from '@azure/core-rest-pipeline'; | ||
additionalPolicies?: AdditionalPolicyConfig[]; | ||
/** | ||
* Specify a custom HttpClient when making requests. | ||
*/ | ||
httpClient?: HttpClient; | ||
}; | ||
@@ -108,0 +113,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143622
1272