{-# 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.IoT.Types.TopicRuleListItem
-- 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)
module Amazonka.IoT.Types.TopicRuleListItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a rule.
--
-- /See:/ 'newTopicRuleListItem' smart constructor.
data TopicRuleListItem = TopicRuleListItem'
  { -- | The date and time the rule was created.
    TopicRuleListItem -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | Specifies whether the rule is disabled.
    TopicRuleListItem -> Maybe Bool
ruleDisabled :: Prelude.Maybe Prelude.Bool,
    -- | The name of the rule.
    TopicRuleListItem -> Maybe Text
ruleName :: Prelude.Maybe Prelude.Text,
    -- | The rule ARN.
    TopicRuleListItem -> Maybe Text
ruleArn :: Prelude.Maybe Prelude.Text,
    -- | The pattern for the topic names that apply.
    TopicRuleListItem -> Maybe Text
topicPattern :: Prelude.Maybe Prelude.Text
  }
  deriving (TopicRuleListItem -> TopicRuleListItem -> Bool
(TopicRuleListItem -> TopicRuleListItem -> Bool)
-> (TopicRuleListItem -> TopicRuleListItem -> Bool)
-> Eq TopicRuleListItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopicRuleListItem -> TopicRuleListItem -> Bool
$c/= :: TopicRuleListItem -> TopicRuleListItem -> Bool
== :: TopicRuleListItem -> TopicRuleListItem -> Bool
$c== :: TopicRuleListItem -> TopicRuleListItem -> Bool
Prelude.Eq, ReadPrec [TopicRuleListItem]
ReadPrec TopicRuleListItem
Int -> ReadS TopicRuleListItem
ReadS [TopicRuleListItem]
(Int -> ReadS TopicRuleListItem)
-> ReadS [TopicRuleListItem]
-> ReadPrec TopicRuleListItem
-> ReadPrec [TopicRuleListItem]
-> Read TopicRuleListItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopicRuleListItem]
$creadListPrec :: ReadPrec [TopicRuleListItem]
readPrec :: ReadPrec TopicRuleListItem
$creadPrec :: ReadPrec TopicRuleListItem
readList :: ReadS [TopicRuleListItem]
$creadList :: ReadS [TopicRuleListItem]
readsPrec :: Int -> ReadS TopicRuleListItem
$creadsPrec :: Int -> ReadS TopicRuleListItem
Prelude.Read, Int -> TopicRuleListItem -> ShowS
[TopicRuleListItem] -> ShowS
TopicRuleListItem -> String
(Int -> TopicRuleListItem -> ShowS)
-> (TopicRuleListItem -> String)
-> ([TopicRuleListItem] -> ShowS)
-> Show TopicRuleListItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopicRuleListItem] -> ShowS
$cshowList :: [TopicRuleListItem] -> ShowS
show :: TopicRuleListItem -> String
$cshow :: TopicRuleListItem -> String
showsPrec :: Int -> TopicRuleListItem -> ShowS
$cshowsPrec :: Int -> TopicRuleListItem -> ShowS
Prelude.Show, (forall x. TopicRuleListItem -> Rep TopicRuleListItem x)
-> (forall x. Rep TopicRuleListItem x -> TopicRuleListItem)
-> Generic TopicRuleListItem
forall x. Rep TopicRuleListItem x -> TopicRuleListItem
forall x. TopicRuleListItem -> Rep TopicRuleListItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TopicRuleListItem x -> TopicRuleListItem
$cfrom :: forall x. TopicRuleListItem -> Rep TopicRuleListItem x
Prelude.Generic)

-- |
-- Create a value of 'TopicRuleListItem' 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:
--
-- 'createdAt', 'topicRuleListItem_createdAt' - The date and time the rule was created.
--
-- 'ruleDisabled', 'topicRuleListItem_ruleDisabled' - Specifies whether the rule is disabled.
--
-- 'ruleName', 'topicRuleListItem_ruleName' - The name of the rule.
--
-- 'ruleArn', 'topicRuleListItem_ruleArn' - The rule ARN.
--
-- 'topicPattern', 'topicRuleListItem_topicPattern' - The pattern for the topic names that apply.
newTopicRuleListItem ::
  TopicRuleListItem
newTopicRuleListItem :: TopicRuleListItem
newTopicRuleListItem =
  TopicRuleListItem' :: Maybe POSIX
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TopicRuleListItem
TopicRuleListItem'
    { $sel:createdAt:TopicRuleListItem' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleDisabled:TopicRuleListItem' :: Maybe Bool
ruleDisabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleName:TopicRuleListItem' :: Maybe Text
ruleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleArn:TopicRuleListItem' :: Maybe Text
ruleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:topicPattern:TopicRuleListItem' :: Maybe Text
topicPattern = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time the rule was created.
topicRuleListItem_createdAt :: Lens.Lens' TopicRuleListItem (Prelude.Maybe Prelude.UTCTime)
topicRuleListItem_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TopicRuleListItem -> f TopicRuleListItem
topicRuleListItem_createdAt = (TopicRuleListItem -> Maybe POSIX)
-> (TopicRuleListItem -> Maybe POSIX -> TopicRuleListItem)
-> Lens
     TopicRuleListItem TopicRuleListItem (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicRuleListItem' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:TopicRuleListItem' :: TopicRuleListItem -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: TopicRuleListItem
s@TopicRuleListItem' {} Maybe POSIX
a -> TopicRuleListItem
s {$sel:createdAt:TopicRuleListItem' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: TopicRuleListItem) ((Maybe POSIX -> f (Maybe POSIX))
 -> TopicRuleListItem -> f TopicRuleListItem)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TopicRuleListItem
-> f TopicRuleListItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Specifies whether the rule is disabled.
topicRuleListItem_ruleDisabled :: Lens.Lens' TopicRuleListItem (Prelude.Maybe Prelude.Bool)
topicRuleListItem_ruleDisabled :: (Maybe Bool -> f (Maybe Bool))
-> TopicRuleListItem -> f TopicRuleListItem
topicRuleListItem_ruleDisabled = (TopicRuleListItem -> Maybe Bool)
-> (TopicRuleListItem -> Maybe Bool -> TopicRuleListItem)
-> Lens
     TopicRuleListItem TopicRuleListItem (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicRuleListItem' {Maybe Bool
ruleDisabled :: Maybe Bool
$sel:ruleDisabled:TopicRuleListItem' :: TopicRuleListItem -> Maybe Bool
ruleDisabled} -> Maybe Bool
ruleDisabled) (\s :: TopicRuleListItem
s@TopicRuleListItem' {} Maybe Bool
a -> TopicRuleListItem
s {$sel:ruleDisabled:TopicRuleListItem' :: Maybe Bool
ruleDisabled = Maybe Bool
a} :: TopicRuleListItem)

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

-- | The rule ARN.
topicRuleListItem_ruleArn :: Lens.Lens' TopicRuleListItem (Prelude.Maybe Prelude.Text)
topicRuleListItem_ruleArn :: (Maybe Text -> f (Maybe Text))
-> TopicRuleListItem -> f TopicRuleListItem
topicRuleListItem_ruleArn = (TopicRuleListItem -> Maybe Text)
-> (TopicRuleListItem -> Maybe Text -> TopicRuleListItem)
-> Lens
     TopicRuleListItem TopicRuleListItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicRuleListItem' {Maybe Text
ruleArn :: Maybe Text
$sel:ruleArn:TopicRuleListItem' :: TopicRuleListItem -> Maybe Text
ruleArn} -> Maybe Text
ruleArn) (\s :: TopicRuleListItem
s@TopicRuleListItem' {} Maybe Text
a -> TopicRuleListItem
s {$sel:ruleArn:TopicRuleListItem' :: Maybe Text
ruleArn = Maybe Text
a} :: TopicRuleListItem)

-- | The pattern for the topic names that apply.
topicRuleListItem_topicPattern :: Lens.Lens' TopicRuleListItem (Prelude.Maybe Prelude.Text)
topicRuleListItem_topicPattern :: (Maybe Text -> f (Maybe Text))
-> TopicRuleListItem -> f TopicRuleListItem
topicRuleListItem_topicPattern = (TopicRuleListItem -> Maybe Text)
-> (TopicRuleListItem -> Maybe Text -> TopicRuleListItem)
-> Lens
     TopicRuleListItem TopicRuleListItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicRuleListItem' {Maybe Text
topicPattern :: Maybe Text
$sel:topicPattern:TopicRuleListItem' :: TopicRuleListItem -> Maybe Text
topicPattern} -> Maybe Text
topicPattern) (\s :: TopicRuleListItem
s@TopicRuleListItem' {} Maybe Text
a -> TopicRuleListItem
s {$sel:topicPattern:TopicRuleListItem' :: Maybe Text
topicPattern = Maybe Text
a} :: TopicRuleListItem)

instance Core.FromJSON TopicRuleListItem where
  parseJSON :: Value -> Parser TopicRuleListItem
parseJSON =
    String
-> (Object -> Parser TopicRuleListItem)
-> Value
-> Parser TopicRuleListItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TopicRuleListItem"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TopicRuleListItem
TopicRuleListItem'
            (Maybe POSIX
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> TopicRuleListItem)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Bool
      -> Maybe Text -> Maybe Text -> Maybe Text -> TopicRuleListItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"createdAt")
            Parser
  (Maybe Bool
   -> Maybe Text -> Maybe Text -> Maybe Text -> TopicRuleListItem)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> TopicRuleListItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ruleDisabled")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> TopicRuleListItem)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> TopicRuleListItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ruleName")
            Parser (Maybe Text -> Maybe Text -> TopicRuleListItem)
-> Parser (Maybe Text) -> Parser (Maybe Text -> TopicRuleListItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ruleArn")
            Parser (Maybe Text -> TopicRuleListItem)
-> Parser (Maybe Text) -> Parser TopicRuleListItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"topicPattern")
      )

instance Prelude.Hashable TopicRuleListItem

instance Prelude.NFData TopicRuleListItem