{-# 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.Lightsail.StartRelationalDatabase
-- 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 a specific database from a stopped state in Amazon Lightsail. To
-- restart a database, use the @reboot relational database@ operation.
--
-- The @start relational database@ operation supports tag-based access
-- control via resource tags applied to the resource identified by
-- relationalDatabaseName. For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.StartRelationalDatabase
  ( -- * Creating a Request
    StartRelationalDatabase (..),
    newStartRelationalDatabase,

    -- * Request Lenses
    startRelationalDatabase_relationalDatabaseName,

    -- * Destructuring the Response
    StartRelationalDatabaseResponse (..),
    newStartRelationalDatabaseResponse,

    -- * Response Lenses
    startRelationalDatabaseResponse_operations,
    startRelationalDatabaseResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartRelationalDatabase' smart constructor.
data StartRelationalDatabase = StartRelationalDatabase'
  { -- | The name of your database to start.
    StartRelationalDatabase -> Text
relationalDatabaseName :: Prelude.Text
  }
  deriving (StartRelationalDatabase -> StartRelationalDatabase -> Bool
(StartRelationalDatabase -> StartRelationalDatabase -> Bool)
-> (StartRelationalDatabase -> StartRelationalDatabase -> Bool)
-> Eq StartRelationalDatabase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartRelationalDatabase -> StartRelationalDatabase -> Bool
$c/= :: StartRelationalDatabase -> StartRelationalDatabase -> Bool
== :: StartRelationalDatabase -> StartRelationalDatabase -> Bool
$c== :: StartRelationalDatabase -> StartRelationalDatabase -> Bool
Prelude.Eq, ReadPrec [StartRelationalDatabase]
ReadPrec StartRelationalDatabase
Int -> ReadS StartRelationalDatabase
ReadS [StartRelationalDatabase]
(Int -> ReadS StartRelationalDatabase)
-> ReadS [StartRelationalDatabase]
-> ReadPrec StartRelationalDatabase
-> ReadPrec [StartRelationalDatabase]
-> Read StartRelationalDatabase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartRelationalDatabase]
$creadListPrec :: ReadPrec [StartRelationalDatabase]
readPrec :: ReadPrec StartRelationalDatabase
$creadPrec :: ReadPrec StartRelationalDatabase
readList :: ReadS [StartRelationalDatabase]
$creadList :: ReadS [StartRelationalDatabase]
readsPrec :: Int -> ReadS StartRelationalDatabase
$creadsPrec :: Int -> ReadS StartRelationalDatabase
Prelude.Read, Int -> StartRelationalDatabase -> ShowS
[StartRelationalDatabase] -> ShowS
StartRelationalDatabase -> String
(Int -> StartRelationalDatabase -> ShowS)
-> (StartRelationalDatabase -> String)
-> ([StartRelationalDatabase] -> ShowS)
-> Show StartRelationalDatabase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartRelationalDatabase] -> ShowS
$cshowList :: [StartRelationalDatabase] -> ShowS
show :: StartRelationalDatabase -> String
$cshow :: StartRelationalDatabase -> String
showsPrec :: Int -> StartRelationalDatabase -> ShowS
$cshowsPrec :: Int -> StartRelationalDatabase -> ShowS
Prelude.Show, (forall x.
 StartRelationalDatabase -> Rep StartRelationalDatabase x)
-> (forall x.
    Rep StartRelationalDatabase x -> StartRelationalDatabase)
-> Generic StartRelationalDatabase
forall x. Rep StartRelationalDatabase x -> StartRelationalDatabase
forall x. StartRelationalDatabase -> Rep StartRelationalDatabase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartRelationalDatabase x -> StartRelationalDatabase
$cfrom :: forall x. StartRelationalDatabase -> Rep StartRelationalDatabase x
Prelude.Generic)

-- |
-- Create a value of 'StartRelationalDatabase' 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:
--
-- 'relationalDatabaseName', 'startRelationalDatabase_relationalDatabaseName' - The name of your database to start.
newStartRelationalDatabase ::
  -- | 'relationalDatabaseName'
  Prelude.Text ->
  StartRelationalDatabase
newStartRelationalDatabase :: Text -> StartRelationalDatabase
newStartRelationalDatabase Text
pRelationalDatabaseName_ =
  StartRelationalDatabase' :: Text -> StartRelationalDatabase
StartRelationalDatabase'
    { $sel:relationalDatabaseName:StartRelationalDatabase' :: Text
relationalDatabaseName =
        Text
pRelationalDatabaseName_
    }

-- | The name of your database to start.
startRelationalDatabase_relationalDatabaseName :: Lens.Lens' StartRelationalDatabase Prelude.Text
startRelationalDatabase_relationalDatabaseName :: (Text -> f Text)
-> StartRelationalDatabase -> f StartRelationalDatabase
startRelationalDatabase_relationalDatabaseName = (StartRelationalDatabase -> Text)
-> (StartRelationalDatabase -> Text -> StartRelationalDatabase)
-> Lens StartRelationalDatabase StartRelationalDatabase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:StartRelationalDatabase' :: StartRelationalDatabase -> Text
relationalDatabaseName} -> Text
relationalDatabaseName) (\s :: StartRelationalDatabase
s@StartRelationalDatabase' {} Text
a -> StartRelationalDatabase
s {$sel:relationalDatabaseName:StartRelationalDatabase' :: Text
relationalDatabaseName = Text
a} :: StartRelationalDatabase)

instance Core.AWSRequest StartRelationalDatabase where
  type
    AWSResponse StartRelationalDatabase =
      StartRelationalDatabaseResponse
  request :: StartRelationalDatabase -> Request StartRelationalDatabase
request = Service
-> StartRelationalDatabase -> Request StartRelationalDatabase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartRelationalDatabase)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartRelationalDatabase))
-> Logger
-> Service
-> Proxy StartRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartRelationalDatabase)))
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 [Operation] -> Int -> StartRelationalDatabaseResponse
StartRelationalDatabaseResponse'
            (Maybe [Operation] -> Int -> StartRelationalDatabaseResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> StartRelationalDatabaseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> StartRelationalDatabaseResponse)
-> Either String Int
-> Either String StartRelationalDatabaseResponse
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 StartRelationalDatabase

instance Prelude.NFData StartRelationalDatabase

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

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

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

-- | /See:/ 'newStartRelationalDatabaseResponse' smart constructor.
data StartRelationalDatabaseResponse = StartRelationalDatabaseResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    StartRelationalDatabaseResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    StartRelationalDatabaseResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartRelationalDatabaseResponse
-> StartRelationalDatabaseResponse -> Bool
(StartRelationalDatabaseResponse
 -> StartRelationalDatabaseResponse -> Bool)
-> (StartRelationalDatabaseResponse
    -> StartRelationalDatabaseResponse -> Bool)
-> Eq StartRelationalDatabaseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartRelationalDatabaseResponse
-> StartRelationalDatabaseResponse -> Bool
$c/= :: StartRelationalDatabaseResponse
-> StartRelationalDatabaseResponse -> Bool
== :: StartRelationalDatabaseResponse
-> StartRelationalDatabaseResponse -> Bool
$c== :: StartRelationalDatabaseResponse
-> StartRelationalDatabaseResponse -> Bool
Prelude.Eq, ReadPrec [StartRelationalDatabaseResponse]
ReadPrec StartRelationalDatabaseResponse
Int -> ReadS StartRelationalDatabaseResponse
ReadS [StartRelationalDatabaseResponse]
(Int -> ReadS StartRelationalDatabaseResponse)
-> ReadS [StartRelationalDatabaseResponse]
-> ReadPrec StartRelationalDatabaseResponse
-> ReadPrec [StartRelationalDatabaseResponse]
-> Read StartRelationalDatabaseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartRelationalDatabaseResponse]
$creadListPrec :: ReadPrec [StartRelationalDatabaseResponse]
readPrec :: ReadPrec StartRelationalDatabaseResponse
$creadPrec :: ReadPrec StartRelationalDatabaseResponse
readList :: ReadS [StartRelationalDatabaseResponse]
$creadList :: ReadS [StartRelationalDatabaseResponse]
readsPrec :: Int -> ReadS StartRelationalDatabaseResponse
$creadsPrec :: Int -> ReadS StartRelationalDatabaseResponse
Prelude.Read, Int -> StartRelationalDatabaseResponse -> ShowS
[StartRelationalDatabaseResponse] -> ShowS
StartRelationalDatabaseResponse -> String
(Int -> StartRelationalDatabaseResponse -> ShowS)
-> (StartRelationalDatabaseResponse -> String)
-> ([StartRelationalDatabaseResponse] -> ShowS)
-> Show StartRelationalDatabaseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartRelationalDatabaseResponse] -> ShowS
$cshowList :: [StartRelationalDatabaseResponse] -> ShowS
show :: StartRelationalDatabaseResponse -> String
$cshow :: StartRelationalDatabaseResponse -> String
showsPrec :: Int -> StartRelationalDatabaseResponse -> ShowS
$cshowsPrec :: Int -> StartRelationalDatabaseResponse -> ShowS
Prelude.Show, (forall x.
 StartRelationalDatabaseResponse
 -> Rep StartRelationalDatabaseResponse x)
-> (forall x.
    Rep StartRelationalDatabaseResponse x
    -> StartRelationalDatabaseResponse)
-> Generic StartRelationalDatabaseResponse
forall x.
Rep StartRelationalDatabaseResponse x
-> StartRelationalDatabaseResponse
forall x.
StartRelationalDatabaseResponse
-> Rep StartRelationalDatabaseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartRelationalDatabaseResponse x
-> StartRelationalDatabaseResponse
$cfrom :: forall x.
StartRelationalDatabaseResponse
-> Rep StartRelationalDatabaseResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartRelationalDatabaseResponse' 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:
--
-- 'operations', 'startRelationalDatabaseResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'startRelationalDatabaseResponse_httpStatus' - The response's http status code.
newStartRelationalDatabaseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartRelationalDatabaseResponse
newStartRelationalDatabaseResponse :: Int -> StartRelationalDatabaseResponse
newStartRelationalDatabaseResponse Int
pHttpStatus_ =
  StartRelationalDatabaseResponse' :: Maybe [Operation] -> Int -> StartRelationalDatabaseResponse
StartRelationalDatabaseResponse'
    { $sel:operations:StartRelationalDatabaseResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartRelationalDatabaseResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
startRelationalDatabaseResponse_operations :: Lens.Lens' StartRelationalDatabaseResponse (Prelude.Maybe [Operation])
startRelationalDatabaseResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> StartRelationalDatabaseResponse
-> f StartRelationalDatabaseResponse
startRelationalDatabaseResponse_operations = (StartRelationalDatabaseResponse -> Maybe [Operation])
-> (StartRelationalDatabaseResponse
    -> Maybe [Operation] -> StartRelationalDatabaseResponse)
-> Lens
     StartRelationalDatabaseResponse
     StartRelationalDatabaseResponse
     (Maybe [Operation])
     (Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRelationalDatabaseResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:StartRelationalDatabaseResponse' :: StartRelationalDatabaseResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: StartRelationalDatabaseResponse
s@StartRelationalDatabaseResponse' {} Maybe [Operation]
a -> StartRelationalDatabaseResponse
s {$sel:operations:StartRelationalDatabaseResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: StartRelationalDatabaseResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> StartRelationalDatabaseResponse
 -> f StartRelationalDatabaseResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> StartRelationalDatabaseResponse
-> f StartRelationalDatabaseResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    StartRelationalDatabaseResponse