{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LookoutMetrics.Types.AthenaSourceConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LookoutMetrics.Types.AthenaSourceConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutMetrics.Types.BackTestConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Details about an Amazon Athena datasource.
--
-- /See:/ 'newAthenaSourceConfig' smart constructor.
data AthenaSourceConfig = AthenaSourceConfig'
  { -- | Settings for backtest mode.
    AthenaSourceConfig -> Maybe BackTestConfiguration
backTestConfiguration :: Prelude.Maybe BackTestConfiguration,
    -- | The database\'s data catalog.
    AthenaSourceConfig -> Maybe Text
dataCatalog :: Prelude.Maybe Prelude.Text,
    -- | The database\'s name.
    AthenaSourceConfig -> Maybe Text
databaseName :: Prelude.Maybe Prelude.Text,
    -- | An IAM role that gives Amazon Lookout for Metrics permission to access
    -- the data.
    AthenaSourceConfig -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The database\'s results path.
    AthenaSourceConfig -> Maybe Text
s3ResultsPath :: Prelude.Maybe Prelude.Text,
    -- | The database\'s table name.
    AthenaSourceConfig -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text,
    -- | The database\'s work group name.
    AthenaSourceConfig -> Maybe Text
workGroupName :: Prelude.Maybe Prelude.Text
  }
  deriving (AthenaSourceConfig -> AthenaSourceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AthenaSourceConfig -> AthenaSourceConfig -> Bool
$c/= :: AthenaSourceConfig -> AthenaSourceConfig -> Bool
== :: AthenaSourceConfig -> AthenaSourceConfig -> Bool
$c== :: AthenaSourceConfig -> AthenaSourceConfig -> Bool
Prelude.Eq, ReadPrec [AthenaSourceConfig]
ReadPrec AthenaSourceConfig
Int -> ReadS AthenaSourceConfig
ReadS [AthenaSourceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AthenaSourceConfig]
$creadListPrec :: ReadPrec [AthenaSourceConfig]
readPrec :: ReadPrec AthenaSourceConfig
$creadPrec :: ReadPrec AthenaSourceConfig
readList :: ReadS [AthenaSourceConfig]
$creadList :: ReadS [AthenaSourceConfig]
readsPrec :: Int -> ReadS AthenaSourceConfig
$creadsPrec :: Int -> ReadS AthenaSourceConfig
Prelude.Read, Int -> AthenaSourceConfig -> ShowS
[AthenaSourceConfig] -> ShowS
AthenaSourceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AthenaSourceConfig] -> ShowS
$cshowList :: [AthenaSourceConfig] -> ShowS
show :: AthenaSourceConfig -> String
$cshow :: AthenaSourceConfig -> String
showsPrec :: Int -> AthenaSourceConfig -> ShowS
$cshowsPrec :: Int -> AthenaSourceConfig -> ShowS
Prelude.Show, forall x. Rep AthenaSourceConfig x -> AthenaSourceConfig
forall x. AthenaSourceConfig -> Rep AthenaSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AthenaSourceConfig x -> AthenaSourceConfig
$cfrom :: forall x. AthenaSourceConfig -> Rep AthenaSourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'AthenaSourceConfig' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'backTestConfiguration', 'athenaSourceConfig_backTestConfiguration' - Settings for backtest mode.
--
-- 'dataCatalog', 'athenaSourceConfig_dataCatalog' - The database\'s data catalog.
--
-- 'databaseName', 'athenaSourceConfig_databaseName' - The database\'s name.
--
-- 'roleArn', 'athenaSourceConfig_roleArn' - An IAM role that gives Amazon Lookout for Metrics permission to access
-- the data.
--
-- 's3ResultsPath', 'athenaSourceConfig_s3ResultsPath' - The database\'s results path.
--
-- 'tableName', 'athenaSourceConfig_tableName' - The database\'s table name.
--
-- 'workGroupName', 'athenaSourceConfig_workGroupName' - The database\'s work group name.
newAthenaSourceConfig ::
  AthenaSourceConfig
newAthenaSourceConfig :: AthenaSourceConfig
newAthenaSourceConfig =
  AthenaSourceConfig'
    { $sel:backTestConfiguration:AthenaSourceConfig' :: Maybe BackTestConfiguration
backTestConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dataCatalog:AthenaSourceConfig' :: Maybe Text
dataCatalog = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:AthenaSourceConfig' :: Maybe Text
databaseName = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:AthenaSourceConfig' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:s3ResultsPath:AthenaSourceConfig' :: Maybe Text
s3ResultsPath = forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:AthenaSourceConfig' :: Maybe Text
tableName = forall a. Maybe a
Prelude.Nothing,
      $sel:workGroupName:AthenaSourceConfig' :: Maybe Text
workGroupName = forall a. Maybe a
Prelude.Nothing
    }

-- | Settings for backtest mode.
athenaSourceConfig_backTestConfiguration :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe BackTestConfiguration)
athenaSourceConfig_backTestConfiguration :: Lens' AthenaSourceConfig (Maybe BackTestConfiguration)
athenaSourceConfig_backTestConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe BackTestConfiguration
backTestConfiguration :: Maybe BackTestConfiguration
$sel:backTestConfiguration:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe BackTestConfiguration
backTestConfiguration} -> Maybe BackTestConfiguration
backTestConfiguration) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe BackTestConfiguration
a -> AthenaSourceConfig
s {$sel:backTestConfiguration:AthenaSourceConfig' :: Maybe BackTestConfiguration
backTestConfiguration = Maybe BackTestConfiguration
a} :: AthenaSourceConfig)

-- | The database\'s data catalog.
athenaSourceConfig_dataCatalog :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe Prelude.Text)
athenaSourceConfig_dataCatalog :: Lens' AthenaSourceConfig (Maybe Text)
athenaSourceConfig_dataCatalog = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe Text
dataCatalog :: Maybe Text
$sel:dataCatalog:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
dataCatalog} -> Maybe Text
dataCatalog) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe Text
a -> AthenaSourceConfig
s {$sel:dataCatalog:AthenaSourceConfig' :: Maybe Text
dataCatalog = Maybe Text
a} :: AthenaSourceConfig)

-- | The database\'s name.
athenaSourceConfig_databaseName :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe Prelude.Text)
athenaSourceConfig_databaseName :: Lens' AthenaSourceConfig (Maybe Text)
athenaSourceConfig_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe Text
databaseName :: Maybe Text
$sel:databaseName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
databaseName} -> Maybe Text
databaseName) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe Text
a -> AthenaSourceConfig
s {$sel:databaseName:AthenaSourceConfig' :: Maybe Text
databaseName = Maybe Text
a} :: AthenaSourceConfig)

-- | An IAM role that gives Amazon Lookout for Metrics permission to access
-- the data.
athenaSourceConfig_roleArn :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe Prelude.Text)
athenaSourceConfig_roleArn :: Lens' AthenaSourceConfig (Maybe Text)
athenaSourceConfig_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe Text
a -> AthenaSourceConfig
s {$sel:roleArn:AthenaSourceConfig' :: Maybe Text
roleArn = Maybe Text
a} :: AthenaSourceConfig)

-- | The database\'s results path.
athenaSourceConfig_s3ResultsPath :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe Prelude.Text)
athenaSourceConfig_s3ResultsPath :: Lens' AthenaSourceConfig (Maybe Text)
athenaSourceConfig_s3ResultsPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe Text
s3ResultsPath :: Maybe Text
$sel:s3ResultsPath:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
s3ResultsPath} -> Maybe Text
s3ResultsPath) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe Text
a -> AthenaSourceConfig
s {$sel:s3ResultsPath:AthenaSourceConfig' :: Maybe Text
s3ResultsPath = Maybe Text
a} :: AthenaSourceConfig)

-- | The database\'s table name.
athenaSourceConfig_tableName :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe Prelude.Text)
athenaSourceConfig_tableName :: Lens' AthenaSourceConfig (Maybe Text)
athenaSourceConfig_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe Text
tableName :: Maybe Text
$sel:tableName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe Text
a -> AthenaSourceConfig
s {$sel:tableName:AthenaSourceConfig' :: Maybe Text
tableName = Maybe Text
a} :: AthenaSourceConfig)

-- | The database\'s work group name.
athenaSourceConfig_workGroupName :: Lens.Lens' AthenaSourceConfig (Prelude.Maybe Prelude.Text)
athenaSourceConfig_workGroupName :: Lens' AthenaSourceConfig (Maybe Text)
athenaSourceConfig_workGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaSourceConfig' {Maybe Text
workGroupName :: Maybe Text
$sel:workGroupName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
workGroupName} -> Maybe Text
workGroupName) (\s :: AthenaSourceConfig
s@AthenaSourceConfig' {} Maybe Text
a -> AthenaSourceConfig
s {$sel:workGroupName:AthenaSourceConfig' :: Maybe Text
workGroupName = Maybe Text
a} :: AthenaSourceConfig)

instance Data.FromJSON AthenaSourceConfig where
  parseJSON :: Value -> Parser AthenaSourceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AthenaSourceConfig"
      ( \Object
x ->
          Maybe BackTestConfiguration
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AthenaSourceConfig
AthenaSourceConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BackTestConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DataCatalog")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DatabaseName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RoleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"S3ResultsPath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TableName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"WorkGroupName")
      )

instance Prelude.Hashable AthenaSourceConfig where
  hashWithSalt :: Int -> AthenaSourceConfig -> Int
hashWithSalt Int
_salt AthenaSourceConfig' {Maybe Text
Maybe BackTestConfiguration
workGroupName :: Maybe Text
tableName :: Maybe Text
s3ResultsPath :: Maybe Text
roleArn :: Maybe Text
databaseName :: Maybe Text
dataCatalog :: Maybe Text
backTestConfiguration :: Maybe BackTestConfiguration
$sel:workGroupName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:tableName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:s3ResultsPath:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:roleArn:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:databaseName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:dataCatalog:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:backTestConfiguration:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe BackTestConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackTestConfiguration
backTestConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataCatalog
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3ResultsPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workGroupName

instance Prelude.NFData AthenaSourceConfig where
  rnf :: AthenaSourceConfig -> ()
rnf AthenaSourceConfig' {Maybe Text
Maybe BackTestConfiguration
workGroupName :: Maybe Text
tableName :: Maybe Text
s3ResultsPath :: Maybe Text
roleArn :: Maybe Text
databaseName :: Maybe Text
dataCatalog :: Maybe Text
backTestConfiguration :: Maybe BackTestConfiguration
$sel:workGroupName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:tableName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:s3ResultsPath:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:roleArn:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:databaseName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:dataCatalog:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:backTestConfiguration:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe BackTestConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BackTestConfiguration
backTestConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataCatalog
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3ResultsPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
workGroupName

instance Data.ToJSON AthenaSourceConfig where
  toJSON :: AthenaSourceConfig -> Value
toJSON AthenaSourceConfig' {Maybe Text
Maybe BackTestConfiguration
workGroupName :: Maybe Text
tableName :: Maybe Text
s3ResultsPath :: Maybe Text
roleArn :: Maybe Text
databaseName :: Maybe Text
dataCatalog :: Maybe Text
backTestConfiguration :: Maybe BackTestConfiguration
$sel:workGroupName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:tableName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:s3ResultsPath:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:roleArn:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:databaseName:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:dataCatalog:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe Text
$sel:backTestConfiguration:AthenaSourceConfig' :: AthenaSourceConfig -> Maybe BackTestConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BackTestConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BackTestConfiguration
backTestConfiguration,
            (Key
"DataCatalog" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataCatalog,
            (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
databaseName,
            (Key
"RoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn,
            (Key
"S3ResultsPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
s3ResultsPath,
            (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
tableName,
            (Key
"WorkGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
workGroupName
          ]
      )