CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

Initialize-IntersightResourceSelector appears to be adding classid/objecttype to payload which backend isn't expecting #148

Closed briamorr closed 6 months ago

briamorr commented 6 months ago

Describe the bug Initialize-IntersightResourceSelector appears to be adding classid/objecttype to payload which backend isn't expecting

To Reproduce Payload when adding a server to a sub-target from the UI:

{"Qualifier":"Allow-Selectors","Selectors":[{"Selector":"/api/v1/compute/Blades?$filter=Serial in ('FCHYYYY','FCHXXXX') and ManagementMode eq 'Intersight'"}]}

Powershell:

$resourceGroup = Get-IntersightResourceGroup -Name IMM-Blade1

$selector = Initialize-IntersightResourceSelector -Selector "/api/v1/compute/Blades?$filter=Serial in ('FCHYYYY','FCHXXX') and ManagementMode eq 'Intersight'"

$resourceGroup | Set-IntersightResourceGroup -Selector $selector

Error:

Set-IntersightResourceGroup: Error calling UpdateResourceGroup: {"code":"InvalidUrl","message":"The resource selector URL '\u0026{{resource.Selector resource.Selector} /api/v1/compute/Blades?=Serial in ('FCHYYYY','FCHXXX') and ManagementMode eq 'Intersight'}' is invalid. A selector must be a relative URL starting with /api/ and ensure filter properties are supported.","messageId":"irvine_invalid_selector_url","messageParams":{"1":{"ClassId":"resource.Selector","ObjectType":"resource.Selector","Selector":"/api/v1/compute/Blades?=Serial in ('FCHYYYY','FCHXXX') and ManagementMode eq 'Intersight'"}},"traceId":"dnJhiK2W-7mvMdkz3OxXfgk0RfoXFtpzVIcP3MyHxs5qFaoLEOiKlg=="}

Version used Intersight SaaS Intersight Module: 1.0.11.16342

Expected behavior Initialize-IntersightResourceSelector works correctly when used in conjunction with Set-IntersightResourceGroup

briamorr commented 6 months ago

Looks like filter needs a backtick to get it working


$resourceGroup = Get-IntersightResourceGroup -Name IMM-Blade1

$selector = Initialize-IntersightResourceSelector -Selector "/api/v1/compute/Blades?`$filter=Serial in ('FCHYYYY','FCHXXX') and ManagementMode eq 'Intersight'"

$resourceGroup | Set-IntersightResourceGroup -Selector $selector