{-# 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.Athena.GetDatabase
(
GetDatabase (..),
newGetDatabase,
getDatabase_catalogName,
getDatabase_databaseName,
GetDatabaseResponse (..),
newGetDatabaseResponse,
getDatabaseResponse_database,
getDatabaseResponse_httpStatus,
)
where
import Amazonka.Athena.Types
import qualified Amazonka.Core as Core
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 -> Text
catalogName :: Prelude.Text,
GetDatabase -> Text
databaseName :: 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 ->
Prelude.Text ->
GetDatabase
newGetDatabase :: Text -> Text -> GetDatabase
newGetDatabase Text
pCatalogName_ Text
pDatabaseName_ =
GetDatabase' :: Text -> Text -> GetDatabase
GetDatabase'
{ $sel:catalogName:GetDatabase' :: Text
catalogName = Text
pCatalogName_,
$sel:databaseName:GetDatabase' :: Text
databaseName = Text
pDatabaseName_
}
getDatabase_catalogName :: Lens.Lens' GetDatabase Prelude.Text
getDatabase_catalogName :: (Text -> f Text) -> GetDatabase -> f GetDatabase
getDatabase_catalogName = (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
catalogName :: Text
$sel:catalogName:GetDatabase' :: GetDatabase -> Text
catalogName} -> Text
catalogName) (\s :: GetDatabase
s@GetDatabase' {} Text
a -> GetDatabase
s {$sel:catalogName:GetDatabase' :: Text
catalogName = Text
a} :: GetDatabase)
getDatabase_databaseName :: Lens.Lens' GetDatabase Prelude.Text
getDatabase_databaseName :: (Text -> f Text) -> GetDatabase -> f GetDatabase
getDatabase_databaseName = (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
databaseName :: Text
$sel:databaseName:GetDatabase' :: GetDatabase -> Text
databaseName} -> Text
databaseName) (\s :: GetDatabase
s@GetDatabase' {} Text
a -> GetDatabase
s {$sel:databaseName:GetDatabase' :: Text
databaseName = 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
"AmazonAthena.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' {Text
databaseName :: Text
catalogName :: Text
$sel:databaseName:GetDatabase' :: GetDatabase -> Text
$sel:catalogName:GetDatabase' :: GetDatabase -> 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
"CatalogName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
catalogName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName)
]
)
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