{-# 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.Amplify.Types.Webhook
-- 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.Amplify.Types.Webhook where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a webhook that connects repository events to an Amplify app.
--
-- /See:/ 'newWebhook' smart constructor.
data Webhook = Webhook'
  { -- | The Amazon Resource Name (ARN) for the webhook.
    Webhook -> Text
webhookArn :: Prelude.Text,
    -- | The ID of the webhook.
    Webhook -> Text
webhookId :: Prelude.Text,
    -- | The URL of the webhook.
    Webhook -> Text
webhookUrl :: Prelude.Text,
    -- | The name for a branch that is part of an Amplify app.
    Webhook -> Text
branchName :: Prelude.Text,
    -- | The description for a webhook.
    Webhook -> Text
description :: Prelude.Text,
    -- | The create date and time for a webhook.
    Webhook -> POSIX
createTime :: Core.POSIX,
    -- | Updates the date and time for a webhook.
    Webhook -> POSIX
updateTime :: Core.POSIX
  }
  deriving (Webhook -> Webhook -> Bool
(Webhook -> Webhook -> Bool)
-> (Webhook -> Webhook -> Bool) -> Eq Webhook
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Webhook -> Webhook -> Bool
$c/= :: Webhook -> Webhook -> Bool
== :: Webhook -> Webhook -> Bool
$c== :: Webhook -> Webhook -> Bool
Prelude.Eq, ReadPrec [Webhook]
ReadPrec Webhook
Int -> ReadS Webhook
ReadS [Webhook]
(Int -> ReadS Webhook)
-> ReadS [Webhook]
-> ReadPrec Webhook
-> ReadPrec [Webhook]
-> Read Webhook
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Webhook]
$creadListPrec :: ReadPrec [Webhook]
readPrec :: ReadPrec Webhook
$creadPrec :: ReadPrec Webhook
readList :: ReadS [Webhook]
$creadList :: ReadS [Webhook]
readsPrec :: Int -> ReadS Webhook
$creadsPrec :: Int -> ReadS Webhook
Prelude.Read, Int -> Webhook -> ShowS
[Webhook] -> ShowS
Webhook -> String
(Int -> Webhook -> ShowS)
-> (Webhook -> String) -> ([Webhook] -> ShowS) -> Show Webhook
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Webhook] -> ShowS
$cshowList :: [Webhook] -> ShowS
show :: Webhook -> String
$cshow :: Webhook -> String
showsPrec :: Int -> Webhook -> ShowS
$cshowsPrec :: Int -> Webhook -> ShowS
Prelude.Show, (forall x. Webhook -> Rep Webhook x)
-> (forall x. Rep Webhook x -> Webhook) -> Generic Webhook
forall x. Rep Webhook x -> Webhook
forall x. Webhook -> Rep Webhook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Webhook x -> Webhook
$cfrom :: forall x. Webhook -> Rep Webhook x
Prelude.Generic)

-- |
-- Create a value of 'Webhook' 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:
--
-- 'webhookArn', 'webhook_webhookArn' - The Amazon Resource Name (ARN) for the webhook.
--
-- 'webhookId', 'webhook_webhookId' - The ID of the webhook.
--
-- 'webhookUrl', 'webhook_webhookUrl' - The URL of the webhook.
--
-- 'branchName', 'webhook_branchName' - The name for a branch that is part of an Amplify app.
--
-- 'description', 'webhook_description' - The description for a webhook.
--
-- 'createTime', 'webhook_createTime' - The create date and time for a webhook.
--
-- 'updateTime', 'webhook_updateTime' - Updates the date and time for a webhook.
newWebhook ::
  -- | 'webhookArn'
  Prelude.Text ->
  -- | 'webhookId'
  Prelude.Text ->
  -- | 'webhookUrl'
  Prelude.Text ->
  -- | 'branchName'
  Prelude.Text ->
  -- | 'description'
  Prelude.Text ->
  -- | 'createTime'
  Prelude.UTCTime ->
  -- | 'updateTime'
  Prelude.UTCTime ->
  Webhook
newWebhook :: Text
-> Text -> Text -> Text -> Text -> UTCTime -> UTCTime -> Webhook
newWebhook
  Text
pWebhookArn_
  Text
pWebhookId_
  Text
pWebhookUrl_
  Text
pBranchName_
  Text
pDescription_
  UTCTime
pCreateTime_
  UTCTime
pUpdateTime_ =
    Webhook' :: Text -> Text -> Text -> Text -> Text -> POSIX -> POSIX -> Webhook
Webhook'
      { $sel:webhookArn:Webhook' :: Text
webhookArn = Text
pWebhookArn_,
        $sel:webhookId:Webhook' :: Text
webhookId = Text
pWebhookId_,
        $sel:webhookUrl:Webhook' :: Text
webhookUrl = Text
pWebhookUrl_,
        $sel:branchName:Webhook' :: Text
branchName = Text
pBranchName_,
        $sel:description:Webhook' :: Text
description = Text
pDescription_,
        $sel:createTime:Webhook' :: POSIX
createTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateTime_,
        $sel:updateTime:Webhook' :: POSIX
updateTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUpdateTime_
      }

-- | The Amazon Resource Name (ARN) for the webhook.
webhook_webhookArn :: Lens.Lens' Webhook Prelude.Text
webhook_webhookArn :: (Text -> f Text) -> Webhook -> f Webhook
webhook_webhookArn = (Webhook -> Text)
-> (Webhook -> Text -> Webhook) -> Lens Webhook Webhook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {Text
webhookArn :: Text
$sel:webhookArn:Webhook' :: Webhook -> Text
webhookArn} -> Text
webhookArn) (\s :: Webhook
s@Webhook' {} Text
a -> Webhook
s {$sel:webhookArn:Webhook' :: Text
webhookArn = Text
a} :: Webhook)

-- | The ID of the webhook.
webhook_webhookId :: Lens.Lens' Webhook Prelude.Text
webhook_webhookId :: (Text -> f Text) -> Webhook -> f Webhook
webhook_webhookId = (Webhook -> Text)
-> (Webhook -> Text -> Webhook) -> Lens Webhook Webhook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {Text
webhookId :: Text
$sel:webhookId:Webhook' :: Webhook -> Text
webhookId} -> Text
webhookId) (\s :: Webhook
s@Webhook' {} Text
a -> Webhook
s {$sel:webhookId:Webhook' :: Text
webhookId = Text
a} :: Webhook)

-- | The URL of the webhook.
webhook_webhookUrl :: Lens.Lens' Webhook Prelude.Text
webhook_webhookUrl :: (Text -> f Text) -> Webhook -> f Webhook
webhook_webhookUrl = (Webhook -> Text)
-> (Webhook -> Text -> Webhook) -> Lens Webhook Webhook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {Text
webhookUrl :: Text
$sel:webhookUrl:Webhook' :: Webhook -> Text
webhookUrl} -> Text
webhookUrl) (\s :: Webhook
s@Webhook' {} Text
a -> Webhook
s {$sel:webhookUrl:Webhook' :: Text
webhookUrl = Text
a} :: Webhook)

-- | The name for a branch that is part of an Amplify app.
webhook_branchName :: Lens.Lens' Webhook Prelude.Text
webhook_branchName :: (Text -> f Text) -> Webhook -> f Webhook
webhook_branchName = (Webhook -> Text)
-> (Webhook -> Text -> Webhook) -> Lens Webhook Webhook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {Text
branchName :: Text
$sel:branchName:Webhook' :: Webhook -> Text
branchName} -> Text
branchName) (\s :: Webhook
s@Webhook' {} Text
a -> Webhook
s {$sel:branchName:Webhook' :: Text
branchName = Text
a} :: Webhook)

-- | The description for a webhook.
webhook_description :: Lens.Lens' Webhook Prelude.Text
webhook_description :: (Text -> f Text) -> Webhook -> f Webhook
webhook_description = (Webhook -> Text)
-> (Webhook -> Text -> Webhook) -> Lens Webhook Webhook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {Text
description :: Text
$sel:description:Webhook' :: Webhook -> Text
description} -> Text
description) (\s :: Webhook
s@Webhook' {} Text
a -> Webhook
s {$sel:description:Webhook' :: Text
description = Text
a} :: Webhook)

-- | The create date and time for a webhook.
webhook_createTime :: Lens.Lens' Webhook Prelude.UTCTime
webhook_createTime :: (UTCTime -> f UTCTime) -> Webhook -> f Webhook
webhook_createTime = (Webhook -> POSIX)
-> (Webhook -> POSIX -> Webhook)
-> Lens Webhook Webhook POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {POSIX
createTime :: POSIX
$sel:createTime:Webhook' :: Webhook -> POSIX
createTime} -> POSIX
createTime) (\s :: Webhook
s@Webhook' {} POSIX
a -> Webhook
s {$sel:createTime:Webhook' :: POSIX
createTime = POSIX
a} :: Webhook) ((POSIX -> f POSIX) -> Webhook -> f Webhook)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Webhook
-> f Webhook
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Updates the date and time for a webhook.
webhook_updateTime :: Lens.Lens' Webhook Prelude.UTCTime
webhook_updateTime :: (UTCTime -> f UTCTime) -> Webhook -> f Webhook
webhook_updateTime = (Webhook -> POSIX)
-> (Webhook -> POSIX -> Webhook)
-> Lens Webhook Webhook POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Webhook' {POSIX
updateTime :: POSIX
$sel:updateTime:Webhook' :: Webhook -> POSIX
updateTime} -> POSIX
updateTime) (\s :: Webhook
s@Webhook' {} POSIX
a -> Webhook
s {$sel:updateTime:Webhook' :: POSIX
updateTime = POSIX
a} :: Webhook) ((POSIX -> f POSIX) -> Webhook -> f Webhook)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Webhook
-> f Webhook
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Webhook where
  parseJSON :: Value -> Parser Webhook
parseJSON =
    String -> (Object -> Parser Webhook) -> Value -> Parser Webhook
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Webhook"
      ( \Object
x ->
          Text -> Text -> Text -> Text -> Text -> POSIX -> POSIX -> Webhook
Webhook'
            (Text -> Text -> Text -> Text -> Text -> POSIX -> POSIX -> Webhook)
-> Parser Text
-> Parser
     (Text -> Text -> Text -> Text -> POSIX -> POSIX -> Webhook)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"webhookArn")
            Parser (Text -> Text -> Text -> Text -> POSIX -> POSIX -> Webhook)
-> Parser Text
-> Parser (Text -> Text -> Text -> POSIX -> POSIX -> Webhook)
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
"webhookId")
            Parser (Text -> Text -> Text -> POSIX -> POSIX -> Webhook)
-> Parser Text
-> Parser (Text -> Text -> POSIX -> POSIX -> Webhook)
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
"webhookUrl")
            Parser (Text -> Text -> POSIX -> POSIX -> Webhook)
-> Parser Text -> Parser (Text -> POSIX -> POSIX -> Webhook)
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
"branchName")
            Parser (Text -> POSIX -> POSIX -> Webhook)
-> Parser Text -> Parser (POSIX -> POSIX -> Webhook)
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
"description")
            Parser (POSIX -> POSIX -> Webhook)
-> Parser POSIX -> Parser (POSIX -> Webhook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"createTime")
            Parser (POSIX -> Webhook) -> Parser POSIX -> Parser Webhook
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"updateTime")
      )

instance Prelude.Hashable Webhook

instance Prelude.NFData Webhook