Hi Team,
This is a fun Quality of Life Improvement! I love that we have APIs in our applications since it really allows us to make quick changes within applications without having to access a GUI. I use APIs in testing and sometimes I want to load users into our DPSK Pools quickly, for testing. Now, I could do this in GUI, but if I am bulk uploading more than a few, this can be quite lengthy. Let’s do it through the API! We are going to use Postman to upload a CSV file with a username and password entered in it for our users.
We have had questions from customers that have asked for this functionality as well, which we point them to the documentation that is located here:
docs.commscope.com
Please point them to the RESTful API docs for Cloudpath located on that page.
If you have questions, please refer to that doc, in this QOL page we are going to show you importing a username/passphrase combination from a CSV file.
Create API key:
To begin with, let’s create an API key in Cloudpath:
- Click on Configuration | API Keys
- Click on Add API Key
- Give it a name and an end date
- Take note of the API key
- Click on Save
You need a CSV file, with, at a minimum, a “name” column, and a “passphrase” column. You need to have these two values to create a DPSK.
Example:
POSTMAN:
Create a Collection:
This will contain our API calls for Cloudpath
In Postman, we are going to create a new Collection:
- Click on Collections in the Scratch Pad on the Left
- Click the + button to create a new collection
- Name the New Collection for future reference
Create an Environment:
This will contain variables for us (such as AUTH token)
- On the top right, you should see “No Environment”, it may appear as a eye behind a piece of paper, click the eye and paper
- Click on ADD to create a new environment
- Provide this with a name
- In the VARIABLE column, enter in the word “token”
- Click on SAVE
Create a API call to authenticate using a token:
- In your collection, click on Add a request
- Change to POST call
- Enter in the URL for the API token, my example:https://cloudpath.ruckusdemos.net/admin/publicApi/token
- Click on the Headers tab
- In the KEY column, enter in “Authorization”
- In the VALUE column, enter in “{{token}}”
- Click on the Body tab,
- Change to “raw”
- Change the language to JSON
- Enter in your credentials in this format: (once enterd, click on Beatify on the right to align the text)
{
“userName”: “username”,
“password”: “password”
}
- Click on the Tests tab; we are going to create a test to auto-fill the “token” variable in Postman for us, then we can re-use this token in subsequent calls. Keep in mind that the token has a very short lifetime (like 5 mins) and has to be renewed before that time limit or created again.
- In this field, enter in this information:
const response = pm.response.json();
pm.environment.set(‘token’, response.token);
- Save
- Click on SEND!
- You will now see output down below with a Token a userName, token, serverVersion, and expireDateTime value. Also, if you look on the eye with paper showing the environment variable, the “token” should have a value assigned to it.
Let’s assume a DPKS pool is already created, if not, you can use APIs to create it as well.
Get a DPSK pool GUID to make DPSKs in
- Create a new request in Postman
- Make it a “Get”
- Enter in the URL : https://cloudpath.ruckusdemos.net/admin/publicApi/dpskPools
- In the Headers Tab, enter in the Authorization for the KEY and {{token}} for the VALUE
- Save
- If your Token has not expired run it, if it has, re-run your auth request. If your token is expired, you will receive a message stating that.
- In the Results, look for the guid for your DPSK pool
- Now, you know where you want to put the DPSKs (the GUID for that pool), let’s load in our file!
Create a RUN in Postman:
- Create a new POST request
- Add the URL:
https://cloudpath.ruckusdemos.net/admin/publicApi/dpskPools/”DPSKPoolGUID”/dpsks
- In the Parms tab, enter in two query parameters under KEY, one for name and one for passphrase
- The VALUE column should be set to {{name}} and {{passphrase}}
The name and passphrase will be read from the file headers.
- In the Headers tab, enter in your Authorization and {{token}} values
- In the Body tab, enter in the following as JSON:
{
“name”: “{{name}}”,
“passphrase”: “{{passphrase}}”,
“status”: “ACTIVE”
}
- Click on Save
If you token has expired… get a new one by running the auth call again.
Let’s load a file!
In Postman we can run a file through a collection and an API call.
- Click on Your Collection on the left.
- You will see that there is a “Run” button now located beside the “fork and save buttons”, click it
- In the run order, only select the last API call that you created.
- On the right, select your CSV file
Click “Run” to import the CSV file
If you look in the console of Postman, you will see the result and time taken:
In Cloudpath, we should see those entries for the DPSK pool:
Enjoy!