{-# 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.CodeCommit.BatchGetCommits
(
BatchGetCommits (..),
newBatchGetCommits,
batchGetCommits_commitIds,
batchGetCommits_repositoryName,
BatchGetCommitsResponse (..),
newBatchGetCommitsResponse,
batchGetCommitsResponse_commits,
batchGetCommitsResponse_errors,
batchGetCommitsResponse_httpStatus,
)
where
import Amazonka.CodeCommit.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 BatchGetCommits = BatchGetCommits'
{
BatchGetCommits -> [Text]
commitIds :: [Prelude.Text],
BatchGetCommits -> Text
repositoryName :: Prelude.Text
}
deriving (BatchGetCommits -> BatchGetCommits -> Bool
(BatchGetCommits -> BatchGetCommits -> Bool)
-> (BatchGetCommits -> BatchGetCommits -> Bool)
-> Eq BatchGetCommits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetCommits -> BatchGetCommits -> Bool
$c/= :: BatchGetCommits -> BatchGetCommits -> Bool
== :: BatchGetCommits -> BatchGetCommits -> Bool
$c== :: BatchGetCommits -> BatchGetCommits -> Bool
Prelude.Eq, ReadPrec [BatchGetCommits]
ReadPrec BatchGetCommits
Int -> ReadS BatchGetCommits
ReadS [BatchGetCommits]
(Int -> ReadS BatchGetCommits)
-> ReadS [BatchGetCommits]
-> ReadPrec BatchGetCommits
-> ReadPrec [BatchGetCommits]
-> Read BatchGetCommits
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetCommits]
$creadListPrec :: ReadPrec [BatchGetCommits]
readPrec :: ReadPrec BatchGetCommits
$creadPrec :: ReadPrec BatchGetCommits
readList :: ReadS [BatchGetCommits]
$creadList :: ReadS [BatchGetCommits]
readsPrec :: Int -> ReadS BatchGetCommits
$creadsPrec :: Int -> ReadS BatchGetCommits
Prelude.Read, Int -> BatchGetCommits -> ShowS
[BatchGetCommits] -> ShowS
BatchGetCommits -> String
(Int -> BatchGetCommits -> ShowS)
-> (BatchGetCommits -> String)
-> ([BatchGetCommits] -> ShowS)
-> Show BatchGetCommits
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetCommits] -> ShowS
$cshowList :: [BatchGetCommits] -> ShowS
show :: BatchGetCommits -> String
$cshow :: BatchGetCommits -> String
showsPrec :: Int -> BatchGetCommits -> ShowS
$cshowsPrec :: Int -> BatchGetCommits -> ShowS
Prelude.Show, (forall x. BatchGetCommits -> Rep BatchGetCommits x)
-> (forall x. Rep BatchGetCommits x -> BatchGetCommits)
-> Generic BatchGetCommits
forall x. Rep BatchGetCommits x -> BatchGetCommits
forall x. BatchGetCommits -> Rep BatchGetCommits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetCommits x -> BatchGetCommits
$cfrom :: forall x. BatchGetCommits -> Rep BatchGetCommits x
Prelude.Generic)
newBatchGetCommits ::
Prelude.Text ->
BatchGetCommits
newBatchGetCommits :: Text -> BatchGetCommits
newBatchGetCommits Text
pRepositoryName_ =
BatchGetCommits' :: [Text] -> Text -> BatchGetCommits
BatchGetCommits'
{ $sel:commitIds:BatchGetCommits' :: [Text]
commitIds = [Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:repositoryName:BatchGetCommits' :: Text
repositoryName = Text
pRepositoryName_
}
batchGetCommits_commitIds :: Lens.Lens' BatchGetCommits [Prelude.Text]
batchGetCommits_commitIds :: ([Text] -> f [Text]) -> BatchGetCommits -> f BatchGetCommits
batchGetCommits_commitIds = (BatchGetCommits -> [Text])
-> (BatchGetCommits -> [Text] -> BatchGetCommits)
-> Lens BatchGetCommits BatchGetCommits [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCommits' {[Text]
commitIds :: [Text]
$sel:commitIds:BatchGetCommits' :: BatchGetCommits -> [Text]
commitIds} -> [Text]
commitIds) (\s :: BatchGetCommits
s@BatchGetCommits' {} [Text]
a -> BatchGetCommits
s {$sel:commitIds:BatchGetCommits' :: [Text]
commitIds = [Text]
a} :: BatchGetCommits) (([Text] -> f [Text]) -> BatchGetCommits -> f BatchGetCommits)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> BatchGetCommits
-> f BatchGetCommits
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchGetCommits_repositoryName :: Lens.Lens' BatchGetCommits Prelude.Text
batchGetCommits_repositoryName :: (Text -> f Text) -> BatchGetCommits -> f BatchGetCommits
batchGetCommits_repositoryName = (BatchGetCommits -> Text)
-> (BatchGetCommits -> Text -> BatchGetCommits)
-> Lens BatchGetCommits BatchGetCommits Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCommits' {Text
repositoryName :: Text
$sel:repositoryName:BatchGetCommits' :: BatchGetCommits -> Text
repositoryName} -> Text
repositoryName) (\s :: BatchGetCommits
s@BatchGetCommits' {} Text
a -> BatchGetCommits
s {$sel:repositoryName:BatchGetCommits' :: Text
repositoryName = Text
a} :: BatchGetCommits)
instance Core.AWSRequest BatchGetCommits where
type
AWSResponse BatchGetCommits =
BatchGetCommitsResponse
request :: BatchGetCommits -> Request BatchGetCommits
request = Service -> BatchGetCommits -> Request BatchGetCommits
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchGetCommits
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetCommits)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchGetCommits))
-> Logger
-> Service
-> Proxy BatchGetCommits
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetCommits)))
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 [Commit]
-> Maybe [BatchGetCommitsError] -> Int -> BatchGetCommitsResponse
BatchGetCommitsResponse'
(Maybe [Commit]
-> Maybe [BatchGetCommitsError] -> Int -> BatchGetCommitsResponse)
-> Either String (Maybe [Commit])
-> Either
String
(Maybe [BatchGetCommitsError] -> Int -> BatchGetCommitsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Commit]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"commits" Either String (Maybe (Maybe [Commit]))
-> Maybe [Commit] -> Either String (Maybe [Commit])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Commit]
forall a. Monoid a => a
Prelude.mempty)
Either
String
(Maybe [BatchGetCommitsError] -> Int -> BatchGetCommitsResponse)
-> Either String (Maybe [BatchGetCommitsError])
-> Either String (Int -> BatchGetCommitsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (Maybe [BatchGetCommitsError]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"errors" Either String (Maybe (Maybe [BatchGetCommitsError]))
-> Maybe [BatchGetCommitsError]
-> Either String (Maybe [BatchGetCommitsError])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BatchGetCommitsError]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> BatchGetCommitsResponse)
-> Either String Int -> Either String BatchGetCommitsResponse
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 BatchGetCommits
instance Prelude.NFData BatchGetCommits
instance Core.ToHeaders BatchGetCommits where
toHeaders :: BatchGetCommits -> ResponseHeaders
toHeaders =
ResponseHeaders -> BatchGetCommits -> 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
"CodeCommit_20150413.BatchGetCommits" ::
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 BatchGetCommits where
toJSON :: BatchGetCommits -> Value
toJSON BatchGetCommits' {[Text]
Text
repositoryName :: Text
commitIds :: [Text]
$sel:repositoryName:BatchGetCommits' :: BatchGetCommits -> Text
$sel:commitIds:BatchGetCommits' :: BatchGetCommits -> [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
"commitIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
commitIds),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName)
]
)
instance Core.ToPath BatchGetCommits where
toPath :: BatchGetCommits -> ByteString
toPath = ByteString -> BatchGetCommits -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery BatchGetCommits where
toQuery :: BatchGetCommits -> QueryString
toQuery = QueryString -> BatchGetCommits -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchGetCommitsResponse = BatchGetCommitsResponse'
{
BatchGetCommitsResponse -> Maybe [Commit]
commits :: Prelude.Maybe [Commit],
BatchGetCommitsResponse -> Maybe [BatchGetCommitsError]
errors :: Prelude.Maybe [BatchGetCommitsError],
BatchGetCommitsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool
(BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool)
-> (BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool)
-> Eq BatchGetCommitsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool
$c/= :: BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool
== :: BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool
$c== :: BatchGetCommitsResponse -> BatchGetCommitsResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetCommitsResponse]
ReadPrec BatchGetCommitsResponse
Int -> ReadS BatchGetCommitsResponse
ReadS [BatchGetCommitsResponse]
(Int -> ReadS BatchGetCommitsResponse)
-> ReadS [BatchGetCommitsResponse]
-> ReadPrec BatchGetCommitsResponse
-> ReadPrec [BatchGetCommitsResponse]
-> Read BatchGetCommitsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetCommitsResponse]
$creadListPrec :: ReadPrec [BatchGetCommitsResponse]
readPrec :: ReadPrec BatchGetCommitsResponse
$creadPrec :: ReadPrec BatchGetCommitsResponse
readList :: ReadS [BatchGetCommitsResponse]
$creadList :: ReadS [BatchGetCommitsResponse]
readsPrec :: Int -> ReadS BatchGetCommitsResponse
$creadsPrec :: Int -> ReadS BatchGetCommitsResponse
Prelude.Read, Int -> BatchGetCommitsResponse -> ShowS
[BatchGetCommitsResponse] -> ShowS
BatchGetCommitsResponse -> String
(Int -> BatchGetCommitsResponse -> ShowS)
-> (BatchGetCommitsResponse -> String)
-> ([BatchGetCommitsResponse] -> ShowS)
-> Show BatchGetCommitsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetCommitsResponse] -> ShowS
$cshowList :: [BatchGetCommitsResponse] -> ShowS
show :: BatchGetCommitsResponse -> String
$cshow :: BatchGetCommitsResponse -> String
showsPrec :: Int -> BatchGetCommitsResponse -> ShowS
$cshowsPrec :: Int -> BatchGetCommitsResponse -> ShowS
Prelude.Show, (forall x.
BatchGetCommitsResponse -> Rep BatchGetCommitsResponse x)
-> (forall x.
Rep BatchGetCommitsResponse x -> BatchGetCommitsResponse)
-> Generic BatchGetCommitsResponse
forall x. Rep BatchGetCommitsResponse x -> BatchGetCommitsResponse
forall x. BatchGetCommitsResponse -> Rep BatchGetCommitsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetCommitsResponse x -> BatchGetCommitsResponse
$cfrom :: forall x. BatchGetCommitsResponse -> Rep BatchGetCommitsResponse x
Prelude.Generic)
newBatchGetCommitsResponse ::
Prelude.Int ->
BatchGetCommitsResponse
newBatchGetCommitsResponse :: Int -> BatchGetCommitsResponse
newBatchGetCommitsResponse Int
pHttpStatus_ =
BatchGetCommitsResponse' :: Maybe [Commit]
-> Maybe [BatchGetCommitsError] -> Int -> BatchGetCommitsResponse
BatchGetCommitsResponse'
{ $sel:commits:BatchGetCommitsResponse' :: Maybe [Commit]
commits = Maybe [Commit]
forall a. Maybe a
Prelude.Nothing,
$sel:errors:BatchGetCommitsResponse' :: Maybe [BatchGetCommitsError]
errors = Maybe [BatchGetCommitsError]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchGetCommitsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchGetCommitsResponse_commits :: Lens.Lens' BatchGetCommitsResponse (Prelude.Maybe [Commit])
batchGetCommitsResponse_commits :: (Maybe [Commit] -> f (Maybe [Commit]))
-> BatchGetCommitsResponse -> f BatchGetCommitsResponse
batchGetCommitsResponse_commits = (BatchGetCommitsResponse -> Maybe [Commit])
-> (BatchGetCommitsResponse
-> Maybe [Commit] -> BatchGetCommitsResponse)
-> Lens
BatchGetCommitsResponse
BatchGetCommitsResponse
(Maybe [Commit])
(Maybe [Commit])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCommitsResponse' {Maybe [Commit]
commits :: Maybe [Commit]
$sel:commits:BatchGetCommitsResponse' :: BatchGetCommitsResponse -> Maybe [Commit]
commits} -> Maybe [Commit]
commits) (\s :: BatchGetCommitsResponse
s@BatchGetCommitsResponse' {} Maybe [Commit]
a -> BatchGetCommitsResponse
s {$sel:commits:BatchGetCommitsResponse' :: Maybe [Commit]
commits = Maybe [Commit]
a} :: BatchGetCommitsResponse) ((Maybe [Commit] -> f (Maybe [Commit]))
-> BatchGetCommitsResponse -> f BatchGetCommitsResponse)
-> ((Maybe [Commit] -> f (Maybe [Commit]))
-> Maybe [Commit] -> f (Maybe [Commit]))
-> (Maybe [Commit] -> f (Maybe [Commit]))
-> BatchGetCommitsResponse
-> f BatchGetCommitsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Commit] [Commit] [Commit] [Commit]
-> Iso
(Maybe [Commit]) (Maybe [Commit]) (Maybe [Commit]) (Maybe [Commit])
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 [Commit] [Commit] [Commit] [Commit]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchGetCommitsResponse_errors :: Lens.Lens' BatchGetCommitsResponse (Prelude.Maybe [BatchGetCommitsError])
batchGetCommitsResponse_errors :: (Maybe [BatchGetCommitsError] -> f (Maybe [BatchGetCommitsError]))
-> BatchGetCommitsResponse -> f BatchGetCommitsResponse
batchGetCommitsResponse_errors = (BatchGetCommitsResponse -> Maybe [BatchGetCommitsError])
-> (BatchGetCommitsResponse
-> Maybe [BatchGetCommitsError] -> BatchGetCommitsResponse)
-> Lens
BatchGetCommitsResponse
BatchGetCommitsResponse
(Maybe [BatchGetCommitsError])
(Maybe [BatchGetCommitsError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCommitsResponse' {Maybe [BatchGetCommitsError]
errors :: Maybe [BatchGetCommitsError]
$sel:errors:BatchGetCommitsResponse' :: BatchGetCommitsResponse -> Maybe [BatchGetCommitsError]
errors} -> Maybe [BatchGetCommitsError]
errors) (\s :: BatchGetCommitsResponse
s@BatchGetCommitsResponse' {} Maybe [BatchGetCommitsError]
a -> BatchGetCommitsResponse
s {$sel:errors:BatchGetCommitsResponse' :: Maybe [BatchGetCommitsError]
errors = Maybe [BatchGetCommitsError]
a} :: BatchGetCommitsResponse) ((Maybe [BatchGetCommitsError] -> f (Maybe [BatchGetCommitsError]))
-> BatchGetCommitsResponse -> f BatchGetCommitsResponse)
-> ((Maybe [BatchGetCommitsError]
-> f (Maybe [BatchGetCommitsError]))
-> Maybe [BatchGetCommitsError]
-> f (Maybe [BatchGetCommitsError]))
-> (Maybe [BatchGetCommitsError]
-> f (Maybe [BatchGetCommitsError]))
-> BatchGetCommitsResponse
-> f BatchGetCommitsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[BatchGetCommitsError]
[BatchGetCommitsError]
[BatchGetCommitsError]
[BatchGetCommitsError]
-> Iso
(Maybe [BatchGetCommitsError])
(Maybe [BatchGetCommitsError])
(Maybe [BatchGetCommitsError])
(Maybe [BatchGetCommitsError])
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
[BatchGetCommitsError]
[BatchGetCommitsError]
[BatchGetCommitsError]
[BatchGetCommitsError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchGetCommitsResponse_httpStatus :: Lens.Lens' BatchGetCommitsResponse Prelude.Int
batchGetCommitsResponse_httpStatus :: (Int -> f Int)
-> BatchGetCommitsResponse -> f BatchGetCommitsResponse
batchGetCommitsResponse_httpStatus = (BatchGetCommitsResponse -> Int)
-> (BatchGetCommitsResponse -> Int -> BatchGetCommitsResponse)
-> Lens BatchGetCommitsResponse BatchGetCommitsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetCommitsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetCommitsResponse' :: BatchGetCommitsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetCommitsResponse
s@BatchGetCommitsResponse' {} Int
a -> BatchGetCommitsResponse
s {$sel:httpStatus:BatchGetCommitsResponse' :: Int
httpStatus = Int
a} :: BatchGetCommitsResponse)
instance Prelude.NFData BatchGetCommitsResponse