Open Sowmyacv opened 4 years ago
Hi @Sowmyacv, this seems to be specifically related to the PowerShell generator so I've transferred it to the Azure/autorest.powershell
repository.
@Sowmyacv @peombwa No, it is not set for all the body parameters. It is designed to pipe an resource(Id) you want to update/delete/etc. But it will need support from service too. When you use get cmdlet, the output is from the response, and path is a part of the request(input), so path info by default is not in the output of a get cmdlet. And there are two solutions from service side.
Thanks for the suggestions.
For our scenario, the response object already has an Id
property, that we would like to bind to the entityId
path parameter of the input command. i.e., Get-Application
| Get-ApplicationOwner
where:
Get-Application
returns a collection of object with [{"Id": "12345", "displayName": "My app" }]
:Get-ApplicationOwner
requires a parameter named -ApplicationId
- GET /applications/{application-id}/owner
.Something like https://learn.microsoft.com/en-us/powershell/module/az.resources/get-azadgroupmember?view=azps-9.4.0#example-2-list-members-by-pipeline-input.
We are interested in supporting piping for all parameter sets (list, get, delete, create, update etc.) We would like piping to work with any top-level path parameter that's provided as the input.:
GET /applications
| GET /applications/{application-id}/owners
GET /applications
| GET /applications/{application-id}/logo
GET /applications
| DELETE /applications/{application-id}/logo
GET /applications
| DELETE /applications/{application-id}/owners/{member-id}
Also, ViaIdentity
does not currently support list
parameter sets.
The thinking on our end was to have AutoREST.PowerShell mark top-level path parameters with ValueFromPipelineByPropertyName = true
attribute, then alias the top-level parameters to id
.
Autorest by default sets Valuefrompipeline property for all body parameters. We want to set ValuefromPipelineByPropertyName for path parameter so we can use our Get cmdlet as Input object for Update cmdlet we need like below as we have Entity ID as input to update cmdlet and get Provides it
[PowerShell.API.Runtime.Info( Required = true, ReadOnly = false, Description = @"Id of the Entity to update", SerializedName = @"EntityId", PossibleTypes = new [] { typeof(int) })] [global::Powershell.API.Category(global::Powershell.API.ParameterCategory.Path)]