{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.CodeBuild.Types.WebhookFilter -- Copyright : (c) 2013-2021 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay <brendan.g.hay+amazonka@gmail.com> -- Stability : auto-generated -- Portability : non-portable (GHC extensions) module Amazonka.CodeBuild.Types.WebhookFilter where import Amazonka.CodeBuild.Types.WebhookFilterType import qualified Amazonka.Core as Core import qualified Amazonka.Lens as Lens import qualified Amazonka.Prelude as Prelude -- | A filter used to determine which webhooks trigger a build. -- -- /See:/ 'newWebhookFilter' smart constructor. data WebhookFilter = WebhookFilter' { -- | Used to indicate that the @pattern@ determines which webhook events do -- not trigger a build. If true, then a webhook event that does not match -- the @pattern@ triggers a build. If false, then a webhook event that -- matches the @pattern@ triggers a build. WebhookFilter -> Maybe Bool excludeMatchedPattern :: Prelude.Maybe Prelude.Bool, -- | The type of webhook filter. There are six webhook filter types: @EVENT@, -- @ACTOR_ACCOUNT_ID@, @HEAD_REF@, @BASE_REF@, @FILE_PATH@, and -- @COMMIT_MESSAGE@. -- -- [EVENT] -- A webhook event triggers a build when the provided @pattern@ matches -- one of five event types: @PUSH@, @PULL_REQUEST_CREATED@, -- @PULL_REQUEST_UPDATED@, @PULL_REQUEST_REOPENED@, and -- @PULL_REQUEST_MERGED@. The @EVENT@ patterns are specified as a -- comma-separated string. For example, -- @PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED@ filters all push, -- pull request created, and pull request updated events. -- -- The @PULL_REQUEST_REOPENED@ works with GitHub and GitHub Enterprise -- only. -- -- [ACTOR_ACCOUNT_ID] -- A webhook event triggers a build when a GitHub, GitHub Enterprise, -- or Bitbucket account ID matches the regular expression @pattern@. -- -- [HEAD_REF] -- A webhook event triggers a build when the head reference matches the -- regular expression @pattern@. For example, -- @refs\/heads\/branch-name@ and @refs\/tags\/tag-name@. -- -- Works with GitHub and GitHub Enterprise push, GitHub and GitHub -- Enterprise pull request, Bitbucket push, and Bitbucket pull request -- events. -- -- [BASE_REF] -- A webhook event triggers a build when the base reference matches the -- regular expression @pattern@. For example, -- @refs\/heads\/branch-name@. -- -- Works with pull request events only. -- -- [FILE_PATH] -- A webhook triggers a build when the path of a changed file matches -- the regular expression @pattern@. -- -- Works with GitHub and Bitbucket events push and pull requests -- events. Also works with GitHub Enterprise push events, but does not -- work with GitHub Enterprise pull request events. -- -- [COMMIT_MESSAGE] -- A webhook triggers a build when the head commit message matches the -- regular expression @pattern@. -- -- Works with GitHub and Bitbucket events push and pull requests -- events. Also works with GitHub Enterprise push events, but does not -- work with GitHub Enterprise pull request events. WebhookFilter -> WebhookFilterType type' :: WebhookFilterType, -- | For a @WebHookFilter@ that uses @EVENT@ type, a comma-separated string -- that specifies one or more events. For example, the webhook filter -- @PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED@ allows all push, pull -- request created, and pull request updated events to trigger a build. -- -- For a @WebHookFilter@ that uses any of the other filter types, a regular -- expression pattern. For example, a @WebHookFilter@ that uses @HEAD_REF@ -- for its @type@ and the pattern @^refs\/heads\/@ triggers a build when -- the head reference is a branch with a reference name -- @refs\/heads\/branch-name@. WebhookFilter -> Text pattern' :: Prelude.Text } deriving (WebhookFilter -> WebhookFilter -> Bool (WebhookFilter -> WebhookFilter -> Bool) -> (WebhookFilter -> WebhookFilter -> Bool) -> Eq WebhookFilter forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: WebhookFilter -> WebhookFilter -> Bool $c/= :: WebhookFilter -> WebhookFilter -> Bool == :: WebhookFilter -> WebhookFilter -> Bool $c== :: WebhookFilter -> WebhookFilter -> Bool Prelude.Eq, ReadPrec [WebhookFilter] ReadPrec WebhookFilter Int -> ReadS WebhookFilter ReadS [WebhookFilter] (Int -> ReadS WebhookFilter) -> ReadS [WebhookFilter] -> ReadPrec WebhookFilter -> ReadPrec [WebhookFilter] -> Read WebhookFilter forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [WebhookFilter] $creadListPrec :: ReadPrec [WebhookFilter] readPrec :: ReadPrec WebhookFilter $creadPrec :: ReadPrec WebhookFilter readList :: ReadS [WebhookFilter] $creadList :: ReadS [WebhookFilter] readsPrec :: Int -> ReadS WebhookFilter $creadsPrec :: Int -> ReadS WebhookFilter Prelude.Read, Int -> WebhookFilter -> ShowS [WebhookFilter] -> ShowS WebhookFilter -> String (Int -> WebhookFilter -> ShowS) -> (WebhookFilter -> String) -> ([WebhookFilter] -> ShowS) -> Show WebhookFilter forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [WebhookFilter] -> ShowS $cshowList :: [WebhookFilter] -> ShowS show :: WebhookFilter -> String $cshow :: WebhookFilter -> String showsPrec :: Int -> WebhookFilter -> ShowS $cshowsPrec :: Int -> WebhookFilter -> ShowS Prelude.Show, (forall x. WebhookFilter -> Rep WebhookFilter x) -> (forall x. Rep WebhookFilter x -> WebhookFilter) -> Generic WebhookFilter forall x. Rep WebhookFilter x -> WebhookFilter forall x. WebhookFilter -> Rep WebhookFilter x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep WebhookFilter x -> WebhookFilter $cfrom :: forall x. WebhookFilter -> Rep WebhookFilter x Prelude.Generic) -- | -- Create a value of 'WebhookFilter' with all optional fields omitted. -- -- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'excludeMatchedPattern', 'webhookFilter_excludeMatchedPattern' - Used to indicate that the @pattern@ determines which webhook events do -- not trigger a build. If true, then a webhook event that does not match -- the @pattern@ triggers a build. If false, then a webhook event that -- matches the @pattern@ triggers a build. -- -- 'type'', 'webhookFilter_type' - The type of webhook filter. There are six webhook filter types: @EVENT@, -- @ACTOR_ACCOUNT_ID@, @HEAD_REF@, @BASE_REF@, @FILE_PATH@, and -- @COMMIT_MESSAGE@. -- -- [EVENT] -- A webhook event triggers a build when the provided @pattern@ matches -- one of five event types: @PUSH@, @PULL_REQUEST_CREATED@, -- @PULL_REQUEST_UPDATED@, @PULL_REQUEST_REOPENED@, and -- @PULL_REQUEST_MERGED@. The @EVENT@ patterns are specified as a -- comma-separated string. For example, -- @PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED@ filters all push, -- pull request created, and pull request updated events. -- -- The @PULL_REQUEST_REOPENED@ works with GitHub and GitHub Enterprise -- only. -- -- [ACTOR_ACCOUNT_ID] -- A webhook event triggers a build when a GitHub, GitHub Enterprise, -- or Bitbucket account ID matches the regular expression @pattern@. -- -- [HEAD_REF] -- A webhook event triggers a build when the head reference matches the -- regular expression @pattern@. For example, -- @refs\/heads\/branch-name@ and @refs\/tags\/tag-name@. -- -- Works with GitHub and GitHub Enterprise push, GitHub and GitHub -- Enterprise pull request, Bitbucket push, and Bitbucket pull request -- events. -- -- [BASE_REF] -- A webhook event triggers a build when the base reference matches the -- regular expression @pattern@. For example, -- @refs\/heads\/branch-name@. -- -- Works with pull request events only. -- -- [FILE_PATH] -- A webhook triggers a build when the path of a changed file matches -- the regular expression @pattern@. -- -- Works with GitHub and Bitbucket events push and pull requests -- events. Also works with GitHub Enterprise push events, but does not -- work with GitHub Enterprise pull request events. -- -- [COMMIT_MESSAGE] -- A webhook triggers a build when the head commit message matches the -- regular expression @pattern@. -- -- Works with GitHub and Bitbucket events push and pull requests -- events. Also works with GitHub Enterprise push events, but does not -- work with GitHub Enterprise pull request events. -- -- 'pattern'', 'webhookFilter_pattern' - For a @WebHookFilter@ that uses @EVENT@ type, a comma-separated string -- that specifies one or more events. For example, the webhook filter -- @PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED@ allows all push, pull -- request created, and pull request updated events to trigger a build. -- -- For a @WebHookFilter@ that uses any of the other filter types, a regular -- expression pattern. For example, a @WebHookFilter@ that uses @HEAD_REF@ -- for its @type@ and the pattern @^refs\/heads\/@ triggers a build when -- the head reference is a branch with a reference name -- @refs\/heads\/branch-name@. newWebhookFilter :: -- | 'type'' WebhookFilterType -> -- | 'pattern'' Prelude.Text -> WebhookFilter newWebhookFilter :: WebhookFilterType -> Text -> WebhookFilter newWebhookFilter WebhookFilterType pType_ Text pPattern_ = WebhookFilter' :: Maybe Bool -> WebhookFilterType -> Text -> WebhookFilter WebhookFilter' { $sel:excludeMatchedPattern:WebhookFilter' :: Maybe Bool excludeMatchedPattern = Maybe Bool forall a. Maybe a Prelude.Nothing, $sel:type':WebhookFilter' :: WebhookFilterType type' = WebhookFilterType pType_, $sel:pattern':WebhookFilter' :: Text pattern' = Text pPattern_ } -- | Used to indicate that the @pattern@ determines which webhook events do -- not trigger a build. If true, then a webhook event that does not match -- the @pattern@ triggers a build. If false, then a webhook event that -- matches the @pattern@ triggers a build. webhookFilter_excludeMatchedPattern :: Lens.Lens' WebhookFilter (Prelude.Maybe Prelude.Bool) webhookFilter_excludeMatchedPattern :: (Maybe Bool -> f (Maybe Bool)) -> WebhookFilter -> f WebhookFilter webhookFilter_excludeMatchedPattern = (WebhookFilter -> Maybe Bool) -> (WebhookFilter -> Maybe Bool -> WebhookFilter) -> Lens WebhookFilter WebhookFilter (Maybe Bool) (Maybe Bool) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\WebhookFilter' {Maybe Bool excludeMatchedPattern :: Maybe Bool $sel:excludeMatchedPattern:WebhookFilter' :: WebhookFilter -> Maybe Bool excludeMatchedPattern} -> Maybe Bool excludeMatchedPattern) (\s :: WebhookFilter s@WebhookFilter' {} Maybe Bool a -> WebhookFilter s {$sel:excludeMatchedPattern:WebhookFilter' :: Maybe Bool excludeMatchedPattern = Maybe Bool a} :: WebhookFilter) -- | The type of webhook filter. There are six webhook filter types: @EVENT@, -- @ACTOR_ACCOUNT_ID@, @HEAD_REF@, @BASE_REF@, @FILE_PATH@, and -- @COMMIT_MESSAGE@. -- -- [EVENT] -- A webhook event triggers a build when the provided @pattern@ matches -- one of five event types: @PUSH@, @PULL_REQUEST_CREATED@, -- @PULL_REQUEST_UPDATED@, @PULL_REQUEST_REOPENED@, and -- @PULL_REQUEST_MERGED@. The @EVENT@ patterns are specified as a -- comma-separated string. For example, -- @PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED@ filters all push, -- pull request created, and pull request updated events. -- -- The @PULL_REQUEST_REOPENED@ works with GitHub and GitHub Enterprise -- only. -- -- [ACTOR_ACCOUNT_ID] -- A webhook event triggers a build when a GitHub, GitHub Enterprise, -- or Bitbucket account ID matches the regular expression @pattern@. -- -- [HEAD_REF] -- A webhook event triggers a build when the head reference matches the -- regular expression @pattern@. For example, -- @refs\/heads\/branch-name@ and @refs\/tags\/tag-name@. -- -- Works with GitHub and GitHub Enterprise push, GitHub and GitHub -- Enterprise pull request, Bitbucket push, and Bitbucket pull request -- events. -- -- [BASE_REF] -- A webhook event triggers a build when the base reference matches the -- regular expression @pattern@. For example, -- @refs\/heads\/branch-name@. -- -- Works with pull request events only. -- -- [FILE_PATH] -- A webhook triggers a build when the path of a changed file matches -- the regular expression @pattern@. -- -- Works with GitHub and Bitbucket events push and pull requests -- events. Also works with GitHub Enterprise push events, but does not -- work with GitHub Enterprise pull request events. -- -- [COMMIT_MESSAGE] -- A webhook triggers a build when the head commit message matches the -- regular expression @pattern@. -- -- Works with GitHub and Bitbucket events push and pull requests -- events. Also works with GitHub Enterprise push events, but does not -- work with GitHub Enterprise pull request events. webhookFilter_type :: Lens.Lens' WebhookFilter WebhookFilterType webhookFilter_type :: (WebhookFilterType -> f WebhookFilterType) -> WebhookFilter -> f WebhookFilter webhookFilter_type = (WebhookFilter -> WebhookFilterType) -> (WebhookFilter -> WebhookFilterType -> WebhookFilter) -> Lens WebhookFilter WebhookFilter WebhookFilterType WebhookFilterType forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\WebhookFilter' {WebhookFilterType type' :: WebhookFilterType $sel:type':WebhookFilter' :: WebhookFilter -> WebhookFilterType type'} -> WebhookFilterType type') (\s :: WebhookFilter s@WebhookFilter' {} WebhookFilterType a -> WebhookFilter s {$sel:type':WebhookFilter' :: WebhookFilterType type' = WebhookFilterType a} :: WebhookFilter) -- | For a @WebHookFilter@ that uses @EVENT@ type, a comma-separated string -- that specifies one or more events. For example, the webhook filter -- @PUSH, PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED@ allows all push, pull -- request created, and pull request updated events to trigger a build. -- -- For a @WebHookFilter@ that uses any of the other filter types, a regular -- expression pattern. For example, a @WebHookFilter@ that uses @HEAD_REF@ -- for its @type@ and the pattern @^refs\/heads\/@ triggers a build when -- the head reference is a branch with a reference name -- @refs\/heads\/branch-name@. webhookFilter_pattern :: Lens.Lens' WebhookFilter Prelude.Text webhookFilter_pattern :: (Text -> f Text) -> WebhookFilter -> f WebhookFilter webhookFilter_pattern = (WebhookFilter -> Text) -> (WebhookFilter -> Text -> WebhookFilter) -> Lens WebhookFilter WebhookFilter Text Text forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\WebhookFilter' {Text pattern' :: Text $sel:pattern':WebhookFilter' :: WebhookFilter -> Text pattern'} -> Text pattern') (\s :: WebhookFilter s@WebhookFilter' {} Text a -> WebhookFilter s {$sel:pattern':WebhookFilter' :: Text pattern' = Text a} :: WebhookFilter) instance Core.FromJSON WebhookFilter where parseJSON :: Value -> Parser WebhookFilter parseJSON = String -> (Object -> Parser WebhookFilter) -> Value -> Parser WebhookFilter forall a. String -> (Object -> Parser a) -> Value -> Parser a Core.withObject String "WebhookFilter" ( \Object x -> Maybe Bool -> WebhookFilterType -> Text -> WebhookFilter WebhookFilter' (Maybe Bool -> WebhookFilterType -> Text -> WebhookFilter) -> Parser (Maybe Bool) -> Parser (WebhookFilterType -> Text -> WebhookFilter) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> (Object x Object -> Text -> Parser (Maybe Bool) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "excludeMatchedPattern") Parser (WebhookFilterType -> Text -> WebhookFilter) -> Parser WebhookFilterType -> Parser (Text -> WebhookFilter) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x Object -> Text -> Parser WebhookFilterType forall a. FromJSON a => Object -> Text -> Parser a Core..: Text "type") Parser (Text -> WebhookFilter) -> Parser Text -> Parser WebhookFilter forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x Object -> Text -> Parser Text forall a. FromJSON a => Object -> Text -> Parser a Core..: Text "pattern") ) instance Prelude.Hashable WebhookFilter instance Prelude.NFData WebhookFilter instance Core.ToJSON WebhookFilter where toJSON :: WebhookFilter -> Value toJSON WebhookFilter' {Maybe Bool Text WebhookFilterType pattern' :: Text type' :: WebhookFilterType excludeMatchedPattern :: Maybe Bool $sel:pattern':WebhookFilter' :: WebhookFilter -> Text $sel:type':WebhookFilter' :: WebhookFilter -> WebhookFilterType $sel:excludeMatchedPattern:WebhookFilter' :: WebhookFilter -> Maybe Bool ..} = [Pair] -> Value Core.object ( [Maybe Pair] -> [Pair] forall a. [Maybe a] -> [a] Prelude.catMaybes [ (Text "excludeMatchedPattern" Text -> Bool -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe Bool excludeMatchedPattern, Pair -> Maybe Pair forall a. a -> Maybe a Prelude.Just (Text "type" Text -> WebhookFilterType -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..= WebhookFilterType type'), Pair -> Maybe Pair forall a. a -> Maybe a Prelude.Just (Text "pattern" Text -> Text -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..= Text pattern') ] )