Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

API & Integration, DevOps,NetOps,SecOps

Reply

How to use "assign_state" to extract the value from an extensible attributes

New Member
Posts: 7
5868     0

I sent the following request 

 

[
{ "method": "GET", "object": "record:srv", "data":{"name":"_sip._tcp.vega.com", "view":"default"},  "args":{"_return_fields+":"extattrs"}, "assign_state": {"ref": "_ref", "ea":"extattrs"}, "discard":true},
{"method": "STATE:DISPLAY"}
]

 

and got such response:

 

[
    {
        "ref": "record:srv/ZG5zLmJpbmRfc3J2JC5fZGVmYXVsdC5jb20udmVnYS9wcml2aWxlZ2UzLTEvMC8wLzUwMDAvdmVnYS5jb20:_sip._tcp.vega.com/default", 
        "ea": {
            "Site": {
                "value": "ABC"
            }
        }
    }
]

My question is how to put the value of the EA "Site" into an variable, so that I can use it in the following request items., such as this:

 

[
{ "method": "GET", "object": "record:srv", "data":{"name":"_sip._tcp.vega.com", "view":"default"},  "args":{"_return_fields+":"extattrs"}, "assign_state": {"ref": "_ref", "ea":"extattrs"}, "discard":true},
{"method": "STATE:DISPLAY"},
{ "method": "PUT", "object": "##STATE:ref:##", "enable_substitution": true, "data":{"extattrs":{
"Site": {"value":"##STATE:ea.Site.value:##"}
}}}

 

what I got now is such an error:

{ "Error": "AdmConProtoError: Variable ea.Site.value not found in the current request state {u'ref': 'record:srv/ZG5zLmJpbmRfc3J2JC5fZGVmYXVsdC5jb20udmVnYS9wcml2aWxlZ2UzLTEvMC8wLzUwMDAvdmVnYS5jb20:_sip._tcp.vega.com/default', u'ea': {'Site': {'value': 'ABC'}}}", 
  "code": "Client.Ibap.Proto", 
  "text": "Variable ea.Site.value not found in the current request state {u'ref': 'record:srv/ZG5zLmJpbmRfc3J2JC5fZGVmYXVsdC5jb20udmVnYS9wcml2aWxlZ2UzLTEvMC8wLzUwMDAvdmVnYS5jb20:_sip._tcp.vega.com/default', u'ea': {'Site': {'value': 'ABC'}}}"
}

 

Re: How to use "assign_state" to extract the value from an extensible attributes

Adviser
Posts: 181
5868     0

Hi,

 

Here is an example from the WAPI document. Let me know if this works for you.

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.9/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
}]

Regards,

Krishna

Re: How to use "assign_state" to extract the value from an extensible attributes

New Member
Posts: 7
5869     0

Thanks a lot, it works well!

Showing results for 
Search instead for 
Did you mean: 

Recommended for You