{-# 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.AwsSnsTopicSubscription
-- 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.AwsSnsTopicSubscription where

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

-- | A wrapper type for the attributes of an Amazon SNS subscription.
--
-- /See:/ 'newAwsSnsTopicSubscription' smart constructor.
data AwsSnsTopicSubscription = AwsSnsTopicSubscription'
  { -- | The subscription\'s protocol.
    AwsSnsTopicSubscription -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The subscription\'s endpoint (format depends on the protocol).
    AwsSnsTopicSubscription -> Maybe Text
endpoint :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool
(AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool)
-> (AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool)
-> Eq AwsSnsTopicSubscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool
$c/= :: AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool
== :: AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool
$c== :: AwsSnsTopicSubscription -> AwsSnsTopicSubscription -> Bool
Prelude.Eq, ReadPrec [AwsSnsTopicSubscription]
ReadPrec AwsSnsTopicSubscription
Int -> ReadS AwsSnsTopicSubscription
ReadS [AwsSnsTopicSubscription]
(Int -> ReadS AwsSnsTopicSubscription)
-> ReadS [AwsSnsTopicSubscription]
-> ReadPrec AwsSnsTopicSubscription
-> ReadPrec [AwsSnsTopicSubscription]
-> Read AwsSnsTopicSubscription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsSnsTopicSubscription]
$creadListPrec :: ReadPrec [AwsSnsTopicSubscription]
readPrec :: ReadPrec AwsSnsTopicSubscription
$creadPrec :: ReadPrec AwsSnsTopicSubscription
readList :: ReadS [AwsSnsTopicSubscription]
$creadList :: ReadS [AwsSnsTopicSubscription]
readsPrec :: Int -> ReadS AwsSnsTopicSubscription
$creadsPrec :: Int -> ReadS AwsSnsTopicSubscription
Prelude.Read, Int -> AwsSnsTopicSubscription -> ShowS
[AwsSnsTopicSubscription] -> ShowS
AwsSnsTopicSubscription -> String
(Int -> AwsSnsTopicSubscription -> ShowS)
-> (AwsSnsTopicSubscription -> String)
-> ([AwsSnsTopicSubscription] -> ShowS)
-> Show AwsSnsTopicSubscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsSnsTopicSubscription] -> ShowS
$cshowList :: [AwsSnsTopicSubscription] -> ShowS
show :: AwsSnsTopicSubscription -> String
$cshow :: AwsSnsTopicSubscription -> String
showsPrec :: Int -> AwsSnsTopicSubscription -> ShowS
$cshowsPrec :: Int -> AwsSnsTopicSubscription -> ShowS
Prelude.Show, (forall x.
 AwsSnsTopicSubscription -> Rep AwsSnsTopicSubscription x)
-> (forall x.
    Rep AwsSnsTopicSubscription x -> AwsSnsTopicSubscription)
-> Generic AwsSnsTopicSubscription
forall x. Rep AwsSnsTopicSubscription x -> AwsSnsTopicSubscription
forall x. AwsSnsTopicSubscription -> Rep AwsSnsTopicSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsSnsTopicSubscription x -> AwsSnsTopicSubscription
$cfrom :: forall x. AwsSnsTopicSubscription -> Rep AwsSnsTopicSubscription x
Prelude.Generic)

-- |
-- Create a value of 'AwsSnsTopicSubscription' 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:
--
-- 'protocol', 'awsSnsTopicSubscription_protocol' - The subscription\'s protocol.
--
-- 'endpoint', 'awsSnsTopicSubscription_endpoint' - The subscription\'s endpoint (format depends on the protocol).
newAwsSnsTopicSubscription ::
  AwsSnsTopicSubscription
newAwsSnsTopicSubscription :: AwsSnsTopicSubscription
newAwsSnsTopicSubscription =
  AwsSnsTopicSubscription' :: Maybe Text -> Maybe Text -> AwsSnsTopicSubscription
AwsSnsTopicSubscription'
    { $sel:protocol:AwsSnsTopicSubscription' :: Maybe Text
protocol =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpoint:AwsSnsTopicSubscription' :: Maybe Text
endpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The subscription\'s endpoint (format depends on the protocol).
awsSnsTopicSubscription_endpoint :: Lens.Lens' AwsSnsTopicSubscription (Prelude.Maybe Prelude.Text)
awsSnsTopicSubscription_endpoint :: (Maybe Text -> f (Maybe Text))
-> AwsSnsTopicSubscription -> f AwsSnsTopicSubscription
awsSnsTopicSubscription_endpoint = (AwsSnsTopicSubscription -> Maybe Text)
-> (AwsSnsTopicSubscription
    -> Maybe Text -> AwsSnsTopicSubscription)
-> Lens
     AwsSnsTopicSubscription
     AwsSnsTopicSubscription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsSnsTopicSubscription' {Maybe Text
endpoint :: Maybe Text
$sel:endpoint:AwsSnsTopicSubscription' :: AwsSnsTopicSubscription -> Maybe Text
endpoint} -> Maybe Text
endpoint) (\s :: AwsSnsTopicSubscription
s@AwsSnsTopicSubscription' {} Maybe Text
a -> AwsSnsTopicSubscription
s {$sel:endpoint:AwsSnsTopicSubscription' :: Maybe Text
endpoint = Maybe Text
a} :: AwsSnsTopicSubscription)

instance Core.FromJSON AwsSnsTopicSubscription where
  parseJSON :: Value -> Parser AwsSnsTopicSubscription
parseJSON =
    String
-> (Object -> Parser AwsSnsTopicSubscription)
-> Value
-> Parser AwsSnsTopicSubscription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsSnsTopicSubscription"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AwsSnsTopicSubscription
AwsSnsTopicSubscription'
            (Maybe Text -> Maybe Text -> AwsSnsTopicSubscription)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsSnsTopicSubscription)
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
"Protocol")
            Parser (Maybe Text -> AwsSnsTopicSubscription)
-> Parser (Maybe Text) -> Parser AwsSnsTopicSubscription
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
"Endpoint")
      )

instance Prelude.Hashable AwsSnsTopicSubscription

instance Prelude.NFData AwsSnsTopicSubscription

instance Core.ToJSON AwsSnsTopicSubscription where
  toJSON :: AwsSnsTopicSubscription -> Value
toJSON AwsSnsTopicSubscription' {Maybe Text
endpoint :: Maybe Text
protocol :: Maybe Text
$sel:endpoint:AwsSnsTopicSubscription' :: AwsSnsTopicSubscription -> Maybe Text
$sel:protocol:AwsSnsTopicSubscription' :: AwsSnsTopicSubscription -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Protocol" 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
protocol,
            (Text
"Endpoint" 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
endpoint
          ]
      )