{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Connect.Types.RuleSummary
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Connect.Types.RuleSummary where

import Amazonka.Connect.Types.ActionSummary
import Amazonka.Connect.Types.EventSourceName
import Amazonka.Connect.Types.RulePublishStatus
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

-- | A list of @ActionTypes@ associated with a rule.
--
-- /See:/ 'newRuleSummary' smart constructor.
data RuleSummary = RuleSummary'
  { -- | The name of the rule.
    RuleSummary -> Text
name :: Prelude.Text,
    -- | A unique identifier for the rule.
    RuleSummary -> Text
ruleId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the rule.
    RuleSummary -> Text
ruleArn :: Prelude.Text,
    -- | The name of the event source.
    RuleSummary -> EventSourceName
eventSourceName :: EventSourceName,
    -- | The publish status of the rule.
    RuleSummary -> RulePublishStatus
publishStatus :: RulePublishStatus,
    -- | A list of ActionTypes associated with a rule.
    RuleSummary -> [ActionSummary]
actionSummaries :: [ActionSummary],
    -- | The timestamp for when the rule was created.
    RuleSummary -> POSIX
createdTime :: Data.POSIX,
    -- | The timestamp for when the rule was last updated.
    RuleSummary -> POSIX
lastUpdatedTime :: Data.POSIX
  }
  deriving (RuleSummary -> RuleSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleSummary -> RuleSummary -> Bool
$c/= :: RuleSummary -> RuleSummary -> Bool
== :: RuleSummary -> RuleSummary -> Bool
$c== :: RuleSummary -> RuleSummary -> Bool
Prelude.Eq, ReadPrec [RuleSummary]
ReadPrec RuleSummary
Int -> ReadS RuleSummary
ReadS [RuleSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleSummary]
$creadListPrec :: ReadPrec [RuleSummary]
readPrec :: ReadPrec RuleSummary
$creadPrec :: ReadPrec RuleSummary
readList :: ReadS [RuleSummary]
$creadList :: ReadS [RuleSummary]
readsPrec :: Int -> ReadS RuleSummary
$creadsPrec :: Int -> ReadS RuleSummary
Prelude.Read, Int -> RuleSummary -> ShowS
[RuleSummary] -> ShowS
RuleSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleSummary] -> ShowS
$cshowList :: [RuleSummary] -> ShowS
show :: RuleSummary -> String
$cshow :: RuleSummary -> String
showsPrec :: Int -> RuleSummary -> ShowS
$cshowsPrec :: Int -> RuleSummary -> ShowS
Prelude.Show, forall x. Rep RuleSummary x -> RuleSummary
forall x. RuleSummary -> Rep RuleSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleSummary x -> RuleSummary
$cfrom :: forall x. RuleSummary -> Rep RuleSummary x
Prelude.Generic)

-- |
-- Create a value of 'RuleSummary' 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:
--
-- 'name', 'ruleSummary_name' - The name of the rule.
--
-- 'ruleId', 'ruleSummary_ruleId' - A unique identifier for the rule.
--
-- 'ruleArn', 'ruleSummary_ruleArn' - The Amazon Resource Name (ARN) of the rule.
--
-- 'eventSourceName', 'ruleSummary_eventSourceName' - The name of the event source.
--
-- 'publishStatus', 'ruleSummary_publishStatus' - The publish status of the rule.
--
-- 'actionSummaries', 'ruleSummary_actionSummaries' - A list of ActionTypes associated with a rule.
--
-- 'createdTime', 'ruleSummary_createdTime' - The timestamp for when the rule was created.
--
-- 'lastUpdatedTime', 'ruleSummary_lastUpdatedTime' - The timestamp for when the rule was last updated.
newRuleSummary ::
  -- | 'name'
  Prelude.Text ->
  -- | 'ruleId'
  Prelude.Text ->
  -- | 'ruleArn'
  Prelude.Text ->
  -- | 'eventSourceName'
  EventSourceName ->
  -- | 'publishStatus'
  RulePublishStatus ->
  -- | 'createdTime'
  Prelude.UTCTime ->
  -- | 'lastUpdatedTime'
  Prelude.UTCTime ->
  RuleSummary
newRuleSummary :: Text
-> Text
-> Text
-> EventSourceName
-> RulePublishStatus
-> UTCTime
-> UTCTime
-> RuleSummary
newRuleSummary
  Text
pName_
  Text
pRuleId_
  Text
pRuleArn_
  EventSourceName
pEventSourceName_
  RulePublishStatus
pPublishStatus_
  UTCTime
pCreatedTime_
  UTCTime
pLastUpdatedTime_ =
    RuleSummary'
      { $sel:name:RuleSummary' :: Text
name = Text
pName_,
        $sel:ruleId:RuleSummary' :: Text
ruleId = Text
pRuleId_,
        $sel:ruleArn:RuleSummary' :: Text
ruleArn = Text
pRuleArn_,
        $sel:eventSourceName:RuleSummary' :: EventSourceName
eventSourceName = EventSourceName
pEventSourceName_,
        $sel:publishStatus:RuleSummary' :: RulePublishStatus
publishStatus = RulePublishStatus
pPublishStatus_,
        $sel:actionSummaries:RuleSummary' :: [ActionSummary]
actionSummaries = forall a. Monoid a => a
Prelude.mempty,
        $sel:createdTime:RuleSummary' :: POSIX
createdTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedTime_,
        $sel:lastUpdatedTime:RuleSummary' :: POSIX
lastUpdatedTime =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastUpdatedTime_
      }

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

-- | A unique identifier for the rule.
ruleSummary_ruleId :: Lens.Lens' RuleSummary Prelude.Text
ruleSummary_ruleId :: Lens' RuleSummary Text
ruleSummary_ruleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Text
ruleId :: Text
$sel:ruleId:RuleSummary' :: RuleSummary -> Text
ruleId} -> Text
ruleId) (\s :: RuleSummary
s@RuleSummary' {} Text
a -> RuleSummary
s {$sel:ruleId:RuleSummary' :: Text
ruleId = Text
a} :: RuleSummary)

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

-- | The name of the event source.
ruleSummary_eventSourceName :: Lens.Lens' RuleSummary EventSourceName
ruleSummary_eventSourceName :: Lens' RuleSummary EventSourceName
ruleSummary_eventSourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {EventSourceName
eventSourceName :: EventSourceName
$sel:eventSourceName:RuleSummary' :: RuleSummary -> EventSourceName
eventSourceName} -> EventSourceName
eventSourceName) (\s :: RuleSummary
s@RuleSummary' {} EventSourceName
a -> RuleSummary
s {$sel:eventSourceName:RuleSummary' :: EventSourceName
eventSourceName = EventSourceName
a} :: RuleSummary)

-- | The publish status of the rule.
ruleSummary_publishStatus :: Lens.Lens' RuleSummary RulePublishStatus
ruleSummary_publishStatus :: Lens' RuleSummary RulePublishStatus
ruleSummary_publishStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {RulePublishStatus
publishStatus :: RulePublishStatus
$sel:publishStatus:RuleSummary' :: RuleSummary -> RulePublishStatus
publishStatus} -> RulePublishStatus
publishStatus) (\s :: RuleSummary
s@RuleSummary' {} RulePublishStatus
a -> RuleSummary
s {$sel:publishStatus:RuleSummary' :: RulePublishStatus
publishStatus = RulePublishStatus
a} :: RuleSummary)

-- | A list of ActionTypes associated with a rule.
ruleSummary_actionSummaries :: Lens.Lens' RuleSummary [ActionSummary]
ruleSummary_actionSummaries :: Lens' RuleSummary [ActionSummary]
ruleSummary_actionSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {[ActionSummary]
actionSummaries :: [ActionSummary]
$sel:actionSummaries:RuleSummary' :: RuleSummary -> [ActionSummary]
actionSummaries} -> [ActionSummary]
actionSummaries) (\s :: RuleSummary
s@RuleSummary' {} [ActionSummary]
a -> RuleSummary
s {$sel:actionSummaries:RuleSummary' :: [ActionSummary]
actionSummaries = [ActionSummary]
a} :: RuleSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The timestamp for when the rule was created.
ruleSummary_createdTime :: Lens.Lens' RuleSummary Prelude.UTCTime
ruleSummary_createdTime :: Lens' RuleSummary UTCTime
ruleSummary_createdTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {POSIX
createdTime :: POSIX
$sel:createdTime:RuleSummary' :: RuleSummary -> POSIX
createdTime} -> POSIX
createdTime) (\s :: RuleSummary
s@RuleSummary' {} POSIX
a -> RuleSummary
s {$sel:createdTime:RuleSummary' :: POSIX
createdTime = POSIX
a} :: RuleSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The timestamp for when the rule was last updated.
ruleSummary_lastUpdatedTime :: Lens.Lens' RuleSummary Prelude.UTCTime
ruleSummary_lastUpdatedTime :: Lens' RuleSummary UTCTime
ruleSummary_lastUpdatedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {POSIX
lastUpdatedTime :: POSIX
$sel:lastUpdatedTime:RuleSummary' :: RuleSummary -> POSIX
lastUpdatedTime} -> POSIX
lastUpdatedTime) (\s :: RuleSummary
s@RuleSummary' {} POSIX
a -> RuleSummary
s {$sel:lastUpdatedTime:RuleSummary' :: POSIX
lastUpdatedTime = POSIX
a} :: RuleSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON RuleSummary where
  parseJSON :: Value -> Parser RuleSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RuleSummary"
      ( \Object
x ->
          Text
-> Text
-> Text
-> EventSourceName
-> RulePublishStatus
-> [ActionSummary]
-> POSIX
-> POSIX
-> RuleSummary
RuleSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"RuleId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"RuleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EventSourceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"PublishStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ActionSummaries"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CreatedTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"LastUpdatedTime")
      )

instance Prelude.Hashable RuleSummary where
  hashWithSalt :: Int -> RuleSummary -> Int
hashWithSalt Int
_salt RuleSummary' {[ActionSummary]
Text
POSIX
EventSourceName
RulePublishStatus
lastUpdatedTime :: POSIX
createdTime :: POSIX
actionSummaries :: [ActionSummary]
publishStatus :: RulePublishStatus
eventSourceName :: EventSourceName
ruleArn :: Text
ruleId :: Text
name :: Text
$sel:lastUpdatedTime:RuleSummary' :: RuleSummary -> POSIX
$sel:createdTime:RuleSummary' :: RuleSummary -> POSIX
$sel:actionSummaries:RuleSummary' :: RuleSummary -> [ActionSummary]
$sel:publishStatus:RuleSummary' :: RuleSummary -> RulePublishStatus
$sel:eventSourceName:RuleSummary' :: RuleSummary -> EventSourceName
$sel:ruleArn:RuleSummary' :: RuleSummary -> Text
$sel:ruleId:RuleSummary' :: RuleSummary -> Text
$sel:name:RuleSummary' :: RuleSummary -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EventSourceName
eventSourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RulePublishStatus
publishStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ActionSummary]
actionSummaries
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
createdTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
lastUpdatedTime

instance Prelude.NFData RuleSummary where
  rnf :: RuleSummary -> ()
rnf RuleSummary' {[ActionSummary]
Text
POSIX
EventSourceName
RulePublishStatus
lastUpdatedTime :: POSIX
createdTime :: POSIX
actionSummaries :: [ActionSummary]
publishStatus :: RulePublishStatus
eventSourceName :: EventSourceName
ruleArn :: Text
ruleId :: Text
name :: Text
$sel:lastUpdatedTime:RuleSummary' :: RuleSummary -> POSIX
$sel:createdTime:RuleSummary' :: RuleSummary -> POSIX
$sel:actionSummaries:RuleSummary' :: RuleSummary -> [ActionSummary]
$sel:publishStatus:RuleSummary' :: RuleSummary -> RulePublishStatus
$sel:eventSourceName:RuleSummary' :: RuleSummary -> EventSourceName
$sel:ruleArn:RuleSummary' :: RuleSummary -> Text
$sel:ruleId:RuleSummary' :: RuleSummary -> Text
$sel:name:RuleSummary' :: RuleSummary -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ruleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ruleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EventSourceName
eventSourceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RulePublishStatus
publishStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ActionSummary]
actionSummaries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
createdTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
lastUpdatedTime