@azure/arm-templatespecs 2.0.2-alpha.20221102.1 → 2.1.0-alpha.20221129.1

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 (40) hide show
  1. package/CHANGELOG.md +10 -11
  2. package/dist/index.js +140 -40
  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/index.d.ts +1 -0
  7. package/dist-esm/src/index.d.ts.map +1 -1
  8. package/dist-esm/src/index.js +1 -0
  9. package/dist-esm/src/index.js.map +1 -1
  10. package/dist-esm/src/models/index.d.ts +12 -8
  11. package/dist-esm/src/models/index.d.ts.map +1 -1
  12. package/dist-esm/src/models/index.js +4 -0
  13. package/dist-esm/src/models/index.js.map +1 -1
  14. package/dist-esm/src/operations/templateSpecVersions.d.ts.map +1 -1
  15. package/dist-esm/src/operations/templateSpecVersions.js +19 -7
  16. package/dist-esm/src/operations/templateSpecVersions.js.map +1 -1
  17. package/dist-esm/src/operations/templateSpecs.d.ts.map +1 -1
  18. package/dist-esm/src/operations/templateSpecs.js +37 -14
  19. package/dist-esm/src/operations/templateSpecs.js.map +1 -1
  20. package/dist-esm/src/pagingHelper.d.ts +13 -0
  21. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  22. package/dist-esm/src/pagingHelper.js +32 -0
  23. package/dist-esm/src/pagingHelper.js.map +1 -0
  24. package/dist-esm/src/templateSpecsClient.d.ts +2 -0
  25. package/dist-esm/src/templateSpecsClient.d.ts.map +1 -1
  26. package/dist-esm/src/templateSpecsClient.js +49 -18
  27. package/dist-esm/src/templateSpecsClient.js.map +1 -1
  28. package/dist-esm/test/sampleTest.js +11 -13
  29. package/dist-esm/test/sampleTest.js.map +1 -1
  30. package/package.json +12 -8
  31. package/review/arm-templatespecs.api.md +18 -19
  32. package/src/index.ts +1 -0
  33. package/src/models/index.ts +12 -8
  34. package/src/operations/templateSpecVersions.ts +23 -9
  35. package/src/operations/templateSpecs.ts +46 -17
  36. package/src/pagingHelper.ts +39 -0
  37. package/src/templateSpecsClient.ts +60 -20
  38. package/tsconfig.json +1 -13
  39. package/types/arm-templatespecs.d.ts +23 -8
  40. package/types/tsdoc-metadata.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # Release History
2
-
3
- ## 2.0.2 (Unreleased)
4
-
5
- ### Features Added
6
-
7
- ### Breaking Changes
8
-
9
- ### Bugs Fixed
10
-
11
- ### Other Changes
12
-
2
+
3
+ ## 2.1.0 (2022-11-23)
4
+
5
+ **Features**
6
+
7
+ - Added Interface TemplateSpec
8
+ - Added Interface TemplateSpecUpdateModel
9
+ - Added Interface TemplateSpecVersion
10
+ - Added Interface TemplateSpecVersionUpdateModel
11
+
13
12
  ## 2.0.1 (2022-04-18)
14
13
 
15
14
  **features**
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,9 +69,13 @@ var coreRestPipeline__namespace = /*#__PURE__*/_interopNamespace(coreRestPipelin
37
69
  /** Known values of {@link CreatedByType} that the service accepts. */
38
70
  exports.KnownCreatedByType = void 0;
39
71
  (function (KnownCreatedByType) {
72
+ /** User */
40
73
  KnownCreatedByType["User"] = "User";
74
+ /** Application */
41
75
  KnownCreatedByType["Application"] = "Application";
76
+ /** ManagedIdentity */
42
77
  KnownCreatedByType["ManagedIdentity"] = "ManagedIdentity";
78
+ /** Key */
43
79
  KnownCreatedByType["Key"] = "Key";
44
80
  })(exports.KnownCreatedByType || (exports.KnownCreatedByType = {}));
45
81
  /** Known values of {@link TemplateSpecExpandKind} that the service accepts. */
@@ -658,20 +694,31 @@ class TemplateSpecsImpl {
658
694
  [Symbol.asyncIterator]() {
659
695
  return this;
660
696
  },
661
- byPage: () => {
662
- return this.listBySubscriptionPagingPage(options);
697
+ byPage: (settings) => {
698
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
699
+ throw new Error("maxPageSize is not supported by this operation.");
700
+ }
701
+ return this.listBySubscriptionPagingPage(options, settings);
663
702
  }
664
703
  };
665
704
  }
666
- listBySubscriptionPagingPage(options) {
705
+ listBySubscriptionPagingPage(options, settings) {
667
706
  return tslib.__asyncGenerator(this, arguments, function* listBySubscriptionPagingPage_1() {
668
- let result = yield tslib.__await(this._listBySubscription(options));
669
- yield yield tslib.__await(result.value || []);
670
- let continuationToken = result.nextLink;
707
+ let result;
708
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
709
+ if (!continuationToken) {
710
+ result = yield tslib.__await(this._listBySubscription(options));
711
+ let page = result.value || [];
712
+ continuationToken = result.nextLink;
713
+ setContinuationToken(page, continuationToken);
714
+ yield yield tslib.__await(page);
715
+ }
671
716
  while (continuationToken) {
672
717
  result = yield tslib.__await(this._listBySubscriptionNext(continuationToken, options));
673
718
  continuationToken = result.nextLink;
674
- yield yield tslib.__await(result.value || []);
719
+ let page = result.value || [];
720
+ setContinuationToken(page, continuationToken);
721
+ yield yield tslib.__await(page);
675
722
  }
676
723
  });
677
724
  }
@@ -707,20 +754,31 @@ class TemplateSpecsImpl {
707
754
  [Symbol.asyncIterator]() {
708
755
  return this;
709
756
  },
710
- byPage: () => {
711
- return this.listByResourceGroupPagingPage(resourceGroupName, options);
757
+ byPage: (settings) => {
758
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
759
+ throw new Error("maxPageSize is not supported by this operation.");
760
+ }
761
+ return this.listByResourceGroupPagingPage(resourceGroupName, options, settings);
712
762
  }
713
763
  };
714
764
  }
715
- listByResourceGroupPagingPage(resourceGroupName, options) {
765
+ listByResourceGroupPagingPage(resourceGroupName, options, settings) {
716
766
  return tslib.__asyncGenerator(this, arguments, function* listByResourceGroupPagingPage_1() {
717
- let result = yield tslib.__await(this._listByResourceGroup(resourceGroupName, options));
718
- yield yield tslib.__await(result.value || []);
719
- let continuationToken = result.nextLink;
767
+ let result;
768
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
769
+ if (!continuationToken) {
770
+ result = yield tslib.__await(this._listByResourceGroup(resourceGroupName, options));
771
+ let page = result.value || [];
772
+ continuationToken = result.nextLink;
773
+ setContinuationToken(page, continuationToken);
774
+ yield yield tslib.__await(page);
775
+ }
720
776
  while (continuationToken) {
721
777
  result = yield tslib.__await(this._listByResourceGroupNext(resourceGroupName, continuationToken, options));
722
778
  continuationToken = result.nextLink;
723
- yield yield tslib.__await(result.value || []);
779
+ let page = result.value || [];
780
+ setContinuationToken(page, continuationToken);
781
+ yield yield tslib.__await(page);
724
782
  }
725
783
  });
726
784
  }
@@ -1014,20 +1072,31 @@ class TemplateSpecVersionsImpl {
1014
1072
  [Symbol.asyncIterator]() {
1015
1073
  return this;
1016
1074
  },
1017
- byPage: () => {
1018
- return this.listPagingPage(resourceGroupName, templateSpecName, options);
1075
+ byPage: (settings) => {
1076
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1077
+ throw new Error("maxPageSize is not supported by this operation.");
1078
+ }
1079
+ return this.listPagingPage(resourceGroupName, templateSpecName, options, settings);
1019
1080
  }
1020
1081
  };
1021
1082
  }
1022
- listPagingPage(resourceGroupName, templateSpecName, options) {
1083
+ listPagingPage(resourceGroupName, templateSpecName, options, settings) {
1023
1084
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
1024
- let result = yield tslib.__await(this._list(resourceGroupName, templateSpecName, options));
1025
- yield yield tslib.__await(result.value || []);
1026
- let continuationToken = result.nextLink;
1085
+ let result;
1086
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
1087
+ if (!continuationToken) {
1088
+ result = yield tslib.__await(this._list(resourceGroupName, templateSpecName, options));
1089
+ let page = result.value || [];
1090
+ continuationToken = result.nextLink;
1091
+ setContinuationToken(page, continuationToken);
1092
+ yield yield tslib.__await(page);
1093
+ }
1027
1094
  while (continuationToken) {
1028
1095
  result = yield tslib.__await(this._listNext(resourceGroupName, templateSpecName, continuationToken, options));
1029
1096
  continuationToken = result.nextLink;
1030
- yield yield tslib.__await(result.value || []);
1097
+ let page = result.value || [];
1098
+ setContinuationToken(page, continuationToken);
1099
+ yield yield tslib.__await(page);
1031
1100
  }
1032
1101
  });
1033
1102
  }
@@ -1272,7 +1341,7 @@ class TemplateSpecsClient extends coreClient__namespace.ServiceClient {
1272
1341
  * @param options The parameter options
1273
1342
  */
1274
1343
  constructor(credentials, subscriptionId, options) {
1275
- var _a, _b;
1344
+ var _a, _b, _c;
1276
1345
  if (credentials === undefined) {
1277
1346
  throw new Error("'credentials' cannot be null");
1278
1347
  }
@@ -1287,32 +1356,34 @@ class TemplateSpecsClient extends coreClient__namespace.ServiceClient {
1287
1356
  requestContentType: "application/json; charset=utf-8",
1288
1357
  credential: credentials
1289
1358
  };
1290
- const packageDetails = `azsdk-js-arm-templatespecs/2.0.2`;
1359
+ const packageDetails = `azsdk-js-arm-templatespecs/2.1.0`;
1291
1360
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1292
1361
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1293
1362
  : `${packageDetails}`;
1294
- if (!options.credentialScopes) {
1295
- options.credentialScopes = ["https://management.azure.com/.default"];
1296
- }
1297
1363
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1298
1364
  userAgentPrefix
1299
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1365
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1300
1366
  super(optionsWithDefaults);
1367
+ let bearerTokenAuthenticationPolicyFound = false;
1301
1368
  if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
1302
1369
  const pipelinePolicies = options.pipeline.getOrderedPolicies();
1303
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1370
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1304
1371
  coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName);
1305
- if (!bearerTokenAuthenticationPolicyFound) {
1306
- this.pipeline.removePolicy({
1307
- name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1308
- });
1309
- this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1310
- scopes: `${optionsWithDefaults.baseUri}/.default`,
1311
- challengeCallbacks: {
1312
- authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1313
- }
1314
- }));
1315
- }
1372
+ }
1373
+ if (!options ||
1374
+ !options.pipeline ||
1375
+ options.pipeline.getOrderedPolicies().length == 0 ||
1376
+ !bearerTokenAuthenticationPolicyFound) {
1377
+ this.pipeline.removePolicy({
1378
+ name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1379
+ });
1380
+ this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1381
+ credential: credentials,
1382
+ scopes: (_c = optionsWithDefaults.credentialScopes) !== null && _c !== void 0 ? _c : `${optionsWithDefaults.endpoint}/.default`,
1383
+ challengeCallbacks: {
1384
+ authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1385
+ }
1386
+ }));
1316
1387
  }
1317
1388
  // Parameter assignments
1318
1389
  this.subscriptionId = subscriptionId;
@@ -1321,8 +1392,37 @@ class TemplateSpecsClient extends coreClient__namespace.ServiceClient {
1321
1392
  this.apiVersion = options.apiVersion || "2021-05-01";
1322
1393
  this.templateSpecs = new TemplateSpecsImpl(this);
1323
1394
  this.templateSpecVersions = new TemplateSpecVersionsImpl(this);
1395
+ this.addCustomApiVersionPolicy(options.apiVersion);
1396
+ }
1397
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
1398
+ addCustomApiVersionPolicy(apiVersion) {
1399
+ if (!apiVersion) {
1400
+ return;
1401
+ }
1402
+ const apiVersionPolicy = {
1403
+ name: "CustomApiVersionPolicy",
1404
+ sendRequest(request, next) {
1405
+ return tslib.__awaiter(this, void 0, void 0, function* () {
1406
+ const param = request.url.split("?");
1407
+ if (param.length > 1) {
1408
+ const newParams = param[1].split("&").map((item) => {
1409
+ if (item.indexOf("api-version") > -1) {
1410
+ return "api-version=" + apiVersion;
1411
+ }
1412
+ else {
1413
+ return item;
1414
+ }
1415
+ });
1416
+ request.url = param[0] + "?" + newParams.join("&");
1417
+ }
1418
+ return next(request);
1419
+ });
1420
+ }
1421
+ };
1422
+ this.pipeline.addPolicy(apiVersionPolicy);
1324
1423
  }
1325
1424
  }
1326
1425
 
1327
1426
  exports.TemplateSpecsClient = TemplateSpecsClient;
1427
+ exports.getContinuationToken = getContinuationToken;
1328
1428
  //# sourceMappingURL=index.js.map