depth

The depth query parameter is used to limit the number of nested levels returned by the server. Data nodes with a depth value greater than the depth parameter are not returned in a response for a GET method.
  • The value of the depth parameter will be either an integer between 1 and 65535, or the string unbounded. The default is unbounded, which retrieves all child resources.
  • The first nest-level will be the requested data node.
  • The depth parameter is allowed only for GET methods on API datastore and data resources. A 400 Bad Request status is returned if used for other methods or resource types.

Sample request from client to retrieve the interfaces YANG model data without specifying the depth parameter

GET  /rest/restconf/data/openconfig-interfaces:interfaces
    HTTP/1.1
    Host: 10.68.5.64

Sample response data from server

{
  "openconfig-interfaces:interfaces": {
    "interface": [
      {
        "config": {
          "description": "X440G2-24t-G4 Port 1", 
          "enabled": true, 
          "mtu": 1500, 
          "name": "1", 
          "type": "ethernetCsmacd"
        }, 
        "hold-time": {
          "config": {
            "down": 0, 
            "up": 0
          }, 
          "state": {
            "down": 0, 
            "up": 0
          }
        }, 
        "name": "1", 
        "openconfig-if-ethernet:ethernet": {
          "config": {
            "auto-negotiate": true, 
            "duplex-mode": "FULL", 
            "enable-flow-control": false, 
            "mac-address": "00:04:96:9E:4B:80", 
            "port-speed": "SPEED_UNKNOWN"
          }, 
          "openconfig-vlan:switched-vlan": {
            "config": {
              "access-vlan": 1, 
              "interface-mode": "ACCESS"
            }, 
            "state": {
              "access-vlan": 1, 
              "interface-mode": "ACCESS"
            }
          }, 
          "state": {
            "auto-negotiate": true, 
            "counters": {
              "in-8021q-frames": 0, 
              "in-crc-errors": 0, 
              "in-fragment-frames": 0, 
              "in-jabber-frames": 0, 
              "in-mac-control-frames": 0, 
              "in-mac-pause-frames": 0, 
              "in-oversize-frames": 0, 
              "out-8021q-frames": 0, 
              "out-mac-control-frames": 0, 
              "out-mac-pause-frames": 0
            }, 
            "duplex-mode": "FULL", 
            "effective-speed": 0, 
            "enable-flow-control": false, 
            "hw-mac-address": "00:04:96:9E:4B:80", 
            "mac-address": "00:04:96:9E:4B:80", 
            "negotiated-duplex-mode": "FULL", 
            "negotiated-port-speed": "SPEED_UNKNOWN", 
            "port-speed": "SPEED_UNKNOWN"
          }
        }, 
        "state": {
          "admin-status": "UP", 
          "counters": {
            "in-broadcast-pkts": 0, 
            "in-discards": 0, 
            "in-errors": 0, 
            "in-multicast-pkts": 0, 
            "in-octets": 0, 
            "in-unicast-pkts": 0, 
            "in-unknown-protos": 0, 
            "last-clear": "2017-12-19T14:25:53Z", 
            "out-broadcast-pkts": 0, 
            "out-discards": 0, 
            "out-errors": 0, 
            "out-multicast-pkts": 0, 
            "out-octets": 0, 
            "out-unicast-pkts": 0
          }, 
          "description": "X440G2-24t-G4 Port 1", 
          "enabled": true, 
          "ifindex": 1001, 
          "last-change": 0, 
          "mtu": 1500, 
          "name": "1", 
          "openconfig-platform-transceiver:physical-channel": [], 
          "openconfig-platform:hardware-port": "00:04:96:9E:4B:80", 
          "oper-status": "DOWN", 
          "type": "ethernetCsmacd"
        }, 
        "subinterfaces": {
          "subinterface": [
            {
              "config": {
                "description": "", 
                "enabled": true, 
                "index": 1000004, 
                "name": "Default"
              }, 
              "index": 1000004, 
              "openconfig-vlan:vlan": {
                "config": {
                  "vlan-id": 1
                }, 
                "state": {
                  "vlan-id": 1
                }
              }, 
              "state": {
                "admin-status": "UP", 
                "counters": {
                  "in-broadcast-pkts": 0, 
                  "in-discards": 0, 
                  "in-errors": 0, 
                  "in-multicast-pkts": 0, 
                  "in-octets": 0, 
                  "in-unicast-pkts": 0, 
                  "in-unknown-protos": 0, 
                  "out-broadcast-pkts": 0, 
                  "out-discards": 0, 
                  "out-errors": 0, 
                  "out-multicast-pkts": 0, 
                  "out-octets": 0, 
                  "out-unicast-pkts": 0
                }, 
                "description": "", 
                "enabled": true, 
                "ifindex": 1000004, 
                "index": 1000004, 
                "last-change": 4400, 
                "name": "Default", 
                "oper-status": "DOWN"
              }
            }
          ]
        }
      }, 
and so on...

This can be more detail than the management application needs. Specifying the depth parameter trims the response.

Sample request from client with depth = 1

GET  rest/restconf/data/openconfig-interfaces:interfaces?depth=1
    HTTP/1.1
    Host: 10.68.5.64

Sample response data from server

{
  "openconfig-interfaces:interfaces": {}
}

Sample request from client with depth = 2

GET  /rest/restconf/data/openconfig-interfaces:interfaces?depth=2
    HTTP/1.1
    Host: 10.68.5.64

Sample response data from server

{   
  "openconfig-interfaces:interfaces":{ 
     "interface": {}   
  } 
}

Sample request from client with depth = 3

GET  /rest/restconf/data/openconfig-interfaces:interfaces?depth=3
    HTTP/1.1
    Host: 10.68.5.64

Using depth = 3 gives you a top level listing of all the interfaces and their types. The query runs faster on the device because it does not have to collect all the details of the full interfaces YANG model.

Sample response from server

{
  "openconfig-interfaces:interfaces": {
    "interface": [
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "1", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "2", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "3", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "4", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "5", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "6", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "7", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "8", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "9", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "10", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "11", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "12", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "13", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "14", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "15", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "16", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "17", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "18", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "19", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "20", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "21", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "22", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "23", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "24", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "25", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "26", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "27", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "hold-time": {}, 
        "name": "28", 
        "openconfig-if-ethernet:ethernet": {}, 
        "state": {}, 
        "subinterfaces": {}
      }, 
      {
        "config": {}, 
        "name": "Default", 
        "state": {}, 
        "subinterfaces": {}
      }
    ]
  }
}