-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
ReservationsExtensions.cs
151 lines (144 loc) · 10 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Azure.ResourceManager.Resources;
using System.Threading;
using Azure.ResourceManager.Reservations.Models;
using Azure.Core;
namespace Azure.ResourceManager.Reservations
{
public static partial class ReservationsExtensions
{
/// <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>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="filter"> May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support 'ne', 'gt', 'le', 'ge', or 'not'. Reservation properties include sku/name, properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDate, provisioningState, quantity, renew, reservedResourceType, term, userFriendlyAppliedScopeType, userFriendlyRenewState}. </param>
/// <param name="orderby"> May be used to sort order by reservation properties. </param>
/// <param name="refreshSummary"> To indicate whether to refresh the roll up counts of the reservations group by provisioning states. </param>
/// <param name="skiptoken"> The number of reservations to skip from the list before returning results. </param>
/// <param name="selectedState"> The selected provisioning state. </param>
/// <param name="take"> To number of reservations to return. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <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, string filter = null, string orderby = null, string refreshSummary = null, float? skiptoken = null, string selectedState = null, float? take = null, CancellationToken cancellationToken = default)
{
TenantResourceGetReservationDetailsOptions options = new TenantResourceGetReservationDetailsOptions();
options.Filter = filter;
options.Orderby = orderby;
options.RefreshSummary = refreshSummary;
options.Skiptoken = skiptoken;
options.SelectedState = selectedState;
options.Take = take;
return 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>
/// </summary>
/// <param name="tenantResource"> The <see cref="TenantResource" /> instance the method will execute against. </param>
/// <param name="filter"> May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support 'ne', 'gt', 'le', 'ge', or 'not'. Reservation properties include sku/name, properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDate, provisioningState, quantity, renew, reservedResourceType, term, userFriendlyAppliedScopeType, userFriendlyRenewState}. </param>
/// <param name="orderby"> May be used to sort order by reservation properties. </param>
/// <param name="refreshSummary"> To indicate whether to refresh the roll up counts of the reservations group by provisioning states. </param>
/// <param name="skiptoken"> The number of reservations to skip from the list before returning results. </param>
/// <param name="selectedState"> The selected provisioning state. </param>
/// <param name="take"> To number of reservations to return. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <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, string filter = null, string orderby = null, string refreshSummary = null, float? skiptoken = null, string selectedState = null, float? take = null, CancellationToken cancellationToken = default)
{
TenantResourceGetReservationDetailsOptions options = new TenantResourceGetReservationDetailsOptions();
options.Filter = filter;
options.Orderby = orderby;
options.RefreshSummary = refreshSummary;
options.Skiptoken = skiptoken;
options.SelectedState = selectedState;
options.Take = take;
return tenantResource.GetReservationDetails(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>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="reservedResourceType"> The type of the resource for which the skus should be provided. </param>
/// <param name="location"> Filters the skus based on the location specified in this parameter. This can be an azure region or global. </param>
/// <param name="publisherId"> Publisher id used to get the third party products. </param>
/// <param name="offerId"> Offer id used to get the third party products. </param>
/// <param name="planId"> Plan id used to get the third party products. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <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, string reservedResourceType = null, AzureLocation? location = null, string publisherId = null, string offerId = null, string planId = null, CancellationToken cancellationToken = default)
{
SubscriptionResourceGetCatalogOptions options = new SubscriptionResourceGetCatalogOptions
{
ReservedResourceType = reservedResourceType,
Location = location,
PublisherId = publisherId,
OfferId = offerId,
PlanId = planId
};
return 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>
/// </summary>
/// <param name="subscriptionResource"> The <see cref="SubscriptionResource" /> instance the method will execute against. </param>
/// <param name="reservedResourceType"> The type of the resource for which the skus should be provided. </param>
/// <param name="location"> Filters the skus based on the location specified in this parameter. This can be an azure region or global. </param>
/// <param name="publisherId"> Publisher id used to get the third party products. </param>
/// <param name="offerId"> Offer id used to get the third party products. </param>
/// <param name="planId"> Plan id used to get the third party products. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <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, string reservedResourceType = null, AzureLocation? location = null, string publisherId = null, string offerId = null, string planId = null, CancellationToken cancellationToken = default)
{
SubscriptionResourceGetCatalogOptions options = new SubscriptionResourceGetCatalogOptions
{
ReservedResourceType = reservedResourceType,
Location = location,
PublisherId = publisherId,
OfferId = offerId,
PlanId = planId
};
return subscriptionResource.GetCatalog(options, cancellationToken);
}
}
}