{-# 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.RDS.StartDBInstance
-- 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)
--
-- Starts an Amazon RDS DB instance that was stopped using the Amazon Web
-- Services console, the stop-db-instance CLI command, or the
-- StopDBInstance action.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_StartInstance.html Starting an Amazon RDS DB instance That Was Previously Stopped>
-- in the /Amazon RDS User Guide./
--
-- This command doesn\'t apply to Aurora MySQL and Aurora PostgreSQL. For
-- Aurora DB clusters, use @StartDBCluster@ instead.
module Amazonka.RDS.StartDBInstance
  ( -- * Creating a Request
    StartDBInstance (..),
    newStartDBInstance,

    -- * Request Lenses
    startDBInstance_dbInstanceIdentifier,

    -- * Destructuring the Response
    StartDBInstanceResponse (..),
    newStartDBInstanceResponse,

    -- * Response Lenses
    startDBInstanceResponse_dbInstance,
    startDBInstanceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartDBInstance' smart constructor.
data StartDBInstance = StartDBInstance'
  { -- | The user-supplied instance identifier.
    StartDBInstance -> Text
dbInstanceIdentifier :: Prelude.Text
  }
  deriving (StartDBInstance -> StartDBInstance -> Bool
(StartDBInstance -> StartDBInstance -> Bool)
-> (StartDBInstance -> StartDBInstance -> Bool)
-> Eq StartDBInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartDBInstance -> StartDBInstance -> Bool
$c/= :: StartDBInstance -> StartDBInstance -> Bool
== :: StartDBInstance -> StartDBInstance -> Bool
$c== :: StartDBInstance -> StartDBInstance -> Bool
Prelude.Eq, ReadPrec [StartDBInstance]
ReadPrec StartDBInstance
Int -> ReadS StartDBInstance
ReadS [StartDBInstance]
(Int -> ReadS StartDBInstance)
-> ReadS [StartDBInstance]
-> ReadPrec StartDBInstance
-> ReadPrec [StartDBInstance]
-> Read StartDBInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartDBInstance]
$creadListPrec :: ReadPrec [StartDBInstance]
readPrec :: ReadPrec StartDBInstance
$creadPrec :: ReadPrec StartDBInstance
readList :: ReadS [StartDBInstance]
$creadList :: ReadS [StartDBInstance]
readsPrec :: Int -> ReadS StartDBInstance
$creadsPrec :: Int -> ReadS StartDBInstance
Prelude.Read, Int -> StartDBInstance -> ShowS
[StartDBInstance] -> ShowS
StartDBInstance -> String
(Int -> StartDBInstance -> ShowS)
-> (StartDBInstance -> String)
-> ([StartDBInstance] -> ShowS)
-> Show StartDBInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartDBInstance] -> ShowS
$cshowList :: [StartDBInstance] -> ShowS
show :: StartDBInstance -> String
$cshow :: StartDBInstance -> String
showsPrec :: Int -> StartDBInstance -> ShowS
$cshowsPrec :: Int -> StartDBInstance -> ShowS
Prelude.Show, (forall x. StartDBInstance -> Rep StartDBInstance x)
-> (forall x. Rep StartDBInstance x -> StartDBInstance)
-> Generic StartDBInstance
forall x. Rep StartDBInstance x -> StartDBInstance
forall x. StartDBInstance -> Rep StartDBInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartDBInstance x -> StartDBInstance
$cfrom :: forall x. StartDBInstance -> Rep StartDBInstance x
Prelude.Generic)

-- |
-- Create a value of 'StartDBInstance' 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:
--
-- 'dbInstanceIdentifier', 'startDBInstance_dbInstanceIdentifier' - The user-supplied instance identifier.
newStartDBInstance ::
  -- | 'dbInstanceIdentifier'
  Prelude.Text ->
  StartDBInstance
newStartDBInstance :: Text -> StartDBInstance
newStartDBInstance Text
pDBInstanceIdentifier_ =
  StartDBInstance' :: Text -> StartDBInstance
StartDBInstance'
    { $sel:dbInstanceIdentifier:StartDBInstance' :: Text
dbInstanceIdentifier =
        Text
pDBInstanceIdentifier_
    }

-- | The user-supplied instance identifier.
startDBInstance_dbInstanceIdentifier :: Lens.Lens' StartDBInstance Prelude.Text
startDBInstance_dbInstanceIdentifier :: (Text -> f Text) -> StartDBInstance -> f StartDBInstance
startDBInstance_dbInstanceIdentifier = (StartDBInstance -> Text)
-> (StartDBInstance -> Text -> StartDBInstance)
-> Lens StartDBInstance StartDBInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDBInstance' {Text
dbInstanceIdentifier :: Text
$sel:dbInstanceIdentifier:StartDBInstance' :: StartDBInstance -> Text
dbInstanceIdentifier} -> Text
dbInstanceIdentifier) (\s :: StartDBInstance
s@StartDBInstance' {} Text
a -> StartDBInstance
s {$sel:dbInstanceIdentifier:StartDBInstance' :: Text
dbInstanceIdentifier = Text
a} :: StartDBInstance)

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

instance Prelude.NFData StartDBInstance

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

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

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

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

-- |
-- Create a value of 'StartDBInstanceResponse' 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:
--
-- 'dbInstance', 'startDBInstanceResponse_dbInstance' - Undocumented member.
--
-- 'httpStatus', 'startDBInstanceResponse_httpStatus' - The response's http status code.
newStartDBInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartDBInstanceResponse
newStartDBInstanceResponse :: Int -> StartDBInstanceResponse
newStartDBInstanceResponse Int
pHttpStatus_ =
  StartDBInstanceResponse' :: Maybe DBInstance -> Int -> StartDBInstanceResponse
StartDBInstanceResponse'
    { $sel:dbInstance:StartDBInstanceResponse' :: Maybe DBInstance
dbInstance =
        Maybe DBInstance
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartDBInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
startDBInstanceResponse_dbInstance :: Lens.Lens' StartDBInstanceResponse (Prelude.Maybe DBInstance)
startDBInstanceResponse_dbInstance :: (Maybe DBInstance -> f (Maybe DBInstance))
-> StartDBInstanceResponse -> f StartDBInstanceResponse
startDBInstanceResponse_dbInstance = (StartDBInstanceResponse -> Maybe DBInstance)
-> (StartDBInstanceResponse
    -> Maybe DBInstance -> StartDBInstanceResponse)
-> Lens
     StartDBInstanceResponse
     StartDBInstanceResponse
     (Maybe DBInstance)
     (Maybe DBInstance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDBInstanceResponse' {Maybe DBInstance
dbInstance :: Maybe DBInstance
$sel:dbInstance:StartDBInstanceResponse' :: StartDBInstanceResponse -> Maybe DBInstance
dbInstance} -> Maybe DBInstance
dbInstance) (\s :: StartDBInstanceResponse
s@StartDBInstanceResponse' {} Maybe DBInstance
a -> StartDBInstanceResponse
s {$sel:dbInstance:StartDBInstanceResponse' :: Maybe DBInstance
dbInstance = Maybe DBInstance
a} :: StartDBInstanceResponse)

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

instance Prelude.NFData StartDBInstanceResponse