@azure/arm-postgresql-flexible 6.0.1-alpha.20221214.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +13 -10
  2. package/dist/index.js +238 -67
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist-esm/samples-dev/checkNameAvailabilityExecuteSample.js +10 -2
  7. package/dist-esm/samples-dev/checkNameAvailabilityExecuteSample.js.map +1 -1
  8. package/dist-esm/samples-dev/configurationsGetSample.js +11 -3
  9. package/dist-esm/samples-dev/configurationsGetSample.js.map +1 -1
  10. package/dist-esm/samples-dev/configurationsListByServerSample.js +11 -3
  11. package/dist-esm/samples-dev/configurationsListByServerSample.js.map +1 -1
  12. package/dist-esm/samples-dev/configurationsPutSample.js +11 -3
  13. package/dist-esm/samples-dev/configurationsPutSample.js.map +1 -1
  14. package/dist-esm/samples-dev/configurationsUpdateSample.js +11 -3
  15. package/dist-esm/samples-dev/configurationsUpdateSample.js.map +1 -1
  16. package/dist-esm/samples-dev/databasesCreateSample.js +11 -3
  17. package/dist-esm/samples-dev/databasesCreateSample.js.map +1 -1
  18. package/dist-esm/samples-dev/databasesDeleteSample.js +11 -3
  19. package/dist-esm/samples-dev/databasesDeleteSample.js.map +1 -1
  20. package/dist-esm/samples-dev/databasesGetSample.js +11 -3
  21. package/dist-esm/samples-dev/databasesGetSample.js.map +1 -1
  22. package/dist-esm/samples-dev/databasesListByServerSample.js +11 -3
  23. package/dist-esm/samples-dev/databasesListByServerSample.js.map +1 -1
  24. package/dist-esm/samples-dev/firewallRulesCreateOrUpdateSample.js +11 -3
  25. package/dist-esm/samples-dev/firewallRulesCreateOrUpdateSample.js.map +1 -1
  26. package/dist-esm/samples-dev/firewallRulesDeleteSample.js +11 -3
  27. package/dist-esm/samples-dev/firewallRulesDeleteSample.js.map +1 -1
  28. package/dist-esm/samples-dev/firewallRulesGetSample.js +11 -3
  29. package/dist-esm/samples-dev/firewallRulesGetSample.js.map +1 -1
  30. package/dist-esm/samples-dev/firewallRulesListByServerSample.js +11 -3
  31. package/dist-esm/samples-dev/firewallRulesListByServerSample.js.map +1 -1
  32. package/dist-esm/samples-dev/getPrivateDnsZoneSuffixExecuteSample.js +10 -2
  33. package/dist-esm/samples-dev/getPrivateDnsZoneSuffixExecuteSample.js.map +1 -1
  34. package/dist-esm/samples-dev/locationBasedCapabilitiesExecuteSample.js +10 -2
  35. package/dist-esm/samples-dev/locationBasedCapabilitiesExecuteSample.js.map +1 -1
  36. package/dist-esm/samples-dev/operationsListSample.js +10 -2
  37. package/dist-esm/samples-dev/operationsListSample.js.map +1 -1
  38. package/dist-esm/samples-dev/serversCreateSample.js +15 -6
  39. package/dist-esm/samples-dev/serversCreateSample.js.map +1 -1
  40. package/dist-esm/samples-dev/serversDeleteSample.js +11 -3
  41. package/dist-esm/samples-dev/serversDeleteSample.js.map +1 -1
  42. package/dist-esm/samples-dev/serversGetSample.js +15 -6
  43. package/dist-esm/samples-dev/serversGetSample.js.map +1 -1
  44. package/dist-esm/samples-dev/serversListByResourceGroupSample.js +11 -3
  45. package/dist-esm/samples-dev/serversListByResourceGroupSample.js.map +1 -1
  46. package/dist-esm/samples-dev/serversListSample.js +10 -2
  47. package/dist-esm/samples-dev/serversListSample.js.map +1 -1
  48. package/dist-esm/samples-dev/serversRestartSample.js +15 -6
  49. package/dist-esm/samples-dev/serversRestartSample.js.map +1 -1
  50. package/dist-esm/samples-dev/serversStartSample.js +11 -3
  51. package/dist-esm/samples-dev/serversStartSample.js.map +1 -1
  52. package/dist-esm/samples-dev/serversStopSample.js +11 -3
  53. package/dist-esm/samples-dev/serversStopSample.js.map +1 -1
  54. package/dist-esm/samples-dev/serversUpdateSample.js +15 -6
  55. package/dist-esm/samples-dev/serversUpdateSample.js.map +1 -1
  56. package/dist-esm/samples-dev/virtualNetworkSubnetUsageExecuteSample.js +10 -2
  57. package/dist-esm/samples-dev/virtualNetworkSubnetUsageExecuteSample.js.map +1 -1
  58. package/dist-esm/src/index.d.ts +1 -0
  59. package/dist-esm/src/index.d.ts.map +1 -1
  60. package/dist-esm/src/index.js +1 -0
  61. package/dist-esm/src/index.js.map +1 -1
  62. package/dist-esm/src/models/index.d.ts +60 -11
  63. package/dist-esm/src/models/index.d.ts.map +1 -1
  64. package/dist-esm/src/models/index.js +48 -0
  65. package/dist-esm/src/models/index.js.map +1 -1
  66. package/dist-esm/src/operations/configurations.d.ts.map +1 -1
  67. package/dist-esm/src/operations/configurations.js +19 -8
  68. package/dist-esm/src/operations/configurations.js.map +1 -1
  69. package/dist-esm/src/operations/databases.d.ts.map +1 -1
  70. package/dist-esm/src/operations/databases.js +19 -8
  71. package/dist-esm/src/operations/databases.js.map +1 -1
  72. package/dist-esm/src/operations/firewallRules.d.ts.map +1 -1
  73. package/dist-esm/src/operations/firewallRules.js +19 -8
  74. package/dist-esm/src/operations/firewallRules.js.map +1 -1
  75. package/dist-esm/src/operations/locationBasedCapabilities.d.ts.map +1 -1
  76. package/dist-esm/src/operations/locationBasedCapabilities.js +19 -8
  77. package/dist-esm/src/operations/locationBasedCapabilities.js.map +1 -1
  78. package/dist-esm/src/operations/servers.d.ts.map +1 -1
  79. package/dist-esm/src/operations/servers.js +37 -16
  80. package/dist-esm/src/operations/servers.js.map +1 -1
  81. package/dist-esm/src/pagingHelper.d.ts +13 -0
  82. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  83. package/dist-esm/src/pagingHelper.js +32 -0
  84. package/dist-esm/src/pagingHelper.js.map +1 -0
  85. package/dist-esm/src/postgreSQLManagementFlexibleServerClient.d.ts +2 -0
  86. package/dist-esm/src/postgreSQLManagementFlexibleServerClient.d.ts.map +1 -1
  87. package/dist-esm/src/postgreSQLManagementFlexibleServerClient.js +49 -18
  88. package/dist-esm/src/postgreSQLManagementFlexibleServerClient.js.map +1 -1
  89. package/dist-esm/test/sampleTest.js +11 -13
  90. package/dist-esm/test/sampleTest.js.map +1 -1
  91. package/package.json +15 -10
  92. package/review/arm-postgresql-flexible.api.md +38 -82
  93. package/src/index.ts +1 -0
  94. package/src/models/index.ts +59 -11
  95. package/src/operations/configurations.ts +22 -13
  96. package/src/operations/databases.ts +23 -14
  97. package/src/operations/firewallRules.ts +23 -14
  98. package/src/operations/locationBasedCapabilities.ts +21 -9
  99. package/src/operations/servers.ts +46 -19
  100. package/src/pagingHelper.ts +39 -0
  101. package/src/postgreSQLManagementFlexibleServerClient.ts +60 -20
  102. package/types/arm-postgresql-flexible.d.ts +71 -11
  103. package/types/tsdoc-metadata.json +1 -1
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { FirewallRules } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -18,12 +19,12 @@ import {
18
19
  FirewallRule,
19
20
  FirewallRulesListByServerNextOptionalParams,
20
21
  FirewallRulesListByServerOptionalParams,
22
+ FirewallRulesListByServerResponse,
21
23
  FirewallRulesCreateOrUpdateOptionalParams,
22
24
  FirewallRulesCreateOrUpdateResponse,
23
25
  FirewallRulesDeleteOptionalParams,
24
26
  FirewallRulesGetOptionalParams,
25
27
  FirewallRulesGetResponse,
26
- FirewallRulesListByServerResponse,
27
28
  FirewallRulesListByServerNextResponse
28
29
  } from "../models";
29
30
 
@@ -63,11 +64,15 @@ export class FirewallRulesImpl implements FirewallRules {
63
64
  [Symbol.asyncIterator]() {
64
65
  return this;
65
66
  },
66
- byPage: () => {
67
+ byPage: (settings?: PageSettings) => {
68
+ if (settings?.maxPageSize) {
69
+ throw new Error("maxPageSize is not supported by this operation.");
70
+ }
67
71
  return this.listByServerPagingPage(
68
72
  resourceGroupName,
69
73
  serverName,
70
- options
74
+ options,
75
+ settings
71
76
  );
72
77
  }
73
78
  };
@@ -76,15 +81,18 @@ export class FirewallRulesImpl implements FirewallRules {
76
81
  private async *listByServerPagingPage(
77
82
  resourceGroupName: string,
78
83
  serverName: string,
79
- options?: FirewallRulesListByServerOptionalParams
84
+ options?: FirewallRulesListByServerOptionalParams,
85
+ settings?: PageSettings
80
86
  ): AsyncIterableIterator<FirewallRule[]> {
81
- let result = await this._listByServer(
82
- resourceGroupName,
83
- serverName,
84
- options
85
- );
86
- yield result.value || [];
87
- let continuationToken = result.nextLink;
87
+ let result: FirewallRulesListByServerResponse;
88
+ let continuationToken = settings?.continuationToken;
89
+ if (!continuationToken) {
90
+ result = await this._listByServer(resourceGroupName, serverName, options);
91
+ let page = result.value || [];
92
+ continuationToken = result.nextLink;
93
+ setContinuationToken(page, continuationToken);
94
+ yield page;
95
+ }
88
96
  while (continuationToken) {
89
97
  result = await this._listByServerNext(
90
98
  resourceGroupName,
@@ -93,7 +101,9 @@ export class FirewallRulesImpl implements FirewallRules {
93
101
  options
94
102
  );
95
103
  continuationToken = result.nextLink;
96
- yield result.value || [];
104
+ let page = result.value || [];
105
+ setContinuationToken(page, continuationToken);
106
+ yield page;
97
107
  }
98
108
  }
99
109
 
@@ -467,7 +477,6 @@ const listByServerNextOperationSpec: coreClient.OperationSpec = {
467
477
  bodyMapper: Mappers.CloudError
468
478
  }
469
479
  },
470
- queryParameters: [Parameters.apiVersion],
471
480
  urlParameters: [
472
481
  Parameters.$host,
473
482
  Parameters.subscriptionId,
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { LocationBasedCapabilities } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -51,19 +52,29 @@ export class LocationBasedCapabilitiesImpl
51
52
  [Symbol.asyncIterator]() {
52
53
  return this;
53
54
  },
54
- byPage: () => {
55
- return this.executePagingPage(locationName, options);
55
+ byPage: (settings?: PageSettings) => {
56
+ if (settings?.maxPageSize) {
57
+ throw new Error("maxPageSize is not supported by this operation.");
58
+ }
59
+ return this.executePagingPage(locationName, options, settings);
56
60
  }
57
61
  };
58
62
  }
59
63
 
60
64
  private async *executePagingPage(
61
65
  locationName: string,
62
- options?: LocationBasedCapabilitiesExecuteOptionalParams
66
+ options?: LocationBasedCapabilitiesExecuteOptionalParams,
67
+ settings?: PageSettings
63
68
  ): AsyncIterableIterator<CapabilityProperties[]> {
64
- let result = await this._execute(locationName, options);
65
- yield result.value || [];
66
- let continuationToken = result.nextLink;
69
+ let result: LocationBasedCapabilitiesExecuteResponse;
70
+ let continuationToken = settings?.continuationToken;
71
+ if (!continuationToken) {
72
+ result = await this._execute(locationName, options);
73
+ let page = result.value || [];
74
+ continuationToken = result.nextLink;
75
+ setContinuationToken(page, continuationToken);
76
+ yield page;
77
+ }
67
78
  while (continuationToken) {
68
79
  result = await this._executeNext(
69
80
  locationName,
@@ -71,7 +82,9 @@ export class LocationBasedCapabilitiesImpl
71
82
  options
72
83
  );
73
84
  continuationToken = result.nextLink;
74
- yield result.value || [];
85
+ let page = result.value || [];
86
+ setContinuationToken(page, continuationToken);
87
+ yield page;
75
88
  }
76
89
  }
77
90
 
@@ -151,7 +164,6 @@ const executeNextOperationSpec: coreClient.OperationSpec = {
151
164
  bodyMapper: Mappers.CloudError
152
165
  }
153
166
  },
154
- queryParameters: [Parameters.apiVersion],
155
167
  urlParameters: [
156
168
  Parameters.$host,
157
169
  Parameters.subscriptionId,
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { Servers } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -18,8 +19,10 @@ import {
18
19
  Server,
19
20
  ServersListByResourceGroupNextOptionalParams,
20
21
  ServersListByResourceGroupOptionalParams,
22
+ ServersListByResourceGroupResponse,
21
23
  ServersListNextOptionalParams,
22
24
  ServersListOptionalParams,
25
+ ServersListResponse,
23
26
  ServersCreateOptionalParams,
24
27
  ServersCreateResponse,
25
28
  ServerForUpdate,
@@ -28,8 +31,6 @@ import {
28
31
  ServersDeleteOptionalParams,
29
32
  ServersGetOptionalParams,
30
33
  ServersGetResponse,
31
- ServersListByResourceGroupResponse,
32
- ServersListResponse,
33
34
  ServersRestartOptionalParams,
34
35
  ServersStartOptionalParams,
35
36
  ServersStopOptionalParams,
@@ -67,19 +68,33 @@ export class ServersImpl implements Servers {
67
68
  [Symbol.asyncIterator]() {
68
69
  return this;
69
70
  },
70
- byPage: () => {
71
- return this.listByResourceGroupPagingPage(resourceGroupName, options);
71
+ byPage: (settings?: PageSettings) => {
72
+ if (settings?.maxPageSize) {
73
+ throw new Error("maxPageSize is not supported by this operation.");
74
+ }
75
+ return this.listByResourceGroupPagingPage(
76
+ resourceGroupName,
77
+ options,
78
+ settings
79
+ );
72
80
  }
73
81
  };
74
82
  }
75
83
 
76
84
  private async *listByResourceGroupPagingPage(
77
85
  resourceGroupName: string,
78
- options?: ServersListByResourceGroupOptionalParams
86
+ options?: ServersListByResourceGroupOptionalParams,
87
+ settings?: PageSettings
79
88
  ): AsyncIterableIterator<Server[]> {
80
- let result = await this._listByResourceGroup(resourceGroupName, options);
81
- yield result.value || [];
82
- let continuationToken = result.nextLink;
89
+ let result: ServersListByResourceGroupResponse;
90
+ let continuationToken = settings?.continuationToken;
91
+ if (!continuationToken) {
92
+ result = await this._listByResourceGroup(resourceGroupName, options);
93
+ let page = result.value || [];
94
+ continuationToken = result.nextLink;
95
+ setContinuationToken(page, continuationToken);
96
+ yield page;
97
+ }
83
98
  while (continuationToken) {
84
99
  result = await this._listByResourceGroupNext(
85
100
  resourceGroupName,
@@ -87,7 +102,9 @@ export class ServersImpl implements Servers {
87
102
  options
88
103
  );
89
104
  continuationToken = result.nextLink;
90
- yield result.value || [];
105
+ let page = result.value || [];
106
+ setContinuationToken(page, continuationToken);
107
+ yield page;
91
108
  }
92
109
  }
93
110
 
@@ -118,22 +135,34 @@ export class ServersImpl implements Servers {
118
135
  [Symbol.asyncIterator]() {
119
136
  return this;
120
137
  },
121
- byPage: () => {
122
- return this.listPagingPage(options);
138
+ byPage: (settings?: PageSettings) => {
139
+ if (settings?.maxPageSize) {
140
+ throw new Error("maxPageSize is not supported by this operation.");
141
+ }
142
+ return this.listPagingPage(options, settings);
123
143
  }
124
144
  };
125
145
  }
126
146
 
127
147
  private async *listPagingPage(
128
- options?: ServersListOptionalParams
148
+ options?: ServersListOptionalParams,
149
+ settings?: PageSettings
129
150
  ): AsyncIterableIterator<Server[]> {
130
- let result = await this._list(options);
131
- yield result.value || [];
132
- let continuationToken = result.nextLink;
151
+ let result: ServersListResponse;
152
+ let continuationToken = settings?.continuationToken;
153
+ if (!continuationToken) {
154
+ result = await this._list(options);
155
+ let page = result.value || [];
156
+ continuationToken = result.nextLink;
157
+ setContinuationToken(page, continuationToken);
158
+ yield page;
159
+ }
133
160
  while (continuationToken) {
134
161
  result = await this._listNext(continuationToken, options);
135
162
  continuationToken = result.nextLink;
136
- yield result.value || [];
163
+ let page = result.value || [];
164
+ setContinuationToken(page, continuationToken);
165
+ yield page;
137
166
  }
138
167
  }
139
168
 
@@ -957,7 +986,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = {
957
986
  bodyMapper: Mappers.CloudError
958
987
  }
959
988
  },
960
- queryParameters: [Parameters.apiVersion],
961
989
  urlParameters: [
962
990
  Parameters.$host,
963
991
  Parameters.subscriptionId,
@@ -978,7 +1006,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
978
1006
  bodyMapper: Mappers.CloudError
979
1007
  }
980
1008
  },
981
- queryParameters: [Parameters.apiVersion],
982
1009
  urlParameters: [
983
1010
  Parameters.$host,
984
1011
  Parameters.subscriptionId,
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * Code generated by Microsoft (R) AutoRest Code Generator.
6
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
+ */
8
+
9
+ export interface PageInfo {
10
+ continuationToken?: string;
11
+ }
12
+
13
+ const pageMap = new WeakMap<object, PageInfo>();
14
+
15
+ /**
16
+ * Given the last `.value` produced by the `byPage` iterator,
17
+ * returns a continuation token that can be used to begin paging from
18
+ * that point later.
19
+ * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator.
20
+ * @returns The continuation token that can be passed into byPage() during future calls.
21
+ */
22
+ export function getContinuationToken(page: unknown): string | undefined {
23
+ if (typeof page !== "object" || page === null) {
24
+ return undefined;
25
+ }
26
+ return pageMap.get(page)?.continuationToken;
27
+ }
28
+
29
+ export function setContinuationToken(
30
+ page: unknown,
31
+ continuationToken: string | undefined
32
+ ): void {
33
+ if (typeof page !== "object" || page === null || !continuationToken) {
34
+ return;
35
+ }
36
+ const pageInfo = pageMap.get(page) ?? {};
37
+ pageInfo.continuationToken = continuationToken;
38
+ pageMap.set(page, pageInfo);
39
+ }
@@ -8,6 +8,11 @@
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 {
13
18
  ServersImpl,
@@ -65,47 +70,53 @@ export class PostgreSQLManagementFlexibleServerClient extends coreClient.Service
65
70
  credential: credentials
66
71
  };
67
72
 
68
- const packageDetails = `azsdk-js-arm-postgresql-flexible/6.0.1`;
73
+ const packageDetails = `azsdk-js-arm-postgresql-flexible/6.1.0`;
69
74
  const userAgentPrefix =
70
75
  options.userAgentOptions && options.userAgentOptions.userAgentPrefix
71
76
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
72
77
  : `${packageDetails}`;
73
78
 
74
- if (!options.credentialScopes) {
75
- options.credentialScopes = ["https://management.azure.com/.default"];
76
- }
77
79
  const optionsWithDefaults = {
78
80
  ...defaults,
79
81
  ...options,
80
82
  userAgentOptions: {
81
83
  userAgentPrefix
82
84
  },
83
- baseUri:
85
+ endpoint:
84
86
  options.endpoint ?? options.baseUri ?? "https://management.azure.com"
85
87
  };
86
88
  super(optionsWithDefaults);
87
89
 
90
+ let bearerTokenAuthenticationPolicyFound: boolean = false;
88
91
  if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {
89
92
  const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();
90
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
93
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
91
94
  (pipelinePolicy) =>
92
95
  pipelinePolicy.name ===
93
96
  coreRestPipeline.bearerTokenAuthenticationPolicyName
94
97
  );
95
- if (!bearerTokenAuthenticationPolicyFound) {
96
- this.pipeline.removePolicy({
97
- name: coreRestPipeline.bearerTokenAuthenticationPolicyName
98
- });
99
- this.pipeline.addPolicy(
100
- coreRestPipeline.bearerTokenAuthenticationPolicy({
101
- scopes: `${optionsWithDefaults.baseUri}/.default`,
102
- challengeCallbacks: {
103
- authorizeRequestOnChallenge:
104
- coreClient.authorizeRequestOnClaimChallenge
105
- }
106
- })
107
- );
108
- }
98
+ }
99
+ if (
100
+ !options ||
101
+ !options.pipeline ||
102
+ options.pipeline.getOrderedPolicies().length == 0 ||
103
+ !bearerTokenAuthenticationPolicyFound
104
+ ) {
105
+ this.pipeline.removePolicy({
106
+ name: coreRestPipeline.bearerTokenAuthenticationPolicyName
107
+ });
108
+ this.pipeline.addPolicy(
109
+ coreRestPipeline.bearerTokenAuthenticationPolicy({
110
+ credential: credentials,
111
+ scopes:
112
+ optionsWithDefaults.credentialScopes ??
113
+ `${optionsWithDefaults.endpoint}/.default`,
114
+ challengeCallbacks: {
115
+ authorizeRequestOnChallenge:
116
+ coreClient.authorizeRequestOnClaimChallenge
117
+ }
118
+ })
119
+ );
109
120
  }
110
121
  // Parameter assignments
111
122
  this.subscriptionId = subscriptionId;
@@ -122,6 +133,35 @@ export class PostgreSQLManagementFlexibleServerClient extends coreClient.Service
122
133
  this.operations = new OperationsImpl(this);
123
134
  this.databases = new DatabasesImpl(this);
124
135
  this.getPrivateDnsZoneSuffix = new GetPrivateDnsZoneSuffixImpl(this);
136
+ this.addCustomApiVersionPolicy(options.apiVersion);
137
+ }
138
+
139
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
140
+ private addCustomApiVersionPolicy(apiVersion?: string) {
141
+ if (!apiVersion) {
142
+ return;
143
+ }
144
+ const apiVersionPolicy = {
145
+ name: "CustomApiVersionPolicy",
146
+ async sendRequest(
147
+ request: PipelineRequest,
148
+ next: SendRequest
149
+ ): Promise<PipelineResponse> {
150
+ const param = request.url.split("?");
151
+ if (param.length > 1) {
152
+ const newParams = param[1].split("&").map((item) => {
153
+ if (item.indexOf("api-version") > -1) {
154
+ return "api-version=" + apiVersion;
155
+ } else {
156
+ return item;
157
+ }
158
+ });
159
+ request.url = param[0] + "?" + newParams.join("&");
160
+ }
161
+ return next(request);
162
+ }
163
+ };
164
+ this.pipeline.addPolicy(apiVersionPolicy);
125
165
  }
126
166
 
127
167
  servers: Servers;