Support Support Downloads Knowledge Base Juniper Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[Contrail] How to use the "detail=True" modifier in REST APIs to find detailed object instance information

0

0

Article ID: KB33913 KB Last Updated: 11 Mar 2019Version: 1.0
Summary:

This article discusses the REST API URL modifier that can be used in 'curl' commands.

Symptoms:

When querying the contrail-API database, we often query an object first to list all instances from the database, then perform another query on the specific object instance to get detailed information about it.

For example, to list all VNs:

  curl -u admin:Juniper http://localhost:8095/virtual-networks | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  100 13909  100 13909    0     0  2616k      0 --:--:-- --:--:-- --:--:-- 2716k
  {
    "virtual-networks": [
        {
            "fq_name": [
                "default-domain",
                "admin",
                "admin-test-vn"
            ],
            "href": "http://localhost:8095/virtual-network/15b43103-a0a0-4837-a567-98ad020a1bc3",
            "uuid": "15b43103-a0a0-4837-a567-98ad020a1bc3"
        },
        {
            "fq_name": [
                "default-domain",
                "tenant1",
                "VN-B"
            ],
            "href": "http://localhost:8095/virtual-network/949a8f40-da1c-4275-ab34-8b62a9f8f461",
            "uuid": "949a8f40-da1c-4275-ab34-8b62a9f8f461"
        },
 

Now, to get the details of each VN, we will run one more query on each specific VN's URL:

root@cont101:~# curl -u admin:Juniper http://localhost:8095/virtual-network/15b43103-a0a0-4837-a567-98ad020a1bc3 | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2574  100  2574    0     0   526k      0 --:--:-- --:--:-- --:--:--  628k
{
    "virtual-network": {
        "display_name": "admin-test-vn",
        "ecmp_hashing_include_fields": {},
        "export_route_target_list": {
            "route_target": []
        },
...<snipped>...

curl -u admin:Juniper http://localhost:8095/virtual-network/949a8f40-da1c-4275-ab34-8b62a9f8f461 | python -mjson.tool
{
    "virtual-network": {
        "display_name": "VN-B",
        "ecmp_hashing_include_fields": {},
        "export_route_target_list": {
            "route_target": []
        },
        "flood_unknown_unicast": false,
        "fq_name": [
            "default-domain",
            "tenant1",
            "VN-B"
        ],
...<snipped>...
 

Sometimes, we need a way to dump detailed information for all instances in the object list.

 

Solution:

To dump detailed information for all instances in the object list, we can use the "details=True" modifier in the RES API URL.

curl -u admin:Juniper http://localhost:8095/virtual-networks?detail=True | python -mjson.tool

 {
     "virtual-networks": [
         {
             "virtual-network": {
                 "display_name": "admin-test-vn",
                 "ecmp_hashing_include_fields": {},
                 "export_route_target_list": {
                     "route_target": []
                 },
                 "flood_unknown_unicast": false,
                 "fq_name": [
 +------  3 lines: "default-domain",
                 ],
                 "href": "http://localhost:8095/virtual-network/15b43103-a0a0-4837-a567-98ad020a1bc3",
                 "id_perms": {
 +------ 17 lines: "created": "2018-11-30T22:25:38.577302",
                 },
                 "import_route_target_list": {
                     "route_target": []
                 },
                 "is_shared": false,
                 "multi_policy_service_chains_enabled": false,
                 "name": "admin-test-vn",
                 "network_ipam_refs": [
 +------ 25 lines: {
                 ],
                 "parent_href": "http://localhost:8095/project/ede15b5d-21eb-4401-bd2a-56e8d373aa71",
                 "parent_type": "project",
                 "parent_uuid": "ede15b5d-21eb-4401-bd2a-56e8d373aa71",
                 "perms2": {
 +------  4 lines: "global_access": 0,
                 },
                 "router_external": false,
                 "uuid": "15b43103-a0a0-4837-a567-98ad020a1bc3",
                 "virtual_network_network_id": 64,
                 "virtual_network_properties": {
 +------  3 lines: "allow_transit": false,
                 }
             }
         },
         {
             "virtual-network": {
 +----- 81 lines: "display_name": "VN-B",
             }
         },
         {
             "virtual-network": {
 +-----103 lines: "display_name": "VN-RIGHT-user1",
             }
         },
         {
 +---- 87 lines: "virtual-network": {
         },
         {
 +---- 88 lines: "virtual-network": {
 

Note: The above output text has been folded based on indentation to reduce overall length.

 

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search