Documentation ¶
Overview ¶
Package flymachines is an API client for Fly's machines API.
This package is loosely based on the Swagger spec for the Fly Machines API1, but with only the important bits implemented.
Index ¶
- func NewError(resp *http.Response) error
- func Ptr[T any](t T) *T
- type App
- type CheckStatus
- type Client
- func (c *Client) CordonAppMachine(ctx context.Context, appID, machineID string) error
- func (c *Client) CreateApp(ctx context.Context, caa CreateAppArgs) (*CreateAppResponse, error)
- func (c *Client) CreateMachine(ctx context.Context, appID string, cm CreateMachine) (*Machine, error)
- func (c *Client) CreateVolume(ctx context.Context, appName string, cv CreateVolume) (*Volume, error)
- func (c *Client) DeleteApp(ctx context.Context, appName string) error
- func (c *Client) DeleteAppMachine(ctx context.Context, appID, machineID string) error
- func (c *Client) DeleteVolume(ctx context.Context, appName, volumeID string) error
- func (c *Client) DestroyAppMachine(ctx context.Context, appID, machineID string) error
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) ExtendVolume(ctx context.Context, appName, voluleID string, sizeGB int) (*ExtendVolumeResponse, error)
- func (c *Client) GetApp(ctx context.Context, appName string) (*SingleApp, error)
- func (c *Client) GetAppMachine(ctx context.Context, appID, machineID string) (*Machine, error)
- func (c *Client) GetAppMachineEvents(ctx context.Context, appID, machineID string) ([]MachineEvent, error)
- func (c *Client) GetAppMachineMetadata(ctx context.Context, appID, machineID string) (map[string]string, error)
- func (c *Client) GetAppMachines(ctx context.Context, appName string) ([]Machine, error)
- func (c *Client) GetApps(ctx context.Context, orgSlug string) ([]ListApp, error)
- func (c *Client) GetVolume(ctx context.Context, appName, volumeID string) (*Volume, error)
- func (c *Client) GetVolumes(ctx context.Context, appName string) ([]Volume, error)
- func (c *Client) ListVolumeSnapshots(ctx context.Context, appName, volumeID string) ([]Snapshot, error)
- func (c *Client) RestartAppMachine(ctx context.Context, appID, machineID string) error
- func (c *Client) StartAppMachine(ctx context.Context, appID, machineID string) error
- func (c *Client) StopAppMachine(ctx context.Context, appID, machineID string) error
- func (c *Client) UncordonAppMachine(ctx context.Context, appID, machineID string) error
- type CreateAppArgs
- type CreateAppResponse
- type CreateMachine
- type CreateVolume
- type Error
- type ExtendVolumeResponse
- type ImageRef
- type ListApp
- type Machine
- type MachineCheck
- type MachineConfig
- type MachineEvent
- type MachineGuest
- type MachineHTTPHeader
- type MachineMount
- type MachinePort
- type MachineProcess
- type MachineRestart
- type MachineRestartPolicy
- type MachineService
- type MachineServiceConcurrency
- type MachineStopConfig
- type MilliTime
- type Org
- type SingleApp
- type Snapshot
- type Volume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct { ID string `json:"id"` // The unique ID of the app Name string `json:"name"` // The name of the app (also unique but human readable) }
App is a Fly app. Apps are collections of resources such as machines, volumes, and IP addresses.
type CheckStatus ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
New returns a new client for the Fly machines API with the given API token.
This will automatically detect if you have access to the internal API either by a WireGuard tunnel or by being on the Fly network.
func NewClient ¶
NewClient returns a new client for the Fly machines API with the given API token and URL.
This is a fairly low-level operation for if you know what URL you need, you probably want to use New instead.
func (*Client) CordonAppMachine ¶
func (*Client) CreateApp ¶
func (c *Client) CreateApp(ctx context.Context, caa CreateAppArgs) (*CreateAppResponse, error)
CreateApp creates a single application in the given organization and on the given network.
func (*Client) CreateMachine ¶
func (*Client) CreateVolume ¶
func (*Client) DeleteAppMachine ¶
func (*Client) DeleteVolume ¶
func (*Client) DestroyAppMachine ¶
func (*Client) Do ¶
Do performs a HTTP request with the appropriate authentication and user agent headers.
func (*Client) ExtendVolume ¶
func (*Client) GetAppMachine ¶
func (*Client) GetAppMachineEvents ¶
func (*Client) GetAppMachineMetadata ¶
func (*Client) GetAppMachines ¶
func (*Client) GetVolumes ¶
func (*Client) ListVolumeSnapshots ¶
func (*Client) RestartAppMachine ¶
func (*Client) StartAppMachine ¶
func (*Client) StopAppMachine ¶
type CreateAppArgs ¶
type CreateAppArgs struct { AppName string `json:"app_name"` Network string `json:"network"` OrgSlug string `json:"org_slug"` }
CreateAppArgs are the arguments to the CreateApp call.
type CreateAppResponse ¶
CreateAppResponse is the response from the CreateApp call.
type CreateMachine ¶
type CreateMachine struct { Config MachineConfig `json:"config"` LeaseTTL int `json:"lease_ttl"` LSVD bool `json:"lsvd"` // should be true? Name string `json:"name"` Region string `json:"region"` SkipLaunch *bool `json:"skip_launch,omitempty"` SkipServiceRegistration *bool `json:"skip_service_registration,omitempty"` }
type CreateVolume ¶
type CreateVolume struct { Compute *MachineGuest `json:"compute,omitempty"` Encrypted bool `json:"encrypted,omitempty"` FSType string `json:"fs_type,omitempty"` MachinesOnly bool `json:"machines_only,omitempty"` Name string `json:"name,omitempty"` Region string `json:"region,omitempty"` RequireUniqueZone bool `json:"require_unique_zone"` SizeGB int `json:"size_gb,omitempty"` SnapshotID string `json:"snapshot_id,omitempty"` SnapshotRetention int `json:"snapshot_retention"` SourceVolumeID string `json:"source_volume_id,omitempty"` }
func (CreateVolume) Fork ¶
func (cv CreateVolume) Fork(vol *Volume) CreateVolume
type Error ¶
type ExtendVolumeResponse ¶
type ListApp ¶
type ListApp struct { App MachineCount int `json:"machine_count"` // The number of machines associated with this app Network string `json:"network"` // The network this app is on }
ListApp is a Fly app with extra information that is only shown when you're listing apps with GetApps.
type Machine ¶
type Machine struct { ID string `json:"id"` Name string `json:"name"` State string `json:"state"` Region string `json:"region"` InstanceID string `json:"instance_id"` PrivateIP string `json:"private_ip"` Config MachineConfig `json:"config"` ImageRef ImageRef `json:"image_ref"` CreatedAt time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Events []MachineEvent `json:"events"` Checks []CheckStatus `json:"checks"` }
type MachineCheck ¶
type MachineCheck struct { Type string `json:"type"` Interval time.Duration `json:"interval"` Timeout time.Duration `json:"timeout"` GracePeriod time.Duration `json:"grace_period"` Path string `json:"path"` TLSServerName *string `json:"tls_server_name,omitempty"` TLSSkipVerify *bool `json:"tls_skip_verify,omitempty"` Headers []MachineHTTPHeader `json:"headers,omitempty"` }
type MachineConfig ¶
type MachineConfig struct { Env map[string]string `json:"env"` Metadata map[string]string `json:"metadata"` Mounts []MachineMount `json:"mounts,omitempty"` Image string `json:"image"` Restart MachineRestart `json:"restart"` Guest MachineGuest `json:"guest"` StopConfig MachineStopConfig `json:"stop_config"` Processes []MachineProcess `json:"processes,omitempty"` }
type MachineEvent ¶
type MachineGuest ¶
type MachineGuest struct { CPUKind string `json:"cpu_kind"` // "shared" or "performance" CPUs int `json:"cpus"` MemoryMB int `json:"memory_mb"` GPUKind string `json:"gpu_kind,omitempty"` KernelArgs []string `json:"kernel_args,omitempty"` HostDedicationID string `json:"host_dedication_id,omitempty"` }
type MachineHTTPHeader ¶
type MachineMount ¶
type MachinePort ¶
type MachineProcess ¶
type MachineRestart ¶
type MachineRestart struct { MaxRetries int `json:"max_retries"` // only relevant when Policy is "on-fail" Policy MachineRestartPolicy `json:"policy"` }
type MachineRestartPolicy ¶
type MachineRestartPolicy string
const ( MachineRestartPolicyNo MachineRestartPolicy = "no" MachineRestartPolicyAlways MachineRestartPolicy = "always" MachineRestartPolicyOnFailure MachineRestartPolicy = "on-failure" )
type MachineService ¶
type MachineService struct { Protocol string `json:"protocol"` InternalPort int `json:"internal_port"` ForceInstanceDescription *string `json:"force_instance_description,omitempty"` ForceInstanceKey *string `json:"force_instance_key,omitempty"` Ports []MachinePort `json:"ports"` Checks []MachineCheck `json:"checks"` MinMachinesRunning int `json:"min_machines_running"` Concurrency MachineServiceConcurrency `json:"concurrency"` }
type MachineStopConfig ¶
type MilliTime ¶
MilliTime is a time.Time that can be marshalled and unmarshalled from milliseconds since the Unix epoch.
func (MilliTime) MarshalJSON ¶
func (*MilliTime) UnmarshalJSON ¶
type Org ¶
Org is a Fly organization. An organization is a collection of apps and users that are allowed to manage that collection.
type SingleApp ¶
type SingleApp struct { App Organization Org `json:"organization"` // The organization this app belongs to Status string `json:"status"` // The current status of the app }
SingleApp is a Fly app with extra information that is only shown when you're getting a single app with GetApp.
type Volume ¶
type Volume struct { ID string `json:"id"` Name string `json:"name"` State string `json:"state"` SizeGB int `json:"size_gb"` Region string `json:"region"` Zone string `json:"zone"` Encrypted bool `json:"encrypted"` AttachedAllocID string `json:"attached_alloc_id"` AttachedMachineID string `json:"attached_machine_id"` CreatedAt time.Time `json:"created_at"` Blocks int `json:"blocks"` BlockSize int `json:"block_size"` BlocksAvail int `json:"blocks_avail"` BlocksFree int `json:"blocks_free"` FSType string `json:"fs_type"` SnapshotRetention int `json:"snapshot_retention"` HostDedicationKey string `json:"host_dedication_key,omitempty"` }