{-# 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.BatchCreatePartition
(
BatchCreatePartition (..),
newBatchCreatePartition,
batchCreatePartition_catalogId,
batchCreatePartition_databaseName,
batchCreatePartition_tableName,
batchCreatePartition_partitionInputList,
BatchCreatePartitionResponse (..),
newBatchCreatePartitionResponse,
batchCreatePartitionResponse_errors,
batchCreatePartitionResponse_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 BatchCreatePartition = BatchCreatePartition'
{
BatchCreatePartition -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
BatchCreatePartition -> Text
databaseName :: Prelude.Text,
BatchCreatePartition -> Text
tableName :: Prelude.Text,
BatchCreatePartition -> [PartitionInput]
partitionInputList :: [PartitionInput]
}
deriving (BatchCreatePartition -> BatchCreatePartition -> Bool
(BatchCreatePartition -> BatchCreatePartition -> Bool)
-> (BatchCreatePartition -> BatchCreatePartition -> Bool)
-> Eq BatchCreatePartition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreatePartition -> BatchCreatePartition -> Bool
$c/= :: BatchCreatePartition -> BatchCreatePartition -> Bool
== :: BatchCreatePartition -> BatchCreatePartition -> Bool
$c== :: BatchCreatePartition -> BatchCreatePartition -> Bool
Prelude.Eq, ReadPrec [BatchCreatePartition]
ReadPrec BatchCreatePartition
Int -> ReadS BatchCreatePartition
ReadS [BatchCreatePartition]
(Int -> ReadS BatchCreatePartition)
-> ReadS [BatchCreatePartition]
-> ReadPrec BatchCreatePartition
-> ReadPrec [BatchCreatePartition]
-> Read BatchCreatePartition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreatePartition]
$creadListPrec :: ReadPrec [BatchCreatePartition]
readPrec :: ReadPrec BatchCreatePartition
$creadPrec :: ReadPrec BatchCreatePartition
readList :: ReadS [BatchCreatePartition]
$creadList :: ReadS [BatchCreatePartition]
readsPrec :: Int -> ReadS BatchCreatePartition
$creadsPrec :: Int -> ReadS BatchCreatePartition
Prelude.Read, Int -> BatchCreatePartition -> ShowS
[BatchCreatePartition] -> ShowS
BatchCreatePartition -> String
(Int -> BatchCreatePartition -> ShowS)
-> (BatchCreatePartition -> String)
-> ([BatchCreatePartition] -> ShowS)
-> Show BatchCreatePartition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreatePartition] -> ShowS
$cshowList :: [BatchCreatePartition] -> ShowS
show :: BatchCreatePartition -> String
$cshow :: BatchCreatePartition -> String
showsPrec :: Int -> BatchCreatePartition -> ShowS
$cshowsPrec :: Int -> BatchCreatePartition -> ShowS
Prelude.Show, (forall x. BatchCreatePartition -> Rep BatchCreatePartition x)
-> (forall x. Rep BatchCreatePartition x -> BatchCreatePartition)
-> Generic BatchCreatePartition
forall x. Rep BatchCreatePartition x -> BatchCreatePartition
forall x. BatchCreatePartition -> Rep BatchCreatePartition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchCreatePartition x -> BatchCreatePartition
$cfrom :: forall x. BatchCreatePartition -> Rep BatchCreatePartition x
Prelude.Generic)
newBatchCreatePartition ::
Prelude.Text ->
Prelude.Text ->
BatchCreatePartition
newBatchCreatePartition :: Text -> Text -> BatchCreatePartition
newBatchCreatePartition Text
pDatabaseName_ Text
pTableName_ =
BatchCreatePartition' :: Maybe Text
-> Text -> Text -> [PartitionInput] -> BatchCreatePartition
BatchCreatePartition'
{ $sel:catalogId:BatchCreatePartition' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:databaseName:BatchCreatePartition' :: Text
databaseName = Text
pDatabaseName_,
$sel:tableName:BatchCreatePartition' :: Text
tableName = Text
pTableName_,
$sel:partitionInputList:BatchCreatePartition' :: [PartitionInput]
partitionInputList = [PartitionInput]
forall a. Monoid a => a
Prelude.mempty
}
batchCreatePartition_catalogId :: Lens.Lens' BatchCreatePartition (Prelude.Maybe Prelude.Text)
batchCreatePartition_catalogId :: (Maybe Text -> f (Maybe Text))
-> BatchCreatePartition -> f BatchCreatePartition
batchCreatePartition_catalogId = (BatchCreatePartition -> Maybe Text)
-> (BatchCreatePartition -> Maybe Text -> BatchCreatePartition)
-> Lens
BatchCreatePartition BatchCreatePartition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreatePartition' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:BatchCreatePartition' :: BatchCreatePartition -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: BatchCreatePartition
s@BatchCreatePartition' {} Maybe Text
a -> BatchCreatePartition
s {$sel:catalogId:BatchCreatePartition' :: Maybe Text
catalogId = Maybe Text
a} :: BatchCreatePartition)
batchCreatePartition_databaseName :: Lens.Lens' BatchCreatePartition Prelude.Text
batchCreatePartition_databaseName :: (Text -> f Text) -> BatchCreatePartition -> f BatchCreatePartition
batchCreatePartition_databaseName = (BatchCreatePartition -> Text)
-> (BatchCreatePartition -> Text -> BatchCreatePartition)
-> Lens BatchCreatePartition BatchCreatePartition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreatePartition' {Text
databaseName :: Text
$sel:databaseName:BatchCreatePartition' :: BatchCreatePartition -> Text
databaseName} -> Text
databaseName) (\s :: BatchCreatePartition
s@BatchCreatePartition' {} Text
a -> BatchCreatePartition
s {$sel:databaseName:BatchCreatePartition' :: Text
databaseName = Text
a} :: BatchCreatePartition)
batchCreatePartition_tableName :: Lens.Lens' BatchCreatePartition Prelude.Text
batchCreatePartition_tableName :: (Text -> f Text) -> BatchCreatePartition -> f BatchCreatePartition
batchCreatePartition_tableName = (BatchCreatePartition -> Text)
-> (BatchCreatePartition -> Text -> BatchCreatePartition)
-> Lens BatchCreatePartition BatchCreatePartition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreatePartition' {Text
tableName :: Text
$sel:tableName:BatchCreatePartition' :: BatchCreatePartition -> Text
tableName} -> Text
tableName) (\s :: BatchCreatePartition
s@BatchCreatePartition' {} Text
a -> BatchCreatePartition
s {$sel:tableName:BatchCreatePartition' :: Text
tableName = Text
a} :: BatchCreatePartition)
batchCreatePartition_partitionInputList :: Lens.Lens' BatchCreatePartition [PartitionInput]
batchCreatePartition_partitionInputList :: ([PartitionInput] -> f [PartitionInput])
-> BatchCreatePartition -> f BatchCreatePartition
batchCreatePartition_partitionInputList = (BatchCreatePartition -> [PartitionInput])
-> (BatchCreatePartition
-> [PartitionInput] -> BatchCreatePartition)
-> Lens
BatchCreatePartition
BatchCreatePartition
[PartitionInput]
[PartitionInput]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreatePartition' {[PartitionInput]
partitionInputList :: [PartitionInput]
$sel:partitionInputList:BatchCreatePartition' :: BatchCreatePartition -> [PartitionInput]
partitionInputList} -> [PartitionInput]
partitionInputList) (\s :: BatchCreatePartition
s@BatchCreatePartition' {} [PartitionInput]
a -> BatchCreatePartition
s {$sel:partitionInputList:BatchCreatePartition' :: [PartitionInput]
partitionInputList = [PartitionInput]
a} :: BatchCreatePartition) (([PartitionInput] -> f [PartitionInput])
-> BatchCreatePartition -> f BatchCreatePartition)
-> (([PartitionInput] -> f [PartitionInput])
-> [PartitionInput] -> f [PartitionInput])
-> ([PartitionInput] -> f [PartitionInput])
-> BatchCreatePartition
-> f BatchCreatePartition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PartitionInput] -> f [PartitionInput])
-> [PartitionInput] -> f [PartitionInput]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest BatchCreatePartition where
type
AWSResponse BatchCreatePartition =
BatchCreatePartitionResponse
request :: BatchCreatePartition -> Request BatchCreatePartition
request = Service -> BatchCreatePartition -> Request BatchCreatePartition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchCreatePartition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchCreatePartition)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchCreatePartition))
-> Logger
-> Service
-> Proxy BatchCreatePartition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchCreatePartition)))
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 [PartitionError] -> Int -> BatchCreatePartitionResponse
BatchCreatePartitionResponse'
(Maybe [PartitionError] -> Int -> BatchCreatePartitionResponse)
-> Either String (Maybe [PartitionError])
-> Either String (Int -> BatchCreatePartitionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [PartitionError]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Errors" Either String (Maybe (Maybe [PartitionError]))
-> Maybe [PartitionError] -> Either String (Maybe [PartitionError])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PartitionError]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> BatchCreatePartitionResponse)
-> Either String Int -> Either String BatchCreatePartitionResponse
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 BatchCreatePartition
instance Prelude.NFData BatchCreatePartition
instance Core.ToHeaders BatchCreatePartition where
toHeaders :: BatchCreatePartition -> ResponseHeaders
toHeaders =
ResponseHeaders -> BatchCreatePartition -> 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.BatchCreatePartition" ::
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 BatchCreatePartition where
toJSON :: BatchCreatePartition -> Value
toJSON BatchCreatePartition' {[PartitionInput]
Maybe Text
Text
partitionInputList :: [PartitionInput]
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:partitionInputList:BatchCreatePartition' :: BatchCreatePartition -> [PartitionInput]
$sel:tableName:BatchCreatePartition' :: BatchCreatePartition -> Text
$sel:databaseName:BatchCreatePartition' :: BatchCreatePartition -> Text
$sel:catalogId:BatchCreatePartition' :: BatchCreatePartition -> 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
"PartitionInputList" Text -> [PartitionInput] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [PartitionInput]
partitionInputList)
]
)
instance Core.ToPath BatchCreatePartition where
toPath :: BatchCreatePartition -> ByteString
toPath = ByteString -> BatchCreatePartition -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery BatchCreatePartition where
toQuery :: BatchCreatePartition -> QueryString
toQuery = QueryString -> BatchCreatePartition -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchCreatePartitionResponse = BatchCreatePartitionResponse'
{
BatchCreatePartitionResponse -> Maybe [PartitionError]
errors :: Prelude.Maybe [PartitionError],
BatchCreatePartitionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool
(BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool)
-> (BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool)
-> Eq BatchCreatePartitionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool
$c/= :: BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool
== :: BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool
$c== :: BatchCreatePartitionResponse
-> BatchCreatePartitionResponse -> Bool
Prelude.Eq, ReadPrec [BatchCreatePartitionResponse]
ReadPrec BatchCreatePartitionResponse
Int -> ReadS BatchCreatePartitionResponse
ReadS [BatchCreatePartitionResponse]
(Int -> ReadS BatchCreatePartitionResponse)
-> ReadS [BatchCreatePartitionResponse]
-> ReadPrec BatchCreatePartitionResponse
-> ReadPrec [BatchCreatePartitionResponse]
-> Read BatchCreatePartitionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreatePartitionResponse]
$creadListPrec :: ReadPrec [BatchCreatePartitionResponse]
readPrec :: ReadPrec BatchCreatePartitionResponse
$creadPrec :: ReadPrec BatchCreatePartitionResponse
readList :: ReadS [BatchCreatePartitionResponse]
$creadList :: ReadS [BatchCreatePartitionResponse]
readsPrec :: Int -> ReadS BatchCreatePartitionResponse
$creadsPrec :: Int -> ReadS BatchCreatePartitionResponse
Prelude.Read, Int -> BatchCreatePartitionResponse -> ShowS
[BatchCreatePartitionResponse] -> ShowS
BatchCreatePartitionResponse -> String
(Int -> BatchCreatePartitionResponse -> ShowS)
-> (BatchCreatePartitionResponse -> String)
-> ([BatchCreatePartitionResponse] -> ShowS)
-> Show BatchCreatePartitionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreatePartitionResponse] -> ShowS
$cshowList :: [BatchCreatePartitionResponse] -> ShowS
show :: BatchCreatePartitionResponse -> String
$cshow :: BatchCreatePartitionResponse -> String
showsPrec :: Int -> BatchCreatePartitionResponse -> ShowS
$cshowsPrec :: Int -> BatchCreatePartitionResponse -> ShowS
Prelude.Show, (forall x.
BatchCreatePartitionResponse -> Rep BatchCreatePartitionResponse x)
-> (forall x.
Rep BatchCreatePartitionResponse x -> BatchCreatePartitionResponse)
-> Generic BatchCreatePartitionResponse
forall x.
Rep BatchCreatePartitionResponse x -> BatchCreatePartitionResponse
forall x.
BatchCreatePartitionResponse -> Rep BatchCreatePartitionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchCreatePartitionResponse x -> BatchCreatePartitionResponse
$cfrom :: forall x.
BatchCreatePartitionResponse -> Rep BatchCreatePartitionResponse x
Prelude.Generic)
newBatchCreatePartitionResponse ::
Prelude.Int ->
BatchCreatePartitionResponse
newBatchCreatePartitionResponse :: Int -> BatchCreatePartitionResponse
newBatchCreatePartitionResponse Int
pHttpStatus_ =
BatchCreatePartitionResponse' :: Maybe [PartitionError] -> Int -> BatchCreatePartitionResponse
BatchCreatePartitionResponse'
{ $sel:errors:BatchCreatePartitionResponse' :: Maybe [PartitionError]
errors =
Maybe [PartitionError]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchCreatePartitionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchCreatePartitionResponse_errors :: Lens.Lens' BatchCreatePartitionResponse (Prelude.Maybe [PartitionError])
batchCreatePartitionResponse_errors :: (Maybe [PartitionError] -> f (Maybe [PartitionError]))
-> BatchCreatePartitionResponse -> f BatchCreatePartitionResponse
batchCreatePartitionResponse_errors = (BatchCreatePartitionResponse -> Maybe [PartitionError])
-> (BatchCreatePartitionResponse
-> Maybe [PartitionError] -> BatchCreatePartitionResponse)
-> Lens
BatchCreatePartitionResponse
BatchCreatePartitionResponse
(Maybe [PartitionError])
(Maybe [PartitionError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreatePartitionResponse' {Maybe [PartitionError]
errors :: Maybe [PartitionError]
$sel:errors:BatchCreatePartitionResponse' :: BatchCreatePartitionResponse -> Maybe [PartitionError]
errors} -> Maybe [PartitionError]
errors) (\s :: BatchCreatePartitionResponse
s@BatchCreatePartitionResponse' {} Maybe [PartitionError]
a -> BatchCreatePartitionResponse
s {$sel:errors:BatchCreatePartitionResponse' :: Maybe [PartitionError]
errors = Maybe [PartitionError]
a} :: BatchCreatePartitionResponse) ((Maybe [PartitionError] -> f (Maybe [PartitionError]))
-> BatchCreatePartitionResponse -> f BatchCreatePartitionResponse)
-> ((Maybe [PartitionError] -> f (Maybe [PartitionError]))
-> Maybe [PartitionError] -> f (Maybe [PartitionError]))
-> (Maybe [PartitionError] -> f (Maybe [PartitionError]))
-> BatchCreatePartitionResponse
-> f BatchCreatePartitionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[PartitionError] [PartitionError] [PartitionError] [PartitionError]
-> Iso
(Maybe [PartitionError])
(Maybe [PartitionError])
(Maybe [PartitionError])
(Maybe [PartitionError])
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
[PartitionError] [PartitionError] [PartitionError] [PartitionError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchCreatePartitionResponse_httpStatus :: Lens.Lens' BatchCreatePartitionResponse Prelude.Int
batchCreatePartitionResponse_httpStatus :: (Int -> f Int)
-> BatchCreatePartitionResponse -> f BatchCreatePartitionResponse
batchCreatePartitionResponse_httpStatus = (BatchCreatePartitionResponse -> Int)
-> (BatchCreatePartitionResponse
-> Int -> BatchCreatePartitionResponse)
-> Lens
BatchCreatePartitionResponse BatchCreatePartitionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreatePartitionResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchCreatePartitionResponse' :: BatchCreatePartitionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchCreatePartitionResponse
s@BatchCreatePartitionResponse' {} Int
a -> BatchCreatePartitionResponse
s {$sel:httpStatus:BatchCreatePartitionResponse' :: Int
httpStatus = Int
a} :: BatchCreatePartitionResponse)
instance Prelude.NFData BatchCreatePartitionResponse