Skip to content

Commit c776104

Browse files
authored
[Az.Accounts] add examples for invoke-azreset, implement supportsshouldprocess for … (#19030)
* add examples for invoke-azreset, implement supportsshouldprocess for invoke-azrest * polish
1 parent 2cee39f commit c776104

File tree

3 files changed

+75
-13
lines changed

3 files changed

+75
-13
lines changed

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Implemented `SupportsShouldProcess` for `Invoke-AzRestMethod`
2223
* Supported giving suggestions if an Azure PowerShell command cannot be found, for example when there is a typo in command name.
2324

2425
## Version 2.9.0

src/Accounts/Accounts/Rest/InvokeAzRestMethodCommand.cs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public override void ExecuteCmdlet()
100100
this.ValidateParameters();
101101

102102
context = DefaultContext;
103-
AzureOperationResponse<string> response;
103+
AzureOperationResponse<string> response = null;
104104

105105
if (ByParameters.Equals(this.ParameterSetName))
106106
{
@@ -158,24 +158,36 @@ public override void ExecuteCmdlet()
158158
.GetResourceWithFullResponse(this.Path, this.ApiVersion);
159159
break;
160160
case "POST":
161-
response = serviceClient
162-
.Operations
163-
.PostResourceWithFullResponse(this.Path, this.ApiVersion, this.Payload);
161+
if (this.ShouldProcess(Path, "POST"))
162+
{
163+
response = serviceClient
164+
.Operations
165+
.PostResourceWithFullResponse(this.Path, this.ApiVersion, this.Payload);
166+
}
164167
break;
165168
case "PUT":
166-
response = serviceClient
167-
.Operations
168-
.PutResourceWithFullResponse(this.Path, this.ApiVersion, this.Payload);
169+
if (this.ShouldProcess(Path, "PUT"))
170+
{
171+
response = serviceClient
172+
.Operations
173+
.PutResourceWithFullResponse(this.Path, this.ApiVersion, this.Payload);
174+
}
169175
break;
170176
case "PATCH":
171-
response = serviceClient
172-
.Operations
173-
.PatchResourceWithFullResponse(this.Path, this.ApiVersion, this.Payload);
177+
if (this.ShouldProcess(Path, "PATCH"))
178+
{
179+
response = serviceClient
180+
.Operations
181+
.PatchResourceWithFullResponse(this.Path, this.ApiVersion, this.Payload);
182+
}
174183
break;
175184
case "DELETE":
176-
response = serviceClient
177-
.Operations
178-
.DeleteResourceWithFullResponse(this.Path, this.ApiVersion);
185+
if (this.ShouldProcess(Path, "DELETE"))
186+
{
187+
response = serviceClient
188+
.Operations
189+
.DeleteResourceWithFullResponse(this.Path, this.ApiVersion);
190+
}
179191
break;
180192
default:
181193
throw new AzPSArgumentException("Invalid HTTP Method", nameof(Method));

src/Accounts/Accounts/help/Invoke-AzRestMethod.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,55 @@ Content : {"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users
9898

9999
Get current signed in user via MicrosoftGraph API. This example is equivalent to `Get-AzADUser -SignedIn`.
100100

101+
### Example 3
102+
```powershell
103+
$subscriptionId = (Get-AzContext).Subscription.ID
104+
Invoke-AzRestMethod -SubscriptionId $subscriptionId -ResourceGroupName "test-group" -ResourceProviderName Microsoft.AppPlatform -ResourceType Spring,apps -Name "test-spring-service" -ApiVersion 2020-07-01 -Method GET
105+
```
106+
107+
```output
108+
Headers : {[Cache-Control, System.String[]], [Pragma, System.String[]], [Vary, System.String[]], [x-ms-request-id,
109+
System.String[]]…}
110+
Version : 1.1
111+
StatusCode : 200
112+
Method : GET
113+
Content : {"value":[{"properties":{"public":true,"url":"https://test-spring-service-demo.azuremicroservices.io","provisioni
114+
ngState":"Succeeded","activeDeploymentName":"default","fqdn":"test-spring-service.azuremicroservices.io","httpsOn
115+
ly":false,"createdTime":"2022-06-22T02:57:13.272Z","temporaryDisk":{"sizeInGB":5,"mountPath":"/tmp"},"pers
116+
istentDisk":{"sizeInGB":0,"mountPath":"/persistent"}},"type":"Microsoft.AppPlatform/Spring/apps","identity
117+
":null,"location":"eastus","id":"/subscriptions/$subscriptionId/resourceGroups/test-group/providers/Microsoft.AppPlatform/Spring/test-spring-service/apps/demo","name":"demo"},{"properties":{"publ
118+
ic":false,"provisioningState":"Succeeded","activeDeploymentName":"deploy01","fqdn":"test-spring-service.azuremicr
119+
oservices.io","httpsOnly":false,"createdTime":"2022-06-22T07:46:54.9Z","temporaryDisk":{"sizeInGB":5,"moun
120+
tPath":"/tmp"},"persistentDisk":{"sizeInGB":0,"mountPath":"/persistent"}},"type":"Microsoft.AppPlatform/Sp
121+
ring/apps","identity":null,"location":"eastus","id":"/subscriptions/$subscriptionId/r
122+
esourceGroups/test-group/providers/Microsoft.AppPlatform/Spring/test-spring-service/apps/pwsh01","name":"pwsh0
123+
1"}]}
124+
```
125+
126+
List apps under spring service "test-spring-service"
127+
128+
### Example 4
129+
```powershell
130+
$subscriptionId = (Get-AzContext).Subscription.ID
131+
Invoke-AzRestMethod -SubscriptionId $subscriptionId -ResourceGroupName "test-group" -ResourceProviderName Microsoft.AppPlatform -ResourceType Spring -Name "test-spring-service","demo" -ApiVersion 2020-07-01 -Method GET
132+
```
133+
134+
```output
135+
Headers : {[Cache-Control, System.String[]], [Pragma, System.String[]], [Vary, System.String[]], [x-ms-request-id,
136+
System.String[]]…}
137+
Version : 1.1
138+
StatusCode : 200
139+
Method : GET
140+
Content : {"properties":{"public":true,"url":"https://test-spring-service-demo.azuremicroservices.io","provisioningState":"
141+
Succeeded","activeDeploymentName":"default","fqdn":"test-spring-service.azuremicroservices.io","httpsOnly":false,
142+
"createdTime":"2022-06-22T02:57:13.272Z","temporaryDisk":{"sizeInGB":5,"mountPath":"/tmp"},"persistentDisk
143+
":{"sizeInGB":0,"mountPath":"/persistent"}},"type":"Microsoft.AppPlatform/Spring/apps","identity":null,"lo
144+
cation":"eastus","id":"/subscriptions/$subscriptionId/resourceGroups/test-group/pr
145+
oviders/Microsoft.AppPlatform/Spring/test-spring-service/apps/demo","name":"demo"}
146+
```
147+
148+
Get app "demo" under Spring cloud service "test-spring-service"
149+
101150
## PARAMETERS
102151

103152
### -ApiVersion

0 commit comments

Comments
 (0)