{-# 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.ElastiCache.Types.LogDeliveryConfiguration
-- 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.ElastiCache.Types.LogDeliveryConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types.DestinationDetails
import Amazonka.ElastiCache.Types.DestinationType
import Amazonka.ElastiCache.Types.LogDeliveryConfigurationStatus
import Amazonka.ElastiCache.Types.LogFormat
import Amazonka.ElastiCache.Types.LogType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns the destination, format and type of the logs.
--
-- /See:/ 'newLogDeliveryConfiguration' smart constructor.
data LogDeliveryConfiguration = LogDeliveryConfiguration'
  { -- | Returns the log delivery configuration status. Values are one of
    -- @enabling@ | @disabling@ | @modifying@ | @active@ | @error@
    LogDeliveryConfiguration -> Maybe LogDeliveryConfigurationStatus
status :: Prelude.Maybe LogDeliveryConfigurationStatus,
    -- | Returns the log format, either JSON or TEXT.
    LogDeliveryConfiguration -> Maybe LogFormat
logFormat :: Prelude.Maybe LogFormat,
    -- | Configuration details of either a CloudWatch Logs destination or Kinesis
    -- Data Firehose destination.
    LogDeliveryConfiguration -> Maybe DestinationDetails
destinationDetails :: Prelude.Maybe DestinationDetails,
    -- | Refers to <https://redis.io/commands/slowlog slow-log>.
    LogDeliveryConfiguration -> Maybe LogType
logType :: Prelude.Maybe LogType,
    -- | Returns the destination type, either @cloudwatch-logs@ or
    -- @kinesis-firehose@.
    LogDeliveryConfiguration -> Maybe DestinationType
destinationType :: Prelude.Maybe DestinationType,
    -- | Returns an error message for the log delivery configuration.
    LogDeliveryConfiguration -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool
(LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool)
-> (LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool)
-> Eq LogDeliveryConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool
$c/= :: LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool
== :: LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool
$c== :: LogDeliveryConfiguration -> LogDeliveryConfiguration -> Bool
Prelude.Eq, ReadPrec [LogDeliveryConfiguration]
ReadPrec LogDeliveryConfiguration
Int -> ReadS LogDeliveryConfiguration
ReadS [LogDeliveryConfiguration]
(Int -> ReadS LogDeliveryConfiguration)
-> ReadS [LogDeliveryConfiguration]
-> ReadPrec LogDeliveryConfiguration
-> ReadPrec [LogDeliveryConfiguration]
-> Read LogDeliveryConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogDeliveryConfiguration]
$creadListPrec :: ReadPrec [LogDeliveryConfiguration]
readPrec :: ReadPrec LogDeliveryConfiguration
$creadPrec :: ReadPrec LogDeliveryConfiguration
readList :: ReadS [LogDeliveryConfiguration]
$creadList :: ReadS [LogDeliveryConfiguration]
readsPrec :: Int -> ReadS LogDeliveryConfiguration
$creadsPrec :: Int -> ReadS LogDeliveryConfiguration
Prelude.Read, Int -> LogDeliveryConfiguration -> ShowS
[LogDeliveryConfiguration] -> ShowS
LogDeliveryConfiguration -> String
(Int -> LogDeliveryConfiguration -> ShowS)
-> (LogDeliveryConfiguration -> String)
-> ([LogDeliveryConfiguration] -> ShowS)
-> Show LogDeliveryConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogDeliveryConfiguration] -> ShowS
$cshowList :: [LogDeliveryConfiguration] -> ShowS
show :: LogDeliveryConfiguration -> String
$cshow :: LogDeliveryConfiguration -> String
showsPrec :: Int -> LogDeliveryConfiguration -> ShowS
$cshowsPrec :: Int -> LogDeliveryConfiguration -> ShowS
Prelude.Show, (forall x.
 LogDeliveryConfiguration -> Rep LogDeliveryConfiguration x)
-> (forall x.
    Rep LogDeliveryConfiguration x -> LogDeliveryConfiguration)
-> Generic LogDeliveryConfiguration
forall x.
Rep LogDeliveryConfiguration x -> LogDeliveryConfiguration
forall x.
LogDeliveryConfiguration -> Rep LogDeliveryConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LogDeliveryConfiguration x -> LogDeliveryConfiguration
$cfrom :: forall x.
LogDeliveryConfiguration -> Rep LogDeliveryConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LogDeliveryConfiguration' 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:
--
-- 'status', 'logDeliveryConfiguration_status' - Returns the log delivery configuration status. Values are one of
-- @enabling@ | @disabling@ | @modifying@ | @active@ | @error@
--
-- 'logFormat', 'logDeliveryConfiguration_logFormat' - Returns the log format, either JSON or TEXT.
--
-- 'destinationDetails', 'logDeliveryConfiguration_destinationDetails' - Configuration details of either a CloudWatch Logs destination or Kinesis
-- Data Firehose destination.
--
-- 'logType', 'logDeliveryConfiguration_logType' - Refers to <https://redis.io/commands/slowlog slow-log>.
--
-- 'destinationType', 'logDeliveryConfiguration_destinationType' - Returns the destination type, either @cloudwatch-logs@ or
-- @kinesis-firehose@.
--
-- 'message', 'logDeliveryConfiguration_message' - Returns an error message for the log delivery configuration.
newLogDeliveryConfiguration ::
  LogDeliveryConfiguration
newLogDeliveryConfiguration :: LogDeliveryConfiguration
newLogDeliveryConfiguration =
  LogDeliveryConfiguration' :: Maybe LogDeliveryConfigurationStatus
-> Maybe LogFormat
-> Maybe DestinationDetails
-> Maybe LogType
-> Maybe DestinationType
-> Maybe Text
-> LogDeliveryConfiguration
LogDeliveryConfiguration'
    { $sel:status:LogDeliveryConfiguration' :: Maybe LogDeliveryConfigurationStatus
status = Maybe LogDeliveryConfigurationStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:logFormat:LogDeliveryConfiguration' :: Maybe LogFormat
logFormat = Maybe LogFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationDetails:LogDeliveryConfiguration' :: Maybe DestinationDetails
destinationDetails = Maybe DestinationDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:logType:LogDeliveryConfiguration' :: Maybe LogType
logType = Maybe LogType
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationType:LogDeliveryConfiguration' :: Maybe DestinationType
destinationType = Maybe DestinationType
forall a. Maybe a
Prelude.Nothing,
      $sel:message:LogDeliveryConfiguration' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Returns the log delivery configuration status. Values are one of
-- @enabling@ | @disabling@ | @modifying@ | @active@ | @error@
logDeliveryConfiguration_status :: Lens.Lens' LogDeliveryConfiguration (Prelude.Maybe LogDeliveryConfigurationStatus)
logDeliveryConfiguration_status :: (Maybe LogDeliveryConfigurationStatus
 -> f (Maybe LogDeliveryConfigurationStatus))
-> LogDeliveryConfiguration -> f LogDeliveryConfiguration
logDeliveryConfiguration_status = (LogDeliveryConfiguration -> Maybe LogDeliveryConfigurationStatus)
-> (LogDeliveryConfiguration
    -> Maybe LogDeliveryConfigurationStatus
    -> LogDeliveryConfiguration)
-> Lens
     LogDeliveryConfiguration
     LogDeliveryConfiguration
     (Maybe LogDeliveryConfigurationStatus)
     (Maybe LogDeliveryConfigurationStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDeliveryConfiguration' {Maybe LogDeliveryConfigurationStatus
status :: Maybe LogDeliveryConfigurationStatus
$sel:status:LogDeliveryConfiguration' :: LogDeliveryConfiguration -> Maybe LogDeliveryConfigurationStatus
status} -> Maybe LogDeliveryConfigurationStatus
status) (\s :: LogDeliveryConfiguration
s@LogDeliveryConfiguration' {} Maybe LogDeliveryConfigurationStatus
a -> LogDeliveryConfiguration
s {$sel:status:LogDeliveryConfiguration' :: Maybe LogDeliveryConfigurationStatus
status = Maybe LogDeliveryConfigurationStatus
a} :: LogDeliveryConfiguration)

-- | Returns the log format, either JSON or TEXT.
logDeliveryConfiguration_logFormat :: Lens.Lens' LogDeliveryConfiguration (Prelude.Maybe LogFormat)
logDeliveryConfiguration_logFormat :: (Maybe LogFormat -> f (Maybe LogFormat))
-> LogDeliveryConfiguration -> f LogDeliveryConfiguration
logDeliveryConfiguration_logFormat = (LogDeliveryConfiguration -> Maybe LogFormat)
-> (LogDeliveryConfiguration
    -> Maybe LogFormat -> LogDeliveryConfiguration)
-> Lens
     LogDeliveryConfiguration
     LogDeliveryConfiguration
     (Maybe LogFormat)
     (Maybe LogFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDeliveryConfiguration' {Maybe LogFormat
logFormat :: Maybe LogFormat
$sel:logFormat:LogDeliveryConfiguration' :: LogDeliveryConfiguration -> Maybe LogFormat
logFormat} -> Maybe LogFormat
logFormat) (\s :: LogDeliveryConfiguration
s@LogDeliveryConfiguration' {} Maybe LogFormat
a -> LogDeliveryConfiguration
s {$sel:logFormat:LogDeliveryConfiguration' :: Maybe LogFormat
logFormat = Maybe LogFormat
a} :: LogDeliveryConfiguration)

-- | Configuration details of either a CloudWatch Logs destination or Kinesis
-- Data Firehose destination.
logDeliveryConfiguration_destinationDetails :: Lens.Lens' LogDeliveryConfiguration (Prelude.Maybe DestinationDetails)
logDeliveryConfiguration_destinationDetails :: (Maybe DestinationDetails -> f (Maybe DestinationDetails))
-> LogDeliveryConfiguration -> f LogDeliveryConfiguration
logDeliveryConfiguration_destinationDetails = (LogDeliveryConfiguration -> Maybe DestinationDetails)
-> (LogDeliveryConfiguration
    -> Maybe DestinationDetails -> LogDeliveryConfiguration)
-> Lens
     LogDeliveryConfiguration
     LogDeliveryConfiguration
     (Maybe DestinationDetails)
     (Maybe DestinationDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDeliveryConfiguration' {Maybe DestinationDetails
destinationDetails :: Maybe DestinationDetails
$sel:destinationDetails:LogDeliveryConfiguration' :: LogDeliveryConfiguration -> Maybe DestinationDetails
destinationDetails} -> Maybe DestinationDetails
destinationDetails) (\s :: LogDeliveryConfiguration
s@LogDeliveryConfiguration' {} Maybe DestinationDetails
a -> LogDeliveryConfiguration
s {$sel:destinationDetails:LogDeliveryConfiguration' :: Maybe DestinationDetails
destinationDetails = Maybe DestinationDetails
a} :: LogDeliveryConfiguration)

-- | Refers to <https://redis.io/commands/slowlog slow-log>.
logDeliveryConfiguration_logType :: Lens.Lens' LogDeliveryConfiguration (Prelude.Maybe LogType)
logDeliveryConfiguration_logType :: (Maybe LogType -> f (Maybe LogType))
-> LogDeliveryConfiguration -> f LogDeliveryConfiguration
logDeliveryConfiguration_logType = (LogDeliveryConfiguration -> Maybe LogType)
-> (LogDeliveryConfiguration
    -> Maybe LogType -> LogDeliveryConfiguration)
-> Lens
     LogDeliveryConfiguration
     LogDeliveryConfiguration
     (Maybe LogType)
     (Maybe LogType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDeliveryConfiguration' {Maybe LogType
logType :: Maybe LogType
$sel:logType:LogDeliveryConfiguration' :: LogDeliveryConfiguration -> Maybe LogType
logType} -> Maybe LogType
logType) (\s :: LogDeliveryConfiguration
s@LogDeliveryConfiguration' {} Maybe LogType
a -> LogDeliveryConfiguration
s {$sel:logType:LogDeliveryConfiguration' :: Maybe LogType
logType = Maybe LogType
a} :: LogDeliveryConfiguration)

-- | Returns the destination type, either @cloudwatch-logs@ or
-- @kinesis-firehose@.
logDeliveryConfiguration_destinationType :: Lens.Lens' LogDeliveryConfiguration (Prelude.Maybe DestinationType)
logDeliveryConfiguration_destinationType :: (Maybe DestinationType -> f (Maybe DestinationType))
-> LogDeliveryConfiguration -> f LogDeliveryConfiguration
logDeliveryConfiguration_destinationType = (LogDeliveryConfiguration -> Maybe DestinationType)
-> (LogDeliveryConfiguration
    -> Maybe DestinationType -> LogDeliveryConfiguration)
-> Lens
     LogDeliveryConfiguration
     LogDeliveryConfiguration
     (Maybe DestinationType)
     (Maybe DestinationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDeliveryConfiguration' {Maybe DestinationType
destinationType :: Maybe DestinationType
$sel:destinationType:LogDeliveryConfiguration' :: LogDeliveryConfiguration -> Maybe DestinationType
destinationType} -> Maybe DestinationType
destinationType) (\s :: LogDeliveryConfiguration
s@LogDeliveryConfiguration' {} Maybe DestinationType
a -> LogDeliveryConfiguration
s {$sel:destinationType:LogDeliveryConfiguration' :: Maybe DestinationType
destinationType = Maybe DestinationType
a} :: LogDeliveryConfiguration)

-- | Returns an error message for the log delivery configuration.
logDeliveryConfiguration_message :: Lens.Lens' LogDeliveryConfiguration (Prelude.Maybe Prelude.Text)
logDeliveryConfiguration_message :: (Maybe Text -> f (Maybe Text))
-> LogDeliveryConfiguration -> f LogDeliveryConfiguration
logDeliveryConfiguration_message = (LogDeliveryConfiguration -> Maybe Text)
-> (LogDeliveryConfiguration
    -> Maybe Text -> LogDeliveryConfiguration)
-> Lens
     LogDeliveryConfiguration
     LogDeliveryConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDeliveryConfiguration' {Maybe Text
message :: Maybe Text
$sel:message:LogDeliveryConfiguration' :: LogDeliveryConfiguration -> Maybe Text
message} -> Maybe Text
message) (\s :: LogDeliveryConfiguration
s@LogDeliveryConfiguration' {} Maybe Text
a -> LogDeliveryConfiguration
s {$sel:message:LogDeliveryConfiguration' :: Maybe Text
message = Maybe Text
a} :: LogDeliveryConfiguration)

instance Core.FromXML LogDeliveryConfiguration where
  parseXML :: [Node] -> Either String LogDeliveryConfiguration
parseXML [Node]
x =
    Maybe LogDeliveryConfigurationStatus
-> Maybe LogFormat
-> Maybe DestinationDetails
-> Maybe LogType
-> Maybe DestinationType
-> Maybe Text
-> LogDeliveryConfiguration
LogDeliveryConfiguration'
      (Maybe LogDeliveryConfigurationStatus
 -> Maybe LogFormat
 -> Maybe DestinationDetails
 -> Maybe LogType
 -> Maybe DestinationType
 -> Maybe Text
 -> LogDeliveryConfiguration)
-> Either String (Maybe LogDeliveryConfigurationStatus)
-> Either
     String
     (Maybe LogFormat
      -> Maybe DestinationDetails
      -> Maybe LogType
      -> Maybe DestinationType
      -> Maybe Text
      -> LogDeliveryConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node]
-> Text -> Either String (Maybe LogDeliveryConfigurationStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either
  String
  (Maybe LogFormat
   -> Maybe DestinationDetails
   -> Maybe LogType
   -> Maybe DestinationType
   -> Maybe Text
   -> LogDeliveryConfiguration)
-> Either String (Maybe LogFormat)
-> Either
     String
     (Maybe DestinationDetails
      -> Maybe LogType
      -> Maybe DestinationType
      -> Maybe Text
      -> LogDeliveryConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe LogFormat)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LogFormat")
      Either
  String
  (Maybe DestinationDetails
   -> Maybe LogType
   -> Maybe DestinationType
   -> Maybe Text
   -> LogDeliveryConfiguration)
-> Either String (Maybe DestinationDetails)
-> Either
     String
     (Maybe LogType
      -> Maybe DestinationType -> Maybe Text -> LogDeliveryConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe DestinationDetails)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DestinationDetails")
      Either
  String
  (Maybe LogType
   -> Maybe DestinationType -> Maybe Text -> LogDeliveryConfiguration)
-> Either String (Maybe LogType)
-> Either
     String
     (Maybe DestinationType -> Maybe Text -> LogDeliveryConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe LogType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LogType")
      Either
  String
  (Maybe DestinationType -> Maybe Text -> LogDeliveryConfiguration)
-> Either String (Maybe DestinationType)
-> Either String (Maybe Text -> LogDeliveryConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe DestinationType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DestinationType")
      Either String (Maybe Text -> LogDeliveryConfiguration)
-> Either String (Maybe Text)
-> Either String LogDeliveryConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Message")

instance Prelude.Hashable LogDeliveryConfiguration

instance Prelude.NFData LogDeliveryConfiguration