{-# 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.DmsTransferSettings
-- 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.DmsTransferSettings where

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

-- | The settings in JSON format for the DMS Transfer type source endpoint.
--
-- /See:/ 'newDmsTransferSettings' smart constructor.
data DmsTransferSettings = DmsTransferSettings'
  { -- | The Amazon Resource Name (ARN) used by the service access IAM role. The
    -- role must allow the @iam:PassRole@ action.
    DmsTransferSettings -> Maybe Text
serviceAccessRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket to use.
    DmsTransferSettings -> Maybe Text
bucketName :: Prelude.Maybe Prelude.Text
  }
  deriving (DmsTransferSettings -> DmsTransferSettings -> Bool
(DmsTransferSettings -> DmsTransferSettings -> Bool)
-> (DmsTransferSettings -> DmsTransferSettings -> Bool)
-> Eq DmsTransferSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DmsTransferSettings -> DmsTransferSettings -> Bool
$c/= :: DmsTransferSettings -> DmsTransferSettings -> Bool
== :: DmsTransferSettings -> DmsTransferSettings -> Bool
$c== :: DmsTransferSettings -> DmsTransferSettings -> Bool
Prelude.Eq, ReadPrec [DmsTransferSettings]
ReadPrec DmsTransferSettings
Int -> ReadS DmsTransferSettings
ReadS [DmsTransferSettings]
(Int -> ReadS DmsTransferSettings)
-> ReadS [DmsTransferSettings]
-> ReadPrec DmsTransferSettings
-> ReadPrec [DmsTransferSettings]
-> Read DmsTransferSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DmsTransferSettings]
$creadListPrec :: ReadPrec [DmsTransferSettings]
readPrec :: ReadPrec DmsTransferSettings
$creadPrec :: ReadPrec DmsTransferSettings
readList :: ReadS [DmsTransferSettings]
$creadList :: ReadS [DmsTransferSettings]
readsPrec :: Int -> ReadS DmsTransferSettings
$creadsPrec :: Int -> ReadS DmsTransferSettings
Prelude.Read, Int -> DmsTransferSettings -> ShowS
[DmsTransferSettings] -> ShowS
DmsTransferSettings -> String
(Int -> DmsTransferSettings -> ShowS)
-> (DmsTransferSettings -> String)
-> ([DmsTransferSettings] -> ShowS)
-> Show DmsTransferSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DmsTransferSettings] -> ShowS
$cshowList :: [DmsTransferSettings] -> ShowS
show :: DmsTransferSettings -> String
$cshow :: DmsTransferSettings -> String
showsPrec :: Int -> DmsTransferSettings -> ShowS
$cshowsPrec :: Int -> DmsTransferSettings -> ShowS
Prelude.Show, (forall x. DmsTransferSettings -> Rep DmsTransferSettings x)
-> (forall x. Rep DmsTransferSettings x -> DmsTransferSettings)
-> Generic DmsTransferSettings
forall x. Rep DmsTransferSettings x -> DmsTransferSettings
forall x. DmsTransferSettings -> Rep DmsTransferSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DmsTransferSettings x -> DmsTransferSettings
$cfrom :: forall x. DmsTransferSettings -> Rep DmsTransferSettings x
Prelude.Generic)

-- |
-- Create a value of 'DmsTransferSettings' 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', 'dmsTransferSettings_serviceAccessRoleArn' - The Amazon Resource Name (ARN) used by the service access IAM role. The
-- role must allow the @iam:PassRole@ action.
--
-- 'bucketName', 'dmsTransferSettings_bucketName' - The name of the S3 bucket to use.
newDmsTransferSettings ::
  DmsTransferSettings
newDmsTransferSettings :: DmsTransferSettings
newDmsTransferSettings =
  DmsTransferSettings' :: Maybe Text -> Maybe Text -> DmsTransferSettings
DmsTransferSettings'
    { $sel:serviceAccessRoleArn:DmsTransferSettings' :: Maybe Text
serviceAccessRoleArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:DmsTransferSettings' :: Maybe Text
bucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the S3 bucket to use.
dmsTransferSettings_bucketName :: Lens.Lens' DmsTransferSettings (Prelude.Maybe Prelude.Text)
dmsTransferSettings_bucketName :: (Maybe Text -> f (Maybe Text))
-> DmsTransferSettings -> f DmsTransferSettings
dmsTransferSettings_bucketName = (DmsTransferSettings -> Maybe Text)
-> (DmsTransferSettings -> Maybe Text -> DmsTransferSettings)
-> Lens
     DmsTransferSettings DmsTransferSettings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DmsTransferSettings' {Maybe Text
bucketName :: Maybe Text
$sel:bucketName:DmsTransferSettings' :: DmsTransferSettings -> Maybe Text
bucketName} -> Maybe Text
bucketName) (\s :: DmsTransferSettings
s@DmsTransferSettings' {} Maybe Text
a -> DmsTransferSettings
s {$sel:bucketName:DmsTransferSettings' :: Maybe Text
bucketName = Maybe Text
a} :: DmsTransferSettings)

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

instance Prelude.Hashable DmsTransferSettings

instance Prelude.NFData DmsTransferSettings

instance Core.ToJSON DmsTransferSettings where
  toJSON :: DmsTransferSettings -> Value
toJSON DmsTransferSettings' {Maybe Text
bucketName :: Maybe Text
serviceAccessRoleArn :: Maybe Text
$sel:bucketName:DmsTransferSettings' :: DmsTransferSettings -> Maybe Text
$sel:serviceAccessRoleArn:DmsTransferSettings' :: DmsTransferSettings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ServiceAccessRoleArn" 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
serviceAccessRoleArn,
            (Text
"BucketName" 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
bucketName
          ]
      )