{-# 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.DMS.Types.DynamoDbSettings
-- 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.DMS.Types.DynamoDbSettings where

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

-- | Provides the Amazon Resource Name (ARN) of the Identity and Access
-- Management (IAM) role used to define an Amazon DynamoDB target endpoint.
--
-- /See:/ 'newDynamoDbSettings' smart constructor.
data DynamoDbSettings = DynamoDbSettings'
  { -- | The Amazon Resource Name (ARN) used by the service to access the IAM
    -- role. The role must allow the @iam:PassRole@ action.
    DynamoDbSettings -> Text
serviceAccessRoleArn :: Prelude.Text
  }
  deriving (DynamoDbSettings -> DynamoDbSettings -> Bool
(DynamoDbSettings -> DynamoDbSettings -> Bool)
-> (DynamoDbSettings -> DynamoDbSettings -> Bool)
-> Eq DynamoDbSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DynamoDbSettings -> DynamoDbSettings -> Bool
$c/= :: DynamoDbSettings -> DynamoDbSettings -> Bool
== :: DynamoDbSettings -> DynamoDbSettings -> Bool
$c== :: DynamoDbSettings -> DynamoDbSettings -> Bool
Prelude.Eq, ReadPrec [DynamoDbSettings]
ReadPrec DynamoDbSettings
Int -> ReadS DynamoDbSettings
ReadS [DynamoDbSettings]
(Int -> ReadS DynamoDbSettings)
-> ReadS [DynamoDbSettings]
-> ReadPrec DynamoDbSettings
-> ReadPrec [DynamoDbSettings]
-> Read DynamoDbSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DynamoDbSettings]
$creadListPrec :: ReadPrec [DynamoDbSettings]
readPrec :: ReadPrec DynamoDbSettings
$creadPrec :: ReadPrec DynamoDbSettings
readList :: ReadS [DynamoDbSettings]
$creadList :: ReadS [DynamoDbSettings]
readsPrec :: Int -> ReadS DynamoDbSettings
$creadsPrec :: Int -> ReadS DynamoDbSettings
Prelude.Read, Int -> DynamoDbSettings -> ShowS
[DynamoDbSettings] -> ShowS
DynamoDbSettings -> String
(Int -> DynamoDbSettings -> ShowS)
-> (DynamoDbSettings -> String)
-> ([DynamoDbSettings] -> ShowS)
-> Show DynamoDbSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DynamoDbSettings] -> ShowS
$cshowList :: [DynamoDbSettings] -> ShowS
show :: DynamoDbSettings -> String
$cshow :: DynamoDbSettings -> String
showsPrec :: Int -> DynamoDbSettings -> ShowS
$cshowsPrec :: Int -> DynamoDbSettings -> ShowS
Prelude.Show, (forall x. DynamoDbSettings -> Rep DynamoDbSettings x)
-> (forall x. Rep DynamoDbSettings x -> DynamoDbSettings)
-> Generic DynamoDbSettings
forall x. Rep DynamoDbSettings x -> DynamoDbSettings
forall x. DynamoDbSettings -> Rep DynamoDbSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DynamoDbSettings x -> DynamoDbSettings
$cfrom :: forall x. DynamoDbSettings -> Rep DynamoDbSettings x
Prelude.Generic)

-- |
-- Create a value of 'DynamoDbSettings' 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:
--
-- 'serviceAccessRoleArn', 'dynamoDbSettings_serviceAccessRoleArn' - The Amazon Resource Name (ARN) used by the service to access the IAM
-- role. The role must allow the @iam:PassRole@ action.
newDynamoDbSettings ::
  -- | 'serviceAccessRoleArn'
  Prelude.Text ->
  DynamoDbSettings
newDynamoDbSettings :: Text -> DynamoDbSettings
newDynamoDbSettings Text
pServiceAccessRoleArn_ =
  DynamoDbSettings' :: Text -> DynamoDbSettings
DynamoDbSettings'
    { $sel:serviceAccessRoleArn:DynamoDbSettings' :: Text
serviceAccessRoleArn =
        Text
pServiceAccessRoleArn_
    }

-- | The Amazon Resource Name (ARN) used by the service to access the IAM
-- role. The role must allow the @iam:PassRole@ action.
dynamoDbSettings_serviceAccessRoleArn :: Lens.Lens' DynamoDbSettings Prelude.Text
dynamoDbSettings_serviceAccessRoleArn :: (Text -> f Text) -> DynamoDbSettings -> f DynamoDbSettings
dynamoDbSettings_serviceAccessRoleArn = (DynamoDbSettings -> Text)
-> (DynamoDbSettings -> Text -> DynamoDbSettings)
-> Lens DynamoDbSettings DynamoDbSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDbSettings' {Text
serviceAccessRoleArn :: Text
$sel:serviceAccessRoleArn:DynamoDbSettings' :: DynamoDbSettings -> Text
serviceAccessRoleArn} -> Text
serviceAccessRoleArn) (\s :: DynamoDbSettings
s@DynamoDbSettings' {} Text
a -> DynamoDbSettings
s {$sel:serviceAccessRoleArn:DynamoDbSettings' :: Text
serviceAccessRoleArn = Text
a} :: DynamoDbSettings)

instance Core.FromJSON DynamoDbSettings where
  parseJSON :: Value -> Parser DynamoDbSettings
parseJSON =
    String
-> (Object -> Parser DynamoDbSettings)
-> Value
-> Parser DynamoDbSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DynamoDbSettings"
      ( \Object
x ->
          Text -> DynamoDbSettings
DynamoDbSettings'
            (Text -> DynamoDbSettings)
-> Parser Text -> Parser DynamoDbSettings
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ServiceAccessRoleArn")
      )

instance Prelude.Hashable DynamoDbSettings

instance Prelude.NFData DynamoDbSettings

instance Core.ToJSON DynamoDbSettings where
  toJSON :: DynamoDbSettings -> Value
toJSON DynamoDbSettings' {Text
serviceAccessRoleArn :: Text
$sel:serviceAccessRoleArn:DynamoDbSettings' :: DynamoDbSettings -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ServiceAccessRoleArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceAccessRoleArn
              )
          ]
      )