.. _dellemc.enterprise_sonic.sonic_api_module: ********************************** dellemc.enterprise_sonic.sonic_api ********************************** **Manages REST operations on devices running Enterprise SONiC** Version added: 1.0.0 .. contents:: :local: :depth: 1 Synopsis -------- - 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. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
body
raw
The body of the HTTP request/response to the web service which contains the payload.
method
string / required
    Choices:
  • GET
  • PUT
  • POST
  • PATCH
  • DELETE
The HTTP method of the request or response. Must be a valid method accepted by the service that handles the request.
status_code
list / elements=integer / required
A list of valid, numeric, HTTP status codes that signifies the success of a request.
url
path / required
The HTTP path of the request after 'restconf/'.

Notes ----- .. note:: - Tested against Enterprise SONiC Distribution by Dell Technologies. - Supports ``check_mode``. Examples -------- .. code-block:: yaml - name: Checks that you can connect (GET) to a page and it returns a status 200 dellemc.enterprise_sonic.sonic_api: url: data/openconfig-interfaces:interfaces/interface=Ethernet60 method: "GET" status_code: 200 - name: Appends data to an existing interface using PATCH and verifies if it returns status 204 dellemc.enterprise_sonic.sonic_api: url: data/openconfig-interfaces:interfaces/interface=Ethernet60/config/description method: "PATCH" body: {"openconfig-interfaces:description": "Eth-60"} status_code: 204 - name: Deletes an associated IP address using DELETE and verifies if it returns status 204 dellemc.enterprise_sonic.sonic_api: url: > data/openconfig-interfaces:interfaces/interface=Ethernet64/subinterfaces/subinterface=0/ openconfig-if-ip:ipv4/addresses/address=1.1.1.1/config/prefix-length method: "DELETE" status_code: 204 - name: Adds a VLAN network instance using PUT and verifies if it returns status 204 dellemc.enterprise_sonic.sonic_api: url: data/openconfig-network-instance:network-instances/network-instance=Vlan100/ method: "PUT" body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100", "config": {"name": "Vlan100"}}]} status_code: 204 - name: Adds a prefix-set to a routing policy using POST and verifies if it returns 201 dellemc.enterprise_sonic.sonic_api: url: data/openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set=p1 method: "POST" body: {"openconfig-routing-policy:config": {"name": "p1", "mode": "IPV4" }} status_code: 201 Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
Key Returned Description
msg
string
HTTP Error
The HTTP error message from the request.

response
list
always
The response at the network device end for the REST call which contains the status code.

Sample:
{'response': [204, {'': None}]}


Status ------ Authors ~~~~~~~ - Abirami N (@abirami-n)