{-# 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.CloudWatchEvents.DeactivateEventSource
-- 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)
--
-- You can use this operation to temporarily stop receiving events from the
-- specified partner event source. The matching event bus is not deleted.
--
-- When you deactivate a partner event source, the source goes into PENDING
-- state. If it remains in PENDING state for more than two weeks, it is
-- deleted.
--
-- To activate a deactivated partner event source, use
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ActivateEventSource.html ActivateEventSource>.
module Amazonka.CloudWatchEvents.DeactivateEventSource
  ( -- * Creating a Request
    DeactivateEventSource (..),
    newDeactivateEventSource,

    -- * Request Lenses
    deactivateEventSource_name,

    -- * Destructuring the Response
    DeactivateEventSourceResponse (..),
    newDeactivateEventSourceResponse,
  )
where

import Amazonka.CloudWatchEvents.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:/ 'newDeactivateEventSource' smart constructor.
data DeactivateEventSource = DeactivateEventSource'
  { -- | The name of the partner event source to deactivate.
    DeactivateEventSource -> Text
name :: Prelude.Text
  }
  deriving (DeactivateEventSource -> DeactivateEventSource -> Bool
(DeactivateEventSource -> DeactivateEventSource -> Bool)
-> (DeactivateEventSource -> DeactivateEventSource -> Bool)
-> Eq DeactivateEventSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeactivateEventSource -> DeactivateEventSource -> Bool
$c/= :: DeactivateEventSource -> DeactivateEventSource -> Bool
== :: DeactivateEventSource -> DeactivateEventSource -> Bool
$c== :: DeactivateEventSource -> DeactivateEventSource -> Bool
Prelude.Eq, ReadPrec [DeactivateEventSource]
ReadPrec DeactivateEventSource
Int -> ReadS DeactivateEventSource
ReadS [DeactivateEventSource]
(Int -> ReadS DeactivateEventSource)
-> ReadS [DeactivateEventSource]
-> ReadPrec DeactivateEventSource
-> ReadPrec [DeactivateEventSource]
-> Read DeactivateEventSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeactivateEventSource]
$creadListPrec :: ReadPrec [DeactivateEventSource]
readPrec :: ReadPrec DeactivateEventSource
$creadPrec :: ReadPrec DeactivateEventSource
readList :: ReadS [DeactivateEventSource]
$creadList :: ReadS [DeactivateEventSource]
readsPrec :: Int -> ReadS DeactivateEventSource
$creadsPrec :: Int -> ReadS DeactivateEventSource
Prelude.Read, Int -> DeactivateEventSource -> ShowS
[DeactivateEventSource] -> ShowS
DeactivateEventSource -> String
(Int -> DeactivateEventSource -> ShowS)
-> (DeactivateEventSource -> String)
-> ([DeactivateEventSource] -> ShowS)
-> Show DeactivateEventSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeactivateEventSource] -> ShowS
$cshowList :: [DeactivateEventSource] -> ShowS
show :: DeactivateEventSource -> String
$cshow :: DeactivateEventSource -> String
showsPrec :: Int -> DeactivateEventSource -> ShowS
$cshowsPrec :: Int -> DeactivateEventSource -> ShowS
Prelude.Show, (forall x. DeactivateEventSource -> Rep DeactivateEventSource x)
-> (forall x. Rep DeactivateEventSource x -> DeactivateEventSource)
-> Generic DeactivateEventSource
forall x. Rep DeactivateEventSource x -> DeactivateEventSource
forall x. DeactivateEventSource -> Rep DeactivateEventSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeactivateEventSource x -> DeactivateEventSource
$cfrom :: forall x. DeactivateEventSource -> Rep DeactivateEventSource x
Prelude.Generic)

-- |
-- Create a value of 'DeactivateEventSource' 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:
--
-- 'name', 'deactivateEventSource_name' - The name of the partner event source to deactivate.
newDeactivateEventSource ::
  -- | 'name'
  Prelude.Text ->
  DeactivateEventSource
newDeactivateEventSource :: Text -> DeactivateEventSource
newDeactivateEventSource Text
pName_ =
  DeactivateEventSource' :: Text -> DeactivateEventSource
DeactivateEventSource' {$sel:name:DeactivateEventSource' :: Text
name = Text
pName_}

-- | The name of the partner event source to deactivate.
deactivateEventSource_name :: Lens.Lens' DeactivateEventSource Prelude.Text
deactivateEventSource_name :: (Text -> f Text)
-> DeactivateEventSource -> f DeactivateEventSource
deactivateEventSource_name = (DeactivateEventSource -> Text)
-> (DeactivateEventSource -> Text -> DeactivateEventSource)
-> Lens DeactivateEventSource DeactivateEventSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeactivateEventSource' {Text
name :: Text
$sel:name:DeactivateEventSource' :: DeactivateEventSource -> Text
name} -> Text
name) (\s :: DeactivateEventSource
s@DeactivateEventSource' {} Text
a -> DeactivateEventSource
s {$sel:name:DeactivateEventSource' :: Text
name = Text
a} :: DeactivateEventSource)

instance Core.AWSRequest DeactivateEventSource where
  type
    AWSResponse DeactivateEventSource =
      DeactivateEventSourceResponse
  request :: DeactivateEventSource -> Request DeactivateEventSource
request = Service -> DeactivateEventSource -> Request DeactivateEventSource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeactivateEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeactivateEventSource)))
response =
    AWSResponse DeactivateEventSource
-> Logger
-> Service
-> Proxy DeactivateEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeactivateEventSource)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeactivateEventSource
DeactivateEventSourceResponse
DeactivateEventSourceResponse'

instance Prelude.Hashable DeactivateEventSource

instance Prelude.NFData DeactivateEventSource

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

instance Core.ToJSON DeactivateEventSource where
  toJSON :: DeactivateEventSource -> Value
toJSON DeactivateEventSource' {Text
name :: Text
$sel:name:DeactivateEventSource' :: DeactivateEventSource -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

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

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

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

-- |
-- Create a value of 'DeactivateEventSourceResponse' 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.
newDeactivateEventSourceResponse ::
  DeactivateEventSourceResponse
newDeactivateEventSourceResponse :: DeactivateEventSourceResponse
newDeactivateEventSourceResponse =
  DeactivateEventSourceResponse
DeactivateEventSourceResponse'

instance Prelude.NFData DeactivateEventSourceResponse