Experimental CLI for Meraki API, using API client libraries code-generated by go-swagger
This golang project demonstrates the ability generate source files for a Meraki API client by running the go-swagger tool against the swagger file downloaded from Cisco Meraki. This project also demonstrates the creation of a CLI client using the Kingpin library by connecting CLI actions to Meraki API calls, using minimal code. Only a few CLI->API calls have been implemented, since this project is meant to serve as an example of a general pattern.
$ ./meraki-cli --help
usage: meraki [<flags>] <command> [<args> ...]
The Meraki CLI command.
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--auth-token="" Auth token. Export env var MERAKI_AUTH_TOKEN as an alternative
--log-level="info" Set log-level (trace|debug|info|warn|error|fatal|panic).
--server-host="api.meraki.com"
Server host.
--server-port=443 Server port.
Commands:
help [<command>...]
Show help.
devices list --organization-id=ORGANIZATION-ID
List all devices.
events list --network-id=NETWORK-ID --product-type=PRODUCT-TYPE
List all events for a network.
events types --network-id=NETWORK-ID
List all events for a network.
networks list --organization-id=ORGANIZATION-ID
List all networks for an organization.
networks get --network-id=NETWORK-ID
Get a network.
networks clients list --network-id=NETWORK-ID
List all Clients for a network.
networks ssids list --network-id=NETWORK-ID
List all SSIDs for a network.
organizations list
List all organizations.
organizations get --organization-id=ORGANIZATION-ID
Get a organization.
version
Display version information.
go get github.com/cisco-sso/meraki-cli
make all
# Set your authentication token
export MERAKI_AUTH_TOKEN=<secret_token>
# Execute a command
meraki-cli organizations list
# Enable debugging via environment variable
export DEBUG=1
# Execute the command with a flag
meraki-cli --log-level=debug ...