{-# 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.CreatePartition
(
CreatePartition (..),
newCreatePartition,
createPartition_catalogId,
createPartition_databaseName,
createPartition_tableName,
createPartition_partitionInput,
CreatePartitionResponse (..),
newCreatePartitionResponse,
createPartitionResponse_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 CreatePartition = CreatePartition'
{
CreatePartition -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
CreatePartition -> Text
databaseName :: Prelude.Text,
CreatePartition -> Text
tableName :: Prelude.Text,
CreatePartition -> PartitionInput
partitionInput :: PartitionInput
}
deriving (CreatePartition -> CreatePartition -> Bool
(CreatePartition -> CreatePartition -> Bool)
-> (CreatePartition -> CreatePartition -> Bool)
-> Eq CreatePartition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePartition -> CreatePartition -> Bool
$c/= :: CreatePartition -> CreatePartition -> Bool
== :: CreatePartition -> CreatePartition -> Bool
$c== :: CreatePartition -> CreatePartition -> Bool
Prelude.Eq, ReadPrec [CreatePartition]
ReadPrec CreatePartition
Int -> ReadS CreatePartition
ReadS [CreatePartition]
(Int -> ReadS CreatePartition)
-> ReadS [CreatePartition]
-> ReadPrec CreatePartition
-> ReadPrec [CreatePartition]
-> Read CreatePartition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePartition]
$creadListPrec :: ReadPrec [CreatePartition]
readPrec :: ReadPrec CreatePartition
$creadPrec :: ReadPrec CreatePartition
readList :: ReadS [CreatePartition]
$creadList :: ReadS [CreatePartition]
readsPrec :: Int -> ReadS CreatePartition
$creadsPrec :: Int -> ReadS CreatePartition
Prelude.Read, Int -> CreatePartition -> ShowS
[CreatePartition] -> ShowS
CreatePartition -> String
(Int -> CreatePartition -> ShowS)
-> (CreatePartition -> String)
-> ([CreatePartition] -> ShowS)
-> Show CreatePartition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePartition] -> ShowS
$cshowList :: [CreatePartition] -> ShowS
show :: CreatePartition -> String
$cshow :: CreatePartition -> String
showsPrec :: Int -> CreatePartition -> ShowS
$cshowsPrec :: Int -> CreatePartition -> ShowS
Prelude.Show, (forall x. CreatePartition -> Rep CreatePartition x)
-> (forall x. Rep CreatePartition x -> CreatePartition)
-> Generic CreatePartition
forall x. Rep CreatePartition x -> CreatePartition
forall x. CreatePartition -> Rep CreatePartition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePartition x -> CreatePartition
$cfrom :: forall x. CreatePartition -> Rep CreatePartition x
Prelude.Generic)
newCreatePartition ::
Prelude.Text ->
Prelude.Text ->
PartitionInput ->
CreatePartition
newCreatePartition :: Text -> Text -> PartitionInput -> CreatePartition
newCreatePartition
Text
pDatabaseName_
Text
pTableName_
PartitionInput
pPartitionInput_ =
CreatePartition' :: Maybe Text -> Text -> Text -> PartitionInput -> CreatePartition
CreatePartition'
{ $sel:catalogId:CreatePartition' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:databaseName:CreatePartition' :: Text
databaseName = Text
pDatabaseName_,
$sel:tableName:CreatePartition' :: Text
tableName = Text
pTableName_,
$sel:partitionInput:CreatePartition' :: PartitionInput
partitionInput = PartitionInput
pPartitionInput_
}
createPartition_catalogId :: Lens.Lens' CreatePartition (Prelude.Maybe Prelude.Text)
createPartition_catalogId :: (Maybe Text -> f (Maybe Text))
-> CreatePartition -> f CreatePartition
createPartition_catalogId = (CreatePartition -> Maybe Text)
-> (CreatePartition -> Maybe Text -> CreatePartition)
-> Lens CreatePartition CreatePartition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePartition' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:CreatePartition' :: CreatePartition -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: CreatePartition
s@CreatePartition' {} Maybe Text
a -> CreatePartition
s {$sel:catalogId:CreatePartition' :: Maybe Text
catalogId = Maybe Text
a} :: CreatePartition)
createPartition_databaseName :: Lens.Lens' CreatePartition Prelude.Text
createPartition_databaseName :: (Text -> f Text) -> CreatePartition -> f CreatePartition
createPartition_databaseName = (CreatePartition -> Text)
-> (CreatePartition -> Text -> CreatePartition)
-> Lens CreatePartition CreatePartition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePartition' {Text
databaseName :: Text
$sel:databaseName:CreatePartition' :: CreatePartition -> Text
databaseName} -> Text
databaseName) (\s :: CreatePartition
s@CreatePartition' {} Text
a -> CreatePartition
s {$sel:databaseName:CreatePartition' :: Text
databaseName = Text
a} :: CreatePartition)
createPartition_tableName :: Lens.Lens' CreatePartition Prelude.Text
createPartition_tableName :: (Text -> f Text) -> CreatePartition -> f CreatePartition
createPartition_tableName = (CreatePartition -> Text)
-> (CreatePartition -> Text -> CreatePartition)
-> Lens CreatePartition CreatePartition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePartition' {Text
tableName :: Text
$sel:tableName:CreatePartition' :: CreatePartition -> Text
tableName} -> Text
tableName) (\s :: CreatePartition
s@CreatePartition' {} Text
a -> CreatePartition
s {$sel:tableName:CreatePartition' :: Text
tableName = Text
a} :: CreatePartition)
createPartition_partitionInput :: Lens.Lens' CreatePartition PartitionInput
createPartition_partitionInput :: (PartitionInput -> f PartitionInput)
-> CreatePartition -> f CreatePartition
createPartition_partitionInput = (CreatePartition -> PartitionInput)
-> (CreatePartition -> PartitionInput -> CreatePartition)
-> Lens
CreatePartition CreatePartition PartitionInput PartitionInput
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePartition' {PartitionInput
partitionInput :: PartitionInput
$sel:partitionInput:CreatePartition' :: CreatePartition -> PartitionInput
partitionInput} -> PartitionInput
partitionInput) (\s :: CreatePartition
s@CreatePartition' {} PartitionInput
a -> CreatePartition
s {$sel:partitionInput:CreatePartition' :: PartitionInput
partitionInput = PartitionInput
a} :: CreatePartition)
instance Core.AWSRequest CreatePartition where
type
AWSResponse CreatePartition =
CreatePartitionResponse
request :: CreatePartition -> Request CreatePartition
request = Service -> CreatePartition -> Request CreatePartition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreatePartition
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePartition)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreatePartition))
-> Logger
-> Service
-> Proxy CreatePartition
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePartition)))
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 -> CreatePartitionResponse
CreatePartitionResponse'
(Int -> CreatePartitionResponse)
-> Either String Int -> Either String CreatePartitionResponse
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 CreatePartition
instance Prelude.NFData CreatePartition
instance Core.ToHeaders CreatePartition where
toHeaders :: CreatePartition -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreatePartition -> 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.CreatePartition" :: 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 CreatePartition where
toJSON :: CreatePartition -> Value
toJSON CreatePartition' {Maybe Text
Text
PartitionInput
partitionInput :: PartitionInput
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:partitionInput:CreatePartition' :: CreatePartition -> PartitionInput
$sel:tableName:CreatePartition' :: CreatePartition -> Text
$sel:databaseName:CreatePartition' :: CreatePartition -> Text
$sel:catalogId:CreatePartition' :: CreatePartition -> 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
"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
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"PartitionInput" Text -> PartitionInput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PartitionInput
partitionInput)
]
)
instance Core.ToPath CreatePartition where
toPath :: CreatePartition -> ByteString
toPath = ByteString -> CreatePartition -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreatePartition where
toQuery :: CreatePartition -> QueryString
toQuery = QueryString -> CreatePartition -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreatePartitionResponse = CreatePartitionResponse'
{
CreatePartitionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreatePartitionResponse -> CreatePartitionResponse -> Bool
(CreatePartitionResponse -> CreatePartitionResponse -> Bool)
-> (CreatePartitionResponse -> CreatePartitionResponse -> Bool)
-> Eq CreatePartitionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePartitionResponse -> CreatePartitionResponse -> Bool
$c/= :: CreatePartitionResponse -> CreatePartitionResponse -> Bool
== :: CreatePartitionResponse -> CreatePartitionResponse -> Bool
$c== :: CreatePartitionResponse -> CreatePartitionResponse -> Bool
Prelude.Eq, ReadPrec [CreatePartitionResponse]
ReadPrec CreatePartitionResponse
Int -> ReadS CreatePartitionResponse
ReadS [CreatePartitionResponse]
(Int -> ReadS CreatePartitionResponse)
-> ReadS [CreatePartitionResponse]
-> ReadPrec CreatePartitionResponse
-> ReadPrec [CreatePartitionResponse]
-> Read CreatePartitionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePartitionResponse]
$creadListPrec :: ReadPrec [CreatePartitionResponse]
readPrec :: ReadPrec CreatePartitionResponse
$creadPrec :: ReadPrec CreatePartitionResponse
readList :: ReadS [CreatePartitionResponse]
$creadList :: ReadS [CreatePartitionResponse]
readsPrec :: Int -> ReadS CreatePartitionResponse
$creadsPrec :: Int -> ReadS CreatePartitionResponse
Prelude.Read, Int -> CreatePartitionResponse -> ShowS
[CreatePartitionResponse] -> ShowS
CreatePartitionResponse -> String
(Int -> CreatePartitionResponse -> ShowS)
-> (CreatePartitionResponse -> String)
-> ([CreatePartitionResponse] -> ShowS)
-> Show CreatePartitionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePartitionResponse] -> ShowS
$cshowList :: [CreatePartitionResponse] -> ShowS
show :: CreatePartitionResponse -> String
$cshow :: CreatePartitionResponse -> String
showsPrec :: Int -> CreatePartitionResponse -> ShowS
$cshowsPrec :: Int -> CreatePartitionResponse -> ShowS
Prelude.Show, (forall x.
CreatePartitionResponse -> Rep CreatePartitionResponse x)
-> (forall x.
Rep CreatePartitionResponse x -> CreatePartitionResponse)
-> Generic CreatePartitionResponse
forall x. Rep CreatePartitionResponse x -> CreatePartitionResponse
forall x. CreatePartitionResponse -> Rep CreatePartitionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePartitionResponse x -> CreatePartitionResponse
$cfrom :: forall x. CreatePartitionResponse -> Rep CreatePartitionResponse x
Prelude.Generic)
newCreatePartitionResponse ::
Prelude.Int ->
CreatePartitionResponse
newCreatePartitionResponse :: Int -> CreatePartitionResponse
newCreatePartitionResponse Int
pHttpStatus_ =
CreatePartitionResponse' :: Int -> CreatePartitionResponse
CreatePartitionResponse' {$sel:httpStatus:CreatePartitionResponse' :: Int
httpStatus = Int
pHttpStatus_}
createPartitionResponse_httpStatus :: Lens.Lens' CreatePartitionResponse Prelude.Int
createPartitionResponse_httpStatus :: (Int -> f Int)
-> CreatePartitionResponse -> f CreatePartitionResponse
createPartitionResponse_httpStatus = (CreatePartitionResponse -> Int)
-> (CreatePartitionResponse -> Int -> CreatePartitionResponse)
-> Lens CreatePartitionResponse CreatePartitionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePartitionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreatePartitionResponse' :: CreatePartitionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreatePartitionResponse
s@CreatePartitionResponse' {} Int
a -> CreatePartitionResponse
s {$sel:httpStatus:CreatePartitionResponse' :: Int
httpStatus = Int
a} :: CreatePartitionResponse)
instance Prelude.NFData CreatePartitionResponse