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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool)
-> (CloudWatchLoggingOption -> CloudWatchLoggingOption -> Bool)
-> Eq CloudWatchLoggingOption
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]
(Int -> ReadS CloudWatchLoggingOption)
-> ReadS [CloudWatchLoggingOption]
-> ReadPrec CloudWatchLoggingOption
-> ReadPrec [CloudWatchLoggingOption]
-> Read 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
(Int -> CloudWatchLoggingOption -> ShowS)
-> (CloudWatchLoggingOption -> String)
-> ([CloudWatchLoggingOption] -> ShowS)
-> Show CloudWatchLoggingOption
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.
 CloudWatchLoggingOption -> Rep CloudWatchLoggingOption x)
-> (forall x.
    Rep CloudWatchLoggingOption x -> CloudWatchLoggingOption)
-> Generic CloudWatchLoggingOption
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' :: Text -> Text -> CloudWatchLoggingOption
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 :: (Text -> f Text)
-> CloudWatchLoggingOption -> f CloudWatchLoggingOption
cloudWatchLoggingOption_logStreamARN = (CloudWatchLoggingOption -> Text)
-> (CloudWatchLoggingOption -> Text -> CloudWatchLoggingOption)
-> Lens CloudWatchLoggingOption CloudWatchLoggingOption Text Text
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 :: (Text -> f Text)
-> CloudWatchLoggingOption -> f CloudWatchLoggingOption
cloudWatchLoggingOption_roleARN = (CloudWatchLoggingOption -> Text)
-> (CloudWatchLoggingOption -> Text -> CloudWatchLoggingOption)
-> Lens CloudWatchLoggingOption CloudWatchLoggingOption Text Text
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

instance Prelude.NFData CloudWatchLoggingOption

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LogStreamARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logStreamARN),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleARN)
          ]
      )