Cycle Platform API
What is Cycle?
Cycle is a Containers as a Service (CaaS) platform that through container-native features into a simple, yet powerful way to deploy and scale to bare-metal infrastructure around the world.
Installation
npm install --save cycle-api
API Overview
A token is required in order to access any endpoint using Cycle's API. When you authenticate using your API Key (generate one in the portal), a token/refresh token combo is generated and stored. This token will expire after two hours, it is up to the user to manage token refreshing.
authenticate;
The token is stored in an internal cache, but can be overridden if desired. This is useful if you want to write your token into a local storage device.
Every resource method returns an API Response wrapped in an awaitable promise. An API response contains the following properties:
where T is the type of resource you are attempting to access. This format is extremely powerful when using Typescript > 2.0, due to tagged unions. When using Typescript > 2.0, you MUST check the response of the call and verify no error is present before you are able to access the value.
getEnvironmentsList;
Settings
- Setting a team:
; Settings.team = "YOUR_TEAM_ID";
- Utilize an internal resource cache - If the same call is made within x seconds, it'll use a cached version of the results for speed
; Settings.cache.use = true; Settings.cache.refresh = 1000 //ms
- Set up token storage - Requires an interface with three functions: read, write, and delete
; Settings.storage = new StorageInterface; // Replace with class that matches interface
Utility
The API client comes with optional utility functions to make interacting with Cycle even simpler.
Job Tracker
The job tracker is an awaitable function that takes a settings object and resolves when the job is in a state that would be completed - whether or not it errored.
; // Settings // Usage