API Guide
Introduction
The Eyeglass REST API offers an alternative way to interact with Eyeglass, complementing the user interface. Through the API, users can retrieve information such as policies, nodes, jobs, and alarms, as well as perform various operations. The API Explorer includes a CURL builder for generating commands, which can be used in scripts to automate these operations. Token-based authentication is utilized to secure and authorize API requests.
Technical Knowledge Required
To effectively utilize the Eyeglass REST API, users should have a working knowledge of the following:
- RESTful APIs: Understanding how REST APIs work, including how to construct and send HTTP requests.
- CURL: Familiarity with using CURL to generate and execute commands.
- Authentication: Basic knowledge of token-based authentication and how to include tokens in API requests.
- Eyeglass Features: Understanding of Eyeglass processes, policies, access zones, and jobs, to correctly interact with the API.
- JSON: Basic knowledge of JSON for parsing and interpreting the responses received from API calls.
Use Cases
-
Polling Alarms: Eyeglass provides an alarm REST interface that allows users to poll for active alarms specific to Eyeglass. Users can retrieve alarms using CURL or any REST-enabled tool.
-
Dashboard Creation: The API can be integrated into dashboards for monitoring policies, access zones, or clusters. It supports various development languages that utilize REST.
-
Automation: The API can be used to request in eyeglass and monitor its progress. It enables automation for single or multiple policies.
-
Custom Scripting: Developers can create custom scripts and integrate them with Eyeglass. The API can also be used to initiate operations scripts, which are executed by the Eyeglass script engine.
API Architecture
REST-based API
The API is REST-based and provides a flexible way to interact with Eyeglass' resources. The API Explorer assists in navigating the various endpoints required to perform tasks.
API Explorer and CURL Builder
The API Explorer offers a CURL command builder that enables users to select policies or access zones and build the corresponding CURL commands for automation. These commands can then be copied into scripts for execution of operations.
Token Generation and Authentication
The API uses token-based authentication to identify and authorize applications. Each API request must include a valid token in the header to authenticate.
Token Authentication Process
Tokens are required for authenticating requests made to the API. When constructing CURL commands, an HTTP header with the api_key
must be included along with a valid token.
CURL Commands
curl --header "api_key: your-token-here" --header "accept: application/json" https://eyeglass.example/sera/v1/jobs
Handling REST API Tokens
Creating Tokens
To authenticate REST commands, tokens must be created for each application. A name parameter, such as "SRM" for VMware SRM, identifies the application. You can create new tokens from the Superna Eyeglass REST API interface.
- Access the Eyeglass menu.
- Click on the Integrations icon.
- Navigate to the API Tokens tab and click the Create New Token button.
- Enter a name for the token.
- Click the OK button.
- After completing these steps, the token will appear on the list of tokens. Select the token you want to copy, and it will be ready for use.
Revoking Tokens
Tokens can be revoked via the API interface, which disables the application’s access to the Eyeglass API.
- Access the Eyeglass menu.
- Click on the Integrations icon.
- Click on the API Tokens tab.
- Once the list of created tokens appears, click on the X located on the Revoke tab.
- A warning will appear asking if you want to permanently revoke the token "token name."
- Click the Yes button to confirm or the No button to cancel.
Launching API Explorer
To explore the available APIs and interact with them, users can launch the API Explorer from the Superna Eyeglass REST API interface.
- Access the Eyeglass menu.
- Click on the Integrations icon.
- Select the API Explorer tab.
- Click the Launch API Explorer button.
- The API Explorer will open, allowing you to see and interact with the available APIs.