NAC API Howto

CNaaS NAC exposes a standard REST-like JSON API. In these examples we will use curl to do some basic operations.

This API uses the TCP port 5001 for communication.

List all users

curl -X GET http://localhost:5001/api/v1.0/auth

List a single user

curl -X GET http://localhost:5001/api/v1.0/auth/foo  # Where 'foo' is the username

Add users

This POST method will accept JSON input with the following fields:

  • username, the name of the user to be created
  • password, the password.
  • vlan, the VLAN to which the user will be associated. 
curl --header "Content-Type: application/json" -X POST --data '{"username":"foo","password":"bar","vlan":111}' http://localhost:5001/api/v1.0/auth

Modify users

This method uses the same input data as add users. But will utilise the username in the URL.

curl --header "Content-Type: application/json" -X POST --data '{"password":"baz","vlan":222}' http://localhost:5001/api/v1.0/auth/foo

Delete users

Once again we will pass the username in the URL.

curl -X DELETE http://localhost:5001/api/v1.0/auth/foo
  • No labels