{-# 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.SecurityHub.Types.AwsElbLoadBalancerAccessLog
-- 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.SecurityHub.Types.AwsElbLoadBalancerAccessLog where

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

-- | Contains information about the access log configuration for the load
-- balancer.
--
-- /See:/ 'newAwsElbLoadBalancerAccessLog' smart constructor.
data AwsElbLoadBalancerAccessLog = AwsElbLoadBalancerAccessLog'
  { -- | The interval in minutes for publishing the access logs.
    --
    -- You can publish access logs either every 5 minutes or every 60 minutes.
    AwsElbLoadBalancerAccessLog -> Maybe Int
emitInterval :: Prelude.Maybe Prelude.Int,
    -- | Indicates whether access logs are enabled for the load balancer.
    AwsElbLoadBalancerAccessLog -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The logical hierarchy that was created for the S3 bucket.
    --
    -- If a prefix is not provided, the log is placed at the root level of the
    -- bucket.
    AwsElbLoadBalancerAccessLog -> Maybe Text
s3BucketPrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket where the access logs are stored.
    AwsElbLoadBalancerAccessLog -> Maybe Text
s3BucketName :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsElbLoadBalancerAccessLog -> AwsElbLoadBalancerAccessLog -> Bool
(AwsElbLoadBalancerAccessLog
 -> AwsElbLoadBalancerAccessLog -> Bool)
-> (AwsElbLoadBalancerAccessLog
    -> AwsElbLoadBalancerAccessLog -> Bool)
-> Eq AwsElbLoadBalancerAccessLog
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsElbLoadBalancerAccessLog -> AwsElbLoadBalancerAccessLog -> Bool
$c/= :: AwsElbLoadBalancerAccessLog -> AwsElbLoadBalancerAccessLog -> Bool
== :: AwsElbLoadBalancerAccessLog -> AwsElbLoadBalancerAccessLog -> Bool
$c== :: AwsElbLoadBalancerAccessLog -> AwsElbLoadBalancerAccessLog -> Bool
Prelude.Eq, ReadPrec [AwsElbLoadBalancerAccessLog]
ReadPrec AwsElbLoadBalancerAccessLog
Int -> ReadS AwsElbLoadBalancerAccessLog
ReadS [AwsElbLoadBalancerAccessLog]
(Int -> ReadS AwsElbLoadBalancerAccessLog)
-> ReadS [AwsElbLoadBalancerAccessLog]
-> ReadPrec AwsElbLoadBalancerAccessLog
-> ReadPrec [AwsElbLoadBalancerAccessLog]
-> Read AwsElbLoadBalancerAccessLog
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsElbLoadBalancerAccessLog]
$creadListPrec :: ReadPrec [AwsElbLoadBalancerAccessLog]
readPrec :: ReadPrec AwsElbLoadBalancerAccessLog
$creadPrec :: ReadPrec AwsElbLoadBalancerAccessLog
readList :: ReadS [AwsElbLoadBalancerAccessLog]
$creadList :: ReadS [AwsElbLoadBalancerAccessLog]
readsPrec :: Int -> ReadS AwsElbLoadBalancerAccessLog
$creadsPrec :: Int -> ReadS AwsElbLoadBalancerAccessLog
Prelude.Read, Int -> AwsElbLoadBalancerAccessLog -> ShowS
[AwsElbLoadBalancerAccessLog] -> ShowS
AwsElbLoadBalancerAccessLog -> String
(Int -> AwsElbLoadBalancerAccessLog -> ShowS)
-> (AwsElbLoadBalancerAccessLog -> String)
-> ([AwsElbLoadBalancerAccessLog] -> ShowS)
-> Show AwsElbLoadBalancerAccessLog
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsElbLoadBalancerAccessLog] -> ShowS
$cshowList :: [AwsElbLoadBalancerAccessLog] -> ShowS
show :: AwsElbLoadBalancerAccessLog -> String
$cshow :: AwsElbLoadBalancerAccessLog -> String
showsPrec :: Int -> AwsElbLoadBalancerAccessLog -> ShowS
$cshowsPrec :: Int -> AwsElbLoadBalancerAccessLog -> ShowS
Prelude.Show, (forall x.
 AwsElbLoadBalancerAccessLog -> Rep AwsElbLoadBalancerAccessLog x)
-> (forall x.
    Rep AwsElbLoadBalancerAccessLog x -> AwsElbLoadBalancerAccessLog)
-> Generic AwsElbLoadBalancerAccessLog
forall x.
Rep AwsElbLoadBalancerAccessLog x -> AwsElbLoadBalancerAccessLog
forall x.
AwsElbLoadBalancerAccessLog -> Rep AwsElbLoadBalancerAccessLog x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsElbLoadBalancerAccessLog x -> AwsElbLoadBalancerAccessLog
$cfrom :: forall x.
AwsElbLoadBalancerAccessLog -> Rep AwsElbLoadBalancerAccessLog x
Prelude.Generic)

-- |
-- Create a value of 'AwsElbLoadBalancerAccessLog' 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:
--
-- 'emitInterval', 'awsElbLoadBalancerAccessLog_emitInterval' - The interval in minutes for publishing the access logs.
--
-- You can publish access logs either every 5 minutes or every 60 minutes.
--
-- 'enabled', 'awsElbLoadBalancerAccessLog_enabled' - Indicates whether access logs are enabled for the load balancer.
--
-- 's3BucketPrefix', 'awsElbLoadBalancerAccessLog_s3BucketPrefix' - The logical hierarchy that was created for the S3 bucket.
--
-- If a prefix is not provided, the log is placed at the root level of the
-- bucket.
--
-- 's3BucketName', 'awsElbLoadBalancerAccessLog_s3BucketName' - The name of the S3 bucket where the access logs are stored.
newAwsElbLoadBalancerAccessLog ::
  AwsElbLoadBalancerAccessLog
newAwsElbLoadBalancerAccessLog :: AwsElbLoadBalancerAccessLog
newAwsElbLoadBalancerAccessLog =
  AwsElbLoadBalancerAccessLog' :: Maybe Int
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> AwsElbLoadBalancerAccessLog
AwsElbLoadBalancerAccessLog'
    { $sel:emitInterval:AwsElbLoadBalancerAccessLog' :: Maybe Int
emitInterval =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:AwsElbLoadBalancerAccessLog' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketPrefix:AwsElbLoadBalancerAccessLog' :: Maybe Text
s3BucketPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:AwsElbLoadBalancerAccessLog' :: Maybe Text
s3BucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The interval in minutes for publishing the access logs.
--
-- You can publish access logs either every 5 minutes or every 60 minutes.
awsElbLoadBalancerAccessLog_emitInterval :: Lens.Lens' AwsElbLoadBalancerAccessLog (Prelude.Maybe Prelude.Int)
awsElbLoadBalancerAccessLog_emitInterval :: (Maybe Int -> f (Maybe Int))
-> AwsElbLoadBalancerAccessLog -> f AwsElbLoadBalancerAccessLog
awsElbLoadBalancerAccessLog_emitInterval = (AwsElbLoadBalancerAccessLog -> Maybe Int)
-> (AwsElbLoadBalancerAccessLog
    -> Maybe Int -> AwsElbLoadBalancerAccessLog)
-> Lens
     AwsElbLoadBalancerAccessLog
     AwsElbLoadBalancerAccessLog
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbLoadBalancerAccessLog' {Maybe Int
emitInterval :: Maybe Int
$sel:emitInterval:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Int
emitInterval} -> Maybe Int
emitInterval) (\s :: AwsElbLoadBalancerAccessLog
s@AwsElbLoadBalancerAccessLog' {} Maybe Int
a -> AwsElbLoadBalancerAccessLog
s {$sel:emitInterval:AwsElbLoadBalancerAccessLog' :: Maybe Int
emitInterval = Maybe Int
a} :: AwsElbLoadBalancerAccessLog)

-- | Indicates whether access logs are enabled for the load balancer.
awsElbLoadBalancerAccessLog_enabled :: Lens.Lens' AwsElbLoadBalancerAccessLog (Prelude.Maybe Prelude.Bool)
awsElbLoadBalancerAccessLog_enabled :: (Maybe Bool -> f (Maybe Bool))
-> AwsElbLoadBalancerAccessLog -> f AwsElbLoadBalancerAccessLog
awsElbLoadBalancerAccessLog_enabled = (AwsElbLoadBalancerAccessLog -> Maybe Bool)
-> (AwsElbLoadBalancerAccessLog
    -> Maybe Bool -> AwsElbLoadBalancerAccessLog)
-> Lens
     AwsElbLoadBalancerAccessLog
     AwsElbLoadBalancerAccessLog
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbLoadBalancerAccessLog' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AwsElbLoadBalancerAccessLog
s@AwsElbLoadBalancerAccessLog' {} Maybe Bool
a -> AwsElbLoadBalancerAccessLog
s {$sel:enabled:AwsElbLoadBalancerAccessLog' :: Maybe Bool
enabled = Maybe Bool
a} :: AwsElbLoadBalancerAccessLog)

-- | The logical hierarchy that was created for the S3 bucket.
--
-- If a prefix is not provided, the log is placed at the root level of the
-- bucket.
awsElbLoadBalancerAccessLog_s3BucketPrefix :: Lens.Lens' AwsElbLoadBalancerAccessLog (Prelude.Maybe Prelude.Text)
awsElbLoadBalancerAccessLog_s3BucketPrefix :: (Maybe Text -> f (Maybe Text))
-> AwsElbLoadBalancerAccessLog -> f AwsElbLoadBalancerAccessLog
awsElbLoadBalancerAccessLog_s3BucketPrefix = (AwsElbLoadBalancerAccessLog -> Maybe Text)
-> (AwsElbLoadBalancerAccessLog
    -> Maybe Text -> AwsElbLoadBalancerAccessLog)
-> Lens
     AwsElbLoadBalancerAccessLog
     AwsElbLoadBalancerAccessLog
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbLoadBalancerAccessLog' {Maybe Text
s3BucketPrefix :: Maybe Text
$sel:s3BucketPrefix:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Text
s3BucketPrefix} -> Maybe Text
s3BucketPrefix) (\s :: AwsElbLoadBalancerAccessLog
s@AwsElbLoadBalancerAccessLog' {} Maybe Text
a -> AwsElbLoadBalancerAccessLog
s {$sel:s3BucketPrefix:AwsElbLoadBalancerAccessLog' :: Maybe Text
s3BucketPrefix = Maybe Text
a} :: AwsElbLoadBalancerAccessLog)

-- | The name of the S3 bucket where the access logs are stored.
awsElbLoadBalancerAccessLog_s3BucketName :: Lens.Lens' AwsElbLoadBalancerAccessLog (Prelude.Maybe Prelude.Text)
awsElbLoadBalancerAccessLog_s3BucketName :: (Maybe Text -> f (Maybe Text))
-> AwsElbLoadBalancerAccessLog -> f AwsElbLoadBalancerAccessLog
awsElbLoadBalancerAccessLog_s3BucketName = (AwsElbLoadBalancerAccessLog -> Maybe Text)
-> (AwsElbLoadBalancerAccessLog
    -> Maybe Text -> AwsElbLoadBalancerAccessLog)
-> Lens
     AwsElbLoadBalancerAccessLog
     AwsElbLoadBalancerAccessLog
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbLoadBalancerAccessLog' {Maybe Text
s3BucketName :: Maybe Text
$sel:s3BucketName:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Text
s3BucketName} -> Maybe Text
s3BucketName) (\s :: AwsElbLoadBalancerAccessLog
s@AwsElbLoadBalancerAccessLog' {} Maybe Text
a -> AwsElbLoadBalancerAccessLog
s {$sel:s3BucketName:AwsElbLoadBalancerAccessLog' :: Maybe Text
s3BucketName = Maybe Text
a} :: AwsElbLoadBalancerAccessLog)

instance Core.FromJSON AwsElbLoadBalancerAccessLog where
  parseJSON :: Value -> Parser AwsElbLoadBalancerAccessLog
parseJSON =
    String
-> (Object -> Parser AwsElbLoadBalancerAccessLog)
-> Value
-> Parser AwsElbLoadBalancerAccessLog
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsElbLoadBalancerAccessLog"
      ( \Object
x ->
          Maybe Int
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> AwsElbLoadBalancerAccessLog
AwsElbLoadBalancerAccessLog'
            (Maybe Int
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> AwsElbLoadBalancerAccessLog)
-> Parser (Maybe Int)
-> Parser
     (Maybe Bool
      -> Maybe Text -> Maybe Text -> AwsElbLoadBalancerAccessLog)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EmitInterval")
            Parser
  (Maybe Bool
   -> Maybe Text -> Maybe Text -> AwsElbLoadBalancerAccessLog)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> Maybe Text -> AwsElbLoadBalancerAccessLog)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser (Maybe Text -> Maybe Text -> AwsElbLoadBalancerAccessLog)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsElbLoadBalancerAccessLog)
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
"S3BucketPrefix")
            Parser (Maybe Text -> AwsElbLoadBalancerAccessLog)
-> Parser (Maybe Text) -> Parser AwsElbLoadBalancerAccessLog
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 AwsElbLoadBalancerAccessLog

instance Prelude.NFData AwsElbLoadBalancerAccessLog

instance Core.ToJSON AwsElbLoadBalancerAccessLog where
  toJSON :: AwsElbLoadBalancerAccessLog -> Value
toJSON AwsElbLoadBalancerAccessLog' {Maybe Bool
Maybe Int
Maybe Text
s3BucketName :: Maybe Text
s3BucketPrefix :: Maybe Text
enabled :: Maybe Bool
emitInterval :: Maybe Int
$sel:s3BucketName:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Text
$sel:s3BucketPrefix:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Text
$sel:enabled:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Bool
$sel:emitInterval:AwsElbLoadBalancerAccessLog' :: AwsElbLoadBalancerAccessLog -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EmitInterval" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
emitInterval,
            (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"S3BucketPrefix" 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
s3BucketPrefix,
            (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
          ]
      )