CitraClient (citra_client v0.3.0)
View SourceElixir client for the Citra Space API.
All API bindings are generated at compile time from the live OpenAPI spec
at https://dev.api.citra.space/openapi.json.
See CitraClient.Generated for details on the compile-time fetch, and the
per-tag modules (e.g. CitraClient.GroundStations, CitraClient.Telescopes,
CitraClient.Antennas, CitraClient.Satellites) for the operations.
Configuration
config :citra_client, :env, :dev # or :prod
config :citra_client, :api_token, "..."Or at runtime:
CitraClient.set_env(:prod)
CitraClient.set_token(System.get_env("CITRA_PAT"))Usage
iex> CitraClient.set_token(System.get_env("CITRA_PAT"))
iex> {:ok, stations} = CitraClient.GroundStations.get_ground_stations()
iex> Enum.map(stations, & &1.name)The S3 image upload flow (upload_image_to_s3/2) is hand-written because
the final PUT hits AWS directly, outside the API surface described by
the OpenAPI spec.
Summary
Functions
Returns the base URL for the current environment.
Gets the current API environment. Defaults to :dev.
Sets the API environment to :dev or :prod.
Stores the Personal Access Token used by all generated API calls.
Uploads an image to S3 using presigned upload parameters obtained from
CitraClient.Images.upload_initiate/1 (the generated binding for
POST /my/images). The generated call returns a struct with the
uploadUrl, fields, etc.; this helper handles the multipart form POST
that AWS requires.
Functions
@spec base_url() :: String.t()
Returns the base URL for the current environment.
@spec get_env() :: :dev | :prod
Gets the current API environment. Defaults to :dev.
@spec set_env(:dev | :prod) :: :ok
Sets the API environment to :dev or :prod.
@spec set_token(String.t()) :: :ok
Stores the Personal Access Token used by all generated API calls.
@spec upload_image_to_s3(String.t(), String.t()) :: :ok | {:error, %{body: any(), status: integer(), url: String.t()}}
Uploads an image to S3 using presigned upload parameters obtained from
CitraClient.Images.upload_initiate/1 (the generated binding for
POST /my/images). The generated call returns a struct with the
uploadUrl, fields, etc.; this helper handles the multipart form POST
that AWS requires.