{-# 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.CloudHSM.DeleteHapg
-- 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)
--
-- This is documentation for __AWS CloudHSM Classic__. For more
-- information, see
-- <http://aws.amazon.com/cloudhsm/faqs-classic/ AWS CloudHSM Classic FAQs>,
-- the
-- <https://docs.aws.amazon.com/cloudhsm/classic/userguide/ AWS CloudHSM Classic User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/classic/APIReference/ AWS CloudHSM Classic API Reference>.
--
-- __For information about the current version of AWS CloudHSM__, see
-- <http://aws.amazon.com/cloudhsm/ AWS CloudHSM>, the
-- <https://docs.aws.amazon.com/cloudhsm/latest/userguide/ AWS CloudHSM User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/latest/APIReference/ AWS CloudHSM API Reference>.
--
-- Deletes a high-availability partition group.
module Amazonka.CloudHSM.DeleteHapg
  ( -- * Creating a Request
    DeleteHapg (..),
    newDeleteHapg,

    -- * Request Lenses
    deleteHapg_hapgArn,

    -- * Destructuring the Response
    DeleteHapgResponse (..),
    newDeleteHapgResponse,

    -- * Response Lenses
    deleteHapgResponse_httpStatus,
    deleteHapgResponse_status,
  )
where

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

-- | Contains the inputs for the DeleteHapg action.
--
-- /See:/ 'newDeleteHapg' smart constructor.
data DeleteHapg = DeleteHapg'
  { -- | The ARN of the high-availability partition group to delete.
    DeleteHapg -> Text
hapgArn :: Prelude.Text
  }
  deriving (DeleteHapg -> DeleteHapg -> Bool
(DeleteHapg -> DeleteHapg -> Bool)
-> (DeleteHapg -> DeleteHapg -> Bool) -> Eq DeleteHapg
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteHapg -> DeleteHapg -> Bool
$c/= :: DeleteHapg -> DeleteHapg -> Bool
== :: DeleteHapg -> DeleteHapg -> Bool
$c== :: DeleteHapg -> DeleteHapg -> Bool
Prelude.Eq, ReadPrec [DeleteHapg]
ReadPrec DeleteHapg
Int -> ReadS DeleteHapg
ReadS [DeleteHapg]
(Int -> ReadS DeleteHapg)
-> ReadS [DeleteHapg]
-> ReadPrec DeleteHapg
-> ReadPrec [DeleteHapg]
-> Read DeleteHapg
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteHapg]
$creadListPrec :: ReadPrec [DeleteHapg]
readPrec :: ReadPrec DeleteHapg
$creadPrec :: ReadPrec DeleteHapg
readList :: ReadS [DeleteHapg]
$creadList :: ReadS [DeleteHapg]
readsPrec :: Int -> ReadS DeleteHapg
$creadsPrec :: Int -> ReadS DeleteHapg
Prelude.Read, Int -> DeleteHapg -> ShowS
[DeleteHapg] -> ShowS
DeleteHapg -> String
(Int -> DeleteHapg -> ShowS)
-> (DeleteHapg -> String)
-> ([DeleteHapg] -> ShowS)
-> Show DeleteHapg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteHapg] -> ShowS
$cshowList :: [DeleteHapg] -> ShowS
show :: DeleteHapg -> String
$cshow :: DeleteHapg -> String
showsPrec :: Int -> DeleteHapg -> ShowS
$cshowsPrec :: Int -> DeleteHapg -> ShowS
Prelude.Show, (forall x. DeleteHapg -> Rep DeleteHapg x)
-> (forall x. Rep DeleteHapg x -> DeleteHapg) -> Generic DeleteHapg
forall x. Rep DeleteHapg x -> DeleteHapg
forall x. DeleteHapg -> Rep DeleteHapg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteHapg x -> DeleteHapg
$cfrom :: forall x. DeleteHapg -> Rep DeleteHapg x
Prelude.Generic)

-- |
-- Create a value of 'DeleteHapg' 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:
--
-- 'hapgArn', 'deleteHapg_hapgArn' - The ARN of the high-availability partition group to delete.
newDeleteHapg ::
  -- | 'hapgArn'
  Prelude.Text ->
  DeleteHapg
newDeleteHapg :: Text -> DeleteHapg
newDeleteHapg Text
pHapgArn_ =
  DeleteHapg' :: Text -> DeleteHapg
DeleteHapg' {$sel:hapgArn:DeleteHapg' :: Text
hapgArn = Text
pHapgArn_}

-- | The ARN of the high-availability partition group to delete.
deleteHapg_hapgArn :: Lens.Lens' DeleteHapg Prelude.Text
deleteHapg_hapgArn :: (Text -> f Text) -> DeleteHapg -> f DeleteHapg
deleteHapg_hapgArn = (DeleteHapg -> Text)
-> (DeleteHapg -> Text -> DeleteHapg)
-> Lens DeleteHapg DeleteHapg Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteHapg' {Text
hapgArn :: Text
$sel:hapgArn:DeleteHapg' :: DeleteHapg -> Text
hapgArn} -> Text
hapgArn) (\s :: DeleteHapg
s@DeleteHapg' {} Text
a -> DeleteHapg
s {$sel:hapgArn:DeleteHapg' :: Text
hapgArn = Text
a} :: DeleteHapg)

instance Core.AWSRequest DeleteHapg where
  type AWSResponse DeleteHapg = DeleteHapgResponse
  request :: DeleteHapg -> Request DeleteHapg
request = Service -> DeleteHapg -> Request DeleteHapg
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteHapg
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHapg)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteHapg))
-> Logger
-> Service
-> Proxy DeleteHapg
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHapg)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> DeleteHapgResponse
DeleteHapgResponse'
            (Int -> Text -> DeleteHapgResponse)
-> Either String Int -> Either String (Text -> DeleteHapgResponse)
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))
            Either String (Text -> DeleteHapgResponse)
-> Either String Text -> Either String DeleteHapgResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Status")
      )

instance Prelude.Hashable DeleteHapg

instance Prelude.NFData DeleteHapg

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

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

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

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

-- |
-- Create a value of 'DeleteHapgResponse' 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', 'deleteHapgResponse_httpStatus' - The response's http status code.
--
-- 'status', 'deleteHapgResponse_status' - The status of the action.
newDeleteHapgResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'status'
  Prelude.Text ->
  DeleteHapgResponse
newDeleteHapgResponse :: Int -> Text -> DeleteHapgResponse
newDeleteHapgResponse Int
pHttpStatus_ Text
pStatus_ =
  DeleteHapgResponse' :: Int -> Text -> DeleteHapgResponse
DeleteHapgResponse'
    { $sel:httpStatus:DeleteHapgResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:status:DeleteHapgResponse' :: Text
status = Text
pStatus_
    }

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

-- | The status of the action.
deleteHapgResponse_status :: Lens.Lens' DeleteHapgResponse Prelude.Text
deleteHapgResponse_status :: (Text -> f Text) -> DeleteHapgResponse -> f DeleteHapgResponse
deleteHapgResponse_status = (DeleteHapgResponse -> Text)
-> (DeleteHapgResponse -> Text -> DeleteHapgResponse)
-> Lens DeleteHapgResponse DeleteHapgResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteHapgResponse' {Text
status :: Text
$sel:status:DeleteHapgResponse' :: DeleteHapgResponse -> Text
status} -> Text
status) (\s :: DeleteHapgResponse
s@DeleteHapgResponse' {} Text
a -> DeleteHapgResponse
s {$sel:status:DeleteHapgResponse' :: Text
status = Text
a} :: DeleteHapgResponse)

instance Prelude.NFData DeleteHapgResponse