Skip to main content
Version: 2.9.0

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.

Example API Calls

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.

  1. Access the Eyeglass menu.
  2. Click on the Integrations icon. eyeglass menu
  3. Navigate to the API Tokens tab and click the Create New Token button. api_tokens_tab_create
  4. Enter a name for the token. token_name
  5. Click the OK button.
  6. 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. token_list.png

Revoking Tokens

Tokens can be revoked via the API interface, which disables the application’s access to the Eyeglass API.

  1. Access the Eyeglass menu.
  2. Click on the Integrations icon. eyeglass menu
  3. Click on the API Tokens tab. alt text
  4. Once the list of created tokens appears, click on the X located on the Revoke tab.
  5. A warning will appear asking if you want to permanently revoke the token "token name." revoke_token
  6. 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.

  1. Access the Eyeglass menu.
  2. Click on the Integrations icon. eyeglass
  3. Select the API Explorer tab. api_explorer
  4. Click the Launch API Explorer button.
  5. The API Explorer will open, allowing you to see and interact with the available APIs. alt text