npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clearpass-csv2api

v1.0.0

Published

Helper CLI tool that will convert a local CSV file to a series of REST POST creation calls.

Downloads

101

Readme

clearpass-csv2api

Node CLI tool to import a CSV into ClearPass via the RESTful API.

Currently supports Guests and Devices. Reference the built in documentation for help.

sudo npm install -g clearpass-csv2api
$ clearpass-csv2api help
Usage: clearpass-csv2api [options] [command]

Options:
  -V, --version                 output the version number
  -v, --verbose                 Output extra debugging (default: false)
  --importing <importing>       What is being imported.  Current accepted values: device, guest (default: "device")
  -h, --help                    Display help for command

Commands:
  import [options] <csv_file>   Import a CSV of items into ClearPass
  testcsv [options] <csv_file>  Confirm the csv seems valid.
  ping [options]                Test connectivity, authentication and privileges
  generate [options] <count>    Generate a random CSV
  help [command]                display help for command

Example calls:

  Confirm credentials and permissions:
  $ clearpass-csv2api ping --host=192.0.2.10 --client_id=Client1 --client_secret=asdfadsf

  Test the CSV:
  $ clearpass-csv2api testcsv devices.csv
  $ clearpass-csv2api --importing=guest testcsv guest.csv

  Initiate the import:
  $ clearpass-csv2api --verbose import --host 192.0.2.10 --client_id=Client1 --client_secret=asdfadsf devices.csv
  $ clearpass-csv2api --verbose import --host 192.0.2.10 --client_id=Client1 --client_secret=asdfadsf --strategy=update-or-create devices-sync.csv
  $ clearpass-csv2api --verbose --importing=guest import --host 192.0.2.10 --client_id=Client1 --client_secret=asdfadsf guests.csv
  $ clearpass-csv2api --verbose import --host 192.0.2.10 --client_id=Client1 --client_secret=asdfadsf --exclude=id,region -x "notes=Import from ACME" -x "visitor_company=IoT Corp" devices.csv

  Generate test data:
  $ clearpass-csv2api generate 100 > devices-100.csv
  $ clearpass-csv2api generate 100 -x role_id=1 -x "notes=Import from ACME" > devices-ACME-Contractors.csv
  $ clearpass-csv2api --importing=guest generate 100 > guests-100.csv
$ clearpass-csv2api help import
Usage: clearpass-csv2api import [options] <csv_file>

Import a CSV of items into ClearPass

Options:
  --host <host>                           The IP address/hostname of ClearPass. (default: "127.0.0.1")
  --insecure                              Disable SSL validation (default: false)
  --client_id <client_id>                 API Client ID (default: "Client1")
  --client_secret <client_secret>         API Client Secret (default: "")
  -x --extra <extra>                      An extra key=value pair. Multiple supported. (default: {})
  --exclude <list of columns to exclude>  Excluded list (default: [])
  --sessions <sessions>                   Max simultaneous sessions (default: 1)
  --strategy <strategy>                   Strategy to use when making API calls
      create-only       Create new items only.  Existing will be ignored.
      create-or-replace Create new items or replace existing entries with the CSV.
      create-or-update  Create new items or update existing entries with data in the CSV.
      update-only       Update existing items only.  Entries without a match will be skipped.
      update-or-create  Update existing items.  If the entry does not exist it will be created.
      replace-only      Replace existing items only.  Entries without a match will be skipped.
      replace-or-create Replace existing items.  If the entry does not exist it will be created.
       (default: "create-only")
  --change-of-authorization               Send RADIUS CoA requests (default: false)
  --dry-run                               Dry run, do not send any API (default: false)
  -h, --help                              Display help for command
$ clearpass-csv2api help testcsv
Usage: clearpass-csv2api testcsv [options] <csv_file>

Confirm the csv seems valid.

Options:
  -x --extra <extra>                      An extra key=value pair. Multiple supported. (default: {})
  --exclude <list of columns to exclude>  Excluded list (default: [])
  -h, --help                              Display help for command
$ clearpass-csv2api help ping
Usage: clearpass-csv2api ping [options]

Test connectivity, authentication and privileges

Options:
  --host <host>                    The IP address/hostname of ClearPass. (default: "127.0.0.1")
  --insecure                       Disable SSL validation (default: false)
  --client_id <client_id>          API Client ID (default: "Client1")
  --client_secret <client_secret>  API Client Secret (default: "")
  --insecure                       Disable SSL validation (default: false)
  -h, --help                       Display help for command

API Clients are created in Guest » Administration » API Services » API Clients.
You need the following set:
  * Operating Mode: ClearPass REST API
  * Operator Profile: A profile with sufficient privileges
  * Grant Type: Client Credentials
The Client ID and Client Secret are passed as arguments.  Ensure you protect the secret.

Privileges:
  * ALL  : API Services > Allow API Access
  * Devices  : Devices > Create New Device and Guest Manager > Full User Control
  * Guests   : Guest Manager > Create New Guest Account and Guest Manager > Full User Control
$ clearpass-csv2api help generate
Usage: clearpass-csv2api generate [options] <count>

Generate a random CSV

Options:
  -x --extra <extra>  An extra key=value pair. Multiple supported. (default: {})
  -h, --help          Display help for command