ExDoppler.Secrets (ExDoppler v1.0.1)

View Source

Module for interacting with ExDoppler.Secret

๐Ÿ“– Resources

Summary

Functions

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

Same as delete_secret/2 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/2 but won't wrap a successful response in {:ok, response}

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

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

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

Same as update_secret/4 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(config, new_secret_name, value, opts \\ [])

Creates a new ExDoppler.Secret

๐Ÿท๏ธ Params

  • config - Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • 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> alias ExDoppler.Config
iex> alias ExDoppler.Secrets
iex> _ = Secrets.delete_secret!(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL")
iex> {:ok, _secret} = Secrets.create_secret(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL", "example.com")
iex> :ok = Secrets.delete_secret!(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL")

๐Ÿ“– Resources

create_secret!(config, new_secret_name, value, opts \\ [])

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

delete_secret(config, secret_name)

Deletes a ExDoppler.Secret

๐Ÿท๏ธ Params

  • config - Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • secret_name - Name of secret to delete

โคต๏ธ Returns

โœ… On Success

  {:ok, {:success, true}}

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

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

๐Ÿ“– Resources

delete_secret!(config, secret_name)

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

download(config, opts \\ [])

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

๐Ÿท๏ธ Params

  • config - Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • 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> alias ExDoppler.Config
iex> alias ExDoppler.Secrets
iex> {:ok, _formatted_body} = Secrets.download(%Config{name: "dev_personal", project: "example-project"}, format: :env, name_transformer: "lower-snake")

๐Ÿ“– Resources

download!(config, opts \\ [])

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

get_secret(config, secret_name)

Retrieves a ExDoppler.Secret

๐Ÿท๏ธ Params

  • config - Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • secret_name - Name of the secret to get (e.g "API_KEY")

โคต๏ธ Returns

โœ… On Success

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

โŒ On Failure

  {:error, err}

๐Ÿ’ป Examples

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

๐Ÿ“– Resources

get_secret!(config, secret_name)

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

list_secret_names(config, opts \\ [])

Lists the names of ExDoppler.Secret

๐Ÿท๏ธ Params

  • config - Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • 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> alias ExDoppler.Config
iex> alias ExDoppler.Secrets
iex> {:ok, _names} = Secrets.list_secret_names(%Config{name: "dev_personal", project: "example-project"})

๐Ÿ“– Resources

list_secret_names!(config, opts \\ [])

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

list_secrets(config, opts \\ [])

Lists ExDoppler.Secret

๐Ÿท๏ธ Params

  • config: Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • 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> alias ExDoppler.Configs
iex> alias ExDoppler.Projects
iex> alias ExDoppler.Secrets
iex> [project | _] = Projects.list_projects!()
iex> [config | _] = Configs.list_configs!(project)
iex> {:ok, _secrets} = Secrets.list_secrets(config)

๐Ÿ“– Resources

list_secrets!(config, opts \\ [])

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

update_secret(config, secret_name, value, opts \\ [])

Updates a ExDoppler.Secret

๐Ÿท๏ธ Params

  • config - Config to get secrets from (e.g %Config{name: "dev_personal", project: "example-project" ...})
  • 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> alias ExDoppler.Config
iex> alias ExDoppler.Secrets
iex> _ = Secrets.delete_secret!(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL")
iex> {:ok, _secret} = Secrets.create_secret(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL", "example.com")
iex> {:ok, _secret} = Secrets.update_secret(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL", "example.com2", visibility: :unmasked)
iex> :ok = Secrets.delete_secret!(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL")

๐Ÿ“– Resources

update_secret!(config, secret_name, value, opts \\ [])

Same as update_secret/4 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> alias ExDoppler.Config
iex> alias ExDoppler.Secrets
iex> _ = Secrets.delete_secret!(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL")
iex> {:ok, _secret} = Secrets.create_secret(%Config{name: "dev_personal", project: "example-project"}, "DOC_URL", "example.com")
iex> {:ok, _secret} = Secrets.update_secret_note("example-project", "DOC_URL", "a new note")
iex> :ok = Secrets.delete_secret!(%Config{name: "dev_personal", project: "example-project"}, "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}