{-# 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.KafkaConnect.Types.WorkerLogDelivery
-- 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.KafkaConnect.Types.WorkerLogDelivery where

import qualified Amazonka.Core as Core
import Amazonka.KafkaConnect.Types.CloudWatchLogsLogDelivery
import Amazonka.KafkaConnect.Types.FirehoseLogDelivery
import Amazonka.KafkaConnect.Types.S3LogDelivery
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Workers can send worker logs to different destination types. This
-- configuration specifies the details of these destinations.
--
-- /See:/ 'newWorkerLogDelivery' smart constructor.
data WorkerLogDelivery = WorkerLogDelivery'
  { -- | Details about delivering logs to Amazon CloudWatch Logs.
    WorkerLogDelivery -> Maybe CloudWatchLogsLogDelivery
cloudWatchLogs :: Prelude.Maybe CloudWatchLogsLogDelivery,
    -- | Details about delivering logs to Amazon Kinesis Data Firehose.
    WorkerLogDelivery -> Maybe FirehoseLogDelivery
firehose :: Prelude.Maybe FirehoseLogDelivery,
    -- | Details about delivering logs to Amazon S3.
    WorkerLogDelivery -> Maybe S3LogDelivery
s3 :: Prelude.Maybe S3LogDelivery
  }
  deriving (WorkerLogDelivery -> WorkerLogDelivery -> Bool
(WorkerLogDelivery -> WorkerLogDelivery -> Bool)
-> (WorkerLogDelivery -> WorkerLogDelivery -> Bool)
-> Eq WorkerLogDelivery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkerLogDelivery -> WorkerLogDelivery -> Bool
$c/= :: WorkerLogDelivery -> WorkerLogDelivery -> Bool
== :: WorkerLogDelivery -> WorkerLogDelivery -> Bool
$c== :: WorkerLogDelivery -> WorkerLogDelivery -> Bool
Prelude.Eq, ReadPrec [WorkerLogDelivery]
ReadPrec WorkerLogDelivery
Int -> ReadS WorkerLogDelivery
ReadS [WorkerLogDelivery]
(Int -> ReadS WorkerLogDelivery)
-> ReadS [WorkerLogDelivery]
-> ReadPrec WorkerLogDelivery
-> ReadPrec [WorkerLogDelivery]
-> Read WorkerLogDelivery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkerLogDelivery]
$creadListPrec :: ReadPrec [WorkerLogDelivery]
readPrec :: ReadPrec WorkerLogDelivery
$creadPrec :: ReadPrec WorkerLogDelivery
readList :: ReadS [WorkerLogDelivery]
$creadList :: ReadS [WorkerLogDelivery]
readsPrec :: Int -> ReadS WorkerLogDelivery
$creadsPrec :: Int -> ReadS WorkerLogDelivery
Prelude.Read, Int -> WorkerLogDelivery -> ShowS
[WorkerLogDelivery] -> ShowS
WorkerLogDelivery -> String
(Int -> WorkerLogDelivery -> ShowS)
-> (WorkerLogDelivery -> String)
-> ([WorkerLogDelivery] -> ShowS)
-> Show WorkerLogDelivery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkerLogDelivery] -> ShowS
$cshowList :: [WorkerLogDelivery] -> ShowS
show :: WorkerLogDelivery -> String
$cshow :: WorkerLogDelivery -> String
showsPrec :: Int -> WorkerLogDelivery -> ShowS
$cshowsPrec :: Int -> WorkerLogDelivery -> ShowS
Prelude.Show, (forall x. WorkerLogDelivery -> Rep WorkerLogDelivery x)
-> (forall x. Rep WorkerLogDelivery x -> WorkerLogDelivery)
-> Generic WorkerLogDelivery
forall x. Rep WorkerLogDelivery x -> WorkerLogDelivery
forall x. WorkerLogDelivery -> Rep WorkerLogDelivery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkerLogDelivery x -> WorkerLogDelivery
$cfrom :: forall x. WorkerLogDelivery -> Rep WorkerLogDelivery x
Prelude.Generic)

-- |
-- Create a value of 'WorkerLogDelivery' 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:
--
-- 'cloudWatchLogs', 'workerLogDelivery_cloudWatchLogs' - Details about delivering logs to Amazon CloudWatch Logs.
--
-- 'firehose', 'workerLogDelivery_firehose' - Details about delivering logs to Amazon Kinesis Data Firehose.
--
-- 's3', 'workerLogDelivery_s3' - Details about delivering logs to Amazon S3.
newWorkerLogDelivery ::
  WorkerLogDelivery
newWorkerLogDelivery :: WorkerLogDelivery
newWorkerLogDelivery =
  WorkerLogDelivery' :: Maybe CloudWatchLogsLogDelivery
-> Maybe FirehoseLogDelivery
-> Maybe S3LogDelivery
-> WorkerLogDelivery
WorkerLogDelivery'
    { $sel:cloudWatchLogs:WorkerLogDelivery' :: Maybe CloudWatchLogsLogDelivery
cloudWatchLogs =
        Maybe CloudWatchLogsLogDelivery
forall a. Maybe a
Prelude.Nothing,
      $sel:firehose:WorkerLogDelivery' :: Maybe FirehoseLogDelivery
firehose = Maybe FirehoseLogDelivery
forall a. Maybe a
Prelude.Nothing,
      $sel:s3:WorkerLogDelivery' :: Maybe S3LogDelivery
s3 = Maybe S3LogDelivery
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about delivering logs to Amazon CloudWatch Logs.
workerLogDelivery_cloudWatchLogs :: Lens.Lens' WorkerLogDelivery (Prelude.Maybe CloudWatchLogsLogDelivery)
workerLogDelivery_cloudWatchLogs :: (Maybe CloudWatchLogsLogDelivery
 -> f (Maybe CloudWatchLogsLogDelivery))
-> WorkerLogDelivery -> f WorkerLogDelivery
workerLogDelivery_cloudWatchLogs = (WorkerLogDelivery -> Maybe CloudWatchLogsLogDelivery)
-> (WorkerLogDelivery
    -> Maybe CloudWatchLogsLogDelivery -> WorkerLogDelivery)
-> Lens
     WorkerLogDelivery
     WorkerLogDelivery
     (Maybe CloudWatchLogsLogDelivery)
     (Maybe CloudWatchLogsLogDelivery)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkerLogDelivery' {Maybe CloudWatchLogsLogDelivery
cloudWatchLogs :: Maybe CloudWatchLogsLogDelivery
$sel:cloudWatchLogs:WorkerLogDelivery' :: WorkerLogDelivery -> Maybe CloudWatchLogsLogDelivery
cloudWatchLogs} -> Maybe CloudWatchLogsLogDelivery
cloudWatchLogs) (\s :: WorkerLogDelivery
s@WorkerLogDelivery' {} Maybe CloudWatchLogsLogDelivery
a -> WorkerLogDelivery
s {$sel:cloudWatchLogs:WorkerLogDelivery' :: Maybe CloudWatchLogsLogDelivery
cloudWatchLogs = Maybe CloudWatchLogsLogDelivery
a} :: WorkerLogDelivery)

-- | Details about delivering logs to Amazon Kinesis Data Firehose.
workerLogDelivery_firehose :: Lens.Lens' WorkerLogDelivery (Prelude.Maybe FirehoseLogDelivery)
workerLogDelivery_firehose :: (Maybe FirehoseLogDelivery -> f (Maybe FirehoseLogDelivery))
-> WorkerLogDelivery -> f WorkerLogDelivery
workerLogDelivery_firehose = (WorkerLogDelivery -> Maybe FirehoseLogDelivery)
-> (WorkerLogDelivery
    -> Maybe FirehoseLogDelivery -> WorkerLogDelivery)
-> Lens
     WorkerLogDelivery
     WorkerLogDelivery
     (Maybe FirehoseLogDelivery)
     (Maybe FirehoseLogDelivery)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkerLogDelivery' {Maybe FirehoseLogDelivery
firehose :: Maybe FirehoseLogDelivery
$sel:firehose:WorkerLogDelivery' :: WorkerLogDelivery -> Maybe FirehoseLogDelivery
firehose} -> Maybe FirehoseLogDelivery
firehose) (\s :: WorkerLogDelivery
s@WorkerLogDelivery' {} Maybe FirehoseLogDelivery
a -> WorkerLogDelivery
s {$sel:firehose:WorkerLogDelivery' :: Maybe FirehoseLogDelivery
firehose = Maybe FirehoseLogDelivery
a} :: WorkerLogDelivery)

-- | Details about delivering logs to Amazon S3.
workerLogDelivery_s3 :: Lens.Lens' WorkerLogDelivery (Prelude.Maybe S3LogDelivery)
workerLogDelivery_s3 :: (Maybe S3LogDelivery -> f (Maybe S3LogDelivery))
-> WorkerLogDelivery -> f WorkerLogDelivery
workerLogDelivery_s3 = (WorkerLogDelivery -> Maybe S3LogDelivery)
-> (WorkerLogDelivery -> Maybe S3LogDelivery -> WorkerLogDelivery)
-> Lens
     WorkerLogDelivery
     WorkerLogDelivery
     (Maybe S3LogDelivery)
     (Maybe S3LogDelivery)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkerLogDelivery' {Maybe S3LogDelivery
s3 :: Maybe S3LogDelivery
$sel:s3:WorkerLogDelivery' :: WorkerLogDelivery -> Maybe S3LogDelivery
s3} -> Maybe S3LogDelivery
s3) (\s :: WorkerLogDelivery
s@WorkerLogDelivery' {} Maybe S3LogDelivery
a -> WorkerLogDelivery
s {$sel:s3:WorkerLogDelivery' :: Maybe S3LogDelivery
s3 = Maybe S3LogDelivery
a} :: WorkerLogDelivery)

instance Prelude.Hashable WorkerLogDelivery

instance Prelude.NFData WorkerLogDelivery

instance Core.ToJSON WorkerLogDelivery where
  toJSON :: WorkerLogDelivery -> Value
toJSON WorkerLogDelivery' {Maybe CloudWatchLogsLogDelivery
Maybe FirehoseLogDelivery
Maybe S3LogDelivery
s3 :: Maybe S3LogDelivery
firehose :: Maybe FirehoseLogDelivery
cloudWatchLogs :: Maybe CloudWatchLogsLogDelivery
$sel:s3:WorkerLogDelivery' :: WorkerLogDelivery -> Maybe S3LogDelivery
$sel:firehose:WorkerLogDelivery' :: WorkerLogDelivery -> Maybe FirehoseLogDelivery
$sel:cloudWatchLogs:WorkerLogDelivery' :: WorkerLogDelivery -> Maybe CloudWatchLogsLogDelivery
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"cloudWatchLogs" Text -> CloudWatchLogsLogDelivery -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CloudWatchLogsLogDelivery -> Pair)
-> Maybe CloudWatchLogsLogDelivery -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudWatchLogsLogDelivery
cloudWatchLogs,
            (Text
"firehose" Text -> FirehoseLogDelivery -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FirehoseLogDelivery -> Pair)
-> Maybe FirehoseLogDelivery -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FirehoseLogDelivery
firehose,
            (Text
"s3" Text -> S3LogDelivery -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3LogDelivery -> Pair) -> Maybe S3LogDelivery -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3LogDelivery
s3
          ]
      )