@azure/arm-reservations 7.2.1-alpha.20230202.1 → 8.0.0-alpha.20230210.2

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 (128) hide show
  1. package/CHANGELOG.md +71 -8
  2. package/LICENSE +1 -1
  3. package/dist/index.js +942 -224
  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/samples-dev/calculateExchangePostSample.js +22 -2
  8. package/dist-esm/samples-dev/calculateExchangePostSample.js.map +1 -1
  9. package/dist-esm/samples-dev/calculateRefundPostSample.js +10 -3
  10. package/dist-esm/samples-dev/calculateRefundPostSample.js.map +1 -1
  11. package/dist-esm/samples-dev/exchangePostSample.js +9 -2
  12. package/dist-esm/samples-dev/exchangePostSample.js.map +1 -1
  13. package/dist-esm/samples-dev/getAppliedReservationListSample.js +9 -2
  14. package/dist-esm/samples-dev/getAppliedReservationListSample.js.map +1 -1
  15. package/dist-esm/samples-dev/getCatalogSample.js +26 -5
  16. package/dist-esm/samples-dev/getCatalogSample.js.map +1 -1
  17. package/dist-esm/samples-dev/operationListSample.js +9 -2
  18. package/dist-esm/samples-dev/operationListSample.js.map +1 -1
  19. package/dist-esm/samples-dev/quotaCreateOrUpdateSample.js +10 -3
  20. package/dist-esm/samples-dev/quotaCreateOrUpdateSample.js.map +1 -1
  21. package/dist-esm/samples-dev/quotaGetSample.js +8 -1
  22. package/dist-esm/samples-dev/quotaGetSample.js.map +1 -1
  23. package/dist-esm/samples-dev/quotaListSample.js +9 -2
  24. package/dist-esm/samples-dev/quotaListSample.js.map +1 -1
  25. package/dist-esm/samples-dev/quotaRequestStatusGetSample.js +10 -3
  26. package/dist-esm/samples-dev/quotaRequestStatusGetSample.js.map +1 -1
  27. package/dist-esm/samples-dev/quotaRequestStatusListSample.js +8 -1
  28. package/dist-esm/samples-dev/quotaRequestStatusListSample.js.map +1 -1
  29. package/dist-esm/samples-dev/quotaUpdateSample.js +8 -1
  30. package/dist-esm/samples-dev/quotaUpdateSample.js.map +1 -1
  31. package/dist-esm/samples-dev/reservationArchiveSample.js +9 -2
  32. package/dist-esm/samples-dev/reservationArchiveSample.js.map +1 -1
  33. package/dist-esm/samples-dev/reservationAvailableScopesSample.js +11 -4
  34. package/dist-esm/samples-dev/reservationAvailableScopesSample.js.map +1 -1
  35. package/dist-esm/samples-dev/reservationGetSample.js +11 -4
  36. package/dist-esm/samples-dev/reservationGetSample.js.map +1 -1
  37. package/dist-esm/samples-dev/reservationListAllSample.js +10 -3
  38. package/dist-esm/samples-dev/reservationListAllSample.js.map +1 -1
  39. package/dist-esm/samples-dev/reservationListRevisionsSample.js +11 -4
  40. package/dist-esm/samples-dev/reservationListRevisionsSample.js.map +1 -1
  41. package/dist-esm/samples-dev/reservationListSample.js +9 -2
  42. package/dist-esm/samples-dev/reservationListSample.js.map +1 -1
  43. package/dist-esm/samples-dev/reservationMergeSample.js +9 -2
  44. package/dist-esm/samples-dev/reservationMergeSample.js.map +1 -1
  45. package/dist-esm/samples-dev/reservationOrderCalculateSample.js +10 -3
  46. package/dist-esm/samples-dev/reservationOrderCalculateSample.js.map +1 -1
  47. package/dist-esm/samples-dev/reservationOrderChangeDirectorySample.js +9 -2
  48. package/dist-esm/samples-dev/reservationOrderChangeDirectorySample.js.map +1 -1
  49. package/dist-esm/samples-dev/reservationOrderGetSample.js +12 -5
  50. package/dist-esm/samples-dev/reservationOrderGetSample.js.map +1 -1
  51. package/dist-esm/samples-dev/reservationOrderListSample.js +9 -2
  52. package/dist-esm/samples-dev/reservationOrderListSample.js.map +1 -1
  53. package/dist-esm/samples-dev/reservationOrderPurchaseSample.js +9 -2
  54. package/dist-esm/samples-dev/reservationOrderPurchaseSample.js.map +1 -1
  55. package/dist-esm/samples-dev/reservationSplitSample.js +9 -2
  56. package/dist-esm/samples-dev/reservationSplitSample.js.map +1 -1
  57. package/dist-esm/samples-dev/reservationUnarchiveSample.js +11 -4
  58. package/dist-esm/samples-dev/reservationUnarchiveSample.js.map +1 -1
  59. package/dist-esm/samples-dev/reservationUpdateSample.js +9 -2
  60. package/dist-esm/samples-dev/reservationUpdateSample.js.map +1 -1
  61. package/dist-esm/samples-dev/returnPostSample.js +14 -7
  62. package/dist-esm/samples-dev/returnPostSample.js.map +1 -1
  63. package/dist-esm/src/azureReservationAPI.d.ts +18 -2
  64. package/dist-esm/src/azureReservationAPI.d.ts.map +1 -1
  65. package/dist-esm/src/azureReservationAPI.js +101 -15
  66. package/dist-esm/src/azureReservationAPI.js.map +1 -1
  67. package/dist-esm/src/index.d.ts +1 -0
  68. package/dist-esm/src/index.d.ts.map +1 -1
  69. package/dist-esm/src/index.js +1 -0
  70. package/dist-esm/src/index.js.map +1 -1
  71. package/dist-esm/src/models/index.d.ts +372 -101
  72. package/dist-esm/src/models/index.d.ts.map +1 -1
  73. package/dist-esm/src/models/index.js +26 -0
  74. package/dist-esm/src/models/index.js.map +1 -1
  75. package/dist-esm/src/models/mappers.d.ts +14 -1
  76. package/dist-esm/src/models/mappers.d.ts.map +1 -1
  77. package/dist-esm/src/models/mappers.js +510 -70
  78. package/dist-esm/src/models/mappers.js.map +1 -1
  79. package/dist-esm/src/models/parameters.d.ts +2 -1
  80. package/dist-esm/src/models/parameters.d.ts.map +1 -1
  81. package/dist-esm/src/models/parameters.js +18 -9
  82. package/dist-esm/src/models/parameters.js.map +1 -1
  83. package/dist-esm/src/operations/operation.d.ts.map +1 -1
  84. package/dist-esm/src/operations/operation.js +19 -8
  85. package/dist-esm/src/operations/operation.js.map +1 -1
  86. package/dist-esm/src/operations/quota.d.ts.map +1 -1
  87. package/dist-esm/src/operations/quota.js +19 -8
  88. package/dist-esm/src/operations/quota.js.map +1 -1
  89. package/dist-esm/src/operations/quotaRequestStatus.d.ts.map +1 -1
  90. package/dist-esm/src/operations/quotaRequestStatus.js +19 -13
  91. package/dist-esm/src/operations/quotaRequestStatus.js.map +1 -1
  92. package/dist-esm/src/operations/reservation.d.ts +17 -17
  93. package/dist-esm/src/operations/reservation.d.ts.map +1 -1
  94. package/dist-esm/src/operations/reservation.js +83 -59
  95. package/dist-esm/src/operations/reservation.js.map +1 -1
  96. package/dist-esm/src/operations/reservationOrder.d.ts.map +1 -1
  97. package/dist-esm/src/operations/reservationOrder.js +20 -9
  98. package/dist-esm/src/operations/reservationOrder.js.map +1 -1
  99. package/dist-esm/src/operations/return.d.ts +10 -2
  100. package/dist-esm/src/operations/return.d.ts.map +1 -1
  101. package/dist-esm/src/operations/return.js +61 -3
  102. package/dist-esm/src/operations/return.js.map +1 -1
  103. package/dist-esm/src/operationsInterfaces/reservation.d.ts +15 -15
  104. package/dist-esm/src/operationsInterfaces/reservation.d.ts.map +1 -1
  105. package/dist-esm/src/operationsInterfaces/return.d.ts +10 -2
  106. package/dist-esm/src/operationsInterfaces/return.d.ts.map +1 -1
  107. package/dist-esm/src/pagingHelper.d.ts +13 -0
  108. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  109. package/dist-esm/src/pagingHelper.js +32 -0
  110. package/dist-esm/src/pagingHelper.js.map +1 -0
  111. package/package.json +6 -4
  112. package/review/arm-reservations.api.md +194 -94
  113. package/src/azureReservationAPI.ts +119 -15
  114. package/src/index.ts +1 -0
  115. package/src/models/index.ts +397 -107
  116. package/src/models/mappers.ts +536 -71
  117. package/src/models/parameters.ts +19 -9
  118. package/src/operations/operation.ts +21 -9
  119. package/src/operations/quota.ts +23 -15
  120. package/src/operations/quotaRequestStatus.ts +23 -20
  121. package/src/operations/reservation.ts +97 -69
  122. package/src/operations/reservationOrder.ts +23 -11
  123. package/src/operations/return.ts +82 -4
  124. package/src/operationsInterfaces/reservation.ts +15 -15
  125. package/src/operationsInterfaces/return.ts +16 -2
  126. package/src/pagingHelper.ts +39 -0
  127. package/types/arm-reservations.d.ts +432 -109
  128. package/types/tsdoc-metadata.json +1 -1
@@ -9,6 +9,8 @@
9
9
  import * as coreClient from "@azure/core-client";
10
10
  import * as coreRestPipeline from "@azure/core-rest-pipeline";
11
11
  import * as coreAuth from "@azure/core-auth";
12
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
13
+ import { setContinuationToken } from "./pagingHelper";
12
14
  import {
13
15
  ReservationImpl,
14
16
  ReservationOrderImpl,
@@ -35,12 +37,16 @@ import * as Parameters from "./models/parameters";
35
37
  import * as Mappers from "./models/mappers";
36
38
  import {
37
39
  AzureReservationAPIOptionalParams,
40
+ Catalog,
41
+ GetCatalogNextOptionalParams,
38
42
  GetCatalogOptionalParams,
39
43
  GetCatalogResponse,
40
44
  GetAppliedReservationListOptionalParams,
41
- GetAppliedReservationListResponse
45
+ GetAppliedReservationListResponse,
46
+ GetCatalogNextResponse
42
47
  } from "./models";
43
48
 
49
+ /// <reference lib="esnext.asynciterable" />
44
50
  export class AzureReservationAPI extends coreClient.ServiceClient {
45
51
  $host: string;
46
52
 
@@ -66,22 +72,19 @@ export class AzureReservationAPI extends coreClient.ServiceClient {
66
72
  credential: credentials
67
73
  };
68
74
 
69
- const packageDetails = `azsdk-js-arm-reservations/7.2.1`;
75
+ const packageDetails = `azsdk-js-arm-reservations/8.0.0`;
70
76
  const userAgentPrefix =
71
77
  options.userAgentOptions && options.userAgentOptions.userAgentPrefix
72
78
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
73
79
  : `${packageDetails}`;
74
80
 
75
- if (!options.credentialScopes) {
76
- options.credentialScopes = ["https://management.azure.com/.default"];
77
- }
78
81
  const optionsWithDefaults = {
79
82
  ...defaults,
80
83
  ...options,
81
84
  userAgentOptions: {
82
85
  userAgentPrefix
83
86
  },
84
- baseUri:
87
+ endpoint:
85
88
  options.endpoint ?? options.baseUri ?? "https://management.azure.com"
86
89
  };
87
90
  super(optionsWithDefaults);
@@ -107,7 +110,9 @@ export class AzureReservationAPI extends coreClient.ServiceClient {
107
110
  this.pipeline.addPolicy(
108
111
  coreRestPipeline.bearerTokenAuthenticationPolicy({
109
112
  credential: credentials,
110
- scopes: `${optionsWithDefaults.credentialScopes}`,
113
+ scopes:
114
+ optionsWithDefaults.credentialScopes ??
115
+ `${optionsWithDefaults.endpoint}/.default`,
111
116
  challengeCallbacks: {
112
117
  authorizeRequestOnChallenge:
113
118
  coreClient.authorizeRequestOnClaimChallenge
@@ -134,7 +139,72 @@ export class AzureReservationAPI extends coreClient.ServiceClient {
134
139
  * @param subscriptionId Id of the subscription
135
140
  * @param options The options parameters.
136
141
  */
137
- getCatalog(
142
+ public listCatalog(
143
+ subscriptionId: string,
144
+ options?: GetCatalogOptionalParams
145
+ ): PagedAsyncIterableIterator<Catalog> {
146
+ const iter = this.getCatalogPagingAll(subscriptionId, options);
147
+ return {
148
+ next() {
149
+ return iter.next();
150
+ },
151
+ [Symbol.asyncIterator]() {
152
+ return this;
153
+ },
154
+ byPage: (settings?: PageSettings) => {
155
+ if (settings?.maxPageSize) {
156
+ throw new Error("maxPageSize is not supported by this operation.");
157
+ }
158
+ return this.getCatalogPagingPage(subscriptionId, options, settings);
159
+ }
160
+ };
161
+ }
162
+
163
+ private async *getCatalogPagingPage(
164
+ subscriptionId: string,
165
+ options?: GetCatalogOptionalParams,
166
+ settings?: PageSettings
167
+ ): AsyncIterableIterator<Catalog[]> {
168
+ let result: GetCatalogResponse;
169
+ let continuationToken = settings?.continuationToken;
170
+ if (!continuationToken) {
171
+ result = await this._getCatalog(subscriptionId, options);
172
+ let page = result.value || [];
173
+ continuationToken = result.nextLink;
174
+ setContinuationToken(page, continuationToken);
175
+ yield page;
176
+ }
177
+ while (continuationToken) {
178
+ result = await this._getCatalogNext(
179
+ subscriptionId,
180
+ continuationToken,
181
+ options
182
+ );
183
+ continuationToken = result.nextLink;
184
+ let page = result.value || [];
185
+ setContinuationToken(page, continuationToken);
186
+ yield page;
187
+ }
188
+ }
189
+
190
+ private async *getCatalogPagingAll(
191
+ subscriptionId: string,
192
+ options?: GetCatalogOptionalParams
193
+ ): AsyncIterableIterator<Catalog> {
194
+ for await (const page of this.getCatalogPagingPage(
195
+ subscriptionId,
196
+ options
197
+ )) {
198
+ yield* page;
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Get the regions and skus that are available for RI purchase for the specified Azure subscription.
204
+ * @param subscriptionId Id of the subscription
205
+ * @param options The options parameters.
206
+ */
207
+ private _getCatalog(
138
208
  subscriptionId: string,
139
209
  options?: GetCatalogOptionalParams
140
210
  ): Promise<GetCatalogResponse> {
@@ -160,6 +230,23 @@ export class AzureReservationAPI extends coreClient.ServiceClient {
160
230
  );
161
231
  }
162
232
 
233
+ /**
234
+ * GetCatalogNext
235
+ * @param subscriptionId Id of the subscription
236
+ * @param nextLink The nextLink from the previous successful call to the GetCatalog method.
237
+ * @param options The options parameters.
238
+ */
239
+ private _getCatalogNext(
240
+ subscriptionId: string,
241
+ nextLink: string,
242
+ options?: GetCatalogNextOptionalParams
243
+ ): Promise<GetCatalogNextResponse> {
244
+ return this.sendOperationRequest(
245
+ { subscriptionId, nextLink, options },
246
+ getCatalogNextOperationSpec
247
+ );
248
+ }
249
+
163
250
  reservation: Reservation;
164
251
  reservationOrder: ReservationOrder;
165
252
  operation: Operation;
@@ -178,12 +265,7 @@ const getCatalogOperationSpec: coreClient.OperationSpec = {
178
265
  httpMethod: "GET",
179
266
  responses: {
180
267
  200: {
181
- bodyMapper: {
182
- type: {
183
- name: "Sequence",
184
- element: { type: { name: "Composite", className: "Catalog" } }
185
- }
186
- }
268
+ bodyMapper: Mappers.CatalogsResult
187
269
  },
188
270
  default: {
189
271
  bodyMapper: Mappers.ErrorModel
@@ -191,11 +273,14 @@ const getCatalogOperationSpec: coreClient.OperationSpec = {
191
273
  },
192
274
  queryParameters: [
193
275
  Parameters.apiVersion,
276
+ Parameters.filter,
194
277
  Parameters.reservedResourceType,
195
278
  Parameters.location,
196
279
  Parameters.publisherId,
197
280
  Parameters.offerId,
198
- Parameters.planId
281
+ Parameters.planId,
282
+ Parameters.skip,
283
+ Parameters.take1
199
284
  ],
200
285
  urlParameters: [Parameters.$host, Parameters.subscriptionId],
201
286
  headerParameters: [Parameters.accept],
@@ -218,3 +303,22 @@ const getAppliedReservationListOperationSpec: coreClient.OperationSpec = {
218
303
  headerParameters: [Parameters.accept],
219
304
  serializer
220
305
  };
306
+ const getCatalogNextOperationSpec: coreClient.OperationSpec = {
307
+ path: "{nextLink}",
308
+ httpMethod: "GET",
309
+ responses: {
310
+ 200: {
311
+ bodyMapper: Mappers.CatalogsResult
312
+ },
313
+ default: {
314
+ bodyMapper: Mappers.ErrorModel
315
+ }
316
+ },
317
+ urlParameters: [
318
+ Parameters.$host,
319
+ Parameters.nextLink,
320
+ Parameters.subscriptionId
321
+ ],
322
+ headerParameters: [Parameters.accept],
323
+ serializer
324
+ };
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  /// <reference lib="esnext.asynciterable" />
10
+ export { getContinuationToken } from "./pagingHelper";
10
11
  export * from "./models";
11
12
  export { AzureReservationAPI } from "./azureReservationAPI";
12
13
  export * from "./operationsInterfaces";