{-# 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.StepFunctions.Types.LogDestination
-- 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.StepFunctions.Types.LogDestination where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.StepFunctions.Types.CloudWatchLogsLogGroup

-- |
--
-- /See:/ 'newLogDestination' smart constructor.
data LogDestination = LogDestination'
  { -- | An object describing a CloudWatch log group. For more information, see
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html AWS::Logs::LogGroup>
    -- in the AWS CloudFormation User Guide.
    LogDestination -> Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup :: Prelude.Maybe CloudWatchLogsLogGroup
  }
  deriving (LogDestination -> LogDestination -> Bool
(LogDestination -> LogDestination -> Bool)
-> (LogDestination -> LogDestination -> Bool) -> Eq LogDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogDestination -> LogDestination -> Bool
$c/= :: LogDestination -> LogDestination -> Bool
== :: LogDestination -> LogDestination -> Bool
$c== :: LogDestination -> LogDestination -> Bool
Prelude.Eq, ReadPrec [LogDestination]
ReadPrec LogDestination
Int -> ReadS LogDestination
ReadS [LogDestination]
(Int -> ReadS LogDestination)
-> ReadS [LogDestination]
-> ReadPrec LogDestination
-> ReadPrec [LogDestination]
-> Read LogDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogDestination]
$creadListPrec :: ReadPrec [LogDestination]
readPrec :: ReadPrec LogDestination
$creadPrec :: ReadPrec LogDestination
readList :: ReadS [LogDestination]
$creadList :: ReadS [LogDestination]
readsPrec :: Int -> ReadS LogDestination
$creadsPrec :: Int -> ReadS LogDestination
Prelude.Read, Int -> LogDestination -> ShowS
[LogDestination] -> ShowS
LogDestination -> String
(Int -> LogDestination -> ShowS)
-> (LogDestination -> String)
-> ([LogDestination] -> ShowS)
-> Show LogDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogDestination] -> ShowS
$cshowList :: [LogDestination] -> ShowS
show :: LogDestination -> String
$cshow :: LogDestination -> String
showsPrec :: Int -> LogDestination -> ShowS
$cshowsPrec :: Int -> LogDestination -> ShowS
Prelude.Show, (forall x. LogDestination -> Rep LogDestination x)
-> (forall x. Rep LogDestination x -> LogDestination)
-> Generic LogDestination
forall x. Rep LogDestination x -> LogDestination
forall x. LogDestination -> Rep LogDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogDestination x -> LogDestination
$cfrom :: forall x. LogDestination -> Rep LogDestination x
Prelude.Generic)

-- |
-- Create a value of 'LogDestination' 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:
--
-- 'cloudWatchLogsLogGroup', 'logDestination_cloudWatchLogsLogGroup' - An object describing a CloudWatch log group. For more information, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html AWS::Logs::LogGroup>
-- in the AWS CloudFormation User Guide.
newLogDestination ::
  LogDestination
newLogDestination :: LogDestination
newLogDestination =
  LogDestination' :: Maybe CloudWatchLogsLogGroup -> LogDestination
LogDestination'
    { $sel:cloudWatchLogsLogGroup:LogDestination' :: Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup =
        Maybe CloudWatchLogsLogGroup
forall a. Maybe a
Prelude.Nothing
    }

-- | An object describing a CloudWatch log group. For more information, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html AWS::Logs::LogGroup>
-- in the AWS CloudFormation User Guide.
logDestination_cloudWatchLogsLogGroup :: Lens.Lens' LogDestination (Prelude.Maybe CloudWatchLogsLogGroup)
logDestination_cloudWatchLogsLogGroup :: (Maybe CloudWatchLogsLogGroup -> f (Maybe CloudWatchLogsLogGroup))
-> LogDestination -> f LogDestination
logDestination_cloudWatchLogsLogGroup = (LogDestination -> Maybe CloudWatchLogsLogGroup)
-> (LogDestination
    -> Maybe CloudWatchLogsLogGroup -> LogDestination)
-> Lens
     LogDestination
     LogDestination
     (Maybe CloudWatchLogsLogGroup)
     (Maybe CloudWatchLogsLogGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogDestination' {Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup :: Maybe CloudWatchLogsLogGroup
$sel:cloudWatchLogsLogGroup:LogDestination' :: LogDestination -> Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup} -> Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup) (\s :: LogDestination
s@LogDestination' {} Maybe CloudWatchLogsLogGroup
a -> LogDestination
s {$sel:cloudWatchLogsLogGroup:LogDestination' :: Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup = Maybe CloudWatchLogsLogGroup
a} :: LogDestination)

instance Core.FromJSON LogDestination where
  parseJSON :: Value -> Parser LogDestination
parseJSON =
    String
-> (Object -> Parser LogDestination)
-> Value
-> Parser LogDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogDestination"
      ( \Object
x ->
          Maybe CloudWatchLogsLogGroup -> LogDestination
LogDestination'
            (Maybe CloudWatchLogsLogGroup -> LogDestination)
-> Parser (Maybe CloudWatchLogsLogGroup) -> Parser LogDestination
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CloudWatchLogsLogGroup)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cloudWatchLogsLogGroup")
      )

instance Prelude.Hashable LogDestination

instance Prelude.NFData LogDestination

instance Core.ToJSON LogDestination where
  toJSON :: LogDestination -> Value
toJSON LogDestination' {Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup :: Maybe CloudWatchLogsLogGroup
$sel:cloudWatchLogsLogGroup:LogDestination' :: LogDestination -> Maybe CloudWatchLogsLogGroup
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"cloudWatchLogsLogGroup" Text -> CloudWatchLogsLogGroup -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CloudWatchLogsLogGroup -> Pair)
-> Maybe CloudWatchLogsLogGroup -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudWatchLogsLogGroup
cloudWatchLogsLogGroup
          ]
      )