@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
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { Reservation } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -18,10 +19,13 @@ import {
18
19
  ReservationResponse,
19
20
  ReservationListNextOptionalParams,
20
21
  ReservationListOptionalParams,
22
+ ReservationListResponse,
21
23
  ReservationListRevisionsNextOptionalParams,
22
24
  ReservationListRevisionsOptionalParams,
25
+ ReservationListRevisionsResponse,
23
26
  ReservationListAllNextOptionalParams,
24
27
  ReservationListAllOptionalParams,
28
+ ReservationListAllResponse,
25
29
  AvailableScopeRequest,
26
30
  ReservationAvailableScopesOptionalParams,
27
31
  ReservationAvailableScopesResponse,
@@ -31,7 +35,6 @@ import {
31
35
  MergeRequest,
32
36
  ReservationMergeOptionalParams,
33
37
  ReservationMergeResponse,
34
- ReservationListResponse,
35
38
  ReservationGetOptionalParams,
36
39
  ReservationGetResponse,
37
40
  Patch,
@@ -39,8 +42,6 @@ import {
39
42
  ReservationUpdateResponse,
40
43
  ReservationArchiveOptionalParams,
41
44
  ReservationUnarchiveOptionalParams,
42
- ReservationListRevisionsResponse,
43
- ReservationListAllResponse,
44
45
  ReservationListNextResponse,
45
46
  ReservationListRevisionsNextResponse,
46
47
  ReservationListAllNextResponse
@@ -76,19 +77,29 @@ export class ReservationImpl implements Reservation {
76
77
  [Symbol.asyncIterator]() {
77
78
  return this;
78
79
  },
79
- byPage: () => {
80
- return this.listPagingPage(reservationOrderId, options);
80
+ byPage: (settings?: PageSettings) => {
81
+ if (settings?.maxPageSize) {
82
+ throw new Error("maxPageSize is not supported by this operation.");
83
+ }
84
+ return this.listPagingPage(reservationOrderId, options, settings);
81
85
  }
82
86
  };
83
87
  }
84
88
 
85
89
  private async *listPagingPage(
86
90
  reservationOrderId: string,
87
- options?: ReservationListOptionalParams
91
+ options?: ReservationListOptionalParams,
92
+ settings?: PageSettings
88
93
  ): AsyncIterableIterator<ReservationResponse[]> {
89
- let result = await this._list(reservationOrderId, options);
90
- yield result.value || [];
91
- let continuationToken = result.nextLink;
94
+ let result: ReservationListResponse;
95
+ let continuationToken = settings?.continuationToken;
96
+ if (!continuationToken) {
97
+ result = await this._list(reservationOrderId, options);
98
+ let page = result.value || [];
99
+ continuationToken = result.nextLink;
100
+ setContinuationToken(page, continuationToken);
101
+ yield page;
102
+ }
92
103
  while (continuationToken) {
93
104
  result = await this._listNext(
94
105
  reservationOrderId,
@@ -96,7 +107,9 @@ export class ReservationImpl implements Reservation {
96
107
  options
97
108
  );
98
109
  continuationToken = result.nextLink;
99
- yield result.value || [];
110
+ let page = result.value || [];
111
+ setContinuationToken(page, continuationToken);
112
+ yield page;
100
113
  }
101
114
  }
102
115
 
@@ -111,18 +124,18 @@ export class ReservationImpl implements Reservation {
111
124
 
112
125
  /**
113
126
  * List of all the revisions for the `Reservation`.
114
- * @param reservationId Id of the Reservation Item
115
127
  * @param reservationOrderId Order Id of the reservation
128
+ * @param reservationId Id of the reservation item
116
129
  * @param options The options parameters.
117
130
  */
118
131
  public listRevisions(
119
- reservationId: string,
120
132
  reservationOrderId: string,
133
+ reservationId: string,
121
134
  options?: ReservationListRevisionsOptionalParams
122
135
  ): PagedAsyncIterableIterator<ReservationResponse> {
123
136
  const iter = this.listRevisionsPagingAll(
124
- reservationId,
125
137
  reservationOrderId,
138
+ reservationId,
126
139
  options
127
140
  );
128
141
  return {
@@ -132,48 +145,61 @@ export class ReservationImpl implements Reservation {
132
145
  [Symbol.asyncIterator]() {
133
146
  return this;
134
147
  },
135
- byPage: () => {
148
+ byPage: (settings?: PageSettings) => {
149
+ if (settings?.maxPageSize) {
150
+ throw new Error("maxPageSize is not supported by this operation.");
151
+ }
136
152
  return this.listRevisionsPagingPage(
137
- reservationId,
138
153
  reservationOrderId,
139
- options
154
+ reservationId,
155
+ options,
156
+ settings
140
157
  );
141
158
  }
142
159
  };
143
160
  }
144
161
 
145
162
  private async *listRevisionsPagingPage(
146
- reservationId: string,
147
163
  reservationOrderId: string,
148
- options?: ReservationListRevisionsOptionalParams
164
+ reservationId: string,
165
+ options?: ReservationListRevisionsOptionalParams,
166
+ settings?: PageSettings
149
167
  ): AsyncIterableIterator<ReservationResponse[]> {
150
- let result = await this._listRevisions(
151
- reservationId,
152
- reservationOrderId,
153
- options
154
- );
155
- yield result.value || [];
156
- let continuationToken = result.nextLink;
168
+ let result: ReservationListRevisionsResponse;
169
+ let continuationToken = settings?.continuationToken;
170
+ if (!continuationToken) {
171
+ result = await this._listRevisions(
172
+ reservationOrderId,
173
+ reservationId,
174
+ options
175
+ );
176
+ let page = result.value || [];
177
+ continuationToken = result.nextLink;
178
+ setContinuationToken(page, continuationToken);
179
+ yield page;
180
+ }
157
181
  while (continuationToken) {
158
182
  result = await this._listRevisionsNext(
159
- reservationId,
160
183
  reservationOrderId,
184
+ reservationId,
161
185
  continuationToken,
162
186
  options
163
187
  );
164
188
  continuationToken = result.nextLink;
165
- yield result.value || [];
189
+ let page = result.value || [];
190
+ setContinuationToken(page, continuationToken);
191
+ yield page;
166
192
  }
167
193
  }
168
194
 
169
195
  private async *listRevisionsPagingAll(
170
- reservationId: string,
171
196
  reservationOrderId: string,
197
+ reservationId: string,
172
198
  options?: ReservationListRevisionsOptionalParams
173
199
  ): AsyncIterableIterator<ReservationResponse> {
174
200
  for await (const page of this.listRevisionsPagingPage(
175
- reservationId,
176
201
  reservationOrderId,
202
+ reservationId,
177
203
  options
178
204
  )) {
179
205
  yield* page;
@@ -196,22 +222,34 @@ export class ReservationImpl implements Reservation {
196
222
  [Symbol.asyncIterator]() {
197
223
  return this;
198
224
  },
199
- byPage: () => {
200
- return this.listAllPagingPage(options);
225
+ byPage: (settings?: PageSettings) => {
226
+ if (settings?.maxPageSize) {
227
+ throw new Error("maxPageSize is not supported by this operation.");
228
+ }
229
+ return this.listAllPagingPage(options, settings);
201
230
  }
202
231
  };
203
232
  }
204
233
 
205
234
  private async *listAllPagingPage(
206
- options?: ReservationListAllOptionalParams
235
+ options?: ReservationListAllOptionalParams,
236
+ settings?: PageSettings
207
237
  ): AsyncIterableIterator<ReservationResponse[]> {
208
- let result = await this._listAll(options);
209
- yield result.value || [];
210
- let continuationToken = result.nextLink;
238
+ let result: ReservationListAllResponse;
239
+ let continuationToken = settings?.continuationToken;
240
+ if (!continuationToken) {
241
+ result = await this._listAll(options);
242
+ let page = result.value || [];
243
+ continuationToken = result.nextLink;
244
+ setContinuationToken(page, continuationToken);
245
+ yield page;
246
+ }
211
247
  while (continuationToken) {
212
248
  result = await this._listAllNext(continuationToken, options);
213
249
  continuationToken = result.nextLink;
214
- yield result.value || [];
250
+ let page = result.value || [];
251
+ setContinuationToken(page, continuationToken);
252
+ yield page;
215
253
  }
216
254
  }
217
255
 
@@ -224,11 +262,11 @@ export class ReservationImpl implements Reservation {
224
262
  }
225
263
 
226
264
  /**
227
- * Get Available Scopes for `Reservation`.
265
+ * Check whether the scopes from request is valid for `Reservation`.
228
266
  *
229
267
  * @param reservationOrderId Order Id of the reservation
230
- * @param reservationId Id of the Reservation Item
231
- * @param body Available scope
268
+ * @param reservationId Id of the reservation item
269
+ * @param body Scopes to be checked for eligibility.
232
270
  * @param options The options parameters.
233
271
  */
234
272
  async beginAvailableScopes(
@@ -295,11 +333,11 @@ export class ReservationImpl implements Reservation {
295
333
  }
296
334
 
297
335
  /**
298
- * Get Available Scopes for `Reservation`.
336
+ * Check whether the scopes from request is valid for `Reservation`.
299
337
  *
300
338
  * @param reservationOrderId Order Id of the reservation
301
- * @param reservationId Id of the Reservation Item
302
- * @param body Available scope
339
+ * @param reservationId Id of the reservation item
340
+ * @param body Scopes to be checked for eligibility.
303
341
  * @param options The options parameters.
304
342
  */
305
343
  async beginAvailableScopesAndWait(
@@ -504,17 +542,17 @@ export class ReservationImpl implements Reservation {
504
542
 
505
543
  /**
506
544
  * Get specific `Reservation` details.
507
- * @param reservationId Id of the Reservation Item
508
545
  * @param reservationOrderId Order Id of the reservation
546
+ * @param reservationId Id of the reservation item
509
547
  * @param options The options parameters.
510
548
  */
511
549
  get(
512
- reservationId: string,
513
550
  reservationOrderId: string,
551
+ reservationId: string,
514
552
  options?: ReservationGetOptionalParams
515
553
  ): Promise<ReservationGetResponse> {
516
554
  return this.client.sendOperationRequest(
517
- { reservationId, reservationOrderId, options },
555
+ { reservationOrderId, reservationId, options },
518
556
  getOperationSpec
519
557
  );
520
558
  }
@@ -522,7 +560,7 @@ export class ReservationImpl implements Reservation {
522
560
  /**
523
561
  * Updates the applied scopes of the `Reservation`.
524
562
  * @param reservationOrderId Order Id of the reservation
525
- * @param reservationId Id of the Reservation Item
563
+ * @param reservationId Id of the reservation item
526
564
  * @param parameters Information needed to patch a reservation item
527
565
  * @param options The options parameters.
528
566
  */
@@ -583,7 +621,8 @@ export class ReservationImpl implements Reservation {
583
621
  );
584
622
  const poller = new LroEngine(lro, {
585
623
  resumeFrom: options?.resumeFrom,
586
- intervalInMs: options?.updateIntervalInMs
624
+ intervalInMs: options?.updateIntervalInMs,
625
+ lroResourceLocationConfig: "azure-async-operation"
587
626
  });
588
627
  await poller.poll();
589
628
  return poller;
@@ -592,7 +631,7 @@ export class ReservationImpl implements Reservation {
592
631
  /**
593
632
  * Updates the applied scopes of the `Reservation`.
594
633
  * @param reservationOrderId Order Id of the reservation
595
- * @param reservationId Id of the Reservation Item
634
+ * @param reservationId Id of the reservation item
596
635
  * @param parameters Information needed to patch a reservation item
597
636
  * @param options The options parameters.
598
637
  */
@@ -614,7 +653,7 @@ export class ReservationImpl implements Reservation {
614
653
  /**
615
654
  * Archiving a `Reservation` moves it to `Archived` state.
616
655
  * @param reservationOrderId Order Id of the reservation
617
- * @param reservationId Id of the Reservation Item
656
+ * @param reservationId Id of the reservation item
618
657
  * @param options The options parameters.
619
658
  */
620
659
  archive(
@@ -629,10 +668,10 @@ export class ReservationImpl implements Reservation {
629
668
  }
630
669
 
631
670
  /**
632
- * Unarchiving a `Reservation` moves it to the state it was before archiving.
671
+ * Restores a `Reservation` to the state it was before archiving.
633
672
  *
634
673
  * @param reservationOrderId Order Id of the reservation
635
- * @param reservationId Id of the Reservation Item
674
+ * @param reservationId Id of the reservation item
636
675
  * @param options The options parameters.
637
676
  */
638
677
  unarchive(
@@ -648,17 +687,17 @@ export class ReservationImpl implements Reservation {
648
687
 
649
688
  /**
650
689
  * List of all the revisions for the `Reservation`.
651
- * @param reservationId Id of the Reservation Item
652
690
  * @param reservationOrderId Order Id of the reservation
691
+ * @param reservationId Id of the reservation item
653
692
  * @param options The options parameters.
654
693
  */
655
694
  private _listRevisions(
656
- reservationId: string,
657
695
  reservationOrderId: string,
696
+ reservationId: string,
658
697
  options?: ReservationListRevisionsOptionalParams
659
698
  ): Promise<ReservationListRevisionsResponse> {
660
699
  return this.client.sendOperationRequest(
661
- { reservationId, reservationOrderId, options },
700
+ { reservationOrderId, reservationId, options },
662
701
  listRevisionsOperationSpec
663
702
  );
664
703
  }
@@ -693,19 +732,19 @@ export class ReservationImpl implements Reservation {
693
732
 
694
733
  /**
695
734
  * ListRevisionsNext
696
- * @param reservationId Id of the Reservation Item
697
735
  * @param reservationOrderId Order Id of the reservation
736
+ * @param reservationId Id of the reservation item
698
737
  * @param nextLink The nextLink from the previous successful call to the ListRevisions method.
699
738
  * @param options The options parameters.
700
739
  */
701
740
  private _listRevisionsNext(
702
- reservationId: string,
703
741
  reservationOrderId: string,
742
+ reservationId: string,
704
743
  nextLink: string,
705
744
  options?: ReservationListRevisionsNextOptionalParams
706
745
  ): Promise<ReservationListRevisionsNextResponse> {
707
746
  return this.client.sendOperationRequest(
708
- { reservationId, reservationOrderId, nextLink, options },
747
+ { reservationOrderId, reservationId, nextLink, options },
709
748
  listRevisionsNextOperationSpec
710
749
  );
711
750
  }
@@ -1036,7 +1075,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
1036
1075
  bodyMapper: Mappers.ErrorModel
1037
1076
  }
1038
1077
  },
1039
- queryParameters: [Parameters.apiVersion],
1040
1078
  urlParameters: [
1041
1079
  Parameters.$host,
1042
1080
  Parameters.reservationOrderId,
@@ -1056,7 +1094,6 @@ const listRevisionsNextOperationSpec: coreClient.OperationSpec = {
1056
1094
  bodyMapper: Mappers.ErrorModel
1057
1095
  }
1058
1096
  },
1059
- queryParameters: [Parameters.apiVersion],
1060
1097
  urlParameters: [
1061
1098
  Parameters.$host,
1062
1099
  Parameters.reservationOrderId,
@@ -1077,15 +1114,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = {
1077
1114
  bodyMapper: Mappers.ErrorResponse
1078
1115
  }
1079
1116
  },
1080
- queryParameters: [
1081
- Parameters.apiVersion,
1082
- Parameters.filter,
1083
- Parameters.orderby,
1084
- Parameters.refreshSummary,
1085
- Parameters.skiptoken,
1086
- Parameters.selectedState,
1087
- Parameters.take
1088
- ],
1089
1117
  urlParameters: [Parameters.$host, Parameters.nextLink],
1090
1118
  headerParameters: [Parameters.accept],
1091
1119
  serializer
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { ReservationOrder } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -18,10 +19,10 @@ import {
18
19
  ReservationOrderResponse,
19
20
  ReservationOrderListNextOptionalParams,
20
21
  ReservationOrderListOptionalParams,
22
+ ReservationOrderListResponse,
21
23
  PurchaseRequest,
22
24
  ReservationOrderCalculateOptionalParams,
23
25
  ReservationOrderCalculateResponse,
24
- ReservationOrderListResponse,
25
26
  ReservationOrderPurchaseOptionalParams,
26
27
  ReservationOrderPurchaseResponse,
27
28
  ReservationOrderGetOptionalParams,
@@ -60,22 +61,34 @@ export class ReservationOrderImpl implements ReservationOrder {
60
61
  [Symbol.asyncIterator]() {
61
62
  return this;
62
63
  },
63
- byPage: () => {
64
- return this.listPagingPage(options);
64
+ byPage: (settings?: PageSettings) => {
65
+ if (settings?.maxPageSize) {
66
+ throw new Error("maxPageSize is not supported by this operation.");
67
+ }
68
+ return this.listPagingPage(options, settings);
65
69
  }
66
70
  };
67
71
  }
68
72
 
69
73
  private async *listPagingPage(
70
- options?: ReservationOrderListOptionalParams
74
+ options?: ReservationOrderListOptionalParams,
75
+ settings?: PageSettings
71
76
  ): AsyncIterableIterator<ReservationOrderResponse[]> {
72
- let result = await this._list(options);
73
- yield result.value || [];
74
- let continuationToken = result.nextLink;
77
+ let result: ReservationOrderListResponse;
78
+ let continuationToken = settings?.continuationToken;
79
+ if (!continuationToken) {
80
+ result = await this._list(options);
81
+ let page = result.value || [];
82
+ continuationToken = result.nextLink;
83
+ setContinuationToken(page, continuationToken);
84
+ yield page;
85
+ }
75
86
  while (continuationToken) {
76
87
  result = await this._listNext(continuationToken, options);
77
88
  continuationToken = result.nextLink;
78
- yield result.value || [];
89
+ let page = result.value || [];
90
+ setContinuationToken(page, continuationToken);
91
+ yield page;
79
92
  }
80
93
  }
81
94
 
@@ -319,7 +332,7 @@ const getOperationSpec: coreClient.OperationSpec = {
319
332
  bodyMapper: Mappers.ErrorModel
320
333
  }
321
334
  },
322
- queryParameters: [Parameters.apiVersion, Parameters.expand1],
335
+ queryParameters: [Parameters.apiVersion, Parameters.expand],
323
336
  urlParameters: [Parameters.$host, Parameters.reservationOrderId],
324
337
  headerParameters: [Parameters.accept],
325
338
  serializer
@@ -354,7 +367,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
354
367
  bodyMapper: Mappers.ErrorModel
355
368
  }
356
369
  },
357
- queryParameters: [Parameters.apiVersion],
358
370
  urlParameters: [Parameters.$host, Parameters.nextLink],
359
371
  headerParameters: [Parameters.accept],
360
372
  serializer
@@ -11,6 +11,8 @@ import * as coreClient from "@azure/core-client";
11
11
  import * as Mappers from "../models/mappers";
12
12
  import * as Parameters from "../models/parameters";
13
13
  import { AzureReservationAPI } from "../azureReservationAPI";
14
+ import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro";
15
+ import { LroImpl } from "../lroImpl";
14
16
  import {
15
17
  RefundRequest,
16
18
  ReturnPostOptionalParams,
@@ -30,20 +32,84 @@ export class ReturnImpl implements Return {
30
32
  }
31
33
 
32
34
  /**
33
- * Return a reservation.
35
+ * Return a reservation and get refund information.
34
36
  * @param reservationOrderId Order Id of the reservation
35
37
  * @param body Information needed for returning reservation.
36
38
  * @param options The options parameters.
37
39
  */
38
- post(
40
+ async beginPost(
39
41
  reservationOrderId: string,
40
42
  body: RefundRequest,
41
43
  options?: ReturnPostOptionalParams
42
- ): Promise<ReturnPostResponse> {
43
- return this.client.sendOperationRequest(
44
+ ): Promise<
45
+ PollerLike<PollOperationState<ReturnPostResponse>, ReturnPostResponse>
46
+ > {
47
+ const directSendOperation = async (
48
+ args: coreClient.OperationArguments,
49
+ spec: coreClient.OperationSpec
50
+ ): Promise<ReturnPostResponse> => {
51
+ return this.client.sendOperationRequest(args, spec);
52
+ };
53
+ const sendOperation = async (
54
+ args: coreClient.OperationArguments,
55
+ spec: coreClient.OperationSpec
56
+ ) => {
57
+ let currentRawResponse:
58
+ | coreClient.FullOperationResponse
59
+ | undefined = undefined;
60
+ const providedCallback = args.options?.onResponse;
61
+ const callback: coreClient.RawResponseCallback = (
62
+ rawResponse: coreClient.FullOperationResponse,
63
+ flatResponse: unknown
64
+ ) => {
65
+ currentRawResponse = rawResponse;
66
+ providedCallback?.(rawResponse, flatResponse);
67
+ };
68
+ const updatedArgs = {
69
+ ...args,
70
+ options: {
71
+ ...args.options,
72
+ onResponse: callback
73
+ }
74
+ };
75
+ const flatResponse = await directSendOperation(updatedArgs, spec);
76
+ return {
77
+ flatResponse,
78
+ rawResponse: {
79
+ statusCode: currentRawResponse!.status,
80
+ body: currentRawResponse!.parsedBody,
81
+ headers: currentRawResponse!.headers.toJSON()
82
+ }
83
+ };
84
+ };
85
+
86
+ const lro = new LroImpl(
87
+ sendOperation,
44
88
  { reservationOrderId, body, options },
45
89
  postOperationSpec
46
90
  );
91
+ const poller = new LroEngine(lro, {
92
+ resumeFrom: options?.resumeFrom,
93
+ intervalInMs: options?.updateIntervalInMs,
94
+ lroResourceLocationConfig: "location"
95
+ });
96
+ await poller.poll();
97
+ return poller;
98
+ }
99
+
100
+ /**
101
+ * Return a reservation and get refund information.
102
+ * @param reservationOrderId Order Id of the reservation
103
+ * @param body Information needed for returning reservation.
104
+ * @param options The options parameters.
105
+ */
106
+ async beginPostAndWait(
107
+ reservationOrderId: string,
108
+ body: RefundRequest,
109
+ options?: ReturnPostOptionalParams
110
+ ): Promise<ReturnPostResponse> {
111
+ const poller = await this.beginPost(reservationOrderId, body, options);
112
+ return poller.pollUntilDone();
47
113
  }
48
114
  }
49
115
  // Operation Specifications
@@ -54,10 +120,22 @@ const postOperationSpec: coreClient.OperationSpec = {
54
120
  "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/return",
55
121
  httpMethod: "POST",
56
122
  responses: {
123
+ 200: {
124
+ bodyMapper: Mappers.RefundResponse,
125
+ headersMapper: Mappers.ReturnPostHeaders
126
+ },
127
+ 201: {
128
+ bodyMapper: Mappers.RefundResponse,
129
+ headersMapper: Mappers.ReturnPostHeaders
130
+ },
57
131
  202: {
58
132
  bodyMapper: Mappers.RefundResponse,
59
133
  headersMapper: Mappers.ReturnPostHeaders
60
134
  },
135
+ 204: {
136
+ bodyMapper: Mappers.RefundResponse,
137
+ headersMapper: Mappers.ReturnPostHeaders
138
+ },
61
139
  default: {
62
140
  bodyMapper: Mappers.ErrorModel
63
141
  }