cancel
Showing results for 
Search instead for 
Did you mean: 

Using the API to bulk upload DPSKs from a file!

Vigneshwar
RUCKUS Team Member

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:

  1. Click on Configuration | API Keys
  2. Click on Add API Key
  3. Give it a name and an end date
  4. Take note of the API key
  5. Click on Save

Vigneshwar_0-1681288551276.png

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:

Vigneshwar_1-1681288551287.png

POSTMAN:

Create a Collection:
This will contain our API calls for Cloudpath

In Postman, we are going to create a new Collection:

  1. Click on Collections in the Scratch Pad on the Left
  2. Click the + button to create a new collection
  3. Name the New Collection for future reference

Create an Environment:
This will contain variables for us (such as AUTH token)

  1. 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
  2. Click on ADD to create a new environment
  3. Provide this with a name
  4. In the VARIABLE column, enter in the word “token”

Vigneshwar_2-1681288551288.png

  1. Click on SAVE

Create a API call to authenticate using a token:

  1. In your collection, click on Add a request
  2. Change to POST call
  3. Enter in the URL for the API token, my example:https://cloudpath.ruckusdemos.net/admin/publicApi/token
  1. Click on the Headers tab
  2. In the KEY column, enter in “Authorization”
  3. In the VALUE column, enter in “{{token}}”

Vigneshwar_3-1681288551289.png

  1. Click on the Body tab,
  2. Change to “raw”
  3. Change the language to JSON
  4. Enter in your credentials in this format: (once enterd, click on Beatify on the right to align the text)

{
“userName”: “username”,
“password”: “password”
}

  1. 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.
  2. In this field, enter in this information:

const response = pm.response.json();
pm.environment.set(‘token’, response.token);

  1. Save
  2. Click on SEND!
  3. 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

  1. Create a new request in Postman
  2. Make it a “Get”
  3. Enter in the URL : https://cloudpath.ruckusdemos.net/admin/publicApi/dpskPools
  4. In the Headers Tab, enter in the Authorization for the KEY and {{token}} for the VALUE

Vigneshwar_4-1681288551291.png

  1. Save
  2. 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.
  3. In the Results, look for the guid for your DPSK pool

Vigneshwar_5-1681288551294.jpeg

  1. 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:

  1. Create a new POST request
  2. Add the URL:
    https://cloudpath.ruckusdemos.net/admin/publicApi/dpskPools/”DPSKPoolGUID”/dpsks
  1. In the Parms tab, enter in two query parameters under KEY, one for name and one for passphrase
  2. The VALUE column should be set to {{name}} and {{passphrase}}

Vigneshwar_6-1681288551295.png

The name and passphrase will be read from the file headers.

  1. In the Headers tab, enter in your Authorization and {{token}} values
  2. In the Body tab, enter in the following as JSON:

{
“name”: “{{name}}”,
“passphrase”: “{{passphrase}}”,
“status”: “ACTIVE”
}

  1. 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.

  1. Click on Your Collection on the left.
  2. You will see that there is a “Run” button now located beside the “fork and save buttons”, click it

Vigneshwar_7-1681288551295.png

  1. In the run order, only select the last API call that you created.
  2. On the right, select your CSV file

Vigneshwar_8-1681288551296.png

Click “Run” to import the CSV file

If you look in the console of Postman, you will see the result and time taken:

Vigneshwar_9-1681288551297.png

In Cloudpath, we should see those entries for the DPSK pool:

Vigneshwar_10-1681288551298.png 

 

Enjoy!

 

0 REPLIES 0