{-# 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.DeregisterWebhookWithThirdParty
-- 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)
--
-- Removes the connection between the webhook that was created by
-- CodePipeline and the external tool with events to be detected. Currently
-- supported only for webhooks that target an action type of GitHub.
module Amazonka.CodePipeline.DeregisterWebhookWithThirdParty
  ( -- * Creating a Request
    DeregisterWebhookWithThirdParty (..),
    newDeregisterWebhookWithThirdParty,

    -- * Request Lenses
    deregisterWebhookWithThirdParty_webhookName,

    -- * Destructuring the Response
    DeregisterWebhookWithThirdPartyResponse (..),
    newDeregisterWebhookWithThirdPartyResponse,

    -- * Response Lenses
    deregisterWebhookWithThirdPartyResponse_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:/ 'newDeregisterWebhookWithThirdParty' smart constructor.
data DeregisterWebhookWithThirdParty = DeregisterWebhookWithThirdParty'
  { -- | The name of the webhook you want to deregister.
    DeregisterWebhookWithThirdParty -> Maybe Text
webhookName :: Prelude.Maybe Prelude.Text
  }
  deriving (DeregisterWebhookWithThirdParty
-> DeregisterWebhookWithThirdParty -> Bool
(DeregisterWebhookWithThirdParty
 -> DeregisterWebhookWithThirdParty -> Bool)
-> (DeregisterWebhookWithThirdParty
    -> DeregisterWebhookWithThirdParty -> Bool)
-> Eq DeregisterWebhookWithThirdParty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterWebhookWithThirdParty
-> DeregisterWebhookWithThirdParty -> Bool
$c/= :: DeregisterWebhookWithThirdParty
-> DeregisterWebhookWithThirdParty -> Bool
== :: DeregisterWebhookWithThirdParty
-> DeregisterWebhookWithThirdParty -> Bool
$c== :: DeregisterWebhookWithThirdParty
-> DeregisterWebhookWithThirdParty -> Bool
Prelude.Eq, ReadPrec [DeregisterWebhookWithThirdParty]
ReadPrec DeregisterWebhookWithThirdParty
Int -> ReadS DeregisterWebhookWithThirdParty
ReadS [DeregisterWebhookWithThirdParty]
(Int -> ReadS DeregisterWebhookWithThirdParty)
-> ReadS [DeregisterWebhookWithThirdParty]
-> ReadPrec DeregisterWebhookWithThirdParty
-> ReadPrec [DeregisterWebhookWithThirdParty]
-> Read DeregisterWebhookWithThirdParty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterWebhookWithThirdParty]
$creadListPrec :: ReadPrec [DeregisterWebhookWithThirdParty]
readPrec :: ReadPrec DeregisterWebhookWithThirdParty
$creadPrec :: ReadPrec DeregisterWebhookWithThirdParty
readList :: ReadS [DeregisterWebhookWithThirdParty]
$creadList :: ReadS [DeregisterWebhookWithThirdParty]
readsPrec :: Int -> ReadS DeregisterWebhookWithThirdParty
$creadsPrec :: Int -> ReadS DeregisterWebhookWithThirdParty
Prelude.Read, Int -> DeregisterWebhookWithThirdParty -> ShowS
[DeregisterWebhookWithThirdParty] -> ShowS
DeregisterWebhookWithThirdParty -> String
(Int -> DeregisterWebhookWithThirdParty -> ShowS)
-> (DeregisterWebhookWithThirdParty -> String)
-> ([DeregisterWebhookWithThirdParty] -> ShowS)
-> Show DeregisterWebhookWithThirdParty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterWebhookWithThirdParty] -> ShowS
$cshowList :: [DeregisterWebhookWithThirdParty] -> ShowS
show :: DeregisterWebhookWithThirdParty -> String
$cshow :: DeregisterWebhookWithThirdParty -> String
showsPrec :: Int -> DeregisterWebhookWithThirdParty -> ShowS
$cshowsPrec :: Int -> DeregisterWebhookWithThirdParty -> ShowS
Prelude.Show, (forall x.
 DeregisterWebhookWithThirdParty
 -> Rep DeregisterWebhookWithThirdParty x)
-> (forall x.
    Rep DeregisterWebhookWithThirdParty x
    -> DeregisterWebhookWithThirdParty)
-> Generic DeregisterWebhookWithThirdParty
forall x.
Rep DeregisterWebhookWithThirdParty x
-> DeregisterWebhookWithThirdParty
forall x.
DeregisterWebhookWithThirdParty
-> Rep DeregisterWebhookWithThirdParty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterWebhookWithThirdParty x
-> DeregisterWebhookWithThirdParty
$cfrom :: forall x.
DeregisterWebhookWithThirdParty
-> Rep DeregisterWebhookWithThirdParty x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterWebhookWithThirdParty' 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', 'deregisterWebhookWithThirdParty_webhookName' - The name of the webhook you want to deregister.
newDeregisterWebhookWithThirdParty ::
  DeregisterWebhookWithThirdParty
newDeregisterWebhookWithThirdParty :: DeregisterWebhookWithThirdParty
newDeregisterWebhookWithThirdParty =
  DeregisterWebhookWithThirdParty' :: Maybe Text -> DeregisterWebhookWithThirdParty
DeregisterWebhookWithThirdParty'
    { $sel:webhookName:DeregisterWebhookWithThirdParty' :: Maybe Text
webhookName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the webhook you want to deregister.
deregisterWebhookWithThirdParty_webhookName :: Lens.Lens' DeregisterWebhookWithThirdParty (Prelude.Maybe Prelude.Text)
deregisterWebhookWithThirdParty_webhookName :: (Maybe Text -> f (Maybe Text))
-> DeregisterWebhookWithThirdParty
-> f DeregisterWebhookWithThirdParty
deregisterWebhookWithThirdParty_webhookName = (DeregisterWebhookWithThirdParty -> Maybe Text)
-> (DeregisterWebhookWithThirdParty
    -> Maybe Text -> DeregisterWebhookWithThirdParty)
-> Lens
     DeregisterWebhookWithThirdParty
     DeregisterWebhookWithThirdParty
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterWebhookWithThirdParty' {Maybe Text
webhookName :: Maybe Text
$sel:webhookName:DeregisterWebhookWithThirdParty' :: DeregisterWebhookWithThirdParty -> Maybe Text
webhookName} -> Maybe Text
webhookName) (\s :: DeregisterWebhookWithThirdParty
s@DeregisterWebhookWithThirdParty' {} Maybe Text
a -> DeregisterWebhookWithThirdParty
s {$sel:webhookName:DeregisterWebhookWithThirdParty' :: Maybe Text
webhookName = Maybe Text
a} :: DeregisterWebhookWithThirdParty)

instance
  Core.AWSRequest
    DeregisterWebhookWithThirdParty
  where
  type
    AWSResponse DeregisterWebhookWithThirdParty =
      DeregisterWebhookWithThirdPartyResponse
  request :: DeregisterWebhookWithThirdParty
-> Request DeregisterWebhookWithThirdParty
request = Service
-> DeregisterWebhookWithThirdParty
-> Request DeregisterWebhookWithThirdParty
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterWebhookWithThirdParty
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DeregisterWebhookWithThirdParty)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeregisterWebhookWithThirdParty))
-> Logger
-> Service
-> Proxy DeregisterWebhookWithThirdParty
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DeregisterWebhookWithThirdParty)))
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 -> DeregisterWebhookWithThirdPartyResponse
DeregisterWebhookWithThirdPartyResponse'
            (Int -> DeregisterWebhookWithThirdPartyResponse)
-> Either String Int
-> Either String DeregisterWebhookWithThirdPartyResponse
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
    DeregisterWebhookWithThirdParty

instance
  Prelude.NFData
    DeregisterWebhookWithThirdParty

instance
  Core.ToHeaders
    DeregisterWebhookWithThirdParty
  where
  toHeaders :: DeregisterWebhookWithThirdParty -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DeregisterWebhookWithThirdParty -> 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.DeregisterWebhookWithThirdParty" ::
                          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 DeregisterWebhookWithThirdParty where
  toJSON :: DeregisterWebhookWithThirdParty -> Value
toJSON DeregisterWebhookWithThirdParty' {Maybe Text
webhookName :: Maybe Text
$sel:webhookName:DeregisterWebhookWithThirdParty' :: DeregisterWebhookWithThirdParty -> 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 DeregisterWebhookWithThirdParty where
  toPath :: DeregisterWebhookWithThirdParty -> ByteString
toPath = ByteString -> DeregisterWebhookWithThirdParty -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance
  Prelude.NFData
    DeregisterWebhookWithThirdPartyResponse