Skip to content

Commit c9cbaee

Browse files
authored
Merge pull request Azure#10525 from Only2125/xishan/powerpower
Update to latest sdk version and priovide new api of CalculatePrice and Purchase
2 parents e20463c + 3fb9813 commit c9cbaee

36 files changed

+1702
-463
lines changed

src/Accounts/Accounts/AzureRmAlias/Mappings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,9 @@
19111911
"Merge-AzReservation": "Merge-AzureRmReservation",
19121912
"Split-AzReservation": "Split-AzureRmReservation",
19131913
"Get-AzReservationOrderId": "Get-AzureRmReservationOrderId",
1914-
"Get-AzReservationCatalog": "Get-AzureRmReservationCatalog"
1914+
"Get-AzReservationCatalog": "Get-AzureRmReservationCatalog",
1915+
"Get-AzReservationQuote": "Get-AzureRmReservationQuote",
1916+
"New-AzReservation": "New-AzureRmReservation"
19151917
},
19161918
"Az.ResourceGraph": {
19171919
"Search-AzGraph": "Search-AzureRmGraph"

src/Reservations/Reservations.Test/Reservations.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.Reservations" Version="1.9.1-preview" />
14+
<PackageReference Include="Microsoft.Azure.Management.Reservations" Version="1.13.0-preview" />
1515
</ItemGroup>
1616

1717
</Project>

src/Reservations/Reservations.Test/ScenarioTests/ReservationOrderTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Test-GetReservationOrder
2222
# Please create reservation through portal and use id to run tests
2323
# Once reservation is created you will have reservationOrderId to run this test
2424
$type = "Microsoft.Capacity/reservationOrders"
25-
$reservationOrderId = "704aee8c-c906-47c7-bd22-781841fb48b5"
25+
$reservationOrderId = "154ed3db-262c-40e5-baa3-a0505b6cdfdd"
2626
$reservation = Get-AzReservationOrder -ReservationOrderId $reservationOrderId
2727

2828
Assert-NotNull $reservation

src/Reservations/Reservations.Test/ScenarioTests/ReservationTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,19 @@ public void TestGetCatalog()
9292
{
9393
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetCatalog");
9494
}
95+
96+
[Fact]
97+
[Trait(Category.AcceptanceType, Category.CheckIn)]
98+
public void TestCalculatePrice()
99+
{
100+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CalculatePrice");
101+
}
102+
103+
[Fact]
104+
[Trait(Category.AcceptanceType, Category.CheckIn)]
105+
public void TestPurchase()
106+
{
107+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-Purchase");
108+
}
95109
}
96110
}

src/Reservations/Reservations.Test/ScenarioTests/ReservationTests.ps1

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# Please create reservation through portal and use id to run tests
1717
# Once reservation is created you will have reservationOrderId (which is container for reservation),
1818
# reservationId, subscriptionId to run this test
19-
$subscriptionId ="302110e3-cd4e-4244-9874-07c91853c809"
20-
$reservationOrderId = "704aee8c-c906-47c7-bd22-781841fb48b5"
21-
$reservationId = "ac7f6b04-ff45-4da1-83f3-b0f2f6c8128e"
19+
$subscriptionId ="d3ae48e5-dbb2-4618-afd4-fb1b8559cb80"
20+
$reservationOrderId = "b9fbc5c6-fa93-4c1d-b7dc-81a786af5813"
21+
$reservationId = "d42d1cd5-9ea9-4a93-b3ca-c50a2ab0c0b9"
2222

2323
<#
2424
.SYNOPSIS
@@ -67,6 +67,48 @@ function Test-GetCatalog
6767
}
6868
}
6969

70+
<#
71+
.SYNOPSIS
72+
Calculate price
73+
#>
74+
function Test-CalculatePrice
75+
{
76+
$reservedResourceType = "VirtualMachines"
77+
$location = "westus"
78+
$term = "P1Y"
79+
$quantity = 1
80+
$billingPlan = "Upfront"
81+
$applyScopeType = "Shared"
82+
$renew = $false
83+
$sku = "standard_b1ls"
84+
$disPlayName = "test"
85+
86+
$calculateP = Get-AzReservationQuote -ReservedResourceType $reservedResourceType -Location $location -BillingScopeId $subscriptionId -Term $term -Quantity $quantity -BillingPlan $billingPlan -AppliedScopeType $applyScopeType -Sku $sku -DisplayName $disPlayName
87+
Assert-NotNull $calculateP
88+
Assert-NotNull $calculateP.ReservationOrderId
89+
}
90+
91+
<#
92+
.SYNOPSIS
93+
Purchase
94+
#>
95+
function Test-Purchase
96+
{
97+
$roId = "53f2a7dd-04ba-4354-afa8-68301b2d3d28"
98+
$reservedResourceType = "VirtualMachines"
99+
$location = "westus"
100+
$term = "P1Y"
101+
$quantity = 1
102+
$billingPlan = "Upfront"
103+
$applyScopeType = "Shared"
104+
$renew = $false
105+
$sku = "standard_b1ls"
106+
$disPlayName = "test"
107+
108+
$purcahseResult = New-AzReservation -ReservationOrderId $roId -ReservedResourceType $reservedResourceType -Location $location -BillingScopeId $subscriptionId -Term $term -Quantity $quantity -BillingPlan $billingPlan -AppliedScopeType $applyScopeType -Sku $sku -DisplayName $disPlayName
109+
Assert-NotNull $purcahseResult
110+
}
111+
70112
<#
71113
.SYNOPSIS
72114
Get applied reservation list
@@ -90,9 +132,11 @@ Split reservation
90132
#>
91133
function Test-SplitReservation
92134
{
135+
$reservationOrderIdSplit = "0c0e972c-a418-497c-8fc9-96b5d43fcb1d"
136+
$reservationIdSplit = "5d941ba9-22d0-46f5-8194-ca00001bb180"
93137
$type = "Microsoft.Capacity/reservationOrders/reservations"
94138

95-
$splitResult = Split-AzReservation -ReservationOrderId $reservationOrderId -ReservationId $reservationId -Quantity 1,1
139+
$splitResult = Split-AzReservation -ReservationOrderId $reservationOrderIdSplit -ReservationId $reservationIdSplit -Quantity 1,2
96140
Foreach ($splitItem in $splitResult)
97141
{
98142
Assert-NotNull $splitItem
@@ -110,10 +154,11 @@ Merge reservations
110154
#>
111155
function Test-MergeReservation
112156
{
113-
$reservationId1 = "efcd2077-baa6-4be3-8190-2b9ba939c8bc"
114-
$reservationId2 = "0281e256-5b31-424a-8df8-e67f6531113a"
157+
$reservationId1 = "5ae9e6f9-6193-4d0b-9c49-d59d5b19fe53"
158+
$reservationId2 = "4a60de37-8be3-4c67-ba15-1c7722f6a008"
159+
$reservationOrderIdMerge = "0c0e972c-a418-497c-8fc9-96b5d43fcb1d"
115160
$type = "Microsoft.Capacity/reservationOrders/reservations"
116-
$mergeResult = Merge-AzReservation -ReservationOrderId $reservationOrderId -ReservationId $reservationId1,$reservationId2
161+
$mergeResult = Merge-AzReservation -ReservationOrderId $reservationOrderIdMerge -ReservationId $reservationId1,$reservationId2
117162
Foreach ($mergeItem in $mergeResult)
118163
{
119164
Assert-NotNull $mergeItem
@@ -151,17 +196,20 @@ function Test-GetReservation
151196
.SYNOPSIS
152197
Update reservation
153198
#>
199+
$ReservationOrderIdTestScope = "11e0f3cb-d8d2-42d4-8b24-b460cab90b67"
200+
$ReservationIdTestScope = "153f4fea-dde4-4656-949a-50e3191840c9"
201+
154202
function Test-UpdateReservationToShared
155203
{
156204
$type = "Microsoft.Capacity/reservationOrders/reservations"
157205

158-
$reservationItem = Update-AzReservation -ReservationOrderId $reservationOrderId -ReservationId $reservationId -appliedscopetype Shared -InstanceFlexibility On
206+
$reservationItem = Update-AzReservation -ReservationOrderId $ReservationOrderIdTestScope -ReservationId $ReservationIdTestScope -appliedscopetype Shared -InstanceFlexibility On
159207

160208
Assert-NotNull $reservationItem
161209
Assert-NotNull $reservationItem.Etag
162210

163-
$name = $reservationOrderId + '/' + $reservationId
164-
$id = "/providers/microsoft.capacity/reservationOrders/" + $reservationOrderId + "/reservations/" + $reservationId
211+
$name = $ReservationOrderIdTestScope + '/' + $ReservationIdTestScope
212+
$id = "/providers/microsoft.capacity/reservationOrders/" + $ReservationOrderIdTestScope + "/reservations/" + $ReservationIdTestScope
165213

166214
Assert-AreEqual $reservationItem.Id $id
167215
Assert-AreEqual $reservationItem.Name $name
@@ -176,15 +224,15 @@ Update reservation
176224
function Test-UpdateReservationToSingle
177225
{
178226
$type = "Microsoft.Capacity/reservationOrders/reservations"
179-
$subscription = "/subscriptions/302110e3-cd4e-4244-9874-07c91853c809"
227+
$subscription = "/subscriptions/d3ae48e5-dbb2-4618-afd4-fb1b8559cb80"
180228

181-
$reservationItem = Update-AzReservation -ReservationOrderId $reservationOrderId -ReservationId $reservationId -appliedscopetype Single -appliedscope $subscription -InstanceFlexibility On
229+
$reservationItem = Update-AzReservation -ReservationOrderId $ReservationOrderIdTestScope -ReservationId $ReservationIdTestScope -appliedscopetype Single -appliedscope $subscription -InstanceFlexibility On
182230

183231
Assert-NotNull $reservationItem
184232
Assert-NotNull $reservationItem.Etag
185233

186-
$name = $reservationOrderId + '/' + $reservationId
187-
$id = "/providers/microsoft.capacity/reservationOrders/" + $reservationOrderId + "/reservations/" + $reservationId
234+
$name = $ReservationOrderIdTestScope + '/' + $ReservationIdTestScope
235+
$id = "/providers/microsoft.capacity/reservationOrders/" + $ReservationOrderIdTestScope + "/reservations/" + $ReservationIdTestScope
188236

189237
Assert-AreEqual $reservationItem.Id $id
190238
Assert-AreEqual $reservationItem.Name $name
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
{
22
"Entries": [
33
{
4-
"RequestUri": "/providers/Microsoft.Capacity/reservationOrders/704aee8c-c906-47c7-bd22-781841fb48b5?api-version=2018-06-01",
5-
"EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ2FwYWNpdHkvcmVzZXJ2YXRpb25PcmRlcnMvNzA0YWVlOGMtYzkwNi00N2M3LWJkMjItNzgxODQxZmI0OGI1P2FwaS12ZXJzaW9uPTIwMTgtMDYtMDE=",
4+
"RequestUri": "/providers/Microsoft.Capacity/reservationOrders/154ed3db-262c-40e5-baa3-a0505b6cdfdd?api-version=2019-04-01",
5+
"EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ2FwYWNpdHkvcmVzZXJ2YXRpb25PcmRlcnMvMTU0ZWQzZGItMjYyYy00MGU1LWJhYTMtYTA1MDViNmNkZmRkP2FwaS12ZXJzaW9uPTIwMTktMDQtMDE=",
66
"RequestMethod": "GET",
77
"RequestBody": "",
88
"RequestHeaders": {
99
"x-ms-client-request-id": [
10-
"43a914ff-665c-4702-9fee-2ac3232fd2ef"
10+
"587d5e9e-2ffa-4f09-98bc-e9c6dd331a48"
1111
],
12-
"accept-language": [
12+
"Accept-Language": [
1313
"en-US"
1414
],
1515
"User-Agent": [
16-
"FxVersion/4.7.3056.0",
17-
"OSName/Windows10Enterprise",
18-
"OSVersion/6.3.17134",
19-
"Microsoft.Azure.Management.Reservations.AzureReservationAPIClient/1.8.0.0"
16+
"FxVersion/4.6.28008.01",
17+
"OSName/Windows",
18+
"OSVersion/Microsoft.Windows.10.0.18363.",
19+
"Microsoft.Azure.Management.Reservations.AzureReservationAPIClient/1.13.0.0"
2020
]
2121
},
22-
"ResponseBody": "{\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/704aee8c-c906-47c7-bd22-781841fb48b5\",\r\n \"type\": \"Microsoft.Capacity/reservationOrders\",\r\n \"name\": \"704aee8c-c906-47c7-bd22-781841fb48b5\",\r\n \"etag\": 7,\r\n \"properties\": {\r\n \"displayName\": \"Powershell_Test\",\r\n \"requestDateTime\": \"2018-06-15T21:31:16.0556902Z\",\r\n \"createdDateTime\": \"2018-06-15T21:33:26.9606767Z\",\r\n \"expiryDate\": \"2019-06-15\",\r\n \"term\": \"P1Y\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"reservations\": [\r\n {\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/704aee8c-c906-47c7-bd22-781841fb48b5/reservations/ac7f6b04-ff45-4da1-83f3-b0f2f6c8128e\"\r\n }\r\n ],\r\n \"originalQuantity\": 2\r\n }\r\n}",
2322
"ResponseHeaders": {
24-
"Content-Length": [
25-
"592"
26-
],
27-
"Content-Type": [
28-
"application/json; charset=utf-8"
29-
],
30-
"Expires": [
31-
"-1"
23+
"Cache-Control": [
24+
"no-cache"
3225
],
3326
"Pragma": [
3427
"no-cache"
@@ -37,38 +30,45 @@
3730
"Accept-Encoding"
3831
],
3932
"x-ms-ratelimit-remaining-tenant-reads": [
40-
"14998"
33+
"11998"
4134
],
4235
"x-ms-request-id": [
43-
"westus:ebefe513-99b6-46fe-a03d-5fb1a915b0ca"
36+
"westcentralus:3ddf5057-6fd1-4595-926e-2dfd8e1649e8"
4437
],
4538
"X-Content-Type-Options": [
4639
"nosniff"
4740
],
41+
"Server": [
42+
"Microsoft-IIS/10.0"
43+
],
4844
"x-ms-correlation-request-id": [
49-
"040e3bb3-b829-4376-befe-8805d274df0a"
45+
"c9735a25-7b16-4b21-bd16-4137003cce8c"
5046
],
5147
"x-ms-routing-request-id": [
52-
"WESTUS2:20180615T215528Z:040e3bb3-b829-4376-befe-8805d274df0a"
48+
"WESTUS2:20191110T233648Z:c9735a25-7b16-4b21-bd16-4137003cce8c"
5349
],
5450
"Strict-Transport-Security": [
5551
"max-age=31536000; includeSubDomains"
5652
],
57-
"Cache-Control": [
58-
"no-cache"
59-
],
6053
"Date": [
61-
"Fri, 15 Jun 2018 21:55:27 GMT"
54+
"Sun, 10 Nov 2019 23:36:48 GMT"
6255
],
63-
"Server": [
64-
"Microsoft-IIS/8.5"
56+
"Content-Length": [
57+
"1057"
58+
],
59+
"Content-Type": [
60+
"application/json; charset=utf-8"
61+
],
62+
"Expires": [
63+
"-1"
6564
]
6665
},
66+
"ResponseBody": "{\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/154ed3db-262c-40e5-baa3-a0505b6cdfdd\",\r\n \"type\": \"Microsoft.Capacity/reservationOrders\",\r\n \"name\": \"154ed3db-262c-40e5-baa3-a0505b6cdfdd\",\r\n \"etag\": 11,\r\n \"properties\": {\r\n \"displayName\": \"TestPurchaseReservation\",\r\n \"requestDateTime\": \"2019-09-12T01:06:51.4409141Z\",\r\n \"createdDateTime\": \"2019-09-12T01:09:55.7425829Z\",\r\n \"expiryDate\": \"2020-09-12\",\r\n \"term\": \"P1Y\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"reservations\": [\r\n {\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/154ed3db-262c-40e5-baa3-a0505b6cdfdd/reservations/4bcb5164-bda0-43d6-82b2-31b97c9e1e45\"\r\n },\r\n {\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/154ed3db-262c-40e5-baa3-a0505b6cdfdd/reservations/77826aff-df48-48e9-a1a9-193e491c2fe4\"\r\n },\r\n {\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/154ed3db-262c-40e5-baa3-a0505b6cdfdd/reservations/a5a08bd1-ae00-424f-a6f3-27e3c7a59139\"\r\n },\r\n {\r\n \"id\": \"/providers/microsoft.capacity/reservationOrders/154ed3db-262c-40e5-baa3-a0505b6cdfdd/reservations/dc69bacc-87ba-496b-aa2f-40fa168192e0\"\r\n }\r\n ],\r\n \"originalQuantity\": 3,\r\n \"billingPlan\": \"Upfront\"\r\n }\r\n}",
6767
"StatusCode": 200
6868
}
6969
],
7070
"Names": {},
7171
"Variables": {
72-
"SubscriptionId": "302110e3-cd4e-4244-9874-07c91853c809"
72+
"SubscriptionId": "d3ae48e5-dbb2-4618-afd4-fb1b8559cb80"
7373
}
7474
}

src/Reservations/Reservations.Test/SessionRecords/Microsoft.Azure.Commands.Reservations.Test.ScenarioTests.ReservationOrderTests/TestListReservationOrders.json

Lines changed: 76 additions & 19 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/providers/Microsoft.Capacity/calculatePrice?api-version=2019-04-01",
5+
"EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ2FwYWNpdHkvY2FsY3VsYXRlUHJpY2U/YXBpLXZlcnNpb249MjAxOS0wNC0wMQ==",
6+
"RequestMethod": "POST",
7+
"RequestBody": "{\r\n \"sku\": {\r\n \"name\": \"standard_b1ls\"\r\n },\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"reservedResourceType\": \"VirtualMachines\",\r\n \"billingScopeId\": \"d3ae48e5-dbb2-4618-afd4-fb1b8559cb80\",\r\n \"term\": \"P1Y\",\r\n \"billingPlan\": \"Upfront\",\r\n \"quantity\": 1,\r\n \"displayName\": \"test\",\r\n \"appliedScopeType\": \"Shared\"\r\n }\r\n}",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"f08b85c7-63f1-4834-b4fd-4a1d6b390682"
11+
],
12+
"Accept-Language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.6.28008.01",
17+
"OSName/Windows",
18+
"OSVersion/Microsoft.Windows.10.0.18363.",
19+
"Microsoft.Azure.Management.Reservations.AzureReservationAPIClient/1.13.0.0"
20+
],
21+
"Content-Type": [
22+
"application/json; charset=utf-8"
23+
],
24+
"Content-Length": [
25+
"344"
26+
]
27+
},
28+
"ResponseHeaders": {
29+
"Cache-Control": [
30+
"no-cache"
31+
],
32+
"Pragma": [
33+
"no-cache"
34+
],
35+
"Vary": [
36+
"Accept-Encoding"
37+
],
38+
"x-ms-ratelimit-remaining-tenant-writes": [
39+
"1199"
40+
],
41+
"x-ms-test": [
42+
"{\"contact\":\"kgautam\",\"scenarios\":\"v6-recurrence-test,time-scale:35040,AcceleratedPayment\",\"retention\":\"2/12/2020 8:35:54 PM\"}"
43+
],
44+
"x-ms-request-id": [
45+
"westus:5f1e7e07-d633-4840-afe9-be465ff3faf7"
46+
],
47+
"X-Content-Type-Options": [
48+
"nosniff"
49+
],
50+
"Server": [
51+
"Microsoft-IIS/10.0"
52+
],
53+
"x-ms-correlation-request-id": [
54+
"cd4c77d0-1409-4e98-b5bd-50f94df48f62"
55+
],
56+
"x-ms-routing-request-id": [
57+
"WESTUS:20191114T203556Z:cd4c77d0-1409-4e98-b5bd-50f94df48f62"
58+
],
59+
"Strict-Transport-Security": [
60+
"max-age=31536000; includeSubDomains"
61+
],
62+
"Date": [
63+
"Thu, 14 Nov 2019 20:35:56 GMT"
64+
],
65+
"Content-Length": [
66+
"344"
67+
],
68+
"Content-Type": [
69+
"application/json; charset=utf-8"
70+
],
71+
"Expires": [
72+
"-1"
73+
]
74+
},
75+
"ResponseBody": "{\r\n \"properties\": {\r\n \"billingCurrencyTotal\": {\r\n \"currencyCode\": \"USD\",\r\n \"amount\": 32.0\r\n },\r\n \"netTotal\": 0.0,\r\n \"taxTotal\": 0.0,\r\n \"grandTotal\": 0.0,\r\n \"reservationOrderId\": \"53f2a7dd-04ba-4354-afa8-68301b2d3d28\",\r\n \"skuTitle\": \"Reserved VM Instance, Standard_B1ls, US West, 1 Year\",\r\n \"skuDescription\": \"standard_b1ls\",\r\n \"pricingCurrencyTotal\": {\r\n \"currencyCode\": \"USD\",\r\n \"amount\": 32.0\r\n }\r\n }\r\n}",
76+
"StatusCode": 200
77+
}
78+
],
79+
"Names": {},
80+
"Variables": {
81+
"SubscriptionId": "d3ae48e5-dbb2-4618-afd4-fb1b8559cb80"
82+
}
83+
}

0 commit comments

Comments
 (0)