{-# 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.RebootRelationalDatabase
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Restarts a specific database in Amazon Lightsail.
--
-- The @reboot 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.RebootRelationalDatabase
  ( -- * Creating a Request
    RebootRelationalDatabase (..),
    newRebootRelationalDatabase,

    -- * Request Lenses
    rebootRelationalDatabase_relationalDatabaseName,

    -- * Destructuring the Response
    RebootRelationalDatabaseResponse (..),
    newRebootRelationalDatabaseResponse,

    -- * Response Lenses
    rebootRelationalDatabaseResponse_operations,
    rebootRelationalDatabaseResponse_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:/ 'newRebootRelationalDatabase' smart constructor.
data RebootRelationalDatabase = RebootRelationalDatabase'
  { -- | The name of your database to reboot.
    RebootRelationalDatabase -> Text
relationalDatabaseName :: Prelude.Text
  }
  deriving (RebootRelationalDatabase -> RebootRelationalDatabase -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebootRelationalDatabase -> RebootRelationalDatabase -> Bool
$c/= :: RebootRelationalDatabase -> RebootRelationalDatabase -> Bool
== :: RebootRelationalDatabase -> RebootRelationalDatabase -> Bool
$c== :: RebootRelationalDatabase -> RebootRelationalDatabase -> Bool
Prelude.Eq, ReadPrec [RebootRelationalDatabase]
ReadPrec RebootRelationalDatabase
Int -> ReadS RebootRelationalDatabase
ReadS [RebootRelationalDatabase]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebootRelationalDatabase]
$creadListPrec :: ReadPrec [RebootRelationalDatabase]
readPrec :: ReadPrec RebootRelationalDatabase
$creadPrec :: ReadPrec RebootRelationalDatabase
readList :: ReadS [RebootRelationalDatabase]
$creadList :: ReadS [RebootRelationalDatabase]
readsPrec :: Int -> ReadS RebootRelationalDatabase
$creadsPrec :: Int -> ReadS RebootRelationalDatabase
Prelude.Read, Int -> RebootRelationalDatabase -> ShowS
[RebootRelationalDatabase] -> ShowS
RebootRelationalDatabase -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebootRelationalDatabase] -> ShowS
$cshowList :: [RebootRelationalDatabase] -> ShowS
show :: RebootRelationalDatabase -> String
$cshow :: RebootRelationalDatabase -> String
showsPrec :: Int -> RebootRelationalDatabase -> ShowS
$cshowsPrec :: Int -> RebootRelationalDatabase -> ShowS
Prelude.Show, forall x.
Rep RebootRelationalDatabase x -> RebootRelationalDatabase
forall x.
RebootRelationalDatabase -> Rep RebootRelationalDatabase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RebootRelationalDatabase x -> RebootRelationalDatabase
$cfrom :: forall x.
RebootRelationalDatabase -> Rep RebootRelationalDatabase x
Prelude.Generic)

-- |
-- Create a value of 'RebootRelationalDatabase' 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', 'rebootRelationalDatabase_relationalDatabaseName' - The name of your database to reboot.
newRebootRelationalDatabase ::
  -- | 'relationalDatabaseName'
  Prelude.Text ->
  RebootRelationalDatabase
newRebootRelationalDatabase :: Text -> RebootRelationalDatabase
newRebootRelationalDatabase Text
pRelationalDatabaseName_ =
  RebootRelationalDatabase'
    { $sel:relationalDatabaseName:RebootRelationalDatabase' :: Text
relationalDatabaseName =
        Text
pRelationalDatabaseName_
    }

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

instance Core.AWSRequest RebootRelationalDatabase where
  type
    AWSResponse RebootRelationalDatabase =
      RebootRelationalDatabaseResponse
  request :: (Service -> Service)
-> RebootRelationalDatabase -> Request RebootRelationalDatabase
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 RebootRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RebootRelationalDatabase)))
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 -> RebootRelationalDatabaseResponse
RebootRelationalDatabaseResponse'
            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 RebootRelationalDatabase where
  hashWithSalt :: Int -> RebootRelationalDatabase -> Int
hashWithSalt Int
_salt RebootRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:RebootRelationalDatabase' :: RebootRelationalDatabase -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
relationalDatabaseName

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

instance Data.ToHeaders RebootRelationalDatabase where
  toHeaders :: RebootRelationalDatabase -> 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.RebootRelationalDatabase" ::
                          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 RebootRelationalDatabase where
  toJSON :: RebootRelationalDatabase -> Value
toJSON RebootRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:RebootRelationalDatabase' :: RebootRelationalDatabase -> 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 RebootRelationalDatabase where
  toPath :: RebootRelationalDatabase -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'RebootRelationalDatabaseResponse' 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', 'rebootRelationalDatabaseResponse_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', 'rebootRelationalDatabaseResponse_httpStatus' - The response's http status code.
newRebootRelationalDatabaseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RebootRelationalDatabaseResponse
newRebootRelationalDatabaseResponse :: Int -> RebootRelationalDatabaseResponse
newRebootRelationalDatabaseResponse Int
pHttpStatus_ =
  RebootRelationalDatabaseResponse'
    { $sel:operations:RebootRelationalDatabaseResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RebootRelationalDatabaseResponse' :: 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.
rebootRelationalDatabaseResponse_operations :: Lens.Lens' RebootRelationalDatabaseResponse (Prelude.Maybe [Operation])
rebootRelationalDatabaseResponse_operations :: Lens' RebootRelationalDatabaseResponse (Maybe [Operation])
rebootRelationalDatabaseResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootRelationalDatabaseResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:RebootRelationalDatabaseResponse' :: RebootRelationalDatabaseResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: RebootRelationalDatabaseResponse
s@RebootRelationalDatabaseResponse' {} Maybe [Operation]
a -> RebootRelationalDatabaseResponse
s {$sel:operations:RebootRelationalDatabaseResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: RebootRelationalDatabaseResponse) 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.
rebootRelationalDatabaseResponse_httpStatus :: Lens.Lens' RebootRelationalDatabaseResponse Prelude.Int
rebootRelationalDatabaseResponse_httpStatus :: Lens' RebootRelationalDatabaseResponse Int
rebootRelationalDatabaseResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootRelationalDatabaseResponse' {Int
httpStatus :: Int
$sel:httpStatus:RebootRelationalDatabaseResponse' :: RebootRelationalDatabaseResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RebootRelationalDatabaseResponse
s@RebootRelationalDatabaseResponse' {} Int
a -> RebootRelationalDatabaseResponse
s {$sel:httpStatus:RebootRelationalDatabaseResponse' :: Int
httpStatus = Int
a} :: RebootRelationalDatabaseResponse)

instance
  Prelude.NFData
    RebootRelationalDatabaseResponse
  where
  rnf :: RebootRelationalDatabaseResponse -> ()
rnf RebootRelationalDatabaseResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:RebootRelationalDatabaseResponse' :: RebootRelationalDatabaseResponse -> Int
$sel:operations:RebootRelationalDatabaseResponse' :: RebootRelationalDatabaseResponse -> 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