The following sections demonstrate how to interact with WAPI via a single entry point.
Use a POST request to get the Host record with the name “test.somewhere.com”:
https://1.2.3.4/wapi/v2.12.3/request
With a body:
{
"data": {
"name": "test.somewhere.com"
},
"method": "GET",
"object": "record:host"
}
Use a POST request to get the Host record with the name “test.somewhere.com”, save its reference to the state object and use it for an update operation:
https://1.2.3.4/wapi/v2.12.3/request
With a body:
[{
"method": "STATE:ASSIGN",
"data": {
"host_name": "test.somewhere.com"
}
},
{
"method": "GET",
"object": "record:host",
"data": {
"name": "##STATE:host_name:##"
},
"assign_state": {
"host_ref": "_ref"
},
"enable_substitution": true,
"discard": true
},
{
"method": "PUT",
"object": "##STATE:host_ref:##",
"enable_substitution": true,
"data": {
"comment": "new comment"
},
"args": {
"_return_fields": "comment"
},
"assign_state": {
"updated_comment": "comment"
},
"discard": true
},
{
"method": "STATE:DISPLAY"
}
]
Returns with a body:
{
"host_name": "test.somewhere.com",
"host_ref": "record:host/ZG5...zdA:test.somewhere.com/default",
"updated_comment": "new comment"
}
Use a POST request to get the Host record with the name “host.test.com”, save array index “ipv4addrs[1]” to the state object and use it for an update operation:
https://1.2.3.4/wapi/v2.12.3/request
With a body:
[{
"method": "STATE:ASSIGN",
"data": {
"host_name": "host.test.com"
}
},
{
"method": "GET",
"object": "record:host",
"data": {
"name": "##STATE:host_name:##"
},
"args": {
"_return_fields": "ipv4addrs.ipv4addr"
},
"assign_state": {
"host_ref": "_ref",
"subobject": "ipv4addrs[1]"
},
"enable_substitution": true
},
{
"method": "PUT",
"object": "##STATE:host_ref:##",
"enable_substitution": true,
"data": {
"comment": "Requested IP is ##STATE:subobject:##"
},
"args": {
"_return_fields": "comment"
},
"assign_state": {
"updated_comment": "comment"
},
"discard": true
},
{
"method": "STATE:DISPLAY"
}
]
Returns with a body:
[{
"result": [{
"_ref": "record:host/ZG5...c3Q:host.test.com/default",
"ipv4addrs": [{
"_ref": "record:host_ipv4addr/ZG5z...xLg:1.1.1.1/host.test.com/default",
"ipv4addr": "1.1.1.1"
},
{
"_ref": "record:host_ipv4addr/ZG5...yLg:2.2.2.2/host.test.com/default",
"ipv4addr": "2.2.2.2"
}
]
}
]
},
{
"host_name": "host.test.com",
"host_ref": "record:host/ZG5...c3Q:host.test.com/default",
"subobject": {
"_ref": "record:host_ipv4addr/ZG5...yLg:2.2.2.2/host.test.com/default",
"ipv4addr": "2.2.2.2"
}
"updated_comment": "Requested IP is {'_ref': 'record:host_ipv4addr/ZG5...yLg:2.2.2.2/host.test.com/default',
'ipv4addr': '2.2.2.2'}"
}
]
Use a POST request to copy extensible attribute “Building” from an existing network to a new one using “assign_state” to save the value in the state object:
https://1.2.3.4/wapi/v2.12.3/request
With a body:
[{
"method": "GET",
"object": "network",
"data": {
"network": "10.1.0.0/16"
},
"args": {
"_return_fields+": "extattrs"
},
"assign_state": {
"ea_value": "*Building"
},
"discard": true
},
{
"method": "POST",
"object": "network",
"data": {
"network": "20.1.0.0/16",
"extattrs": {
"Building": {
"value": "##STATE:ea_value:##"
}
}
},
"enable_substitution": true
}
]