{-# 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.GetRelationalDatabase
-- 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)
--
-- Returns information about a specific database in Amazon Lightsail.
module Amazonka.Lightsail.GetRelationalDatabase
  ( -- * Creating a Request
    GetRelationalDatabase (..),
    newGetRelationalDatabase,

    -- * Request Lenses
    getRelationalDatabase_relationalDatabaseName,

    -- * Destructuring the Response
    GetRelationalDatabaseResponse (..),
    newGetRelationalDatabaseResponse,

    -- * Response Lenses
    getRelationalDatabaseResponse_relationalDatabase,
    getRelationalDatabaseResponse_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:/ 'newGetRelationalDatabase' smart constructor.
data GetRelationalDatabase = GetRelationalDatabase'
  { -- | The name of the database that you are looking up.
    GetRelationalDatabase -> Text
relationalDatabaseName :: Prelude.Text
  }
  deriving (GetRelationalDatabase -> GetRelationalDatabase -> Bool
(GetRelationalDatabase -> GetRelationalDatabase -> Bool)
-> (GetRelationalDatabase -> GetRelationalDatabase -> Bool)
-> Eq GetRelationalDatabase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRelationalDatabase -> GetRelationalDatabase -> Bool
$c/= :: GetRelationalDatabase -> GetRelationalDatabase -> Bool
== :: GetRelationalDatabase -> GetRelationalDatabase -> Bool
$c== :: GetRelationalDatabase -> GetRelationalDatabase -> Bool
Prelude.Eq, ReadPrec [GetRelationalDatabase]
ReadPrec GetRelationalDatabase
Int -> ReadS GetRelationalDatabase
ReadS [GetRelationalDatabase]
(Int -> ReadS GetRelationalDatabase)
-> ReadS [GetRelationalDatabase]
-> ReadPrec GetRelationalDatabase
-> ReadPrec [GetRelationalDatabase]
-> Read GetRelationalDatabase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRelationalDatabase]
$creadListPrec :: ReadPrec [GetRelationalDatabase]
readPrec :: ReadPrec GetRelationalDatabase
$creadPrec :: ReadPrec GetRelationalDatabase
readList :: ReadS [GetRelationalDatabase]
$creadList :: ReadS [GetRelationalDatabase]
readsPrec :: Int -> ReadS GetRelationalDatabase
$creadsPrec :: Int -> ReadS GetRelationalDatabase
Prelude.Read, Int -> GetRelationalDatabase -> ShowS
[GetRelationalDatabase] -> ShowS
GetRelationalDatabase -> String
(Int -> GetRelationalDatabase -> ShowS)
-> (GetRelationalDatabase -> String)
-> ([GetRelationalDatabase] -> ShowS)
-> Show GetRelationalDatabase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRelationalDatabase] -> ShowS
$cshowList :: [GetRelationalDatabase] -> ShowS
show :: GetRelationalDatabase -> String
$cshow :: GetRelationalDatabase -> String
showsPrec :: Int -> GetRelationalDatabase -> ShowS
$cshowsPrec :: Int -> GetRelationalDatabase -> ShowS
Prelude.Show, (forall x. GetRelationalDatabase -> Rep GetRelationalDatabase x)
-> (forall x. Rep GetRelationalDatabase x -> GetRelationalDatabase)
-> Generic GetRelationalDatabase
forall x. Rep GetRelationalDatabase x -> GetRelationalDatabase
forall x. GetRelationalDatabase -> Rep GetRelationalDatabase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRelationalDatabase x -> GetRelationalDatabase
$cfrom :: forall x. GetRelationalDatabase -> Rep GetRelationalDatabase x
Prelude.Generic)

-- |
-- Create a value of 'GetRelationalDatabase' 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', 'getRelationalDatabase_relationalDatabaseName' - The name of the database that you are looking up.
newGetRelationalDatabase ::
  -- | 'relationalDatabaseName'
  Prelude.Text ->
  GetRelationalDatabase
newGetRelationalDatabase :: Text -> GetRelationalDatabase
newGetRelationalDatabase Text
pRelationalDatabaseName_ =
  GetRelationalDatabase' :: Text -> GetRelationalDatabase
GetRelationalDatabase'
    { $sel:relationalDatabaseName:GetRelationalDatabase' :: Text
relationalDatabaseName =
        Text
pRelationalDatabaseName_
    }

-- | The name of the database that you are looking up.
getRelationalDatabase_relationalDatabaseName :: Lens.Lens' GetRelationalDatabase Prelude.Text
getRelationalDatabase_relationalDatabaseName :: (Text -> f Text)
-> GetRelationalDatabase -> f GetRelationalDatabase
getRelationalDatabase_relationalDatabaseName = (GetRelationalDatabase -> Text)
-> (GetRelationalDatabase -> Text -> GetRelationalDatabase)
-> Lens GetRelationalDatabase GetRelationalDatabase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRelationalDatabase' {Text
relationalDatabaseName :: Text
$sel:relationalDatabaseName:GetRelationalDatabase' :: GetRelationalDatabase -> Text
relationalDatabaseName} -> Text
relationalDatabaseName) (\s :: GetRelationalDatabase
s@GetRelationalDatabase' {} Text
a -> GetRelationalDatabase
s {$sel:relationalDatabaseName:GetRelationalDatabase' :: Text
relationalDatabaseName = Text
a} :: GetRelationalDatabase)

instance Core.AWSRequest GetRelationalDatabase where
  type
    AWSResponse GetRelationalDatabase =
      GetRelationalDatabaseResponse
  request :: GetRelationalDatabase -> Request GetRelationalDatabase
request = Service -> GetRelationalDatabase -> Request GetRelationalDatabase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRelationalDatabase)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetRelationalDatabase))
-> Logger
-> Service
-> Proxy GetRelationalDatabase
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRelationalDatabase)))
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 RelationalDatabase -> Int -> GetRelationalDatabaseResponse
GetRelationalDatabaseResponse'
            (Maybe RelationalDatabase -> Int -> GetRelationalDatabaseResponse)
-> Either String (Maybe RelationalDatabase)
-> Either String (Int -> GetRelationalDatabaseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RelationalDatabase)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"relationalDatabase")
            Either String (Int -> GetRelationalDatabaseResponse)
-> Either String Int -> Either String GetRelationalDatabaseResponse
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 GetRelationalDatabase

instance Prelude.NFData GetRelationalDatabase

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

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

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

-- |
-- Create a value of 'GetRelationalDatabaseResponse' 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:
--
-- 'relationalDatabase', 'getRelationalDatabaseResponse_relationalDatabase' - An object describing the specified database.
--
-- 'httpStatus', 'getRelationalDatabaseResponse_httpStatus' - The response's http status code.
newGetRelationalDatabaseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRelationalDatabaseResponse
newGetRelationalDatabaseResponse :: Int -> GetRelationalDatabaseResponse
newGetRelationalDatabaseResponse Int
pHttpStatus_ =
  GetRelationalDatabaseResponse' :: Maybe RelationalDatabase -> Int -> GetRelationalDatabaseResponse
GetRelationalDatabaseResponse'
    { $sel:relationalDatabase:GetRelationalDatabaseResponse' :: Maybe RelationalDatabase
relationalDatabase =
        Maybe RelationalDatabase
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRelationalDatabaseResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object describing the specified database.
getRelationalDatabaseResponse_relationalDatabase :: Lens.Lens' GetRelationalDatabaseResponse (Prelude.Maybe RelationalDatabase)
getRelationalDatabaseResponse_relationalDatabase :: (Maybe RelationalDatabase -> f (Maybe RelationalDatabase))
-> GetRelationalDatabaseResponse -> f GetRelationalDatabaseResponse
getRelationalDatabaseResponse_relationalDatabase = (GetRelationalDatabaseResponse -> Maybe RelationalDatabase)
-> (GetRelationalDatabaseResponse
    -> Maybe RelationalDatabase -> GetRelationalDatabaseResponse)
-> Lens
     GetRelationalDatabaseResponse
     GetRelationalDatabaseResponse
     (Maybe RelationalDatabase)
     (Maybe RelationalDatabase)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRelationalDatabaseResponse' {Maybe RelationalDatabase
relationalDatabase :: Maybe RelationalDatabase
$sel:relationalDatabase:GetRelationalDatabaseResponse' :: GetRelationalDatabaseResponse -> Maybe RelationalDatabase
relationalDatabase} -> Maybe RelationalDatabase
relationalDatabase) (\s :: GetRelationalDatabaseResponse
s@GetRelationalDatabaseResponse' {} Maybe RelationalDatabase
a -> GetRelationalDatabaseResponse
s {$sel:relationalDatabase:GetRelationalDatabaseResponse' :: Maybe RelationalDatabase
relationalDatabase = Maybe RelationalDatabase
a} :: GetRelationalDatabaseResponse)

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

instance Prelude.NFData GetRelationalDatabaseResponse