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

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

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

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

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

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

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

instance
  Prelude.NFData
    AwsOpenSearchServiceDomainLogPublishingOption

instance
  Core.ToJSON
    AwsOpenSearchServiceDomainLogPublishingOption
  where
  toJSON :: AwsOpenSearchServiceDomainLogPublishingOption -> Value
toJSON
    AwsOpenSearchServiceDomainLogPublishingOption' {Maybe Bool
Maybe Text
cloudWatchLogsLogGroupArn :: Maybe Text
enabled :: Maybe Bool
$sel:cloudWatchLogsLogGroupArn:AwsOpenSearchServiceDomainLogPublishingOption' :: AwsOpenSearchServiceDomainLogPublishingOption -> Maybe Text
$sel:enabled:AwsOpenSearchServiceDomainLogPublishingOption' :: AwsOpenSearchServiceDomainLogPublishingOption -> 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
            ]
        )