{-# 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 #-}
module Amazonka.Glue.GetDatabase
(
GetDatabase (..),
newGetDatabase,
getDatabase_catalogId,
getDatabase_name,
GetDatabaseResponse (..),
newGetDatabaseResponse,
getDatabaseResponse_database,
getDatabaseResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetDatabase = GetDatabase'
{
GetDatabase -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
GetDatabase -> Text
name :: Prelude.Text
}
deriving (GetDatabase -> GetDatabase -> Bool
(GetDatabase -> GetDatabase -> Bool)
-> (GetDatabase -> GetDatabase -> Bool) -> Eq GetDatabase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDatabase -> GetDatabase -> Bool
$c/= :: GetDatabase -> GetDatabase -> Bool
== :: GetDatabase -> GetDatabase -> Bool
$c== :: GetDatabase -> GetDatabase -> Bool
Prelude.Eq, ReadPrec [GetDatabase]
ReadPrec GetDatabase
Int -> ReadS GetDatabase
ReadS [GetDatabase]
(Int -> ReadS GetDatabase)
-> ReadS [GetDatabase]
-> ReadPrec GetDatabase
-> ReadPrec [GetDatabase]
-> Read GetDatabase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDatabase]
$creadListPrec :: ReadPrec [GetDatabase]
readPrec :: ReadPrec GetDatabase
$creadPrec :: ReadPrec GetDatabase
readList :: ReadS [GetDatabase]
$creadList :: ReadS [GetDatabase]
readsPrec :: Int -> ReadS GetDatabase
$creadsPrec :: Int -> ReadS GetDatabase
Prelude.Read, Int -> GetDatabase -> ShowS
[GetDatabase] -> ShowS
GetDatabase -> String
(Int -> GetDatabase -> ShowS)
-> (GetDatabase -> String)
-> ([GetDatabase] -> ShowS)
-> Show GetDatabase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDatabase] -> ShowS
$cshowList :: [GetDatabase] -> ShowS
show :: GetDatabase -> String
$cshow :: GetDatabase -> String
showsPrec :: Int -> GetDatabase -> ShowS
$cshowsPrec :: Int -> GetDatabase -> ShowS
Prelude.Show, (forall x. GetDatabase -> Rep GetDatabase x)
-> (forall x. Rep GetDatabase x -> GetDatabase)
-> Generic GetDatabase
forall x. Rep GetDatabase x -> GetDatabase
forall x. GetDatabase -> Rep GetDatabase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDatabase x -> GetDatabase
$cfrom :: forall x. GetDatabase -> Rep GetDatabase x
Prelude.Generic)
newGetDatabase ::
Prelude.Text ->
GetDatabase
newGetDatabase :: Text -> GetDatabase
newGetDatabase Text
pName_ =
GetDatabase' :: Maybe Text -> Text -> GetDatabase
GetDatabase'
{ $sel:catalogId:GetDatabase' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:GetDatabase' :: Text
name = Text
pName_
}
getDatabase_catalogId :: Lens.Lens' GetDatabase (Prelude.Maybe Prelude.Text)
getDatabase_catalogId :: (Maybe Text -> f (Maybe Text)) -> GetDatabase -> f GetDatabase
getDatabase_catalogId = (GetDatabase -> Maybe Text)
-> (GetDatabase -> Maybe Text -> GetDatabase)
-> Lens GetDatabase GetDatabase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDatabase' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:GetDatabase' :: GetDatabase -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: GetDatabase
s@GetDatabase' {} Maybe Text
a -> GetDatabase
s {$sel:catalogId:GetDatabase' :: Maybe Text
catalogId = Maybe Text
a} :: GetDatabase)
getDatabase_name :: Lens.Lens' GetDatabase Prelude.Text
getDatabase_name :: (Text -> f Text) -> GetDatabase -> f GetDatabase
getDatabase_name = (GetDatabase -> Text)
-> (GetDatabase -> Text -> GetDatabase)
-> Lens GetDatabase GetDatabase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDatabase' {Text
name :: Text
$sel:name:GetDatabase' :: GetDatabase -> Text
name} -> Text
name) (\s :: GetDatabase
s@GetDatabase' {} Text
a -> GetDatabase
s {$sel:name:GetDatabase' :: Text
name = Text
a} :: GetDatabase)
instance Core.AWSRequest GetDatabase where
type AWSResponse GetDatabase = GetDatabaseResponse
request :: GetDatabase -> Request GetDatabase
request = Service -> GetDatabase -> Request GetDatabase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetDatabase
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDatabase)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetDatabase))
-> Logger
-> Service
-> Proxy GetDatabase
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDatabase)))
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 Database -> Int -> GetDatabaseResponse
GetDatabaseResponse'
(Maybe Database -> Int -> GetDatabaseResponse)
-> Either String (Maybe Database)
-> Either String (Int -> GetDatabaseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Database)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Database")
Either String (Int -> GetDatabaseResponse)
-> Either String Int -> Either String GetDatabaseResponse
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 GetDatabase
instance Prelude.NFData GetDatabase
instance Core.ToHeaders GetDatabase where
toHeaders :: GetDatabase -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetDatabase -> 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
"AWSGlue.GetDatabase" :: 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 GetDatabase where
toJSON :: GetDatabase -> Value
toJSON GetDatabase' {Maybe Text
Text
name :: Text
catalogId :: Maybe Text
$sel:name:GetDatabase' :: GetDatabase -> Text
$sel:catalogId:GetDatabase' :: GetDatabase -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"CatalogId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
]
)
instance Core.ToPath GetDatabase where
toPath :: GetDatabase -> ByteString
toPath = ByteString -> GetDatabase -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetDatabase where
toQuery :: GetDatabase -> QueryString
toQuery = QueryString -> GetDatabase -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetDatabaseResponse = GetDatabaseResponse'
{
GetDatabaseResponse -> Maybe Database
database :: Prelude.Maybe Database,
GetDatabaseResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetDatabaseResponse -> GetDatabaseResponse -> Bool
(GetDatabaseResponse -> GetDatabaseResponse -> Bool)
-> (GetDatabaseResponse -> GetDatabaseResponse -> Bool)
-> Eq GetDatabaseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDatabaseResponse -> GetDatabaseResponse -> Bool
$c/= :: GetDatabaseResponse -> GetDatabaseResponse -> Bool
== :: GetDatabaseResponse -> GetDatabaseResponse -> Bool
$c== :: GetDatabaseResponse -> GetDatabaseResponse -> Bool
Prelude.Eq, ReadPrec [GetDatabaseResponse]
ReadPrec GetDatabaseResponse
Int -> ReadS GetDatabaseResponse
ReadS [GetDatabaseResponse]
(Int -> ReadS GetDatabaseResponse)
-> ReadS [GetDatabaseResponse]
-> ReadPrec GetDatabaseResponse
-> ReadPrec [GetDatabaseResponse]
-> Read GetDatabaseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDatabaseResponse]
$creadListPrec :: ReadPrec [GetDatabaseResponse]
readPrec :: ReadPrec GetDatabaseResponse
$creadPrec :: ReadPrec GetDatabaseResponse
readList :: ReadS [GetDatabaseResponse]
$creadList :: ReadS [GetDatabaseResponse]
readsPrec :: Int -> ReadS GetDatabaseResponse
$creadsPrec :: Int -> ReadS GetDatabaseResponse
Prelude.Read, Int -> GetDatabaseResponse -> ShowS
[GetDatabaseResponse] -> ShowS
GetDatabaseResponse -> String
(Int -> GetDatabaseResponse -> ShowS)
-> (GetDatabaseResponse -> String)
-> ([GetDatabaseResponse] -> ShowS)
-> Show GetDatabaseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDatabaseResponse] -> ShowS
$cshowList :: [GetDatabaseResponse] -> ShowS
show :: GetDatabaseResponse -> String
$cshow :: GetDatabaseResponse -> String
showsPrec :: Int -> GetDatabaseResponse -> ShowS
$cshowsPrec :: Int -> GetDatabaseResponse -> ShowS
Prelude.Show, (forall x. GetDatabaseResponse -> Rep GetDatabaseResponse x)
-> (forall x. Rep GetDatabaseResponse x -> GetDatabaseResponse)
-> Generic GetDatabaseResponse
forall x. Rep GetDatabaseResponse x -> GetDatabaseResponse
forall x. GetDatabaseResponse -> Rep GetDatabaseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDatabaseResponse x -> GetDatabaseResponse
$cfrom :: forall x. GetDatabaseResponse -> Rep GetDatabaseResponse x
Prelude.Generic)
newGetDatabaseResponse ::
Prelude.Int ->
GetDatabaseResponse
newGetDatabaseResponse :: Int -> GetDatabaseResponse
newGetDatabaseResponse Int
pHttpStatus_ =
GetDatabaseResponse' :: Maybe Database -> Int -> GetDatabaseResponse
GetDatabaseResponse'
{ $sel:database:GetDatabaseResponse' :: Maybe Database
database = Maybe Database
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetDatabaseResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getDatabaseResponse_database :: Lens.Lens' GetDatabaseResponse (Prelude.Maybe Database)
getDatabaseResponse_database :: (Maybe Database -> f (Maybe Database))
-> GetDatabaseResponse -> f GetDatabaseResponse
getDatabaseResponse_database = (GetDatabaseResponse -> Maybe Database)
-> (GetDatabaseResponse -> Maybe Database -> GetDatabaseResponse)
-> Lens
GetDatabaseResponse
GetDatabaseResponse
(Maybe Database)
(Maybe Database)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDatabaseResponse' {Maybe Database
database :: Maybe Database
$sel:database:GetDatabaseResponse' :: GetDatabaseResponse -> Maybe Database
database} -> Maybe Database
database) (\s :: GetDatabaseResponse
s@GetDatabaseResponse' {} Maybe Database
a -> GetDatabaseResponse
s {$sel:database:GetDatabaseResponse' :: Maybe Database
database = Maybe Database
a} :: GetDatabaseResponse)
getDatabaseResponse_httpStatus :: Lens.Lens' GetDatabaseResponse Prelude.Int
getDatabaseResponse_httpStatus :: (Int -> f Int) -> GetDatabaseResponse -> f GetDatabaseResponse
getDatabaseResponse_httpStatus = (GetDatabaseResponse -> Int)
-> (GetDatabaseResponse -> Int -> GetDatabaseResponse)
-> Lens GetDatabaseResponse GetDatabaseResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDatabaseResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDatabaseResponse' :: GetDatabaseResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDatabaseResponse
s@GetDatabaseResponse' {} Int
a -> GetDatabaseResponse
s {$sel:httpStatus:GetDatabaseResponse' :: Int
httpStatus = Int
a} :: GetDatabaseResponse)
instance Prelude.NFData GetDatabaseResponse