{-# 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.GetBranch
(
GetBranch (..),
newGetBranch,
getBranch_branchName,
getBranch_repositoryName,
GetBranchResponse (..),
newGetBranchResponse,
getBranchResponse_branch,
getBranchResponse_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 GetBranch = GetBranch'
{
GetBranch -> Maybe Text
branchName :: Prelude.Maybe Prelude.Text,
GetBranch -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text
}
deriving (GetBranch -> GetBranch -> Bool
(GetBranch -> GetBranch -> Bool)
-> (GetBranch -> GetBranch -> Bool) -> Eq GetBranch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBranch -> GetBranch -> Bool
$c/= :: GetBranch -> GetBranch -> Bool
== :: GetBranch -> GetBranch -> Bool
$c== :: GetBranch -> GetBranch -> Bool
Prelude.Eq, ReadPrec [GetBranch]
ReadPrec GetBranch
Int -> ReadS GetBranch
ReadS [GetBranch]
(Int -> ReadS GetBranch)
-> ReadS [GetBranch]
-> ReadPrec GetBranch
-> ReadPrec [GetBranch]
-> Read GetBranch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBranch]
$creadListPrec :: ReadPrec [GetBranch]
readPrec :: ReadPrec GetBranch
$creadPrec :: ReadPrec GetBranch
readList :: ReadS [GetBranch]
$creadList :: ReadS [GetBranch]
readsPrec :: Int -> ReadS GetBranch
$creadsPrec :: Int -> ReadS GetBranch
Prelude.Read, Int -> GetBranch -> ShowS
[GetBranch] -> ShowS
GetBranch -> String
(Int -> GetBranch -> ShowS)
-> (GetBranch -> String)
-> ([GetBranch] -> ShowS)
-> Show GetBranch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBranch] -> ShowS
$cshowList :: [GetBranch] -> ShowS
show :: GetBranch -> String
$cshow :: GetBranch -> String
showsPrec :: Int -> GetBranch -> ShowS
$cshowsPrec :: Int -> GetBranch -> ShowS
Prelude.Show, (forall x. GetBranch -> Rep GetBranch x)
-> (forall x. Rep GetBranch x -> GetBranch) -> Generic GetBranch
forall x. Rep GetBranch x -> GetBranch
forall x. GetBranch -> Rep GetBranch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBranch x -> GetBranch
$cfrom :: forall x. GetBranch -> Rep GetBranch x
Prelude.Generic)
newGetBranch ::
GetBranch
newGetBranch :: GetBranch
newGetBranch =
GetBranch' :: Maybe Text -> Maybe Text -> GetBranch
GetBranch'
{ $sel:branchName:GetBranch' :: Maybe Text
branchName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:repositoryName:GetBranch' :: Maybe Text
repositoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
getBranch_branchName :: Lens.Lens' GetBranch (Prelude.Maybe Prelude.Text)
getBranch_branchName :: (Maybe Text -> f (Maybe Text)) -> GetBranch -> f GetBranch
getBranch_branchName = (GetBranch -> Maybe Text)
-> (GetBranch -> Maybe Text -> GetBranch)
-> Lens GetBranch GetBranch (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBranch' {Maybe Text
branchName :: Maybe Text
$sel:branchName:GetBranch' :: GetBranch -> Maybe Text
branchName} -> Maybe Text
branchName) (\s :: GetBranch
s@GetBranch' {} Maybe Text
a -> GetBranch
s {$sel:branchName:GetBranch' :: Maybe Text
branchName = Maybe Text
a} :: GetBranch)
getBranch_repositoryName :: Lens.Lens' GetBranch (Prelude.Maybe Prelude.Text)
getBranch_repositoryName :: (Maybe Text -> f (Maybe Text)) -> GetBranch -> f GetBranch
getBranch_repositoryName = (GetBranch -> Maybe Text)
-> (GetBranch -> Maybe Text -> GetBranch)
-> Lens GetBranch GetBranch (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBranch' {Maybe Text
repositoryName :: Maybe Text
$sel:repositoryName:GetBranch' :: GetBranch -> Maybe Text
repositoryName} -> Maybe Text
repositoryName) (\s :: GetBranch
s@GetBranch' {} Maybe Text
a -> GetBranch
s {$sel:repositoryName:GetBranch' :: Maybe Text
repositoryName = Maybe Text
a} :: GetBranch)
instance Core.AWSRequest GetBranch where
type AWSResponse GetBranch = GetBranchResponse
request :: GetBranch -> Request GetBranch
request = Service -> GetBranch -> Request GetBranch
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetBranch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBranch)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetBranch))
-> Logger
-> Service
-> Proxy GetBranch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBranch)))
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 BranchInfo -> Int -> GetBranchResponse
GetBranchResponse'
(Maybe BranchInfo -> Int -> GetBranchResponse)
-> Either String (Maybe BranchInfo)
-> Either String (Int -> GetBranchResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe BranchInfo)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"branch")
Either String (Int -> GetBranchResponse)
-> Either String Int -> Either String GetBranchResponse
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 GetBranch
instance Prelude.NFData GetBranch
instance Core.ToHeaders GetBranch where
toHeaders :: GetBranch -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetBranch -> 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.GetBranch" ::
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 GetBranch where
toJSON :: GetBranch -> Value
toJSON GetBranch' {Maybe Text
repositoryName :: Maybe Text
branchName :: Maybe Text
$sel:repositoryName:GetBranch' :: GetBranch -> Maybe Text
$sel:branchName:GetBranch' :: GetBranch -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"branchName" 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
branchName,
(Text
"repositoryName" 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
repositoryName
]
)
instance Core.ToPath GetBranch where
toPath :: GetBranch -> ByteString
toPath = ByteString -> GetBranch -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetBranch where
toQuery :: GetBranch -> QueryString
toQuery = QueryString -> GetBranch -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetBranchResponse = GetBranchResponse'
{
GetBranchResponse -> Maybe BranchInfo
branch :: Prelude.Maybe BranchInfo,
GetBranchResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetBranchResponse -> GetBranchResponse -> Bool
(GetBranchResponse -> GetBranchResponse -> Bool)
-> (GetBranchResponse -> GetBranchResponse -> Bool)
-> Eq GetBranchResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBranchResponse -> GetBranchResponse -> Bool
$c/= :: GetBranchResponse -> GetBranchResponse -> Bool
== :: GetBranchResponse -> GetBranchResponse -> Bool
$c== :: GetBranchResponse -> GetBranchResponse -> Bool
Prelude.Eq, ReadPrec [GetBranchResponse]
ReadPrec GetBranchResponse
Int -> ReadS GetBranchResponse
ReadS [GetBranchResponse]
(Int -> ReadS GetBranchResponse)
-> ReadS [GetBranchResponse]
-> ReadPrec GetBranchResponse
-> ReadPrec [GetBranchResponse]
-> Read GetBranchResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBranchResponse]
$creadListPrec :: ReadPrec [GetBranchResponse]
readPrec :: ReadPrec GetBranchResponse
$creadPrec :: ReadPrec GetBranchResponse
readList :: ReadS [GetBranchResponse]
$creadList :: ReadS [GetBranchResponse]
readsPrec :: Int -> ReadS GetBranchResponse
$creadsPrec :: Int -> ReadS GetBranchResponse
Prelude.Read, Int -> GetBranchResponse -> ShowS
[GetBranchResponse] -> ShowS
GetBranchResponse -> String
(Int -> GetBranchResponse -> ShowS)
-> (GetBranchResponse -> String)
-> ([GetBranchResponse] -> ShowS)
-> Show GetBranchResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBranchResponse] -> ShowS
$cshowList :: [GetBranchResponse] -> ShowS
show :: GetBranchResponse -> String
$cshow :: GetBranchResponse -> String
showsPrec :: Int -> GetBranchResponse -> ShowS
$cshowsPrec :: Int -> GetBranchResponse -> ShowS
Prelude.Show, (forall x. GetBranchResponse -> Rep GetBranchResponse x)
-> (forall x. Rep GetBranchResponse x -> GetBranchResponse)
-> Generic GetBranchResponse
forall x. Rep GetBranchResponse x -> GetBranchResponse
forall x. GetBranchResponse -> Rep GetBranchResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBranchResponse x -> GetBranchResponse
$cfrom :: forall x. GetBranchResponse -> Rep GetBranchResponse x
Prelude.Generic)
newGetBranchResponse ::
Prelude.Int ->
GetBranchResponse
newGetBranchResponse :: Int -> GetBranchResponse
newGetBranchResponse Int
pHttpStatus_ =
GetBranchResponse' :: Maybe BranchInfo -> Int -> GetBranchResponse
GetBranchResponse'
{ $sel:branch:GetBranchResponse' :: Maybe BranchInfo
branch = Maybe BranchInfo
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetBranchResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getBranchResponse_branch :: Lens.Lens' GetBranchResponse (Prelude.Maybe BranchInfo)
getBranchResponse_branch :: (Maybe BranchInfo -> f (Maybe BranchInfo))
-> GetBranchResponse -> f GetBranchResponse
getBranchResponse_branch = (GetBranchResponse -> Maybe BranchInfo)
-> (GetBranchResponse -> Maybe BranchInfo -> GetBranchResponse)
-> Lens
GetBranchResponse
GetBranchResponse
(Maybe BranchInfo)
(Maybe BranchInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBranchResponse' {Maybe BranchInfo
branch :: Maybe BranchInfo
$sel:branch:GetBranchResponse' :: GetBranchResponse -> Maybe BranchInfo
branch} -> Maybe BranchInfo
branch) (\s :: GetBranchResponse
s@GetBranchResponse' {} Maybe BranchInfo
a -> GetBranchResponse
s {$sel:branch:GetBranchResponse' :: Maybe BranchInfo
branch = Maybe BranchInfo
a} :: GetBranchResponse)
getBranchResponse_httpStatus :: Lens.Lens' GetBranchResponse Prelude.Int
getBranchResponse_httpStatus :: (Int -> f Int) -> GetBranchResponse -> f GetBranchResponse
getBranchResponse_httpStatus = (GetBranchResponse -> Int)
-> (GetBranchResponse -> Int -> GetBranchResponse)
-> Lens GetBranchResponse GetBranchResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBranchResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetBranchResponse' :: GetBranchResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetBranchResponse
s@GetBranchResponse' {} Int
a -> GetBranchResponse
s {$sel:httpStatus:GetBranchResponse' :: Int
httpStatus = Int
a} :: GetBranchResponse)
instance Prelude.NFData GetBranchResponse