{-# 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.CreateTable
(
CreateTable (..),
newCreateTable,
createTable_partitionIndexes,
createTable_catalogId,
createTable_databaseName,
createTable_tableInput,
CreateTableResponse (..),
newCreateTableResponse,
createTableResponse_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 CreateTable = CreateTable'
{
CreateTable -> Maybe [PartitionIndex]
partitionIndexes :: Prelude.Maybe [PartitionIndex],
CreateTable -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
CreateTable -> Text
databaseName :: Prelude.Text,
CreateTable -> TableInput
tableInput :: TableInput
}
deriving (CreateTable -> CreateTable -> Bool
(CreateTable -> CreateTable -> Bool)
-> (CreateTable -> CreateTable -> Bool) -> Eq CreateTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTable -> CreateTable -> Bool
$c/= :: CreateTable -> CreateTable -> Bool
== :: CreateTable -> CreateTable -> Bool
$c== :: CreateTable -> CreateTable -> Bool
Prelude.Eq, ReadPrec [CreateTable]
ReadPrec CreateTable
Int -> ReadS CreateTable
ReadS [CreateTable]
(Int -> ReadS CreateTable)
-> ReadS [CreateTable]
-> ReadPrec CreateTable
-> ReadPrec [CreateTable]
-> Read CreateTable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTable]
$creadListPrec :: ReadPrec [CreateTable]
readPrec :: ReadPrec CreateTable
$creadPrec :: ReadPrec CreateTable
readList :: ReadS [CreateTable]
$creadList :: ReadS [CreateTable]
readsPrec :: Int -> ReadS CreateTable
$creadsPrec :: Int -> ReadS CreateTable
Prelude.Read, Int -> CreateTable -> ShowS
[CreateTable] -> ShowS
CreateTable -> String
(Int -> CreateTable -> ShowS)
-> (CreateTable -> String)
-> ([CreateTable] -> ShowS)
-> Show CreateTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTable] -> ShowS
$cshowList :: [CreateTable] -> ShowS
show :: CreateTable -> String
$cshow :: CreateTable -> String
showsPrec :: Int -> CreateTable -> ShowS
$cshowsPrec :: Int -> CreateTable -> ShowS
Prelude.Show, (forall x. CreateTable -> Rep CreateTable x)
-> (forall x. Rep CreateTable x -> CreateTable)
-> Generic CreateTable
forall x. Rep CreateTable x -> CreateTable
forall x. CreateTable -> Rep CreateTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTable x -> CreateTable
$cfrom :: forall x. CreateTable -> Rep CreateTable x
Prelude.Generic)
newCreateTable ::
Prelude.Text ->
TableInput ->
CreateTable
newCreateTable :: Text -> TableInput -> CreateTable
newCreateTable Text
pDatabaseName_ TableInput
pTableInput_ =
CreateTable' :: Maybe [PartitionIndex]
-> Maybe Text -> Text -> TableInput -> CreateTable
CreateTable'
{ $sel:partitionIndexes:CreateTable' :: Maybe [PartitionIndex]
partitionIndexes = Maybe [PartitionIndex]
forall a. Maybe a
Prelude.Nothing,
$sel:catalogId:CreateTable' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:databaseName:CreateTable' :: Text
databaseName = Text
pDatabaseName_,
$sel:tableInput:CreateTable' :: TableInput
tableInput = TableInput
pTableInput_
}
createTable_partitionIndexes :: Lens.Lens' CreateTable (Prelude.Maybe [PartitionIndex])
createTable_partitionIndexes :: (Maybe [PartitionIndex] -> f (Maybe [PartitionIndex]))
-> CreateTable -> f CreateTable
createTable_partitionIndexes = (CreateTable -> Maybe [PartitionIndex])
-> (CreateTable -> Maybe [PartitionIndex] -> CreateTable)
-> Lens
CreateTable
CreateTable
(Maybe [PartitionIndex])
(Maybe [PartitionIndex])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe [PartitionIndex]
partitionIndexes :: Maybe [PartitionIndex]
$sel:partitionIndexes:CreateTable' :: CreateTable -> Maybe [PartitionIndex]
partitionIndexes} -> Maybe [PartitionIndex]
partitionIndexes) (\s :: CreateTable
s@CreateTable' {} Maybe [PartitionIndex]
a -> CreateTable
s {$sel:partitionIndexes:CreateTable' :: Maybe [PartitionIndex]
partitionIndexes = Maybe [PartitionIndex]
a} :: CreateTable) ((Maybe [PartitionIndex] -> f (Maybe [PartitionIndex]))
-> CreateTable -> f CreateTable)
-> ((Maybe [PartitionIndex] -> f (Maybe [PartitionIndex]))
-> Maybe [PartitionIndex] -> f (Maybe [PartitionIndex]))
-> (Maybe [PartitionIndex] -> f (Maybe [PartitionIndex]))
-> CreateTable
-> f CreateTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[PartitionIndex] [PartitionIndex] [PartitionIndex] [PartitionIndex]
-> Iso
(Maybe [PartitionIndex])
(Maybe [PartitionIndex])
(Maybe [PartitionIndex])
(Maybe [PartitionIndex])
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
[PartitionIndex] [PartitionIndex] [PartitionIndex] [PartitionIndex]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createTable_catalogId :: Lens.Lens' CreateTable (Prelude.Maybe Prelude.Text)
createTable_catalogId :: (Maybe Text -> f (Maybe Text)) -> CreateTable -> f CreateTable
createTable_catalogId = (CreateTable -> Maybe Text)
-> (CreateTable -> Maybe Text -> CreateTable)
-> Lens CreateTable CreateTable (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:CreateTable' :: CreateTable -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: CreateTable
s@CreateTable' {} Maybe Text
a -> CreateTable
s {$sel:catalogId:CreateTable' :: Maybe Text
catalogId = Maybe Text
a} :: CreateTable)
createTable_databaseName :: Lens.Lens' CreateTable Prelude.Text
createTable_databaseName :: (Text -> f Text) -> CreateTable -> f CreateTable
createTable_databaseName = (CreateTable -> Text)
-> (CreateTable -> Text -> CreateTable)
-> Lens CreateTable CreateTable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {Text
databaseName :: Text
$sel:databaseName:CreateTable' :: CreateTable -> Text
databaseName} -> Text
databaseName) (\s :: CreateTable
s@CreateTable' {} Text
a -> CreateTable
s {$sel:databaseName:CreateTable' :: Text
databaseName = Text
a} :: CreateTable)
createTable_tableInput :: Lens.Lens' CreateTable TableInput
createTable_tableInput :: (TableInput -> f TableInput) -> CreateTable -> f CreateTable
createTable_tableInput = (CreateTable -> TableInput)
-> (CreateTable -> TableInput -> CreateTable)
-> Lens CreateTable CreateTable TableInput TableInput
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTable' {TableInput
tableInput :: TableInput
$sel:tableInput:CreateTable' :: CreateTable -> TableInput
tableInput} -> TableInput
tableInput) (\s :: CreateTable
s@CreateTable' {} TableInput
a -> CreateTable
s {$sel:tableInput:CreateTable' :: TableInput
tableInput = TableInput
a} :: CreateTable)
instance Core.AWSRequest CreateTable where
type AWSResponse CreateTable = CreateTableResponse
request :: CreateTable -> Request CreateTable
request = Service -> CreateTable -> Request CreateTable
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTable)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreateTable))
-> Logger
-> Service
-> Proxy CreateTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTable)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> CreateTableResponse
CreateTableResponse'
(Int -> CreateTableResponse)
-> Either String Int -> Either String CreateTableResponse
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))
)
instance Prelude.Hashable CreateTable
instance Prelude.NFData CreateTable
instance Core.ToHeaders CreateTable where
toHeaders :: CreateTable -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateTable -> 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.CreateTable" :: 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 CreateTable where
toJSON :: CreateTable -> Value
toJSON CreateTable' {Maybe [PartitionIndex]
Maybe Text
Text
TableInput
tableInput :: TableInput
databaseName :: Text
catalogId :: Maybe Text
partitionIndexes :: Maybe [PartitionIndex]
$sel:tableInput:CreateTable' :: CreateTable -> TableInput
$sel:databaseName:CreateTable' :: CreateTable -> Text
$sel:catalogId:CreateTable' :: CreateTable -> Maybe Text
$sel:partitionIndexes:CreateTable' :: CreateTable -> Maybe [PartitionIndex]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"PartitionIndexes" Text -> [PartitionIndex] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([PartitionIndex] -> Pair) -> Maybe [PartitionIndex] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PartitionIndex]
partitionIndexes,
(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
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TableInput" Text -> TableInput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TableInput
tableInput)
]
)
instance Core.ToPath CreateTable where
toPath :: CreateTable -> ByteString
toPath = ByteString -> CreateTable -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateTable where
toQuery :: CreateTable -> QueryString
toQuery = QueryString -> CreateTable -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateTableResponse = CreateTableResponse'
{
CreateTableResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateTableResponse -> CreateTableResponse -> Bool
(CreateTableResponse -> CreateTableResponse -> Bool)
-> (CreateTableResponse -> CreateTableResponse -> Bool)
-> Eq CreateTableResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTableResponse -> CreateTableResponse -> Bool
$c/= :: CreateTableResponse -> CreateTableResponse -> Bool
== :: CreateTableResponse -> CreateTableResponse -> Bool
$c== :: CreateTableResponse -> CreateTableResponse -> Bool
Prelude.Eq, ReadPrec [CreateTableResponse]
ReadPrec CreateTableResponse
Int -> ReadS CreateTableResponse
ReadS [CreateTableResponse]
(Int -> ReadS CreateTableResponse)
-> ReadS [CreateTableResponse]
-> ReadPrec CreateTableResponse
-> ReadPrec [CreateTableResponse]
-> Read CreateTableResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTableResponse]
$creadListPrec :: ReadPrec [CreateTableResponse]
readPrec :: ReadPrec CreateTableResponse
$creadPrec :: ReadPrec CreateTableResponse
readList :: ReadS [CreateTableResponse]
$creadList :: ReadS [CreateTableResponse]
readsPrec :: Int -> ReadS CreateTableResponse
$creadsPrec :: Int -> ReadS CreateTableResponse
Prelude.Read, Int -> CreateTableResponse -> ShowS
[CreateTableResponse] -> ShowS
CreateTableResponse -> String
(Int -> CreateTableResponse -> ShowS)
-> (CreateTableResponse -> String)
-> ([CreateTableResponse] -> ShowS)
-> Show CreateTableResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTableResponse] -> ShowS
$cshowList :: [CreateTableResponse] -> ShowS
show :: CreateTableResponse -> String
$cshow :: CreateTableResponse -> String
showsPrec :: Int -> CreateTableResponse -> ShowS
$cshowsPrec :: Int -> CreateTableResponse -> ShowS
Prelude.Show, (forall x. CreateTableResponse -> Rep CreateTableResponse x)
-> (forall x. Rep CreateTableResponse x -> CreateTableResponse)
-> Generic CreateTableResponse
forall x. Rep CreateTableResponse x -> CreateTableResponse
forall x. CreateTableResponse -> Rep CreateTableResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTableResponse x -> CreateTableResponse
$cfrom :: forall x. CreateTableResponse -> Rep CreateTableResponse x
Prelude.Generic)
newCreateTableResponse ::
Prelude.Int ->
CreateTableResponse
newCreateTableResponse :: Int -> CreateTableResponse
newCreateTableResponse Int
pHttpStatus_ =
CreateTableResponse' :: Int -> CreateTableResponse
CreateTableResponse' {$sel:httpStatus:CreateTableResponse' :: Int
httpStatus = Int
pHttpStatus_}
createTableResponse_httpStatus :: Lens.Lens' CreateTableResponse Prelude.Int
createTableResponse_httpStatus :: (Int -> f Int) -> CreateTableResponse -> f CreateTableResponse
createTableResponse_httpStatus = (CreateTableResponse -> Int)
-> (CreateTableResponse -> Int -> CreateTableResponse)
-> Lens CreateTableResponse CreateTableResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTableResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateTableResponse' :: CreateTableResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateTableResponse
s@CreateTableResponse' {} Int
a -> CreateTableResponse
s {$sel:httpStatus:CreateTableResponse' :: Int
httpStatus = Int
a} :: CreateTableResponse)
instance Prelude.NFData CreateTableResponse