{-# 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.KinesisAnalytics.Types.CloudWatchLoggingOption
-- 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.KinesisAnalytics.Types.CloudWatchLoggingOption 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

-- | Provides a description of CloudWatch logging options, including the log
-- stream Amazon Resource Name (ARN) and the role ARN.
--
-- /See:/ 'newCloudWatchLoggingOption' smart constructor.
data CloudWatchLoggingOption = CloudWatchLoggingOption'
  { -- | ARN of the CloudWatch log to receive application messages.
    CloudWatchLoggingOption -> Text
logStreamARN :: Prelude.Text,
    -- | IAM ARN of the role to use to send application messages. Note: To write
    -- application messages to CloudWatch, the IAM role that is used must have
    -- the @PutLogEvents@ policy action enabled.
    CloudWatchLoggingOption -> Text
roleARN :: Prelude.Text
  }
  deriving (CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool
$c/= :: CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool
== :: CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool
$c== :: CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool
Prelude.Eq, ReadPrec [CloudWatchLoggingOption]
ReadPrec CloudWatchLoggingOption
Int -> ReadS CloudWatchLoggingOption
ReadS [CloudWatchLoggingOption]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchLoggingOption]
$creadListPrec :: ReadPrec [CloudWatchLoggingOption]
readPrec :: ReadPrec CloudWatchLoggingOption
$creadPrec :: ReadPrec CloudWatchLoggingOption
readList :: ReadS [CloudWatchLoggingOption]
$creadList :: ReadS [CloudWatchLoggingOption]
readsPrec :: Int -> ReadS CloudWatchLoggingOption
$creadsPrec :: Int -> ReadS CloudWatchLoggingOption
Prelude.Read, Int -> CloudWatchLoggingOption -> ShowS
[CloudWatchLoggingOption] -> ShowS
CloudWatchLoggingOption -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchLoggingOption] -> ShowS
$cshowList :: [CloudWatchLoggingOption] -> ShowS
show :: CloudWatchLoggingOption -> String
$cshow :: CloudWatchLoggingOption -> String
showsPrec :: Int -> CloudWatchLoggingOption -> ShowS
$cshowsPrec :: Int -> CloudWatchLoggingOption -> ShowS
Prelude.Show, forall x. Rep CloudWatchLoggingOption x -> CloudWatchLoggingOption
forall x. CloudWatchLoggingOption -> Rep CloudWatchLoggingOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudWatchLoggingOption x -> CloudWatchLoggingOption
$cfrom :: forall x. CloudWatchLoggingOption -> Rep CloudWatchLoggingOption x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchLoggingOption' 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:
--
-- 'logStreamARN', 'cloudWatchLoggingOption_logStreamARN' - ARN of the CloudWatch log to receive application messages.
--
-- 'roleARN', 'cloudWatchLoggingOption_roleARN' - IAM ARN of the role to use to send application messages. Note: To write
-- application messages to CloudWatch, the IAM role that is used must have
-- the @PutLogEvents@ policy action enabled.
newCloudWatchLoggingOption ::
  -- | 'logStreamARN'
  Prelude.Text ->
  -- | 'roleARN'
  Prelude.Text ->
  CloudWatchLoggingOption
newCloudWatchLoggingOption :: Text -> Text -> CloudWatchLoggingOption
newCloudWatchLoggingOption Text
pLogStreamARN_ Text
pRoleARN_ =
  CloudWatchLoggingOption'
    { $sel:logStreamARN:CloudWatchLoggingOption' :: Text
logStreamARN =
        Text
pLogStreamARN_,
      $sel:roleARN:CloudWatchLoggingOption' :: Text
roleARN = Text
pRoleARN_
    }

-- | ARN of the CloudWatch log to receive application messages.
cloudWatchLoggingOption_logStreamARN :: Lens.Lens' CloudWatchLoggingOption Prelude.Text
cloudWatchLoggingOption_logStreamARN :: Lens' CloudWatchLoggingOption Text
cloudWatchLoggingOption_logStreamARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLoggingOption' {Text
logStreamARN :: Text
$sel:logStreamARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
logStreamARN} -> Text
logStreamARN) (\s :: CloudWatchLoggingOption
s@CloudWatchLoggingOption' {} Text
a -> CloudWatchLoggingOption
s {$sel:logStreamARN:CloudWatchLoggingOption' :: Text
logStreamARN = Text
a} :: CloudWatchLoggingOption)

-- | IAM ARN of the role to use to send application messages. Note: To write
-- application messages to CloudWatch, the IAM role that is used must have
-- the @PutLogEvents@ policy action enabled.
cloudWatchLoggingOption_roleARN :: Lens.Lens' CloudWatchLoggingOption Prelude.Text
cloudWatchLoggingOption_roleARN :: Lens' CloudWatchLoggingOption Text
cloudWatchLoggingOption_roleARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLoggingOption' {Text
roleARN :: Text
$sel:roleARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
roleARN} -> Text
roleARN) (\s :: CloudWatchLoggingOption
s@CloudWatchLoggingOption' {} Text
a -> CloudWatchLoggingOption
s {$sel:roleARN:CloudWatchLoggingOption' :: Text
roleARN = Text
a} :: CloudWatchLoggingOption)

instance Prelude.Hashable CloudWatchLoggingOption where
  hashWithSalt :: Int -> CloudWatchLoggingOption -> Int
hashWithSalt Int
_salt CloudWatchLoggingOption' {Text
roleARN :: Text
logStreamARN :: Text
$sel:roleARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
$sel:logStreamARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logStreamARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleARN

instance Prelude.NFData CloudWatchLoggingOption where
  rnf :: CloudWatchLoggingOption -> ()
rnf CloudWatchLoggingOption' {Text
roleARN :: Text
logStreamARN :: Text
$sel:roleARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
$sel:logStreamARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
logStreamARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleARN

instance Data.ToJSON CloudWatchLoggingOption where
  toJSON :: CloudWatchLoggingOption -> Value
toJSON CloudWatchLoggingOption' {Text
roleARN :: Text
logStreamARN :: Text
$sel:roleARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
$sel:logStreamARN:CloudWatchLoggingOption' :: CloudWatchLoggingOption -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"LogStreamARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logStreamARN),
            forall a. a -> Maybe a
Prelude.Just (Key
"RoleARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleARN)
          ]
      )