{-# 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.CodeStarNotifications.DeleteTarget
-- 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 specified target for notifications.
module Amazonka.CodeStarNotifications.DeleteTarget
  ( -- * Creating a Request
    DeleteTarget (..),
    newDeleteTarget,

    -- * Request Lenses
    deleteTarget_forceUnsubscribeAll,
    deleteTarget_targetAddress,

    -- * Destructuring the Response
    DeleteTargetResponse (..),
    newDeleteTargetResponse,

    -- * Response Lenses
    deleteTargetResponse_httpStatus,
  )
where

import Amazonka.CodeStarNotifications.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

-- | /See:/ 'newDeleteTarget' smart constructor.
data DeleteTarget = DeleteTarget'
  { -- | A Boolean value that can be used to delete all associations with this
    -- SNS topic. The default value is FALSE. If set to TRUE, all associations
    -- between that target and every notification rule in your AWS account are
    -- deleted.
    DeleteTarget -> Maybe Bool
forceUnsubscribeAll :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the SNS topic to delete.
    DeleteTarget -> Sensitive Text
targetAddress :: Core.Sensitive Prelude.Text
  }
  deriving (DeleteTarget -> DeleteTarget -> Bool
(DeleteTarget -> DeleteTarget -> Bool)
-> (DeleteTarget -> DeleteTarget -> Bool) -> Eq DeleteTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTarget -> DeleteTarget -> Bool
$c/= :: DeleteTarget -> DeleteTarget -> Bool
== :: DeleteTarget -> DeleteTarget -> Bool
$c== :: DeleteTarget -> DeleteTarget -> Bool
Prelude.Eq, Int -> DeleteTarget -> ShowS
[DeleteTarget] -> ShowS
DeleteTarget -> String
(Int -> DeleteTarget -> ShowS)
-> (DeleteTarget -> String)
-> ([DeleteTarget] -> ShowS)
-> Show DeleteTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTarget] -> ShowS
$cshowList :: [DeleteTarget] -> ShowS
show :: DeleteTarget -> String
$cshow :: DeleteTarget -> String
showsPrec :: Int -> DeleteTarget -> ShowS
$cshowsPrec :: Int -> DeleteTarget -> ShowS
Prelude.Show, (forall x. DeleteTarget -> Rep DeleteTarget x)
-> (forall x. Rep DeleteTarget x -> DeleteTarget)
-> Generic DeleteTarget
forall x. Rep DeleteTarget x -> DeleteTarget
forall x. DeleteTarget -> Rep DeleteTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTarget x -> DeleteTarget
$cfrom :: forall x. DeleteTarget -> Rep DeleteTarget x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTarget' 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:
--
-- 'forceUnsubscribeAll', 'deleteTarget_forceUnsubscribeAll' - A Boolean value that can be used to delete all associations with this
-- SNS topic. The default value is FALSE. If set to TRUE, all associations
-- between that target and every notification rule in your AWS account are
-- deleted.
--
-- 'targetAddress', 'deleteTarget_targetAddress' - The Amazon Resource Name (ARN) of the SNS topic to delete.
newDeleteTarget ::
  -- | 'targetAddress'
  Prelude.Text ->
  DeleteTarget
newDeleteTarget :: Text -> DeleteTarget
newDeleteTarget Text
pTargetAddress_ =
  DeleteTarget' :: Maybe Bool -> Sensitive Text -> DeleteTarget
DeleteTarget'
    { $sel:forceUnsubscribeAll:DeleteTarget' :: Maybe Bool
forceUnsubscribeAll =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:targetAddress:DeleteTarget' :: Sensitive Text
targetAddress =
        Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pTargetAddress_
    }

-- | A Boolean value that can be used to delete all associations with this
-- SNS topic. The default value is FALSE. If set to TRUE, all associations
-- between that target and every notification rule in your AWS account are
-- deleted.
deleteTarget_forceUnsubscribeAll :: Lens.Lens' DeleteTarget (Prelude.Maybe Prelude.Bool)
deleteTarget_forceUnsubscribeAll :: (Maybe Bool -> f (Maybe Bool)) -> DeleteTarget -> f DeleteTarget
deleteTarget_forceUnsubscribeAll = (DeleteTarget -> Maybe Bool)
-> (DeleteTarget -> Maybe Bool -> DeleteTarget)
-> Lens DeleteTarget DeleteTarget (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTarget' {Maybe Bool
forceUnsubscribeAll :: Maybe Bool
$sel:forceUnsubscribeAll:DeleteTarget' :: DeleteTarget -> Maybe Bool
forceUnsubscribeAll} -> Maybe Bool
forceUnsubscribeAll) (\s :: DeleteTarget
s@DeleteTarget' {} Maybe Bool
a -> DeleteTarget
s {$sel:forceUnsubscribeAll:DeleteTarget' :: Maybe Bool
forceUnsubscribeAll = Maybe Bool
a} :: DeleteTarget)

-- | The Amazon Resource Name (ARN) of the SNS topic to delete.
deleteTarget_targetAddress :: Lens.Lens' DeleteTarget Prelude.Text
deleteTarget_targetAddress :: (Text -> f Text) -> DeleteTarget -> f DeleteTarget
deleteTarget_targetAddress = (DeleteTarget -> Sensitive Text)
-> (DeleteTarget -> Sensitive Text -> DeleteTarget)
-> Lens DeleteTarget DeleteTarget (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTarget' {Sensitive Text
targetAddress :: Sensitive Text
$sel:targetAddress:DeleteTarget' :: DeleteTarget -> Sensitive Text
targetAddress} -> Sensitive Text
targetAddress) (\s :: DeleteTarget
s@DeleteTarget' {} Sensitive Text
a -> DeleteTarget
s {$sel:targetAddress:DeleteTarget' :: Sensitive Text
targetAddress = Sensitive Text
a} :: DeleteTarget) ((Sensitive Text -> f (Sensitive Text))
 -> DeleteTarget -> f DeleteTarget)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DeleteTarget
-> f DeleteTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.NFData DeleteTarget

instance Core.ToHeaders DeleteTarget where
  toHeaders :: DeleteTarget -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteTarget -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 DeleteTarget where
  toJSON :: DeleteTarget -> Value
toJSON DeleteTarget' {Maybe Bool
Sensitive Text
targetAddress :: Sensitive Text
forceUnsubscribeAll :: Maybe Bool
$sel:targetAddress:DeleteTarget' :: DeleteTarget -> Sensitive Text
$sel:forceUnsubscribeAll:DeleteTarget' :: DeleteTarget -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ForceUnsubscribeAll" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
forceUnsubscribeAll,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TargetAddress" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
targetAddress)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteTargetResponse