{-# 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.AwsElasticsearchDomainLogPublishingOptionsLogConfig
-- 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.AwsElasticsearchDomainLogPublishingOptionsLogConfig where

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

-- | The log configuration.
--
-- /See:/ 'newAwsElasticsearchDomainLogPublishingOptionsLogConfig' smart constructor.
data AwsElasticsearchDomainLogPublishingOptionsLogConfig = AwsElasticsearchDomainLogPublishingOptionsLogConfig'
  { -- | Whether the log publishing is enabled.
    AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The ARN of the CloudWatch Logs group to publish the logs to.
    AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Text
cloudWatchLogsLogGroupArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool
(AwsElasticsearchDomainLogPublishingOptionsLogConfig
 -> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool)
-> (AwsElasticsearchDomainLogPublishingOptionsLogConfig
    -> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool)
-> Eq AwsElasticsearchDomainLogPublishingOptionsLogConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool
$c/= :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool
== :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool
$c== :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Bool
Prelude.Eq, ReadPrec [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
ReadPrec AwsElasticsearchDomainLogPublishingOptionsLogConfig
Int -> ReadS AwsElasticsearchDomainLogPublishingOptionsLogConfig
ReadS [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
(Int -> ReadS AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> ReadS [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
-> ReadPrec AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> ReadPrec [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
-> Read AwsElasticsearchDomainLogPublishingOptionsLogConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
$creadListPrec :: ReadPrec [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
readPrec :: ReadPrec AwsElasticsearchDomainLogPublishingOptionsLogConfig
$creadPrec :: ReadPrec AwsElasticsearchDomainLogPublishingOptionsLogConfig
readList :: ReadS [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
$creadList :: ReadS [AwsElasticsearchDomainLogPublishingOptionsLogConfig]
readsPrec :: Int -> ReadS AwsElasticsearchDomainLogPublishingOptionsLogConfig
$creadsPrec :: Int -> ReadS AwsElasticsearchDomainLogPublishingOptionsLogConfig
Prelude.Read, Int -> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> ShowS
[AwsElasticsearchDomainLogPublishingOptionsLogConfig] -> ShowS
AwsElasticsearchDomainLogPublishingOptionsLogConfig -> String
(Int
 -> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> ShowS)
-> (AwsElasticsearchDomainLogPublishingOptionsLogConfig -> String)
-> ([AwsElasticsearchDomainLogPublishingOptionsLogConfig] -> ShowS)
-> Show AwsElasticsearchDomainLogPublishingOptionsLogConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsElasticsearchDomainLogPublishingOptionsLogConfig] -> ShowS
$cshowList :: [AwsElasticsearchDomainLogPublishingOptionsLogConfig] -> ShowS
show :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> String
$cshow :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> String
showsPrec :: Int -> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> ShowS
$cshowsPrec :: Int -> AwsElasticsearchDomainLogPublishingOptionsLogConfig -> ShowS
Prelude.Show, (forall x.
 AwsElasticsearchDomainLogPublishingOptionsLogConfig
 -> Rep AwsElasticsearchDomainLogPublishingOptionsLogConfig x)
-> (forall x.
    Rep AwsElasticsearchDomainLogPublishingOptionsLogConfig x
    -> AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> Generic AwsElasticsearchDomainLogPublishingOptionsLogConfig
forall x.
Rep AwsElasticsearchDomainLogPublishingOptionsLogConfig x
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig
forall x.
AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> Rep AwsElasticsearchDomainLogPublishingOptionsLogConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsElasticsearchDomainLogPublishingOptionsLogConfig x
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig
$cfrom :: forall x.
AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> Rep AwsElasticsearchDomainLogPublishingOptionsLogConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsElasticsearchDomainLogPublishingOptionsLogConfig' 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:
--
-- 'enabled', 'awsElasticsearchDomainLogPublishingOptionsLogConfig_enabled' - Whether the log publishing is enabled.
--
-- 'cloudWatchLogsLogGroupArn', 'awsElasticsearchDomainLogPublishingOptionsLogConfig_cloudWatchLogsLogGroupArn' - The ARN of the CloudWatch Logs group to publish the logs to.
newAwsElasticsearchDomainLogPublishingOptionsLogConfig ::
  AwsElasticsearchDomainLogPublishingOptionsLogConfig
newAwsElasticsearchDomainLogPublishingOptionsLogConfig :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
newAwsElasticsearchDomainLogPublishingOptionsLogConfig =
  AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: Maybe Bool
-> Maybe Text
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig
AwsElasticsearchDomainLogPublishingOptionsLogConfig'
    { $sel:enabled:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: Maybe Bool
enabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchLogsLogGroupArn:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: Maybe Text
cloudWatchLogsLogGroupArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the log publishing is enabled.
awsElasticsearchDomainLogPublishingOptionsLogConfig_enabled :: Lens.Lens' AwsElasticsearchDomainLogPublishingOptionsLogConfig (Prelude.Maybe Prelude.Bool)
awsElasticsearchDomainLogPublishingOptionsLogConfig_enabled :: (Maybe Bool -> f (Maybe Bool))
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> f AwsElasticsearchDomainLogPublishingOptionsLogConfig
awsElasticsearchDomainLogPublishingOptionsLogConfig_enabled = (AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Bool)
-> (AwsElasticsearchDomainLogPublishingOptionsLogConfig
    -> Maybe Bool
    -> AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> Lens
     AwsElasticsearchDomainLogPublishingOptionsLogConfig
     AwsElasticsearchDomainLogPublishingOptionsLogConfig
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElasticsearchDomainLogPublishingOptionsLogConfig' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
s@AwsElasticsearchDomainLogPublishingOptionsLogConfig' {} Maybe Bool
a -> AwsElasticsearchDomainLogPublishingOptionsLogConfig
s {$sel:enabled:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: Maybe Bool
enabled = Maybe Bool
a} :: AwsElasticsearchDomainLogPublishingOptionsLogConfig)

-- | The ARN of the CloudWatch Logs group to publish the logs to.
awsElasticsearchDomainLogPublishingOptionsLogConfig_cloudWatchLogsLogGroupArn :: Lens.Lens' AwsElasticsearchDomainLogPublishingOptionsLogConfig (Prelude.Maybe Prelude.Text)
awsElasticsearchDomainLogPublishingOptionsLogConfig_cloudWatchLogsLogGroupArn :: (Maybe Text -> f (Maybe Text))
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig
-> f AwsElasticsearchDomainLogPublishingOptionsLogConfig
awsElasticsearchDomainLogPublishingOptionsLogConfig_cloudWatchLogsLogGroupArn = (AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Text)
-> (AwsElasticsearchDomainLogPublishingOptionsLogConfig
    -> Maybe Text
    -> AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> Lens
     AwsElasticsearchDomainLogPublishingOptionsLogConfig
     AwsElasticsearchDomainLogPublishingOptionsLogConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElasticsearchDomainLogPublishingOptionsLogConfig' {Maybe Text
cloudWatchLogsLogGroupArn :: Maybe Text
$sel:cloudWatchLogsLogGroupArn:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Text
cloudWatchLogsLogGroupArn} -> Maybe Text
cloudWatchLogsLogGroupArn) (\s :: AwsElasticsearchDomainLogPublishingOptionsLogConfig
s@AwsElasticsearchDomainLogPublishingOptionsLogConfig' {} Maybe Text
a -> AwsElasticsearchDomainLogPublishingOptionsLogConfig
s {$sel:cloudWatchLogsLogGroupArn:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: Maybe Text
cloudWatchLogsLogGroupArn = Maybe Text
a} :: AwsElasticsearchDomainLogPublishingOptionsLogConfig)

instance
  Core.FromJSON
    AwsElasticsearchDomainLogPublishingOptionsLogConfig
  where
  parseJSON :: Value -> Parser AwsElasticsearchDomainLogPublishingOptionsLogConfig
parseJSON =
    String
-> (Object
    -> Parser AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> Value
-> Parser AwsElasticsearchDomainLogPublishingOptionsLogConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsElasticsearchDomainLogPublishingOptionsLogConfig"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> AwsElasticsearchDomainLogPublishingOptionsLogConfig
AwsElasticsearchDomainLogPublishingOptionsLogConfig'
            (Maybe Bool
 -> Maybe Text
 -> AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text -> AwsElasticsearchDomainLogPublishingOptionsLogConfig)
forall (f :: * -> *) a b. Functor 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 -> AwsElasticsearchDomainLogPublishingOptionsLogConfig)
-> Parser (Maybe Text)
-> Parser AwsElasticsearchDomainLogPublishingOptionsLogConfig
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
"CloudWatchLogsLogGroupArn")
      )

instance
  Prelude.Hashable
    AwsElasticsearchDomainLogPublishingOptionsLogConfig

instance
  Prelude.NFData
    AwsElasticsearchDomainLogPublishingOptionsLogConfig

instance
  Core.ToJSON
    AwsElasticsearchDomainLogPublishingOptionsLogConfig
  where
  toJSON :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Value
toJSON
    AwsElasticsearchDomainLogPublishingOptionsLogConfig' {Maybe Bool
Maybe Text
cloudWatchLogsLogGroupArn :: Maybe Text
enabled :: Maybe Bool
$sel:cloudWatchLogsLogGroupArn:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Text
$sel:enabled:AwsElasticsearchDomainLogPublishingOptionsLogConfig' :: AwsElasticsearchDomainLogPublishingOptionsLogConfig -> Maybe Bool
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (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
"CloudWatchLogsLogGroupArn" 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
cloudWatchLogsLogGroupArn
            ]
        )