Added JSON and XML payloads tabs with working RFC 8040 URL 31/90531/9
authorAman <170030039@iitdh.ac.in>
Sat, 20 Jun 2020 19:54:45 +0000 (01:24 +0530)
committerRobert Varga <nite@hq.sk>
Mon, 7 Sep 2020 13:09:32 +0000 (13:09 +0000)
Modified docs/bgp/bgp-user-guide-ip-unicast-family.rst by adding JSON,XML examples with corresponding sphinx tabs

Change-Id: I277e40fb90b1140d9c59ff492024db0361845525
Signed-off-by: Aman <170030039@iitdh.ac.in>
docs/bgp/bgp-user-guide-ip-unicast-family.rst

index c8cbc0919619de42ffe414b4837e176f2c192d8f..f1470cfcac83d27ad82ac62c15de7275d053fac0 100644 (file)
@@ -21,34 +21,75 @@ To enable IPv4 and IPv6 Unicast support in BGP plugin, first configure BGP speak
 
 **URL:** ``/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols``
 
+**RFC8040 URL:** ``/rests/data/openconfig-network-instance:network-instances/network-instance=global-bgp/protocols``
+
 **Method:** ``POST``
 
-**Content-Type:** ``application/xml``
-
-**Request Body:**
-
-.. code-block:: xml
-
-   <protocol xmlns="http://openconfig.net/yang/network-instance">
-       <name>bgp-example</name>
-       <identifier xmlns:x="http://openconfig.net/yang/policy-types">x:BGP</identifier>
-       <bgp xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
-           <global>
-               <config>
-                   <router-id>192.0.2.2</router-id>
-                   <as>65000</as>
-               </config>
-               <afi-safis>
-                   <afi-safi>
-                       <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
-                   </afi-safi>
-                   <afi-safi>
-                       <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
-                   </afi-safi>
-               </afi-safis>
-           </global>
-       </bgp>
-   </protocol>
+.. tabs::
+
+   .. tab:: XML
+
+      **Content-Type:** ``application/xml``
+
+      **Request Body:**
+
+      .. code-block:: xml
+
+         <protocol xmlns="http://openconfig.net/yang/network-instance">
+             <name>bgp-example</name>
+             <identifier xmlns:x="http://openconfig.net/yang/policy-types">x:BGP</identifier>
+             <bgp xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
+                 <global>
+                     <config>
+                         <router-id>192.0.2.2</router-id>
+                         <as>65000</as>
+                     </config>
+                     <afi-safis>
+                         <afi-safi>
+                             <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
+                         </afi-safi>
+                         <afi-safi>
+                             <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
+                         </afi-safi>
+                     </afi-safis>
+                 </global>
+             </bgp>
+         </protocol>
+
+   .. tab:: JSON
+
+      **Content-Type:** ``application/json``
+
+      **Request Body:**
+
+      .. code-block:: json
+
+         {
+             "protocol": [
+                 {
+                     "identifier": "openconfig-policy-types:BGP",
+                     "name": "bgp-example",
+                     "bgp-openconfig-extensions:bgp": {
+                         "global": {
+                             "config": {
+                                 "router-id": "192.0.2.2",
+                                 "as": 65000
+                             },
+                             "afi-safis": {
+                                 "afi-safi": [
+                                     {
+                                         "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
+                                     },
+                                     {
+                                         "afi-safi-name": "openconfig-bgp-types:IPV6-UNICAST"
+                                     }
+                                 ]
+                             }
+                         }
+                     }
+                 }
+             ]
+         }
 
 BGP Peer
 ''''''''
@@ -58,23 +99,53 @@ Here is an example for BGP peer configuration with enabled IPv4 and IPv6 Unicast
 
 **Method:** ``POST``
 
-**Content-Type:** ``application/xml``
+.. tabs::
+
+   .. tab:: XML
+
+      **Content-Type:** ``application/xml``
+
+      **Request Body:**
+
+      .. code-block:: xml
+
+         <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
+             <neighbor-address>192.0.2.1</neighbor-address>
+             <afi-safis>
+                 <afi-safi>
+                     <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
+                 </afi-safi>
+                 <afi-safi>
+                     <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
+                 </afi-safi>
+             </afi-safis>
+         </neighbor>
+
+   .. tab:: JSON
+
+      **Content-Type:** ``application/json``
 
-**Request Body:**
+      **Request Body:**
 
-.. code-block:: xml
+      .. code-block:: json
 
-   <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
-       <neighbor-address>192.0.2.1</neighbor-address>
-       <afi-safis>
-           <afi-safi>
-               <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
-           </afi-safi>
-           <afi-safi>
-               <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
-           </afi-safi>
-       </afi-safis>
-   </neighbor>
+         {
+             "neighbor": [
+                 {
+                     "neighbor-address": "192.0.2.1",
+                     "afi-safis": {
+                         "afi-safi": [
+                             {
+                                 "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
+                             },
+                             {
+                                 "afi-safi-name": "openconfig-bgp-types:IPV6-UNICAST"
+                             }
+                         ]
+                     }
+                 }
+             ]
+         }
 
 IP Unicast API
 ^^^^^^^^^^^^^^
@@ -205,29 +276,62 @@ The IPv4 Unicast table in an instance of the speaker's Loc-RIB can be verified v
 
 **Method:** ``GET``
 
-**Response Body:**
-
-.. code-block:: xml
-
-   <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
-       <ipv4-route>
-           <route-key>193.0.2.1/32</route-key>
-           <path-id>0</path-id>
-           <prefix>193.0.2.1/32</prefix>
-           <attributes>
-               <as-path></as-path>
-               <origin>
-                   <value>igp</value>
-               </origin>
-               <local-pref>
-                   <pref>100</pref>
-               </local-pref>
-               <ipv4-next-hop>
-                   <global>10.0.0.1</global>
-               </ipv4-next-hop>
-           </attributes>
-       </ipv4-route>
-   </ipv4-routes>
+.. tabs::
+
+   .. tab:: XML
+
+      **Response Body:**
+
+      .. code-block:: xml
+
+         <ipv4-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
+             <ipv4-route>
+                 <route-key>193.0.2.1/32</route-key>
+                 <path-id>0</path-id>
+                 <prefix>193.0.2.1/32</prefix>
+                 <attributes>
+                     <as-path></as-path>
+                     <origin>
+                         <value>igp</value>
+                     </origin>
+                     <local-pref>
+                         <pref>100</pref>
+                     </local-pref>
+                     <ipv4-next-hop>
+                         <global>10.0.0.1</global>
+                     </ipv4-next-hop>
+                 </attributes>
+             </ipv4-route>
+         </ipv4-routes>
+
+   .. tab:: JSON
+
+      **Response Body:**
+
+      .. code-block:: json
+
+         {
+             "bgp-inet:ipv4-routes":{
+                 "ipv4-route": [
+                     {
+                         "route-key":"193.0.2.1/32",
+                         "path-id": 0,
+                         "prefix": "193.0.2.1/32",
+                         "attributes": {
+                             "origin": {
+                                 "value": "igp"
+                             },
+                             "local-pref": {
+                                 "pref": 100
+                             },
+                             "ipv4-next-hop": {
+                                 "global": "10.0.0.1"
+                             }
+                         }
+                     }
+                 ]
+             }
+         }
 
 IPv6 Unicast
 ''''''''''''
@@ -237,29 +341,62 @@ The IPv6 Unicast table in an instance of the speaker's Loc-RIB can be verified v
 
 **Method:** ``GET``
 
-**Response Body:**
-
-.. code-block:: xml
-
-   <ipv6-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
-       <ipv6-route>
-           <route-key>2a02:b80:0:1::/64</route-key>
-           <path-id>0</path-id>
-           <prefix>2a02:b80:0:1::/64</prefix>
-           <attributes>
-               <as-path></as-path>
-               <origin>
-                   <value>igp</value>
-               </origin>
-               <local-pref>
-                   <pref>200</pref>
-               </local-pref>
-               <ipv6-next-hop>
-                   <global>2a02:b80:0:2::1</global>
-               </ipv6-next-hop>
-           </attributes>
-       </ipv6-route>
-   </ipv6-routes>
+.. tabs::
+
+   .. tab:: XML
+
+      **Response Body:**
+
+      .. code-block:: xml
+
+         <ipv6-routes xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
+             <ipv6-route>
+                 <route-key>2a02:b80:0:1::/64</route-key>
+                 <path-id>0</path-id>
+                 <prefix>2a02:b80:0:1::/64</prefix>
+                 <attributes>
+                     <as-path></as-path>
+                     <origin>
+                         <value>igp</value>
+                     </origin>
+                     <local-pref>
+                         <pref>200</pref>
+                     </local-pref>
+                     <ipv6-next-hop>
+                         <global>2a02:b80:0:2::1</global>
+                     </ipv6-next-hop>
+                 </attributes>
+             </ipv6-route>
+         </ipv6-routes>
+
+   .. tab:: JSON
+
+      **Response Body:**
+
+      .. code-block:: json
+
+         {
+             "bgp-inet:ipv6-routes":{
+                 "ipv6-route": [
+                     {
+                         "route-key":"2a02:b80:0:1::/64",
+                         "path-id": 0,
+                         "prefix": "2a02:b80:0:1::/64",
+                         "attributes": {
+                             "origin": {
+                                 "value": "igp"
+                             },
+                             "local-pref": {
+                                 "pref": 200
+                             },
+                             "ipv6-next-hop": {
+                                 "global": "2a02:b80:0:2::1"
+                             }
+                         }
+                     }
+                 ]
+             }
+         }
 
 .. note:: IPv4/6 routes mapping to topology nodes is supported by BGP Topology Provider.
 
@@ -276,29 +413,62 @@ Make sure the *Application Peer* is configured first.
 
 **Method:** ``POST``
 
-**Content-Type:** ``application/xml``
-
-**Request Body:**
-
-.. code-block:: xml
-
-   <ipv4-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
-       <route-key>10.0.0.11/32</route-key>
-       <prefix>10.0.0.11/32</prefix>
-       <path-id>0</path-id>
-       <attributes>
-           <as-path></as-path>
-           <origin>
-               <value>igp</value>
-           </origin>
-           <local-pref>
-               <pref>100</pref>
-           </local-pref>
-           <ipv4-next-hop>
-               <global>10.11.1.1</global>
-           </ipv4-next-hop>
-       </attributes>
-   </ipv4-route>
+.. tabs::
+
+   .. tab:: XML
+
+      **Content-Type:** ``application/xml``
+
+      **Request Body:**
+
+      .. code-block:: xml
+
+         <ipv4-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
+             <route-key>10.0.0.11/32</route-key>
+             <prefix>10.0.0.11/32</prefix>
+             <path-id>0</path-id>
+             <attributes>
+                 <as-path></as-path>
+                 <origin>
+                     <value>igp</value>
+                 </origin>
+                 <local-pref>
+                     <pref>100</pref>
+                 </local-pref>
+                 <ipv4-next-hop>
+                     <global>10.11.1.1</global>
+                 </ipv4-next-hop>
+             </attributes>
+         </ipv4-route>
+
+   .. tab:: JSON
+
+      **Content-Type:** ``application/json``
+
+      **Request Body:**
+
+      .. code-block:: json
+
+         {
+             "ipv4-route": [
+                 {
+                     "route-key":"10.0.0.11/32",
+                     "path-id": 0,
+                     "prefix": "10.0.0.11/32",
+                     "attributes": {
+                         "origin": {
+                             "value": "igp"
+                         },
+                         "local-pref": {
+                             "pref": 100
+                         },
+                         "ipv4-next-hop": {
+                             "global": "10.11.1.1"
+                         }
+                     }
+                 }
+             ]
+         }
 
 -----
 
@@ -318,29 +488,62 @@ This examples show how to originate and remove IPv6 route via programmable RIB:
 
 **Method:** ``POST``
 
-**Content-Type:** ``application/xml``
-
-**Request Body:**
-
-.. code-block:: xml
-
-   <ipv6-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
-       <route-key>2001:db8:30::3/128</route-key>
-       <prefix>2001:db8:30::3/128</prefix>
-       <path-id>0</path-id>
-       <attributes>
-           <ipv6-next-hop>
-               <global>2001:db8:1::6</global>
-           </ipv6-next-hop>
-           <as-path/>
-           <origin>
-               <value>igp</value>
-           </origin>
-           <local-pref>
-               <pref>100</pref>
-           </local-pref>
-       </attributes>
-   </ipv6-route>
+.. tabs::
+
+   .. tab:: XML
+
+      **Content-Type:** ``application/xml``
+
+      **Request Body:**
+
+      .. code-block:: xml
+
+         <ipv6-route xmlns="urn:opendaylight:params:xml:ns:yang:bgp-inet">
+             <route-key>2001:db8:30::3/128</route-key>
+             <prefix>2001:db8:30::3/128</prefix>
+             <path-id>0</path-id>
+             <attributes>
+                 <ipv6-next-hop>
+                     <global>2001:db8:1::6</global>
+                 </ipv6-next-hop>
+                 <as-path/>
+                 <origin>
+                     <value>igp</value>
+                 </origin>
+                 <local-pref>
+                     <pref>100</pref>
+                 </local-pref>
+             </attributes>
+         </ipv6-route>
+
+   .. tab:: JSON
+
+      **Content-Type:** ``application/json``
+
+      **Request Body:**
+
+      .. code-block:: json
+
+         {
+             "ipv6-route": [
+                 {
+                     "route-key": "2001:db8:30::3/128",
+                     "path-id": 0,
+                     "prefix": "2001:db8:30::3/128",
+                     "attributes": {
+                         "ipv6-next-hop": {
+                             "global": "2001:db8:1::6"
+                         },
+                         "origin": {
+                             "value": "igp"
+                         },
+                         "local-pref": {
+                             "pref": 100
+                         }
+                     }
+                 }
+             ]
+         }
 
 -----