@azure/arm-operations 4.0.0-beta.3 → 4.0.0-beta.4

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.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Release History
2
2
 
3
- ## 4.0.0-beta.3 (2022-05-11)
3
+ ## 4.0.0-beta.4 (2022-12-02)
4
4
 
5
- The package of @azure/arm-operations is using our next generation design principles since version 4.0.0-beta.3, which contains breaking changes.
5
+ The package of @azure/arm-operations is using our next generation design principles since version 4.0.0-beta.4, which contains breaking changes.
6
6
 
7
7
  To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog).
8
8
 
package/README.md CHANGED
@@ -13,7 +13,7 @@ Operations Management Client
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
@@ -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
  var coreLro = require('@azure/core-lro');
9
9
 
10
10
  function _interopNamespace(e) {
@@ -28,6 +28,29 @@ function _interopNamespace(e) {
28
28
  var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
29
29
  var coreRestPipeline__namespace = /*#__PURE__*/_interopNamespace(coreRestPipeline);
30
30
 
31
+ /*
32
+ * Copyright (c) Microsoft Corporation.
33
+ * Licensed under the MIT License.
34
+ *
35
+ * Code generated by Microsoft (R) AutoRest Code Generator.
36
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
37
+ */
38
+ const pageMap = new WeakMap();
39
+ /**
40
+ * Given a result page from a pageable operation, returns a
41
+ * continuation token that can be used to begin paging from
42
+ * that point later.
43
+ * @param page A result object from calling .byPage() on a paged operation.
44
+ * @returns The continuation token that can be passed into byPage().
45
+ */
46
+ function getContinuationToken(page) {
47
+ var _a;
48
+ if (typeof page !== "object" || page === null) {
49
+ return undefined;
50
+ }
51
+ return (_a = pageMap.get(page)) === null || _a === void 0 ? void 0 : _a.continuationToken;
52
+ }
53
+
31
54
  /*
32
55
  * Copyright (c) Microsoft Corporation.
33
56
  * Licensed under the MIT License.
@@ -1397,14 +1420,18 @@ class OperationsImpl {
1397
1420
  [Symbol.asyncIterator]() {
1398
1421
  return this;
1399
1422
  },
1400
- byPage: () => {
1401
- return this.listPagingPage(options);
1423
+ byPage: (settings) => {
1424
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
1425
+ throw new Error("maxPageSize is not supported by this operation.");
1426
+ }
1427
+ return this.listPagingPage(options, settings);
1402
1428
  }
1403
1429
  };
1404
1430
  }
1405
- listPagingPage(options) {
1431
+ listPagingPage(options, _settings) {
1406
1432
  return tslib.__asyncGenerator(this, arguments, function* listPagingPage_1() {
1407
- let result = yield tslib.__await(this._list(options));
1433
+ let result;
1434
+ result = yield tslib.__await(this._list(options));
1408
1435
  yield yield tslib.__await(result.value || []);
1409
1436
  });
1410
1437
  }
@@ -1466,7 +1493,7 @@ class OperationsManagementClient extends coreClient__namespace.ServiceClient {
1466
1493
  * @param options The parameter options
1467
1494
  */
1468
1495
  constructor(credentials, subscriptionId, options) {
1469
- var _a, _b;
1496
+ var _a, _b, _c;
1470
1497
  if (credentials === undefined) {
1471
1498
  throw new Error("'credentials' cannot be null");
1472
1499
  }
@@ -1481,32 +1508,34 @@ class OperationsManagementClient extends coreClient__namespace.ServiceClient {
1481
1508
  requestContentType: "application/json; charset=utf-8",
1482
1509
  credential: credentials
1483
1510
  };
1484
- const packageDetails = `azsdk-js-arm-operations/4.0.0-beta.3`;
1511
+ const packageDetails = `azsdk-js-arm-operations/4.0.0-beta.4`;
1485
1512
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1486
1513
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1487
1514
  : `${packageDetails}`;
1488
- if (!options.credentialScopes) {
1489
- options.credentialScopes = ["https://management.azure.com/.default"];
1490
- }
1491
1515
  const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1492
1516
  userAgentPrefix
1493
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1517
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "https://management.azure.com" });
1494
1518
  super(optionsWithDefaults);
1519
+ let bearerTokenAuthenticationPolicyFound = false;
1495
1520
  if ((options === null || options === void 0 ? void 0 : options.pipeline) && options.pipeline.getOrderedPolicies().length > 0) {
1496
1521
  const pipelinePolicies = options.pipeline.getOrderedPolicies();
1497
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1522
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some((pipelinePolicy) => pipelinePolicy.name ===
1498
1523
  coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName);
1499
- if (!bearerTokenAuthenticationPolicyFound) {
1500
- this.pipeline.removePolicy({
1501
- name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1502
- });
1503
- this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1504
- scopes: `${optionsWithDefaults.baseUri}/.default`,
1505
- challengeCallbacks: {
1506
- authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1507
- }
1508
- }));
1509
- }
1524
+ }
1525
+ if (!options ||
1526
+ !options.pipeline ||
1527
+ options.pipeline.getOrderedPolicies().length == 0 ||
1528
+ !bearerTokenAuthenticationPolicyFound) {
1529
+ this.pipeline.removePolicy({
1530
+ name: coreRestPipeline__namespace.bearerTokenAuthenticationPolicyName
1531
+ });
1532
+ this.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
1533
+ credential: credentials,
1534
+ scopes: (_c = optionsWithDefaults.credentialScopes) !== null && _c !== void 0 ? _c : `${optionsWithDefaults.endpoint}/.default`,
1535
+ challengeCallbacks: {
1536
+ authorizeRequestOnChallenge: coreClient__namespace.authorizeRequestOnClaimChallenge
1537
+ }
1538
+ }));
1510
1539
  }
1511
1540
  // Parameter assignments
1512
1541
  this.subscriptionId = subscriptionId;
@@ -1517,8 +1546,37 @@ class OperationsManagementClient extends coreClient__namespace.ServiceClient {
1517
1546
  this.managementAssociations = new ManagementAssociationsImpl(this);
1518
1547
  this.managementConfigurations = new ManagementConfigurationsImpl(this);
1519
1548
  this.operations = new OperationsImpl(this);
1549
+ this.addCustomApiVersionPolicy(options.apiVersion);
1550
+ }
1551
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
1552
+ addCustomApiVersionPolicy(apiVersion) {
1553
+ if (!apiVersion) {
1554
+ return;
1555
+ }
1556
+ const apiVersionPolicy = {
1557
+ name: "CustomApiVersionPolicy",
1558
+ sendRequest(request, next) {
1559
+ return tslib.__awaiter(this, void 0, void 0, function* () {
1560
+ const param = request.url.split("?");
1561
+ if (param.length > 1) {
1562
+ const newParams = param[1].split("&").map((item) => {
1563
+ if (item.indexOf("api-version") > -1) {
1564
+ return "api-version=" + apiVersion;
1565
+ }
1566
+ else {
1567
+ return item;
1568
+ }
1569
+ });
1570
+ request.url = param[0] + "?" + newParams.join("&");
1571
+ }
1572
+ return next(request);
1573
+ });
1574
+ }
1575
+ };
1576
+ this.pipeline.addPolicy(apiVersionPolicy);
1520
1577
  }
1521
1578
  }
1522
1579
 
1523
1580
  exports.OperationsManagementClient = OperationsManagementClient;
1581
+ exports.getContinuationToken = getContinuationToken;
1524
1582
  //# sourceMappingURL=index.js.map