{-# 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.QuickSight.Types.AthenaParameters
-- 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.QuickSight.Types.AthenaParameters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Parameters for Amazon Athena.
--
-- /See:/ 'newAthenaParameters' smart constructor.
data AthenaParameters = AthenaParameters'
  { -- | Use the @RoleArn@ structure to override an account-wide role for a
    -- specific Athena data source. For example, say an account administrator
    -- has turned off all Athena access with an account-wide role. The
    -- administrator can then use @RoleArn@ to bypass the account-wide role and
    -- allow Athena access for the single Athena data source that is specified
    -- in the structure, even if the account-wide role forbidding Athena access
    -- is still active.
    AthenaParameters -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The workgroup that Amazon Athena uses.
    AthenaParameters -> Maybe Text
workGroup :: Prelude.Maybe Prelude.Text
  }
  deriving (AthenaParameters -> AthenaParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AthenaParameters -> AthenaParameters -> Bool
$c/= :: AthenaParameters -> AthenaParameters -> Bool
== :: AthenaParameters -> AthenaParameters -> Bool
$c== :: AthenaParameters -> AthenaParameters -> Bool
Prelude.Eq, ReadPrec [AthenaParameters]
ReadPrec AthenaParameters
Int -> ReadS AthenaParameters
ReadS [AthenaParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AthenaParameters]
$creadListPrec :: ReadPrec [AthenaParameters]
readPrec :: ReadPrec AthenaParameters
$creadPrec :: ReadPrec AthenaParameters
readList :: ReadS [AthenaParameters]
$creadList :: ReadS [AthenaParameters]
readsPrec :: Int -> ReadS AthenaParameters
$creadsPrec :: Int -> ReadS AthenaParameters
Prelude.Read, Int -> AthenaParameters -> ShowS
[AthenaParameters] -> ShowS
AthenaParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AthenaParameters] -> ShowS
$cshowList :: [AthenaParameters] -> ShowS
show :: AthenaParameters -> String
$cshow :: AthenaParameters -> String
showsPrec :: Int -> AthenaParameters -> ShowS
$cshowsPrec :: Int -> AthenaParameters -> ShowS
Prelude.Show, forall x. Rep AthenaParameters x -> AthenaParameters
forall x. AthenaParameters -> Rep AthenaParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AthenaParameters x -> AthenaParameters
$cfrom :: forall x. AthenaParameters -> Rep AthenaParameters x
Prelude.Generic)

-- |
-- Create a value of 'AthenaParameters' 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:
--
-- 'roleArn', 'athenaParameters_roleArn' - Use the @RoleArn@ structure to override an account-wide role for a
-- specific Athena data source. For example, say an account administrator
-- has turned off all Athena access with an account-wide role. The
-- administrator can then use @RoleArn@ to bypass the account-wide role and
-- allow Athena access for the single Athena data source that is specified
-- in the structure, even if the account-wide role forbidding Athena access
-- is still active.
--
-- 'workGroup', 'athenaParameters_workGroup' - The workgroup that Amazon Athena uses.
newAthenaParameters ::
  AthenaParameters
newAthenaParameters :: AthenaParameters
newAthenaParameters =
  AthenaParameters'
    { $sel:roleArn:AthenaParameters' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:workGroup:AthenaParameters' :: Maybe Text
workGroup = forall a. Maybe a
Prelude.Nothing
    }

-- | Use the @RoleArn@ structure to override an account-wide role for a
-- specific Athena data source. For example, say an account administrator
-- has turned off all Athena access with an account-wide role. The
-- administrator can then use @RoleArn@ to bypass the account-wide role and
-- allow Athena access for the single Athena data source that is specified
-- in the structure, even if the account-wide role forbidding Athena access
-- is still active.
athenaParameters_roleArn :: Lens.Lens' AthenaParameters (Prelude.Maybe Prelude.Text)
athenaParameters_roleArn :: Lens' AthenaParameters (Maybe Text)
athenaParameters_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaParameters' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:AthenaParameters' :: AthenaParameters -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: AthenaParameters
s@AthenaParameters' {} Maybe Text
a -> AthenaParameters
s {$sel:roleArn:AthenaParameters' :: Maybe Text
roleArn = Maybe Text
a} :: AthenaParameters)

-- | The workgroup that Amazon Athena uses.
athenaParameters_workGroup :: Lens.Lens' AthenaParameters (Prelude.Maybe Prelude.Text)
athenaParameters_workGroup :: Lens' AthenaParameters (Maybe Text)
athenaParameters_workGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AthenaParameters' {Maybe Text
workGroup :: Maybe Text
$sel:workGroup:AthenaParameters' :: AthenaParameters -> Maybe Text
workGroup} -> Maybe Text
workGroup) (\s :: AthenaParameters
s@AthenaParameters' {} Maybe Text
a -> AthenaParameters
s {$sel:workGroup:AthenaParameters' :: Maybe Text
workGroup = Maybe Text
a} :: AthenaParameters)

instance Data.FromJSON AthenaParameters where
  parseJSON :: Value -> Parser AthenaParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AthenaParameters"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AthenaParameters
AthenaParameters'
            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
"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
"WorkGroup")
      )

instance Prelude.Hashable AthenaParameters where
  hashWithSalt :: Int -> AthenaParameters -> Int
hashWithSalt Int
_salt AthenaParameters' {Maybe Text
workGroup :: Maybe Text
roleArn :: Maybe Text
$sel:workGroup:AthenaParameters' :: AthenaParameters -> Maybe Text
$sel:roleArn:AthenaParameters' :: AthenaParameters -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workGroup

instance Prelude.NFData AthenaParameters where
  rnf :: AthenaParameters -> ()
rnf AthenaParameters' {Maybe Text
workGroup :: Maybe Text
roleArn :: Maybe Text
$sel:workGroup:AthenaParameters' :: AthenaParameters -> Maybe Text
$sel:roleArn:AthenaParameters' :: AthenaParameters -> Maybe Text
..} =
    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
workGroup

instance Data.ToJSON AthenaParameters where
  toJSON :: AthenaParameters -> Value
toJSON AthenaParameters' {Maybe Text
workGroup :: Maybe Text
roleArn :: Maybe Text
$sel:workGroup:AthenaParameters' :: AthenaParameters -> Maybe Text
$sel:roleArn:AthenaParameters' :: AthenaParameters -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"WorkGroup" 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
workGroup
          ]
      )