{-# 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-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)
--
-- 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.Lens as Lens
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
(ActivateEventSource -> ActivateEventSource -> Bool)
-> (ActivateEventSource -> ActivateEventSource -> Bool)
-> Eq ActivateEventSource
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]
(Int -> ReadS ActivateEventSource)
-> ReadS [ActivateEventSource]
-> ReadPrec ActivateEventSource
-> ReadPrec [ActivateEventSource]
-> Read 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
(Int -> ActivateEventSource -> ShowS)
-> (ActivateEventSource -> String)
-> ([ActivateEventSource] -> ShowS)
-> Show ActivateEventSource
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. ActivateEventSource -> Rep ActivateEventSource x)
-> (forall x. Rep ActivateEventSource x -> ActivateEventSource)
-> Generic ActivateEventSource
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' :: Text -> ActivateEventSource
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 :: (Text -> f Text) -> ActivateEventSource -> f ActivateEventSource
activateEventSource_name = (ActivateEventSource -> Text)
-> (ActivateEventSource -> Text -> ActivateEventSource)
-> Lens ActivateEventSource ActivateEventSource Text Text
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 :: ActivateEventSource -> Request ActivateEventSource
request = Service -> ActivateEventSource -> Request ActivateEventSource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ActivateEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateEventSource)))
response =
    AWSResponse ActivateEventSource
-> Logger
-> Service
-> Proxy ActivateEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateEventSource)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse ActivateEventSource
ActivateEventSourceResponse
ActivateEventSourceResponse'

instance Prelude.Hashable ActivateEventSource

instance Prelude.NFData ActivateEventSource

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

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

-- | /See:/ 'newActivateEventSourceResponse' smart constructor.
data ActivateEventSourceResponse = ActivateEventSourceResponse'
  {
  }
  deriving (ActivateEventSourceResponse -> ActivateEventSourceResponse -> Bool
(ActivateEventSourceResponse
 -> ActivateEventSourceResponse -> Bool)
-> (ActivateEventSourceResponse
    -> ActivateEventSourceResponse -> Bool)
-> Eq ActivateEventSourceResponse
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]
(Int -> ReadS ActivateEventSourceResponse)
-> ReadS [ActivateEventSourceResponse]
-> ReadPrec ActivateEventSourceResponse
-> ReadPrec [ActivateEventSourceResponse]
-> Read 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
(Int -> ActivateEventSourceResponse -> ShowS)
-> (ActivateEventSourceResponse -> String)
-> ([ActivateEventSourceResponse] -> ShowS)
-> Show ActivateEventSourceResponse
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.
 ActivateEventSourceResponse -> Rep ActivateEventSourceResponse x)
-> (forall x.
    Rep ActivateEventSourceResponse x -> ActivateEventSourceResponse)
-> Generic ActivateEventSourceResponse
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