About The NX-API Developer Sandbox
About The NX-API Developer Sandbox
Controls in the Command pane allow you to choose a message format for a supported API, such as NX-API
REST, and a command type, such as XML or JSON. The available command type options vary depending
on the selected message format.
When you type or paste one or more CLI commands into the Command pane, the web form converts the
commands into an API payload, checking for configuration errors, and displays the resulting payload in the
Request pane. If you then choose to post the payload directly from the Sandbox to the switch, using the POST
button in the Command pane, the Response pane displays the API response.
Conversely, when you type an NX-API REST designated name (DN) and payload into the Command pane
and select the nx-api rest Message format and the model Command type, Developer Sandbox checks
the payload for configuration errors, then the Response pane displays the equivalent CLIs.
Protocol Description
json-rpc A standard lightweight remote procedure call (RPC) protocol that can be used to deliver
NX-OS CLI commands in a JSON payload. The JSON-RPC 2.0 specification is outlined
by jsonrpc.org.
xml Cisco NX-API proprietary protocol for delivering NX-OS CLI or bash commands in
an XML payload.
json Cisco NX-API proprietary protocol for delivering NX-OS CLI or bash commands in
a JSON payload.
nx-api rest Cisco NX-API proprietary protocol for manipulating and reading managed objects
(MOs) and their properties in the internal NX-OS data management engine (DME)
model. For more information about the Cisco Nexus 3000 and 9000 Series NX-API
REST SDK, see https://developer.cisco.com/site/cisco-nexus-nx-api-references/.
nx yang The YANG ("Yet Another Next Generation") data modeling language for configuration
and state data.
When the Message Format has been chosen, a set of Command Type options are presented just below the
Message Format control. The Command Type setting can constrain the input CLI and can determine the
Request and Response format. The options vary depending on the Message Format selection. For each
Message Format, the following table describes the Command Type options:
Output Chunking
In order to handle large show command output, some NX-API message formats support output chunking for
show commands. In this case, an Enable chunk mode checkbox appears below the Command Type control
along with a session ID (SID) type-in box.
When chunking is enabled, the response is sent in multiple "chunks," with the first chunk sent in the immediate
command response. In order to retrieve the next chunk of the response message, you must send an NX-API
request with SID set to the session ID of the previous response message.
Tip Online help is available by clicking Quick Start in the upper right corner of the Sandbox window.
Additional details, such as response codes and security methods, can be found in the chapter "NX-API CLI".
Only configuration commands are supported.
Procedure
Step 1 Configure the Message Format and Command Type for the API protocol you want to use.
For detailed instructions, see Configuring the Message Format and Command Type, on page 2.
Step 2 Type or paste NX-OS CLI configuration commands, one command per line, into the text entry box in the top
pane.
You can erase the contents of the text entry box (and the Request and Response panes) by clicking Reset at
the bottom of the top pane.
Step 4 When a valid payload is present in the Request pane, you can click POST to send the payload as an API call
to the switch.
The response from the switch appears in the Response pane.
Warning Clicking POST commits the command to the switch, which can result in a configuration or state
change.
Step 5 You can copy the contents of the Request or Response pane to the clipboard by clicking Copy in the pane.
Step 6 You can obtain a Python implementation of the request on the clipboard by clicking Python in the Request
pane.
Tip Online help is available by clicking Quick Start in the upper right corner of the Sandbox window.
Additional details, such as response codes and security methods, can be found in the chapter "NX-API CLI".
Procedure
Step 1 Select nx-api rest as the Message Format and model as the Command Type.
Example:
Step 2 Enter a DN and payload into the text entry box in the top pane. Then click on the Convert button below the
top pane.
Example:
For this example, the DN is api/mo/sys.json and the NX-API REST payload is:
{
"topSystem": {
"attributes": {
"name": "REST2CLI"
}
}
}
When you click on the Convert button, the CLI equivalent appears in the CLI pane as shown in the following
image.
Note The Developer Sandbox cannot convert all payloads into equivalent CLIs, even if the Sandbox
converted the CLIs to NX-API REST payloads. The following is a list of possible sources of error
that can prevent a payload from completely converting to CLI commands:
The payload contains an attribute that does not The Error pane will return an error related to
exist in the MO. the attribute.
Example: Example:
api/mo/sys.json CLI
{
"topSystem": { Error unknown attribute
"children": [ 'fakeattribute' in element
{
"interfaceEntity": { 'l1PhysIf'
"children": [
{
"l1PhysIf": {
"attributes": {
"id": "eth1/1",
"fakeattribute":
"totallyFake"
}
}
}
]
}
}
]
}
}
The payload includes MOs that aren't yet The Error Pane will return an error related to
supported for conversion: the unsupported MO.
Example: Example:
api/mo/sys.json CLI
{
"topSystem": { Error The entire subtree of
"children": [ "sys/dhcp" is not converted.
{
"dhcpEntity": {
"children": [
{
"dhcpInst": {
"attributes": {
"SnoopingEnabled": "yes"
}
}
}
]
}
}
]
}
}