{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:relationalDatabaseName:StartRelationalDatabase' :: Text
relationalDatabaseName =
        Text
pRelationalDatabaseName_
    }

-- | The name of your database to start.
startRelationalDatabase_relationalDatabaseName :: Lens.Lens' StartRelationalDatabase Prelude.Text
startRelationalDatabase_relationalDatabaseName :: Lens' StartRelationalDatabase Text
startRelationalDatabase_relationalDatabaseName = 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 :: (Service -> Service)
-> StartRelationalDatabase -> Request StartRelationalDatabase
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartRelationalDatabase)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> StartRelationalDatabaseResponse
StartRelationalDatabaseResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartRelationalDatabase where
  hashWithSalt :: Int -> StartRelationalDatabase -> Int
hashWithSalt Int
_salt StartRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:StartRelationalDatabase' :: StartRelationalDatabase -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
relationalDatabaseName

instance Prelude.NFData StartRelationalDatabase where
  rnf :: StartRelationalDatabase -> ()
rnf StartRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:StartRelationalDatabase' :: StartRelationalDatabase -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
relationalDatabaseName

instance Data.ToHeaders StartRelationalDatabase where
  toHeaders :: StartRelationalDatabase -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.StartRelationalDatabase" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartRelationalDatabase where
  toJSON :: StartRelationalDatabase -> Value
toJSON StartRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:StartRelationalDatabase' :: StartRelationalDatabase -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"relationalDatabaseName"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
relationalDatabaseName
              )
          ]
      )

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

instance Data.ToQuery StartRelationalDatabase where
  toQuery :: StartRelationalDatabase -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:operations:StartRelationalDatabaseResponse' :: Maybe [Operation]
operations =
        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 :: Lens' StartRelationalDatabaseResponse (Maybe [Operation])
startRelationalDatabaseResponse_operations = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' StartRelationalDatabaseResponse Int
startRelationalDatabaseResponse_httpStatus = 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
  where
  rnf :: StartRelationalDatabaseResponse -> ()
rnf StartRelationalDatabaseResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:StartRelationalDatabaseResponse' :: StartRelationalDatabaseResponse -> Int
$sel:operations:StartRelationalDatabaseResponse' :: StartRelationalDatabaseResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus