{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Amplify.Types.Webhook where

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

-- | 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 :: Data.POSIX,
    -- | Updates the date and time for a webhook.
    Webhook -> POSIX
updateTime :: Data.POSIX
  }
  deriving (Webhook -> Webhook -> Bool
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]
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
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. 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'
      { $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 = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateTime_,
        $sel:updateTime:Webhook' :: POSIX
updateTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' Webhook Text
webhook_webhookArn = 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 :: Lens' Webhook Text
webhook_webhookId = 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 :: Lens' Webhook Text
webhook_webhookUrl = 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 :: Lens' Webhook Text
webhook_branchName = 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 :: Lens' Webhook Text
webhook_description = 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 :: Lens' Webhook UTCTime
webhook_createTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Updates the date and time for a webhook.
webhook_updateTime :: Lens.Lens' Webhook Prelude.UTCTime
webhook_updateTime :: Lens' Webhook UTCTime
webhook_updateTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable Webhook where
  hashWithSalt :: Int -> Webhook -> Int
hashWithSalt Int
_salt Webhook' {Text
POSIX
updateTime :: POSIX
createTime :: POSIX
description :: Text
branchName :: Text
webhookUrl :: Text
webhookId :: Text
webhookArn :: Text
$sel:updateTime:Webhook' :: Webhook -> POSIX
$sel:createTime:Webhook' :: Webhook -> POSIX
$sel:description:Webhook' :: Webhook -> Text
$sel:branchName:Webhook' :: Webhook -> Text
$sel:webhookUrl:Webhook' :: Webhook -> Text
$sel:webhookId:Webhook' :: Webhook -> Text
$sel:webhookArn:Webhook' :: Webhook -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
webhookArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
webhookId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
webhookUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
branchName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
createTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
updateTime

instance Prelude.NFData Webhook where
  rnf :: Webhook -> ()
rnf Webhook' {Text
POSIX
updateTime :: POSIX
createTime :: POSIX
description :: Text
branchName :: Text
webhookUrl :: Text
webhookId :: Text
webhookArn :: Text
$sel:updateTime:Webhook' :: Webhook -> POSIX
$sel:createTime:Webhook' :: Webhook -> POSIX
$sel:description:Webhook' :: Webhook -> Text
$sel:branchName:Webhook' :: Webhook -> Text
$sel:webhookUrl:Webhook' :: Webhook -> Text
$sel:webhookId:Webhook' :: Webhook -> Text
$sel:webhookArn:Webhook' :: Webhook -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
webhookArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
webhookId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
webhookUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
branchName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
createTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
updateTime