ExDoppler (ExDoppler v1.0.1)

View Source

Convenience functions for interacting with Doppler

๐Ÿ“– Resources

Summary

Functions

Same as create_secret/5 but won't wrap a successful response in {:ok, response}

Same as delete_secret/3 but won't wrap a successful response in {:ok, response}

Retrieves multiple ExDoppler.Secret and responds in a format ready to put into a file

Same as download_secrets/2 but won't wrap a successful response in {:ok, response}

Same as get_secret/3 but won't wrap a successful response in {:ok, response}

Same as get_secret_raw/3 but won't wrap a successful response in {:ok, response}

Same as list_secret_names/3 but won't wrap a successful response in {:ok, response}

Same as list_secrets/3 but won't wrap a successful response in {:ok, response}

Same as update_secret/5 but won't wrap a successful response in {:ok, response}

Same as update_secret_note/3 but won't wrap a successful response in {:ok, response}

Functions

create_secret(project_name, config_name, new_secret_name, value, opts \\ [])

Creates a new ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • new_secret_name - Name of this new secret
  • value - Value of this new secret
  • opts: Optional modifications
    • visibility - how the secret should appear - :masked, :unmasked, or :restricted. Default: :masked

โคต๏ธ Returns

โœ… On Success

  {:ok, %ExDoppler.Secret{...}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> _ = ExDoppler.delete_secret!("example-project", "dev_personal", "DOC_URL")
iex> {:ok, _secret} = ExDoppler.create_secret("example-project", "dev_personal", "DOC_URL", "example.com")
iex> {:ok, {:success, true}} = ExDoppler.delete_secret("example-project", "dev_personal", "DOC_URL")

๐Ÿ“– Resources

create_secret!(project_name, config_name, new_secret_name, value, opts \\ [])

Same as create_secret/5 but won't wrap a successful response in {:ok, response}

delete_secret(project_name, config_name, secret_name)

Deletes a ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • secret_name - Name of secret to delete

โคต๏ธ Returns

โœ… On Success

  {:ok, {:success, true}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> _ = ExDoppler.delete_secret!("example-project", "dev_personal", "DOC_URL")
iex> {:ok, _secret} = ExDoppler.create_secret("example-project", "dev_personal", "DOC_URL", "example.com")
iex> {:ok, {:success, true}} = ExDoppler.delete_secret("example-project", "dev_personal", "DOC_URL")

๐Ÿ“– Resources

delete_secret!(project_name, config_name, secret_name)

Same as delete_secret/3 but won't wrap a successful response in {:ok, response}

download_secrets(project_name, config_name, opts \\ [])

Retrieves multiple ExDoppler.Secret and responds in a format ready to put into a file

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • opts: Optional modifications to the download call
    • include_dynamic_secrets - whether to include dynamic secrets. Default: false
    • dynamic_secrets_ttl_sec - The number of seconds until dynamic leases expire. Must be used with include_dynamic_secrets. Defaults to 1800 (30 minutes). Default: nil
    • format - File format to use. (e.g "dotnet-json", "env", "yaml", "docker", "env-no-quotes") Default: json
    • name_transformer - Transform secret names to a different case (e.g "camel", "upper-camel", "lower-snake", "tf-var", "dotnet", "dotnet-env", "lower-kebab"). Default: nil
    • secrets - Comma-delimited list of secrets to include in the download. Defaults to all secrets if left unspecified.

โคต๏ธ Returns

โœ… On Success

  {:ok, requested_body}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> {:ok, _formatted_body} = ExDoppler.download_secrets("example-project", "dev_personal", format: :env, name_transformer: "lower-snake")

๐Ÿ“– Resources

download_secrets!(project_name, config_name, opts \\ [])

Same as download_secrets/2 but won't wrap a successful response in {:ok, response}

get_secret(project_name, config_name, secret_name)

Retrieves a ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • secret_name - Name of the secret to get (e.g "API_KEY")

โคต๏ธ Returns

โœ… On Success

  {:ok, %ExDoppler.Secret{...}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> {:ok, _secret} = ExDoppler.get_secret("example-project", "dev_personal", "DB_URL")

๐Ÿ“– Resources

get_secret!(project_name, config_name, secret_name)

Same as get_secret/3 but won't wrap a successful response in {:ok, response}

get_secret_raw(project_name, config_name, secret_name)

Retrieves the raw value of a ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • secret_name - Name of the secret to get (e.g "API_KEY")

โคต๏ธ Returns

โœ… On Success

  {:ok, %ExDoppler.Secret{...}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> {:ok, _raw_value} = ExDoppler.get_secret_raw("example-project", "dev_personal", "DB_URL")

๐Ÿ“– Resources

get_secret_raw!(project_name, config_name, secret_name)

Same as get_secret_raw/3 but won't wrap a successful response in {:ok, response}

list_secret_names(project_name, config_name, opts \\ [])

Lists the names of ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • opts: Optional modifications to the list call
    • include_dynamic_secrets - whether to include dynamic secrets. Default: false
    • include_managed_secrets - whether to include managed secrets. Default: true

โคต๏ธ Returns

โœ… On Success

  {:ok, names}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> {:ok, _names} = ExDoppler.list_secret_names("example-project", "dev_personal")

๐Ÿ“– Resources

list_secret_names!(project_name, config_name, opts \\ [])

Same as list_secret_names/3 but won't wrap a successful response in {:ok, response}

list_secrets(project_name, config_name, opts \\ [])

Lists ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • opts: Optional modifications to the list call
    • include_dynamic_secrets - whether to include dynamic secrets. Default: false
    • include_managed_secrets - whether to include dynamic secrets. Default: true
    • secrets - A comma-separated list of secrets to include in the response. Default: nil

โคต๏ธ Returns

โœ… On Success

  {:ok, [%ExDoppler.Secret{...} ...]}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> {:ok, _secrets} = ExDoppler.list_secrets("example-project", "dev_personal")

๐Ÿ“– Resources

list_secrets!(project_name, config_name, opts \\ [])

Same as list_secrets/3 but won't wrap a successful response in {:ok, response}

update_secret(project_name, config_name, secret_name, value, opts \\ [])

Updates a ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name: Name of the project (e.g "example-project")
  • config_name: Name of the config (e.g "dev_personal")
  • secret_name - Name of this secret
  • value - Value of this secret
  • opts: Optional modifications
    • visibility - how the secret should appear - :masked, :unmasked, or :restricted. Default: :masked
    • should_promote - Defaults to false. Can only be set to true if the config being updated is a branch config. If set to true, the provided secret will be set in both the branch config as well as the root config in that environment.
    • should_delete - Defaults to false. If set to true, will delete the secret matching the name field.
    • should_converge - Defaults to false. Can only be set to true if the config being updated is a branch config and there is a secret with the same name in the root config. In this case, the branch secret will inherit the value and visibility type from the root secret.

โคต๏ธ Returns

โœ… On Success

  {:ok, %ExDoppler.Secret{...}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> _ = ExDoppler.delete_secret!("example-project", "dev_personal", "DOC_URL")
iex> {:ok, _secret} = ExDoppler.create_secret("example-project", "dev_personal", "DOC_URL", "example.com")
iex> {:ok, _secret} = ExDoppler.update_secret("example-project", "dev_personal", "DOC_URL", "example.com2", visibility: :unmasked)
iex> {:ok, {:success, true}} = ExDoppler.delete_secret("example-project", "dev_personal", "DOC_URL")

๐Ÿ“– Resources

update_secret!(project_name, config_name, secret_name, value, opts \\ [])

Same as update_secret/5 but won't wrap a successful response in {:ok, response}

update_secret_note(project_name, secret_name, note)

Updates the note field on a ExDoppler.Secret

๐Ÿท๏ธ Params

  • project_name - Name of the associated project (e.g "example-project")
  • secret_name - Name of this secret
  • note - Attached Note

โคต๏ธ Returns

โœ… On Success

  {:ok, %{note: note secret: %ExDoppler.Secret{...}}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

iex> _ = ExDoppler.delete_secret!("example-project", "dev_personal", "DOC_URL")
iex> {:ok, _secret} = ExDoppler.create_secret("example-project", "dev_personal", "DOC_URL", "example.com")
iex> {:ok, _secret} = ExDoppler.update_secret_note("example-project", "DOC_URL", "a new note")
iex> {:ok, {:success, true}} = ExDoppler.delete_secret("example-project", "dev_personal", "DOC_URL")

๐Ÿ“– Resources

update_secret_note!(project_name, secret_name, note)

Same as update_secret_note/3 but won't wrap a successful response in {:ok, response}