{-# 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.CloudHSMV2.DeleteCluster
-- 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 the specified AWS CloudHSM cluster. Before you can delete a
-- cluster, you must delete all HSMs in the cluster. To see if the cluster
-- contains any HSMs, use DescribeClusters. To delete an HSM, use
-- DeleteHsm.
module Amazonka.CloudHSMV2.DeleteCluster
  ( -- * Creating a Request
    DeleteCluster (..),
    newDeleteCluster,

    -- * Request Lenses
    deleteCluster_clusterId,

    -- * Destructuring the Response
    DeleteClusterResponse (..),
    newDeleteClusterResponse,

    -- * Response Lenses
    deleteClusterResponse_cluster,
    deleteClusterResponse_httpStatus,
  )
where

import Amazonka.CloudHSMV2.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:/ 'newDeleteCluster' smart constructor.
data DeleteCluster = DeleteCluster'
  { -- | The identifier (ID) of the cluster that you are deleting. To find the
    -- cluster ID, use DescribeClusters.
    DeleteCluster -> Text
clusterId :: Prelude.Text
  }
  deriving (DeleteCluster -> DeleteCluster -> Bool
(DeleteCluster -> DeleteCluster -> Bool)
-> (DeleteCluster -> DeleteCluster -> Bool) -> Eq DeleteCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCluster -> DeleteCluster -> Bool
$c/= :: DeleteCluster -> DeleteCluster -> Bool
== :: DeleteCluster -> DeleteCluster -> Bool
$c== :: DeleteCluster -> DeleteCluster -> Bool
Prelude.Eq, ReadPrec [DeleteCluster]
ReadPrec DeleteCluster
Int -> ReadS DeleteCluster
ReadS [DeleteCluster]
(Int -> ReadS DeleteCluster)
-> ReadS [DeleteCluster]
-> ReadPrec DeleteCluster
-> ReadPrec [DeleteCluster]
-> Read DeleteCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCluster]
$creadListPrec :: ReadPrec [DeleteCluster]
readPrec :: ReadPrec DeleteCluster
$creadPrec :: ReadPrec DeleteCluster
readList :: ReadS [DeleteCluster]
$creadList :: ReadS [DeleteCluster]
readsPrec :: Int -> ReadS DeleteCluster
$creadsPrec :: Int -> ReadS DeleteCluster
Prelude.Read, Int -> DeleteCluster -> ShowS
[DeleteCluster] -> ShowS
DeleteCluster -> String
(Int -> DeleteCluster -> ShowS)
-> (DeleteCluster -> String)
-> ([DeleteCluster] -> ShowS)
-> Show DeleteCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCluster] -> ShowS
$cshowList :: [DeleteCluster] -> ShowS
show :: DeleteCluster -> String
$cshow :: DeleteCluster -> String
showsPrec :: Int -> DeleteCluster -> ShowS
$cshowsPrec :: Int -> DeleteCluster -> ShowS
Prelude.Show, (forall x. DeleteCluster -> Rep DeleteCluster x)
-> (forall x. Rep DeleteCluster x -> DeleteCluster)
-> Generic DeleteCluster
forall x. Rep DeleteCluster x -> DeleteCluster
forall x. DeleteCluster -> Rep DeleteCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCluster x -> DeleteCluster
$cfrom :: forall x. DeleteCluster -> Rep DeleteCluster x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCluster' 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:
--
-- 'clusterId', 'deleteCluster_clusterId' - The identifier (ID) of the cluster that you are deleting. To find the
-- cluster ID, use DescribeClusters.
newDeleteCluster ::
  -- | 'clusterId'
  Prelude.Text ->
  DeleteCluster
newDeleteCluster :: Text -> DeleteCluster
newDeleteCluster Text
pClusterId_ =
  DeleteCluster' :: Text -> DeleteCluster
DeleteCluster' {$sel:clusterId:DeleteCluster' :: Text
clusterId = Text
pClusterId_}

-- | The identifier (ID) of the cluster that you are deleting. To find the
-- cluster ID, use DescribeClusters.
deleteCluster_clusterId :: Lens.Lens' DeleteCluster Prelude.Text
deleteCluster_clusterId :: (Text -> f Text) -> DeleteCluster -> f DeleteCluster
deleteCluster_clusterId = (DeleteCluster -> Text)
-> (DeleteCluster -> Text -> DeleteCluster)
-> Lens DeleteCluster DeleteCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCluster' {Text
clusterId :: Text
$sel:clusterId:DeleteCluster' :: DeleteCluster -> Text
clusterId} -> Text
clusterId) (\s :: DeleteCluster
s@DeleteCluster' {} Text
a -> DeleteCluster
s {$sel:clusterId:DeleteCluster' :: Text
clusterId = Text
a} :: DeleteCluster)

instance Core.AWSRequest DeleteCluster where
  type
    AWSResponse DeleteCluster =
      DeleteClusterResponse
  request :: DeleteCluster -> Request DeleteCluster
request = Service -> DeleteCluster -> Request DeleteCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteCluster)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteCluster))
-> Logger
-> Service
-> Proxy DeleteCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteCluster)))
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 ->
          Maybe Cluster -> Int -> DeleteClusterResponse
DeleteClusterResponse'
            (Maybe Cluster -> Int -> DeleteClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> DeleteClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Cluster)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Cluster")
            Either String (Int -> DeleteClusterResponse)
-> Either String Int -> Either String DeleteClusterResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteCluster

instance Prelude.NFData DeleteCluster

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

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

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

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

-- |
-- Create a value of 'DeleteClusterResponse' 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:
--
-- 'cluster', 'deleteClusterResponse_cluster' - Information about the cluster that was deleted.
--
-- 'httpStatus', 'deleteClusterResponse_httpStatus' - The response's http status code.
newDeleteClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteClusterResponse
newDeleteClusterResponse :: Int -> DeleteClusterResponse
newDeleteClusterResponse Int
pHttpStatus_ =
  DeleteClusterResponse' :: Maybe Cluster -> Int -> DeleteClusterResponse
DeleteClusterResponse'
    { $sel:cluster:DeleteClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the cluster that was deleted.
deleteClusterResponse_cluster :: Lens.Lens' DeleteClusterResponse (Prelude.Maybe Cluster)
deleteClusterResponse_cluster :: (Maybe Cluster -> f (Maybe Cluster))
-> DeleteClusterResponse -> f DeleteClusterResponse
deleteClusterResponse_cluster = (DeleteClusterResponse -> Maybe Cluster)
-> (DeleteClusterResponse
    -> Maybe Cluster -> DeleteClusterResponse)
-> Lens
     DeleteClusterResponse
     DeleteClusterResponse
     (Maybe Cluster)
     (Maybe Cluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteClusterResponse' {Maybe Cluster
cluster :: Maybe Cluster
$sel:cluster:DeleteClusterResponse' :: DeleteClusterResponse -> Maybe Cluster
cluster} -> Maybe Cluster
cluster) (\s :: DeleteClusterResponse
s@DeleteClusterResponse' {} Maybe Cluster
a -> DeleteClusterResponse
s {$sel:cluster:DeleteClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
a} :: DeleteClusterResponse)

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

instance Prelude.NFData DeleteClusterResponse