{-# 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.SNS.Types.Subscription
-- 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.SNS.Types.Subscription 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

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

-- |
-- Create a value of 'Subscription' 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:
--
-- 'endpoint', 'subscription_endpoint' - The subscription\'s endpoint (format depends on the protocol).
--
-- 'owner', 'subscription_owner' - The subscription\'s owner.
--
-- 'protocol', 'subscription_protocol' - The subscription\'s protocol.
--
-- 'subscriptionArn', 'subscription_subscriptionArn' - The subscription\'s ARN.
--
-- 'topicArn', 'subscription_topicArn' - The ARN of the subscription\'s topic.
newSubscription ::
  Subscription
newSubscription :: Subscription
newSubscription =
  Subscription'
    { $sel:endpoint:Subscription' :: Maybe Text
endpoint = forall a. Maybe a
Prelude.Nothing,
      $sel:owner:Subscription' :: Maybe Text
owner = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:Subscription' :: Maybe Text
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:subscriptionArn:Subscription' :: Maybe Text
subscriptionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:topicArn:Subscription' :: Maybe Text
topicArn = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

-- | The subscription\'s ARN.
subscription_subscriptionArn :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Text)
subscription_subscriptionArn :: Lens' Subscription (Maybe Text)
subscription_subscriptionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Text
subscriptionArn :: Maybe Text
$sel:subscriptionArn:Subscription' :: Subscription -> Maybe Text
subscriptionArn} -> Maybe Text
subscriptionArn) (\s :: Subscription
s@Subscription' {} Maybe Text
a -> Subscription
s {$sel:subscriptionArn:Subscription' :: Maybe Text
subscriptionArn = Maybe Text
a} :: Subscription)

-- | The ARN of the subscription\'s topic.
subscription_topicArn :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Text)
subscription_topicArn :: Lens' Subscription (Maybe Text)
subscription_topicArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:Subscription' :: Subscription -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: Subscription
s@Subscription' {} Maybe Text
a -> Subscription
s {$sel:topicArn:Subscription' :: Maybe Text
topicArn = Maybe Text
a} :: Subscription)

instance Data.FromXML Subscription where
  parseXML :: [Node] -> Either String Subscription
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Subscription
Subscription'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Endpoint")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Owner")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Protocol")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"SubscriptionArn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"TopicArn")

instance Prelude.Hashable Subscription where
  hashWithSalt :: Int -> Subscription -> Int
hashWithSalt Int
_salt Subscription' {Maybe Text
topicArn :: Maybe Text
subscriptionArn :: Maybe Text
protocol :: Maybe Text
owner :: Maybe Text
endpoint :: Maybe Text
$sel:topicArn:Subscription' :: Subscription -> Maybe Text
$sel:subscriptionArn:Subscription' :: Subscription -> Maybe Text
$sel:protocol:Subscription' :: Subscription -> Maybe Text
$sel:owner:Subscription' :: Subscription -> Maybe Text
$sel:endpoint:Subscription' :: Subscription -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
owner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subscriptionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
topicArn

instance Prelude.NFData Subscription where
  rnf :: Subscription -> ()
rnf Subscription' {Maybe Text
topicArn :: Maybe Text
subscriptionArn :: Maybe Text
protocol :: Maybe Text
owner :: Maybe Text
endpoint :: Maybe Text
$sel:topicArn:Subscription' :: Subscription -> Maybe Text
$sel:subscriptionArn:Subscription' :: Subscription -> Maybe Text
$sel:protocol:Subscription' :: Subscription -> Maybe Text
$sel:owner:Subscription' :: Subscription -> Maybe Text
$sel:endpoint:Subscription' :: Subscription -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
owner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subscriptionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
topicArn