{-# 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-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)
--
-- 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.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:/ 'newRebootRelationalDatabase' smart constructor.
data RebootRelationalDatabase = RebootRelationalDatabase'
  { -- | The name of your database to reboot.
    RebootRelationalDatabase -> Text
relationalDatabaseName :: Prelude.Text
  }
  deriving (RebootRelationalDatabase -> RebootRelationalDatabase -> Bool
(RebootRelationalDatabase -> RebootRelationalDatabase -> Bool)
-> (RebootRelationalDatabase -> RebootRelationalDatabase -> Bool)
-> Eq RebootRelationalDatabase
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]
(Int -> ReadS RebootRelationalDatabase)
-> ReadS [RebootRelationalDatabase]
-> ReadPrec RebootRelationalDatabase
-> ReadPrec [RebootRelationalDatabase]
-> Read 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
(Int -> RebootRelationalDatabase -> ShowS)
-> (RebootRelationalDatabase -> String)
-> ([RebootRelationalDatabase] -> ShowS)
-> Show RebootRelationalDatabase
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.
 RebootRelationalDatabase -> Rep RebootRelationalDatabase x)
-> (forall x.
    Rep RebootRelationalDatabase x -> RebootRelationalDatabase)
-> Generic RebootRelationalDatabase
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' :: Text -> RebootRelationalDatabase
RebootRelationalDatabase'
    { $sel:relationalDatabaseName:RebootRelationalDatabase' :: Text
relationalDatabaseName =
        Text
pRelationalDatabaseName_
    }

-- | The name of your database to reboot.
rebootRelationalDatabase_relationalDatabaseName :: Lens.Lens' RebootRelationalDatabase Prelude.Text
rebootRelationalDatabase_relationalDatabaseName :: (Text -> f Text)
-> RebootRelationalDatabase -> f RebootRelationalDatabase
rebootRelationalDatabase_relationalDatabaseName = (RebootRelationalDatabase -> Text)
-> (RebootRelationalDatabase -> Text -> RebootRelationalDatabase)
-> Lens RebootRelationalDatabase RebootRelationalDatabase Text Text
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 :: RebootRelationalDatabase -> Request RebootRelationalDatabase
request = Service
-> RebootRelationalDatabase -> Request RebootRelationalDatabase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RebootRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RebootRelationalDatabase)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RebootRelationalDatabase))
-> Logger
-> Service
-> Proxy RebootRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RebootRelationalDatabase)))
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 -> RebootRelationalDatabaseResponse
RebootRelationalDatabaseResponse'
            (Maybe [Operation] -> Int -> RebootRelationalDatabaseResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> RebootRelationalDatabaseResponse)
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 -> RebootRelationalDatabaseResponse)
-> Either String Int
-> Either String RebootRelationalDatabaseResponse
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 RebootRelationalDatabase

instance Prelude.NFData RebootRelationalDatabase

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

instance Core.ToQuery RebootRelationalDatabase where
  toQuery :: RebootRelationalDatabase -> QueryString
toQuery = QueryString -> RebootRelationalDatabase -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(RebootRelationalDatabaseResponse
 -> RebootRelationalDatabaseResponse -> Bool)
-> (RebootRelationalDatabaseResponse
    -> RebootRelationalDatabaseResponse -> Bool)
-> Eq RebootRelationalDatabaseResponse
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]
(Int -> ReadS RebootRelationalDatabaseResponse)
-> ReadS [RebootRelationalDatabaseResponse]
-> ReadPrec RebootRelationalDatabaseResponse
-> ReadPrec [RebootRelationalDatabaseResponse]
-> Read 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
(Int -> RebootRelationalDatabaseResponse -> ShowS)
-> (RebootRelationalDatabaseResponse -> String)
-> ([RebootRelationalDatabaseResponse] -> ShowS)
-> Show RebootRelationalDatabaseResponse
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.
 RebootRelationalDatabaseResponse
 -> Rep RebootRelationalDatabaseResponse x)
-> (forall x.
    Rep RebootRelationalDatabaseResponse x
    -> RebootRelationalDatabaseResponse)
-> Generic RebootRelationalDatabaseResponse
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' :: Maybe [Operation] -> Int -> RebootRelationalDatabaseResponse
RebootRelationalDatabaseResponse'
    { $sel:operations:RebootRelationalDatabaseResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
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 :: (Maybe [Operation] -> f (Maybe [Operation]))
-> RebootRelationalDatabaseResponse
-> f RebootRelationalDatabaseResponse
rebootRelationalDatabaseResponse_operations = (RebootRelationalDatabaseResponse -> Maybe [Operation])
-> (RebootRelationalDatabaseResponse
    -> Maybe [Operation] -> RebootRelationalDatabaseResponse)
-> Lens
     RebootRelationalDatabaseResponse
     RebootRelationalDatabaseResponse
     (Maybe [Operation])
     (Maybe [Operation])
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) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> RebootRelationalDatabaseResponse
 -> f RebootRelationalDatabaseResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> RebootRelationalDatabaseResponse
-> f RebootRelationalDatabaseResponse
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.
rebootRelationalDatabaseResponse_httpStatus :: Lens.Lens' RebootRelationalDatabaseResponse Prelude.Int
rebootRelationalDatabaseResponse_httpStatus :: (Int -> f Int)
-> RebootRelationalDatabaseResponse
-> f RebootRelationalDatabaseResponse
rebootRelationalDatabaseResponse_httpStatus = (RebootRelationalDatabaseResponse -> Int)
-> (RebootRelationalDatabaseResponse
    -> Int -> RebootRelationalDatabaseResponse)
-> Lens
     RebootRelationalDatabaseResponse
     RebootRelationalDatabaseResponse
     Int
     Int
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