{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateTopic
-- 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)
--
-- Creates a topic to which notifications can be published. Users can
-- create at most 100,000 standard topics (at most 1,000 FIFO topics). For
-- more information, see
-- <https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html Creating an Amazon SNS topic>
-- in the /Amazon SNS Developer Guide/. This action is idempotent, so if
-- the requester already owns a topic with the specified name, that
-- topic\'s ARN is returned without creating a new topic.
module Amazonka.SNS.CreateTopic
  ( -- * Creating a Request
    CreateTopic (..),
    newCreateTopic,

    -- * Request Lenses
    createTopic_attributes,
    createTopic_tags,
    createTopic_name,

    -- * Destructuring the Response
    CreateTopicResponse (..),
    newCreateTopicResponse,

    -- * Response Lenses
    createTopicResponse_topicArn,
    createTopicResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types

-- | Input for CreateTopic action.
--
-- /See:/ 'newCreateTopic' smart constructor.
data CreateTopic = CreateTopic'
  { -- | A map of attributes with their corresponding values.
    --
    -- The following lists the names, descriptions, and values of the special
    -- request parameters that the @CreateTopic@ action uses:
    --
    -- -   @DeliveryPolicy@ – The policy that defines how Amazon SNS retries
    --     failed deliveries to HTTP\/S endpoints.
    --
    -- -   @DisplayName@ – The display name to use for a topic with SMS
    --     subscriptions.
    --
    -- -   @FifoTopic@ – Set to true to create a FIFO topic.
    --
    -- -   @Policy@ – The policy that defines who can access your topic. By
    --     default, only the topic owner can publish or subscribe to the topic.
    --
    -- The following attribute applies only to
    -- <https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html server-side encryption>:
    --
    -- -   @KmsMasterKeyId@ – The ID of an Amazon Web Services managed customer
    --     master key (CMK) for Amazon SNS or a custom CMK. For more
    --     information, see
    --     <https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms Key Terms>.
    --     For more examples, see
    --     <https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters KeyId>
    --     in the /Key Management Service API Reference/.
    --
    -- The following attributes apply only to
    -- <https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html FIFO topics>:
    --
    -- -   @FifoTopic@ – When this is set to @true@, a FIFO topic is created.
    --
    -- -   @ContentBasedDeduplication@ – Enables content-based deduplication
    --     for FIFO topics.
    --
    --     -   By default, @ContentBasedDeduplication@ is set to @false@. If
    --         you create a FIFO topic and this attribute is @false@, you must
    --         specify a value for the @MessageDeduplicationId@ parameter for
    --         the
    --         <https://docs.aws.amazon.com/sns/latest/api/API_Publish.html Publish>
    --         action.
    --
    --     -   When you set @ContentBasedDeduplication@ to @true@, Amazon SNS
    --         uses a SHA-256 hash to generate the @MessageDeduplicationId@
    --         using the body of the message (but not the attributes of the
    --         message).
    --
    --         (Optional) To override the generated value, you can specify a
    --         value for the @MessageDeduplicationId@ parameter for the
    --         @Publish@ action.
    CreateTopic -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The list of tags to add to a new topic.
    --
    -- To be able to tag a topic on creation, you must have the
    -- @sns:CreateTopic@ and @sns:TagResource@ permissions.
    CreateTopic -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the topic you want to create.
    --
    -- Constraints: Topic names must be made up of only uppercase and lowercase
    -- ASCII letters, numbers, underscores, and hyphens, and must be between 1
    -- and 256 characters long.
    --
    -- For a FIFO (first-in-first-out) topic, the name must end with the
    -- @.fifo@ suffix.
    CreateTopic -> Text
name :: Prelude.Text
  }
  deriving (CreateTopic -> CreateTopic -> Bool
(CreateTopic -> CreateTopic -> Bool)
-> (CreateTopic -> CreateTopic -> Bool) -> Eq CreateTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTopic -> CreateTopic -> Bool
$c/= :: CreateTopic -> CreateTopic -> Bool
== :: CreateTopic -> CreateTopic -> Bool
$c== :: CreateTopic -> CreateTopic -> Bool
Prelude.Eq, ReadPrec [CreateTopic]
ReadPrec CreateTopic
Int -> ReadS CreateTopic
ReadS [CreateTopic]
(Int -> ReadS CreateTopic)
-> ReadS [CreateTopic]
-> ReadPrec CreateTopic
-> ReadPrec [CreateTopic]
-> Read CreateTopic
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTopic]
$creadListPrec :: ReadPrec [CreateTopic]
readPrec :: ReadPrec CreateTopic
$creadPrec :: ReadPrec CreateTopic
readList :: ReadS [CreateTopic]
$creadList :: ReadS [CreateTopic]
readsPrec :: Int -> ReadS CreateTopic
$creadsPrec :: Int -> ReadS CreateTopic
Prelude.Read, Int -> CreateTopic -> ShowS
[CreateTopic] -> ShowS
CreateTopic -> String
(Int -> CreateTopic -> ShowS)
-> (CreateTopic -> String)
-> ([CreateTopic] -> ShowS)
-> Show CreateTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTopic] -> ShowS
$cshowList :: [CreateTopic] -> ShowS
show :: CreateTopic -> String
$cshow :: CreateTopic -> String
showsPrec :: Int -> CreateTopic -> ShowS
$cshowsPrec :: Int -> CreateTopic -> ShowS
Prelude.Show, (forall x. CreateTopic -> Rep CreateTopic x)
-> (forall x. Rep CreateTopic x -> CreateTopic)
-> Generic CreateTopic
forall x. Rep CreateTopic x -> CreateTopic
forall x. CreateTopic -> Rep CreateTopic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTopic x -> CreateTopic
$cfrom :: forall x. CreateTopic -> Rep CreateTopic x
Prelude.Generic)

-- |
-- Create a value of 'CreateTopic' 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:
--
-- 'attributes', 'createTopic_attributes' - A map of attributes with their corresponding values.
--
-- The following lists the names, descriptions, and values of the special
-- request parameters that the @CreateTopic@ action uses:
--
-- -   @DeliveryPolicy@ – The policy that defines how Amazon SNS retries
--     failed deliveries to HTTP\/S endpoints.
--
-- -   @DisplayName@ – The display name to use for a topic with SMS
--     subscriptions.
--
-- -   @FifoTopic@ – Set to true to create a FIFO topic.
--
-- -   @Policy@ – The policy that defines who can access your topic. By
--     default, only the topic owner can publish or subscribe to the topic.
--
-- The following attribute applies only to
-- <https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html server-side encryption>:
--
-- -   @KmsMasterKeyId@ – The ID of an Amazon Web Services managed customer
--     master key (CMK) for Amazon SNS or a custom CMK. For more
--     information, see
--     <https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms Key Terms>.
--     For more examples, see
--     <https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters KeyId>
--     in the /Key Management Service API Reference/.
--
-- The following attributes apply only to
-- <https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html FIFO topics>:
--
-- -   @FifoTopic@ – When this is set to @true@, a FIFO topic is created.
--
-- -   @ContentBasedDeduplication@ – Enables content-based deduplication
--     for FIFO topics.
--
--     -   By default, @ContentBasedDeduplication@ is set to @false@. If
--         you create a FIFO topic and this attribute is @false@, you must
--         specify a value for the @MessageDeduplicationId@ parameter for
--         the
--         <https://docs.aws.amazon.com/sns/latest/api/API_Publish.html Publish>
--         action.
--
--     -   When you set @ContentBasedDeduplication@ to @true@, Amazon SNS
--         uses a SHA-256 hash to generate the @MessageDeduplicationId@
--         using the body of the message (but not the attributes of the
--         message).
--
--         (Optional) To override the generated value, you can specify a
--         value for the @MessageDeduplicationId@ parameter for the
--         @Publish@ action.
--
-- 'tags', 'createTopic_tags' - The list of tags to add to a new topic.
--
-- To be able to tag a topic on creation, you must have the
-- @sns:CreateTopic@ and @sns:TagResource@ permissions.
--
-- 'name', 'createTopic_name' - The name of the topic you want to create.
--
-- Constraints: Topic names must be made up of only uppercase and lowercase
-- ASCII letters, numbers, underscores, and hyphens, and must be between 1
-- and 256 characters long.
--
-- For a FIFO (first-in-first-out) topic, the name must end with the
-- @.fifo@ suffix.
newCreateTopic ::
  -- | 'name'
  Prelude.Text ->
  CreateTopic
newCreateTopic :: Text -> CreateTopic
newCreateTopic Text
pName_ =
  CreateTopic' :: Maybe (HashMap Text Text) -> Maybe [Tag] -> Text -> CreateTopic
CreateTopic'
    { $sel:attributes:CreateTopic' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateTopic' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateTopic' :: Text
name = Text
pName_
    }

-- | A map of attributes with their corresponding values.
--
-- The following lists the names, descriptions, and values of the special
-- request parameters that the @CreateTopic@ action uses:
--
-- -   @DeliveryPolicy@ – The policy that defines how Amazon SNS retries
--     failed deliveries to HTTP\/S endpoints.
--
-- -   @DisplayName@ – The display name to use for a topic with SMS
--     subscriptions.
--
-- -   @FifoTopic@ – Set to true to create a FIFO topic.
--
-- -   @Policy@ – The policy that defines who can access your topic. By
--     default, only the topic owner can publish or subscribe to the topic.
--
-- The following attribute applies only to
-- <https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html server-side encryption>:
--
-- -   @KmsMasterKeyId@ – The ID of an Amazon Web Services managed customer
--     master key (CMK) for Amazon SNS or a custom CMK. For more
--     information, see
--     <https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms Key Terms>.
--     For more examples, see
--     <https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters KeyId>
--     in the /Key Management Service API Reference/.
--
-- The following attributes apply only to
-- <https://docs.aws.amazon.com/sns/latest/dg/sns-fifo-topics.html FIFO topics>:
--
-- -   @FifoTopic@ – When this is set to @true@, a FIFO topic is created.
--
-- -   @ContentBasedDeduplication@ – Enables content-based deduplication
--     for FIFO topics.
--
--     -   By default, @ContentBasedDeduplication@ is set to @false@. If
--         you create a FIFO topic and this attribute is @false@, you must
--         specify a value for the @MessageDeduplicationId@ parameter for
--         the
--         <https://docs.aws.amazon.com/sns/latest/api/API_Publish.html Publish>
--         action.
--
--     -   When you set @ContentBasedDeduplication@ to @true@, Amazon SNS
--         uses a SHA-256 hash to generate the @MessageDeduplicationId@
--         using the body of the message (but not the attributes of the
--         message).
--
--         (Optional) To override the generated value, you can specify a
--         value for the @MessageDeduplicationId@ parameter for the
--         @Publish@ action.
createTopic_attributes :: Lens.Lens' CreateTopic (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createTopic_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateTopic -> f CreateTopic
createTopic_attributes = (CreateTopic -> Maybe (HashMap Text Text))
-> (CreateTopic -> Maybe (HashMap Text Text) -> CreateTopic)
-> Lens
     CreateTopic
     CreateTopic
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTopic' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:CreateTopic' :: CreateTopic -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: CreateTopic
s@CreateTopic' {} Maybe (HashMap Text Text)
a -> CreateTopic
s {$sel:attributes:CreateTopic' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: CreateTopic) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateTopic -> f CreateTopic)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateTopic
-> f CreateTopic
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of tags to add to a new topic.
--
-- To be able to tag a topic on creation, you must have the
-- @sns:CreateTopic@ and @sns:TagResource@ permissions.
createTopic_tags :: Lens.Lens' CreateTopic (Prelude.Maybe [Tag])
createTopic_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateTopic -> f CreateTopic
createTopic_tags = (CreateTopic -> Maybe [Tag])
-> (CreateTopic -> Maybe [Tag] -> CreateTopic)
-> Lens CreateTopic CreateTopic (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTopic' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateTopic' :: CreateTopic -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateTopic
s@CreateTopic' {} Maybe [Tag]
a -> CreateTopic
s {$sel:tags:CreateTopic' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateTopic) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateTopic -> f CreateTopic)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateTopic
-> f CreateTopic
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the topic you want to create.
--
-- Constraints: Topic names must be made up of only uppercase and lowercase
-- ASCII letters, numbers, underscores, and hyphens, and must be between 1
-- and 256 characters long.
--
-- For a FIFO (first-in-first-out) topic, the name must end with the
-- @.fifo@ suffix.
createTopic_name :: Lens.Lens' CreateTopic Prelude.Text
createTopic_name :: (Text -> f Text) -> CreateTopic -> f CreateTopic
createTopic_name = (CreateTopic -> Text)
-> (CreateTopic -> Text -> CreateTopic)
-> Lens CreateTopic CreateTopic Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTopic' {Text
name :: Text
$sel:name:CreateTopic' :: CreateTopic -> Text
name} -> Text
name) (\s :: CreateTopic
s@CreateTopic' {} Text
a -> CreateTopic
s {$sel:name:CreateTopic' :: Text
name = Text
a} :: CreateTopic)

instance Core.AWSRequest CreateTopic where
  type AWSResponse CreateTopic = CreateTopicResponse
  request :: CreateTopic -> Request CreateTopic
request = Service -> CreateTopic -> Request CreateTopic
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTopic
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTopic)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CreateTopic))
-> Logger
-> Service
-> Proxy CreateTopic
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTopic)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"CreateTopicResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> CreateTopicResponse
CreateTopicResponse'
            (Maybe Text -> Int -> CreateTopicResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateTopicResponse)
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")
            Either String (Int -> CreateTopicResponse)
-> Either String Int -> Either String CreateTopicResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateTopic

instance Prelude.NFData CreateTopic

instance Core.ToHeaders CreateTopic where
  toHeaders :: CreateTopic -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateTopic -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath CreateTopic where
  toPath :: CreateTopic -> ByteString
toPath = ByteString -> CreateTopic -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateTopic where
  toQuery :: CreateTopic -> QueryString
toQuery CreateTopic' {Maybe [Tag]
Maybe (HashMap Text Text)
Text
name :: Text
tags :: Maybe [Tag]
attributes :: Maybe (HashMap Text Text)
$sel:name:CreateTopic' :: CreateTopic -> Text
$sel:tags:CreateTopic' :: CreateTopic -> Maybe [Tag]
$sel:attributes:CreateTopic' :: CreateTopic -> Maybe (HashMap Text Text)
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateTopic" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"Attributes"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString
-> ByteString -> ByteString -> HashMap Text Text -> QueryString
forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Core.toQueryMap ByteString
"entry" ByteString
"key" ByteString
"value"
                (HashMap Text Text -> QueryString)
-> Maybe (HashMap Text Text) -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributes
            ),
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Tag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Tag] -> QueryString) -> Maybe [Tag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
        ByteString
"Name" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
name
      ]

-- | Response from CreateTopic action.
--
-- /See:/ 'newCreateTopicResponse' smart constructor.
data CreateTopicResponse = CreateTopicResponse'
  { -- | The Amazon Resource Name (ARN) assigned to the created topic.
    CreateTopicResponse -> Maybe Text
topicArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateTopicResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateTopicResponse -> CreateTopicResponse -> Bool
(CreateTopicResponse -> CreateTopicResponse -> Bool)
-> (CreateTopicResponse -> CreateTopicResponse -> Bool)
-> Eq CreateTopicResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTopicResponse -> CreateTopicResponse -> Bool
$c/= :: CreateTopicResponse -> CreateTopicResponse -> Bool
== :: CreateTopicResponse -> CreateTopicResponse -> Bool
$c== :: CreateTopicResponse -> CreateTopicResponse -> Bool
Prelude.Eq, ReadPrec [CreateTopicResponse]
ReadPrec CreateTopicResponse
Int -> ReadS CreateTopicResponse
ReadS [CreateTopicResponse]
(Int -> ReadS CreateTopicResponse)
-> ReadS [CreateTopicResponse]
-> ReadPrec CreateTopicResponse
-> ReadPrec [CreateTopicResponse]
-> Read CreateTopicResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTopicResponse]
$creadListPrec :: ReadPrec [CreateTopicResponse]
readPrec :: ReadPrec CreateTopicResponse
$creadPrec :: ReadPrec CreateTopicResponse
readList :: ReadS [CreateTopicResponse]
$creadList :: ReadS [CreateTopicResponse]
readsPrec :: Int -> ReadS CreateTopicResponse
$creadsPrec :: Int -> ReadS CreateTopicResponse
Prelude.Read, Int -> CreateTopicResponse -> ShowS
[CreateTopicResponse] -> ShowS
CreateTopicResponse -> String
(Int -> CreateTopicResponse -> ShowS)
-> (CreateTopicResponse -> String)
-> ([CreateTopicResponse] -> ShowS)
-> Show CreateTopicResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTopicResponse] -> ShowS
$cshowList :: [CreateTopicResponse] -> ShowS
show :: CreateTopicResponse -> String
$cshow :: CreateTopicResponse -> String
showsPrec :: Int -> CreateTopicResponse -> ShowS
$cshowsPrec :: Int -> CreateTopicResponse -> ShowS
Prelude.Show, (forall x. CreateTopicResponse -> Rep CreateTopicResponse x)
-> (forall x. Rep CreateTopicResponse x -> CreateTopicResponse)
-> Generic CreateTopicResponse
forall x. Rep CreateTopicResponse x -> CreateTopicResponse
forall x. CreateTopicResponse -> Rep CreateTopicResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTopicResponse x -> CreateTopicResponse
$cfrom :: forall x. CreateTopicResponse -> Rep CreateTopicResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateTopicResponse' 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', 'createTopicResponse_topicArn' - The Amazon Resource Name (ARN) assigned to the created topic.
--
-- 'httpStatus', 'createTopicResponse_httpStatus' - The response's http status code.
newCreateTopicResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTopicResponse
newCreateTopicResponse :: Int -> CreateTopicResponse
newCreateTopicResponse Int
pHttpStatus_ =
  CreateTopicResponse' :: Maybe Text -> Int -> CreateTopicResponse
CreateTopicResponse'
    { $sel:topicArn:CreateTopicResponse' :: Maybe Text
topicArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateTopicResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) assigned to the created topic.
createTopicResponse_topicArn :: Lens.Lens' CreateTopicResponse (Prelude.Maybe Prelude.Text)
createTopicResponse_topicArn :: (Maybe Text -> f (Maybe Text))
-> CreateTopicResponse -> f CreateTopicResponse
createTopicResponse_topicArn = (CreateTopicResponse -> Maybe Text)
-> (CreateTopicResponse -> Maybe Text -> CreateTopicResponse)
-> Lens
     CreateTopicResponse CreateTopicResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTopicResponse' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:CreateTopicResponse' :: CreateTopicResponse -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: CreateTopicResponse
s@CreateTopicResponse' {} Maybe Text
a -> CreateTopicResponse
s {$sel:topicArn:CreateTopicResponse' :: Maybe Text
topicArn = Maybe Text
a} :: CreateTopicResponse)

-- | The response's http status code.
createTopicResponse_httpStatus :: Lens.Lens' CreateTopicResponse Prelude.Int
createTopicResponse_httpStatus :: (Int -> f Int) -> CreateTopicResponse -> f CreateTopicResponse
createTopicResponse_httpStatus = (CreateTopicResponse -> Int)
-> (CreateTopicResponse -> Int -> CreateTopicResponse)
-> Lens CreateTopicResponse CreateTopicResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTopicResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateTopicResponse' :: CreateTopicResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateTopicResponse
s@CreateTopicResponse' {} Int
a -> CreateTopicResponse
s {$sel:httpStatus:CreateTopicResponse' :: Int
httpStatus = Int
a} :: CreateTopicResponse)

instance Prelude.NFData CreateTopicResponse