FlyMachineClient.Machines (fly_machine_client v0.1.0)

Module for managing machines on Fly.io.

Summary

Functions

Creates a new machine in a Fly.io app.

Gets details of a specific machine.

Lists all machines for a given app.

Updates an existing machine in a Fly.io app.

Functions

create_machine(params, opts \\ [])

@spec create_machine(map(), FlyMachineClient.options()) :: FlyMachineClient.response()

Creates a new machine in a Fly.io app.

Parameters

  • params: A map containing the machine creation parameters:
    • app_name: The name of the app to create the machine in (required)
    • name: The name for the machine (optional)
    • region: The region to deploy the machine to (optional)
    • config: Machine configuration map (required)
    • image: Docker image to use (required)
    • env: Environment variables map (optional)
    • services: List of services (optional)
    • metadata: Metadata map (optional)
  • opts: Optional list of options

Returns

on success where machine is the created machine data {:error, error} on failure

destroy_machine(app_name, machine_id, opts \\ [])

@spec destroy_machine(String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Destroys (deletes) a machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to destroy.
  • opts: Optional. Additional options for the request.

Returns

on success. {:error, error()} on failure.

get_machine(app_name, machine_id, opts \\ [])

@spec get_machine(String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Gets details of a specific machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to retrieve.
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the machine data. {:error, error()} on failure.

list_machines(app_name, opts \\ [])

@spec list_machines(String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Lists all machines for a given app.

Parameters

  • app_name: The name of the app to list machines for.
  • opts: Optional. Additional options for the request.

Returns

on success, where machines is a list of machine data. {:error, error()} on failure.

restart_machine(app_name, machine_id, opts \\ [])

@spec restart_machine(String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Restarts a machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to restart.
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the restarted machine data. {:error, error()} on failure.

signal_machine(app_name, machine_id, signal, opts \\ [])

@spec signal_machine(String.t(), String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Sends a signal to a machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to signal.
  • signal: The signal to send (e.g., "SIGINT", "SIGTERM").
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the updated machine data. {:error, error()} on failure.

start_machine(app_name, machine_id, opts \\ [])

@spec start_machine(String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Starts a stopped machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to start.
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the started machine data. {:error, error()} on failure.

stop_machine(app_name, machine_id, opts \\ [])

@spec stop_machine(String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Stops a running machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to stop.
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the stopped machine data. {:error, error()} on failure.

suspend_machine(app_name, machine_id, opts \\ [])

@spec suspend_machine(String.t(), String.t(), FlyMachineClient.options()) ::
  FlyMachineClient.response()

Suspends a running machine.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to suspend.
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the suspended machine data. {:error, error()} on failure.

update_machine(params, opts \\ [])

@spec update_machine(map(), FlyMachineClient.options()) :: FlyMachineClient.response()

Updates an existing machine in a Fly.io app.

Parameters

  • params: A map containing the machine update parameters:
    • app_name: The name of the app containing the machine (required)
    • machine_id: The ID of the machine to update (required)
    • name: New name for the machine (optional)
    • region: New region for the machine (optional)
    • config: Updated machine configuration map (optional)
    • image: New Docker image to use (optional)
    • env: Updated environment variables map (optional)
    • services: Updated list of services (optional)
    • metadata: Updated metadata map (optional)
  • opts: Optional list of options

Returns

on success where machine is the updated machine data {:error, error} on failure

wait_for_machine_state(app_name, machine_id, instance_id, state \\ "started", timeout \\ 60, opts \\ [])

@spec wait_for_machine_state(
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  integer(),
  FlyMachineClient.options()
) :: FlyMachineClient.response()

Waits for a machine to reach a specific state.

Parameters

  • app_name: The name of the app the machine belongs to.
  • machine_id: The ID of the machine to wait for.
  • instance_id: The ID of the instance to wait for.
  • state: The desired state to wait for.
  • timeout: The maximum time to wait (in seconds).
  • opts: Optional. Additional options for the request.

Returns

on success, where machine is the machine data after reaching the desired state. {:error, error()} on failure or timeout.