Skip to content

cycleplatform/api-spec

Repository files navigation

Cycle API Spec

cycle

This repository contains the OpenAPI definitions for the Cycle Platform. This spec is used to generate various API clients, used by our team internally, and also the foundation of our API documentation.

⚠️ This spec is still under development. While most endpoints should be stable, there are still edge cases and small discrepancies that are actively being worked on. While no major breaking changes are expected, we can't guarantee that any downstream clients won't be affected by changes to schemas.

APIs

Platform API

https://api.cycle.io

Documentation

The platform API is the general use API for the Cycle Platform, and is available to all Cycle customers. It is the same API consumed by Cycle's portal, and is the main way to interact with all aspects of the platform.

See the platform folder for implementation.

Internal API

Documentation

Inside every container running on Cycle, there is a Unix socket mounted at /var/run/cycle/api/api.sock. You can send HTTP requests over this socket to access information about the local environment, access secrets, and much more. The way this internal API functions is very similar to how Cycle's main API works, though the purpose is different. The internal API is primarily used by instances to learn about their environment, and dynamically update as deployments change.

See the internal folder for implementation.

Scheduler API

Documentation

The scheduler API is used to interact with the Scheduler Service inside of an environment on Cycle. The scheduler service can be accessed from other containers in the environment over the private network, or the scheduler service can be made available over the public internet.

See the scheduler folder for implementation.

Infrastructure Abstraction Layer API

Documentation

Cycle's Infrastructure Abstract Layer (IAL) API. Endpoints listed here should be implemented by the customer, and Cycle will call the various endpoints over the lifecycle of provisioning and decommissioning servers.

For more information, check out the official Infrastructure Abstraction Layer Documentation.

Stack Spec

While not truly an API spec, the stack spec defines the JSON schema for a Cycle Stack File. The JSON schema is useful for editor validation etc.

The compiled stack spec schema is committed to this repo and hosted on JSON Schema Store

Building the APIs

The APIs can be consumed by tools that support stitching together specs divided between multiple files, or built into a single file using the Redocly CLI.

Prerequisites

You must have npm installed on your machine, or run inside a container with npm in the PATH.

Building the Platform API

npm run build:platform

The outputted file is located at /dist/platform.yml

Building the Internal API

npm run build:internal

The outputted file is located at /dist/internal.yml

Building the Scheduler API

npm run build:scheduler

The outputted file is located at /dist/scheduler.yml

Building the Infrastructure Abstraction Layer API

npm run build:ial

The outputted file is located at /dist/ial.yml

Building the Stack Spec

npm run build:stackspec

This will build the stack spec into a single JSON schema file, and save it to ./stackspec/stackspec.json.

This file should be committed to the repo.

Downconverting to OpenAPI 3.0.3

The API specs in this repo are written using the OpenAPI 3.1.0 standard. Some code generators and other tools haven't yet been updated to support 3.1.0, which can be an inconvenience. For us, it seems nearly all golang client generators don't support 3.1.0 (if you find one let us know!).

To resolve this, we've created a script that will downconvert the openapi spec to 3.0.3. Of course, some fidelity is lost with these conversions, so it may not be a perfect 1:1 with the 'true' spec, but hopefully is good enough to generate clients off of when necessary.

To downconvert, run npm run downconvert:platform. The script will output to dist/platform-3.0.3.yml.