@azure/arm-commitmentplans 2.0.0-alpha.20221128.2 → 2.0.0-alpha.20221202.3

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 (50) hide show
  1. package/CHANGELOG.md +3 -13
  2. package/dist/index.js +176 -54
  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/src/azureMLCommitmentPlansManagementClient.d.ts +2 -0
  7. package/dist-esm/src/azureMLCommitmentPlansManagementClient.d.ts.map +1 -1
  8. package/dist-esm/src/azureMLCommitmentPlansManagementClient.js +48 -17
  9. package/dist-esm/src/azureMLCommitmentPlansManagementClient.js.map +1 -1
  10. package/dist-esm/src/index.d.ts +1 -0
  11. package/dist-esm/src/index.d.ts.map +1 -1
  12. package/dist-esm/src/index.js +1 -0
  13. package/dist-esm/src/index.js.map +1 -1
  14. package/dist-esm/src/models/index.d.ts +11 -4
  15. package/dist-esm/src/models/index.d.ts.map +1 -1
  16. package/dist-esm/src/models/index.js +7 -0
  17. package/dist-esm/src/models/index.js.map +1 -1
  18. package/dist-esm/src/operations/commitmentAssociations.d.ts.map +1 -1
  19. package/dist-esm/src/operations/commitmentAssociations.js +19 -7
  20. package/dist-esm/src/operations/commitmentAssociations.js.map +1 -1
  21. package/dist-esm/src/operations/commitmentPlans.d.ts.map +1 -1
  22. package/dist-esm/src/operations/commitmentPlans.js +37 -14
  23. package/dist-esm/src/operations/commitmentPlans.js.map +1 -1
  24. package/dist-esm/src/operations/operations.d.ts.map +1 -1
  25. package/dist-esm/src/operations/operations.js +8 -4
  26. package/dist-esm/src/operations/operations.js.map +1 -1
  27. package/dist-esm/src/operations/skus.d.ts.map +1 -1
  28. package/dist-esm/src/operations/skus.js +8 -4
  29. package/dist-esm/src/operations/skus.js.map +1 -1
  30. package/dist-esm/src/operations/usageHistory.d.ts.map +1 -1
  31. package/dist-esm/src/operations/usageHistory.js +19 -7
  32. package/dist-esm/src/operations/usageHistory.js.map +1 -1
  33. package/dist-esm/src/pagingHelper.d.ts +13 -0
  34. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  35. package/dist-esm/src/pagingHelper.js +32 -0
  36. package/dist-esm/src/pagingHelper.js.map +1 -0
  37. package/dist-esm/test/sampleTest.js +11 -13
  38. package/dist-esm/test/sampleTest.js.map +1 -1
  39. package/package.json +12 -8
  40. package/review/arm-commitmentplans.api.md +7 -11
  41. package/src/azureMLCommitmentPlansManagementClient.ts +59 -19
  42. package/src/index.ts +1 -0
  43. package/src/models/index.ts +11 -4
  44. package/src/operations/commitmentAssociations.ts +23 -13
  45. package/src/operations/commitmentPlans.ts +46 -17
  46. package/src/operations/operations.ts +10 -5
  47. package/src/operations/skus.ts +10 -5
  48. package/src/operations/usageHistory.ts +22 -12
  49. package/src/pagingHelper.ts +39 -0
  50. package/types/arm-commitmentplans.d.ts +22 -4
package/CHANGELOG.md CHANGED
@@ -1,18 +1,8 @@
1
1
  # Release History
2
+
3
+ ## 2.0.0-beta.3 (2022-11-28)
2
4
 
3
- ## 2.0.0-beta.3 (Unreleased)
4
-
5
- ### Features Added
6
-
7
- ### Breaking Changes
8
-
9
- ### Bugs Fixed
10
-
11
- ### Other Changes
12
-
13
- ## 2.0.0-beta.2 (2022-04-24)
14
-
15
- The package of @azure/arm-commitmentplans is using our next generation design principles since version 2.0.0-beta.2, which contains breaking changes.
5
+ The package of @azure/arm-commitmentplans is using our next generation design principles since version 2.0.0-beta.3, which contains breaking changes.
16
6
 
17
7
  To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog).
18
8
 
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var tslib = require('tslib');
5
6
  var coreClient = require('@azure/core-client');
6
7
  var coreRestPipeline = require('@azure/core-rest-pipeline');
7
- var tslib = require('tslib');
8
8
 
9
9
  function _interopNamespace(e) {
10
10
  if (e && e.__esModule) return e;
@@ -27,6 +27,38 @@ function _interopNamespace(e) {
27
27
  var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
28
28
  var coreRestPipeline__namespace = /*#__PURE__*/_interopNamespace(coreRestPipeline);
29
29
 
30
+ /*
31
+ * Copyright (c) Microsoft Corporation.
32
+ * Licensed under the MIT License.
33
+ *
34
+ * Code generated by Microsoft (R) AutoRest Code Generator.
35
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
36
+ */
37
+ const pageMap = new WeakMap();
38
+ /**
39
+ * Given a result page from a pageable operation, returns a
40
+ * continuation token that can be used to begin paging from
41
+ * that point later.
42
+ * @param page A result object from calling .byPage() on a paged operation.
43
+ * @returns The continuation token that can be passed into byPage().
44
+ */
45
+ function getContinuationToken(page) {
46
+ var _a;
47
+ if (typeof page !== "object" || page === null) {
48
+ return undefined;
49
+ }
50
+ return (_a = pageMap.get(page)) === null || _a === void 0 ? void 0 : _a.continuationToken;
51
+ }
52
+ function setContinuationToken(page, continuationToken) {
53
+ var _a;
54
+ if (typeof page !== "object" || page === null || !continuationToken) {
55
+ return;
56
+ }
57
+ const pageInfo = (_a = pageMap.get(page)) !== null && _a !== void 0 ? _a : {};
58
+ pageInfo.continuationToken = continuationToken;
59
+ pageMap.set(page, pageInfo);
60
+ }
61
+
30
62
  /*
31
63
  * Copyright (c) Microsoft Corporation.
32
64
  * Licensed under the MIT License.
@@ -37,20 +69,27 @@ var coreRestPipeline__namespace = /*#__PURE__*/_interopNamespace(coreRestPipelin
37
69
  /** Known values of {@link SkuCapacityScaleType} that the service accepts. */
38
70
  exports.KnownSkuCapacityScaleType = void 0;
39
71
  (function (KnownSkuCapacityScaleType) {
72
+ /** Automatic */
40
73
  KnownSkuCapacityScaleType["Automatic"] = "Automatic";
74
+ /** Manual */
41
75
  KnownSkuCapacityScaleType["Manual"] = "Manual";
76
+ /** None */
42
77
  KnownSkuCapacityScaleType["None"] = "None";
43
78
  })(exports.KnownSkuCapacityScaleType || (exports.KnownSkuCapacityScaleType = {}));
44
79
  /** Known values of {@link ResourceSkuRestrictionsType} that the service accepts. */
45
80
  exports.KnownResourceSkuRestrictionsType = void 0;
46
81
  (function (KnownResourceSkuRestrictionsType) {
82
+ /** Location */
47
83
  KnownResourceSkuRestrictionsType["Location"] = "location";
84
+ /** Zone */
48
85
  KnownResourceSkuRestrictionsType["Zone"] = "zone";
49
86
  })(exports.KnownResourceSkuRestrictionsType || (exports.KnownResourceSkuRestrictionsType = {}));
50
87
  /** Known values of {@link ResourceSkuRestrictionsReasonCode} that the service accepts. */
51
88
  exports.KnownResourceSkuRestrictionsReasonCode = void 0;
52
89
  (function (KnownResourceSkuRestrictionsReasonCode) {
90
+ /** QuotaId */
53
91
  KnownResourceSkuRestrictionsReasonCode["QuotaId"] = "QuotaId";
92
+ /** NotAvailableForSubscription */
54
93
  KnownResourceSkuRestrictionsReasonCode["NotAvailableForSubscription"] = "NotAvailableForSubscription";
55
94
  })(exports.KnownResourceSkuRestrictionsReasonCode || (exports.KnownResourceSkuRestrictionsReasonCode = {}));
56
95
 
@@ -975,14 +1014,18 @@ class OperationsImpl {
975
1014
  [Symbol.asyncIterator]() {
976
1015
  return this;
977
1016
  },
978
- byPage: () => {
979
- return this.listPagingPage(options);
1017
+ byPage: (settings) => {
1018
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1019
+ throw new Error("maxPageSize is not supported by this operation.");
1020
+ }
1021
+ return this.listPagingPage(options, settings);
980
1022
  }
981
1023
  };
982
1024
  }
983
- listPagingPage(options) {
1025
+ listPagingPage(options, _settings) {
984
1026
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
985
- let result = yield tslib.__await(this._list(options));
1027
+ let result;
1028
+ result = yield tslib.__await(this._list(options));
986
1029
  yield yield tslib.__await(result.value || []);
987
1030
  });
988
1031
  }
@@ -1058,14 +1101,18 @@ class SkusImpl {
1058
1101
  [Symbol.asyncIterator]() {
1059
1102
  return this;
1060
1103
  },
1061
- byPage: () => {
1062
- return this.listPagingPage(options);
1104
+ byPage: (settings) => {
1105
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1106
+ throw new Error("maxPageSize is not supported by this operation.");
1107
+ }
1108
+ return this.listPagingPage(options, settings);
1063
1109
  }
1064
1110
  };
1065
1111
  }
1066
- listPagingPage(options) {
1112
+ listPagingPage(options, _settings) {
1067
1113
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
1068
- let result = yield tslib.__await(this._list(options));
1114
+ let result;
1115
+ result = yield tslib.__await(this._list(options));
1069
1116
  yield yield tslib.__await(result.value || []);
1070
1117
  });
1071
1118
  }
@@ -1143,20 +1190,31 @@ class CommitmentAssociationsImpl {
1143
1190
  [Symbol.asyncIterator]() {
1144
1191
  return this;
1145
1192
  },
1146
- byPage: () => {
1147
- return this.listPagingPage(resourceGroupName, commitmentPlanName, options);
1193
+ byPage: (settings) => {
1194
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1195
+ throw new Error("maxPageSize is not supported by this operation.");
1196
+ }
1197
+ return this.listPagingPage(resourceGroupName, commitmentPlanName, options, settings);
1148
1198
  }
1149
1199
  };
1150
1200
  }
1151
- listPagingPage(resourceGroupName, commitmentPlanName, options) {
1201
+ listPagingPage(resourceGroupName, commitmentPlanName, options, settings) {
1152
1202
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
1153
- let result = yield tslib.__await(this._list(resourceGroupName, commitmentPlanName, options));
1154
- yield yield tslib.__await(result.value || []);
1155
- let continuationToken = result.nextLink;
1203
+ let result;
1204
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1205
+ if (!continuationToken) {
1206
+ result = yield tslib.__await(this._list(resourceGroupName, commitmentPlanName, options));
1207
+ let page = result.value || [];
1208
+ continuationToken = result.nextLink;
1209
+ setContinuationToken(page, continuationToken);
1210
+ yield yield tslib.__await(page);
1211
+ }
1156
1212
  while (continuationToken) {
1157
1213
  result = yield tslib.__await(this._listNext(resourceGroupName, commitmentPlanName, continuationToken, options));
1158
1214
  continuationToken = result.nextLink;
1159
- yield yield tslib.__await(result.value || []);
1215
+ let page = result.value || [];
1216
+ setContinuationToken(page, continuationToken);
1217
+ yield yield tslib.__await(page);
1160
1218
  }
1161
1219
  });
1162
1220
  }
@@ -1340,20 +1398,31 @@ class CommitmentPlansImpl {
1340
1398
  [Symbol.asyncIterator]() {
1341
1399
  return this;
1342
1400
  },
1343
- byPage: () => {
1344
- return this.listPagingPage(options);
1401
+ byPage: (settings) => {
1402
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1403
+ throw new Error("maxPageSize is not supported by this operation.");
1404
+ }
1405
+ return this.listPagingPage(options, settings);
1345
1406
  }
1346
1407
  };
1347
1408
  }
1348
- listPagingPage(options) {
1409
+ listPagingPage(options, settings) {
1349
1410
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
1350
- let result = yield tslib.__await(this._list(options));
1351
- yield yield tslib.__await(result.value || []);
1352
- let continuationToken = result.nextLink;
1411
+ let result;
1412
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1413
+ if (!continuationToken) {
1414
+ result = yield tslib.__await(this._list(options));
1415
+ let page = result.value || [];
1416
+ continuationToken = result.nextLink;
1417
+ setContinuationToken(page, continuationToken);
1418
+ yield yield tslib.__await(page);
1419
+ }
1353
1420
  while (continuationToken) {
1354
1421
  result = yield tslib.__await(this._listNext(continuationToken, options));
1355
1422
  continuationToken = result.nextLink;
1356
- yield yield tslib.__await(result.value || []);
1423
+ let page = result.value || [];
1424
+ setContinuationToken(page, continuationToken);
1425
+ yield yield tslib.__await(page);
1357
1426
  }
1358
1427
  });
1359
1428
  }
@@ -1389,20 +1458,31 @@ class CommitmentPlansImpl {
1389
1458
  [Symbol.asyncIterator]() {
1390
1459
  return this;
1391
1460
  },
1392
- byPage: () => {
1393
- return this.listInResourceGroupPagingPage(resourceGroupName, options);
1461
+ byPage: (settings) => {
1462
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1463
+ throw new Error("maxPageSize is not supported by this operation.");
1464
+ }
1465
+ return this.listInResourceGroupPagingPage(resourceGroupName, options, settings);
1394
1466
  }
1395
1467
  };
1396
1468
  }
1397
- listInResourceGroupPagingPage(resourceGroupName, options) {
1469
+ listInResourceGroupPagingPage(resourceGroupName, options, settings) {
1398
1470
  return tslib.__asyncGenerator(this, arguments, function* listInResourceGroupPagingPage_1() {
1399
- let result = yield tslib.__await(this._listInResourceGroup(resourceGroupName, options));
1400
- yield yield tslib.__await(result.value || []);
1401
- let continuationToken = result.nextLink;
1471
+ let result;
1472
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1473
+ if (!continuationToken) {
1474
+ result = yield tslib.__await(this._listInResourceGroup(resourceGroupName, options));
1475
+ let page = result.value || [];
1476
+ continuationToken = result.nextLink;
1477
+ setContinuationToken(page, continuationToken);
1478
+ yield yield tslib.__await(page);
1479
+ }
1402
1480
  while (continuationToken) {
1403
1481
  result = yield tslib.__await(this._listInResourceGroupNext(resourceGroupName, continuationToken, options));
1404
1482
  continuationToken = result.nextLink;
1405
- yield yield tslib.__await(result.value || []);
1483
+ let page = result.value || [];
1484
+ setContinuationToken(page, continuationToken);
1485
+ yield yield tslib.__await(page);
1406
1486
  }
1407
1487
  });
1408
1488
  }
@@ -1670,20 +1750,31 @@ class UsageHistoryImpl {
1670
1750
  [Symbol.asyncIterator]() {
1671
1751
  return this;
1672
1752
  },
1673
- byPage: () => {
1674
- return this.listPagingPage(resourceGroupName, commitmentPlanName, options);
1753
+ byPage: (settings) => {
1754
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1755
+ throw new Error("maxPageSize is not supported by this operation.");
1756
+ }
1757
+ return this.listPagingPage(resourceGroupName, commitmentPlanName, options, settings);
1675
1758
  }
1676
1759
  };
1677
1760
  }
1678
- listPagingPage(resourceGroupName, commitmentPlanName, options) {
1761
+ listPagingPage(resourceGroupName, commitmentPlanName, options, settings) {
1679
1762
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
1680
- let result = yield tslib.__await(this._list(resourceGroupName, commitmentPlanName, options));
1681
- yield yield tslib.__await(result.value || []);
1682
- let continuationToken = result.nextLink;
1763
+ let result;
1764
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1765
+ if (!continuationToken) {
1766
+ result = yield tslib.__await(this._list(resourceGroupName, commitmentPlanName, options));
1767
+ let page = result.value || [];
1768
+ continuationToken = result.nextLink;
1769
+ setContinuationToken(page, continuationToken);
1770
+ yield yield tslib.__await(page);
1771
+ }
1683
1772
  while (continuationToken) {
1684
1773
  result = yield tslib.__await(this._listNext(resourceGroupName, commitmentPlanName, continuationToken, options));
1685
1774
  continuationToken = result.nextLink;
1686
- yield yield tslib.__await(result.value || []);
1775
+ let page = result.value || [];
1776
+ setContinuationToken(page, continuationToken);
1777
+ yield yield tslib.__await(page);
1687
1778
  }
1688
1779
  });
1689
1780
  }
@@ -1780,7 +1871,7 @@ class AzureMLCommitmentPlansManagementClient extends coreClient__namespace.Servi
1780
1871
  * @param options The parameter options
1781
1872
  */
1782
1873
  constructor(credentials, subscriptionId, options) {
1783
- var _a, _b;
1874
+ var _a, _b, _c;
1784
1875
  if (credentials === undefined) {
1785
1876
  throw new Error("'credentials' cannot be null");
1786
1877
  }
@@ -1799,28 +1890,30 @@ class AzureMLCommitmentPlansManagementClient extends coreClient__namespace.Servi
1799
1890
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1800
1891
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1801
1892
  : `${packageDetails}`;
1802
- if (!options.credentialScopes) {
1803
- options.credentialScopes = ["https://management.azure.com/.default"];
1804
- }
1805
1893
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1806
1894
  userAgentPrefix
1807
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1895
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1808
1896
  super(optionsWithDefaults);
1897
+ let bearerTokenAuthenticationPolicyFound = false;
1809
1898
  if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
1810
1899
  const pipelinePolicies = options.pipeline.getOrderedPolicies();
1811
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1900
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1812
1901
  coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName);
1813
- if (!bearerTokenAuthenticationPolicyFound) {
1814
- this.pipeline.removePolicy({
1815
- name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1816
- });
1817
- this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1818
- scopes: `${optionsWithDefaults.baseUri}/.default`,
1819
- challengeCallbacks: {
1820
- authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1821
- }
1822
- }));
1823
- }
1902
+ }
1903
+ if (!options ||
1904
+ !options.pipeline ||
1905
+ options.pipeline.getOrderedPolicies().length == 0 ||
1906
+ !bearerTokenAuthenticationPolicyFound) {
1907
+ this.pipeline.removePolicy({
1908
+ name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1909
+ });
1910
+ this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1911
+ credential: credentials,
1912
+ scopes: (_c = optionsWithDefaults.credentialScopes) !== null && _c !== void 0 ? _c : `${optionsWithDefaults.endpoint}/.default`,
1913
+ challengeCallbacks: {
1914
+ authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1915
+ }
1916
+ }));
1824
1917
  }
1825
1918
  // Parameter assignments
1826
1919
  this.subscriptionId = subscriptionId;
@@ -1832,8 +1925,37 @@ class AzureMLCommitmentPlansManagementClient extends coreClient__namespace.Servi
1832
1925
  this.commitmentAssociations = new CommitmentAssociationsImpl(this);
1833
1926
  this.commitmentPlans = new CommitmentPlansImpl(this);
1834
1927
  this.usageHistory = new UsageHistoryImpl(this);
1928
+ this.addCustomApiVersionPolicy(options.apiVersion);
1929
+ }
1930
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
1931
+ addCustomApiVersionPolicy(apiVersion) {
1932
+ if (!apiVersion) {
1933
+ return;
1934
+ }
1935
+ const apiVersionPolicy = {
1936
+ name: "CustomApiVersionPolicy",
1937
+ sendRequest(request, next) {
1938
+ return tslib.__awaiter(this, void 0, void 0, function* () {
1939
+ const param = request.url.split("?");
1940
+ if (param.length > 1) {
1941
+ const newParams = param[1].split("&").map((item) => {
1942
+ if (item.indexOf("api-version") > -1) {
1943
+ return "api-version=" + apiVersion;
1944
+ }
1945
+ else {
1946
+ return item;
1947
+ }
1948
+ });
1949
+ request.url = param[0] + "?" + newParams.join("&");
1950
+ }
1951
+ return next(request);
1952
+ });
1953
+ }
1954
+ };
1955
+ this.pipeline.addPolicy(apiVersionPolicy);
1835
1956
  }
1836
1957
  }
1837
1958
 
1838
1959
  exports.AzureMLCommitmentPlansManagementClient = AzureMLCommitmentPlansManagementClient;
1960
+ exports.getContinuationToken = getContinuationToken;
1839
1961
  //# sourceMappingURL=index.js.map