{-# 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.ImageBuilder.Types.S3Logs
-- 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.ImageBuilder.Types.S3Logs where

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

-- | Amazon S3 logging configuration.
--
-- /See:/ 'newS3Logs' smart constructor.
data S3Logs = S3Logs'
  { -- | The Amazon S3 path in which to store the logs.
    S3Logs -> Maybe Text
s3KeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 bucket in which to store the logs.
    S3Logs -> Maybe Text
s3BucketName :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Logs -> S3Logs -> Bool
(S3Logs -> S3Logs -> Bool)
-> (S3Logs -> S3Logs -> Bool) -> Eq S3Logs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Logs -> S3Logs -> Bool
$c/= :: S3Logs -> S3Logs -> Bool
== :: S3Logs -> S3Logs -> Bool
$c== :: S3Logs -> S3Logs -> Bool
Prelude.Eq, ReadPrec [S3Logs]
ReadPrec S3Logs
Int -> ReadS S3Logs
ReadS [S3Logs]
(Int -> ReadS S3Logs)
-> ReadS [S3Logs]
-> ReadPrec S3Logs
-> ReadPrec [S3Logs]
-> Read S3Logs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Logs]
$creadListPrec :: ReadPrec [S3Logs]
readPrec :: ReadPrec S3Logs
$creadPrec :: ReadPrec S3Logs
readList :: ReadS [S3Logs]
$creadList :: ReadS [S3Logs]
readsPrec :: Int -> ReadS S3Logs
$creadsPrec :: Int -> ReadS S3Logs
Prelude.Read, Int -> S3Logs -> ShowS
[S3Logs] -> ShowS
S3Logs -> String
(Int -> S3Logs -> ShowS)
-> (S3Logs -> String) -> ([S3Logs] -> ShowS) -> Show S3Logs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Logs] -> ShowS
$cshowList :: [S3Logs] -> ShowS
show :: S3Logs -> String
$cshow :: S3Logs -> String
showsPrec :: Int -> S3Logs -> ShowS
$cshowsPrec :: Int -> S3Logs -> ShowS
Prelude.Show, (forall x. S3Logs -> Rep S3Logs x)
-> (forall x. Rep S3Logs x -> S3Logs) -> Generic S3Logs
forall x. Rep S3Logs x -> S3Logs
forall x. S3Logs -> Rep S3Logs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Logs x -> S3Logs
$cfrom :: forall x. S3Logs -> Rep S3Logs x
Prelude.Generic)

-- |
-- Create a value of 'S3Logs' 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:
--
-- 's3KeyPrefix', 's3Logs_s3KeyPrefix' - The Amazon S3 path in which to store the logs.
--
-- 's3BucketName', 's3Logs_s3BucketName' - The Amazon S3 bucket in which to store the logs.
newS3Logs ::
  S3Logs
newS3Logs :: S3Logs
newS3Logs =
  S3Logs' :: Maybe Text -> Maybe Text -> S3Logs
S3Logs'
    { $sel:s3KeyPrefix:S3Logs' :: Maybe Text
s3KeyPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:S3Logs' :: Maybe Text
s3BucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon S3 path in which to store the logs.
s3Logs_s3KeyPrefix :: Lens.Lens' S3Logs (Prelude.Maybe Prelude.Text)
s3Logs_s3KeyPrefix :: (Maybe Text -> f (Maybe Text)) -> S3Logs -> f S3Logs
s3Logs_s3KeyPrefix = (S3Logs -> Maybe Text)
-> (S3Logs -> Maybe Text -> S3Logs)
-> Lens S3Logs S3Logs (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Logs' {Maybe Text
s3KeyPrefix :: Maybe Text
$sel:s3KeyPrefix:S3Logs' :: S3Logs -> Maybe Text
s3KeyPrefix} -> Maybe Text
s3KeyPrefix) (\s :: S3Logs
s@S3Logs' {} Maybe Text
a -> S3Logs
s {$sel:s3KeyPrefix:S3Logs' :: Maybe Text
s3KeyPrefix = Maybe Text
a} :: S3Logs)

-- | The Amazon S3 bucket in which to store the logs.
s3Logs_s3BucketName :: Lens.Lens' S3Logs (Prelude.Maybe Prelude.Text)
s3Logs_s3BucketName :: (Maybe Text -> f (Maybe Text)) -> S3Logs -> f S3Logs
s3Logs_s3BucketName = (S3Logs -> Maybe Text)
-> (S3Logs -> Maybe Text -> S3Logs)
-> Lens S3Logs S3Logs (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Logs' {Maybe Text
s3BucketName :: Maybe Text
$sel:s3BucketName:S3Logs' :: S3Logs -> Maybe Text
s3BucketName} -> Maybe Text
s3BucketName) (\s :: S3Logs
s@S3Logs' {} Maybe Text
a -> S3Logs
s {$sel:s3BucketName:S3Logs' :: Maybe Text
s3BucketName = Maybe Text
a} :: S3Logs)

instance Core.FromJSON S3Logs where
  parseJSON :: Value -> Parser S3Logs
parseJSON =
    String -> (Object -> Parser S3Logs) -> Value -> Parser S3Logs
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Logs"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> S3Logs
S3Logs'
            (Maybe Text -> Maybe Text -> S3Logs)
-> Parser (Maybe Text) -> Parser (Maybe Text -> S3Logs)
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
"s3KeyPrefix")
            Parser (Maybe Text -> S3Logs)
-> Parser (Maybe Text) -> Parser S3Logs
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
"s3BucketName")
      )

instance Prelude.Hashable S3Logs

instance Prelude.NFData S3Logs

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