{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 text of the error message about the webhook.
    ListWebhookItem -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The date and time a webhook was last successfully triggered, in
    -- timestamp format.
    ListWebhookItem -> Maybe POSIX
lastTriggered :: Prelude.Maybe Data.POSIX,
    -- | 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
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]
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
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. 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.
--
-- 'errorMessage', 'listWebhookItem_errorMessage' - The text of the error message about the webhook.
--
-- 'lastTriggered', 'listWebhookItem_lastTriggered' - The date and time a webhook was last successfully triggered, in
-- timestamp format.
--
-- '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'
    { $sel:arn:ListWebhookItem' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:ListWebhookItem' :: Maybe Text
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ListWebhookItem' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:lastTriggered:ListWebhookItem' :: Maybe POSIX
lastTriggered = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ListWebhookItem' :: Maybe [Tag]
tags = 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 :: Lens' ListWebhookItem (Maybe Text)
listWebhookItem_arn = 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 :: Lens' ListWebhookItem (Maybe Text)
listWebhookItem_errorCode = 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 text of the error message about the webhook.
listWebhookItem_errorMessage :: Lens.Lens' ListWebhookItem (Prelude.Maybe Prelude.Text)
listWebhookItem_errorMessage :: Lens' ListWebhookItem (Maybe Text)
listWebhookItem_errorMessage = 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)

-- | The date and time a webhook was last successfully triggered, in
-- timestamp format.
listWebhookItem_lastTriggered :: Lens.Lens' ListWebhookItem (Prelude.Maybe Prelude.UTCTime)
listWebhookItem_lastTriggered :: Lens' ListWebhookItem (Maybe UTCTime)
listWebhookItem_lastTriggered = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Specifies the tags applied to the webhook.
listWebhookItem_tags :: Lens.Lens' ListWebhookItem (Prelude.Maybe [Tag])
listWebhookItem_tags :: Lens' ListWebhookItem (Maybe [Tag])
listWebhookItem_tags = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ListWebhookItem WebhookDefinition
listWebhookItem_definition = 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 :: Lens' ListWebhookItem Text
listWebhookItem_url = 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 Data.FromJSON ListWebhookItem where
  parseJSON :: Value -> Parser ListWebhookItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ListWebhookItem"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe [Tag]
-> WebhookDefinition
-> Text
-> ListWebhookItem
ListWebhookItem'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"errorCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"errorMessage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lastTriggered")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"definition")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"url")
      )

instance Prelude.Hashable ListWebhookItem where
  hashWithSalt :: Int -> ListWebhookItem -> Int
hashWithSalt Int
_salt ListWebhookItem' {Maybe [Tag]
Maybe Text
Maybe POSIX
Text
WebhookDefinition
url :: Text
definition :: WebhookDefinition
tags :: Maybe [Tag]
lastTriggered :: Maybe POSIX
errorMessage :: Maybe Text
errorCode :: Maybe Text
arn :: Maybe Text
$sel:url:ListWebhookItem' :: ListWebhookItem -> Text
$sel:definition:ListWebhookItem' :: ListWebhookItem -> WebhookDefinition
$sel:tags:ListWebhookItem' :: ListWebhookItem -> Maybe [Tag]
$sel:lastTriggered:ListWebhookItem' :: ListWebhookItem -> Maybe POSIX
$sel:errorMessage:ListWebhookItem' :: ListWebhookItem -> Maybe Text
$sel:errorCode:ListWebhookItem' :: ListWebhookItem -> Maybe Text
$sel:arn:ListWebhookItem' :: ListWebhookItem -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastTriggered
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` WebhookDefinition
definition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
url

instance Prelude.NFData ListWebhookItem where
  rnf :: ListWebhookItem -> ()
rnf ListWebhookItem' {Maybe [Tag]
Maybe Text
Maybe POSIX
Text
WebhookDefinition
url :: Text
definition :: WebhookDefinition
tags :: Maybe [Tag]
lastTriggered :: Maybe POSIX
errorMessage :: Maybe Text
errorCode :: Maybe Text
arn :: Maybe Text
$sel:url:ListWebhookItem' :: ListWebhookItem -> Text
$sel:definition:ListWebhookItem' :: ListWebhookItem -> WebhookDefinition
$sel:tags:ListWebhookItem' :: ListWebhookItem -> Maybe [Tag]
$sel:lastTriggered:ListWebhookItem' :: ListWebhookItem -> Maybe POSIX
$sel:errorMessage:ListWebhookItem' :: ListWebhookItem -> Maybe Text
$sel:errorCode:ListWebhookItem' :: ListWebhookItem -> Maybe Text
$sel:arn:ListWebhookItem' :: ListWebhookItem -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastTriggered
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf WebhookDefinition
definition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
url