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

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

-- | A wrapper type for the topic\'s Amazon Resource Name (ARN). To retrieve
-- a topic\'s attributes, use @GetTopicAttributes@.
--
-- /See:/ 'newTopic' smart constructor.
data Topic = Topic'
  { -- | The topic\'s ARN.
    Topic -> Maybe Text
topicArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Topic -> Topic -> Bool
(Topic -> Topic -> Bool) -> (Topic -> Topic -> Bool) -> Eq Topic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Topic -> Topic -> Bool
$c/= :: Topic -> Topic -> Bool
== :: Topic -> Topic -> Bool
$c== :: Topic -> Topic -> Bool
Prelude.Eq, ReadPrec [Topic]
ReadPrec Topic
Int -> ReadS Topic
ReadS [Topic]
(Int -> ReadS Topic)
-> ReadS [Topic]
-> ReadPrec Topic
-> ReadPrec [Topic]
-> Read Topic
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Topic]
$creadListPrec :: ReadPrec [Topic]
readPrec :: ReadPrec Topic
$creadPrec :: ReadPrec Topic
readList :: ReadS [Topic]
$creadList :: ReadS [Topic]
readsPrec :: Int -> ReadS Topic
$creadsPrec :: Int -> ReadS Topic
Prelude.Read, Int -> Topic -> ShowS
[Topic] -> ShowS
Topic -> String
(Int -> Topic -> ShowS)
-> (Topic -> String) -> ([Topic] -> ShowS) -> Show Topic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Topic] -> ShowS
$cshowList :: [Topic] -> ShowS
show :: Topic -> String
$cshow :: Topic -> String
showsPrec :: Int -> Topic -> ShowS
$cshowsPrec :: Int -> Topic -> ShowS
Prelude.Show, (forall x. Topic -> Rep Topic x)
-> (forall x. Rep Topic x -> Topic) -> Generic Topic
forall x. Rep Topic x -> Topic
forall x. Topic -> Rep Topic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Topic x -> Topic
$cfrom :: forall x. Topic -> Rep Topic x
Prelude.Generic)

-- |
-- Create a value of 'Topic' 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:
--
-- 'topicArn', 'topic_topicArn' - The topic\'s ARN.
newTopic ::
  Topic
newTopic :: Topic
newTopic = Topic' :: Maybe Text -> Topic
Topic' {$sel:topicArn:Topic' :: Maybe Text
topicArn = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The topic\'s ARN.
topic_topicArn :: Lens.Lens' Topic (Prelude.Maybe Prelude.Text)
topic_topicArn :: (Maybe Text -> f (Maybe Text)) -> Topic -> f Topic
topic_topicArn = (Topic -> Maybe Text)
-> (Topic -> Maybe Text -> Topic)
-> Lens Topic Topic (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Topic' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:Topic' :: Topic -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: Topic
s@Topic' {} Maybe Text
a -> Topic
s {$sel:topicArn:Topic' :: Maybe Text
topicArn = Maybe Text
a} :: Topic)

instance Core.FromXML Topic where
  parseXML :: [Node] -> Either String Topic
parseXML [Node]
x =
    Maybe Text -> Topic
Topic' (Maybe Text -> Topic)
-> Either String (Maybe Text) -> Either String Topic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TopicArn")

instance Prelude.Hashable Topic

instance Prelude.NFData Topic