Forum Discussion

Patrik_Jonsson's avatar
Dec 20, 2016

iControl REST Select from subcollections

Hi!

I'm making a REST query against

/mgmt/tm/ltm/pool?expandSubcollections=true&$select=membersReference
and would like to be able to go further into the data and select ie. only session, state and fullPath.

Is this possible? I you have a rather big pool collection there's a lot of data that needs to be sent otherwise.

Sample data to make it more clear. 🙂

{
  "kind": "tm:ltm:pool:poolcollectionstate",
  "selfLink": "https://localhost/mgmt/tm/ltm/pool?expandSubcollections\u003dtrue\u0026ver\u003d12.1.1",
  "items": [
    {
      "kind": "tm:ltm:pool:poolstate",
      ...
      Truncated for readability
      ...
      "membersReference": {
        "link": "https://localhost/mgmt/tm/ltm/pool/~myPartition~myPool/members?ver\u003d12.1.1",
        "isSubcollection": true,
        "items": [
          {
            "kind": "tm:ltm:pool:members:membersstate",
            "name": "MYWEB-01:80",
            "partition": "Common",
            "fullPath": "/Common/MYWEB-01:80",
            "generation": 1,
            "selfLink": "https://localhost/mgmt/tm/ltm/pool/~myPartition~myPool/members/~Common~MYWEB-01:80?ver\u003d12.1.1",
            "address": "10.0.0.31",
            "connectionLimit": 0,
            "dynamicRatio": 1,
            "ephemeral": "false",
            "fqdn": {
              "autopopulate": "disabled"
            },
            "inheritProfile": "enabled",
            "logging": "disabled",
            "monitor": "default",
            "priorityGroup": 0,
            "rateLimit": "disabled",
            "ratio": 1,
            "session": "monitor-enabled",
            "state": "up",
            "nameReference": {
              "link": "https://localhost/mgmt/tm/ltm/node/~Common~MYWEB-01:80?ver\u003d12.1.1"
            }
          },

/Patrik

2 Replies

  • tl;dr -

    /mgmt/tm/ltm/pool?expandSubcollections=true&$select=fullPath,membersReference/items/session,membersReference/items/state,membersReference/items/fullPath

    Since iControlRest is using odata, you can use the same (at least the parts that are implemented) format as other odata implementations. So, to get a nested item, you would delimiter each level with a

    /
    (forward slash), thus getting something like
    membersReference/items/state
    .

    There is the

    $expand
    option, but I don't know if it's implemented here (at least not in 11.5.3 from my experience)

    ref: OData Getting Started Guide

  • I wasn't able to figure it out and was advised to sed/awk/grep it out which is a pain. I tried playing around with "dot-notation" and "filters" that is usually recommended in REST/JSON but no luck. Version tried: 11.5