{-# 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.GetNamedQuery
(
GetNamedQuery (..),
newGetNamedQuery,
getNamedQuery_namedQueryId,
GetNamedQueryResponse (..),
newGetNamedQueryResponse,
getNamedQueryResponse_namedQuery,
getNamedQueryResponse_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 GetNamedQuery = GetNamedQuery'
{
GetNamedQuery -> Text
namedQueryId :: Prelude.Text
}
deriving (GetNamedQuery -> GetNamedQuery -> Bool
(GetNamedQuery -> GetNamedQuery -> Bool)
-> (GetNamedQuery -> GetNamedQuery -> Bool) -> Eq GetNamedQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNamedQuery -> GetNamedQuery -> Bool
$c/= :: GetNamedQuery -> GetNamedQuery -> Bool
== :: GetNamedQuery -> GetNamedQuery -> Bool
$c== :: GetNamedQuery -> GetNamedQuery -> Bool
Prelude.Eq, ReadPrec [GetNamedQuery]
ReadPrec GetNamedQuery
Int -> ReadS GetNamedQuery
ReadS [GetNamedQuery]
(Int -> ReadS GetNamedQuery)
-> ReadS [GetNamedQuery]
-> ReadPrec GetNamedQuery
-> ReadPrec [GetNamedQuery]
-> Read GetNamedQuery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNamedQuery]
$creadListPrec :: ReadPrec [GetNamedQuery]
readPrec :: ReadPrec GetNamedQuery
$creadPrec :: ReadPrec GetNamedQuery
readList :: ReadS [GetNamedQuery]
$creadList :: ReadS [GetNamedQuery]
readsPrec :: Int -> ReadS GetNamedQuery
$creadsPrec :: Int -> ReadS GetNamedQuery
Prelude.Read, Int -> GetNamedQuery -> ShowS
[GetNamedQuery] -> ShowS
GetNamedQuery -> String
(Int -> GetNamedQuery -> ShowS)
-> (GetNamedQuery -> String)
-> ([GetNamedQuery] -> ShowS)
-> Show GetNamedQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNamedQuery] -> ShowS
$cshowList :: [GetNamedQuery] -> ShowS
show :: GetNamedQuery -> String
$cshow :: GetNamedQuery -> String
showsPrec :: Int -> GetNamedQuery -> ShowS
$cshowsPrec :: Int -> GetNamedQuery -> ShowS
Prelude.Show, (forall x. GetNamedQuery -> Rep GetNamedQuery x)
-> (forall x. Rep GetNamedQuery x -> GetNamedQuery)
-> Generic GetNamedQuery
forall x. Rep GetNamedQuery x -> GetNamedQuery
forall x. GetNamedQuery -> Rep GetNamedQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNamedQuery x -> GetNamedQuery
$cfrom :: forall x. GetNamedQuery -> Rep GetNamedQuery x
Prelude.Generic)
newGetNamedQuery ::
Prelude.Text ->
GetNamedQuery
newGetNamedQuery :: Text -> GetNamedQuery
newGetNamedQuery Text
pNamedQueryId_ =
GetNamedQuery' :: Text -> GetNamedQuery
GetNamedQuery' {$sel:namedQueryId:GetNamedQuery' :: Text
namedQueryId = Text
pNamedQueryId_}
getNamedQuery_namedQueryId :: Lens.Lens' GetNamedQuery Prelude.Text
getNamedQuery_namedQueryId :: (Text -> f Text) -> GetNamedQuery -> f GetNamedQuery
getNamedQuery_namedQueryId = (GetNamedQuery -> Text)
-> (GetNamedQuery -> Text -> GetNamedQuery)
-> Lens GetNamedQuery GetNamedQuery Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNamedQuery' {Text
namedQueryId :: Text
$sel:namedQueryId:GetNamedQuery' :: GetNamedQuery -> Text
namedQueryId} -> Text
namedQueryId) (\s :: GetNamedQuery
s@GetNamedQuery' {} Text
a -> GetNamedQuery
s {$sel:namedQueryId:GetNamedQuery' :: Text
namedQueryId = Text
a} :: GetNamedQuery)
instance Core.AWSRequest GetNamedQuery where
type
AWSResponse GetNamedQuery =
GetNamedQueryResponse
request :: GetNamedQuery -> Request GetNamedQuery
request = Service -> GetNamedQuery -> Request GetNamedQuery
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetNamedQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNamedQuery)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetNamedQuery))
-> Logger
-> Service
-> Proxy GetNamedQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNamedQuery)))
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 NamedQuery -> Int -> GetNamedQueryResponse
GetNamedQueryResponse'
(Maybe NamedQuery -> Int -> GetNamedQueryResponse)
-> Either String (Maybe NamedQuery)
-> Either String (Int -> GetNamedQueryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe NamedQuery)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NamedQuery")
Either String (Int -> GetNamedQueryResponse)
-> Either String Int -> Either String GetNamedQueryResponse
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 GetNamedQuery
instance Prelude.NFData GetNamedQuery
instance Core.ToHeaders GetNamedQuery where
toHeaders :: GetNamedQuery -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetNamedQuery -> 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.GetNamedQuery" :: 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 GetNamedQuery where
toJSON :: GetNamedQuery -> Value
toJSON GetNamedQuery' {Text
namedQueryId :: Text
$sel:namedQueryId:GetNamedQuery' :: GetNamedQuery -> 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
"NamedQueryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
namedQueryId)]
)
instance Core.ToPath GetNamedQuery where
toPath :: GetNamedQuery -> ByteString
toPath = ByteString -> GetNamedQuery -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetNamedQuery where
toQuery :: GetNamedQuery -> QueryString
toQuery = QueryString -> GetNamedQuery -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetNamedQueryResponse = GetNamedQueryResponse'
{
GetNamedQueryResponse -> Maybe NamedQuery
namedQuery :: Prelude.Maybe NamedQuery,
GetNamedQueryResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetNamedQueryResponse -> GetNamedQueryResponse -> Bool
(GetNamedQueryResponse -> GetNamedQueryResponse -> Bool)
-> (GetNamedQueryResponse -> GetNamedQueryResponse -> Bool)
-> Eq GetNamedQueryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNamedQueryResponse -> GetNamedQueryResponse -> Bool
$c/= :: GetNamedQueryResponse -> GetNamedQueryResponse -> Bool
== :: GetNamedQueryResponse -> GetNamedQueryResponse -> Bool
$c== :: GetNamedQueryResponse -> GetNamedQueryResponse -> Bool
Prelude.Eq, ReadPrec [GetNamedQueryResponse]
ReadPrec GetNamedQueryResponse
Int -> ReadS GetNamedQueryResponse
ReadS [GetNamedQueryResponse]
(Int -> ReadS GetNamedQueryResponse)
-> ReadS [GetNamedQueryResponse]
-> ReadPrec GetNamedQueryResponse
-> ReadPrec [GetNamedQueryResponse]
-> Read GetNamedQueryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNamedQueryResponse]
$creadListPrec :: ReadPrec [GetNamedQueryResponse]
readPrec :: ReadPrec GetNamedQueryResponse
$creadPrec :: ReadPrec GetNamedQueryResponse
readList :: ReadS [GetNamedQueryResponse]
$creadList :: ReadS [GetNamedQueryResponse]
readsPrec :: Int -> ReadS GetNamedQueryResponse
$creadsPrec :: Int -> ReadS GetNamedQueryResponse
Prelude.Read, Int -> GetNamedQueryResponse -> ShowS
[GetNamedQueryResponse] -> ShowS
GetNamedQueryResponse -> String
(Int -> GetNamedQueryResponse -> ShowS)
-> (GetNamedQueryResponse -> String)
-> ([GetNamedQueryResponse] -> ShowS)
-> Show GetNamedQueryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNamedQueryResponse] -> ShowS
$cshowList :: [GetNamedQueryResponse] -> ShowS
show :: GetNamedQueryResponse -> String
$cshow :: GetNamedQueryResponse -> String
showsPrec :: Int -> GetNamedQueryResponse -> ShowS
$cshowsPrec :: Int -> GetNamedQueryResponse -> ShowS
Prelude.Show, (forall x. GetNamedQueryResponse -> Rep GetNamedQueryResponse x)
-> (forall x. Rep GetNamedQueryResponse x -> GetNamedQueryResponse)
-> Generic GetNamedQueryResponse
forall x. Rep GetNamedQueryResponse x -> GetNamedQueryResponse
forall x. GetNamedQueryResponse -> Rep GetNamedQueryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNamedQueryResponse x -> GetNamedQueryResponse
$cfrom :: forall x. GetNamedQueryResponse -> Rep GetNamedQueryResponse x
Prelude.Generic)
newGetNamedQueryResponse ::
Prelude.Int ->
GetNamedQueryResponse
newGetNamedQueryResponse :: Int -> GetNamedQueryResponse
newGetNamedQueryResponse Int
pHttpStatus_ =
GetNamedQueryResponse' :: Maybe NamedQuery -> Int -> GetNamedQueryResponse
GetNamedQueryResponse'
{ $sel:namedQuery:GetNamedQueryResponse' :: Maybe NamedQuery
namedQuery =
Maybe NamedQuery
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetNamedQueryResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getNamedQueryResponse_namedQuery :: Lens.Lens' GetNamedQueryResponse (Prelude.Maybe NamedQuery)
getNamedQueryResponse_namedQuery :: (Maybe NamedQuery -> f (Maybe NamedQuery))
-> GetNamedQueryResponse -> f GetNamedQueryResponse
getNamedQueryResponse_namedQuery = (GetNamedQueryResponse -> Maybe NamedQuery)
-> (GetNamedQueryResponse
-> Maybe NamedQuery -> GetNamedQueryResponse)
-> Lens
GetNamedQueryResponse
GetNamedQueryResponse
(Maybe NamedQuery)
(Maybe NamedQuery)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNamedQueryResponse' {Maybe NamedQuery
namedQuery :: Maybe NamedQuery
$sel:namedQuery:GetNamedQueryResponse' :: GetNamedQueryResponse -> Maybe NamedQuery
namedQuery} -> Maybe NamedQuery
namedQuery) (\s :: GetNamedQueryResponse
s@GetNamedQueryResponse' {} Maybe NamedQuery
a -> GetNamedQueryResponse
s {$sel:namedQuery:GetNamedQueryResponse' :: Maybe NamedQuery
namedQuery = Maybe NamedQuery
a} :: GetNamedQueryResponse)
getNamedQueryResponse_httpStatus :: Lens.Lens' GetNamedQueryResponse Prelude.Int
getNamedQueryResponse_httpStatus :: (Int -> f Int) -> GetNamedQueryResponse -> f GetNamedQueryResponse
getNamedQueryResponse_httpStatus = (GetNamedQueryResponse -> Int)
-> (GetNamedQueryResponse -> Int -> GetNamedQueryResponse)
-> Lens GetNamedQueryResponse GetNamedQueryResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNamedQueryResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetNamedQueryResponse' :: GetNamedQueryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetNamedQueryResponse
s@GetNamedQueryResponse' {} Int
a -> GetNamedQueryResponse
s {$sel:httpStatus:GetNamedQueryResponse' :: Int
httpStatus = Int
a} :: GetNamedQueryResponse)
instance Prelude.NFData GetNamedQueryResponse