Reply
Accepted Solution

get list of valid values for a attribute

kennethdue
Techie
Posts: 5
6545     0

Hi All

what is the easy REST-way to get a list of possible values in a extattr ?

 

We have a attribute with a list of possible values - let's call it rack-number


Now we are working on automating a function, where we need to check if the rack-number is within the allowed list, before making the create-REST-call.

 

If the create-call has a extattr value that is not in the list, it will fail,

and we want to catch the error, before making the create-call

 

we are using wapi 2.2.2, not sure if the server supports anything newer

 

Re: get list of valid values for a attribute

Moderator BRampling
Moderator
Posts: 69
6546     0
curl -k1 -u admin:infoblox -H "Content-Type: application/json" -X GET https://10.60.27.4/wapi/v2.7/extensibleattributedef?_return_fields=list_values -d '{"name":"TestList"}'

 

Results in:

 

[

    {

        "_ref": "extensibleattributedef/b25lLmV4dGVuc2libGVfYXR0cmlidXRlc19kZWYkLlRlc3RMaXN0:TestList",

        "list_values": [

            {

                "value": "TestValue1"

            },

            {

                "value": "TestValue2"

            }

        ]

    }

]

Re: get list of valid values for a attribute

kennethdue
Techie
Posts: 5
6546     0

Thanks, it works great

 

Re: get list of valid values for a attribute

[ Edited ]
Authority
Posts: 18
6546     0

Hi tried giving , to list all our VLAN-ID

GET : https://ipman/wapi/v2.6.1/extensibleattributedef?_return_fields=list_values –d '{"name":"VLAN-ID"}'

but it shows error as follows :

{
    "Error": "AdmConProtoError: Unknown argument/field: 'list_values –d  '{\"name\":\"VLAN-ID\"}''",
    "code": "Client.Ibap.Proto",
    "text": "Unknown argument/field: 'list_values –d  '{\"name\":\"VLAN-ID\"}''"
}

 

BUT When I tried

GET : https://ipman/wapi/v2.6.1/extensibleattributedef?_return_fields=list_values

Which could list all the EA list

 {
        "_ref": "extensibleattributedef/b25lLmV4dGVuc2libGVfYXR0cmlidXRlc19kZWYkLlZMQU4tSUQ:VLAN-ID",
        "list_values": [
            {
                "value": "kein"
            },
            {
                "value": "2"
            },
            {
                "value": "3"
            },
            {....

 

Where I have gone wrong!!

 

and Additionally , is there any way I could sort the VLAN ID as numerically ?

 

thank you

Re: get list of valid values for a attribute

Adviser
Posts: 93
6546     0

If your're sending JSON data you also need to include the header telling it you're sending JSON data.  Otherwise your request looks good.

 

"Content-Type: application/json"

 

Or, you could put the name of the EA directly in the URL and get the same results:

 

GET : https://ipman/wapi/v2.6.1/extensibleattributedef?name=VLAN-ID&_return_fields=list_values

Re: get list of valid values for a attribute

[ Edited ]
Authority
Posts: 18
6546     0

Thanks it works fine !

 

is there any way I could sort the VLAN-ID ie. sorting Values in ascending order.

like 1,2,3 rather than 1,10,11.. etc

Re: get list of valid values for a attribute

Adviser
Posts: 93
6546     0

No, you would need to sort on the client side.  While you can view the REST API output directly, generally API output is intended to be loaded into a client and parsed before being displayed for human consumption.

Showing results for 
Search instead for 
Do you mean 

Recommended for You