{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.RegisterWebhookWithThirdParty
-- 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)
--
-- Configures a connection between the webhook that was created and the
-- external tool with events to be detected.
module Amazonka.CodePipeline.RegisterWebhookWithThirdParty
  ( -- * Creating a Request
    RegisterWebhookWithThirdParty (..),
    newRegisterWebhookWithThirdParty,

    -- * Request Lenses
    registerWebhookWithThirdParty_webhookName,

    -- * Destructuring the Response
    RegisterWebhookWithThirdPartyResponse (..),
    newRegisterWebhookWithThirdPartyResponse,

    -- * Response Lenses
    registerWebhookWithThirdPartyResponse_httpStatus,
  )
where

import Amazonka.CodePipeline.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newRegisterWebhookWithThirdParty' smart constructor.
data RegisterWebhookWithThirdParty = RegisterWebhookWithThirdParty'
  { -- | The name of an existing webhook created with PutWebhook to register with
    -- a supported third party.
    RegisterWebhookWithThirdParty -> Maybe Text
webhookName :: Prelude.Maybe Prelude.Text
  }
  deriving (RegisterWebhookWithThirdParty
-> RegisterWebhookWithThirdParty -> Bool
(RegisterWebhookWithThirdParty
 -> RegisterWebhookWithThirdParty -> Bool)
-> (RegisterWebhookWithThirdParty
    -> RegisterWebhookWithThirdParty -> Bool)
-> Eq RegisterWebhookWithThirdParty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterWebhookWithThirdParty
-> RegisterWebhookWithThirdParty -> Bool
$c/= :: RegisterWebhookWithThirdParty
-> RegisterWebhookWithThirdParty -> Bool
== :: RegisterWebhookWithThirdParty
-> RegisterWebhookWithThirdParty -> Bool
$c== :: RegisterWebhookWithThirdParty
-> RegisterWebhookWithThirdParty -> Bool
Prelude.Eq, ReadPrec [RegisterWebhookWithThirdParty]
ReadPrec RegisterWebhookWithThirdParty
Int -> ReadS RegisterWebhookWithThirdParty
ReadS [RegisterWebhookWithThirdParty]
(Int -> ReadS RegisterWebhookWithThirdParty)
-> ReadS [RegisterWebhookWithThirdParty]
-> ReadPrec RegisterWebhookWithThirdParty
-> ReadPrec [RegisterWebhookWithThirdParty]
-> Read RegisterWebhookWithThirdParty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterWebhookWithThirdParty]
$creadListPrec :: ReadPrec [RegisterWebhookWithThirdParty]
readPrec :: ReadPrec RegisterWebhookWithThirdParty
$creadPrec :: ReadPrec RegisterWebhookWithThirdParty
readList :: ReadS [RegisterWebhookWithThirdParty]
$creadList :: ReadS [RegisterWebhookWithThirdParty]
readsPrec :: Int -> ReadS RegisterWebhookWithThirdParty
$creadsPrec :: Int -> ReadS RegisterWebhookWithThirdParty
Prelude.Read, Int -> RegisterWebhookWithThirdParty -> ShowS
[RegisterWebhookWithThirdParty] -> ShowS
RegisterWebhookWithThirdParty -> String
(Int -> RegisterWebhookWithThirdParty -> ShowS)
-> (RegisterWebhookWithThirdParty -> String)
-> ([RegisterWebhookWithThirdParty] -> ShowS)
-> Show RegisterWebhookWithThirdParty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterWebhookWithThirdParty] -> ShowS
$cshowList :: [RegisterWebhookWithThirdParty] -> ShowS
show :: RegisterWebhookWithThirdParty -> String
$cshow :: RegisterWebhookWithThirdParty -> String
showsPrec :: Int -> RegisterWebhookWithThirdParty -> ShowS
$cshowsPrec :: Int -> RegisterWebhookWithThirdParty -> ShowS
Prelude.Show, (forall x.
 RegisterWebhookWithThirdParty
 -> Rep RegisterWebhookWithThirdParty x)
-> (forall x.
    Rep RegisterWebhookWithThirdParty x
    -> RegisterWebhookWithThirdParty)
-> Generic RegisterWebhookWithThirdParty
forall x.
Rep RegisterWebhookWithThirdParty x
-> RegisterWebhookWithThirdParty
forall x.
RegisterWebhookWithThirdParty
-> Rep RegisterWebhookWithThirdParty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterWebhookWithThirdParty x
-> RegisterWebhookWithThirdParty
$cfrom :: forall x.
RegisterWebhookWithThirdParty
-> Rep RegisterWebhookWithThirdParty x
Prelude.Generic)

-- |
-- Create a value of 'RegisterWebhookWithThirdParty' 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:
--
-- 'webhookName', 'registerWebhookWithThirdParty_webhookName' - The name of an existing webhook created with PutWebhook to register with
-- a supported third party.
newRegisterWebhookWithThirdParty ::
  RegisterWebhookWithThirdParty
newRegisterWebhookWithThirdParty :: RegisterWebhookWithThirdParty
newRegisterWebhookWithThirdParty =
  RegisterWebhookWithThirdParty' :: Maybe Text -> RegisterWebhookWithThirdParty
RegisterWebhookWithThirdParty'
    { $sel:webhookName:RegisterWebhookWithThirdParty' :: Maybe Text
webhookName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of an existing webhook created with PutWebhook to register with
-- a supported third party.
registerWebhookWithThirdParty_webhookName :: Lens.Lens' RegisterWebhookWithThirdParty (Prelude.Maybe Prelude.Text)
registerWebhookWithThirdParty_webhookName :: (Maybe Text -> f (Maybe Text))
-> RegisterWebhookWithThirdParty -> f RegisterWebhookWithThirdParty
registerWebhookWithThirdParty_webhookName = (RegisterWebhookWithThirdParty -> Maybe Text)
-> (RegisterWebhookWithThirdParty
    -> Maybe Text -> RegisterWebhookWithThirdParty)
-> Lens
     RegisterWebhookWithThirdParty
     RegisterWebhookWithThirdParty
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterWebhookWithThirdParty' {Maybe Text
webhookName :: Maybe Text
$sel:webhookName:RegisterWebhookWithThirdParty' :: RegisterWebhookWithThirdParty -> Maybe Text
webhookName} -> Maybe Text
webhookName) (\s :: RegisterWebhookWithThirdParty
s@RegisterWebhookWithThirdParty' {} Maybe Text
a -> RegisterWebhookWithThirdParty
s {$sel:webhookName:RegisterWebhookWithThirdParty' :: Maybe Text
webhookName = Maybe Text
a} :: RegisterWebhookWithThirdParty)

instance
  Core.AWSRequest
    RegisterWebhookWithThirdParty
  where
  type
    AWSResponse RegisterWebhookWithThirdParty =
      RegisterWebhookWithThirdPartyResponse
  request :: RegisterWebhookWithThirdParty
-> Request RegisterWebhookWithThirdParty
request = Service
-> RegisterWebhookWithThirdParty
-> Request RegisterWebhookWithThirdParty
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RegisterWebhookWithThirdParty
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterWebhookWithThirdParty)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RegisterWebhookWithThirdParty))
-> Logger
-> Service
-> Proxy RegisterWebhookWithThirdParty
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterWebhookWithThirdParty)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RegisterWebhookWithThirdPartyResponse
RegisterWebhookWithThirdPartyResponse'
            (Int -> RegisterWebhookWithThirdPartyResponse)
-> Either String Int
-> Either String RegisterWebhookWithThirdPartyResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    RegisterWebhookWithThirdParty

instance Prelude.NFData RegisterWebhookWithThirdParty

instance Core.ToHeaders RegisterWebhookWithThirdParty where
  toHeaders :: RegisterWebhookWithThirdParty -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RegisterWebhookWithThirdParty -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodePipeline_20150709.RegisterWebhookWithThirdParty" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RegisterWebhookWithThirdParty where
  toJSON :: RegisterWebhookWithThirdParty -> Value
toJSON RegisterWebhookWithThirdParty' {Maybe Text
webhookName :: Maybe Text
$sel:webhookName:RegisterWebhookWithThirdParty' :: RegisterWebhookWithThirdParty -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"webhookName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
webhookName]
      )

instance Core.ToPath RegisterWebhookWithThirdParty where
  toPath :: RegisterWebhookWithThirdParty -> ByteString
toPath = ByteString -> RegisterWebhookWithThirdParty -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery RegisterWebhookWithThirdParty where
  toQuery :: RegisterWebhookWithThirdParty -> QueryString
toQuery = QueryString -> RegisterWebhookWithThirdParty -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newRegisterWebhookWithThirdPartyResponse' smart constructor.
data RegisterWebhookWithThirdPartyResponse = RegisterWebhookWithThirdPartyResponse'
  { -- | The response's http status code.
    RegisterWebhookWithThirdPartyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RegisterWebhookWithThirdPartyResponse
-> RegisterWebhookWithThirdPartyResponse -> Bool
(RegisterWebhookWithThirdPartyResponse
 -> RegisterWebhookWithThirdPartyResponse -> Bool)
-> (RegisterWebhookWithThirdPartyResponse
    -> RegisterWebhookWithThirdPartyResponse -> Bool)
-> Eq RegisterWebhookWithThirdPartyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterWebhookWithThirdPartyResponse
-> RegisterWebhookWithThirdPartyResponse -> Bool
$c/= :: RegisterWebhookWithThirdPartyResponse
-> RegisterWebhookWithThirdPartyResponse -> Bool
== :: RegisterWebhookWithThirdPartyResponse
-> RegisterWebhookWithThirdPartyResponse -> Bool
$c== :: RegisterWebhookWithThirdPartyResponse
-> RegisterWebhookWithThirdPartyResponse -> Bool
Prelude.Eq, ReadPrec [RegisterWebhookWithThirdPartyResponse]
ReadPrec RegisterWebhookWithThirdPartyResponse
Int -> ReadS RegisterWebhookWithThirdPartyResponse
ReadS [RegisterWebhookWithThirdPartyResponse]
(Int -> ReadS RegisterWebhookWithThirdPartyResponse)
-> ReadS [RegisterWebhookWithThirdPartyResponse]
-> ReadPrec RegisterWebhookWithThirdPartyResponse
-> ReadPrec [RegisterWebhookWithThirdPartyResponse]
-> Read RegisterWebhookWithThirdPartyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterWebhookWithThirdPartyResponse]
$creadListPrec :: ReadPrec [RegisterWebhookWithThirdPartyResponse]
readPrec :: ReadPrec RegisterWebhookWithThirdPartyResponse
$creadPrec :: ReadPrec RegisterWebhookWithThirdPartyResponse
readList :: ReadS [RegisterWebhookWithThirdPartyResponse]
$creadList :: ReadS [RegisterWebhookWithThirdPartyResponse]
readsPrec :: Int -> ReadS RegisterWebhookWithThirdPartyResponse
$creadsPrec :: Int -> ReadS RegisterWebhookWithThirdPartyResponse
Prelude.Read, Int -> RegisterWebhookWithThirdPartyResponse -> ShowS
[RegisterWebhookWithThirdPartyResponse] -> ShowS
RegisterWebhookWithThirdPartyResponse -> String
(Int -> RegisterWebhookWithThirdPartyResponse -> ShowS)
-> (RegisterWebhookWithThirdPartyResponse -> String)
-> ([RegisterWebhookWithThirdPartyResponse] -> ShowS)
-> Show RegisterWebhookWithThirdPartyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterWebhookWithThirdPartyResponse] -> ShowS
$cshowList :: [RegisterWebhookWithThirdPartyResponse] -> ShowS
show :: RegisterWebhookWithThirdPartyResponse -> String
$cshow :: RegisterWebhookWithThirdPartyResponse -> String
showsPrec :: Int -> RegisterWebhookWithThirdPartyResponse -> ShowS
$cshowsPrec :: Int -> RegisterWebhookWithThirdPartyResponse -> ShowS
Prelude.Show, (forall x.
 RegisterWebhookWithThirdPartyResponse
 -> Rep RegisterWebhookWithThirdPartyResponse x)
-> (forall x.
    Rep RegisterWebhookWithThirdPartyResponse x
    -> RegisterWebhookWithThirdPartyResponse)
-> Generic RegisterWebhookWithThirdPartyResponse
forall x.
Rep RegisterWebhookWithThirdPartyResponse x
-> RegisterWebhookWithThirdPartyResponse
forall x.
RegisterWebhookWithThirdPartyResponse
-> Rep RegisterWebhookWithThirdPartyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterWebhookWithThirdPartyResponse x
-> RegisterWebhookWithThirdPartyResponse
$cfrom :: forall x.
RegisterWebhookWithThirdPartyResponse
-> Rep RegisterWebhookWithThirdPartyResponse x
Prelude.Generic)

-- |
-- Create a value of 'RegisterWebhookWithThirdPartyResponse' 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:
--
-- 'httpStatus', 'registerWebhookWithThirdPartyResponse_httpStatus' - The response's http status code.
newRegisterWebhookWithThirdPartyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RegisterWebhookWithThirdPartyResponse
newRegisterWebhookWithThirdPartyResponse :: Int -> RegisterWebhookWithThirdPartyResponse
newRegisterWebhookWithThirdPartyResponse Int
pHttpStatus_ =
  RegisterWebhookWithThirdPartyResponse' :: Int -> RegisterWebhookWithThirdPartyResponse
RegisterWebhookWithThirdPartyResponse'
    { $sel:httpStatus:RegisterWebhookWithThirdPartyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
registerWebhookWithThirdPartyResponse_httpStatus :: Lens.Lens' RegisterWebhookWithThirdPartyResponse Prelude.Int
registerWebhookWithThirdPartyResponse_httpStatus :: (Int -> f Int)
-> RegisterWebhookWithThirdPartyResponse
-> f RegisterWebhookWithThirdPartyResponse
registerWebhookWithThirdPartyResponse_httpStatus = (RegisterWebhookWithThirdPartyResponse -> Int)
-> (RegisterWebhookWithThirdPartyResponse
    -> Int -> RegisterWebhookWithThirdPartyResponse)
-> Lens
     RegisterWebhookWithThirdPartyResponse
     RegisterWebhookWithThirdPartyResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterWebhookWithThirdPartyResponse' {Int
httpStatus :: Int
$sel:httpStatus:RegisterWebhookWithThirdPartyResponse' :: RegisterWebhookWithThirdPartyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RegisterWebhookWithThirdPartyResponse
s@RegisterWebhookWithThirdPartyResponse' {} Int
a -> RegisterWebhookWithThirdPartyResponse
s {$sel:httpStatus:RegisterWebhookWithThirdPartyResponse' :: Int
httpStatus = Int
a} :: RegisterWebhookWithThirdPartyResponse)

instance
  Prelude.NFData
    RegisterWebhookWithThirdPartyResponse