zcli api-tokengenerates a session token that scripts and integrations can use to call the Edge Infrastructure Services API.zcli api-usageshows how many API requests were made to each endpoint in a time range, and how many of them succeeded or failed.
Before You Start
- ZCLI is installed and authenticated against your enterprise. See Get Started.
- To view API usage, you have a role that allows you to read API usage statistics. [TBD: confirm the minimum role required for
zcli api-usage show, and whether cluster-wide statistics require a cloud-service administrator role.]
Generate an API Token
Generate a token for your enterprise
Generate an API token for the user who is logged in to ZCLI. The token carries the same permissions as your user account.
Example: generate a token that is valid for 30 days (43,200 minutes):
API-Token: as the Bearer token in API requests. See Use the Token in API Requests.
Keep the following in mind:
- Enter
--token-expiryin minutes, not seconds. The Authentication page describes the API’sexpiresfield in seconds, but ZCLI multiplies your value by 60. For example,--token-expiry=60creates a token that is valid for one hour. - Enter
--token-expiryas a whole number. A value such as1hor30.5stops ZCLI with a Python error (ValueError) before the request is sent. - Your enterprise can set a maximum token lifetime. See Token Expiry and Rotation.
- If the enterprise name is not found, Edge Infrastructure Services returns an error and no token is created.
The
zcli api-token --help text has two errors. The Commands section lists the command as get-api-oken, and the example uses get-token. Neither name works. Use get-api-token, as shown on this page.View API Usage
Show API usage statistics
Show the number of API requests per endpoint, with the number of successful and failed requests.
Flag names are case-sensitive. Write
--enterpriseIDs and --userAgents exactly as shown.
To show API usage with the default time range:
zcli enterprise show <name>.
The
zcli api-usage --help text documents the enterprise filter as --enterpriseID (singular) and does not describe --userAgents. Use --enterpriseIDs and --userAgents, as shown in the syntax line on this page.Time zone
ZCLI reads--from and --to in the local time zone of the system where ZCLI runs, and converts them to UTC before it sends the request. In the ZCLI container, the local time zone is usually UTC. If a value is not in the format YYYY-MM-DD HH:MM:SS, ZCLI prints input datetime in format %Y-%m-%d %H:%M:%S and stops.
Read the output
The text output starts with a line that shows what the statistics cover:(Cluster Wide)when the statistics are not filtered by enterprise.(Enterprise (IDs: [...]))with the enterprise IDs when they are.
To see the full response, including the count for each HTTP status code, add the global
--format=json option:
Next Steps
Authentication
Token scope, expiry, rotation, and how to use a token in API requests.
ZEDEDA API Overview
The services and versions of the Edge Infrastructure Services API.
Get Started
Install ZCLI, configure access to Edge Infrastructure Services, and sign in.
Overview
All ZCLI command procedures, organized by resource type.