{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTAnalytics.Types.LateDataRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTAnalytics.Types.LateDataRuleConfiguration
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
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]
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
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. 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'
    { $sel:ruleName:LateDataRule' :: Maybe Text
ruleName = 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 :: Lens' LateDataRule (Maybe Text)
lateDataRule_ruleName = 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 :: Lens' LateDataRule LateDataRuleConfiguration
lateDataRule_ruleConfiguration = 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 Data.FromJSON LateDataRule where
  parseJSON :: Value -> Parser LateDataRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LateDataRule"
      ( \Object
x ->
          Maybe Text -> LateDataRuleConfiguration -> LateDataRule
LateDataRule'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ruleName")
            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
"ruleConfiguration")
      )

instance Prelude.Hashable LateDataRule where
  hashWithSalt :: Int -> LateDataRule -> Int
hashWithSalt Int
_salt LateDataRule' {Maybe Text
LateDataRuleConfiguration
ruleConfiguration :: LateDataRuleConfiguration
ruleName :: Maybe Text
$sel:ruleConfiguration:LateDataRule' :: LateDataRule -> LateDataRuleConfiguration
$sel:ruleName:LateDataRule' :: LateDataRule -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LateDataRuleConfiguration
ruleConfiguration

instance Prelude.NFData LateDataRule where
  rnf :: LateDataRule -> ()
rnf LateDataRule' {Maybe Text
LateDataRuleConfiguration
ruleConfiguration :: LateDataRuleConfiguration
ruleName :: Maybe Text
$sel:ruleConfiguration:LateDataRule' :: LateDataRule -> LateDataRuleConfiguration
$sel:ruleName:LateDataRule' :: LateDataRule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LateDataRuleConfiguration
ruleConfiguration

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ruleName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleName,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ruleConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LateDataRuleConfiguration
ruleConfiguration)
          ]
      )