{-# 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.PutRule
-- 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)
--
-- Creates or updates the specified rule. Rules are enabled by default, or
-- based on value of the state. You can disable a rule using
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_DisableRule.html DisableRule>.
--
-- A single rule watches for events from a single event bus. Events
-- generated by Amazon Web Services services go to your account\'s default
-- event bus. Events generated by SaaS partner services or applications go
-- to the matching partner event bus. If you have custom applications or
-- services, you can specify whether their events go to your default event
-- bus or a custom event bus that you have created. For more information,
-- see
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_CreateEventBus.html CreateEventBus>.
--
-- If you are updating an existing rule, the rule is replaced with what you
-- specify in this @PutRule@ command. If you omit arguments in @PutRule@,
-- the old values for those arguments are not kept. Instead, they are
-- replaced with null values.
--
-- When you create or update a rule, incoming events might not immediately
-- start matching to new or updated rules. Allow a short period of time for
-- changes to take effect.
--
-- A rule must contain at least an EventPattern or ScheduleExpression.
-- Rules with EventPatterns are triggered when a matching event is
-- observed. Rules with ScheduleExpressions self-trigger based on the given
-- schedule. A rule can have both an EventPattern and a ScheduleExpression,
-- in which case the rule triggers on matching events as well as on a
-- schedule.
--
-- When you initially create a rule, you can optionally assign one or more
-- tags to the rule. Tags can help you organize and categorize your
-- resources. You can also use them to scope user permissions, by granting
-- a user permission to access or change only rules with certain tag
-- values. To use the @PutRule@ operation and assign tags, you must have
-- both the @events:PutRule@ and @events:TagResource@ permissions.
--
-- If you are updating an existing rule, any tags you specify in the
-- @PutRule@ operation are ignored. To update the tags of an existing rule,
-- use
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_TagResource.html TagResource>
-- and
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_UntagResource.html UntagResource>.
--
-- Most services in Amazon Web Services treat : or \/ as the same character
-- in Amazon Resource Names (ARNs). However, EventBridge uses an exact
-- match in event patterns and rules. Be sure to use the correct ARN
-- characters when creating event patterns so that they match the ARN
-- syntax in the event you want to match.
--
-- In EventBridge, it is possible to create rules that lead to infinite
-- loops, where a rule is fired repeatedly. For example, a rule might
-- detect that ACLs have changed on an S3 bucket, and trigger software to
-- change them to the desired state. If the rule is not written carefully,
-- the subsequent change to the ACLs fires the rule again, creating an
-- infinite loop.
--
-- To prevent this, write the rules so that the triggered actions do not
-- re-fire the same rule. For example, your rule could fire only if ACLs
-- are found to be in a bad state, instead of after any change.
--
-- An infinite loop can quickly cause higher than expected charges. We
-- recommend that you use budgeting, which alerts you when charges exceed
-- your specified limit. For more information, see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/budgets-managing-costs.html Managing Your Costs with Budgets>.
module Amazonka.CloudWatchEvents.PutRule
  ( -- * Creating a Request
    PutRule (..),
    newPutRule,

    -- * Request Lenses
    putRule_eventPattern,
    putRule_state,
    putRule_eventBusName,
    putRule_scheduleExpression,
    putRule_description,
    putRule_tags,
    putRule_roleArn,
    putRule_name,

    -- * Destructuring the Response
    PutRuleResponse (..),
    newPutRuleResponse,

    -- * Response Lenses
    putRuleResponse_ruleArn,
    putRuleResponse_httpStatus,
  )
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:/ 'newPutRule' smart constructor.
data PutRule = PutRule'
  { -- | The event pattern. For more information, see
    -- <https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html Events and Event Patterns>
    -- in the /Amazon EventBridge User Guide/.
    PutRule -> Maybe Text
eventPattern :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the rule is enabled or disabled.
    PutRule -> Maybe RuleState
state :: Prelude.Maybe RuleState,
    -- | The name or ARN of the event bus to associate with this rule. If you
    -- omit this, the default event bus is used.
    PutRule -> Maybe Text
eventBusName :: Prelude.Maybe Prelude.Text,
    -- | The scheduling expression. For example, \"cron(0 20 * * ? *)\" or
    -- \"rate(5 minutes)\".
    PutRule -> Maybe Text
scheduleExpression :: Prelude.Maybe Prelude.Text,
    -- | A description of the rule.
    PutRule -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The list of key-value pairs to associate with the rule.
    PutRule -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The Amazon Resource Name (ARN) of the IAM role associated with the rule.
    --
    -- If you\'re setting an event bus in another account as the target and
    -- that account granted permission to your account through an organization
    -- instead of directly by the account ID, you must specify a @RoleArn@ with
    -- proper permissions in the @Target@ structure, instead of here in this
    -- parameter.
    PutRule -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule that you are creating or updating.
    PutRule -> Text
name :: Prelude.Text
  }
  deriving (PutRule -> PutRule -> Bool
(PutRule -> PutRule -> Bool)
-> (PutRule -> PutRule -> Bool) -> Eq PutRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRule -> PutRule -> Bool
$c/= :: PutRule -> PutRule -> Bool
== :: PutRule -> PutRule -> Bool
$c== :: PutRule -> PutRule -> Bool
Prelude.Eq, ReadPrec [PutRule]
ReadPrec PutRule
Int -> ReadS PutRule
ReadS [PutRule]
(Int -> ReadS PutRule)
-> ReadS [PutRule]
-> ReadPrec PutRule
-> ReadPrec [PutRule]
-> Read PutRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRule]
$creadListPrec :: ReadPrec [PutRule]
readPrec :: ReadPrec PutRule
$creadPrec :: ReadPrec PutRule
readList :: ReadS [PutRule]
$creadList :: ReadS [PutRule]
readsPrec :: Int -> ReadS PutRule
$creadsPrec :: Int -> ReadS PutRule
Prelude.Read, Int -> PutRule -> ShowS
[PutRule] -> ShowS
PutRule -> String
(Int -> PutRule -> ShowS)
-> (PutRule -> String) -> ([PutRule] -> ShowS) -> Show PutRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRule] -> ShowS
$cshowList :: [PutRule] -> ShowS
show :: PutRule -> String
$cshow :: PutRule -> String
showsPrec :: Int -> PutRule -> ShowS
$cshowsPrec :: Int -> PutRule -> ShowS
Prelude.Show, (forall x. PutRule -> Rep PutRule x)
-> (forall x. Rep PutRule x -> PutRule) -> Generic PutRule
forall x. Rep PutRule x -> PutRule
forall x. PutRule -> Rep PutRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRule x -> PutRule
$cfrom :: forall x. PutRule -> Rep PutRule x
Prelude.Generic)

-- |
-- Create a value of 'PutRule' 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:
--
-- 'eventPattern', 'putRule_eventPattern' - The event pattern. For more information, see
-- <https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html Events and Event Patterns>
-- in the /Amazon EventBridge User Guide/.
--
-- 'state', 'putRule_state' - Indicates whether the rule is enabled or disabled.
--
-- 'eventBusName', 'putRule_eventBusName' - The name or ARN of the event bus to associate with this rule. If you
-- omit this, the default event bus is used.
--
-- 'scheduleExpression', 'putRule_scheduleExpression' - The scheduling expression. For example, \"cron(0 20 * * ? *)\" or
-- \"rate(5 minutes)\".
--
-- 'description', 'putRule_description' - A description of the rule.
--
-- 'tags', 'putRule_tags' - The list of key-value pairs to associate with the rule.
--
-- 'roleArn', 'putRule_roleArn' - The Amazon Resource Name (ARN) of the IAM role associated with the rule.
--
-- If you\'re setting an event bus in another account as the target and
-- that account granted permission to your account through an organization
-- instead of directly by the account ID, you must specify a @RoleArn@ with
-- proper permissions in the @Target@ structure, instead of here in this
-- parameter.
--
-- 'name', 'putRule_name' - The name of the rule that you are creating or updating.
newPutRule ::
  -- | 'name'
  Prelude.Text ->
  PutRule
newPutRule :: Text -> PutRule
newPutRule Text
pName_ =
  PutRule' :: Maybe Text
-> Maybe RuleState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Maybe Text
-> Text
-> PutRule
PutRule'
    { $sel:eventPattern:PutRule' :: Maybe Text
eventPattern = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:PutRule' :: Maybe RuleState
state = Maybe RuleState
forall a. Maybe a
Prelude.Nothing,
      $sel:eventBusName:PutRule' :: Maybe Text
eventBusName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scheduleExpression:PutRule' :: Maybe Text
scheduleExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:PutRule' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:PutRule' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:PutRule' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:PutRule' :: Text
name = Text
pName_
    }

-- | The event pattern. For more information, see
-- <https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html Events and Event Patterns>
-- in the /Amazon EventBridge User Guide/.
putRule_eventPattern :: Lens.Lens' PutRule (Prelude.Maybe Prelude.Text)
putRule_eventPattern :: (Maybe Text -> f (Maybe Text)) -> PutRule -> f PutRule
putRule_eventPattern = (PutRule -> Maybe Text)
-> (PutRule -> Maybe Text -> PutRule)
-> Lens PutRule PutRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Maybe Text
eventPattern :: Maybe Text
$sel:eventPattern:PutRule' :: PutRule -> Maybe Text
eventPattern} -> Maybe Text
eventPattern) (\s :: PutRule
s@PutRule' {} Maybe Text
a -> PutRule
s {$sel:eventPattern:PutRule' :: Maybe Text
eventPattern = Maybe Text
a} :: PutRule)

-- | Indicates whether the rule is enabled or disabled.
putRule_state :: Lens.Lens' PutRule (Prelude.Maybe RuleState)
putRule_state :: (Maybe RuleState -> f (Maybe RuleState)) -> PutRule -> f PutRule
putRule_state = (PutRule -> Maybe RuleState)
-> (PutRule -> Maybe RuleState -> PutRule)
-> Lens PutRule PutRule (Maybe RuleState) (Maybe RuleState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Maybe RuleState
state :: Maybe RuleState
$sel:state:PutRule' :: PutRule -> Maybe RuleState
state} -> Maybe RuleState
state) (\s :: PutRule
s@PutRule' {} Maybe RuleState
a -> PutRule
s {$sel:state:PutRule' :: Maybe RuleState
state = Maybe RuleState
a} :: PutRule)

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

-- | The scheduling expression. For example, \"cron(0 20 * * ? *)\" or
-- \"rate(5 minutes)\".
putRule_scheduleExpression :: Lens.Lens' PutRule (Prelude.Maybe Prelude.Text)
putRule_scheduleExpression :: (Maybe Text -> f (Maybe Text)) -> PutRule -> f PutRule
putRule_scheduleExpression = (PutRule -> Maybe Text)
-> (PutRule -> Maybe Text -> PutRule)
-> Lens PutRule PutRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Maybe Text
scheduleExpression :: Maybe Text
$sel:scheduleExpression:PutRule' :: PutRule -> Maybe Text
scheduleExpression} -> Maybe Text
scheduleExpression) (\s :: PutRule
s@PutRule' {} Maybe Text
a -> PutRule
s {$sel:scheduleExpression:PutRule' :: Maybe Text
scheduleExpression = Maybe Text
a} :: PutRule)

-- | A description of the rule.
putRule_description :: Lens.Lens' PutRule (Prelude.Maybe Prelude.Text)
putRule_description :: (Maybe Text -> f (Maybe Text)) -> PutRule -> f PutRule
putRule_description = (PutRule -> Maybe Text)
-> (PutRule -> Maybe Text -> PutRule)
-> Lens PutRule PutRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Maybe Text
description :: Maybe Text
$sel:description:PutRule' :: PutRule -> Maybe Text
description} -> Maybe Text
description) (\s :: PutRule
s@PutRule' {} Maybe Text
a -> PutRule
s {$sel:description:PutRule' :: Maybe Text
description = Maybe Text
a} :: PutRule)

-- | The list of key-value pairs to associate with the rule.
putRule_tags :: Lens.Lens' PutRule (Prelude.Maybe [Tag])
putRule_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> PutRule -> f PutRule
putRule_tags = (PutRule -> Maybe [Tag])
-> (PutRule -> Maybe [Tag] -> PutRule)
-> Lens PutRule PutRule (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:PutRule' :: PutRule -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: PutRule
s@PutRule' {} Maybe [Tag]
a -> PutRule
s {$sel:tags:PutRule' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: PutRule) ((Maybe [Tag] -> f (Maybe [Tag])) -> PutRule -> f PutRule)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutRule
-> f PutRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the IAM role associated with the rule.
--
-- If you\'re setting an event bus in another account as the target and
-- that account granted permission to your account through an organization
-- instead of directly by the account ID, you must specify a @RoleArn@ with
-- proper permissions in the @Target@ structure, instead of here in this
-- parameter.
putRule_roleArn :: Lens.Lens' PutRule (Prelude.Maybe Prelude.Text)
putRule_roleArn :: (Maybe Text -> f (Maybe Text)) -> PutRule -> f PutRule
putRule_roleArn = (PutRule -> Maybe Text)
-> (PutRule -> Maybe Text -> PutRule)
-> Lens PutRule PutRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:PutRule' :: PutRule -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: PutRule
s@PutRule' {} Maybe Text
a -> PutRule
s {$sel:roleArn:PutRule' :: Maybe Text
roleArn = Maybe Text
a} :: PutRule)

-- | The name of the rule that you are creating or updating.
putRule_name :: Lens.Lens' PutRule Prelude.Text
putRule_name :: (Text -> f Text) -> PutRule -> f PutRule
putRule_name = (PutRule -> Text)
-> (PutRule -> Text -> PutRule) -> Lens PutRule PutRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRule' {Text
name :: Text
$sel:name:PutRule' :: PutRule -> Text
name} -> Text
name) (\s :: PutRule
s@PutRule' {} Text
a -> PutRule
s {$sel:name:PutRule' :: Text
name = Text
a} :: PutRule)

instance Core.AWSRequest PutRule where
  type AWSResponse PutRule = PutRuleResponse
  request :: PutRule -> Request PutRule
request = Service -> PutRule -> Request PutRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutRule))
-> Logger
-> Service
-> Proxy PutRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> PutRuleResponse
PutRuleResponse'
            (Maybe Text -> Int -> PutRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RuleArn")
            Either String (Int -> PutRuleResponse)
-> Either String Int -> Either String PutRuleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutRule

instance Prelude.NFData PutRule

instance Core.ToHeaders PutRule where
  toHeaders :: PutRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AWSEvents.PutRule" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutRule where
  toJSON :: PutRule -> Value
toJSON PutRule' {Maybe [Tag]
Maybe Text
Maybe RuleState
Text
name :: Text
roleArn :: Maybe Text
tags :: Maybe [Tag]
description :: Maybe Text
scheduleExpression :: Maybe Text
eventBusName :: Maybe Text
state :: Maybe RuleState
eventPattern :: Maybe Text
$sel:name:PutRule' :: PutRule -> Text
$sel:roleArn:PutRule' :: PutRule -> Maybe Text
$sel:tags:PutRule' :: PutRule -> Maybe [Tag]
$sel:description:PutRule' :: PutRule -> Maybe Text
$sel:scheduleExpression:PutRule' :: PutRule -> Maybe Text
$sel:eventBusName:PutRule' :: PutRule -> Maybe Text
$sel:state:PutRule' :: PutRule -> Maybe RuleState
$sel:eventPattern:PutRule' :: PutRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EventPattern" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eventPattern,
            (Text
"State" Text -> RuleState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RuleState -> Pair) -> Maybe RuleState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RuleState
state,
            (Text
"EventBusName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eventBusName,
            (Text
"ScheduleExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
scheduleExpression,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            (Text
"RoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn,
            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 PutRule where
  toPath :: PutRule -> ByteString
toPath = ByteString -> PutRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newPutRuleResponse' smart constructor.
data PutRuleResponse = PutRuleResponse'
  { -- | The Amazon Resource Name (ARN) of the rule.
    PutRuleResponse -> Maybe Text
ruleArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    PutRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutRuleResponse -> PutRuleResponse -> Bool
(PutRuleResponse -> PutRuleResponse -> Bool)
-> (PutRuleResponse -> PutRuleResponse -> Bool)
-> Eq PutRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRuleResponse -> PutRuleResponse -> Bool
$c/= :: PutRuleResponse -> PutRuleResponse -> Bool
== :: PutRuleResponse -> PutRuleResponse -> Bool
$c== :: PutRuleResponse -> PutRuleResponse -> Bool
Prelude.Eq, ReadPrec [PutRuleResponse]
ReadPrec PutRuleResponse
Int -> ReadS PutRuleResponse
ReadS [PutRuleResponse]
(Int -> ReadS PutRuleResponse)
-> ReadS [PutRuleResponse]
-> ReadPrec PutRuleResponse
-> ReadPrec [PutRuleResponse]
-> Read PutRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRuleResponse]
$creadListPrec :: ReadPrec [PutRuleResponse]
readPrec :: ReadPrec PutRuleResponse
$creadPrec :: ReadPrec PutRuleResponse
readList :: ReadS [PutRuleResponse]
$creadList :: ReadS [PutRuleResponse]
readsPrec :: Int -> ReadS PutRuleResponse
$creadsPrec :: Int -> ReadS PutRuleResponse
Prelude.Read, Int -> PutRuleResponse -> ShowS
[PutRuleResponse] -> ShowS
PutRuleResponse -> String
(Int -> PutRuleResponse -> ShowS)
-> (PutRuleResponse -> String)
-> ([PutRuleResponse] -> ShowS)
-> Show PutRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRuleResponse] -> ShowS
$cshowList :: [PutRuleResponse] -> ShowS
show :: PutRuleResponse -> String
$cshow :: PutRuleResponse -> String
showsPrec :: Int -> PutRuleResponse -> ShowS
$cshowsPrec :: Int -> PutRuleResponse -> ShowS
Prelude.Show, (forall x. PutRuleResponse -> Rep PutRuleResponse x)
-> (forall x. Rep PutRuleResponse x -> PutRuleResponse)
-> Generic PutRuleResponse
forall x. Rep PutRuleResponse x -> PutRuleResponse
forall x. PutRuleResponse -> Rep PutRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRuleResponse x -> PutRuleResponse
$cfrom :: forall x. PutRuleResponse -> Rep PutRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutRuleResponse' 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:
--
-- 'ruleArn', 'putRuleResponse_ruleArn' - The Amazon Resource Name (ARN) of the rule.
--
-- 'httpStatus', 'putRuleResponse_httpStatus' - The response's http status code.
newPutRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutRuleResponse
newPutRuleResponse :: Int -> PutRuleResponse
newPutRuleResponse Int
pHttpStatus_ =
  PutRuleResponse' :: Maybe Text -> Int -> PutRuleResponse
PutRuleResponse'
    { $sel:ruleArn:PutRuleResponse' :: Maybe Text
ruleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the rule.
putRuleResponse_ruleArn :: Lens.Lens' PutRuleResponse (Prelude.Maybe Prelude.Text)
putRuleResponse_ruleArn :: (Maybe Text -> f (Maybe Text))
-> PutRuleResponse -> f PutRuleResponse
putRuleResponse_ruleArn = (PutRuleResponse -> Maybe Text)
-> (PutRuleResponse -> Maybe Text -> PutRuleResponse)
-> Lens PutRuleResponse PutRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRuleResponse' {Maybe Text
ruleArn :: Maybe Text
$sel:ruleArn:PutRuleResponse' :: PutRuleResponse -> Maybe Text
ruleArn} -> Maybe Text
ruleArn) (\s :: PutRuleResponse
s@PutRuleResponse' {} Maybe Text
a -> PutRuleResponse
s {$sel:ruleArn:PutRuleResponse' :: Maybe Text
ruleArn = Maybe Text
a} :: PutRuleResponse)

-- | The response's http status code.
putRuleResponse_httpStatus :: Lens.Lens' PutRuleResponse Prelude.Int
putRuleResponse_httpStatus :: (Int -> f Int) -> PutRuleResponse -> f PutRuleResponse
putRuleResponse_httpStatus = (PutRuleResponse -> Int)
-> (PutRuleResponse -> Int -> PutRuleResponse)
-> Lens PutRuleResponse PutRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutRuleResponse' :: PutRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutRuleResponse
s@PutRuleResponse' {} Int
a -> PutRuleResponse
s {$sel:httpStatus:PutRuleResponse' :: Int
httpStatus = Int
a} :: PutRuleResponse)

instance Prelude.NFData PutRuleResponse