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

instance Prelude.Hashable EnableTopicRule

instance Prelude.NFData EnableTopicRule

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

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

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

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

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