-
Notifications
You must be signed in to change notification settings - Fork 27
Description
The Issue
The current syntax for the intersight_search_search_item data source (which is also poorly documented) essentially allows us to insert positive (i.e. eq) searches for attributes, such as this...
data "intersight_search_search_item" "example_by_model" {
additional_properties = jsonencode({ "Model" = "UCSC-C220-M5SX"})
}
But not a simple negative (i.e. ne) searches for attributes. More complex searches are not supported in a direct way.
Although it's possible to hack the attribute packing to create a more complex search as long as your search includes at least one positive element like this... (it's essentially an injection attack, which IMO should also be 'fixed' as a part of this request)
data "intersight_search_search_item" "example_exclude_model" {
additional_properties = jsonencode({ "Presence" = "equipped' and Model ne 'UCSC-C220-M5SX"})
}
or
data "intersight_search_search_item" "os_linux" {
additional_properties = jsonencode({ "Presence" = "equipped' and Tags/any(t:t/Key eq 'os' and t/Value eq 'linux') and ObjectType eq 'compute.PhysicalSummary" })
}
Really complex syntax is completely out of reach.
Proposed Solution
The data source should accept the standard set of parameters as an array. Syntax should appear similar to this...
data "intersight_search_search_item" "os_linux" {
odata {
filter = "ObjectType ne 'compute.PhysicalSummary' and Tags/any(t:t/Key eq 'os' and t/Value eq 'linux')"
select = "BiosUnits,Model,Serial"
top = "2"
expand = "BiosUnits($select=RunningFirmware%3b$expand=RunningFirmware($select=PackageVersion))"
}
}
This would provide a much more obvious and expressive syntax as well as access to the complex search capabilities that are available in Intersight.