Files
Julien Lengrand-Lambert 3cdf8826eb Adding flyio
2024-03-07 10:52:37 +01:00

9.5 KiB
Raw Permalink Blame History

Machines API - Jetbrains API Client

General API description

Introduction Fly Machines are the compute behind the Fly.io platform. They are fast-launching VMs that can be started and stopped at subsecond speeds. A Machine is the configuration and state for a single VM running on our platform. Every Machine will belong to a Fly App; Apps can have more than one Machine. Read more here. The Machines REST API allows you to provison and manage Apps, Machines and Volumes on the Fly.io platform. To manage other Fly.io resources like organizations, use the GraphQL API. ## Authentication All requests must include the Fly API Token in the HTTP Headers as follows: ``` Authorization: Bearer [TOKEN] ``` You can get your API token using flyctl by running `fly auth token` ## Base URL The easiest (and recommended) way to connect to the Machines API is to use the public `api.machines.dev` endpoint, a simpler and more performant alternative to connecting over WireGuard. You can still access your Machines directly over a WireGuard VPN, and use the private Machines API endpoint: `http://_api.internal:4280`. This method requires more setup. Follow the instructions to set up a permanent WireGuard connection to your Fly.io IPv6 private network. Once youre connected, Fly internal DNS should expose the Machines API endpoint at: `http://_api.internal:4280` ## Response Codes The API uses conventional HTTP status codes to signal whether a request was successful or not. Typically, 2xx HTTP status codes denote successful operations, 4xx codes imply failures related to the user, and 5xx codes suggest problems with the infrastructure. | Status | Description | | :----: | ------------------------------------------- | | `200` | Successful request. | | `201` | Created successfully. | | `202` | Successful request. No content. | | `400` | Check that the parameters were correct. | | `401` | The API key used was missing or invalid. | | `404` | The resource was not found. | | `5xx` | Indicates an error with Fly.io API servers. |

Documentation for API Endpoints

All URIs are relative to https://api.machines.dev/v1, but will link to the .http file that contains the endpoint definition. There may be multiple requests for a single endpoint, one for each example described in the OpenAPI specification.

Class Method HTTP request Description
AppsApi appsCreate POST /apps Create App
AppsApi appsDelete DELETE /apps/{app_name} Destroy App
AppsApi appsList GET /apps List Apps
AppsApi appsShow GET /apps/{app_name} Get App
MachinesApi machinesCordon POST /apps/{app_name}/machines/{machine_id}/cordon Cordon Machine
MachinesApi machinesCreate POST /apps/{app_name}/machines Create Machine
MachinesApi machinesCreateLease POST /apps/{app_name}/machines/{machine_id}/lease Create Lease
MachinesApi machinesDelete DELETE /apps/{app_name}/machines/{machine_id} Destroy Machine
MachinesApi machinesDeleteMetadata DELETE /apps/{app_name}/machines/{machine_id}/metadata/{key} Delete Metadata
MachinesApi machinesExec POST /apps/{app_name}/machines/{machine_id}/exec Execute Command
MachinesApi machinesList GET /apps/{app_name}/machines List Machines
MachinesApi machinesListEvents GET /apps/{app_name}/machines/{machine_id}/events List Events
MachinesApi machinesListProcesses GET /apps/{app_name}/machines/{machine_id}/ps List Processes
MachinesApi machinesListVersions GET /apps/{app_name}/machines/{machine_id}/versions List Versions
MachinesApi machinesReleaseLease DELETE /apps/{app_name}/machines/{machine_id}/lease Release Lease
MachinesApi machinesRestart POST /apps/{app_name}/machines/{machine_id}/restart Restart Machine
MachinesApi machinesShow GET /apps/{app_name}/machines/{machine_id} Get Machine
MachinesApi machinesShowLease GET /apps/{app_name}/machines/{machine_id}/lease Get Lease
MachinesApi machinesShowMetadata GET /apps/{app_name}/machines/{machine_id}/metadata Get Metadata
MachinesApi machinesSignal POST /apps/{app_name}/machines/{machine_id}/signal Signal Machine
MachinesApi machinesStart POST /apps/{app_name}/machines/{machine_id}/start Start Machine
MachinesApi machinesStop POST /apps/{app_name}/machines/{machine_id}/stop Stop Machine
MachinesApi machinesUncordon POST /apps/{app_name}/machines/{machine_id}/uncordon Uncordon Machine
MachinesApi machinesUpdate POST /apps/{app_name}/machines/{machine_id} Update Machine
MachinesApi machinesUpdateMetadata POST /apps/{app_name}/machines/{machine_id}/metadata/{key} Update Metadata
MachinesApi machinesWait GET /apps/{app_name}/machines/{machine_id}/wait Wait for State
VolumesApi createVolumeSnapshot POST /apps/{app_name}/volumes/{volume_id}/snapshots Create Snapshot
VolumesApi volumeDelete DELETE /apps/{app_name}/volumes/{volume_id} Destroy Volume
VolumesApi volumesCreate POST /apps/{app_name}/volumes Create Volume
VolumesApi volumesExtend PUT /apps/{app_name}/volumes/{volume_id}/extend Extend Volume
VolumesApi volumesGetById GET /apps/{app_name}/volumes/{volume_id} Get Volume
VolumesApi volumesList GET /apps/{app_name}/volumes List Volumes
VolumesApi volumesListSnapshots GET /apps/{app_name}/volumes/{volume_id}/snapshots List Snapshots
VolumesApi volumesUpdate POST /apps/{app_name}/volumes/{volume_id} Update Volume

Usage

Prerequisites

You need IntelliJ to be able to run those queries. More information can be found here. You may have some luck running queries using the Code REST Client as well, but your mileage may vary.

Variables and Environment files

  • Generally speaking, you want queries to be specific using custom variables. All variables in the .http files have the `` format.
  • You can create public or private environment files to dynamically replace the variables at runtime.

Note: don't commit private environment files! They typically will contain sensitive information like API Keys.

Customizations

If you have control over the generation of the files here, there are two main things you can do

  • Select elements to replace as variables during generation. The process is case-sensitive. For example, API_KEY ->
    • For this, run the generation with the bodyVariables property, followed by a "-" separated list of variables
    • Example: --additional-properties bodyVariables=YOUR_MERCHANT_ACCOUNT-YOUR_COMPANY_ACCOUNT-YOUR_BALANCE_PLATFORM
  • Add custom headers to all requests. This can be useful for example if your specifications are missing security schemes.
    • For this, run the generation with the customHeaders property, followed by a "&" separated list of variables
    • Example : --additional-properties=customHeaders="Cookie:X-API-KEY="&"Accept-Encoding=gzip"

This client was generated by the jetbrains-http-client generator of OpenAPI Generator