{-# 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.TimeStreamWrite.Types.S3Configuration
-- 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.TimeStreamWrite.Types.S3Configuration 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
import Amazonka.TimeStreamWrite.Types.S3EncryptionOption

-- | Configuration specifing an S3 location.
--
-- /See:/ 'newS3Configuration' smart constructor.
data S3Configuration = S3Configuration'
  { -- | >Bucket name of the customer S3 bucket.
    S3Configuration -> Maybe Text
bucketName :: Prelude.Maybe Prelude.Text,
    -- | Encryption option for the customer s3 location. Options are S3 server
    -- side encryption with an S3-managed key or KMS managed key.
    S3Configuration -> Maybe S3EncryptionOption
encryptionOption :: Prelude.Maybe S3EncryptionOption,
    -- | KMS key id for the customer s3 location when encrypting with a KMS
    -- managed key.
    S3Configuration -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | Object key preview for the customer S3 location.
    S3Configuration -> Maybe Text
objectKeyPrefix :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Configuration -> S3Configuration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Configuration -> S3Configuration -> Bool
$c/= :: S3Configuration -> S3Configuration -> Bool
== :: S3Configuration -> S3Configuration -> Bool
$c== :: S3Configuration -> S3Configuration -> Bool
Prelude.Eq, ReadPrec [S3Configuration]
ReadPrec S3Configuration
Int -> ReadS S3Configuration
ReadS [S3Configuration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Configuration]
$creadListPrec :: ReadPrec [S3Configuration]
readPrec :: ReadPrec S3Configuration
$creadPrec :: ReadPrec S3Configuration
readList :: ReadS [S3Configuration]
$creadList :: ReadS [S3Configuration]
readsPrec :: Int -> ReadS S3Configuration
$creadsPrec :: Int -> ReadS S3Configuration
Prelude.Read, Int -> S3Configuration -> ShowS
[S3Configuration] -> ShowS
S3Configuration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Configuration] -> ShowS
$cshowList :: [S3Configuration] -> ShowS
show :: S3Configuration -> String
$cshow :: S3Configuration -> String
showsPrec :: Int -> S3Configuration -> ShowS
$cshowsPrec :: Int -> S3Configuration -> ShowS
Prelude.Show, forall x. Rep S3Configuration x -> S3Configuration
forall x. S3Configuration -> Rep S3Configuration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Configuration x -> S3Configuration
$cfrom :: forall x. S3Configuration -> Rep S3Configuration x
Prelude.Generic)

-- |
-- Create a value of 'S3Configuration' 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:
--
-- 'bucketName', 's3Configuration_bucketName' - >Bucket name of the customer S3 bucket.
--
-- 'encryptionOption', 's3Configuration_encryptionOption' - Encryption option for the customer s3 location. Options are S3 server
-- side encryption with an S3-managed key or KMS managed key.
--
-- 'kmsKeyId', 's3Configuration_kmsKeyId' - KMS key id for the customer s3 location when encrypting with a KMS
-- managed key.
--
-- 'objectKeyPrefix', 's3Configuration_objectKeyPrefix' - Object key preview for the customer S3 location.
newS3Configuration ::
  S3Configuration
newS3Configuration :: S3Configuration
newS3Configuration =
  S3Configuration'
    { $sel:bucketName:S3Configuration' :: Maybe Text
bucketName = forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionOption:S3Configuration' :: Maybe S3EncryptionOption
encryptionOption = forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:S3Configuration' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:objectKeyPrefix:S3Configuration' :: Maybe Text
objectKeyPrefix = forall a. Maybe a
Prelude.Nothing
    }

-- | >Bucket name of the customer S3 bucket.
s3Configuration_bucketName :: Lens.Lens' S3Configuration (Prelude.Maybe Prelude.Text)
s3Configuration_bucketName :: Lens' S3Configuration (Maybe Text)
s3Configuration_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Maybe Text
bucketName :: Maybe Text
$sel:bucketName:S3Configuration' :: S3Configuration -> Maybe Text
bucketName} -> Maybe Text
bucketName) (\s :: S3Configuration
s@S3Configuration' {} Maybe Text
a -> S3Configuration
s {$sel:bucketName:S3Configuration' :: Maybe Text
bucketName = Maybe Text
a} :: S3Configuration)

-- | Encryption option for the customer s3 location. Options are S3 server
-- side encryption with an S3-managed key or KMS managed key.
s3Configuration_encryptionOption :: Lens.Lens' S3Configuration (Prelude.Maybe S3EncryptionOption)
s3Configuration_encryptionOption :: Lens' S3Configuration (Maybe S3EncryptionOption)
s3Configuration_encryptionOption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Maybe S3EncryptionOption
encryptionOption :: Maybe S3EncryptionOption
$sel:encryptionOption:S3Configuration' :: S3Configuration -> Maybe S3EncryptionOption
encryptionOption} -> Maybe S3EncryptionOption
encryptionOption) (\s :: S3Configuration
s@S3Configuration' {} Maybe S3EncryptionOption
a -> S3Configuration
s {$sel:encryptionOption:S3Configuration' :: Maybe S3EncryptionOption
encryptionOption = Maybe S3EncryptionOption
a} :: S3Configuration)

-- | KMS key id for the customer s3 location when encrypting with a KMS
-- managed key.
s3Configuration_kmsKeyId :: Lens.Lens' S3Configuration (Prelude.Maybe Prelude.Text)
s3Configuration_kmsKeyId :: Lens' S3Configuration (Maybe Text)
s3Configuration_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:S3Configuration' :: S3Configuration -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: S3Configuration
s@S3Configuration' {} Maybe Text
a -> S3Configuration
s {$sel:kmsKeyId:S3Configuration' :: Maybe Text
kmsKeyId = Maybe Text
a} :: S3Configuration)

-- | Object key preview for the customer S3 location.
s3Configuration_objectKeyPrefix :: Lens.Lens' S3Configuration (Prelude.Maybe Prelude.Text)
s3Configuration_objectKeyPrefix :: Lens' S3Configuration (Maybe Text)
s3Configuration_objectKeyPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Maybe Text
objectKeyPrefix :: Maybe Text
$sel:objectKeyPrefix:S3Configuration' :: S3Configuration -> Maybe Text
objectKeyPrefix} -> Maybe Text
objectKeyPrefix) (\s :: S3Configuration
s@S3Configuration' {} Maybe Text
a -> S3Configuration
s {$sel:objectKeyPrefix:S3Configuration' :: Maybe Text
objectKeyPrefix = Maybe Text
a} :: S3Configuration)

instance Data.FromJSON S3Configuration where
  parseJSON :: Value -> Parser S3Configuration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Configuration"
      ( \Object
x ->
          Maybe Text
-> Maybe S3EncryptionOption
-> Maybe Text
-> Maybe Text
-> S3Configuration
S3Configuration'
            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
"BucketName")
            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
"EncryptionOption")
            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
"KmsKeyId")
            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
"ObjectKeyPrefix")
      )

instance Prelude.Hashable S3Configuration where
  hashWithSalt :: Int -> S3Configuration -> Int
hashWithSalt Int
_salt S3Configuration' {Maybe Text
Maybe S3EncryptionOption
objectKeyPrefix :: Maybe Text
kmsKeyId :: Maybe Text
encryptionOption :: Maybe S3EncryptionOption
bucketName :: Maybe Text
$sel:objectKeyPrefix:S3Configuration' :: S3Configuration -> Maybe Text
$sel:kmsKeyId:S3Configuration' :: S3Configuration -> Maybe Text
$sel:encryptionOption:S3Configuration' :: S3Configuration -> Maybe S3EncryptionOption
$sel:bucketName:S3Configuration' :: S3Configuration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3EncryptionOption
encryptionOption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
objectKeyPrefix

instance Prelude.NFData S3Configuration where
  rnf :: S3Configuration -> ()
rnf S3Configuration' {Maybe Text
Maybe S3EncryptionOption
objectKeyPrefix :: Maybe Text
kmsKeyId :: Maybe Text
encryptionOption :: Maybe S3EncryptionOption
bucketName :: Maybe Text
$sel:objectKeyPrefix:S3Configuration' :: S3Configuration -> Maybe Text
$sel:kmsKeyId:S3Configuration' :: S3Configuration -> Maybe Text
$sel:encryptionOption:S3Configuration' :: S3Configuration -> Maybe S3EncryptionOption
$sel:bucketName:S3Configuration' :: S3Configuration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3EncryptionOption
encryptionOption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
objectKeyPrefix

instance Data.ToJSON S3Configuration where
  toJSON :: S3Configuration -> Value
toJSON S3Configuration' {Maybe Text
Maybe S3EncryptionOption
objectKeyPrefix :: Maybe Text
kmsKeyId :: Maybe Text
encryptionOption :: Maybe S3EncryptionOption
bucketName :: Maybe Text
$sel:objectKeyPrefix:S3Configuration' :: S3Configuration -> Maybe Text
$sel:kmsKeyId:S3Configuration' :: S3Configuration -> Maybe Text
$sel:encryptionOption:S3Configuration' :: S3Configuration -> Maybe S3EncryptionOption
$sel:bucketName:S3Configuration' :: S3Configuration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BucketName" 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
bucketName,
            (Key
"EncryptionOption" 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 S3EncryptionOption
encryptionOption,
            (Key
"KmsKeyId" 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
kmsKeyId,
            (Key
"ObjectKeyPrefix" 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
objectKeyPrefix
          ]
      )