{-# 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.IoT.Types.AuditNotificationTarget
-- 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.IoT.Types.AuditNotificationTarget where

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

-- | Information about the targets to which audit notifications are sent.
--
-- /See:/ 'newAuditNotificationTarget' smart constructor.
data AuditNotificationTarget = AuditNotificationTarget'
  { -- | The ARN of the target (SNS topic) to which audit notifications are sent.
    AuditNotificationTarget -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text,
    -- | True if notifications to the target are enabled.
    AuditNotificationTarget -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The ARN of the role that grants permission to send notifications to the
    -- target.
    AuditNotificationTarget -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AuditNotificationTarget -> AuditNotificationTarget -> Bool
(AuditNotificationTarget -> AuditNotificationTarget -> Bool)
-> (AuditNotificationTarget -> AuditNotificationTarget -> Bool)
-> Eq AuditNotificationTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuditNotificationTarget -> AuditNotificationTarget -> Bool
$c/= :: AuditNotificationTarget -> AuditNotificationTarget -> Bool
== :: AuditNotificationTarget -> AuditNotificationTarget -> Bool
$c== :: AuditNotificationTarget -> AuditNotificationTarget -> Bool
Prelude.Eq, ReadPrec [AuditNotificationTarget]
ReadPrec AuditNotificationTarget
Int -> ReadS AuditNotificationTarget
ReadS [AuditNotificationTarget]
(Int -> ReadS AuditNotificationTarget)
-> ReadS [AuditNotificationTarget]
-> ReadPrec AuditNotificationTarget
-> ReadPrec [AuditNotificationTarget]
-> Read AuditNotificationTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuditNotificationTarget]
$creadListPrec :: ReadPrec [AuditNotificationTarget]
readPrec :: ReadPrec AuditNotificationTarget
$creadPrec :: ReadPrec AuditNotificationTarget
readList :: ReadS [AuditNotificationTarget]
$creadList :: ReadS [AuditNotificationTarget]
readsPrec :: Int -> ReadS AuditNotificationTarget
$creadsPrec :: Int -> ReadS AuditNotificationTarget
Prelude.Read, Int -> AuditNotificationTarget -> ShowS
[AuditNotificationTarget] -> ShowS
AuditNotificationTarget -> String
(Int -> AuditNotificationTarget -> ShowS)
-> (AuditNotificationTarget -> String)
-> ([AuditNotificationTarget] -> ShowS)
-> Show AuditNotificationTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditNotificationTarget] -> ShowS
$cshowList :: [AuditNotificationTarget] -> ShowS
show :: AuditNotificationTarget -> String
$cshow :: AuditNotificationTarget -> String
showsPrec :: Int -> AuditNotificationTarget -> ShowS
$cshowsPrec :: Int -> AuditNotificationTarget -> ShowS
Prelude.Show, (forall x.
 AuditNotificationTarget -> Rep AuditNotificationTarget x)
-> (forall x.
    Rep AuditNotificationTarget x -> AuditNotificationTarget)
-> Generic AuditNotificationTarget
forall x. Rep AuditNotificationTarget x -> AuditNotificationTarget
forall x. AuditNotificationTarget -> Rep AuditNotificationTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuditNotificationTarget x -> AuditNotificationTarget
$cfrom :: forall x. AuditNotificationTarget -> Rep AuditNotificationTarget x
Prelude.Generic)

-- |
-- Create a value of 'AuditNotificationTarget' 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:
--
-- 'targetArn', 'auditNotificationTarget_targetArn' - The ARN of the target (SNS topic) to which audit notifications are sent.
--
-- 'enabled', 'auditNotificationTarget_enabled' - True if notifications to the target are enabled.
--
-- 'roleArn', 'auditNotificationTarget_roleArn' - The ARN of the role that grants permission to send notifications to the
-- target.
newAuditNotificationTarget ::
  AuditNotificationTarget
newAuditNotificationTarget :: AuditNotificationTarget
newAuditNotificationTarget =
  AuditNotificationTarget' :: Maybe Text -> Maybe Bool -> Maybe Text -> AuditNotificationTarget
AuditNotificationTarget'
    { $sel:targetArn:AuditNotificationTarget' :: Maybe Text
targetArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:AuditNotificationTarget' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:AuditNotificationTarget' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the target (SNS topic) to which audit notifications are sent.
auditNotificationTarget_targetArn :: Lens.Lens' AuditNotificationTarget (Prelude.Maybe Prelude.Text)
auditNotificationTarget_targetArn :: (Maybe Text -> f (Maybe Text))
-> AuditNotificationTarget -> f AuditNotificationTarget
auditNotificationTarget_targetArn = (AuditNotificationTarget -> Maybe Text)
-> (AuditNotificationTarget
    -> Maybe Text -> AuditNotificationTarget)
-> Lens
     AuditNotificationTarget
     AuditNotificationTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuditNotificationTarget' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:AuditNotificationTarget' :: AuditNotificationTarget -> Maybe Text
targetArn} -> Maybe Text
targetArn) (\s :: AuditNotificationTarget
s@AuditNotificationTarget' {} Maybe Text
a -> AuditNotificationTarget
s {$sel:targetArn:AuditNotificationTarget' :: Maybe Text
targetArn = Maybe Text
a} :: AuditNotificationTarget)

-- | True if notifications to the target are enabled.
auditNotificationTarget_enabled :: Lens.Lens' AuditNotificationTarget (Prelude.Maybe Prelude.Bool)
auditNotificationTarget_enabled :: (Maybe Bool -> f (Maybe Bool))
-> AuditNotificationTarget -> f AuditNotificationTarget
auditNotificationTarget_enabled = (AuditNotificationTarget -> Maybe Bool)
-> (AuditNotificationTarget
    -> Maybe Bool -> AuditNotificationTarget)
-> Lens
     AuditNotificationTarget
     AuditNotificationTarget
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuditNotificationTarget' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AuditNotificationTarget' :: AuditNotificationTarget -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AuditNotificationTarget
s@AuditNotificationTarget' {} Maybe Bool
a -> AuditNotificationTarget
s {$sel:enabled:AuditNotificationTarget' :: Maybe Bool
enabled = Maybe Bool
a} :: AuditNotificationTarget)

-- | The ARN of the role that grants permission to send notifications to the
-- target.
auditNotificationTarget_roleArn :: Lens.Lens' AuditNotificationTarget (Prelude.Maybe Prelude.Text)
auditNotificationTarget_roleArn :: (Maybe Text -> f (Maybe Text))
-> AuditNotificationTarget -> f AuditNotificationTarget
auditNotificationTarget_roleArn = (AuditNotificationTarget -> Maybe Text)
-> (AuditNotificationTarget
    -> Maybe Text -> AuditNotificationTarget)
-> Lens
     AuditNotificationTarget
     AuditNotificationTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuditNotificationTarget' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:AuditNotificationTarget' :: AuditNotificationTarget -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: AuditNotificationTarget
s@AuditNotificationTarget' {} Maybe Text
a -> AuditNotificationTarget
s {$sel:roleArn:AuditNotificationTarget' :: Maybe Text
roleArn = Maybe Text
a} :: AuditNotificationTarget)

instance Core.FromJSON AuditNotificationTarget where
  parseJSON :: Value -> Parser AuditNotificationTarget
parseJSON =
    String
-> (Object -> Parser AuditNotificationTarget)
-> Value
-> Parser AuditNotificationTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AuditNotificationTarget"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> Maybe Text -> AuditNotificationTarget
AuditNotificationTarget'
            (Maybe Text -> Maybe Bool -> Maybe Text -> AuditNotificationTarget)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Maybe Text -> AuditNotificationTarget)
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
"targetArn")
            Parser (Maybe Bool -> Maybe Text -> AuditNotificationTarget)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> AuditNotificationTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"enabled")
            Parser (Maybe Text -> AuditNotificationTarget)
-> Parser (Maybe Text) -> Parser AuditNotificationTarget
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
"roleArn")
      )

instance Prelude.Hashable AuditNotificationTarget

instance Prelude.NFData AuditNotificationTarget

instance Core.ToJSON AuditNotificationTarget where
  toJSON :: AuditNotificationTarget -> Value
toJSON AuditNotificationTarget' {Maybe Bool
Maybe Text
roleArn :: Maybe Text
enabled :: Maybe Bool
targetArn :: Maybe Text
$sel:roleArn:AuditNotificationTarget' :: AuditNotificationTarget -> Maybe Text
$sel:enabled:AuditNotificationTarget' :: AuditNotificationTarget -> Maybe Bool
$sel:targetArn:AuditNotificationTarget' :: AuditNotificationTarget -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"targetArn" 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
targetArn,
            (Text
"enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"roleArn" 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
roleArn
          ]
      )