{-# 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.IoTAnalytics.Types.LateDataRule
-- 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.IoTAnalytics.Types.LateDataRule where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.LateDataRuleConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains the name and configuration information of a
-- late data rule.
--
-- /See:/ 'newLateDataRule' smart constructor.
data LateDataRule = LateDataRule'
  { -- | The name of the late data rule.
    LateDataRule -> Maybe Text
ruleName :: Prelude.Maybe Prelude.Text,
    -- | The information needed to configure the late data rule.
    LateDataRule -> LateDataRuleConfiguration
ruleConfiguration :: LateDataRuleConfiguration
  }
  deriving (LateDataRule -> LateDataRule -> Bool
(LateDataRule -> LateDataRule -> Bool)
-> (LateDataRule -> LateDataRule -> Bool) -> Eq LateDataRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LateDataRule -> LateDataRule -> Bool
$c/= :: LateDataRule -> LateDataRule -> Bool
== :: LateDataRule -> LateDataRule -> Bool
$c== :: LateDataRule -> LateDataRule -> Bool
Prelude.Eq, ReadPrec [LateDataRule]
ReadPrec LateDataRule
Int -> ReadS LateDataRule
ReadS [LateDataRule]
(Int -> ReadS LateDataRule)
-> ReadS [LateDataRule]
-> ReadPrec LateDataRule
-> ReadPrec [LateDataRule]
-> Read LateDataRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LateDataRule]
$creadListPrec :: ReadPrec [LateDataRule]
readPrec :: ReadPrec LateDataRule
$creadPrec :: ReadPrec LateDataRule
readList :: ReadS [LateDataRule]
$creadList :: ReadS [LateDataRule]
readsPrec :: Int -> ReadS LateDataRule
$creadsPrec :: Int -> ReadS LateDataRule
Prelude.Read, Int -> LateDataRule -> ShowS
[LateDataRule] -> ShowS
LateDataRule -> String
(Int -> LateDataRule -> ShowS)
-> (LateDataRule -> String)
-> ([LateDataRule] -> ShowS)
-> Show LateDataRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LateDataRule] -> ShowS
$cshowList :: [LateDataRule] -> ShowS
show :: LateDataRule -> String
$cshow :: LateDataRule -> String
showsPrec :: Int -> LateDataRule -> ShowS
$cshowsPrec :: Int -> LateDataRule -> ShowS
Prelude.Show, (forall x. LateDataRule -> Rep LateDataRule x)
-> (forall x. Rep LateDataRule x -> LateDataRule)
-> Generic LateDataRule
forall x. Rep LateDataRule x -> LateDataRule
forall x. LateDataRule -> Rep LateDataRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LateDataRule x -> LateDataRule
$cfrom :: forall x. LateDataRule -> Rep LateDataRule x
Prelude.Generic)

-- |
-- Create a value of 'LateDataRule' 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:
--
-- 'ruleName', 'lateDataRule_ruleName' - The name of the late data rule.
--
-- 'ruleConfiguration', 'lateDataRule_ruleConfiguration' - The information needed to configure the late data rule.
newLateDataRule ::
  -- | 'ruleConfiguration'
  LateDataRuleConfiguration ->
  LateDataRule
newLateDataRule :: LateDataRuleConfiguration -> LateDataRule
newLateDataRule LateDataRuleConfiguration
pRuleConfiguration_ =
  LateDataRule' :: Maybe Text -> LateDataRuleConfiguration -> LateDataRule
LateDataRule'
    { $sel:ruleName:LateDataRule' :: Maybe Text
ruleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleConfiguration:LateDataRule' :: LateDataRuleConfiguration
ruleConfiguration = LateDataRuleConfiguration
pRuleConfiguration_
    }

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

-- | The information needed to configure the late data rule.
lateDataRule_ruleConfiguration :: Lens.Lens' LateDataRule LateDataRuleConfiguration
lateDataRule_ruleConfiguration :: (LateDataRuleConfiguration -> f LateDataRuleConfiguration)
-> LateDataRule -> f LateDataRule
lateDataRule_ruleConfiguration = (LateDataRule -> LateDataRuleConfiguration)
-> (LateDataRule -> LateDataRuleConfiguration -> LateDataRule)
-> Lens
     LateDataRule
     LateDataRule
     LateDataRuleConfiguration
     LateDataRuleConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LateDataRule' {LateDataRuleConfiguration
ruleConfiguration :: LateDataRuleConfiguration
$sel:ruleConfiguration:LateDataRule' :: LateDataRule -> LateDataRuleConfiguration
ruleConfiguration} -> LateDataRuleConfiguration
ruleConfiguration) (\s :: LateDataRule
s@LateDataRule' {} LateDataRuleConfiguration
a -> LateDataRule
s {$sel:ruleConfiguration:LateDataRule' :: LateDataRuleConfiguration
ruleConfiguration = LateDataRuleConfiguration
a} :: LateDataRule)

instance Core.FromJSON LateDataRule where
  parseJSON :: Value -> Parser LateDataRule
parseJSON =
    String
-> (Object -> Parser LateDataRule) -> Value -> Parser LateDataRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LateDataRule"
      ( \Object
x ->
          Maybe Text -> LateDataRuleConfiguration -> LateDataRule
LateDataRule'
            (Maybe Text -> LateDataRuleConfiguration -> LateDataRule)
-> Parser (Maybe Text)
-> Parser (LateDataRuleConfiguration -> LateDataRule)
forall (f :: * -> *) a b. Functor 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 (LateDataRuleConfiguration -> LateDataRule)
-> Parser LateDataRuleConfiguration -> Parser LateDataRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LateDataRuleConfiguration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ruleConfiguration")
      )

instance Prelude.Hashable LateDataRule

instance Prelude.NFData LateDataRule

instance Core.ToJSON LateDataRule where
  toJSON :: LateDataRule -> Value
toJSON LateDataRule' {Maybe Text
LateDataRuleConfiguration
ruleConfiguration :: LateDataRuleConfiguration
ruleName :: Maybe Text
$sel:ruleConfiguration:LateDataRule' :: LateDataRule -> LateDataRuleConfiguration
$sel:ruleName:LateDataRule' :: LateDataRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ruleName" 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
ruleName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ruleConfiguration" Text -> LateDataRuleConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LateDataRuleConfiguration
ruleConfiguration)
          ]
      )