{-# 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.ActivateEventSource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates a partner event source that has been deactivated. Once
-- activated, your matching event bus will start receiving events from the
-- event source.
module Amazonka.CloudWatchEvents.ActivateEventSource
  ( -- * Creating a Request
    ActivateEventSource (..),
    newActivateEventSource,

    -- * Request Lenses
    activateEventSource_name,

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

-- |
-- Create a value of 'ActivateEventSource' 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', 'activateEventSource_name' - The name of the partner event source to activate.
newActivateEventSource ::
  -- | 'name'
  Prelude.Text ->
  ActivateEventSource
newActivateEventSource :: Text -> ActivateEventSource
newActivateEventSource Text
pName_ =
  ActivateEventSource' {$sel:name:ActivateEventSource' :: Text
name = Text
pName_}

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

instance Core.AWSRequest ActivateEventSource where
  type
    AWSResponse ActivateEventSource =
      ActivateEventSourceResponse
  request :: (Service -> Service)
-> ActivateEventSource -> Request ActivateEventSource
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 ActivateEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateEventSource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull ActivateEventSourceResponse
ActivateEventSourceResponse'

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

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

instance Data.ToHeaders ActivateEventSource where
  toHeaders :: ActivateEventSource -> [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.ActivateEventSource" ::
                          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 ActivateEventSource where
  toJSON :: ActivateEventSource -> Value
toJSON ActivateEventSource' {Text
name :: Text
$sel:name:ActivateEventSource' :: ActivateEventSource -> 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 ActivateEventSource where
  toPath :: ActivateEventSource -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

instance Prelude.NFData ActivateEventSourceResponse where
  rnf :: ActivateEventSourceResponse -> ()
rnf ActivateEventSourceResponse
_ = ()