{-# 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.DescribeRule
-- 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)
--
-- Describes the specified rule.
--
-- DescribeRule does not list the targets of a rule. To see the targets
-- associated with a rule, use
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListTargetsByRule.html ListTargetsByRule>.
module Amazonka.CloudWatchEvents.DescribeRule
  ( -- * Creating a Request
    DescribeRule (..),
    newDescribeRule,

    -- * Request Lenses
    describeRule_eventBusName,
    describeRule_name,

    -- * Destructuring the Response
    DescribeRuleResponse (..),
    newDescribeRuleResponse,

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

-- |
-- Create a value of 'DescribeRule' 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', 'describeRule_eventBusName' - The name or ARN of the event bus associated with the rule. If you omit
-- this, the default event bus is used.
--
-- 'name', 'describeRule_name' - The name of the rule.
newDescribeRule ::
  -- | 'name'
  Prelude.Text ->
  DescribeRule
newDescribeRule :: Text -> DescribeRule
newDescribeRule Text
pName_ =
  DescribeRule' :: Maybe Text -> Text -> DescribeRule
DescribeRule'
    { $sel:eventBusName:DescribeRule' :: Maybe Text
eventBusName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DescribeRule' :: 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.
describeRule_eventBusName :: Lens.Lens' DescribeRule (Prelude.Maybe Prelude.Text)
describeRule_eventBusName :: (Maybe Text -> f (Maybe Text)) -> DescribeRule -> f DescribeRule
describeRule_eventBusName = (DescribeRule -> Maybe Text)
-> (DescribeRule -> Maybe Text -> DescribeRule)
-> Lens DescribeRule DescribeRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRule' {Maybe Text
eventBusName :: Maybe Text
$sel:eventBusName:DescribeRule' :: DescribeRule -> Maybe Text
eventBusName} -> Maybe Text
eventBusName) (\s :: DescribeRule
s@DescribeRule' {} Maybe Text
a -> DescribeRule
s {$sel:eventBusName:DescribeRule' :: Maybe Text
eventBusName = Maybe Text
a} :: DescribeRule)

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

instance Core.AWSRequest DescribeRule where
  type AWSResponse DescribeRule = DescribeRuleResponse
  request :: DescribeRule -> Request DescribeRule
request = Service -> DescribeRule -> Request DescribeRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeRule))
-> Logger
-> Service
-> Proxy DescribeRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeRule)))
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
-> Maybe RuleState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> DescribeRuleResponse
DescribeRuleResponse'
            (Maybe Text
 -> Maybe RuleState
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe RuleState
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> DescribeRuleResponse)
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
"EventPattern")
            Either
  String
  (Maybe RuleState
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> DescribeRuleResponse)
-> Either String (Maybe RuleState)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe RuleState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"State")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"Arn")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"CreatedBy")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"EventBusName")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"ScheduleExpression")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Int -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Int -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"Description")
            Either
  String (Maybe Text -> Maybe Text -> Int -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"ManagedBy")
            Either String (Maybe Text -> Int -> DescribeRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeRuleResponse)
forall (f :: * -> *) a b. Applicative f => 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
"RoleArn")
            Either String (Int -> DescribeRuleResponse)
-> Either String Int -> Either String DescribeRuleResponse
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 DescribeRule

instance Prelude.NFData DescribeRule

instance Core.ToHeaders DescribeRule where
  toHeaders :: DescribeRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRule -> 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.DescribeRule" :: 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 DescribeRule where
  toJSON :: DescribeRule -> Value
toJSON DescribeRule' {Maybe Text
Text
name :: Text
eventBusName :: Maybe Text
$sel:name:DescribeRule' :: DescribeRule -> Text
$sel:eventBusName:DescribeRule' :: DescribeRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            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 DescribeRule where
  toPath :: DescribeRule -> ByteString
toPath = ByteString -> DescribeRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeRuleResponse' smart constructor.
data DescribeRuleResponse = DescribeRuleResponse'
  { -- | 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/.
    DescribeRuleResponse -> Maybe Text
eventPattern :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the rule is enabled or disabled.
    DescribeRuleResponse -> Maybe RuleState
state :: Prelude.Maybe RuleState,
    -- | The Amazon Resource Name (ARN) of the rule.
    DescribeRuleResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The account ID of the user that created the rule. If you use @PutRule@
    -- to put a rule on an event bus in another account, the other account is
    -- the owner of the rule, and the rule ARN includes the account ID for that
    -- account. However, the value for @CreatedBy@ is the account ID as the
    -- account that created the rule in the other account.
    DescribeRuleResponse -> Maybe Text
createdBy :: Prelude.Maybe Prelude.Text,
    -- | The name of the event bus associated with the rule.
    DescribeRuleResponse -> Maybe Text
eventBusName :: Prelude.Maybe Prelude.Text,
    -- | The scheduling expression. For example, \"cron(0 20 * * ? *)\", \"rate(5
    -- minutes)\".
    DescribeRuleResponse -> Maybe Text
scheduleExpression :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule.
    DescribeRuleResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The description of the rule.
    DescribeRuleResponse -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | If this is a managed rule, created by an Amazon Web Services service on
    -- your behalf, this field displays the principal name of the Amazon Web
    -- Services service that created the rule.
    DescribeRuleResponse -> Maybe Text
managedBy :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role associated with the rule.
    DescribeRuleResponse -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeRuleResponse -> DescribeRuleResponse -> Bool
(DescribeRuleResponse -> DescribeRuleResponse -> Bool)
-> (DescribeRuleResponse -> DescribeRuleResponse -> Bool)
-> Eq DescribeRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRuleResponse -> DescribeRuleResponse -> Bool
$c/= :: DescribeRuleResponse -> DescribeRuleResponse -> Bool
== :: DescribeRuleResponse -> DescribeRuleResponse -> Bool
$c== :: DescribeRuleResponse -> DescribeRuleResponse -> Bool
Prelude.Eq, ReadPrec [DescribeRuleResponse]
ReadPrec DescribeRuleResponse
Int -> ReadS DescribeRuleResponse
ReadS [DescribeRuleResponse]
(Int -> ReadS DescribeRuleResponse)
-> ReadS [DescribeRuleResponse]
-> ReadPrec DescribeRuleResponse
-> ReadPrec [DescribeRuleResponse]
-> Read DescribeRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRuleResponse]
$creadListPrec :: ReadPrec [DescribeRuleResponse]
readPrec :: ReadPrec DescribeRuleResponse
$creadPrec :: ReadPrec DescribeRuleResponse
readList :: ReadS [DescribeRuleResponse]
$creadList :: ReadS [DescribeRuleResponse]
readsPrec :: Int -> ReadS DescribeRuleResponse
$creadsPrec :: Int -> ReadS DescribeRuleResponse
Prelude.Read, Int -> DescribeRuleResponse -> ShowS
[DescribeRuleResponse] -> ShowS
DescribeRuleResponse -> String
(Int -> DescribeRuleResponse -> ShowS)
-> (DescribeRuleResponse -> String)
-> ([DescribeRuleResponse] -> ShowS)
-> Show DescribeRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRuleResponse] -> ShowS
$cshowList :: [DescribeRuleResponse] -> ShowS
show :: DescribeRuleResponse -> String
$cshow :: DescribeRuleResponse -> String
showsPrec :: Int -> DescribeRuleResponse -> ShowS
$cshowsPrec :: Int -> DescribeRuleResponse -> ShowS
Prelude.Show, (forall x. DescribeRuleResponse -> Rep DescribeRuleResponse x)
-> (forall x. Rep DescribeRuleResponse x -> DescribeRuleResponse)
-> Generic DescribeRuleResponse
forall x. Rep DescribeRuleResponse x -> DescribeRuleResponse
forall x. DescribeRuleResponse -> Rep DescribeRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeRuleResponse x -> DescribeRuleResponse
$cfrom :: forall x. DescribeRuleResponse -> Rep DescribeRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRuleResponse' 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', 'describeRuleResponse_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', 'describeRuleResponse_state' - Specifies whether the rule is enabled or disabled.
--
-- 'arn', 'describeRuleResponse_arn' - The Amazon Resource Name (ARN) of the rule.
--
-- 'createdBy', 'describeRuleResponse_createdBy' - The account ID of the user that created the rule. If you use @PutRule@
-- to put a rule on an event bus in another account, the other account is
-- the owner of the rule, and the rule ARN includes the account ID for that
-- account. However, the value for @CreatedBy@ is the account ID as the
-- account that created the rule in the other account.
--
-- 'eventBusName', 'describeRuleResponse_eventBusName' - The name of the event bus associated with the rule.
--
-- 'scheduleExpression', 'describeRuleResponse_scheduleExpression' - The scheduling expression. For example, \"cron(0 20 * * ? *)\", \"rate(5
-- minutes)\".
--
-- 'name', 'describeRuleResponse_name' - The name of the rule.
--
-- 'description', 'describeRuleResponse_description' - The description of the rule.
--
-- 'managedBy', 'describeRuleResponse_managedBy' - If this is a managed rule, created by an Amazon Web Services service on
-- your behalf, this field displays the principal name of the Amazon Web
-- Services service that created the rule.
--
-- 'roleArn', 'describeRuleResponse_roleArn' - The Amazon Resource Name (ARN) of the IAM role associated with the rule.
--
-- 'httpStatus', 'describeRuleResponse_httpStatus' - The response's http status code.
newDescribeRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeRuleResponse
newDescribeRuleResponse :: Int -> DescribeRuleResponse
newDescribeRuleResponse Int
pHttpStatus_ =
  DescribeRuleResponse' :: Maybe Text
-> Maybe RuleState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> DescribeRuleResponse
DescribeRuleResponse'
    { $sel:eventPattern:DescribeRuleResponse' :: Maybe Text
eventPattern =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:DescribeRuleResponse' :: Maybe RuleState
state = Maybe RuleState
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:DescribeRuleResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBy:DescribeRuleResponse' :: Maybe Text
createdBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventBusName:DescribeRuleResponse' :: Maybe Text
eventBusName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scheduleExpression:DescribeRuleResponse' :: Maybe Text
scheduleExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DescribeRuleResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:DescribeRuleResponse' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:managedBy:DescribeRuleResponse' :: Maybe Text
managedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:DescribeRuleResponse' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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/.
describeRuleResponse_eventPattern :: Lens.Lens' DescribeRuleResponse (Prelude.Maybe Prelude.Text)
describeRuleResponse_eventPattern :: (Maybe Text -> f (Maybe Text))
-> DescribeRuleResponse -> f DescribeRuleResponse
describeRuleResponse_eventPattern = (DescribeRuleResponse -> Maybe Text)
-> (DescribeRuleResponse -> Maybe Text -> DescribeRuleResponse)
-> Lens
     DescribeRuleResponse DescribeRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuleResponse' {Maybe Text
eventPattern :: Maybe Text
$sel:eventPattern:DescribeRuleResponse' :: DescribeRuleResponse -> Maybe Text
eventPattern} -> Maybe Text
eventPattern) (\s :: DescribeRuleResponse
s@DescribeRuleResponse' {} Maybe Text
a -> DescribeRuleResponse
s {$sel:eventPattern:DescribeRuleResponse' :: Maybe Text
eventPattern = Maybe Text
a} :: DescribeRuleResponse)

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

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

-- | The account ID of the user that created the rule. If you use @PutRule@
-- to put a rule on an event bus in another account, the other account is
-- the owner of the rule, and the rule ARN includes the account ID for that
-- account. However, the value for @CreatedBy@ is the account ID as the
-- account that created the rule in the other account.
describeRuleResponse_createdBy :: Lens.Lens' DescribeRuleResponse (Prelude.Maybe Prelude.Text)
describeRuleResponse_createdBy :: (Maybe Text -> f (Maybe Text))
-> DescribeRuleResponse -> f DescribeRuleResponse
describeRuleResponse_createdBy = (DescribeRuleResponse -> Maybe Text)
-> (DescribeRuleResponse -> Maybe Text -> DescribeRuleResponse)
-> Lens
     DescribeRuleResponse DescribeRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuleResponse' {Maybe Text
createdBy :: Maybe Text
$sel:createdBy:DescribeRuleResponse' :: DescribeRuleResponse -> Maybe Text
createdBy} -> Maybe Text
createdBy) (\s :: DescribeRuleResponse
s@DescribeRuleResponse' {} Maybe Text
a -> DescribeRuleResponse
s {$sel:createdBy:DescribeRuleResponse' :: Maybe Text
createdBy = Maybe Text
a} :: DescribeRuleResponse)

-- | The name of the event bus associated with the rule.
describeRuleResponse_eventBusName :: Lens.Lens' DescribeRuleResponse (Prelude.Maybe Prelude.Text)
describeRuleResponse_eventBusName :: (Maybe Text -> f (Maybe Text))
-> DescribeRuleResponse -> f DescribeRuleResponse
describeRuleResponse_eventBusName = (DescribeRuleResponse -> Maybe Text)
-> (DescribeRuleResponse -> Maybe Text -> DescribeRuleResponse)
-> Lens
     DescribeRuleResponse DescribeRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuleResponse' {Maybe Text
eventBusName :: Maybe Text
$sel:eventBusName:DescribeRuleResponse' :: DescribeRuleResponse -> Maybe Text
eventBusName} -> Maybe Text
eventBusName) (\s :: DescribeRuleResponse
s@DescribeRuleResponse' {} Maybe Text
a -> DescribeRuleResponse
s {$sel:eventBusName:DescribeRuleResponse' :: Maybe Text
eventBusName = Maybe Text
a} :: DescribeRuleResponse)

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

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

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

-- | If this is a managed rule, created by an Amazon Web Services service on
-- your behalf, this field displays the principal name of the Amazon Web
-- Services service that created the rule.
describeRuleResponse_managedBy :: Lens.Lens' DescribeRuleResponse (Prelude.Maybe Prelude.Text)
describeRuleResponse_managedBy :: (Maybe Text -> f (Maybe Text))
-> DescribeRuleResponse -> f DescribeRuleResponse
describeRuleResponse_managedBy = (DescribeRuleResponse -> Maybe Text)
-> (DescribeRuleResponse -> Maybe Text -> DescribeRuleResponse)
-> Lens
     DescribeRuleResponse DescribeRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuleResponse' {Maybe Text
managedBy :: Maybe Text
$sel:managedBy:DescribeRuleResponse' :: DescribeRuleResponse -> Maybe Text
managedBy} -> Maybe Text
managedBy) (\s :: DescribeRuleResponse
s@DescribeRuleResponse' {} Maybe Text
a -> DescribeRuleResponse
s {$sel:managedBy:DescribeRuleResponse' :: Maybe Text
managedBy = Maybe Text
a} :: DescribeRuleResponse)

-- | The Amazon Resource Name (ARN) of the IAM role associated with the rule.
describeRuleResponse_roleArn :: Lens.Lens' DescribeRuleResponse (Prelude.Maybe Prelude.Text)
describeRuleResponse_roleArn :: (Maybe Text -> f (Maybe Text))
-> DescribeRuleResponse -> f DescribeRuleResponse
describeRuleResponse_roleArn = (DescribeRuleResponse -> Maybe Text)
-> (DescribeRuleResponse -> Maybe Text -> DescribeRuleResponse)
-> Lens
     DescribeRuleResponse DescribeRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuleResponse' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:DescribeRuleResponse' :: DescribeRuleResponse -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: DescribeRuleResponse
s@DescribeRuleResponse' {} Maybe Text
a -> DescribeRuleResponse
s {$sel:roleArn:DescribeRuleResponse' :: Maybe Text
roleArn = Maybe Text
a} :: DescribeRuleResponse)

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

instance Prelude.NFData DescribeRuleResponse