{-# 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.GetMapping
(
GetMapping (..),
newGetMapping,
getMapping_sinks,
getMapping_location,
getMapping_source,
GetMappingResponse (..),
newGetMappingResponse,
getMappingResponse_httpStatus,
getMappingResponse_mapping,
)
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 GetMapping = GetMapping'
{
GetMapping -> Maybe [CatalogEntry]
sinks :: Prelude.Maybe [CatalogEntry],
GetMapping -> Maybe Location
location :: Prelude.Maybe Location,
GetMapping -> CatalogEntry
source :: CatalogEntry
}
deriving (GetMapping -> GetMapping -> Bool
(GetMapping -> GetMapping -> Bool)
-> (GetMapping -> GetMapping -> Bool) -> Eq GetMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMapping -> GetMapping -> Bool
$c/= :: GetMapping -> GetMapping -> Bool
== :: GetMapping -> GetMapping -> Bool
$c== :: GetMapping -> GetMapping -> Bool
Prelude.Eq, ReadPrec [GetMapping]
ReadPrec GetMapping
Int -> ReadS GetMapping
ReadS [GetMapping]
(Int -> ReadS GetMapping)
-> ReadS [GetMapping]
-> ReadPrec GetMapping
-> ReadPrec [GetMapping]
-> Read GetMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMapping]
$creadListPrec :: ReadPrec [GetMapping]
readPrec :: ReadPrec GetMapping
$creadPrec :: ReadPrec GetMapping
readList :: ReadS [GetMapping]
$creadList :: ReadS [GetMapping]
readsPrec :: Int -> ReadS GetMapping
$creadsPrec :: Int -> ReadS GetMapping
Prelude.Read, Int -> GetMapping -> ShowS
[GetMapping] -> ShowS
GetMapping -> String
(Int -> GetMapping -> ShowS)
-> (GetMapping -> String)
-> ([GetMapping] -> ShowS)
-> Show GetMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMapping] -> ShowS
$cshowList :: [GetMapping] -> ShowS
show :: GetMapping -> String
$cshow :: GetMapping -> String
showsPrec :: Int -> GetMapping -> ShowS
$cshowsPrec :: Int -> GetMapping -> ShowS
Prelude.Show, (forall x. GetMapping -> Rep GetMapping x)
-> (forall x. Rep GetMapping x -> GetMapping) -> Generic GetMapping
forall x. Rep GetMapping x -> GetMapping
forall x. GetMapping -> Rep GetMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMapping x -> GetMapping
$cfrom :: forall x. GetMapping -> Rep GetMapping x
Prelude.Generic)
newGetMapping ::
CatalogEntry ->
GetMapping
newGetMapping :: CatalogEntry -> GetMapping
newGetMapping CatalogEntry
pSource_ =
GetMapping' :: Maybe [CatalogEntry]
-> Maybe Location -> CatalogEntry -> GetMapping
GetMapping'
{ $sel:sinks:GetMapping' :: Maybe [CatalogEntry]
sinks = Maybe [CatalogEntry]
forall a. Maybe a
Prelude.Nothing,
$sel:location:GetMapping' :: Maybe Location
location = Maybe Location
forall a. Maybe a
Prelude.Nothing,
$sel:source:GetMapping' :: CatalogEntry
source = CatalogEntry
pSource_
}
getMapping_sinks :: Lens.Lens' GetMapping (Prelude.Maybe [CatalogEntry])
getMapping_sinks :: (Maybe [CatalogEntry] -> f (Maybe [CatalogEntry]))
-> GetMapping -> f GetMapping
getMapping_sinks = (GetMapping -> Maybe [CatalogEntry])
-> (GetMapping -> Maybe [CatalogEntry] -> GetMapping)
-> Lens
GetMapping GetMapping (Maybe [CatalogEntry]) (Maybe [CatalogEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMapping' {Maybe [CatalogEntry]
sinks :: Maybe [CatalogEntry]
$sel:sinks:GetMapping' :: GetMapping -> Maybe [CatalogEntry]
sinks} -> Maybe [CatalogEntry]
sinks) (\s :: GetMapping
s@GetMapping' {} Maybe [CatalogEntry]
a -> GetMapping
s {$sel:sinks:GetMapping' :: Maybe [CatalogEntry]
sinks = Maybe [CatalogEntry]
a} :: GetMapping) ((Maybe [CatalogEntry] -> f (Maybe [CatalogEntry]))
-> GetMapping -> f GetMapping)
-> ((Maybe [CatalogEntry] -> f (Maybe [CatalogEntry]))
-> Maybe [CatalogEntry] -> f (Maybe [CatalogEntry]))
-> (Maybe [CatalogEntry] -> f (Maybe [CatalogEntry]))
-> GetMapping
-> f GetMapping
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [CatalogEntry] [CatalogEntry] [CatalogEntry] [CatalogEntry]
-> Iso
(Maybe [CatalogEntry])
(Maybe [CatalogEntry])
(Maybe [CatalogEntry])
(Maybe [CatalogEntry])
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 [CatalogEntry] [CatalogEntry] [CatalogEntry] [CatalogEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getMapping_location :: Lens.Lens' GetMapping (Prelude.Maybe Location)
getMapping_location :: (Maybe Location -> f (Maybe Location))
-> GetMapping -> f GetMapping
getMapping_location = (GetMapping -> Maybe Location)
-> (GetMapping -> Maybe Location -> GetMapping)
-> Lens GetMapping GetMapping (Maybe Location) (Maybe Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMapping' {Maybe Location
location :: Maybe Location
$sel:location:GetMapping' :: GetMapping -> Maybe Location
location} -> Maybe Location
location) (\s :: GetMapping
s@GetMapping' {} Maybe Location
a -> GetMapping
s {$sel:location:GetMapping' :: Maybe Location
location = Maybe Location
a} :: GetMapping)
getMapping_source :: Lens.Lens' GetMapping CatalogEntry
getMapping_source :: (CatalogEntry -> f CatalogEntry) -> GetMapping -> f GetMapping
getMapping_source = (GetMapping -> CatalogEntry)
-> (GetMapping -> CatalogEntry -> GetMapping)
-> Lens GetMapping GetMapping CatalogEntry CatalogEntry
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMapping' {CatalogEntry
source :: CatalogEntry
$sel:source:GetMapping' :: GetMapping -> CatalogEntry
source} -> CatalogEntry
source) (\s :: GetMapping
s@GetMapping' {} CatalogEntry
a -> GetMapping
s {$sel:source:GetMapping' :: CatalogEntry
source = CatalogEntry
a} :: GetMapping)
instance Core.AWSRequest GetMapping where
type AWSResponse GetMapping = GetMappingResponse
request :: GetMapping -> Request GetMapping
request = Service -> GetMapping -> Request GetMapping
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetMapping
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMapping)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetMapping))
-> Logger
-> Service
-> Proxy GetMapping
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMapping)))
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 ->
Int -> [MappingEntry] -> GetMappingResponse
GetMappingResponse'
(Int -> [MappingEntry] -> GetMappingResponse)
-> Either String Int
-> Either String ([MappingEntry] -> GetMappingResponse)
forall (f :: * -> *) a b. Functor 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))
Either String ([MappingEntry] -> GetMappingResponse)
-> Either String [MappingEntry] -> Either String GetMappingResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Key -> Either String (Maybe [MappingEntry])
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Mapping" Either String (Maybe [MappingEntry])
-> [MappingEntry] -> Either String [MappingEntry]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [MappingEntry]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable GetMapping
instance Prelude.NFData GetMapping
instance Core.ToHeaders GetMapping where
toHeaders :: GetMapping -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetMapping -> 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.GetMapping" :: 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 GetMapping where
toJSON :: GetMapping -> Value
toJSON GetMapping' {Maybe [CatalogEntry]
Maybe Location
CatalogEntry
source :: CatalogEntry
location :: Maybe Location
sinks :: Maybe [CatalogEntry]
$sel:source:GetMapping' :: GetMapping -> CatalogEntry
$sel:location:GetMapping' :: GetMapping -> Maybe Location
$sel:sinks:GetMapping' :: GetMapping -> Maybe [CatalogEntry]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Sinks" Key -> [CatalogEntry] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) ([CatalogEntry] -> Pair) -> Maybe [CatalogEntry] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CatalogEntry]
sinks,
(Key
"Location" Key -> Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) (Location -> Pair) -> Maybe Location -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Location
location,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"Source" Key -> CatalogEntry -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= CatalogEntry
source)
]
)
instance Core.ToPath GetMapping where
toPath :: GetMapping -> ByteString
toPath = ByteString -> GetMapping -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetMapping where
toQuery :: GetMapping -> QueryString
toQuery = QueryString -> GetMapping -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetMappingResponse = GetMappingResponse'
{
GetMappingResponse -> Int
httpStatus :: Prelude.Int,
GetMappingResponse -> [MappingEntry]
mapping :: [MappingEntry]
}
deriving (GetMappingResponse -> GetMappingResponse -> Bool
(GetMappingResponse -> GetMappingResponse -> Bool)
-> (GetMappingResponse -> GetMappingResponse -> Bool)
-> Eq GetMappingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMappingResponse -> GetMappingResponse -> Bool
$c/= :: GetMappingResponse -> GetMappingResponse -> Bool
== :: GetMappingResponse -> GetMappingResponse -> Bool
$c== :: GetMappingResponse -> GetMappingResponse -> Bool
Prelude.Eq, ReadPrec [GetMappingResponse]
ReadPrec GetMappingResponse
Int -> ReadS GetMappingResponse
ReadS [GetMappingResponse]
(Int -> ReadS GetMappingResponse)
-> ReadS [GetMappingResponse]
-> ReadPrec GetMappingResponse
-> ReadPrec [GetMappingResponse]
-> Read GetMappingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMappingResponse]
$creadListPrec :: ReadPrec [GetMappingResponse]
readPrec :: ReadPrec GetMappingResponse
$creadPrec :: ReadPrec GetMappingResponse
readList :: ReadS [GetMappingResponse]
$creadList :: ReadS [GetMappingResponse]
readsPrec :: Int -> ReadS GetMappingResponse
$creadsPrec :: Int -> ReadS GetMappingResponse
Prelude.Read, Int -> GetMappingResponse -> ShowS
[GetMappingResponse] -> ShowS
GetMappingResponse -> String
(Int -> GetMappingResponse -> ShowS)
-> (GetMappingResponse -> String)
-> ([GetMappingResponse] -> ShowS)
-> Show GetMappingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMappingResponse] -> ShowS
$cshowList :: [GetMappingResponse] -> ShowS
show :: GetMappingResponse -> String
$cshow :: GetMappingResponse -> String
showsPrec :: Int -> GetMappingResponse -> ShowS
$cshowsPrec :: Int -> GetMappingResponse -> ShowS
Prelude.Show, (forall x. GetMappingResponse -> Rep GetMappingResponse x)
-> (forall x. Rep GetMappingResponse x -> GetMappingResponse)
-> Generic GetMappingResponse
forall x. Rep GetMappingResponse x -> GetMappingResponse
forall x. GetMappingResponse -> Rep GetMappingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMappingResponse x -> GetMappingResponse
$cfrom :: forall x. GetMappingResponse -> Rep GetMappingResponse x
Prelude.Generic)
newGetMappingResponse ::
Prelude.Int ->
GetMappingResponse
newGetMappingResponse :: Int -> GetMappingResponse
newGetMappingResponse Int
pHttpStatus_ =
GetMappingResponse' :: Int -> [MappingEntry] -> GetMappingResponse
GetMappingResponse'
{ $sel:httpStatus:GetMappingResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:mapping:GetMappingResponse' :: [MappingEntry]
mapping = [MappingEntry]
forall a. Monoid a => a
Prelude.mempty
}
getMappingResponse_httpStatus :: Lens.Lens' GetMappingResponse Prelude.Int
getMappingResponse_httpStatus :: (Int -> f Int) -> GetMappingResponse -> f GetMappingResponse
getMappingResponse_httpStatus = (GetMappingResponse -> Int)
-> (GetMappingResponse -> Int -> GetMappingResponse)
-> Lens GetMappingResponse GetMappingResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMappingResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetMappingResponse' :: GetMappingResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetMappingResponse
s@GetMappingResponse' {} Int
a -> GetMappingResponse
s {$sel:httpStatus:GetMappingResponse' :: Int
httpStatus = Int
a} :: GetMappingResponse)
getMappingResponse_mapping :: Lens.Lens' GetMappingResponse [MappingEntry]
getMappingResponse_mapping :: ([MappingEntry] -> f [MappingEntry])
-> GetMappingResponse -> f GetMappingResponse
getMappingResponse_mapping = (GetMappingResponse -> [MappingEntry])
-> (GetMappingResponse -> [MappingEntry] -> GetMappingResponse)
-> Lens
GetMappingResponse GetMappingResponse [MappingEntry] [MappingEntry]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMappingResponse' {[MappingEntry]
mapping :: [MappingEntry]
$sel:mapping:GetMappingResponse' :: GetMappingResponse -> [MappingEntry]
mapping} -> [MappingEntry]
mapping) (\s :: GetMappingResponse
s@GetMappingResponse' {} [MappingEntry]
a -> GetMappingResponse
s {$sel:mapping:GetMappingResponse' :: [MappingEntry]
mapping = [MappingEntry]
a} :: GetMappingResponse) (([MappingEntry] -> f [MappingEntry])
-> GetMappingResponse -> f GetMappingResponse)
-> (([MappingEntry] -> f [MappingEntry])
-> [MappingEntry] -> f [MappingEntry])
-> ([MappingEntry] -> f [MappingEntry])
-> GetMappingResponse
-> f GetMappingResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MappingEntry] -> f [MappingEntry])
-> [MappingEntry] -> f [MappingEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData GetMappingResponse