{-# 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.Shield.DeleteProtection
-- 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 an Shield Advanced Protection.
module Amazonka.Shield.DeleteProtection
  ( -- * Creating a Request
    DeleteProtection (..),
    newDeleteProtection,

    -- * Request Lenses
    deleteProtection_protectionId,

    -- * Destructuring the Response
    DeleteProtectionResponse (..),
    newDeleteProtectionResponse,

    -- * Response Lenses
    deleteProtectionResponse_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.Shield.Types

-- | /See:/ 'newDeleteProtection' smart constructor.
data DeleteProtection = DeleteProtection'
  { -- | The unique identifier (ID) for the Protection object to be deleted.
    DeleteProtection -> Text
protectionId :: Prelude.Text
  }
  deriving (DeleteProtection -> DeleteProtection -> Bool
(DeleteProtection -> DeleteProtection -> Bool)
-> (DeleteProtection -> DeleteProtection -> Bool)
-> Eq DeleteProtection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProtection -> DeleteProtection -> Bool
$c/= :: DeleteProtection -> DeleteProtection -> Bool
== :: DeleteProtection -> DeleteProtection -> Bool
$c== :: DeleteProtection -> DeleteProtection -> Bool
Prelude.Eq, ReadPrec [DeleteProtection]
ReadPrec DeleteProtection
Int -> ReadS DeleteProtection
ReadS [DeleteProtection]
(Int -> ReadS DeleteProtection)
-> ReadS [DeleteProtection]
-> ReadPrec DeleteProtection
-> ReadPrec [DeleteProtection]
-> Read DeleteProtection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProtection]
$creadListPrec :: ReadPrec [DeleteProtection]
readPrec :: ReadPrec DeleteProtection
$creadPrec :: ReadPrec DeleteProtection
readList :: ReadS [DeleteProtection]
$creadList :: ReadS [DeleteProtection]
readsPrec :: Int -> ReadS DeleteProtection
$creadsPrec :: Int -> ReadS DeleteProtection
Prelude.Read, Int -> DeleteProtection -> ShowS
[DeleteProtection] -> ShowS
DeleteProtection -> String
(Int -> DeleteProtection -> ShowS)
-> (DeleteProtection -> String)
-> ([DeleteProtection] -> ShowS)
-> Show DeleteProtection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProtection] -> ShowS
$cshowList :: [DeleteProtection] -> ShowS
show :: DeleteProtection -> String
$cshow :: DeleteProtection -> String
showsPrec :: Int -> DeleteProtection -> ShowS
$cshowsPrec :: Int -> DeleteProtection -> ShowS
Prelude.Show, (forall x. DeleteProtection -> Rep DeleteProtection x)
-> (forall x. Rep DeleteProtection x -> DeleteProtection)
-> Generic DeleteProtection
forall x. Rep DeleteProtection x -> DeleteProtection
forall x. DeleteProtection -> Rep DeleteProtection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProtection x -> DeleteProtection
$cfrom :: forall x. DeleteProtection -> Rep DeleteProtection x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProtection' 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:
--
-- 'protectionId', 'deleteProtection_protectionId' - The unique identifier (ID) for the Protection object to be deleted.
newDeleteProtection ::
  -- | 'protectionId'
  Prelude.Text ->
  DeleteProtection
newDeleteProtection :: Text -> DeleteProtection
newDeleteProtection Text
pProtectionId_ =
  DeleteProtection' :: Text -> DeleteProtection
DeleteProtection' {$sel:protectionId:DeleteProtection' :: Text
protectionId = Text
pProtectionId_}

-- | The unique identifier (ID) for the Protection object to be deleted.
deleteProtection_protectionId :: Lens.Lens' DeleteProtection Prelude.Text
deleteProtection_protectionId :: (Text -> f Text) -> DeleteProtection -> f DeleteProtection
deleteProtection_protectionId = (DeleteProtection -> Text)
-> (DeleteProtection -> Text -> DeleteProtection)
-> Lens DeleteProtection DeleteProtection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProtection' {Text
protectionId :: Text
$sel:protectionId:DeleteProtection' :: DeleteProtection -> Text
protectionId} -> Text
protectionId) (\s :: DeleteProtection
s@DeleteProtection' {} Text
a -> DeleteProtection
s {$sel:protectionId:DeleteProtection' :: Text
protectionId = Text
a} :: DeleteProtection)

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

instance Prelude.NFData DeleteProtection

instance Core.ToHeaders DeleteProtection where
  toHeaders :: DeleteProtection -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteProtection -> 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
"AWSShield_20160616.DeleteProtection" ::
                          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 DeleteProtection where
  toJSON :: DeleteProtection -> Value
toJSON DeleteProtection' {Text
protectionId :: Text
$sel:protectionId:DeleteProtection' :: DeleteProtection -> 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
"ProtectionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
protectionId)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteProtectionResponse