{-# 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.StopDBCluster
-- 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)
--
-- Stops the running cluster that is specified by @DBClusterIdentifier@.
-- The cluster must be in the /available/ state. For more information, see
-- <https://docs.aws.amazon.com/documentdb/latest/developerguide/db-cluster-stop-start.html Stopping and Starting an Amazon DocumentDB Cluster>.
module Amazonka.DocumentDB.StopDBCluster
  ( -- * Creating a Request
    StopDBCluster (..),
    newStopDBCluster,

    -- * Request Lenses
    stopDBCluster_dbClusterIdentifier,

    -- * Destructuring the Response
    StopDBClusterResponse (..),
    newStopDBClusterResponse,

    -- * Response Lenses
    stopDBClusterResponse_dbCluster,
    stopDBClusterResponse_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

-- | /See:/ 'newStopDBCluster' smart constructor.
data StopDBCluster = StopDBCluster'
  { -- | The identifier of the cluster to stop. Example:
    -- @docdb-2019-05-28-15-24-52@
    StopDBCluster -> Text
dbClusterIdentifier :: Prelude.Text
  }
  deriving (StopDBCluster -> StopDBCluster -> Bool
(StopDBCluster -> StopDBCluster -> Bool)
-> (StopDBCluster -> StopDBCluster -> Bool) -> Eq StopDBCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopDBCluster -> StopDBCluster -> Bool
$c/= :: StopDBCluster -> StopDBCluster -> Bool
== :: StopDBCluster -> StopDBCluster -> Bool
$c== :: StopDBCluster -> StopDBCluster -> Bool
Prelude.Eq, ReadPrec [StopDBCluster]
ReadPrec StopDBCluster
Int -> ReadS StopDBCluster
ReadS [StopDBCluster]
(Int -> ReadS StopDBCluster)
-> ReadS [StopDBCluster]
-> ReadPrec StopDBCluster
-> ReadPrec [StopDBCluster]
-> Read StopDBCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopDBCluster]
$creadListPrec :: ReadPrec [StopDBCluster]
readPrec :: ReadPrec StopDBCluster
$creadPrec :: ReadPrec StopDBCluster
readList :: ReadS [StopDBCluster]
$creadList :: ReadS [StopDBCluster]
readsPrec :: Int -> ReadS StopDBCluster
$creadsPrec :: Int -> ReadS StopDBCluster
Prelude.Read, Int -> StopDBCluster -> ShowS
[StopDBCluster] -> ShowS
StopDBCluster -> String
(Int -> StopDBCluster -> ShowS)
-> (StopDBCluster -> String)
-> ([StopDBCluster] -> ShowS)
-> Show StopDBCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopDBCluster] -> ShowS
$cshowList :: [StopDBCluster] -> ShowS
show :: StopDBCluster -> String
$cshow :: StopDBCluster -> String
showsPrec :: Int -> StopDBCluster -> ShowS
$cshowsPrec :: Int -> StopDBCluster -> ShowS
Prelude.Show, (forall x. StopDBCluster -> Rep StopDBCluster x)
-> (forall x. Rep StopDBCluster x -> StopDBCluster)
-> Generic StopDBCluster
forall x. Rep StopDBCluster x -> StopDBCluster
forall x. StopDBCluster -> Rep StopDBCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopDBCluster x -> StopDBCluster
$cfrom :: forall x. StopDBCluster -> Rep StopDBCluster x
Prelude.Generic)

-- |
-- Create a value of 'StopDBCluster' 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:
--
-- 'dbClusterIdentifier', 'stopDBCluster_dbClusterIdentifier' - The identifier of the cluster to stop. Example:
-- @docdb-2019-05-28-15-24-52@
newStopDBCluster ::
  -- | 'dbClusterIdentifier'
  Prelude.Text ->
  StopDBCluster
newStopDBCluster :: Text -> StopDBCluster
newStopDBCluster Text
pDBClusterIdentifier_ =
  StopDBCluster' :: Text -> StopDBCluster
StopDBCluster'
    { $sel:dbClusterIdentifier:StopDBCluster' :: Text
dbClusterIdentifier =
        Text
pDBClusterIdentifier_
    }

-- | The identifier of the cluster to stop. Example:
-- @docdb-2019-05-28-15-24-52@
stopDBCluster_dbClusterIdentifier :: Lens.Lens' StopDBCluster Prelude.Text
stopDBCluster_dbClusterIdentifier :: (Text -> f Text) -> StopDBCluster -> f StopDBCluster
stopDBCluster_dbClusterIdentifier = (StopDBCluster -> Text)
-> (StopDBCluster -> Text -> StopDBCluster)
-> Lens StopDBCluster StopDBCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopDBCluster' {Text
dbClusterIdentifier :: Text
$sel:dbClusterIdentifier:StopDBCluster' :: StopDBCluster -> Text
dbClusterIdentifier} -> Text
dbClusterIdentifier) (\s :: StopDBCluster
s@StopDBCluster' {} Text
a -> StopDBCluster
s {$sel:dbClusterIdentifier:StopDBCluster' :: Text
dbClusterIdentifier = Text
a} :: StopDBCluster)

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

instance Prelude.NFData StopDBCluster

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

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

instance Core.ToQuery StopDBCluster where
  toQuery :: StopDBCluster -> QueryString
toQuery StopDBCluster' {Text
dbClusterIdentifier :: Text
$sel:dbClusterIdentifier:StopDBCluster' :: StopDBCluster -> 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
"StopDBCluster" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"DBClusterIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dbClusterIdentifier
      ]

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

-- |
-- Create a value of 'StopDBClusterResponse' 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:
--
-- 'dbCluster', 'stopDBClusterResponse_dbCluster' - Undocumented member.
--
-- 'httpStatus', 'stopDBClusterResponse_httpStatus' - The response's http status code.
newStopDBClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopDBClusterResponse
newStopDBClusterResponse :: Int -> StopDBClusterResponse
newStopDBClusterResponse Int
pHttpStatus_ =
  StopDBClusterResponse' :: Maybe DBCluster -> Int -> StopDBClusterResponse
StopDBClusterResponse'
    { $sel:dbCluster:StopDBClusterResponse' :: Maybe DBCluster
dbCluster = Maybe DBCluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopDBClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
stopDBClusterResponse_dbCluster :: Lens.Lens' StopDBClusterResponse (Prelude.Maybe DBCluster)
stopDBClusterResponse_dbCluster :: (Maybe DBCluster -> f (Maybe DBCluster))
-> StopDBClusterResponse -> f StopDBClusterResponse
stopDBClusterResponse_dbCluster = (StopDBClusterResponse -> Maybe DBCluster)
-> (StopDBClusterResponse
    -> Maybe DBCluster -> StopDBClusterResponse)
-> Lens
     StopDBClusterResponse
     StopDBClusterResponse
     (Maybe DBCluster)
     (Maybe DBCluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopDBClusterResponse' {Maybe DBCluster
dbCluster :: Maybe DBCluster
$sel:dbCluster:StopDBClusterResponse' :: StopDBClusterResponse -> Maybe DBCluster
dbCluster} -> Maybe DBCluster
dbCluster) (\s :: StopDBClusterResponse
s@StopDBClusterResponse' {} Maybe DBCluster
a -> StopDBClusterResponse
s {$sel:dbCluster:StopDBClusterResponse' :: Maybe DBCluster
dbCluster = Maybe DBCluster
a} :: StopDBClusterResponse)

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

instance Prelude.NFData StopDBClusterResponse