{-# 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.DataSourceCredentials
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.DataSourceCredentials where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.CredentialPair

-- | Data source credentials. This is a variant type structure. For this
-- structure to be valid, only one of the attributes can be non-null.
--
-- /See:/ 'newDataSourceCredentials' smart constructor.
data DataSourceCredentials = DataSourceCredentials'
  { -- | The Amazon Resource Name (ARN) of a data source that has the credential
    -- pair that you want to use. When @CopySourceArn@ is not null, the
    -- credential pair from the data source in the ARN is used as the
    -- credentials for the @DataSourceCredentials@ structure.
    DataSourceCredentials -> Maybe Text
copySourceArn :: Prelude.Maybe Prelude.Text,
    -- | Credential pair. For more information, see CredentialPair.
    DataSourceCredentials -> Maybe CredentialPair
credentialPair :: Prelude.Maybe CredentialPair
  }
  deriving (DataSourceCredentials -> DataSourceCredentials -> Bool
(DataSourceCredentials -> DataSourceCredentials -> Bool)
-> (DataSourceCredentials -> DataSourceCredentials -> Bool)
-> Eq DataSourceCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSourceCredentials -> DataSourceCredentials -> Bool
$c/= :: DataSourceCredentials -> DataSourceCredentials -> Bool
== :: DataSourceCredentials -> DataSourceCredentials -> Bool
$c== :: DataSourceCredentials -> DataSourceCredentials -> Bool
Prelude.Eq, Int -> DataSourceCredentials -> ShowS
[DataSourceCredentials] -> ShowS
DataSourceCredentials -> String
(Int -> DataSourceCredentials -> ShowS)
-> (DataSourceCredentials -> String)
-> ([DataSourceCredentials] -> ShowS)
-> Show DataSourceCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSourceCredentials] -> ShowS
$cshowList :: [DataSourceCredentials] -> ShowS
show :: DataSourceCredentials -> String
$cshow :: DataSourceCredentials -> String
showsPrec :: Int -> DataSourceCredentials -> ShowS
$cshowsPrec :: Int -> DataSourceCredentials -> ShowS
Prelude.Show, (forall x. DataSourceCredentials -> Rep DataSourceCredentials x)
-> (forall x. Rep DataSourceCredentials x -> DataSourceCredentials)
-> Generic DataSourceCredentials
forall x. Rep DataSourceCredentials x -> DataSourceCredentials
forall x. DataSourceCredentials -> Rep DataSourceCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataSourceCredentials x -> DataSourceCredentials
$cfrom :: forall x. DataSourceCredentials -> Rep DataSourceCredentials x
Prelude.Generic)

-- |
-- Create a value of 'DataSourceCredentials' 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:
--
-- 'copySourceArn', 'dataSourceCredentials_copySourceArn' - The Amazon Resource Name (ARN) of a data source that has the credential
-- pair that you want to use. When @CopySourceArn@ is not null, the
-- credential pair from the data source in the ARN is used as the
-- credentials for the @DataSourceCredentials@ structure.
--
-- 'credentialPair', 'dataSourceCredentials_credentialPair' - Credential pair. For more information, see CredentialPair.
newDataSourceCredentials ::
  DataSourceCredentials
newDataSourceCredentials :: DataSourceCredentials
newDataSourceCredentials =
  DataSourceCredentials' :: Maybe Text -> Maybe CredentialPair -> DataSourceCredentials
DataSourceCredentials'
    { $sel:copySourceArn:DataSourceCredentials' :: Maybe Text
copySourceArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:credentialPair:DataSourceCredentials' :: Maybe CredentialPair
credentialPair = Maybe CredentialPair
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of a data source that has the credential
-- pair that you want to use. When @CopySourceArn@ is not null, the
-- credential pair from the data source in the ARN is used as the
-- credentials for the @DataSourceCredentials@ structure.
dataSourceCredentials_copySourceArn :: Lens.Lens' DataSourceCredentials (Prelude.Maybe Prelude.Text)
dataSourceCredentials_copySourceArn :: (Maybe Text -> f (Maybe Text))
-> DataSourceCredentials -> f DataSourceCredentials
dataSourceCredentials_copySourceArn = (DataSourceCredentials -> Maybe Text)
-> (DataSourceCredentials -> Maybe Text -> DataSourceCredentials)
-> Lens
     DataSourceCredentials
     DataSourceCredentials
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceCredentials' {Maybe Text
copySourceArn :: Maybe Text
$sel:copySourceArn:DataSourceCredentials' :: DataSourceCredentials -> Maybe Text
copySourceArn} -> Maybe Text
copySourceArn) (\s :: DataSourceCredentials
s@DataSourceCredentials' {} Maybe Text
a -> DataSourceCredentials
s {$sel:copySourceArn:DataSourceCredentials' :: Maybe Text
copySourceArn = Maybe Text
a} :: DataSourceCredentials)

-- | Credential pair. For more information, see CredentialPair.
dataSourceCredentials_credentialPair :: Lens.Lens' DataSourceCredentials (Prelude.Maybe CredentialPair)
dataSourceCredentials_credentialPair :: (Maybe CredentialPair -> f (Maybe CredentialPair))
-> DataSourceCredentials -> f DataSourceCredentials
dataSourceCredentials_credentialPair = (DataSourceCredentials -> Maybe CredentialPair)
-> (DataSourceCredentials
    -> Maybe CredentialPair -> DataSourceCredentials)
-> Lens
     DataSourceCredentials
     DataSourceCredentials
     (Maybe CredentialPair)
     (Maybe CredentialPair)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceCredentials' {Maybe CredentialPair
credentialPair :: Maybe CredentialPair
$sel:credentialPair:DataSourceCredentials' :: DataSourceCredentials -> Maybe CredentialPair
credentialPair} -> Maybe CredentialPair
credentialPair) (\s :: DataSourceCredentials
s@DataSourceCredentials' {} Maybe CredentialPair
a -> DataSourceCredentials
s {$sel:credentialPair:DataSourceCredentials' :: Maybe CredentialPair
credentialPair = Maybe CredentialPair
a} :: DataSourceCredentials)

instance Prelude.Hashable DataSourceCredentials

instance Prelude.NFData DataSourceCredentials

instance Core.ToJSON DataSourceCredentials where
  toJSON :: DataSourceCredentials -> Value
toJSON DataSourceCredentials' {Maybe Text
Maybe CredentialPair
credentialPair :: Maybe CredentialPair
copySourceArn :: Maybe Text
$sel:credentialPair:DataSourceCredentials' :: DataSourceCredentials -> Maybe CredentialPair
$sel:copySourceArn:DataSourceCredentials' :: DataSourceCredentials -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CopySourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
copySourceArn,
            (Text
"CredentialPair" Text -> CredentialPair -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CredentialPair -> Pair) -> Maybe CredentialPair -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CredentialPair
credentialPair
          ]
      )