{-# 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.CodePipeline.Types.ListWebhookItem
-- 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.CodePipeline.Types.ListWebhookItem where

import Amazonka.CodePipeline.Types.Tag
import Amazonka.CodePipeline.Types.WebhookDefinition
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The detail returned for each webhook after listing webhooks, such as the
-- webhook URL, the webhook name, and the webhook ARN.
--
-- /See:/ 'newListWebhookItem' smart constructor.
data ListWebhookItem = ListWebhookItem'
  { -- | The Amazon Resource Name (ARN) of the webhook.
    ListWebhookItem -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The number code of the error.
    ListWebhookItem -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The date and time a webhook was last successfully triggered, in
    -- timestamp format.
    ListWebhookItem -> Maybe POSIX
lastTriggered :: Prelude.Maybe Core.POSIX,
    -- | The text of the error message about the webhook.
    ListWebhookItem -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | Specifies the tags applied to the webhook.
    ListWebhookItem -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The detail returned for each webhook, such as the webhook authentication
    -- type and filter rules.
    ListWebhookItem -> WebhookDefinition
definition :: WebhookDefinition,
    -- | A unique URL generated by CodePipeline. When a POST request is made to
    -- this URL, the defined pipeline is started as long as the body of the
    -- post request satisfies the defined authentication and filtering
    -- conditions. Deleting and re-creating a webhook makes the old URL invalid
    -- and generates a new one.
    ListWebhookItem -> Text
url :: Prelude.Text
  }
  deriving (ListWebhookItem -> ListWebhookItem -> Bool
(ListWebhookItem -> ListWebhookItem -> Bool)
-> (ListWebhookItem -> ListWebhookItem -> Bool)
-> Eq ListWebhookItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWebhookItem -> ListWebhookItem -> Bool
$c/= :: ListWebhookItem -> ListWebhookItem -> Bool
== :: ListWebhookItem -> ListWebhookItem -> Bool
$c== :: ListWebhookItem -> ListWebhookItem -> Bool
Prelude.Eq, ReadPrec [ListWebhookItem]
ReadPrec ListWebhookItem
Int -> ReadS ListWebhookItem
ReadS [ListWebhookItem]
(Int -> ReadS ListWebhookItem)
-> ReadS [ListWebhookItem]
-> ReadPrec ListWebhookItem
-> ReadPrec [ListWebhookItem]
-> Read ListWebhookItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWebhookItem]
$creadListPrec :: ReadPrec [ListWebhookItem]
readPrec :: ReadPrec ListWebhookItem
$creadPrec :: ReadPrec ListWebhookItem
readList :: ReadS [ListWebhookItem]
$creadList :: ReadS [ListWebhookItem]
readsPrec :: Int -> ReadS ListWebhookItem
$creadsPrec :: Int -> ReadS ListWebhookItem
Prelude.Read, Int -> ListWebhookItem -> ShowS
[ListWebhookItem] -> ShowS
ListWebhookItem -> String
(Int -> ListWebhookItem -> ShowS)
-> (ListWebhookItem -> String)
-> ([ListWebhookItem] -> ShowS)
-> Show ListWebhookItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWebhookItem] -> ShowS
$cshowList :: [ListWebhookItem] -> ShowS
show :: ListWebhookItem -> String
$cshow :: ListWebhookItem -> String
showsPrec :: Int -> ListWebhookItem -> ShowS
$cshowsPrec :: Int -> ListWebhookItem -> ShowS
Prelude.Show, (forall x. ListWebhookItem -> Rep ListWebhookItem x)
-> (forall x. Rep ListWebhookItem x -> ListWebhookItem)
-> Generic ListWebhookItem
forall x. Rep ListWebhookItem x -> ListWebhookItem
forall x. ListWebhookItem -> Rep ListWebhookItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListWebhookItem x -> ListWebhookItem
$cfrom :: forall x. ListWebhookItem -> Rep ListWebhookItem x
Prelude.Generic)

-- |
-- Create a value of 'ListWebhookItem' 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:
--
-- 'arn', 'listWebhookItem_arn' - The Amazon Resource Name (ARN) of the webhook.
--
-- 'errorCode', 'listWebhookItem_errorCode' - The number code of the error.
--
-- 'lastTriggered', 'listWebhookItem_lastTriggered' - The date and time a webhook was last successfully triggered, in
-- timestamp format.
--
-- 'errorMessage', 'listWebhookItem_errorMessage' - The text of the error message about the webhook.
--
-- 'tags', 'listWebhookItem_tags' - Specifies the tags applied to the webhook.
--
-- 'definition', 'listWebhookItem_definition' - The detail returned for each webhook, such as the webhook authentication
-- type and filter rules.
--
-- 'url', 'listWebhookItem_url' - A unique URL generated by CodePipeline. When a POST request is made to
-- this URL, the defined pipeline is started as long as the body of the
-- post request satisfies the defined authentication and filtering
-- conditions. Deleting and re-creating a webhook makes the old URL invalid
-- and generates a new one.
newListWebhookItem ::
  -- | 'definition'
  WebhookDefinition ->
  -- | 'url'
  Prelude.Text ->
  ListWebhookItem
newListWebhookItem :: WebhookDefinition -> Text -> ListWebhookItem
newListWebhookItem WebhookDefinition
pDefinition_ Text
pUrl_ =
  ListWebhookItem' :: Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe [Tag]
-> WebhookDefinition
-> Text
-> ListWebhookItem
ListWebhookItem'
    { $sel:arn:ListWebhookItem' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:ListWebhookItem' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastTriggered:ListWebhookItem' :: Maybe POSIX
lastTriggered = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ListWebhookItem' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ListWebhookItem' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:definition:ListWebhookItem' :: WebhookDefinition
definition = WebhookDefinition
pDefinition_,
      $sel:url:ListWebhookItem' :: Text
url = Text
pUrl_
    }

-- | The Amazon Resource Name (ARN) of the webhook.
listWebhookItem_arn :: Lens.Lens' ListWebhookItem (Prelude.Maybe Prelude.Text)
listWebhookItem_arn :: (Maybe Text -> f (Maybe Text))
-> ListWebhookItem -> f ListWebhookItem
listWebhookItem_arn = (ListWebhookItem -> Maybe Text)
-> (ListWebhookItem -> Maybe Text -> ListWebhookItem)
-> Lens ListWebhookItem ListWebhookItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {Maybe Text
arn :: Maybe Text
$sel:arn:ListWebhookItem' :: ListWebhookItem -> Maybe Text
arn} -> Maybe Text
arn) (\s :: ListWebhookItem
s@ListWebhookItem' {} Maybe Text
a -> ListWebhookItem
s {$sel:arn:ListWebhookItem' :: Maybe Text
arn = Maybe Text
a} :: ListWebhookItem)

-- | The number code of the error.
listWebhookItem_errorCode :: Lens.Lens' ListWebhookItem (Prelude.Maybe Prelude.Text)
listWebhookItem_errorCode :: (Maybe Text -> f (Maybe Text))
-> ListWebhookItem -> f ListWebhookItem
listWebhookItem_errorCode = (ListWebhookItem -> Maybe Text)
-> (ListWebhookItem -> Maybe Text -> ListWebhookItem)
-> Lens ListWebhookItem ListWebhookItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:ListWebhookItem' :: ListWebhookItem -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: ListWebhookItem
s@ListWebhookItem' {} Maybe Text
a -> ListWebhookItem
s {$sel:errorCode:ListWebhookItem' :: Maybe Text
errorCode = Maybe Text
a} :: ListWebhookItem)

-- | The date and time a webhook was last successfully triggered, in
-- timestamp format.
listWebhookItem_lastTriggered :: Lens.Lens' ListWebhookItem (Prelude.Maybe Prelude.UTCTime)
listWebhookItem_lastTriggered :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListWebhookItem -> f ListWebhookItem
listWebhookItem_lastTriggered = (ListWebhookItem -> Maybe POSIX)
-> (ListWebhookItem -> Maybe POSIX -> ListWebhookItem)
-> Lens ListWebhookItem ListWebhookItem (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {Maybe POSIX
lastTriggered :: Maybe POSIX
$sel:lastTriggered:ListWebhookItem' :: ListWebhookItem -> Maybe POSIX
lastTriggered} -> Maybe POSIX
lastTriggered) (\s :: ListWebhookItem
s@ListWebhookItem' {} Maybe POSIX
a -> ListWebhookItem
s {$sel:lastTriggered:ListWebhookItem' :: Maybe POSIX
lastTriggered = Maybe POSIX
a} :: ListWebhookItem) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListWebhookItem -> f ListWebhookItem)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListWebhookItem
-> f ListWebhookItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The text of the error message about the webhook.
listWebhookItem_errorMessage :: Lens.Lens' ListWebhookItem (Prelude.Maybe Prelude.Text)
listWebhookItem_errorMessage :: (Maybe Text -> f (Maybe Text))
-> ListWebhookItem -> f ListWebhookItem
listWebhookItem_errorMessage = (ListWebhookItem -> Maybe Text)
-> (ListWebhookItem -> Maybe Text -> ListWebhookItem)
-> Lens ListWebhookItem ListWebhookItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:ListWebhookItem' :: ListWebhookItem -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: ListWebhookItem
s@ListWebhookItem' {} Maybe Text
a -> ListWebhookItem
s {$sel:errorMessage:ListWebhookItem' :: Maybe Text
errorMessage = Maybe Text
a} :: ListWebhookItem)

-- | Specifies the tags applied to the webhook.
listWebhookItem_tags :: Lens.Lens' ListWebhookItem (Prelude.Maybe [Tag])
listWebhookItem_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> ListWebhookItem -> f ListWebhookItem
listWebhookItem_tags = (ListWebhookItem -> Maybe [Tag])
-> (ListWebhookItem -> Maybe [Tag] -> ListWebhookItem)
-> Lens ListWebhookItem ListWebhookItem (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:ListWebhookItem' :: ListWebhookItem -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: ListWebhookItem
s@ListWebhookItem' {} Maybe [Tag]
a -> ListWebhookItem
s {$sel:tags:ListWebhookItem' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: ListWebhookItem) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> ListWebhookItem -> f ListWebhookItem)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> ListWebhookItem
-> f ListWebhookItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The detail returned for each webhook, such as the webhook authentication
-- type and filter rules.
listWebhookItem_definition :: Lens.Lens' ListWebhookItem WebhookDefinition
listWebhookItem_definition :: (WebhookDefinition -> f WebhookDefinition)
-> ListWebhookItem -> f ListWebhookItem
listWebhookItem_definition = (ListWebhookItem -> WebhookDefinition)
-> (ListWebhookItem -> WebhookDefinition -> ListWebhookItem)
-> Lens
     ListWebhookItem ListWebhookItem WebhookDefinition WebhookDefinition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {WebhookDefinition
definition :: WebhookDefinition
$sel:definition:ListWebhookItem' :: ListWebhookItem -> WebhookDefinition
definition} -> WebhookDefinition
definition) (\s :: ListWebhookItem
s@ListWebhookItem' {} WebhookDefinition
a -> ListWebhookItem
s {$sel:definition:ListWebhookItem' :: WebhookDefinition
definition = WebhookDefinition
a} :: ListWebhookItem)

-- | A unique URL generated by CodePipeline. When a POST request is made to
-- this URL, the defined pipeline is started as long as the body of the
-- post request satisfies the defined authentication and filtering
-- conditions. Deleting and re-creating a webhook makes the old URL invalid
-- and generates a new one.
listWebhookItem_url :: Lens.Lens' ListWebhookItem Prelude.Text
listWebhookItem_url :: (Text -> f Text) -> ListWebhookItem -> f ListWebhookItem
listWebhookItem_url = (ListWebhookItem -> Text)
-> (ListWebhookItem -> Text -> ListWebhookItem)
-> Lens ListWebhookItem ListWebhookItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWebhookItem' {Text
url :: Text
$sel:url:ListWebhookItem' :: ListWebhookItem -> Text
url} -> Text
url) (\s :: ListWebhookItem
s@ListWebhookItem' {} Text
a -> ListWebhookItem
s {$sel:url:ListWebhookItem' :: Text
url = Text
a} :: ListWebhookItem)

instance Core.FromJSON ListWebhookItem where
  parseJSON :: Value -> Parser ListWebhookItem
parseJSON =
    String
-> (Object -> Parser ListWebhookItem)
-> Value
-> Parser ListWebhookItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ListWebhookItem"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe [Tag]
-> WebhookDefinition
-> Text
-> ListWebhookItem
ListWebhookItem'
            (Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe [Tag]
 -> WebhookDefinition
 -> Text
 -> ListWebhookItem)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe [Tag]
      -> WebhookDefinition
      -> Text
      -> ListWebhookItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"arn")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe [Tag]
   -> WebhookDefinition
   -> Text
   -> ListWebhookItem)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe [Tag]
      -> WebhookDefinition
      -> Text
      -> ListWebhookItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorCode")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe [Tag]
   -> WebhookDefinition
   -> Text
   -> ListWebhookItem)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe [Tag] -> WebhookDefinition -> Text -> ListWebhookItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastTriggered")
            Parser
  (Maybe Text
   -> Maybe [Tag] -> WebhookDefinition -> Text -> ListWebhookItem)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Tag] -> WebhookDefinition -> Text -> ListWebhookItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorMessage")
            Parser
  (Maybe [Tag] -> WebhookDefinition -> Text -> ListWebhookItem)
-> Parser (Maybe [Tag])
-> Parser (WebhookDefinition -> Text -> ListWebhookItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Tag]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tags" Parser (Maybe (Maybe [Tag])) -> Maybe [Tag] -> Parser (Maybe [Tag])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Tag]
forall a. Monoid a => a
Prelude.mempty)
            Parser (WebhookDefinition -> Text -> ListWebhookItem)
-> Parser WebhookDefinition -> Parser (Text -> ListWebhookItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser WebhookDefinition
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"definition")
            Parser (Text -> ListWebhookItem)
-> Parser Text -> Parser ListWebhookItem
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
"url")
      )

instance Prelude.Hashable ListWebhookItem

instance Prelude.NFData ListWebhookItem