{-# 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.DocumentDB.DeleteGlobalCluster
-- 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 global cluster. The primary and secondary clusters must
-- already be detached or deleted before attempting to delete a global
-- cluster.
--
-- This action only applies to Amazon DocumentDB clusters.
module Amazonka.DocumentDB.DeleteGlobalCluster
  ( -- * Creating a Request
    DeleteGlobalCluster (..),
    newDeleteGlobalCluster,

    -- * Request Lenses
    deleteGlobalCluster_globalClusterIdentifier,

    -- * Destructuring the Response
    DeleteGlobalClusterResponse (..),
    newDeleteGlobalClusterResponse,

    -- * Response Lenses
    deleteGlobalClusterResponse_globalCluster,
    deleteGlobalClusterResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DocumentDB.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input to DeleteGlobalCluster.
--
-- /See:/ 'newDeleteGlobalCluster' smart constructor.
data DeleteGlobalCluster = DeleteGlobalCluster'
  { -- | The cluster identifier of the global cluster being deleted.
    DeleteGlobalCluster -> Text
globalClusterIdentifier :: Prelude.Text
  }
  deriving (DeleteGlobalCluster -> DeleteGlobalCluster -> Bool
(DeleteGlobalCluster -> DeleteGlobalCluster -> Bool)
-> (DeleteGlobalCluster -> DeleteGlobalCluster -> Bool)
-> Eq DeleteGlobalCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteGlobalCluster -> DeleteGlobalCluster -> Bool
$c/= :: DeleteGlobalCluster -> DeleteGlobalCluster -> Bool
== :: DeleteGlobalCluster -> DeleteGlobalCluster -> Bool
$c== :: DeleteGlobalCluster -> DeleteGlobalCluster -> Bool
Prelude.Eq, ReadPrec [DeleteGlobalCluster]
ReadPrec DeleteGlobalCluster
Int -> ReadS DeleteGlobalCluster
ReadS [DeleteGlobalCluster]
(Int -> ReadS DeleteGlobalCluster)
-> ReadS [DeleteGlobalCluster]
-> ReadPrec DeleteGlobalCluster
-> ReadPrec [DeleteGlobalCluster]
-> Read DeleteGlobalCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteGlobalCluster]
$creadListPrec :: ReadPrec [DeleteGlobalCluster]
readPrec :: ReadPrec DeleteGlobalCluster
$creadPrec :: ReadPrec DeleteGlobalCluster
readList :: ReadS [DeleteGlobalCluster]
$creadList :: ReadS [DeleteGlobalCluster]
readsPrec :: Int -> ReadS DeleteGlobalCluster
$creadsPrec :: Int -> ReadS DeleteGlobalCluster
Prelude.Read, Int -> DeleteGlobalCluster -> ShowS
[DeleteGlobalCluster] -> ShowS
DeleteGlobalCluster -> String
(Int -> DeleteGlobalCluster -> ShowS)
-> (DeleteGlobalCluster -> String)
-> ([DeleteGlobalCluster] -> ShowS)
-> Show DeleteGlobalCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteGlobalCluster] -> ShowS
$cshowList :: [DeleteGlobalCluster] -> ShowS
show :: DeleteGlobalCluster -> String
$cshow :: DeleteGlobalCluster -> String
showsPrec :: Int -> DeleteGlobalCluster -> ShowS
$cshowsPrec :: Int -> DeleteGlobalCluster -> ShowS
Prelude.Show, (forall x. DeleteGlobalCluster -> Rep DeleteGlobalCluster x)
-> (forall x. Rep DeleteGlobalCluster x -> DeleteGlobalCluster)
-> Generic DeleteGlobalCluster
forall x. Rep DeleteGlobalCluster x -> DeleteGlobalCluster
forall x. DeleteGlobalCluster -> Rep DeleteGlobalCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteGlobalCluster x -> DeleteGlobalCluster
$cfrom :: forall x. DeleteGlobalCluster -> Rep DeleteGlobalCluster x
Prelude.Generic)

-- |
-- Create a value of 'DeleteGlobalCluster' 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:
--
-- 'globalClusterIdentifier', 'deleteGlobalCluster_globalClusterIdentifier' - The cluster identifier of the global cluster being deleted.
newDeleteGlobalCluster ::
  -- | 'globalClusterIdentifier'
  Prelude.Text ->
  DeleteGlobalCluster
newDeleteGlobalCluster :: Text -> DeleteGlobalCluster
newDeleteGlobalCluster Text
pGlobalClusterIdentifier_ =
  DeleteGlobalCluster' :: Text -> DeleteGlobalCluster
DeleteGlobalCluster'
    { $sel:globalClusterIdentifier:DeleteGlobalCluster' :: Text
globalClusterIdentifier =
        Text
pGlobalClusterIdentifier_
    }

-- | The cluster identifier of the global cluster being deleted.
deleteGlobalCluster_globalClusterIdentifier :: Lens.Lens' DeleteGlobalCluster Prelude.Text
deleteGlobalCluster_globalClusterIdentifier :: (Text -> f Text) -> DeleteGlobalCluster -> f DeleteGlobalCluster
deleteGlobalCluster_globalClusterIdentifier = (DeleteGlobalCluster -> Text)
-> (DeleteGlobalCluster -> Text -> DeleteGlobalCluster)
-> Lens DeleteGlobalCluster DeleteGlobalCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGlobalCluster' {Text
globalClusterIdentifier :: Text
$sel:globalClusterIdentifier:DeleteGlobalCluster' :: DeleteGlobalCluster -> Text
globalClusterIdentifier} -> Text
globalClusterIdentifier) (\s :: DeleteGlobalCluster
s@DeleteGlobalCluster' {} Text
a -> DeleteGlobalCluster
s {$sel:globalClusterIdentifier:DeleteGlobalCluster' :: Text
globalClusterIdentifier = Text
a} :: DeleteGlobalCluster)

instance Core.AWSRequest DeleteGlobalCluster where
  type
    AWSResponse DeleteGlobalCluster =
      DeleteGlobalClusterResponse
  request :: DeleteGlobalCluster -> Request DeleteGlobalCluster
request = Service -> DeleteGlobalCluster -> Request DeleteGlobalCluster
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteGlobalCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteGlobalCluster)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteGlobalCluster))
-> Logger
-> Service
-> Proxy DeleteGlobalCluster
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteGlobalCluster)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DeleteGlobalClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe GlobalCluster -> Int -> DeleteGlobalClusterResponse
DeleteGlobalClusterResponse'
            (Maybe GlobalCluster -> Int -> DeleteGlobalClusterResponse)
-> Either String (Maybe GlobalCluster)
-> Either String (Int -> DeleteGlobalClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe GlobalCluster)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"GlobalCluster")
            Either String (Int -> DeleteGlobalClusterResponse)
-> Either String Int -> Either String DeleteGlobalClusterResponse
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 DeleteGlobalCluster

instance Prelude.NFData DeleteGlobalCluster

instance Core.ToHeaders DeleteGlobalCluster where
  toHeaders :: DeleteGlobalCluster -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteGlobalCluster -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DeleteGlobalCluster where
  toQuery :: DeleteGlobalCluster -> QueryString
toQuery DeleteGlobalCluster' {Text
globalClusterIdentifier :: Text
$sel:globalClusterIdentifier:DeleteGlobalCluster' :: DeleteGlobalCluster -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteGlobalCluster" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"GlobalClusterIdentifier"
          ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
globalClusterIdentifier
      ]

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

-- |
-- Create a value of 'DeleteGlobalClusterResponse' 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:
--
-- 'globalCluster', 'deleteGlobalClusterResponse_globalCluster' - Undocumented member.
--
-- 'httpStatus', 'deleteGlobalClusterResponse_httpStatus' - The response's http status code.
newDeleteGlobalClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteGlobalClusterResponse
newDeleteGlobalClusterResponse :: Int -> DeleteGlobalClusterResponse
newDeleteGlobalClusterResponse Int
pHttpStatus_ =
  DeleteGlobalClusterResponse' :: Maybe GlobalCluster -> Int -> DeleteGlobalClusterResponse
DeleteGlobalClusterResponse'
    { $sel:globalCluster:DeleteGlobalClusterResponse' :: Maybe GlobalCluster
globalCluster =
        Maybe GlobalCluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteGlobalClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteGlobalClusterResponse_globalCluster :: Lens.Lens' DeleteGlobalClusterResponse (Prelude.Maybe GlobalCluster)
deleteGlobalClusterResponse_globalCluster :: (Maybe GlobalCluster -> f (Maybe GlobalCluster))
-> DeleteGlobalClusterResponse -> f DeleteGlobalClusterResponse
deleteGlobalClusterResponse_globalCluster = (DeleteGlobalClusterResponse -> Maybe GlobalCluster)
-> (DeleteGlobalClusterResponse
    -> Maybe GlobalCluster -> DeleteGlobalClusterResponse)
-> Lens
     DeleteGlobalClusterResponse
     DeleteGlobalClusterResponse
     (Maybe GlobalCluster)
     (Maybe GlobalCluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGlobalClusterResponse' {Maybe GlobalCluster
globalCluster :: Maybe GlobalCluster
$sel:globalCluster:DeleteGlobalClusterResponse' :: DeleteGlobalClusterResponse -> Maybe GlobalCluster
globalCluster} -> Maybe GlobalCluster
globalCluster) (\s :: DeleteGlobalClusterResponse
s@DeleteGlobalClusterResponse' {} Maybe GlobalCluster
a -> DeleteGlobalClusterResponse
s {$sel:globalCluster:DeleteGlobalClusterResponse' :: Maybe GlobalCluster
globalCluster = Maybe GlobalCluster
a} :: DeleteGlobalClusterResponse)

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

instance Prelude.NFData DeleteGlobalClusterResponse