{-# 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.DisableRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables the specified rule. A disabled rule won\'t match any events,
-- and won\'t self-trigger if it has a schedule expression.
--
-- When you disable a rule, incoming events might continue to match to the
-- disabled rule. Allow a short period of time for changes to take effect.
module Amazonka.CloudWatchEvents.DisableRule
  ( -- * Creating a Request
    DisableRule (..),
    newDisableRule,

    -- * Request Lenses
    disableRule_eventBusName,
    disableRule_name,

    -- * Destructuring the Response
    DisableRuleResponse (..),
    newDisableRuleResponse,
  )
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:/ 'newDisableRule' smart constructor.
data DisableRule = DisableRule'
  { -- | The name or ARN of the event bus associated with the rule. If you omit
    -- this, the default event bus is used.
    DisableRule -> Maybe Text
eventBusName :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule.
    DisableRule -> Text
name :: Prelude.Text
  }
  deriving (DisableRule -> DisableRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableRule -> DisableRule -> Bool
$c/= :: DisableRule -> DisableRule -> Bool
== :: DisableRule -> DisableRule -> Bool
$c== :: DisableRule -> DisableRule -> Bool
Prelude.Eq, ReadPrec [DisableRule]
ReadPrec DisableRule
Int -> ReadS DisableRule
ReadS [DisableRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableRule]
$creadListPrec :: ReadPrec [DisableRule]
readPrec :: ReadPrec DisableRule
$creadPrec :: ReadPrec DisableRule
readList :: ReadS [DisableRule]
$creadList :: ReadS [DisableRule]
readsPrec :: Int -> ReadS DisableRule
$creadsPrec :: Int -> ReadS DisableRule
Prelude.Read, Int -> DisableRule -> ShowS
[DisableRule] -> ShowS
DisableRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableRule] -> ShowS
$cshowList :: [DisableRule] -> ShowS
show :: DisableRule -> String
$cshow :: DisableRule -> String
showsPrec :: Int -> DisableRule -> ShowS
$cshowsPrec :: Int -> DisableRule -> ShowS
Prelude.Show, forall x. Rep DisableRule x -> DisableRule
forall x. DisableRule -> Rep DisableRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableRule x -> DisableRule
$cfrom :: forall x. DisableRule -> Rep DisableRule x
Prelude.Generic)

-- |
-- Create a value of 'DisableRule' 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:
--
-- 'eventBusName', 'disableRule_eventBusName' - The name or ARN of the event bus associated with the rule. If you omit
-- this, the default event bus is used.
--
-- 'name', 'disableRule_name' - The name of the rule.
newDisableRule ::
  -- | 'name'
  Prelude.Text ->
  DisableRule
newDisableRule :: Text -> DisableRule
newDisableRule Text
pName_ =
  DisableRule'
    { $sel:eventBusName:DisableRule' :: Maybe Text
eventBusName = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DisableRule' :: Text
name = Text
pName_
    }

-- | The name or ARN of the event bus associated with the rule. If you omit
-- this, the default event bus is used.
disableRule_eventBusName :: Lens.Lens' DisableRule (Prelude.Maybe Prelude.Text)
disableRule_eventBusName :: Lens' DisableRule (Maybe Text)
disableRule_eventBusName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableRule' {Maybe Text
eventBusName :: Maybe Text
$sel:eventBusName:DisableRule' :: DisableRule -> Maybe Text
eventBusName} -> Maybe Text
eventBusName) (\s :: DisableRule
s@DisableRule' {} Maybe Text
a -> DisableRule
s {$sel:eventBusName:DisableRule' :: Maybe Text
eventBusName = Maybe Text
a} :: DisableRule)

-- | The name of the rule.
disableRule_name :: Lens.Lens' DisableRule Prelude.Text
disableRule_name :: Lens' DisableRule Text
disableRule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableRule' {Text
name :: Text
$sel:name:DisableRule' :: DisableRule -> Text
name} -> Text
name) (\s :: DisableRule
s@DisableRule' {} Text
a -> DisableRule
s {$sel:name:DisableRule' :: Text
name = Text
a} :: DisableRule)

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

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

instance Prelude.NFData DisableRule where
  rnf :: DisableRule -> ()
rnf DisableRule' {Maybe Text
Text
name :: Text
eventBusName :: Maybe Text
$sel:name:DisableRule' :: DisableRule -> Text
$sel:eventBusName:DisableRule' :: DisableRule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventBusName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders DisableRule where
  toHeaders :: DisableRule -> [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.DisableRule" :: 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 DisableRule where
  toJSON :: DisableRule -> Value
toJSON DisableRule' {Maybe Text
Text
name :: Text
eventBusName :: Maybe Text
$sel:name:DisableRule' :: DisableRule -> Text
$sel:eventBusName:DisableRule' :: DisableRule -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EventBusName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eventBusName,
            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 DisableRule where
  toPath :: DisableRule -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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