|
8 | 8 |
|
9 | 9 | import * as coreClient from "@azure/core-client"; |
10 | 10 | import * as coreRestPipeline from "@azure/core-rest-pipeline"; |
| 11 | +import { |
| 12 | + PipelineRequest, |
| 13 | + PipelineResponse, |
| 14 | + SendRequest |
| 15 | +} from "@azure/core-rest-pipeline"; |
11 | 16 | import * as coreAuth from "@azure/core-auth"; |
12 | 17 | import { PagedAsyncIterableIterator } from "@azure/core-paging"; |
13 | 18 | import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; |
@@ -313,7 +318,7 @@ export class NetworkManagementClient extends coreClient.ServiceClient { |
313 | 318 | credential: credentials |
314 | 319 | }; |
315 | 320 |
|
316 | | - const packageDetails = `azsdk-js-arm-network/28.0.1`; |
| 321 | + const packageDetails = `azsdk-js-arm-network/28.1.0`; |
317 | 322 | const userAgentPrefix = |
318 | 323 | options.userAgentOptions && options.userAgentOptions.userAgentPrefix |
319 | 324 | ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` |
@@ -539,6 +544,35 @@ export class NetworkManagementClient extends coreClient.ServiceClient { |
539 | 544 | this.webApplicationFirewallPolicies = new WebApplicationFirewallPoliciesImpl( |
540 | 545 | this |
541 | 546 | ); |
| 547 | + this.addCustomApiVersionPolicy(options.apiVersion); |
| 548 | + } |
| 549 | + |
| 550 | + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ |
| 551 | + private addCustomApiVersionPolicy(apiVersion?: string) { |
| 552 | + if (!apiVersion) { |
| 553 | + return; |
| 554 | + } |
| 555 | + const apiVersionPolicy = { |
| 556 | + name: "CustomApiVersionPolicy", |
| 557 | + async sendRequest( |
| 558 | + request: PipelineRequest, |
| 559 | + next: SendRequest |
| 560 | + ): Promise<PipelineResponse> { |
| 561 | + const param = request.url.split("?"); |
| 562 | + if (param.length > 1) { |
| 563 | + const newParams = param[1].split("&").map((item) => { |
| 564 | + if (item.indexOf("api-version") > -1) { |
| 565 | + return item.replace(/(?<==).*$/, apiVersion); |
| 566 | + } else { |
| 567 | + return item; |
| 568 | + } |
| 569 | + }); |
| 570 | + request.url = param[0] + "?" + newParams.join("&"); |
| 571 | + } |
| 572 | + return next(request); |
| 573 | + } |
| 574 | + }; |
| 575 | + this.pipeline.addPolicy(apiVersionPolicy); |
542 | 576 | } |
543 | 577 |
|
544 | 578 | /** |
|
0 commit comments