ReqFly.Secrets (req_fly v1.0.0)
View SourceFunctions for interacting with Fly.io Secrets API.
The Secrets API provides operations for managing application secrets, including listing, creating, generating, and destroying secrets.
Examples
req = Req.new() |> ReqFly.attach(token: "fly_token")
# List all secrets for an app
{:ok, secrets} = ReqFly.Secrets.list(req, app_name: "my-app")
# Create a new secret
{:ok, secret} = ReqFly.Secrets.create(req,
app_name: "my-app",
label: "DATABASE_URL",
type: "env",
value: "postgres://..."
)
# Generate a random secret
{:ok, secret} = ReqFly.Secrets.generate(req,
app_name: "my-app",
label: "SECRET_KEY",
type: "env"
)
# Destroy a secret
{:ok, _} = ReqFly.Secrets.destroy(req,
app_name: "my-app",
label: "OLD_SECRET"
)
Summary
Functions
Creates a new secret for an app.
Destroys (deletes) a secret from an app.
Generates a random secret for an app.
Lists all secrets for an app.
Functions
@spec create( Req.Request.t(), keyword() ) :: {:ok, map()} | {:error, ReqFly.Error.t()}
Creates a new secret for an app.
Parameters
req- A Req.Request with ReqFly attachedopts- Options keyword list:app_name- Name of the app (required):label- Secret label/name (required):type- Secret type, typically "env" (required):value- Secret value (required)
Returns
{:ok, secret}- Created secret details{:error, %ReqFly.Error{}}- Error details
Examples
req = Req.new() |> ReqFly.attach(token: "fly_token")
{:ok, secret} = ReqFly.Secrets.create(req,
app_name: "my-app",
label: "DATABASE_URL",
type: "env",
value: "postgres://..."
)
@spec destroy( Req.Request.t(), keyword() ) :: {:ok, term()} | {:error, ReqFly.Error.t()}
Destroys (deletes) a secret from an app.
Parameters
req- A Req.Request with ReqFly attachedopts- Options keyword list:app_name- Name of the app (required):label- Secret label/name to destroy (required)
Returns
{:ok, response}- Deletion confirmation{:error, %ReqFly.Error{}}- Error details
Examples
req = Req.new() |> ReqFly.attach(token: "fly_token")
{:ok, _} = ReqFly.Secrets.destroy(req,
app_name: "my-app",
label: "OLD_SECRET"
)
@spec generate( Req.Request.t(), keyword() ) :: {:ok, map()} | {:error, ReqFly.Error.t()}
Generates a random secret for an app.
Parameters
req- A Req.Request with ReqFly attachedopts- Options keyword list:app_name- Name of the app (required):label- Secret label/name (required):type- Secret type, typically "env" (required)
Returns
{:ok, secret}- Generated secret details{:error, %ReqFly.Error{}}- Error details
Examples
req = Req.new() |> ReqFly.attach(token: "fly_token")
{:ok, secret} = ReqFly.Secrets.generate(req,
app_name: "my-app",
label: "SECRET_KEY",
type: "env"
)
@spec list( Req.Request.t(), keyword() ) :: {:ok, [map()]} | {:error, ReqFly.Error.t()}
Lists all secrets for an app.
Parameters
req- A Req.Request with ReqFly attachedopts- Options keyword list:app_name- Name of the app (required)
Returns
{:ok, secrets}- List of secret maps{:error, %ReqFly.Error{}}- Error details
Examples
req = Req.new() |> ReqFly.attach(token: "fly_token")
{:ok, secrets} = ReqFly.Secrets.list(req, app_name: "my-app")