{-# 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.CodeBuild.CreateWebhook
(
CreateWebhook (..),
newCreateWebhook,
createWebhook_branchFilter,
createWebhook_filterGroups,
createWebhook_buildType,
createWebhook_projectName,
CreateWebhookResponse (..),
newCreateWebhookResponse,
createWebhookResponse_webhook,
createWebhookResponse_httpStatus,
)
where
import Amazonka.CodeBuild.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 CreateWebhook = CreateWebhook'
{
CreateWebhook -> Maybe Text
branchFilter :: Prelude.Maybe Prelude.Text,
CreateWebhook -> Maybe [[WebhookFilter]]
filterGroups :: Prelude.Maybe [[WebhookFilter]],
CreateWebhook -> Maybe WebhookBuildType
buildType :: Prelude.Maybe WebhookBuildType,
CreateWebhook -> Text
projectName :: Prelude.Text
}
deriving (CreateWebhook -> CreateWebhook -> Bool
(CreateWebhook -> CreateWebhook -> Bool)
-> (CreateWebhook -> CreateWebhook -> Bool) -> Eq CreateWebhook
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateWebhook -> CreateWebhook -> Bool
$c/= :: CreateWebhook -> CreateWebhook -> Bool
== :: CreateWebhook -> CreateWebhook -> Bool
$c== :: CreateWebhook -> CreateWebhook -> Bool
Prelude.Eq, ReadPrec [CreateWebhook]
ReadPrec CreateWebhook
Int -> ReadS CreateWebhook
ReadS [CreateWebhook]
(Int -> ReadS CreateWebhook)
-> ReadS [CreateWebhook]
-> ReadPrec CreateWebhook
-> ReadPrec [CreateWebhook]
-> Read CreateWebhook
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateWebhook]
$creadListPrec :: ReadPrec [CreateWebhook]
readPrec :: ReadPrec CreateWebhook
$creadPrec :: ReadPrec CreateWebhook
readList :: ReadS [CreateWebhook]
$creadList :: ReadS [CreateWebhook]
readsPrec :: Int -> ReadS CreateWebhook
$creadsPrec :: Int -> ReadS CreateWebhook
Prelude.Read, Int -> CreateWebhook -> ShowS
[CreateWebhook] -> ShowS
CreateWebhook -> String
(Int -> CreateWebhook -> ShowS)
-> (CreateWebhook -> String)
-> ([CreateWebhook] -> ShowS)
-> Show CreateWebhook
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateWebhook] -> ShowS
$cshowList :: [CreateWebhook] -> ShowS
show :: CreateWebhook -> String
$cshow :: CreateWebhook -> String
showsPrec :: Int -> CreateWebhook -> ShowS
$cshowsPrec :: Int -> CreateWebhook -> ShowS
Prelude.Show, (forall x. CreateWebhook -> Rep CreateWebhook x)
-> (forall x. Rep CreateWebhook x -> CreateWebhook)
-> Generic CreateWebhook
forall x. Rep CreateWebhook x -> CreateWebhook
forall x. CreateWebhook -> Rep CreateWebhook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateWebhook x -> CreateWebhook
$cfrom :: forall x. CreateWebhook -> Rep CreateWebhook x
Prelude.Generic)
newCreateWebhook ::
Prelude.Text ->
CreateWebhook
newCreateWebhook :: Text -> CreateWebhook
newCreateWebhook Text
pProjectName_ =
CreateWebhook' :: Maybe Text
-> Maybe [[WebhookFilter]]
-> Maybe WebhookBuildType
-> Text
-> CreateWebhook
CreateWebhook'
{ $sel:branchFilter:CreateWebhook' :: Maybe Text
branchFilter = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:filterGroups:CreateWebhook' :: Maybe [[WebhookFilter]]
filterGroups = Maybe [[WebhookFilter]]
forall a. Maybe a
Prelude.Nothing,
$sel:buildType:CreateWebhook' :: Maybe WebhookBuildType
buildType = Maybe WebhookBuildType
forall a. Maybe a
Prelude.Nothing,
$sel:projectName:CreateWebhook' :: Text
projectName = Text
pProjectName_
}
createWebhook_branchFilter :: Lens.Lens' CreateWebhook (Prelude.Maybe Prelude.Text)
createWebhook_branchFilter :: (Maybe Text -> f (Maybe Text)) -> CreateWebhook -> f CreateWebhook
createWebhook_branchFilter = (CreateWebhook -> Maybe Text)
-> (CreateWebhook -> Maybe Text -> CreateWebhook)
-> Lens CreateWebhook CreateWebhook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWebhook' {Maybe Text
branchFilter :: Maybe Text
$sel:branchFilter:CreateWebhook' :: CreateWebhook -> Maybe Text
branchFilter} -> Maybe Text
branchFilter) (\s :: CreateWebhook
s@CreateWebhook' {} Maybe Text
a -> CreateWebhook
s {$sel:branchFilter:CreateWebhook' :: Maybe Text
branchFilter = Maybe Text
a} :: CreateWebhook)
createWebhook_filterGroups :: Lens.Lens' CreateWebhook (Prelude.Maybe [[WebhookFilter]])
createWebhook_filterGroups :: (Maybe [[WebhookFilter]] -> f (Maybe [[WebhookFilter]]))
-> CreateWebhook -> f CreateWebhook
createWebhook_filterGroups = (CreateWebhook -> Maybe [[WebhookFilter]])
-> (CreateWebhook -> Maybe [[WebhookFilter]] -> CreateWebhook)
-> Lens
CreateWebhook
CreateWebhook
(Maybe [[WebhookFilter]])
(Maybe [[WebhookFilter]])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWebhook' {Maybe [[WebhookFilter]]
filterGroups :: Maybe [[WebhookFilter]]
$sel:filterGroups:CreateWebhook' :: CreateWebhook -> Maybe [[WebhookFilter]]
filterGroups} -> Maybe [[WebhookFilter]]
filterGroups) (\s :: CreateWebhook
s@CreateWebhook' {} Maybe [[WebhookFilter]]
a -> CreateWebhook
s {$sel:filterGroups:CreateWebhook' :: Maybe [[WebhookFilter]]
filterGroups = Maybe [[WebhookFilter]]
a} :: CreateWebhook) ((Maybe [[WebhookFilter]] -> f (Maybe [[WebhookFilter]]))
-> CreateWebhook -> f CreateWebhook)
-> ((Maybe [[WebhookFilter]] -> f (Maybe [[WebhookFilter]]))
-> Maybe [[WebhookFilter]] -> f (Maybe [[WebhookFilter]]))
-> (Maybe [[WebhookFilter]] -> f (Maybe [[WebhookFilter]]))
-> CreateWebhook
-> f CreateWebhook
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[[WebhookFilter]]
[[WebhookFilter]]
[[WebhookFilter]]
[[WebhookFilter]]
-> Iso
(Maybe [[WebhookFilter]])
(Maybe [[WebhookFilter]])
(Maybe [[WebhookFilter]])
(Maybe [[WebhookFilter]])
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
[[WebhookFilter]]
[[WebhookFilter]]
[[WebhookFilter]]
[[WebhookFilter]]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createWebhook_buildType :: Lens.Lens' CreateWebhook (Prelude.Maybe WebhookBuildType)
createWebhook_buildType :: (Maybe WebhookBuildType -> f (Maybe WebhookBuildType))
-> CreateWebhook -> f CreateWebhook
createWebhook_buildType = (CreateWebhook -> Maybe WebhookBuildType)
-> (CreateWebhook -> Maybe WebhookBuildType -> CreateWebhook)
-> Lens
CreateWebhook
CreateWebhook
(Maybe WebhookBuildType)
(Maybe WebhookBuildType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWebhook' {Maybe WebhookBuildType
buildType :: Maybe WebhookBuildType
$sel:buildType:CreateWebhook' :: CreateWebhook -> Maybe WebhookBuildType
buildType} -> Maybe WebhookBuildType
buildType) (\s :: CreateWebhook
s@CreateWebhook' {} Maybe WebhookBuildType
a -> CreateWebhook
s {$sel:buildType:CreateWebhook' :: Maybe WebhookBuildType
buildType = Maybe WebhookBuildType
a} :: CreateWebhook)
createWebhook_projectName :: Lens.Lens' CreateWebhook Prelude.Text
createWebhook_projectName :: (Text -> f Text) -> CreateWebhook -> f CreateWebhook
createWebhook_projectName = (CreateWebhook -> Text)
-> (CreateWebhook -> Text -> CreateWebhook)
-> Lens CreateWebhook CreateWebhook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWebhook' {Text
projectName :: Text
$sel:projectName:CreateWebhook' :: CreateWebhook -> Text
projectName} -> Text
projectName) (\s :: CreateWebhook
s@CreateWebhook' {} Text
a -> CreateWebhook
s {$sel:projectName:CreateWebhook' :: Text
projectName = Text
a} :: CreateWebhook)
instance Core.AWSRequest CreateWebhook where
type
AWSResponse CreateWebhook =
CreateWebhookResponse
request :: CreateWebhook -> Request CreateWebhook
request = Service -> CreateWebhook -> Request CreateWebhook
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateWebhook
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateWebhook)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateWebhook))
-> Logger
-> Service
-> Proxy CreateWebhook
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateWebhook)))
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 Webhook -> Int -> CreateWebhookResponse
CreateWebhookResponse'
(Maybe Webhook -> Int -> CreateWebhookResponse)
-> Either String (Maybe Webhook)
-> Either String (Int -> CreateWebhookResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Webhook)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"webhook")
Either String (Int -> CreateWebhookResponse)
-> Either String Int -> Either String CreateWebhookResponse
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 CreateWebhook
instance Prelude.NFData CreateWebhook
instance Core.ToHeaders CreateWebhook where
toHeaders :: CreateWebhook -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateWebhook -> 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
"CodeBuild_20161006.CreateWebhook" ::
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 CreateWebhook where
toJSON :: CreateWebhook -> Value
toJSON CreateWebhook' {Maybe [[WebhookFilter]]
Maybe Text
Maybe WebhookBuildType
Text
projectName :: Text
buildType :: Maybe WebhookBuildType
filterGroups :: Maybe [[WebhookFilter]]
branchFilter :: Maybe Text
$sel:projectName:CreateWebhook' :: CreateWebhook -> Text
$sel:buildType:CreateWebhook' :: CreateWebhook -> Maybe WebhookBuildType
$sel:filterGroups:CreateWebhook' :: CreateWebhook -> Maybe [[WebhookFilter]]
$sel:branchFilter:CreateWebhook' :: CreateWebhook -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"branchFilter" 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
branchFilter,
(Text
"filterGroups" Text -> [[WebhookFilter]] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([[WebhookFilter]] -> Pair)
-> Maybe [[WebhookFilter]] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [[WebhookFilter]]
filterGroups,
(Text
"buildType" Text -> WebhookBuildType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (WebhookBuildType -> Pair) -> Maybe WebhookBuildType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WebhookBuildType
buildType,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"projectName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
projectName)
]
)
instance Core.ToPath CreateWebhook where
toPath :: CreateWebhook -> ByteString
toPath = ByteString -> CreateWebhook -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateWebhook where
toQuery :: CreateWebhook -> QueryString
toQuery = QueryString -> CreateWebhook -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateWebhookResponse = CreateWebhookResponse'
{
CreateWebhookResponse -> Maybe Webhook
webhook :: Prelude.Maybe Webhook,
CreateWebhookResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateWebhookResponse -> CreateWebhookResponse -> Bool
(CreateWebhookResponse -> CreateWebhookResponse -> Bool)
-> (CreateWebhookResponse -> CreateWebhookResponse -> Bool)
-> Eq CreateWebhookResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateWebhookResponse -> CreateWebhookResponse -> Bool
$c/= :: CreateWebhookResponse -> CreateWebhookResponse -> Bool
== :: CreateWebhookResponse -> CreateWebhookResponse -> Bool
$c== :: CreateWebhookResponse -> CreateWebhookResponse -> Bool
Prelude.Eq, ReadPrec [CreateWebhookResponse]
ReadPrec CreateWebhookResponse
Int -> ReadS CreateWebhookResponse
ReadS [CreateWebhookResponse]
(Int -> ReadS CreateWebhookResponse)
-> ReadS [CreateWebhookResponse]
-> ReadPrec CreateWebhookResponse
-> ReadPrec [CreateWebhookResponse]
-> Read CreateWebhookResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateWebhookResponse]
$creadListPrec :: ReadPrec [CreateWebhookResponse]
readPrec :: ReadPrec CreateWebhookResponse
$creadPrec :: ReadPrec CreateWebhookResponse
readList :: ReadS [CreateWebhookResponse]
$creadList :: ReadS [CreateWebhookResponse]
readsPrec :: Int -> ReadS CreateWebhookResponse
$creadsPrec :: Int -> ReadS CreateWebhookResponse
Prelude.Read, Int -> CreateWebhookResponse -> ShowS
[CreateWebhookResponse] -> ShowS
CreateWebhookResponse -> String
(Int -> CreateWebhookResponse -> ShowS)
-> (CreateWebhookResponse -> String)
-> ([CreateWebhookResponse] -> ShowS)
-> Show CreateWebhookResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateWebhookResponse] -> ShowS
$cshowList :: [CreateWebhookResponse] -> ShowS
show :: CreateWebhookResponse -> String
$cshow :: CreateWebhookResponse -> String
showsPrec :: Int -> CreateWebhookResponse -> ShowS
$cshowsPrec :: Int -> CreateWebhookResponse -> ShowS
Prelude.Show, (forall x. CreateWebhookResponse -> Rep CreateWebhookResponse x)
-> (forall x. Rep CreateWebhookResponse x -> CreateWebhookResponse)
-> Generic CreateWebhookResponse
forall x. Rep CreateWebhookResponse x -> CreateWebhookResponse
forall x. CreateWebhookResponse -> Rep CreateWebhookResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateWebhookResponse x -> CreateWebhookResponse
$cfrom :: forall x. CreateWebhookResponse -> Rep CreateWebhookResponse x
Prelude.Generic)
newCreateWebhookResponse ::
Prelude.Int ->
CreateWebhookResponse
newCreateWebhookResponse :: Int -> CreateWebhookResponse
newCreateWebhookResponse Int
pHttpStatus_ =
CreateWebhookResponse' :: Maybe Webhook -> Int -> CreateWebhookResponse
CreateWebhookResponse'
{ $sel:webhook:CreateWebhookResponse' :: Maybe Webhook
webhook = Maybe Webhook
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateWebhookResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createWebhookResponse_webhook :: Lens.Lens' CreateWebhookResponse (Prelude.Maybe Webhook)
createWebhookResponse_webhook :: (Maybe Webhook -> f (Maybe Webhook))
-> CreateWebhookResponse -> f CreateWebhookResponse
createWebhookResponse_webhook = (CreateWebhookResponse -> Maybe Webhook)
-> (CreateWebhookResponse
-> Maybe Webhook -> CreateWebhookResponse)
-> Lens
CreateWebhookResponse
CreateWebhookResponse
(Maybe Webhook)
(Maybe Webhook)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWebhookResponse' {Maybe Webhook
webhook :: Maybe Webhook
$sel:webhook:CreateWebhookResponse' :: CreateWebhookResponse -> Maybe Webhook
webhook} -> Maybe Webhook
webhook) (\s :: CreateWebhookResponse
s@CreateWebhookResponse' {} Maybe Webhook
a -> CreateWebhookResponse
s {$sel:webhook:CreateWebhookResponse' :: Maybe Webhook
webhook = Maybe Webhook
a} :: CreateWebhookResponse)
createWebhookResponse_httpStatus :: Lens.Lens' CreateWebhookResponse Prelude.Int
createWebhookResponse_httpStatus :: (Int -> f Int) -> CreateWebhookResponse -> f CreateWebhookResponse
createWebhookResponse_httpStatus = (CreateWebhookResponse -> Int)
-> (CreateWebhookResponse -> Int -> CreateWebhookResponse)
-> Lens CreateWebhookResponse CreateWebhookResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWebhookResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateWebhookResponse' :: CreateWebhookResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateWebhookResponse
s@CreateWebhookResponse' {} Int
a -> CreateWebhookResponse
s {$sel:httpStatus:CreateWebhookResponse' :: Int
httpStatus = Int
a} :: CreateWebhookResponse)
instance Prelude.NFData CreateWebhookResponse