{-# 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.CodeGuruReviewer.CreateCodeReview
(
CreateCodeReview (..),
newCreateCodeReview,
createCodeReview_clientRequestToken,
createCodeReview_name,
createCodeReview_repositoryAssociationArn,
createCodeReview_type,
CreateCodeReviewResponse (..),
newCreateCodeReviewResponse,
createCodeReviewResponse_codeReview,
createCodeReviewResponse_httpStatus,
)
where
import Amazonka.CodeGuruReviewer.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 CreateCodeReview = CreateCodeReview'
{
CreateCodeReview -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
CreateCodeReview -> Text
name :: Prelude.Text,
CreateCodeReview -> Text
repositoryAssociationArn :: Prelude.Text,
CreateCodeReview -> CodeReviewType
type' :: CodeReviewType
}
deriving (CreateCodeReview -> CreateCodeReview -> Bool
(CreateCodeReview -> CreateCodeReview -> Bool)
-> (CreateCodeReview -> CreateCodeReview -> Bool)
-> Eq CreateCodeReview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCodeReview -> CreateCodeReview -> Bool
$c/= :: CreateCodeReview -> CreateCodeReview -> Bool
== :: CreateCodeReview -> CreateCodeReview -> Bool
$c== :: CreateCodeReview -> CreateCodeReview -> Bool
Prelude.Eq, ReadPrec [CreateCodeReview]
ReadPrec CreateCodeReview
Int -> ReadS CreateCodeReview
ReadS [CreateCodeReview]
(Int -> ReadS CreateCodeReview)
-> ReadS [CreateCodeReview]
-> ReadPrec CreateCodeReview
-> ReadPrec [CreateCodeReview]
-> Read CreateCodeReview
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCodeReview]
$creadListPrec :: ReadPrec [CreateCodeReview]
readPrec :: ReadPrec CreateCodeReview
$creadPrec :: ReadPrec CreateCodeReview
readList :: ReadS [CreateCodeReview]
$creadList :: ReadS [CreateCodeReview]
readsPrec :: Int -> ReadS CreateCodeReview
$creadsPrec :: Int -> ReadS CreateCodeReview
Prelude.Read, Int -> CreateCodeReview -> ShowS
[CreateCodeReview] -> ShowS
CreateCodeReview -> String
(Int -> CreateCodeReview -> ShowS)
-> (CreateCodeReview -> String)
-> ([CreateCodeReview] -> ShowS)
-> Show CreateCodeReview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCodeReview] -> ShowS
$cshowList :: [CreateCodeReview] -> ShowS
show :: CreateCodeReview -> String
$cshow :: CreateCodeReview -> String
showsPrec :: Int -> CreateCodeReview -> ShowS
$cshowsPrec :: Int -> CreateCodeReview -> ShowS
Prelude.Show, (forall x. CreateCodeReview -> Rep CreateCodeReview x)
-> (forall x. Rep CreateCodeReview x -> CreateCodeReview)
-> Generic CreateCodeReview
forall x. Rep CreateCodeReview x -> CreateCodeReview
forall x. CreateCodeReview -> Rep CreateCodeReview x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCodeReview x -> CreateCodeReview
$cfrom :: forall x. CreateCodeReview -> Rep CreateCodeReview x
Prelude.Generic)
newCreateCodeReview ::
Prelude.Text ->
Prelude.Text ->
CodeReviewType ->
CreateCodeReview
newCreateCodeReview :: Text -> Text -> CodeReviewType -> CreateCodeReview
newCreateCodeReview
Text
pName_
Text
pRepositoryAssociationArn_
CodeReviewType
pType_ =
CreateCodeReview' :: Maybe Text -> Text -> Text -> CodeReviewType -> CreateCodeReview
CreateCodeReview'
{ $sel:clientRequestToken:CreateCodeReview' :: Maybe Text
clientRequestToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateCodeReview' :: Text
name = Text
pName_,
$sel:repositoryAssociationArn:CreateCodeReview' :: Text
repositoryAssociationArn =
Text
pRepositoryAssociationArn_,
$sel:type':CreateCodeReview' :: CodeReviewType
type' = CodeReviewType
pType_
}
createCodeReview_clientRequestToken :: Lens.Lens' CreateCodeReview (Prelude.Maybe Prelude.Text)
createCodeReview_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> CreateCodeReview -> f CreateCodeReview
createCodeReview_clientRequestToken = (CreateCodeReview -> Maybe Text)
-> (CreateCodeReview -> Maybe Text -> CreateCodeReview)
-> Lens CreateCodeReview CreateCodeReview (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeReview' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:CreateCodeReview' :: CreateCodeReview -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: CreateCodeReview
s@CreateCodeReview' {} Maybe Text
a -> CreateCodeReview
s {$sel:clientRequestToken:CreateCodeReview' :: Maybe Text
clientRequestToken = Maybe Text
a} :: CreateCodeReview)
createCodeReview_name :: Lens.Lens' CreateCodeReview Prelude.Text
createCodeReview_name :: (Text -> f Text) -> CreateCodeReview -> f CreateCodeReview
createCodeReview_name = (CreateCodeReview -> Text)
-> (CreateCodeReview -> Text -> CreateCodeReview)
-> Lens CreateCodeReview CreateCodeReview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeReview' {Text
name :: Text
$sel:name:CreateCodeReview' :: CreateCodeReview -> Text
name} -> Text
name) (\s :: CreateCodeReview
s@CreateCodeReview' {} Text
a -> CreateCodeReview
s {$sel:name:CreateCodeReview' :: Text
name = Text
a} :: CreateCodeReview)
createCodeReview_repositoryAssociationArn :: Lens.Lens' CreateCodeReview Prelude.Text
createCodeReview_repositoryAssociationArn :: (Text -> f Text) -> CreateCodeReview -> f CreateCodeReview
createCodeReview_repositoryAssociationArn = (CreateCodeReview -> Text)
-> (CreateCodeReview -> Text -> CreateCodeReview)
-> Lens CreateCodeReview CreateCodeReview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeReview' {Text
repositoryAssociationArn :: Text
$sel:repositoryAssociationArn:CreateCodeReview' :: CreateCodeReview -> Text
repositoryAssociationArn} -> Text
repositoryAssociationArn) (\s :: CreateCodeReview
s@CreateCodeReview' {} Text
a -> CreateCodeReview
s {$sel:repositoryAssociationArn:CreateCodeReview' :: Text
repositoryAssociationArn = Text
a} :: CreateCodeReview)
createCodeReview_type :: Lens.Lens' CreateCodeReview CodeReviewType
createCodeReview_type :: (CodeReviewType -> f CodeReviewType)
-> CreateCodeReview -> f CreateCodeReview
createCodeReview_type = (CreateCodeReview -> CodeReviewType)
-> (CreateCodeReview -> CodeReviewType -> CreateCodeReview)
-> Lens
CreateCodeReview CreateCodeReview CodeReviewType CodeReviewType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeReview' {CodeReviewType
type' :: CodeReviewType
$sel:type':CreateCodeReview' :: CreateCodeReview -> CodeReviewType
type'} -> CodeReviewType
type') (\s :: CreateCodeReview
s@CreateCodeReview' {} CodeReviewType
a -> CreateCodeReview
s {$sel:type':CreateCodeReview' :: CodeReviewType
type' = CodeReviewType
a} :: CreateCodeReview)
instance Core.AWSRequest CreateCodeReview where
type
AWSResponse CreateCodeReview =
CreateCodeReviewResponse
request :: CreateCodeReview -> Request CreateCodeReview
request = Service -> CreateCodeReview -> Request CreateCodeReview
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateCodeReview
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCodeReview)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateCodeReview))
-> Logger
-> Service
-> Proxy CreateCodeReview
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCodeReview)))
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 CodeReview -> Int -> CreateCodeReviewResponse
CreateCodeReviewResponse'
(Maybe CodeReview -> Int -> CreateCodeReviewResponse)
-> Either String (Maybe CodeReview)
-> Either String (Int -> CreateCodeReviewResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CodeReview)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CodeReview")
Either String (Int -> CreateCodeReviewResponse)
-> Either String Int -> Either String CreateCodeReviewResponse
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 CreateCodeReview
instance Prelude.NFData CreateCodeReview
instance Core.ToHeaders CreateCodeReview where
toHeaders :: CreateCodeReview -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateCodeReview -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 CreateCodeReview where
toJSON :: CreateCodeReview -> Value
toJSON CreateCodeReview' {Maybe Text
Text
CodeReviewType
type' :: CodeReviewType
repositoryAssociationArn :: Text
name :: Text
clientRequestToken :: Maybe Text
$sel:type':CreateCodeReview' :: CreateCodeReview -> CodeReviewType
$sel:repositoryAssociationArn:CreateCodeReview' :: CreateCodeReview -> Text
$sel:name:CreateCodeReview' :: CreateCodeReview -> Text
$sel:clientRequestToken:CreateCodeReview' :: CreateCodeReview -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ClientRequestToken" 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
clientRequestToken,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"RepositoryAssociationArn"
Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryAssociationArn
),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> CodeReviewType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CodeReviewType
type')
]
)
instance Core.ToPath CreateCodeReview where
toPath :: CreateCodeReview -> ByteString
toPath = ByteString -> CreateCodeReview -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/codereviews"
instance Core.ToQuery CreateCodeReview where
toQuery :: CreateCodeReview -> QueryString
toQuery = QueryString -> CreateCodeReview -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateCodeReviewResponse = CreateCodeReviewResponse'
{ CreateCodeReviewResponse -> Maybe CodeReview
codeReview :: Prelude.Maybe CodeReview,
CreateCodeReviewResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool
(CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool)
-> (CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool)
-> Eq CreateCodeReviewResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool
$c/= :: CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool
== :: CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool
$c== :: CreateCodeReviewResponse -> CreateCodeReviewResponse -> Bool
Prelude.Eq, ReadPrec [CreateCodeReviewResponse]
ReadPrec CreateCodeReviewResponse
Int -> ReadS CreateCodeReviewResponse
ReadS [CreateCodeReviewResponse]
(Int -> ReadS CreateCodeReviewResponse)
-> ReadS [CreateCodeReviewResponse]
-> ReadPrec CreateCodeReviewResponse
-> ReadPrec [CreateCodeReviewResponse]
-> Read CreateCodeReviewResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCodeReviewResponse]
$creadListPrec :: ReadPrec [CreateCodeReviewResponse]
readPrec :: ReadPrec CreateCodeReviewResponse
$creadPrec :: ReadPrec CreateCodeReviewResponse
readList :: ReadS [CreateCodeReviewResponse]
$creadList :: ReadS [CreateCodeReviewResponse]
readsPrec :: Int -> ReadS CreateCodeReviewResponse
$creadsPrec :: Int -> ReadS CreateCodeReviewResponse
Prelude.Read, Int -> CreateCodeReviewResponse -> ShowS
[CreateCodeReviewResponse] -> ShowS
CreateCodeReviewResponse -> String
(Int -> CreateCodeReviewResponse -> ShowS)
-> (CreateCodeReviewResponse -> String)
-> ([CreateCodeReviewResponse] -> ShowS)
-> Show CreateCodeReviewResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCodeReviewResponse] -> ShowS
$cshowList :: [CreateCodeReviewResponse] -> ShowS
show :: CreateCodeReviewResponse -> String
$cshow :: CreateCodeReviewResponse -> String
showsPrec :: Int -> CreateCodeReviewResponse -> ShowS
$cshowsPrec :: Int -> CreateCodeReviewResponse -> ShowS
Prelude.Show, (forall x.
CreateCodeReviewResponse -> Rep CreateCodeReviewResponse x)
-> (forall x.
Rep CreateCodeReviewResponse x -> CreateCodeReviewResponse)
-> Generic CreateCodeReviewResponse
forall x.
Rep CreateCodeReviewResponse x -> CreateCodeReviewResponse
forall x.
CreateCodeReviewResponse -> Rep CreateCodeReviewResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateCodeReviewResponse x -> CreateCodeReviewResponse
$cfrom :: forall x.
CreateCodeReviewResponse -> Rep CreateCodeReviewResponse x
Prelude.Generic)
newCreateCodeReviewResponse ::
Prelude.Int ->
CreateCodeReviewResponse
newCreateCodeReviewResponse :: Int -> CreateCodeReviewResponse
newCreateCodeReviewResponse Int
pHttpStatus_ =
CreateCodeReviewResponse' :: Maybe CodeReview -> Int -> CreateCodeReviewResponse
CreateCodeReviewResponse'
{ $sel:codeReview:CreateCodeReviewResponse' :: Maybe CodeReview
codeReview =
Maybe CodeReview
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateCodeReviewResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createCodeReviewResponse_codeReview :: Lens.Lens' CreateCodeReviewResponse (Prelude.Maybe CodeReview)
createCodeReviewResponse_codeReview :: (Maybe CodeReview -> f (Maybe CodeReview))
-> CreateCodeReviewResponse -> f CreateCodeReviewResponse
createCodeReviewResponse_codeReview = (CreateCodeReviewResponse -> Maybe CodeReview)
-> (CreateCodeReviewResponse
-> Maybe CodeReview -> CreateCodeReviewResponse)
-> Lens
CreateCodeReviewResponse
CreateCodeReviewResponse
(Maybe CodeReview)
(Maybe CodeReview)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeReviewResponse' {Maybe CodeReview
codeReview :: Maybe CodeReview
$sel:codeReview:CreateCodeReviewResponse' :: CreateCodeReviewResponse -> Maybe CodeReview
codeReview} -> Maybe CodeReview
codeReview) (\s :: CreateCodeReviewResponse
s@CreateCodeReviewResponse' {} Maybe CodeReview
a -> CreateCodeReviewResponse
s {$sel:codeReview:CreateCodeReviewResponse' :: Maybe CodeReview
codeReview = Maybe CodeReview
a} :: CreateCodeReviewResponse)
createCodeReviewResponse_httpStatus :: Lens.Lens' CreateCodeReviewResponse Prelude.Int
createCodeReviewResponse_httpStatus :: (Int -> f Int)
-> CreateCodeReviewResponse -> f CreateCodeReviewResponse
createCodeReviewResponse_httpStatus = (CreateCodeReviewResponse -> Int)
-> (CreateCodeReviewResponse -> Int -> CreateCodeReviewResponse)
-> Lens CreateCodeReviewResponse CreateCodeReviewResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeReviewResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCodeReviewResponse' :: CreateCodeReviewResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCodeReviewResponse
s@CreateCodeReviewResponse' {} Int
a -> CreateCodeReviewResponse
s {$sel:httpStatus:CreateCodeReviewResponse' :: Int
httpStatus = Int
a} :: CreateCodeReviewResponse)
instance Prelude.NFData CreateCodeReviewResponse