| 1 |
.. _dellemc.enterprise_sonic.sonic_api_module: |
| 2 |
|
| 3 |
|
| 4 |
********************************** |
| 5 |
dellemc.enterprise_sonic.sonic_api |
| 6 |
********************************** |
| 7 |
|
| 8 |
**Manages REST operations on devices running Enterprise SONiC** |
| 9 |
|
| 10 |
|
| 11 |
Version added: 1.0.0 |
| 12 |
|
| 13 |
.. contents:: |
| 14 |
:local: |
| 15 |
:depth: 1 |
| 16 |
|
| 17 |
|
| 18 |
Synopsis |
| 19 |
-------- |
| 20 |
- Manages REST operations on devices running Enterprise SONiC Distribution by Dell Technologies. This module provides an implementation for working with SONiC REST operations in a deterministic way. |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
Parameters |
| 26 |
---------- |
| 27 |
|
| 28 |
.. raw:: html |
| 29 |
|
| 30 |
<table border=0 cellpadding=0 class="documentation-table"> |
| 31 |
<tr> |
| 32 |
<th colspan="1">Parameter</th> |
| 33 |
<th>Choices/<font color="blue">Defaults</font></th> |
| 34 |
<th width="100%">Comments</th> |
| 35 |
</tr> |
| 36 |
<tr> |
| 37 |
<td colspan="1"> |
| 38 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 39 |
<b>body</b> |
| 40 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 41 |
<div style="font-size: small"> |
| 42 |
<span style="color: purple">raw</span> |
| 43 |
</div> |
| 44 |
</td> |
| 45 |
<td> |
| 46 |
</td> |
| 47 |
<td> |
| 48 |
<div>The body of the HTTP request/response to the web service which contains the payload.</div> |
| 49 |
</td> |
| 50 |
</tr> |
| 51 |
<tr> |
| 52 |
<td colspan="1"> |
| 53 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 54 |
<b>method</b> |
| 55 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 56 |
<div style="font-size: small"> |
| 57 |
<span style="color: purple">string</span> |
| 58 |
/ <span style="color: red">required</span> |
| 59 |
</div> |
| 60 |
</td> |
| 61 |
<td> |
| 62 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 63 |
<li>GET</li> |
| 64 |
<li>PUT</li> |
| 65 |
<li>POST</li> |
| 66 |
<li>PATCH</li> |
| 67 |
<li>DELETE</li> |
| 68 |
</ul> |
| 69 |
</td> |
| 70 |
<td> |
| 71 |
<div>The HTTP method of the request or response. Must be a valid method accepted by the service that handles the request.</div> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
<tr> |
| 75 |
<td colspan="1"> |
| 76 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 77 |
<b>status_code</b> |
| 78 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 79 |
<div style="font-size: small"> |
| 80 |
<span style="color: purple">list</span> |
| 81 |
/ <span style="color: purple">elements=integer</span> |
| 82 |
/ <span style="color: red">required</span> |
| 83 |
</div> |
| 84 |
</td> |
| 85 |
<td> |
| 86 |
</td> |
| 87 |
<td> |
| 88 |
<div>A list of valid, numeric, HTTP status codes that signifies the success of a request.</div> |
| 89 |
</td> |
| 90 |
</tr> |
| 91 |
<tr> |
| 92 |
<td colspan="1"> |
| 93 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 94 |
<b>url</b> |
| 95 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 96 |
<div style="font-size: small"> |
| 97 |
<span style="color: purple">path</span> |
| 98 |
/ <span style="color: red">required</span> |
| 99 |
</div> |
| 100 |
</td> |
| 101 |
<td> |
| 102 |
</td> |
| 103 |
<td> |
| 104 |
<div>The HTTP path of the request after 'restconf/'.</div> |
| 105 |
</td> |
| 106 |
</tr> |
| 107 |
</table> |
| 108 |
<br/> |
| 109 |
|
| 110 |
|
| 111 |
Notes |
| 112 |
----- |
| 113 |
|
| 114 |
.. note:: |
| 115 |
- Tested against Enterprise SONiC Distribution by Dell Technologies. |
| 116 |
- Supports ``check_mode``. |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
Examples |
| 121 |
-------- |
| 122 |
|
| 123 |
.. code-block:: yaml |
| 124 |
|
| 125 |
- name: Checks that you can connect (GET) to a page and it returns a status 200 |
| 126 |
dellemc.enterprise_sonic.sonic_api: |
| 127 |
url: data/openconfig-interfaces:interfaces/interface=Ethernet60 |
| 128 |
method: "GET" |
| 129 |
status_code: 200 |
| 130 |
|
| 131 |
- name: Appends data to an existing interface using PATCH and verifies if it returns status 204 |
| 132 |
dellemc.enterprise_sonic.sonic_api: |
| 133 |
url: data/openconfig-interfaces:interfaces/interface=Ethernet60/config/description |
| 134 |
method: "PATCH" |
| 135 |
body: {"openconfig-interfaces:description": "Eth-60"} |
| 136 |
status_code: 204 |
| 137 |
|
| 138 |
- name: Deletes an associated IP address using DELETE and verifies if it returns status 204 |
| 139 |
dellemc.enterprise_sonic.sonic_api: |
| 140 |
url: > |
| 141 |
data/openconfig-interfaces:interfaces/interface=Ethernet64/subinterfaces/subinterface=0/ |
| 142 |
openconfig-if-ip:ipv4/addresses/address=1.1.1.1/config/prefix-length |
| 143 |
method: "DELETE" |
| 144 |
status_code: 204 |
| 145 |
|
| 146 |
- name: Adds a VLAN network instance using PUT and verifies if it returns status 204 |
| 147 |
dellemc.enterprise_sonic.sonic_api: |
| 148 |
url: data/openconfig-network-instance:network-instances/network-instance=Vlan100/ |
| 149 |
method: "PUT" |
| 150 |
body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100", "config": {"name": "Vlan100"}}]} |
| 151 |
status_code: 204 |
| 152 |
|
| 153 |
- name: Adds a prefix-set to a routing policy using POST and verifies if it returns 201 |
| 154 |
dellemc.enterprise_sonic.sonic_api: |
| 155 |
url: data/openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set=p1 |
| 156 |
method: "POST" |
| 157 |
body: {"openconfig-routing-policy:config": {"name": "p1", "mode": "IPV4" }} |
| 158 |
status_code: 201 |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
Return Values |
| 163 |
------------- |
| 164 |
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: |
| 165 |
|
| 166 |
.. raw:: html |
| 167 |
|
| 168 |
<table border=0 cellpadding=0 class="documentation-table"> |
| 169 |
<tr> |
| 170 |
<th colspan="1">Key</th> |
| 171 |
<th>Returned</th> |
| 172 |
<th width="100%">Description</th> |
| 173 |
</tr> |
| 174 |
<tr> |
| 175 |
<td colspan="1"> |
| 176 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 177 |
<b>msg</b> |
| 178 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 179 |
<div style="font-size: small"> |
| 180 |
<span style="color: purple">string</span> |
| 181 |
</div> |
| 182 |
</td> |
| 183 |
<td>HTTP Error</td> |
| 184 |
<td> |
| 185 |
<div>The HTTP error message from the request.</div> |
| 186 |
<br/> |
| 187 |
</td> |
| 188 |
</tr> |
| 189 |
<tr> |
| 190 |
<td colspan="1"> |
| 191 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 192 |
<b>response</b> |
| 193 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 194 |
<div style="font-size: small"> |
| 195 |
<span style="color: purple">list</span> |
| 196 |
</div> |
| 197 |
</td> |
| 198 |
<td>always</td> |
| 199 |
<td> |
| 200 |
<div>The response at the network device end for the REST call which contains the status code.</div> |
| 201 |
<br/> |
| 202 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 203 |
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">{'response': [204, {'': None}]}</div> |
| 204 |
</td> |
| 205 |
</tr> |
| 206 |
</table> |
| 207 |
<br/><br/> |
| 208 |
|
| 209 |
|
| 210 |
Status |
| 211 |
------ |
| 212 |
|
| 213 |
|
| 214 |
Authors |
| 215 |
~~~~~~~ |
| 216 |
|
| 217 |
- Abirami N (@abirami-n) |