{-# 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.PinpointSMSVoice.Types.CloudWatchLogsDestination
-- 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.PinpointSMSVoice.Types.CloudWatchLogsDestination where

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

-- | An object that contains information about an event destination that
-- sends data to Amazon CloudWatch Logs.
--
-- /See:/ 'newCloudWatchLogsDestination' smart constructor.
data CloudWatchLogsDestination = CloudWatchLogsDestination'
  { -- | The Amazon Resource Name (ARN) of an Amazon Identity and Access
    -- Management (IAM) role that is able to write event data to an Amazon
    -- CloudWatch destination.
    CloudWatchLogsDestination -> Maybe Text
iamRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon CloudWatch Log Group that you want to record
    -- events in.
    CloudWatchLogsDestination -> Maybe Text
logGroupArn :: Prelude.Maybe Prelude.Text
  }
  deriving (CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool
(CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool)
-> (CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool)
-> Eq CloudWatchLogsDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool
$c/= :: CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool
== :: CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool
$c== :: CloudWatchLogsDestination -> CloudWatchLogsDestination -> Bool
Prelude.Eq, ReadPrec [CloudWatchLogsDestination]
ReadPrec CloudWatchLogsDestination
Int -> ReadS CloudWatchLogsDestination
ReadS [CloudWatchLogsDestination]
(Int -> ReadS CloudWatchLogsDestination)
-> ReadS [CloudWatchLogsDestination]
-> ReadPrec CloudWatchLogsDestination
-> ReadPrec [CloudWatchLogsDestination]
-> Read CloudWatchLogsDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchLogsDestination]
$creadListPrec :: ReadPrec [CloudWatchLogsDestination]
readPrec :: ReadPrec CloudWatchLogsDestination
$creadPrec :: ReadPrec CloudWatchLogsDestination
readList :: ReadS [CloudWatchLogsDestination]
$creadList :: ReadS [CloudWatchLogsDestination]
readsPrec :: Int -> ReadS CloudWatchLogsDestination
$creadsPrec :: Int -> ReadS CloudWatchLogsDestination
Prelude.Read, Int -> CloudWatchLogsDestination -> ShowS
[CloudWatchLogsDestination] -> ShowS
CloudWatchLogsDestination -> String
(Int -> CloudWatchLogsDestination -> ShowS)
-> (CloudWatchLogsDestination -> String)
-> ([CloudWatchLogsDestination] -> ShowS)
-> Show CloudWatchLogsDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchLogsDestination] -> ShowS
$cshowList :: [CloudWatchLogsDestination] -> ShowS
show :: CloudWatchLogsDestination -> String
$cshow :: CloudWatchLogsDestination -> String
showsPrec :: Int -> CloudWatchLogsDestination -> ShowS
$cshowsPrec :: Int -> CloudWatchLogsDestination -> ShowS
Prelude.Show, (forall x.
 CloudWatchLogsDestination -> Rep CloudWatchLogsDestination x)
-> (forall x.
    Rep CloudWatchLogsDestination x -> CloudWatchLogsDestination)
-> Generic CloudWatchLogsDestination
forall x.
Rep CloudWatchLogsDestination x -> CloudWatchLogsDestination
forall x.
CloudWatchLogsDestination -> Rep CloudWatchLogsDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudWatchLogsDestination x -> CloudWatchLogsDestination
$cfrom :: forall x.
CloudWatchLogsDestination -> Rep CloudWatchLogsDestination x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchLogsDestination' 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:
--
-- 'iamRoleArn', 'cloudWatchLogsDestination_iamRoleArn' - The Amazon Resource Name (ARN) of an Amazon Identity and Access
-- Management (IAM) role that is able to write event data to an Amazon
-- CloudWatch destination.
--
-- 'logGroupArn', 'cloudWatchLogsDestination_logGroupArn' - The name of the Amazon CloudWatch Log Group that you want to record
-- events in.
newCloudWatchLogsDestination ::
  CloudWatchLogsDestination
newCloudWatchLogsDestination :: CloudWatchLogsDestination
newCloudWatchLogsDestination =
  CloudWatchLogsDestination' :: Maybe Text -> Maybe Text -> CloudWatchLogsDestination
CloudWatchLogsDestination'
    { $sel:iamRoleArn:CloudWatchLogsDestination' :: Maybe Text
iamRoleArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupArn:CloudWatchLogsDestination' :: Maybe Text
logGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of an Amazon Identity and Access
-- Management (IAM) role that is able to write event data to an Amazon
-- CloudWatch destination.
cloudWatchLogsDestination_iamRoleArn :: Lens.Lens' CloudWatchLogsDestination (Prelude.Maybe Prelude.Text)
cloudWatchLogsDestination_iamRoleArn :: (Maybe Text -> f (Maybe Text))
-> CloudWatchLogsDestination -> f CloudWatchLogsDestination
cloudWatchLogsDestination_iamRoleArn = (CloudWatchLogsDestination -> Maybe Text)
-> (CloudWatchLogsDestination
    -> Maybe Text -> CloudWatchLogsDestination)
-> Lens
     CloudWatchLogsDestination
     CloudWatchLogsDestination
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogsDestination' {Maybe Text
iamRoleArn :: Maybe Text
$sel:iamRoleArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
iamRoleArn} -> Maybe Text
iamRoleArn) (\s :: CloudWatchLogsDestination
s@CloudWatchLogsDestination' {} Maybe Text
a -> CloudWatchLogsDestination
s {$sel:iamRoleArn:CloudWatchLogsDestination' :: Maybe Text
iamRoleArn = Maybe Text
a} :: CloudWatchLogsDestination)

-- | The name of the Amazon CloudWatch Log Group that you want to record
-- events in.
cloudWatchLogsDestination_logGroupArn :: Lens.Lens' CloudWatchLogsDestination (Prelude.Maybe Prelude.Text)
cloudWatchLogsDestination_logGroupArn :: (Maybe Text -> f (Maybe Text))
-> CloudWatchLogsDestination -> f CloudWatchLogsDestination
cloudWatchLogsDestination_logGroupArn = (CloudWatchLogsDestination -> Maybe Text)
-> (CloudWatchLogsDestination
    -> Maybe Text -> CloudWatchLogsDestination)
-> Lens
     CloudWatchLogsDestination
     CloudWatchLogsDestination
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogsDestination' {Maybe Text
logGroupArn :: Maybe Text
$sel:logGroupArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
logGroupArn} -> Maybe Text
logGroupArn) (\s :: CloudWatchLogsDestination
s@CloudWatchLogsDestination' {} Maybe Text
a -> CloudWatchLogsDestination
s {$sel:logGroupArn:CloudWatchLogsDestination' :: Maybe Text
logGroupArn = Maybe Text
a} :: CloudWatchLogsDestination)

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

instance Prelude.Hashable CloudWatchLogsDestination

instance Prelude.NFData CloudWatchLogsDestination

instance Core.ToJSON CloudWatchLogsDestination where
  toJSON :: CloudWatchLogsDestination -> Value
toJSON CloudWatchLogsDestination' {Maybe Text
logGroupArn :: Maybe Text
iamRoleArn :: Maybe Text
$sel:logGroupArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
$sel:iamRoleArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IamRoleArn" 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
iamRoleArn,
            (Text
"LogGroupArn" 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
logGroupArn
          ]
      )