{-# 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 #-}
module Amazonka.Connect.Types.S3Config where
import Amazonka.Connect.Types.EncryptionConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data S3Config = S3Config'
{
S3Config -> Maybe EncryptionConfig
encryptionConfig :: Prelude.Maybe EncryptionConfig,
S3Config -> Text
bucketName :: Prelude.Text,
S3Config -> Text
bucketPrefix :: Prelude.Text
}
deriving (S3Config -> S3Config -> Bool
(S3Config -> S3Config -> Bool)
-> (S3Config -> S3Config -> Bool) -> Eq S3Config
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Config -> S3Config -> Bool
$c/= :: S3Config -> S3Config -> Bool
== :: S3Config -> S3Config -> Bool
$c== :: S3Config -> S3Config -> Bool
Prelude.Eq, ReadPrec [S3Config]
ReadPrec S3Config
Int -> ReadS S3Config
ReadS [S3Config]
(Int -> ReadS S3Config)
-> ReadS [S3Config]
-> ReadPrec S3Config
-> ReadPrec [S3Config]
-> Read S3Config
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Config]
$creadListPrec :: ReadPrec [S3Config]
readPrec :: ReadPrec S3Config
$creadPrec :: ReadPrec S3Config
readList :: ReadS [S3Config]
$creadList :: ReadS [S3Config]
readsPrec :: Int -> ReadS S3Config
$creadsPrec :: Int -> ReadS S3Config
Prelude.Read, Int -> S3Config -> ShowS
[S3Config] -> ShowS
S3Config -> String
(Int -> S3Config -> ShowS)
-> (S3Config -> String) -> ([S3Config] -> ShowS) -> Show S3Config
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Config] -> ShowS
$cshowList :: [S3Config] -> ShowS
show :: S3Config -> String
$cshow :: S3Config -> String
showsPrec :: Int -> S3Config -> ShowS
$cshowsPrec :: Int -> S3Config -> ShowS
Prelude.Show, (forall x. S3Config -> Rep S3Config x)
-> (forall x. Rep S3Config x -> S3Config) -> Generic S3Config
forall x. Rep S3Config x -> S3Config
forall x. S3Config -> Rep S3Config x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Config x -> S3Config
$cfrom :: forall x. S3Config -> Rep S3Config x
Prelude.Generic)
newS3Config ::
Prelude.Text ->
Prelude.Text ->
S3Config
newS3Config :: Text -> Text -> S3Config
newS3Config Text
pBucketName_ Text
pBucketPrefix_ =
S3Config' :: Maybe EncryptionConfig -> Text -> Text -> S3Config
S3Config'
{ $sel:encryptionConfig:S3Config' :: Maybe EncryptionConfig
encryptionConfig = Maybe EncryptionConfig
forall a. Maybe a
Prelude.Nothing,
$sel:bucketName:S3Config' :: Text
bucketName = Text
pBucketName_,
$sel:bucketPrefix:S3Config' :: Text
bucketPrefix = Text
pBucketPrefix_
}
s3Config_encryptionConfig :: Lens.Lens' S3Config (Prelude.Maybe EncryptionConfig)
s3Config_encryptionConfig :: (Maybe EncryptionConfig -> f (Maybe EncryptionConfig))
-> S3Config -> f S3Config
s3Config_encryptionConfig = (S3Config -> Maybe EncryptionConfig)
-> (S3Config -> Maybe EncryptionConfig -> S3Config)
-> Lens
S3Config S3Config (Maybe EncryptionConfig) (Maybe EncryptionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Config' {Maybe EncryptionConfig
encryptionConfig :: Maybe EncryptionConfig
$sel:encryptionConfig:S3Config' :: S3Config -> Maybe EncryptionConfig
encryptionConfig} -> Maybe EncryptionConfig
encryptionConfig) (\s :: S3Config
s@S3Config' {} Maybe EncryptionConfig
a -> S3Config
s {$sel:encryptionConfig:S3Config' :: Maybe EncryptionConfig
encryptionConfig = Maybe EncryptionConfig
a} :: S3Config)
s3Config_bucketName :: Lens.Lens' S3Config Prelude.Text
s3Config_bucketName :: (Text -> f Text) -> S3Config -> f S3Config
s3Config_bucketName = (S3Config -> Text)
-> (S3Config -> Text -> S3Config)
-> Lens S3Config S3Config Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Config' {Text
bucketName :: Text
$sel:bucketName:S3Config' :: S3Config -> Text
bucketName} -> Text
bucketName) (\s :: S3Config
s@S3Config' {} Text
a -> S3Config
s {$sel:bucketName:S3Config' :: Text
bucketName = Text
a} :: S3Config)
s3Config_bucketPrefix :: Lens.Lens' S3Config Prelude.Text
s3Config_bucketPrefix :: (Text -> f Text) -> S3Config -> f S3Config
s3Config_bucketPrefix = (S3Config -> Text)
-> (S3Config -> Text -> S3Config)
-> Lens S3Config S3Config Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Config' {Text
bucketPrefix :: Text
$sel:bucketPrefix:S3Config' :: S3Config -> Text
bucketPrefix} -> Text
bucketPrefix) (\s :: S3Config
s@S3Config' {} Text
a -> S3Config
s {$sel:bucketPrefix:S3Config' :: Text
bucketPrefix = Text
a} :: S3Config)
instance Core.FromJSON S3Config where
parseJSON :: Value -> Parser S3Config
parseJSON =
String -> (Object -> Parser S3Config) -> Value -> Parser S3Config
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"S3Config"
( \Object
x ->
Maybe EncryptionConfig -> Text -> Text -> S3Config
S3Config'
(Maybe EncryptionConfig -> Text -> Text -> S3Config)
-> Parser (Maybe EncryptionConfig)
-> Parser (Text -> Text -> S3Config)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EncryptionConfig")
Parser (Text -> Text -> S3Config)
-> Parser Text -> Parser (Text -> S3Config)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BucketName")
Parser (Text -> S3Config) -> Parser Text -> Parser S3Config
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BucketPrefix")
)
instance Prelude.Hashable S3Config
instance Prelude.NFData S3Config
instance Core.ToJSON S3Config where
toJSON :: S3Config -> Value
toJSON S3Config' {Maybe EncryptionConfig
Text
bucketPrefix :: Text
bucketName :: Text
encryptionConfig :: Maybe EncryptionConfig
$sel:bucketPrefix:S3Config' :: S3Config -> Text
$sel:bucketName:S3Config' :: S3Config -> Text
$sel:encryptionConfig:S3Config' :: S3Config -> Maybe EncryptionConfig
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"EncryptionConfig" Text -> EncryptionConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(EncryptionConfig -> Pair) -> Maybe EncryptionConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionConfig
encryptionConfig,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BucketName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucketName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BucketPrefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucketPrefix)
]
)