{-# 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.Budgets.DeleteSubscriber
-- 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)
--
-- Deletes a subscriber.
--
-- Deleting the last subscriber to a notification also deletes the
-- notification.
module Amazonka.Budgets.DeleteSubscriber
  ( -- * Creating a Request
    DeleteSubscriber (..),
    newDeleteSubscriber,

    -- * Request Lenses
    deleteSubscriber_accountId,
    deleteSubscriber_budgetName,
    deleteSubscriber_notification,
    deleteSubscriber_subscriber,

    -- * Destructuring the Response
    DeleteSubscriberResponse (..),
    newDeleteSubscriberResponse,

    -- * Response Lenses
    deleteSubscriberResponse_httpStatus,
  )
where

import Amazonka.Budgets.Types
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

-- | Request of DeleteSubscriber
--
-- /See:/ 'newDeleteSubscriber' smart constructor.
data DeleteSubscriber = DeleteSubscriber'
  { -- | The @accountId@ that is associated with the budget whose subscriber you
    -- want to delete.
    DeleteSubscriber -> Text
accountId :: Prelude.Text,
    -- | The name of the budget whose subscriber you want to delete.
    DeleteSubscriber -> Text
budgetName :: Prelude.Text,
    -- | The notification whose subscriber you want to delete.
    DeleteSubscriber -> Notification
notification :: Notification,
    -- | The subscriber that you want to delete.
    DeleteSubscriber -> Subscriber
subscriber :: Subscriber
  }
  deriving (DeleteSubscriber -> DeleteSubscriber -> Bool
(DeleteSubscriber -> DeleteSubscriber -> Bool)
-> (DeleteSubscriber -> DeleteSubscriber -> Bool)
-> Eq DeleteSubscriber
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSubscriber -> DeleteSubscriber -> Bool
$c/= :: DeleteSubscriber -> DeleteSubscriber -> Bool
== :: DeleteSubscriber -> DeleteSubscriber -> Bool
$c== :: DeleteSubscriber -> DeleteSubscriber -> Bool
Prelude.Eq, Int -> DeleteSubscriber -> ShowS
[DeleteSubscriber] -> ShowS
DeleteSubscriber -> String
(Int -> DeleteSubscriber -> ShowS)
-> (DeleteSubscriber -> String)
-> ([DeleteSubscriber] -> ShowS)
-> Show DeleteSubscriber
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSubscriber] -> ShowS
$cshowList :: [DeleteSubscriber] -> ShowS
show :: DeleteSubscriber -> String
$cshow :: DeleteSubscriber -> String
showsPrec :: Int -> DeleteSubscriber -> ShowS
$cshowsPrec :: Int -> DeleteSubscriber -> ShowS
Prelude.Show, (forall x. DeleteSubscriber -> Rep DeleteSubscriber x)
-> (forall x. Rep DeleteSubscriber x -> DeleteSubscriber)
-> Generic DeleteSubscriber
forall x. Rep DeleteSubscriber x -> DeleteSubscriber
forall x. DeleteSubscriber -> Rep DeleteSubscriber x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSubscriber x -> DeleteSubscriber
$cfrom :: forall x. DeleteSubscriber -> Rep DeleteSubscriber x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSubscriber' 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:
--
-- 'accountId', 'deleteSubscriber_accountId' - The @accountId@ that is associated with the budget whose subscriber you
-- want to delete.
--
-- 'budgetName', 'deleteSubscriber_budgetName' - The name of the budget whose subscriber you want to delete.
--
-- 'notification', 'deleteSubscriber_notification' - The notification whose subscriber you want to delete.
--
-- 'subscriber', 'deleteSubscriber_subscriber' - The subscriber that you want to delete.
newDeleteSubscriber ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'budgetName'
  Prelude.Text ->
  -- | 'notification'
  Notification ->
  -- | 'subscriber'
  Subscriber ->
  DeleteSubscriber
newDeleteSubscriber :: Text -> Text -> Notification -> Subscriber -> DeleteSubscriber
newDeleteSubscriber
  Text
pAccountId_
  Text
pBudgetName_
  Notification
pNotification_
  Subscriber
pSubscriber_ =
    DeleteSubscriber' :: Text -> Text -> Notification -> Subscriber -> DeleteSubscriber
DeleteSubscriber'
      { $sel:accountId:DeleteSubscriber' :: Text
accountId = Text
pAccountId_,
        $sel:budgetName:DeleteSubscriber' :: Text
budgetName = Text
pBudgetName_,
        $sel:notification:DeleteSubscriber' :: Notification
notification = Notification
pNotification_,
        $sel:subscriber:DeleteSubscriber' :: Subscriber
subscriber = Subscriber
pSubscriber_
      }

-- | The @accountId@ that is associated with the budget whose subscriber you
-- want to delete.
deleteSubscriber_accountId :: Lens.Lens' DeleteSubscriber Prelude.Text
deleteSubscriber_accountId :: (Text -> f Text) -> DeleteSubscriber -> f DeleteSubscriber
deleteSubscriber_accountId = (DeleteSubscriber -> Text)
-> (DeleteSubscriber -> Text -> DeleteSubscriber)
-> Lens DeleteSubscriber DeleteSubscriber Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSubscriber' {Text
accountId :: Text
$sel:accountId:DeleteSubscriber' :: DeleteSubscriber -> Text
accountId} -> Text
accountId) (\s :: DeleteSubscriber
s@DeleteSubscriber' {} Text
a -> DeleteSubscriber
s {$sel:accountId:DeleteSubscriber' :: Text
accountId = Text
a} :: DeleteSubscriber)

-- | The name of the budget whose subscriber you want to delete.
deleteSubscriber_budgetName :: Lens.Lens' DeleteSubscriber Prelude.Text
deleteSubscriber_budgetName :: (Text -> f Text) -> DeleteSubscriber -> f DeleteSubscriber
deleteSubscriber_budgetName = (DeleteSubscriber -> Text)
-> (DeleteSubscriber -> Text -> DeleteSubscriber)
-> Lens DeleteSubscriber DeleteSubscriber Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSubscriber' {Text
budgetName :: Text
$sel:budgetName:DeleteSubscriber' :: DeleteSubscriber -> Text
budgetName} -> Text
budgetName) (\s :: DeleteSubscriber
s@DeleteSubscriber' {} Text
a -> DeleteSubscriber
s {$sel:budgetName:DeleteSubscriber' :: Text
budgetName = Text
a} :: DeleteSubscriber)

-- | The notification whose subscriber you want to delete.
deleteSubscriber_notification :: Lens.Lens' DeleteSubscriber Notification
deleteSubscriber_notification :: (Notification -> f Notification)
-> DeleteSubscriber -> f DeleteSubscriber
deleteSubscriber_notification = (DeleteSubscriber -> Notification)
-> (DeleteSubscriber -> Notification -> DeleteSubscriber)
-> Lens DeleteSubscriber DeleteSubscriber Notification Notification
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSubscriber' {Notification
notification :: Notification
$sel:notification:DeleteSubscriber' :: DeleteSubscriber -> Notification
notification} -> Notification
notification) (\s :: DeleteSubscriber
s@DeleteSubscriber' {} Notification
a -> DeleteSubscriber
s {$sel:notification:DeleteSubscriber' :: Notification
notification = Notification
a} :: DeleteSubscriber)

-- | The subscriber that you want to delete.
deleteSubscriber_subscriber :: Lens.Lens' DeleteSubscriber Subscriber
deleteSubscriber_subscriber :: (Subscriber -> f Subscriber)
-> DeleteSubscriber -> f DeleteSubscriber
deleteSubscriber_subscriber = (DeleteSubscriber -> Subscriber)
-> (DeleteSubscriber -> Subscriber -> DeleteSubscriber)
-> Lens DeleteSubscriber DeleteSubscriber Subscriber Subscriber
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSubscriber' {Subscriber
subscriber :: Subscriber
$sel:subscriber:DeleteSubscriber' :: DeleteSubscriber -> Subscriber
subscriber} -> Subscriber
subscriber) (\s :: DeleteSubscriber
s@DeleteSubscriber' {} Subscriber
a -> DeleteSubscriber
s {$sel:subscriber:DeleteSubscriber' :: Subscriber
subscriber = Subscriber
a} :: DeleteSubscriber)

instance Core.AWSRequest DeleteSubscriber where
  type
    AWSResponse DeleteSubscriber =
      DeleteSubscriberResponse
  request :: DeleteSubscriber -> Request DeleteSubscriber
request = Service -> DeleteSubscriber -> Request DeleteSubscriber
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteSubscriber
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteSubscriber)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteSubscriber))
-> Logger
-> Service
-> Proxy DeleteSubscriber
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteSubscriber)))
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 -> DeleteSubscriberResponse
DeleteSubscriberResponse'
            (Int -> DeleteSubscriberResponse)
-> Either String Int -> Either String DeleteSubscriberResponse
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 DeleteSubscriber

instance Prelude.NFData DeleteSubscriber

instance Core.ToHeaders DeleteSubscriber where
  toHeaders :: DeleteSubscriber -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteSubscriber -> 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
"AWSBudgetServiceGateway.DeleteSubscriber" ::
                          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 DeleteSubscriber where
  toJSON :: DeleteSubscriber -> Value
toJSON DeleteSubscriber' {Text
Subscriber
Notification
subscriber :: Subscriber
notification :: Notification
budgetName :: Text
accountId :: Text
$sel:subscriber:DeleteSubscriber' :: DeleteSubscriber -> Subscriber
$sel:notification:DeleteSubscriber' :: DeleteSubscriber -> Notification
$sel:budgetName:DeleteSubscriber' :: DeleteSubscriber -> Text
$sel:accountId:DeleteSubscriber' :: DeleteSubscriber -> 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
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BudgetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
budgetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Notification" Text -> Notification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Notification
notification),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Subscriber" Text -> Subscriber -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Subscriber
subscriber)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteSubscriberResponse