{- |

This library uses the AWS Command Line Interface. By default, this is
expected to be found as an executable called "aws" on the binary PATH.
This can be customized using 'setAwsCli'.

-}
module AWS.Secrets.Config
  ( SecretsConfig,
    secretsConfig,

    -- ** Region
    AwsRegion (..),
    getAwsRegion,
    getAwsRegionText,

    -- ** AWS command-line tool
    getAwsCli,
    setAwsCli,
    AwsCli (..),
    getAwsCliFilePath,
  )
where

import Data.Text (Text)
import System.IO (FilePath)

data SecretsConfig = SecretConfig
  { SecretsConfig -> AwsCli
secretsConfigAwsCli :: AwsCli,
    SecretsConfig -> AwsRegion
secretsConfigAwsRegion :: AwsRegion
  }

newtype AwsCli = AwsCli FilePath

newtype AwsRegion = AwsRegion Text

defaultAwsCli :: AwsCli
defaultAwsCli :: AwsCli
defaultAwsCli = FilePath -> AwsCli
AwsCli FilePath
"aws"

secretsConfig :: AwsRegion -> SecretsConfig
secretsConfig :: AwsRegion -> SecretsConfig
secretsConfig AwsRegion
secretsConfigAwsRegion =
  SecretConfig {secretsConfigAwsCli :: AwsCli
secretsConfigAwsCli = AwsCli
defaultAwsCli, AwsRegion
secretsConfigAwsRegion :: AwsRegion
secretsConfigAwsRegion :: AwsRegion
secretsConfigAwsRegion}

setAwsCli :: AwsCli -> SecretsConfig -> SecretsConfig
setAwsCli :: AwsCli -> SecretsConfig -> SecretsConfig
setAwsCli AwsCli
secretsConfigAwsCli SecretsConfig
config = SecretsConfig
config {AwsCli
secretsConfigAwsCli :: AwsCli
secretsConfigAwsCli :: AwsCli
secretsConfigAwsCli}

getAwsCli :: SecretsConfig -> AwsCli
getAwsCli :: SecretsConfig -> AwsCli
getAwsCli = SecretsConfig -> AwsCli
secretsConfigAwsCli

getAwsRegion :: SecretsConfig -> AwsRegion
getAwsRegion :: SecretsConfig -> AwsRegion
getAwsRegion = SecretsConfig -> AwsRegion
secretsConfigAwsRegion

getAwsCliFilePath :: AwsCli -> FilePath
getAwsCliFilePath :: AwsCli -> FilePath
getAwsCliFilePath (AwsCli FilePath
x) = FilePath
x

getAwsRegionText :: AwsRegion -> Text
getAwsRegionText :: AwsRegion -> Text
getAwsRegionText (AwsRegion Text
x) = Text
x