{-# 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.DirectoryService.DeregisterEventTopic
-- 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)
--
-- Removes the specified directory as a publisher to the specified Amazon
-- SNS topic.
module Amazonka.DirectoryService.DeregisterEventTopic
  ( -- * Creating a Request
    DeregisterEventTopic (..),
    newDeregisterEventTopic,

    -- * Request Lenses
    deregisterEventTopic_directoryId,
    deregisterEventTopic_topicName,

    -- * Destructuring the Response
    DeregisterEventTopicResponse (..),
    newDeregisterEventTopicResponse,

    -- * Response Lenses
    deregisterEventTopicResponse_httpStatus,
  )
where

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

-- | Removes the specified directory as a publisher to the specified Amazon
-- SNS topic.
--
-- /See:/ 'newDeregisterEventTopic' smart constructor.
data DeregisterEventTopic = DeregisterEventTopic'
  { -- | The Directory ID to remove as a publisher. This directory will no longer
    -- send messages to the specified Amazon SNS topic.
    DeregisterEventTopic -> Text
directoryId :: Prelude.Text,
    -- | The name of the Amazon SNS topic from which to remove the directory as a
    -- publisher.
    DeregisterEventTopic -> Text
topicName :: Prelude.Text
  }
  deriving (DeregisterEventTopic -> DeregisterEventTopic -> Bool
(DeregisterEventTopic -> DeregisterEventTopic -> Bool)
-> (DeregisterEventTopic -> DeregisterEventTopic -> Bool)
-> Eq DeregisterEventTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterEventTopic -> DeregisterEventTopic -> Bool
$c/= :: DeregisterEventTopic -> DeregisterEventTopic -> Bool
== :: DeregisterEventTopic -> DeregisterEventTopic -> Bool
$c== :: DeregisterEventTopic -> DeregisterEventTopic -> Bool
Prelude.Eq, ReadPrec [DeregisterEventTopic]
ReadPrec DeregisterEventTopic
Int -> ReadS DeregisterEventTopic
ReadS [DeregisterEventTopic]
(Int -> ReadS DeregisterEventTopic)
-> ReadS [DeregisterEventTopic]
-> ReadPrec DeregisterEventTopic
-> ReadPrec [DeregisterEventTopic]
-> Read DeregisterEventTopic
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterEventTopic]
$creadListPrec :: ReadPrec [DeregisterEventTopic]
readPrec :: ReadPrec DeregisterEventTopic
$creadPrec :: ReadPrec DeregisterEventTopic
readList :: ReadS [DeregisterEventTopic]
$creadList :: ReadS [DeregisterEventTopic]
readsPrec :: Int -> ReadS DeregisterEventTopic
$creadsPrec :: Int -> ReadS DeregisterEventTopic
Prelude.Read, Int -> DeregisterEventTopic -> ShowS
[DeregisterEventTopic] -> ShowS
DeregisterEventTopic -> String
(Int -> DeregisterEventTopic -> ShowS)
-> (DeregisterEventTopic -> String)
-> ([DeregisterEventTopic] -> ShowS)
-> Show DeregisterEventTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterEventTopic] -> ShowS
$cshowList :: [DeregisterEventTopic] -> ShowS
show :: DeregisterEventTopic -> String
$cshow :: DeregisterEventTopic -> String
showsPrec :: Int -> DeregisterEventTopic -> ShowS
$cshowsPrec :: Int -> DeregisterEventTopic -> ShowS
Prelude.Show, (forall x. DeregisterEventTopic -> Rep DeregisterEventTopic x)
-> (forall x. Rep DeregisterEventTopic x -> DeregisterEventTopic)
-> Generic DeregisterEventTopic
forall x. Rep DeregisterEventTopic x -> DeregisterEventTopic
forall x. DeregisterEventTopic -> Rep DeregisterEventTopic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterEventTopic x -> DeregisterEventTopic
$cfrom :: forall x. DeregisterEventTopic -> Rep DeregisterEventTopic x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterEventTopic' 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:
--
-- 'directoryId', 'deregisterEventTopic_directoryId' - The Directory ID to remove as a publisher. This directory will no longer
-- send messages to the specified Amazon SNS topic.
--
-- 'topicName', 'deregisterEventTopic_topicName' - The name of the Amazon SNS topic from which to remove the directory as a
-- publisher.
newDeregisterEventTopic ::
  -- | 'directoryId'
  Prelude.Text ->
  -- | 'topicName'
  Prelude.Text ->
  DeregisterEventTopic
newDeregisterEventTopic :: Text -> Text -> DeregisterEventTopic
newDeregisterEventTopic Text
pDirectoryId_ Text
pTopicName_ =
  DeregisterEventTopic' :: Text -> Text -> DeregisterEventTopic
DeregisterEventTopic'
    { $sel:directoryId:DeregisterEventTopic' :: Text
directoryId = Text
pDirectoryId_,
      $sel:topicName:DeregisterEventTopic' :: Text
topicName = Text
pTopicName_
    }

-- | The Directory ID to remove as a publisher. This directory will no longer
-- send messages to the specified Amazon SNS topic.
deregisterEventTopic_directoryId :: Lens.Lens' DeregisterEventTopic Prelude.Text
deregisterEventTopic_directoryId :: (Text -> f Text) -> DeregisterEventTopic -> f DeregisterEventTopic
deregisterEventTopic_directoryId = (DeregisterEventTopic -> Text)
-> (DeregisterEventTopic -> Text -> DeregisterEventTopic)
-> Lens DeregisterEventTopic DeregisterEventTopic Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterEventTopic' {Text
directoryId :: Text
$sel:directoryId:DeregisterEventTopic' :: DeregisterEventTopic -> Text
directoryId} -> Text
directoryId) (\s :: DeregisterEventTopic
s@DeregisterEventTopic' {} Text
a -> DeregisterEventTopic
s {$sel:directoryId:DeregisterEventTopic' :: Text
directoryId = Text
a} :: DeregisterEventTopic)

-- | The name of the Amazon SNS topic from which to remove the directory as a
-- publisher.
deregisterEventTopic_topicName :: Lens.Lens' DeregisterEventTopic Prelude.Text
deregisterEventTopic_topicName :: (Text -> f Text) -> DeregisterEventTopic -> f DeregisterEventTopic
deregisterEventTopic_topicName = (DeregisterEventTopic -> Text)
-> (DeregisterEventTopic -> Text -> DeregisterEventTopic)
-> Lens DeregisterEventTopic DeregisterEventTopic Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterEventTopic' {Text
topicName :: Text
$sel:topicName:DeregisterEventTopic' :: DeregisterEventTopic -> Text
topicName} -> Text
topicName) (\s :: DeregisterEventTopic
s@DeregisterEventTopic' {} Text
a -> DeregisterEventTopic
s {$sel:topicName:DeregisterEventTopic' :: Text
topicName = Text
a} :: DeregisterEventTopic)

instance Core.AWSRequest DeregisterEventTopic where
  type
    AWSResponse DeregisterEventTopic =
      DeregisterEventTopicResponse
  request :: DeregisterEventTopic -> Request DeregisterEventTopic
request = Service -> DeregisterEventTopic -> Request DeregisterEventTopic
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterEventTopic
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterEventTopic)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeregisterEventTopic))
-> Logger
-> Service
-> Proxy DeregisterEventTopic
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterEventTopic)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeregisterEventTopicResponse
DeregisterEventTopicResponse'
            (Int -> DeregisterEventTopicResponse)
-> Either String Int -> Either String DeregisterEventTopicResponse
forall (f :: * -> *) a b. Functor 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 DeregisterEventTopic

instance Prelude.NFData DeregisterEventTopic

instance Core.ToHeaders DeregisterEventTopic where
  toHeaders :: DeregisterEventTopic -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeregisterEventTopic -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DirectoryService_20150416.DeregisterEventTopic" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeregisterEventTopic where
  toJSON :: DeregisterEventTopic -> Value
toJSON DeregisterEventTopic' {Text
topicName :: Text
directoryId :: Text
$sel:topicName:DeregisterEventTopic' :: DeregisterEventTopic -> Text
$sel:directoryId:DeregisterEventTopic' :: DeregisterEventTopic -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TopicName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
topicName)
          ]
      )

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

instance Core.ToQuery DeregisterEventTopic where
  toQuery :: DeregisterEventTopic -> QueryString
toQuery = QueryString -> DeregisterEventTopic -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | The result of a DeregisterEventTopic request.
--
-- /See:/ 'newDeregisterEventTopicResponse' smart constructor.
data DeregisterEventTopicResponse = DeregisterEventTopicResponse'
  { -- | The response's http status code.
    DeregisterEventTopicResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeregisterEventTopicResponse
-> DeregisterEventTopicResponse -> Bool
(DeregisterEventTopicResponse
 -> DeregisterEventTopicResponse -> Bool)
-> (DeregisterEventTopicResponse
    -> DeregisterEventTopicResponse -> Bool)
-> Eq DeregisterEventTopicResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterEventTopicResponse
-> DeregisterEventTopicResponse -> Bool
$c/= :: DeregisterEventTopicResponse
-> DeregisterEventTopicResponse -> Bool
== :: DeregisterEventTopicResponse
-> DeregisterEventTopicResponse -> Bool
$c== :: DeregisterEventTopicResponse
-> DeregisterEventTopicResponse -> Bool
Prelude.Eq, ReadPrec [DeregisterEventTopicResponse]
ReadPrec DeregisterEventTopicResponse
Int -> ReadS DeregisterEventTopicResponse
ReadS [DeregisterEventTopicResponse]
(Int -> ReadS DeregisterEventTopicResponse)
-> ReadS [DeregisterEventTopicResponse]
-> ReadPrec DeregisterEventTopicResponse
-> ReadPrec [DeregisterEventTopicResponse]
-> Read DeregisterEventTopicResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterEventTopicResponse]
$creadListPrec :: ReadPrec [DeregisterEventTopicResponse]
readPrec :: ReadPrec DeregisterEventTopicResponse
$creadPrec :: ReadPrec DeregisterEventTopicResponse
readList :: ReadS [DeregisterEventTopicResponse]
$creadList :: ReadS [DeregisterEventTopicResponse]
readsPrec :: Int -> ReadS DeregisterEventTopicResponse
$creadsPrec :: Int -> ReadS DeregisterEventTopicResponse
Prelude.Read, Int -> DeregisterEventTopicResponse -> ShowS
[DeregisterEventTopicResponse] -> ShowS
DeregisterEventTopicResponse -> String
(Int -> DeregisterEventTopicResponse -> ShowS)
-> (DeregisterEventTopicResponse -> String)
-> ([DeregisterEventTopicResponse] -> ShowS)
-> Show DeregisterEventTopicResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterEventTopicResponse] -> ShowS
$cshowList :: [DeregisterEventTopicResponse] -> ShowS
show :: DeregisterEventTopicResponse -> String
$cshow :: DeregisterEventTopicResponse -> String
showsPrec :: Int -> DeregisterEventTopicResponse -> ShowS
$cshowsPrec :: Int -> DeregisterEventTopicResponse -> ShowS
Prelude.Show, (forall x.
 DeregisterEventTopicResponse -> Rep DeregisterEventTopicResponse x)
-> (forall x.
    Rep DeregisterEventTopicResponse x -> DeregisterEventTopicResponse)
-> Generic DeregisterEventTopicResponse
forall x.
Rep DeregisterEventTopicResponse x -> DeregisterEventTopicResponse
forall x.
DeregisterEventTopicResponse -> Rep DeregisterEventTopicResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterEventTopicResponse x -> DeregisterEventTopicResponse
$cfrom :: forall x.
DeregisterEventTopicResponse -> Rep DeregisterEventTopicResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterEventTopicResponse' 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:
--
-- 'httpStatus', 'deregisterEventTopicResponse_httpStatus' - The response's http status code.
newDeregisterEventTopicResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterEventTopicResponse
newDeregisterEventTopicResponse :: Int -> DeregisterEventTopicResponse
newDeregisterEventTopicResponse Int
pHttpStatus_ =
  DeregisterEventTopicResponse' :: Int -> DeregisterEventTopicResponse
DeregisterEventTopicResponse'
    { $sel:httpStatus:DeregisterEventTopicResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeregisterEventTopicResponse