{-# 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.TimeStreamQuery.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.TimeStreamQuery.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.TimeStreamQuery.Types.S3EncryptionOption

-- | Details on S3 location for error reports that result from running a
-- query.
--
-- /See:/ 'newS3Configuration' smart constructor.
data S3Configuration = S3Configuration'
  { -- | Encryption at rest options for the error reports. If no encryption
    -- option is specified, Timestream will choose SSE_S3 as default.
    S3Configuration -> Maybe S3EncryptionOption
encryptionOption :: Prelude.Maybe S3EncryptionOption,
    -- | Prefix for the error report key. Timestream by default adds the
    -- following prefix to the error report path.
    S3Configuration -> Maybe Text
objectKeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | Name of the S3 bucket under which error reports will be created.
    S3Configuration -> Text
bucketName :: 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:
--
-- 'encryptionOption', 's3Configuration_encryptionOption' - Encryption at rest options for the error reports. If no encryption
-- option is specified, Timestream will choose SSE_S3 as default.
--
-- 'objectKeyPrefix', 's3Configuration_objectKeyPrefix' - Prefix for the error report key. Timestream by default adds the
-- following prefix to the error report path.
--
-- 'bucketName', 's3Configuration_bucketName' - Name of the S3 bucket under which error reports will be created.
newS3Configuration ::
  -- | 'bucketName'
  Prelude.Text ->
  S3Configuration
newS3Configuration :: Text -> S3Configuration
newS3Configuration Text
pBucketName_ =
  S3Configuration'
    { $sel:encryptionOption:S3Configuration' :: Maybe S3EncryptionOption
encryptionOption =
        forall a. Maybe a
Prelude.Nothing,
      $sel:objectKeyPrefix:S3Configuration' :: Maybe Text
objectKeyPrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3Configuration' :: Text
bucketName = Text
pBucketName_
    }

-- | Encryption at rest options for the error reports. If no encryption
-- option is specified, Timestream will choose SSE_S3 as default.
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)

-- | Prefix for the error report key. Timestream by default adds the
-- following prefix to the error report path.
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)

-- | Name of the S3 bucket under which error reports will be created.
s3Configuration_bucketName :: Lens.Lens' S3Configuration Prelude.Text
s3Configuration_bucketName :: Lens' S3Configuration Text
s3Configuration_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Text
bucketName :: Text
$sel:bucketName:S3Configuration' :: S3Configuration -> Text
bucketName} -> Text
bucketName) (\s :: S3Configuration
s@S3Configuration' {} Text
a -> S3Configuration
s {$sel:bucketName:S3Configuration' :: Text
bucketName = 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 S3EncryptionOption -> Maybe Text -> 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
"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
"ObjectKeyPrefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"BucketName")
      )

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

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

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