{-# 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.SecurityHub.Types.AwsSnsTopicDetails
-- 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.SecurityHub.Types.AwsSnsTopicDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsSnsTopicSubscription

-- | A wrapper type for the topic\'s ARN.
--
-- /See:/ 'newAwsSnsTopicDetails' smart constructor.
data AwsSnsTopicDetails = AwsSnsTopicDetails'
  { -- | The ID of an Amazon Web Services managed key for Amazon SNS or a
    -- customer managed key.
    AwsSnsTopicDetails -> Maybe Text
kmsMasterKeyId :: Prelude.Maybe Prelude.Text,
    -- | The name of the topic.
    AwsSnsTopicDetails -> Maybe Text
topicName :: Prelude.Maybe Prelude.Text,
    -- | The subscription\'s owner.
    AwsSnsTopicDetails -> Maybe Text
owner :: Prelude.Maybe Prelude.Text,
    -- | Subscription is an embedded property that describes the subscription
    -- endpoints of an SNS topic.
    AwsSnsTopicDetails -> Maybe [AwsSnsTopicSubscription]
subscription :: Prelude.Maybe [AwsSnsTopicSubscription]
  }
  deriving (AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool
(AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool)
-> (AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool)
-> Eq AwsSnsTopicDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool
$c/= :: AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool
== :: AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool
$c== :: AwsSnsTopicDetails -> AwsSnsTopicDetails -> Bool
Prelude.Eq, ReadPrec [AwsSnsTopicDetails]
ReadPrec AwsSnsTopicDetails
Int -> ReadS AwsSnsTopicDetails
ReadS [AwsSnsTopicDetails]
(Int -> ReadS AwsSnsTopicDetails)
-> ReadS [AwsSnsTopicDetails]
-> ReadPrec AwsSnsTopicDetails
-> ReadPrec [AwsSnsTopicDetails]
-> Read AwsSnsTopicDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsSnsTopicDetails]
$creadListPrec :: ReadPrec [AwsSnsTopicDetails]
readPrec :: ReadPrec AwsSnsTopicDetails
$creadPrec :: ReadPrec AwsSnsTopicDetails
readList :: ReadS [AwsSnsTopicDetails]
$creadList :: ReadS [AwsSnsTopicDetails]
readsPrec :: Int -> ReadS AwsSnsTopicDetails
$creadsPrec :: Int -> ReadS AwsSnsTopicDetails
Prelude.Read, Int -> AwsSnsTopicDetails -> ShowS
[AwsSnsTopicDetails] -> ShowS
AwsSnsTopicDetails -> String
(Int -> AwsSnsTopicDetails -> ShowS)
-> (AwsSnsTopicDetails -> String)
-> ([AwsSnsTopicDetails] -> ShowS)
-> Show AwsSnsTopicDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsSnsTopicDetails] -> ShowS
$cshowList :: [AwsSnsTopicDetails] -> ShowS
show :: AwsSnsTopicDetails -> String
$cshow :: AwsSnsTopicDetails -> String
showsPrec :: Int -> AwsSnsTopicDetails -> ShowS
$cshowsPrec :: Int -> AwsSnsTopicDetails -> ShowS
Prelude.Show, (forall x. AwsSnsTopicDetails -> Rep AwsSnsTopicDetails x)
-> (forall x. Rep AwsSnsTopicDetails x -> AwsSnsTopicDetails)
-> Generic AwsSnsTopicDetails
forall x. Rep AwsSnsTopicDetails x -> AwsSnsTopicDetails
forall x. AwsSnsTopicDetails -> Rep AwsSnsTopicDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsSnsTopicDetails x -> AwsSnsTopicDetails
$cfrom :: forall x. AwsSnsTopicDetails -> Rep AwsSnsTopicDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsSnsTopicDetails' 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:
--
-- 'kmsMasterKeyId', 'awsSnsTopicDetails_kmsMasterKeyId' - The ID of an Amazon Web Services managed key for Amazon SNS or a
-- customer managed key.
--
-- 'topicName', 'awsSnsTopicDetails_topicName' - The name of the topic.
--
-- 'owner', 'awsSnsTopicDetails_owner' - The subscription\'s owner.
--
-- 'subscription', 'awsSnsTopicDetails_subscription' - Subscription is an embedded property that describes the subscription
-- endpoints of an SNS topic.
newAwsSnsTopicDetails ::
  AwsSnsTopicDetails
newAwsSnsTopicDetails :: AwsSnsTopicDetails
newAwsSnsTopicDetails =
  AwsSnsTopicDetails' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [AwsSnsTopicSubscription]
-> AwsSnsTopicDetails
AwsSnsTopicDetails'
    { $sel:kmsMasterKeyId:AwsSnsTopicDetails' :: Maybe Text
kmsMasterKeyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:topicName:AwsSnsTopicDetails' :: Maybe Text
topicName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:owner:AwsSnsTopicDetails' :: Maybe Text
owner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subscription:AwsSnsTopicDetails' :: Maybe [AwsSnsTopicSubscription]
subscription = Maybe [AwsSnsTopicSubscription]
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of an Amazon Web Services managed key for Amazon SNS or a
-- customer managed key.
awsSnsTopicDetails_kmsMasterKeyId :: Lens.Lens' AwsSnsTopicDetails (Prelude.Maybe Prelude.Text)
awsSnsTopicDetails_kmsMasterKeyId :: (Maybe Text -> f (Maybe Text))
-> AwsSnsTopicDetails -> f AwsSnsTopicDetails
awsSnsTopicDetails_kmsMasterKeyId = (AwsSnsTopicDetails -> Maybe Text)
-> (AwsSnsTopicDetails -> Maybe Text -> AwsSnsTopicDetails)
-> Lens
     AwsSnsTopicDetails AwsSnsTopicDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsSnsTopicDetails' {Maybe Text
kmsMasterKeyId :: Maybe Text
$sel:kmsMasterKeyId:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe Text
kmsMasterKeyId} -> Maybe Text
kmsMasterKeyId) (\s :: AwsSnsTopicDetails
s@AwsSnsTopicDetails' {} Maybe Text
a -> AwsSnsTopicDetails
s {$sel:kmsMasterKeyId:AwsSnsTopicDetails' :: Maybe Text
kmsMasterKeyId = Maybe Text
a} :: AwsSnsTopicDetails)

-- | The name of the topic.
awsSnsTopicDetails_topicName :: Lens.Lens' AwsSnsTopicDetails (Prelude.Maybe Prelude.Text)
awsSnsTopicDetails_topicName :: (Maybe Text -> f (Maybe Text))
-> AwsSnsTopicDetails -> f AwsSnsTopicDetails
awsSnsTopicDetails_topicName = (AwsSnsTopicDetails -> Maybe Text)
-> (AwsSnsTopicDetails -> Maybe Text -> AwsSnsTopicDetails)
-> Lens
     AwsSnsTopicDetails AwsSnsTopicDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsSnsTopicDetails' {Maybe Text
topicName :: Maybe Text
$sel:topicName:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe Text
topicName} -> Maybe Text
topicName) (\s :: AwsSnsTopicDetails
s@AwsSnsTopicDetails' {} Maybe Text
a -> AwsSnsTopicDetails
s {$sel:topicName:AwsSnsTopicDetails' :: Maybe Text
topicName = Maybe Text
a} :: AwsSnsTopicDetails)

-- | The subscription\'s owner.
awsSnsTopicDetails_owner :: Lens.Lens' AwsSnsTopicDetails (Prelude.Maybe Prelude.Text)
awsSnsTopicDetails_owner :: (Maybe Text -> f (Maybe Text))
-> AwsSnsTopicDetails -> f AwsSnsTopicDetails
awsSnsTopicDetails_owner = (AwsSnsTopicDetails -> Maybe Text)
-> (AwsSnsTopicDetails -> Maybe Text -> AwsSnsTopicDetails)
-> Lens
     AwsSnsTopicDetails AwsSnsTopicDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsSnsTopicDetails' {Maybe Text
owner :: Maybe Text
$sel:owner:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe Text
owner} -> Maybe Text
owner) (\s :: AwsSnsTopicDetails
s@AwsSnsTopicDetails' {} Maybe Text
a -> AwsSnsTopicDetails
s {$sel:owner:AwsSnsTopicDetails' :: Maybe Text
owner = Maybe Text
a} :: AwsSnsTopicDetails)

-- | Subscription is an embedded property that describes the subscription
-- endpoints of an SNS topic.
awsSnsTopicDetails_subscription :: Lens.Lens' AwsSnsTopicDetails (Prelude.Maybe [AwsSnsTopicSubscription])
awsSnsTopicDetails_subscription :: (Maybe [AwsSnsTopicSubscription]
 -> f (Maybe [AwsSnsTopicSubscription]))
-> AwsSnsTopicDetails -> f AwsSnsTopicDetails
awsSnsTopicDetails_subscription = (AwsSnsTopicDetails -> Maybe [AwsSnsTopicSubscription])
-> (AwsSnsTopicDetails
    -> Maybe [AwsSnsTopicSubscription] -> AwsSnsTopicDetails)
-> Lens
     AwsSnsTopicDetails
     AwsSnsTopicDetails
     (Maybe [AwsSnsTopicSubscription])
     (Maybe [AwsSnsTopicSubscription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsSnsTopicDetails' {Maybe [AwsSnsTopicSubscription]
subscription :: Maybe [AwsSnsTopicSubscription]
$sel:subscription:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe [AwsSnsTopicSubscription]
subscription} -> Maybe [AwsSnsTopicSubscription]
subscription) (\s :: AwsSnsTopicDetails
s@AwsSnsTopicDetails' {} Maybe [AwsSnsTopicSubscription]
a -> AwsSnsTopicDetails
s {$sel:subscription:AwsSnsTopicDetails' :: Maybe [AwsSnsTopicSubscription]
subscription = Maybe [AwsSnsTopicSubscription]
a} :: AwsSnsTopicDetails) ((Maybe [AwsSnsTopicSubscription]
  -> f (Maybe [AwsSnsTopicSubscription]))
 -> AwsSnsTopicDetails -> f AwsSnsTopicDetails)
-> ((Maybe [AwsSnsTopicSubscription]
     -> f (Maybe [AwsSnsTopicSubscription]))
    -> Maybe [AwsSnsTopicSubscription]
    -> f (Maybe [AwsSnsTopicSubscription]))
-> (Maybe [AwsSnsTopicSubscription]
    -> f (Maybe [AwsSnsTopicSubscription]))
-> AwsSnsTopicDetails
-> f AwsSnsTopicDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsSnsTopicSubscription]
  [AwsSnsTopicSubscription]
  [AwsSnsTopicSubscription]
  [AwsSnsTopicSubscription]
-> Iso
     (Maybe [AwsSnsTopicSubscription])
     (Maybe [AwsSnsTopicSubscription])
     (Maybe [AwsSnsTopicSubscription])
     (Maybe [AwsSnsTopicSubscription])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AwsSnsTopicSubscription]
  [AwsSnsTopicSubscription]
  [AwsSnsTopicSubscription]
  [AwsSnsTopicSubscription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AwsSnsTopicDetails where
  parseJSON :: Value -> Parser AwsSnsTopicDetails
parseJSON =
    String
-> (Object -> Parser AwsSnsTopicDetails)
-> Value
-> Parser AwsSnsTopicDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsSnsTopicDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [AwsSnsTopicSubscription]
-> AwsSnsTopicDetails
AwsSnsTopicDetails'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [AwsSnsTopicSubscription]
 -> AwsSnsTopicDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [AwsSnsTopicSubscription]
      -> AwsSnsTopicDetails)
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
"KmsMasterKeyId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [AwsSnsTopicSubscription]
   -> AwsSnsTopicDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [AwsSnsTopicSubscription] -> AwsSnsTopicDetails)
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
"TopicName")
            Parser
  (Maybe Text
   -> Maybe [AwsSnsTopicSubscription] -> AwsSnsTopicDetails)
-> Parser (Maybe Text)
-> Parser (Maybe [AwsSnsTopicSubscription] -> AwsSnsTopicDetails)
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
"Owner")
            Parser (Maybe [AwsSnsTopicSubscription] -> AwsSnsTopicDetails)
-> Parser (Maybe [AwsSnsTopicSubscription])
-> Parser AwsSnsTopicDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [AwsSnsTopicSubscription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Subscription" Parser (Maybe (Maybe [AwsSnsTopicSubscription]))
-> Maybe [AwsSnsTopicSubscription]
-> Parser (Maybe [AwsSnsTopicSubscription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AwsSnsTopicSubscription]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AwsSnsTopicDetails

instance Prelude.NFData AwsSnsTopicDetails

instance Core.ToJSON AwsSnsTopicDetails where
  toJSON :: AwsSnsTopicDetails -> Value
toJSON AwsSnsTopicDetails' {Maybe [AwsSnsTopicSubscription]
Maybe Text
subscription :: Maybe [AwsSnsTopicSubscription]
owner :: Maybe Text
topicName :: Maybe Text
kmsMasterKeyId :: Maybe Text
$sel:subscription:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe [AwsSnsTopicSubscription]
$sel:owner:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe Text
$sel:topicName:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe Text
$sel:kmsMasterKeyId:AwsSnsTopicDetails' :: AwsSnsTopicDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KmsMasterKeyId" 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
kmsMasterKeyId,
            (Text
"TopicName" 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
topicName,
            (Text
"Owner" 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
owner,
            (Text
"Subscription" Text -> [AwsSnsTopicSubscription] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AwsSnsTopicSubscription] -> Pair)
-> Maybe [AwsSnsTopicSubscription] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AwsSnsTopicSubscription]
subscription
          ]
      )