GoodAnalytics.Connectors.Settings (GoodAnalytics v0.1.1)

Copy Markdown View Source

Connector setting keys and configuration helpers.

Provides per-workspace connector enablement and encrypted credential storage through the existing GoodAnalytics.Settings system.

Setting Key Conventions

Connector settings use a dotted key namespace:

connector.<type>.enabled     boolean, whether the connector is active
connector.<type>.credential.<name>  encrypted credential value
connector.<type>.config.<name>      non-sensitive connector config

Encryption

Credential settings are stored encrypted via Cloak.Ecto. The host app must configure a Cloak vault and set it in the GoodAnalytics config:

config :good_analytics, :cloak_vault, MyApp.Vault

Summary

Functions

Returns the setting key for a connector config value.

Returns true if the given connector type is enabled for the workspace.

Returns the setting key for a connector credential.

Disables a connector for a workspace.

Enables a connector for a workspace.

Returns a list of enabled connector types for a workspace.

Returns the setting key for connector enablement.

Retrieves a non-sensitive config value for a connector.

Retrieves and decrypts a credential for a connector.

Returns all credentials for a connector as a map of name => decrypted value.

Stores a non-sensitive config value for a connector.

Stores an encrypted credential for a connector.

Returns true if the given setting key is a sensitive credential key.

Functions

config_key(connector_type, name)

Returns the setting key for a connector config value.

connector_enabled?(workspace_id, connector_type)

Returns true if the given connector type is enabled for the workspace.

credential_key(connector_type, name)

Returns the setting key for a connector credential.

disable_connector(workspace_id, connector_type)

Disables a connector for a workspace.

enable_connector(workspace_id, connector_type)

Enables a connector for a workspace.

enabled_connectors(workspace_id, registered_types)

Returns a list of enabled connector types for a workspace.

enabled_key(connector_type)

Returns the setting key for connector enablement.

get_config(workspace_id, connector_type, config_name, default \\ nil)

Retrieves a non-sensitive config value for a connector.

get_credential(workspace_id, connector_type, credential_name)

Retrieves and decrypts a credential for a connector.

Returns nil if the credential is not set.

get_credentials(workspace_id, connector_type, credential_names)

Returns all credentials for a connector as a map of name => decrypted value.

put_config(workspace_id, connector_type, config_name, value)

Stores a non-sensitive config value for a connector.

put_credential(workspace_id, connector_type, credential_name, value)

Stores an encrypted credential for a connector.

The value is encrypted at rest using the configured Cloak vault. Raises if no vault is configured.

sensitive_key?(key)

Returns true if the given setting key is a sensitive credential key.