@azure/arm-features 3.0.1 → 3.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 (45) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/index.js +181 -53
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.js +1 -1
  6. package/dist/index.min.js.map +1 -1
  7. package/dist-esm/src/featureClient.d.ts +2 -0
  8. package/dist-esm/src/featureClient.d.ts.map +1 -1
  9. package/dist-esm/src/featureClient.js +68 -26
  10. package/dist-esm/src/featureClient.js.map +1 -1
  11. package/dist-esm/src/index.d.ts +1 -0
  12. package/dist-esm/src/index.d.ts.map +1 -1
  13. package/dist-esm/src/index.js +1 -0
  14. package/dist-esm/src/index.js.map +1 -1
  15. package/dist-esm/src/models/index.d.ts +12 -2
  16. package/dist-esm/src/models/index.d.ts.map +1 -1
  17. package/dist-esm/src/models/index.js +10 -0
  18. package/dist-esm/src/models/index.js.map +1 -1
  19. package/dist-esm/src/operations/features.d.ts.map +1 -1
  20. package/dist-esm/src/operations/features.js +37 -14
  21. package/dist-esm/src/operations/features.js.map +1 -1
  22. package/dist-esm/src/operations/subscriptionFeatureRegistrations.d.ts.map +1 -1
  23. package/dist-esm/src/operations/subscriptionFeatureRegistrations.js +37 -14
  24. package/dist-esm/src/operations/subscriptionFeatureRegistrations.js.map +1 -1
  25. package/dist-esm/src/pagingHelper.d.ts +13 -0
  26. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  27. package/dist-esm/src/pagingHelper.js +32 -0
  28. package/dist-esm/src/pagingHelper.js.map +1 -0
  29. package/dist-esm/test/{sampleTest.d.ts → features_example.spec.d.ts} +1 -1
  30. package/dist-esm/test/features_example.spec.d.ts.map +1 -0
  31. package/dist-esm/test/{sampleTest.js → features_example.spec.js} +17 -19
  32. package/dist-esm/test/features_example.spec.js.map +1 -0
  33. package/package.json +15 -11
  34. package/review/arm-features.api.md +6 -12
  35. package/src/featureClient.ts +81 -28
  36. package/src/index.ts +1 -0
  37. package/src/models/index.ts +12 -2
  38. package/src/operations/features.ts +45 -16
  39. package/src/operations/subscriptionFeatureRegistrations.ts +46 -17
  40. package/src/pagingHelper.ts +39 -0
  41. package/tsconfig.json +0 -2
  42. package/types/arm-features.d.ts +23 -2
  43. package/types/tsdoc-metadata.json +1 -1
  44. package/dist-esm/test/sampleTest.d.ts.map +0 -1
  45. package/dist-esm/test/sampleTest.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
+
3
+ ## 3.1.0 (2022-11-22)
4
+
5
+ **Features**
2
6
 
7
+ - Added Interface SubscriptionFeatureRegistration
8
+
3
9
  ## 3.0.1 (2022-04-18)
4
10
 
5
11
  **features**
package/README.md CHANGED
@@ -13,7 +13,7 @@ Azure Feature Exposure Control (AFEC) provides a mechanism for the resource prov
13
13
 
14
14
  ### Currently supported environments
15
15
 
16
- - [LTS versions of Node.js](https://nodejs.org/about/releases/)
16
+ - [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
17
17
  - Latest versions of Safari, Chrome, Edge and Firefox.
18
18
 
19
19
  See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
package/dist/index.js CHANGED
@@ -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,19 +69,29 @@ var coreRestPipeline__namespace = /*#__PURE__*/_interopNamespace(coreRestPipelin
37
69
  /** Known values of {@link SubscriptionFeatureRegistrationState} that the service accepts. */
38
70
  exports.KnownSubscriptionFeatureRegistrationState = void 0;
39
71
  (function (KnownSubscriptionFeatureRegistrationState) {
72
+ /** NotSpecified */
40
73
  KnownSubscriptionFeatureRegistrationState["NotSpecified"] = "NotSpecified";
74
+ /** NotRegistered */
41
75
  KnownSubscriptionFeatureRegistrationState["NotRegistered"] = "NotRegistered";
76
+ /** Pending */
42
77
  KnownSubscriptionFeatureRegistrationState["Pending"] = "Pending";
78
+ /** Registering */
43
79
  KnownSubscriptionFeatureRegistrationState["Registering"] = "Registering";
80
+ /** Registered */
44
81
  KnownSubscriptionFeatureRegistrationState["Registered"] = "Registered";
82
+ /** Unregistering */
45
83
  KnownSubscriptionFeatureRegistrationState["Unregistering"] = "Unregistering";
84
+ /** Unregistered */
46
85
  KnownSubscriptionFeatureRegistrationState["Unregistered"] = "Unregistered";
47
86
  })(exports.KnownSubscriptionFeatureRegistrationState || (exports.KnownSubscriptionFeatureRegistrationState = {}));
48
87
  /** Known values of {@link SubscriptionFeatureRegistrationApprovalType} that the service accepts. */
49
88
  exports.KnownSubscriptionFeatureRegistrationApprovalType = void 0;
50
89
  (function (KnownSubscriptionFeatureRegistrationApprovalType) {
90
+ /** NotSpecified */
51
91
  KnownSubscriptionFeatureRegistrationApprovalType["NotSpecified"] = "NotSpecified";
92
+ /** ApprovalRequired */
52
93
  KnownSubscriptionFeatureRegistrationApprovalType["ApprovalRequired"] = "ApprovalRequired";
94
+ /** AutoApproval */
53
95
  KnownSubscriptionFeatureRegistrationApprovalType["AutoApproval"] = "AutoApproval";
54
96
  })(exports.KnownSubscriptionFeatureRegistrationApprovalType || (exports.KnownSubscriptionFeatureRegistrationApprovalType = {}));
55
97
 
@@ -642,20 +684,31 @@ class FeaturesImpl {
642
684
  [Symbol.asyncIterator]() {
643
685
  return this;
644
686
  },
645
- byPage: () => {
646
- return this.listAllPagingPage(options);
687
+ byPage: (settings) => {
688
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
689
+ throw new Error("maxPageSize is not supported by this operation.");
690
+ }
691
+ return this.listAllPagingPage(options, settings);
647
692
  }
648
693
  };
649
694
  }
650
- listAllPagingPage(options) {
695
+ listAllPagingPage(options, settings) {
651
696
  return tslib.__asyncGenerator(this, arguments, function* listAllPagingPage_1() {
652
- let result = yield tslib.__await(this._listAll(options));
653
- yield yield tslib.__await(result.value || []);
654
- let continuationToken = result.nextLink;
697
+ let result;
698
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
699
+ if (!continuationToken) {
700
+ result = yield tslib.__await(this._listAll(options));
701
+ let page = result.value || [];
702
+ continuationToken = result.nextLink;
703
+ setContinuationToken(page, continuationToken);
704
+ yield yield tslib.__await(page);
705
+ }
655
706
  while (continuationToken) {
656
707
  result = yield tslib.__await(this._listAllNext(continuationToken, options));
657
708
  continuationToken = result.nextLink;
658
- yield yield tslib.__await(result.value || []);
709
+ let page = result.value || [];
710
+ setContinuationToken(page, continuationToken);
711
+ yield yield tslib.__await(page);
659
712
  }
660
713
  });
661
714
  }
@@ -692,20 +745,31 @@ class FeaturesImpl {
692
745
  [Symbol.asyncIterator]() {
693
746
  return this;
694
747
  },
695
- byPage: () => {
696
- return this.listPagingPage(resourceProviderNamespace, options);
748
+ byPage: (settings) => {
749
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
750
+ throw new Error("maxPageSize is not supported by this operation.");
751
+ }
752
+ return this.listPagingPage(resourceProviderNamespace, options, settings);
697
753
  }
698
754
  };
699
755
  }
700
- listPagingPage(resourceProviderNamespace, options) {
756
+ listPagingPage(resourceProviderNamespace, options, settings) {
701
757
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
702
- let result = yield tslib.__await(this._list(resourceProviderNamespace, options));
703
- yield yield tslib.__await(result.value || []);
704
- let continuationToken = result.nextLink;
758
+ let result;
759
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
760
+ if (!continuationToken) {
761
+ result = yield tslib.__await(this._list(resourceProviderNamespace, options));
762
+ let page = result.value || [];
763
+ continuationToken = result.nextLink;
764
+ setContinuationToken(page, continuationToken);
765
+ yield yield tslib.__await(page);
766
+ }
705
767
  while (continuationToken) {
706
768
  result = yield tslib.__await(this._listNext(resourceProviderNamespace, continuationToken, options));
707
769
  continuationToken = result.nextLink;
708
- yield yield tslib.__await(result.value || []);
770
+ let page = result.value || [];
771
+ setContinuationToken(page, continuationToken);
772
+ yield yield tslib.__await(page);
709
773
  }
710
774
  });
711
775
  }
@@ -962,20 +1026,31 @@ class SubscriptionFeatureRegistrationsImpl {
962
1026
  [Symbol.asyncIterator]() {
963
1027
  return this;
964
1028
  },
965
- byPage: () => {
966
- return this.listBySubscriptionPagingPage(providerNamespace, options);
1029
+ byPage: (settings) => {
1030
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1031
+ throw new Error("maxPageSize is not supported by this operation.");
1032
+ }
1033
+ return this.listBySubscriptionPagingPage(providerNamespace, options, settings);
967
1034
  }
968
1035
  };
969
1036
  }
970
- listBySubscriptionPagingPage(providerNamespace, options) {
1037
+ listBySubscriptionPagingPage(providerNamespace, options, settings) {
971
1038
  return tslib.__asyncGenerator(this, arguments, function* listBySubscriptionPagingPage_1() {
972
- let result = yield tslib.__await(this._listBySubscription(providerNamespace, options));
973
- yield yield tslib.__await(result.value || []);
974
- let continuationToken = result.nextLink;
1039
+ let result;
1040
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1041
+ if (!continuationToken) {
1042
+ result = yield tslib.__await(this._listBySubscription(providerNamespace, options));
1043
+ let page = result.value || [];
1044
+ continuationToken = result.nextLink;
1045
+ setContinuationToken(page, continuationToken);
1046
+ yield yield tslib.__await(page);
1047
+ }
975
1048
  while (continuationToken) {
976
1049
  result = yield tslib.__await(this._listBySubscriptionNext(providerNamespace, continuationToken, options));
977
1050
  continuationToken = result.nextLink;
978
- yield yield tslib.__await(result.value || []);
1051
+ let page = result.value || [];
1052
+ setContinuationToken(page, continuationToken);
1053
+ yield yield tslib.__await(page);
979
1054
  }
980
1055
  });
981
1056
  }
@@ -1010,20 +1085,31 @@ class SubscriptionFeatureRegistrationsImpl {
1010
1085
  [Symbol.asyncIterator]() {
1011
1086
  return this;
1012
1087
  },
1013
- byPage: () => {
1014
- return this.listAllBySubscriptionPagingPage(options);
1088
+ byPage: (settings) => {
1089
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1090
+ throw new Error("maxPageSize is not supported by this operation.");
1091
+ }
1092
+ return this.listAllBySubscriptionPagingPage(options, settings);
1015
1093
  }
1016
1094
  };
1017
1095
  }
1018
- listAllBySubscriptionPagingPage(options) {
1096
+ listAllBySubscriptionPagingPage(options, settings) {
1019
1097
  return tslib.__asyncGenerator(this, arguments, function* listAllBySubscriptionPagingPage_1() {
1020
- let result = yield tslib.__await(this._listAllBySubscription(options));
1021
- yield yield tslib.__await(result.value || []);
1022
- let continuationToken = result.nextLink;
1098
+ let result;
1099
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1100
+ if (!continuationToken) {
1101
+ result = yield tslib.__await(this._listAllBySubscription(options));
1102
+ let page = result.value || [];
1103
+ continuationToken = result.nextLink;
1104
+ setContinuationToken(page, continuationToken);
1105
+ yield yield tslib.__await(page);
1106
+ }
1023
1107
  while (continuationToken) {
1024
1108
  result = yield tslib.__await(this._listAllBySubscriptionNext(continuationToken, options));
1025
1109
  continuationToken = result.nextLink;
1026
- yield yield tslib.__await(result.value || []);
1110
+ let page = result.value || [];
1111
+ setContinuationToken(page, continuationToken);
1112
+ yield yield tslib.__await(page);
1027
1113
  }
1028
1114
  });
1029
1115
  }
@@ -1265,7 +1351,7 @@ class FeatureClient extends coreClient__namespace.ServiceClient {
1265
1351
  * @param options The parameter options
1266
1352
  */
1267
1353
  constructor(credentials, subscriptionId, options) {
1268
- var _a, _b;
1354
+ var _a, _b, _c;
1269
1355
  if (credentials === undefined) {
1270
1356
  throw new Error("'credentials' cannot be null");
1271
1357
  }
@@ -1280,32 +1366,34 @@ class FeatureClient extends coreClient__namespace.ServiceClient {
1280
1366
  requestContentType: "application/json; charset=utf-8",
1281
1367
  credential: credentials
1282
1368
  };
1283
- const packageDetails = `azsdk-js-arm-features/3.0.1`;
1369
+ const packageDetails = `azsdk-js-arm-features/3.1.0`;
1284
1370
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1285
1371
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1286
1372
  : `${packageDetails}`;
1287
- if (!options.credentialScopes) {
1288
- options.credentialScopes = ["https://management.azure.com/.default"];
1289
- }
1290
1373
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1291
1374
  userAgentPrefix
1292
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1375
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1293
1376
  super(optionsWithDefaults);
1377
+ let bearerTokenAuthenticationPolicyFound = false;
1294
1378
  if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
1295
1379
  const pipelinePolicies = options.pipeline.getOrderedPolicies();
1296
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1380
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1297
1381
  coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName);
1298
- if (!bearerTokenAuthenticationPolicyFound) {
1299
- this.pipeline.removePolicy({
1300
- name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1301
- });
1302
- this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1303
- scopes: `${optionsWithDefaults.baseUri}/.default`,
1304
- challengeCallbacks: {
1305
- authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1306
- }
1307
- }));
1308
- }
1382
+ }
1383
+ if (!options ||
1384
+ !options.pipeline ||
1385
+ options.pipeline.getOrderedPolicies().length == 0 ||
1386
+ !bearerTokenAuthenticationPolicyFound) {
1387
+ this.pipeline.removePolicy({
1388
+ name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1389
+ });
1390
+ this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1391
+ credential: credentials,
1392
+ scopes: (_c = optionsWithDefaults.credentialScopes) !== null && _c !== void 0 ? _c : `${optionsWithDefaults.endpoint}/.default`,
1393
+ challengeCallbacks: {
1394
+ authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1395
+ }
1396
+ }));
1309
1397
  }
1310
1398
  // Parameter assignments
1311
1399
  this.subscriptionId = subscriptionId;
@@ -1314,6 +1402,34 @@ class FeatureClient extends coreClient__namespace.ServiceClient {
1314
1402
  this.apiVersion = options.apiVersion || "2021-07-01";
1315
1403
  this.features = new FeaturesImpl(this);
1316
1404
  this.subscriptionFeatureRegistrations = new SubscriptionFeatureRegistrationsImpl(this);
1405
+ this.addCustomApiVersionPolicy(options.apiVersion);
1406
+ }
1407
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
1408
+ addCustomApiVersionPolicy(apiVersion) {
1409
+ if (!apiVersion) {
1410
+ return;
1411
+ }
1412
+ const apiVersionPolicy = {
1413
+ name: "CustomApiVersionPolicy",
1414
+ sendRequest(request, next) {
1415
+ return tslib.__awaiter(this, void 0, void 0, function* () {
1416
+ const param = request.url.split("?");
1417
+ if (param.length > 1) {
1418
+ const newParams = param[1].split("&").map((item) => {
1419
+ if (item.indexOf("api-version") > -1) {
1420
+ return "api-version=" + apiVersion;
1421
+ }
1422
+ else {
1423
+ return item;
1424
+ }
1425
+ });
1426
+ request.url = param[0] + "?" + newParams.join("&");
1427
+ }
1428
+ return next(request);
1429
+ });
1430
+ }
1431
+ };
1432
+ this.pipeline.addPolicy(apiVersionPolicy);
1317
1433
  }
1318
1434
  /**
1319
1435
  * Lists all of the available Microsoft.Features REST API operations.
@@ -1328,20 +1444,31 @@ class FeatureClient extends coreClient__namespace.ServiceClient {
1328
1444
  [Symbol.asyncIterator]() {
1329
1445
  return this;
1330
1446
  },
1331
- byPage: () => {
1332
- return this.listOperationsPagingPage(options);
1447
+ byPage: (settings) => {
1448
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1449
+ throw new Error("maxPageSize is not supported by this operation.");
1450
+ }
1451
+ return this.listOperationsPagingPage(options, settings);
1333
1452
  }
1334
1453
  };
1335
1454
  }
1336
- listOperationsPagingPage(options) {
1455
+ listOperationsPagingPage(options, settings) {
1337
1456
  return tslib.__asyncGenerator(this, arguments, function* listOperationsPagingPage_1() {
1338
- let result = yield tslib.__await(this._listOperations(options));
1339
- yield yield tslib.__await(result.value || []);
1340
- let continuationToken = result.nextLink;
1457
+ let result;
1458
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1459
+ if (!continuationToken) {
1460
+ result = yield tslib.__await(this._listOperations(options));
1461
+ let page = result.value || [];
1462
+ continuationToken = result.nextLink;
1463
+ setContinuationToken(page, continuationToken);
1464
+ yield yield tslib.__await(page);
1465
+ }
1341
1466
  while (continuationToken) {
1342
1467
  result = yield tslib.__await(this._listOperationsNext(continuationToken, options));
1343
1468
  continuationToken = result.nextLink;
1344
- yield yield tslib.__await(result.value || []);
1469
+ let page = result.value || [];
1470
+ setContinuationToken(page, continuationToken);
1471
+ yield yield tslib.__await(page);
1345
1472
  }
1346
1473
  });
1347
1474
  }
@@ -1415,4 +1542,5 @@ const listOperationsNextOperationSpec = {
1415
1542
  };
1416
1543
 
1417
1544
  exports.FeatureClient = FeatureClient;
1545
+ exports.getContinuationToken = getContinuationToken;
1418
1546
  //# sourceMappingURL=index.js.map