{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' DeactivateEventSource Text
deactivateEventSource_name = 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 :: (Service -> Service)
-> DeactivateEventSource -> Request DeactivateEventSource
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeactivateEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeactivateEventSource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeactivateEventSourceResponse
DeactivateEventSourceResponse'

instance Prelude.Hashable DeactivateEventSource where
  hashWithSalt :: Int -> DeactivateEventSource -> Int
hashWithSalt Int
_salt DeactivateEventSource' {Text
name :: Text
$sel:name:DeactivateEventSource' :: DeactivateEventSource -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeactivateEventSource where
  rnf :: DeactivateEventSource -> ()
rnf DeactivateEventSource' {Text
name :: Text
$sel:name:DeactivateEventSource' :: DeactivateEventSource -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

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

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

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

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

-- | /See:/ 'newDeactivateEventSourceResponse' smart constructor.
data DeactivateEventSourceResponse = DeactivateEventSourceResponse'
  {
  }
  deriving (DeactivateEventSourceResponse
-> DeactivateEventSourceResponse -> Bool
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]
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
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.
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 where
  rnf :: DeactivateEventSourceResponse -> ()
rnf DeactivateEventSourceResponse
_ = ()