07-29-2017 05:28 PM
I'm trying to gather a list of devices using the data/Devices call, and filtering based on manufacturerPartNrs->manufacturerPartNr(list). The deviceType is unreliable in the sense that a WS-C2960C-8PC-L and a WS-C2960X-48FPS-L are "Cisco Catalyst 29xx Stack-able Ethernet Switch" but they are two completely different architectures and I need to treat them differently.
I guess i'm not reading the filtering docs right, but I believe I should be able to use something like:
https://prime/webacs/api/v1/data/Devices.json?.full=true&.sort=deviceName&manufacturerPartNrs.manufacturerPartNrs.elements=WS-C2960X-48FPS-L
or
https://prime/webacs/api/v1/data/Devices.json?.full=true&.sort=deviceName&manufacturerPartNrs.manufacturerPartNrs.indices=WS-C2960X-48FPS-L
However, any iteration i've tried returns the same thing as if i ran:
https://prime/webacs/api/v1/data/Devices.json?.full=true&.sort=deviceName
Solved! Go to Solution.
07-31-2017 08:02 AM
As an array, manufacturerPartNrs is not filterable. Our apologies, as this isn't called out anywhere in the documentation (we'll address that). To address your use case, please try the following query using our InventoryDetails resource:
/webacs/api/v1/data/InventoryDetails?.full=true&.sort=summary.deviceName&udiDetail.modelNr="WS-C2960X-48FPS-L"
EDIT: Nevermind, we do in fact support filtering here. It's not a feature that often gets used (because we don't have many collections of primitives in filterable resources) so I'd totally forgotten about it . Our filtering page covers this in the "Filtering on collections of primitives" section.
So you can either use the above query, which I believe satisfies your use case, or use the following:
/webacs/api/v1/data/Devices?.full=true&.sort=deviceName&manufacturerPartNr.elements="WS-C2960X-48FPS-L"
07-30-2017 03:00 AM
Just a guess here, can you try "manufacturerPartNrs.manufacturerPartNr" instead of "manufacturerPartNrs.manufacturerPartNrs"
You can also try manufacturerPartNrs.manufacturerPartNr="WS-C2960X-48FPS-L"
07-30-2017 12:49 PM
Apologies, cut and paste error. That is what I meant - manufacturerPartNrs.manufacturerPartNr In all honesty i've tried all combinations.
I've also tried other filter options like:
https://prime/webacs/api/v1/data/Devices.json?.full=true&.sort=deviceName&manufacturerPartNrs.manufacturerPartNr=contains("C2960X")
with the same result - full list of devices.
07-31-2017 08:02 AM
As an array, manufacturerPartNrs is not filterable. Our apologies, as this isn't called out anywhere in the documentation (we'll address that). To address your use case, please try the following query using our InventoryDetails resource:
/webacs/api/v1/data/InventoryDetails?.full=true&.sort=summary.deviceName&udiDetail.modelNr="WS-C2960X-48FPS-L"
EDIT: Nevermind, we do in fact support filtering here. It's not a feature that often gets used (because we don't have many collections of primitives in filterable resources) so I'd totally forgotten about it . Our filtering page covers this in the "Filtering on collections of primitives" section.
So you can either use the above query, which I believe satisfies your use case, or use the following:
/webacs/api/v1/data/Devices?.full=true&.sort=deviceName&manufacturerPartNr.elements="WS-C2960X-48FPS-L"
07-31-2017 09:42 AM
Thanks, that worked!
I guess I just misunderstood the docs, I was going by using the "dotted notation" under Filtering Syntax section for a nested parameter. Since it is an element in a collection, it isn't nested - is that correct?
07-31-2017 10:51 AM
It isn't needed in this case, correct.
To get into the weeds a little bit, because the presentation that we do here (<manufacturerPartNrs><manuFacturerPartNr>) doesn't represent the actual structure of the data, it's just a cosmetic way for us to take the array of Strings and display and marshal them into XML. The actual filtering that needs to happen is against elements parameter of the array itself (hence, the filter parameter is manufacturerPartNr.elements). When we do dotted notation against other collections, what you see in the XML represents the actual structure of our data; for example, in the InventoryDetails query above, summary is a reference to a separate object, so using the dotted notation lets the filtering logic know that it needs to apply that filter to the other object, rather than to the root InventoryDetails object. I'm not sure if you wanted these details, but that's why there's this difference here.
My apologies for the confusion. Thank you for reaching out
07-31-2017 10:53 AM
That's exactly the detail i was looking for. Thanks!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide