{-# 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.IoT.EnableTopicRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enables the rule.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions EnableTopicRule>
-- action.
module Amazonka.IoT.EnableTopicRule
  ( -- * Creating a Request
    EnableTopicRule (..),
    newEnableTopicRule,

    -- * Request Lenses
    enableTopicRule_ruleName,

    -- * Destructuring the Response
    EnableTopicRuleResponse (..),
    newEnableTopicRuleResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the EnableTopicRuleRequest operation.
--
-- /See:/ 'newEnableTopicRule' smart constructor.
data EnableTopicRule = EnableTopicRule'
  { -- | The name of the topic rule to enable.
    EnableTopicRule -> Text
ruleName :: Prelude.Text
  }
  deriving (EnableTopicRule -> EnableTopicRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableTopicRule -> EnableTopicRule -> Bool
$c/= :: EnableTopicRule -> EnableTopicRule -> Bool
== :: EnableTopicRule -> EnableTopicRule -> Bool
$c== :: EnableTopicRule -> EnableTopicRule -> Bool
Prelude.Eq, ReadPrec [EnableTopicRule]
ReadPrec EnableTopicRule
Int -> ReadS EnableTopicRule
ReadS [EnableTopicRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableTopicRule]
$creadListPrec :: ReadPrec [EnableTopicRule]
readPrec :: ReadPrec EnableTopicRule
$creadPrec :: ReadPrec EnableTopicRule
readList :: ReadS [EnableTopicRule]
$creadList :: ReadS [EnableTopicRule]
readsPrec :: Int -> ReadS EnableTopicRule
$creadsPrec :: Int -> ReadS EnableTopicRule
Prelude.Read, Int -> EnableTopicRule -> ShowS
[EnableTopicRule] -> ShowS
EnableTopicRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableTopicRule] -> ShowS
$cshowList :: [EnableTopicRule] -> ShowS
show :: EnableTopicRule -> String
$cshow :: EnableTopicRule -> String
showsPrec :: Int -> EnableTopicRule -> ShowS
$cshowsPrec :: Int -> EnableTopicRule -> ShowS
Prelude.Show, forall x. Rep EnableTopicRule x -> EnableTopicRule
forall x. EnableTopicRule -> Rep EnableTopicRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableTopicRule x -> EnableTopicRule
$cfrom :: forall x. EnableTopicRule -> Rep EnableTopicRule x
Prelude.Generic)

-- |
-- Create a value of 'EnableTopicRule' 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:
--
-- 'ruleName', 'enableTopicRule_ruleName' - The name of the topic rule to enable.
newEnableTopicRule ::
  -- | 'ruleName'
  Prelude.Text ->
  EnableTopicRule
newEnableTopicRule :: Text -> EnableTopicRule
newEnableTopicRule Text
pRuleName_ =
  EnableTopicRule' {$sel:ruleName:EnableTopicRule' :: Text
ruleName = Text
pRuleName_}

-- | The name of the topic rule to enable.
enableTopicRule_ruleName :: Lens.Lens' EnableTopicRule Prelude.Text
enableTopicRule_ruleName :: Lens' EnableTopicRule Text
enableTopicRule_ruleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableTopicRule' {Text
ruleName :: Text
$sel:ruleName:EnableTopicRule' :: EnableTopicRule -> Text
ruleName} -> Text
ruleName) (\s :: EnableTopicRule
s@EnableTopicRule' {} Text
a -> EnableTopicRule
s {$sel:ruleName:EnableTopicRule' :: Text
ruleName = Text
a} :: EnableTopicRule)

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

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

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

instance Data.ToHeaders EnableTopicRule where
  toHeaders :: EnableTopicRule -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON EnableTopicRule where
  toJSON :: EnableTopicRule -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath EnableTopicRule where
  toPath :: EnableTopicRule -> ByteString
toPath EnableTopicRule' {Text
ruleName :: Text
$sel:ruleName:EnableTopicRule' :: EnableTopicRule -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/rules/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
ruleName, ByteString
"/enable"]

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

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

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

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