{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.PinpointSMSVoice.Types.CloudWatchLogsDestination where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:iamRoleArn:CloudWatchLogsDestination' :: Maybe Text
iamRoleArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupArn:CloudWatchLogsDestination' :: Maybe Text
logGroupArn = 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 :: Lens' CloudWatchLogsDestination (Maybe Text)
cloudWatchLogsDestination_iamRoleArn = 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 :: Lens' CloudWatchLogsDestination (Maybe Text)
cloudWatchLogsDestination_logGroupArn = 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 Data.FromJSON CloudWatchLogsDestination where
  parseJSON :: Value -> Parser CloudWatchLogsDestination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CloudWatchLogsDestination"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> CloudWatchLogsDestination
CloudWatchLogsDestination'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IamRoleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LogGroupArn")
      )

instance Prelude.Hashable CloudWatchLogsDestination where
  hashWithSalt :: Int -> CloudWatchLogsDestination -> Int
hashWithSalt Int
_salt CloudWatchLogsDestination' {Maybe Text
logGroupArn :: Maybe Text
iamRoleArn :: Maybe Text
$sel:logGroupArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
$sel:iamRoleArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iamRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logGroupArn

instance Prelude.NFData CloudWatchLogsDestination where
  rnf :: CloudWatchLogsDestination -> ()
rnf CloudWatchLogsDestination' {Maybe Text
logGroupArn :: Maybe Text
iamRoleArn :: Maybe Text
$sel:logGroupArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
$sel:iamRoleArn:CloudWatchLogsDestination' :: CloudWatchLogsDestination -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iamRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logGroupArn

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IamRoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
iamRoleArn,
            (Key
"LogGroupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
logGroupArn
          ]
      )