-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
ReservationsExtensions.cs
705 lines (649 loc) · 45.3 KB
/
ReservationsExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.Reservations.Mocking;
using Azure.ResourceManager.Reservations.Models;
using Azure.ResourceManager.Resources;
namespace Azure.ResourceManager.Reservations
{
/// <summary> A class to add extension methods to Azure.ResourceManager.Reservations. </summary>
public static partial class ReservationsExtensions
{
private static MockableReservationsArmClient GetMockableReservationsArmClient(ArmClient client)
{
return client.GetCachedClient(client0 => new MockableReservationsArmClient(client0));
}
private static MockableReservationsSubscriptionResource GetMockableReservationsSubscriptionResource(ArmResource resource)
{
return resource.GetCachedClient(client => new MockableReservationsSubscriptionResource(client, resource.Id));
}
private static MockableReservationsTenantResource GetMockableReservationsTenantResource(ArmResource resource)
{
return resource.GetCachedClient(client => new MockableReservationsTenantResource(client, resource.Id));
}
/// <summary>
/// Gets an object representing a <see cref="ReservationDetailResource" /> along with the instance operations that can be performed on it but with no data.
/// You can use <see cref="ReservationDetailResource.CreateResourceIdentifier" /> to create a <see cref="ReservationDetailResource" /> <see cref="ResourceIdentifier" /> from its components.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsArmClient.GetReservationDetailResource(ResourceIdentifier)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="client"> The <see cref="ArmClient" /> instance the method will execute against. </param>
/// <param name="id"> The resource ID of the resource to get. </param>
/// <exception cref="ArgumentNullException"> <paramref name="client"/> is null. </exception>
/// <returns> Returns a <see cref="ReservationDetailResource"/> object. </returns>
public static ReservationDetailResource GetReservationDetailResource(this ArmClient client, ResourceIdentifier id)
{
Argument.AssertNotNull(client, nameof(client));
return GetMockableReservationsArmClient(client).GetReservationDetailResource(id);
}
/// <summary>
/// Gets an object representing a <see cref="ReservationOrderResource" /> along with the instance operations that can be performed on it but with no data.
/// You can use <see cref="ReservationOrderResource.CreateResourceIdentifier" /> to create a <see cref="ReservationOrderResource" /> <see cref="ResourceIdentifier" /> from its components.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsArmClient.GetReservationOrderResource(ResourceIdentifier)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="client"> The <see cref="ArmClient" /> instance the method will execute against. </param>
/// <param name="id"> The resource ID of the resource to get. </param>
/// <exception cref="ArgumentNullException"> <paramref name="client"/> is null. </exception>
/// <returns> Returns a <see cref="ReservationOrderResource"/> object. </returns>
public static ReservationOrderResource GetReservationOrderResource(this ArmClient client, ResourceIdentifier id)
{
Argument.AssertNotNull(client, nameof(client));
return GetMockableReservationsArmClient(client).GetReservationOrderResource(id);
}
/// <summary>
/// Gets an object representing a <see cref="ReservationQuotaResource" /> along with the instance operations that can be performed on it but with no data.
/// You can use <see cref="ReservationQuotaResource.CreateResourceIdentifier" /> to create a <see cref="ReservationQuotaResource" /> <see cref="ResourceIdentifier" /> from its components.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsArmClient.GetReservationQuotaResource(ResourceIdentifier)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="client"> The <see cref="ArmClient" /> instance the method will execute against. </param>
/// <param name="id"> The resource ID of the resource to get. </param>
/// <exception cref="ArgumentNullException"> <paramref name="client"/> is null. </exception>
/// <returns> Returns a <see cref="ReservationQuotaResource"/> object. </returns>
public static ReservationQuotaResource GetReservationQuotaResource(this ArmClient client, ResourceIdentifier id)
{
Argument.AssertNotNull(client, nameof(client));
return GetMockableReservationsArmClient(client).GetReservationQuotaResource(id);
}
/// <summary>
/// Gets an object representing a <see cref="QuotaRequestDetailResource" /> along with the instance operations that can be performed on it but with no data.
/// You can use <see cref="QuotaRequestDetailResource.CreateResourceIdentifier" /> to create a <see cref="QuotaRequestDetailResource" /> <see cref="ResourceIdentifier" /> from its components.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsArmClient.GetQuotaRequestDetailResource(ResourceIdentifier)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="client"> The <see cref="ArmClient" /> instance the method will execute against. </param>
/// <param name="id"> The resource ID of the resource to get. </param>
/// <exception cref="ArgumentNullException"> <paramref name="client"/> is null. </exception>
/// <returns> Returns a <see cref="QuotaRequestDetailResource"/> object. </returns>
public static QuotaRequestDetailResource GetQuotaRequestDetailResource(this ArmClient client, ResourceIdentifier id)
{
Argument.AssertNotNull(client, nameof(client));
return GetMockableReservationsArmClient(client).GetQuotaRequestDetailResource(id);
}
/// <summary>
/// Gets a collection of ReservationQuotaResources in the SubscriptionResource.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetAllReservationQuota(string,AzureLocation)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="providerId"> Azure resource provider ID. </param>
/// <param name="location"> Azure region. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> or <paramref name="providerId"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="providerId"/> is an empty string, and was expected to be non-empty. </exception>
/// <returns> An object representing collection of ReservationQuotaResources and their operations over a ReservationQuotaResource. </returns>
public static ReservationQuotaCollection GetAllReservationQuota(this SubscriptionResource subscriptionResource, string providerId, AzureLocation location)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetAllReservationQuota(providerId, location);
}
/// <summary>
/// Get the current quota (service limit) and usage of a resource. You can use the response from the GET operation to submit quota update request.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Quota_Get</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetReservationQuotaAsync(string,AzureLocation,string,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="providerId"> Azure resource provider ID. </param>
/// <param name="location"> Azure region. </param>
/// <param name="resourceName"> The resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/>, <paramref name="providerId"/> or <paramref name="resourceName"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="providerId"/> or <paramref name="resourceName"/> is an empty string, and was expected to be non-empty. </exception>
[ForwardsClientCalls]
public static async Task<Response<ReservationQuotaResource>> GetReservationQuotaAsync(this SubscriptionResource subscriptionResource, string providerId, AzureLocation location, string resourceName, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return await GetMockableReservationsSubscriptionResource(subscriptionResource).GetReservationQuotaAsync(providerId, location, resourceName, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Get the current quota (service limit) and usage of a resource. You can use the response from the GET operation to submit quota update request.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Quota_Get</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetReservationQuota(string,AzureLocation,string,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="providerId"> Azure resource provider ID. </param>
/// <param name="location"> Azure region. </param>
/// <param name="resourceName"> The resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/>, <paramref name="providerId"/> or <paramref name="resourceName"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="providerId"/> or <paramref name="resourceName"/> is an empty string, and was expected to be non-empty. </exception>
[ForwardsClientCalls]
public static Response<ReservationQuotaResource> GetReservationQuota(this SubscriptionResource subscriptionResource, string providerId, AzureLocation location, string resourceName, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetReservationQuota(providerId, location, resourceName, cancellationToken);
}
/// <summary>
/// Gets a collection of QuotaRequestDetailResources in the SubscriptionResource.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetQuotaRequestDetails(string,AzureLocation)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="providerId"> Azure resource provider ID. </param>
/// <param name="location"> Azure region. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> or <paramref name="providerId"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="providerId"/> is an empty string, and was expected to be non-empty. </exception>
/// <returns> An object representing collection of QuotaRequestDetailResources and their operations over a QuotaRequestDetailResource. </returns>
public static QuotaRequestDetailCollection GetQuotaRequestDetails(this SubscriptionResource subscriptionResource, string providerId, AzureLocation location)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetQuotaRequestDetails(providerId, location);
}
/// <summary>
/// For the specified Azure region (location), get the details and status of the quota request by the quota request ID for the resources of the resource provider. The PUT request for the quota (service limit) returns a response with the requestId parameter.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>QuotaRequestStatus_Get</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetQuotaRequestDetailAsync(string,AzureLocation,Guid,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="providerId"> Azure resource provider ID. </param>
/// <param name="location"> Azure region. </param>
/// <param name="id"> Quota Request ID. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> or <paramref name="providerId"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="providerId"/> is an empty string, and was expected to be non-empty. </exception>
[ForwardsClientCalls]
public static async Task<Response<QuotaRequestDetailResource>> GetQuotaRequestDetailAsync(this SubscriptionResource subscriptionResource, string providerId, AzureLocation location, Guid id, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return await GetMockableReservationsSubscriptionResource(subscriptionResource).GetQuotaRequestDetailAsync(providerId, location, id, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// For the specified Azure region (location), get the details and status of the quota request by the quota request ID for the resources of the resource provider. The PUT request for the quota (service limit) returns a response with the requestId parameter.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>QuotaRequestStatus_Get</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetQuotaRequestDetail(string,AzureLocation,Guid,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="providerId"> Azure resource provider ID. </param>
/// <param name="location"> Azure region. </param>
/// <param name="id"> Quota Request ID. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> or <paramref name="providerId"/> is null. </exception>
/// <exception cref="ArgumentException"> <paramref name="providerId"/> is an empty string, and was expected to be non-empty. </exception>
[ForwardsClientCalls]
public static Response<QuotaRequestDetailResource> GetQuotaRequestDetail(this SubscriptionResource subscriptionResource, string providerId, AzureLocation location, Guid id, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetQuotaRequestDetail(providerId, location, id, cancellationToken);
}
/// <summary>
/// Get the regions and skus that are available for RI purchase for the specified Azure subscription.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>GetCatalog</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetCatalog(SubscriptionResourceGetCatalogOptions,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="options"> A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> is null. </exception>
/// <returns> An async collection of <see cref="ReservationCatalog"/> that may take multiple service requests to iterate over. </returns>
public static AsyncPageable<ReservationCatalog> GetCatalogAsync(this SubscriptionResource subscriptionResource, SubscriptionResourceGetCatalogOptions options, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetCatalogAsync(options, cancellationToken);
}
/// <summary>
/// Get the regions and skus that are available for RI purchase for the specified Azure subscription.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>GetCatalog</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetCatalog(SubscriptionResourceGetCatalogOptions,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="options"> A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> is null. </exception>
/// <returns> A collection of <see cref="ReservationCatalog"/> that may take multiple service requests to iterate over. </returns>
public static Pageable<ReservationCatalog> GetCatalog(this SubscriptionResource subscriptionResource, SubscriptionResourceGetCatalogOptions options, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetCatalog(options, cancellationToken);
}
/// <summary>
/// Get applicable `Reservation`s that are applied to this subscription or a resource group under this subscription.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>GetAppliedReservationList</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetAppliedReservations(CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> is null. </exception>
public static async Task<Response<AppliedReservationData>> GetAppliedReservationsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return await GetMockableReservationsSubscriptionResource(subscriptionResource).GetAppliedReservationsAsync(cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Get applicable `Reservation`s that are applied to this subscription or a resource group under this subscription.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>GetAppliedReservationList</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsSubscriptionResource.GetAppliedReservations(CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="subscriptionResource"/> is null. </exception>
public static Response<AppliedReservationData> GetAppliedReservations(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
return GetMockableReservationsSubscriptionResource(subscriptionResource).GetAppliedReservations(cancellationToken);
}
/// <summary>
/// Gets a collection of ReservationOrderResources in the TenantResource.
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.GetReservationOrders()"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> is null. </exception>
/// <returns> An object representing collection of ReservationOrderResources and their operations over a ReservationOrderResource. </returns>
public static ReservationOrderCollection GetReservationOrders(this TenantResource tenantResource)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).GetReservationOrders();
}
/// <summary>
/// Get the details of the `ReservationOrder`.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>ReservationOrder_Get</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.GetReservationOrderAsync(Guid,string,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="reservationOrderId"> Order Id of the reservation. </param>
/// <param name="expand"> May be used to expand the planInformation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> is null. </exception>
[ForwardsClientCalls]
public static async Task<Response<ReservationOrderResource>> GetReservationOrderAsync(this TenantResource tenantResource, Guid reservationOrderId, string expand = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return await GetMockableReservationsTenantResource(tenantResource).GetReservationOrderAsync(reservationOrderId, expand, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Get the details of the `ReservationOrder`.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>ReservationOrder_Get</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.GetReservationOrder(Guid,string,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="reservationOrderId"> Order Id of the reservation. </param>
/// <param name="expand"> May be used to expand the planInformation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> is null. </exception>
[ForwardsClientCalls]
public static Response<ReservationOrderResource> GetReservationOrder(this TenantResource tenantResource, Guid reservationOrderId, string expand = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).GetReservationOrder(reservationOrderId, expand, cancellationToken);
}
/// <summary>
/// List the reservations and the roll up counts of reservations group by provisioning states that the user has access to in the current tenant.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/reservations</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Reservation_ListAll</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.GetReservationDetails(TenantResourceGetReservationDetailsOptions,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="options"> A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> is null. </exception>
/// <returns> An async collection of <see cref="ReservationDetailResource"/> that may take multiple service requests to iterate over. </returns>
public static AsyncPageable<ReservationDetailResource> GetReservationDetailsAsync(this TenantResource tenantResource, TenantResourceGetReservationDetailsOptions options, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).GetReservationDetailsAsync(options, cancellationToken);
}
/// <summary>
/// List the reservations and the roll up counts of reservations group by provisioning states that the user has access to in the current tenant.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/reservations</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Reservation_ListAll</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.GetReservationDetails(TenantResourceGetReservationDetailsOptions,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="options"> A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> is null. </exception>
/// <returns> A collection of <see cref="ReservationDetailResource"/> that may take multiple service requests to iterate over. </returns>
public static Pageable<ReservationDetailResource> GetReservationDetails(this TenantResource tenantResource, TenantResourceGetReservationDetailsOptions options, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).GetReservationDetails(options, cancellationToken);
}
/// <summary>
/// Calculate price for placing a `ReservationOrder`.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/calculatePrice</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>ReservationOrder_Calculate</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.CalculateReservationOrder(ReservationPurchaseContent,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="content"> Information needed for calculate or purchase reservation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> or <paramref name="content"/> is null. </exception>
public static async Task<Response<CalculatePriceResult>> CalculateReservationOrderAsync(this TenantResource tenantResource, ReservationPurchaseContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return await GetMockableReservationsTenantResource(tenantResource).CalculateReservationOrderAsync(content, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Calculate price for placing a `ReservationOrder`.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/calculatePrice</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>ReservationOrder_Calculate</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.CalculateReservationOrder(ReservationPurchaseContent,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="content"> Information needed for calculate or purchase reservation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> or <paramref name="content"/> is null. </exception>
public static Response<CalculatePriceResult> CalculateReservationOrder(this TenantResource tenantResource, ReservationPurchaseContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).CalculateReservationOrder(content, cancellationToken);
}
/// <summary>
/// Calculates price for exchanging `Reservations` if there are no policy errors.
///
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/calculateExchange</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>CalculateExchange_Post</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.CalculateReservationExchange(WaitUntil,CalculateExchangeContent,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
/// <param name="content"> Request containing purchases and refunds that need to be executed. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> or <paramref name="content"/> is null. </exception>
public static async Task<ArmOperation<CalculateExchangeResult>> CalculateReservationExchangeAsync(this TenantResource tenantResource, WaitUntil waitUntil, CalculateExchangeContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return await GetMockableReservationsTenantResource(tenantResource).CalculateReservationExchangeAsync(waitUntil, content, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Calculates price for exchanging `Reservations` if there are no policy errors.
///
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/calculateExchange</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>CalculateExchange_Post</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.CalculateReservationExchange(WaitUntil,CalculateExchangeContent,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
/// <param name="content"> Request containing purchases and refunds that need to be executed. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> or <paramref name="content"/> is null. </exception>
public static ArmOperation<CalculateExchangeResult> CalculateReservationExchange(this TenantResource tenantResource, WaitUntil waitUntil, CalculateExchangeContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).CalculateReservationExchange(waitUntil, content, cancellationToken);
}
/// <summary>
/// Returns one or more `Reservations` in exchange for one or more `Reservation` purchases.
///
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/exchange</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Exchange_Post</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.Exchange(WaitUntil,ExchangeContent,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
/// <param name="content"> Request containing the refunds and purchases that need to be executed. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> or <paramref name="content"/> is null. </exception>
public static async Task<ArmOperation<ExchangeResult>> ExchangeAsync(this TenantResource tenantResource, WaitUntil waitUntil, ExchangeContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return await GetMockableReservationsTenantResource(tenantResource).ExchangeAsync(waitUntil, content, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Returns one or more `Reservations` in exchange for one or more `Reservation` purchases.
///
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/providers/Microsoft.Capacity/exchange</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Exchange_Post</description>
/// </item>
/// </list>
/// <item>
/// <term>Mocking</term>
/// <description>To mock this method, please mock <see cref="MockableReservationsTenantResource.Exchange(WaitUntil,ExchangeContent,CancellationToken)"/> instead.</description>
/// </item>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
/// <param name="content"> Request containing the refunds and purchases that need to be executed. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="tenantResource"/> or <paramref name="content"/> is null. </exception>
public static ArmOperation<ExchangeResult> Exchange(this TenantResource tenantResource, WaitUntil waitUntil, ExchangeContent content, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(tenantResource, nameof(tenantResource));
return GetMockableReservationsTenantResource(tenantResource).Exchange(waitUntil, content, cancellationToken);
}
}
}