{-# 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 #-}
module Amazonka.IoTEvents.Types.InputDefinition where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.Attribute
import qualified Amazonka.Prelude as Prelude
data InputDefinition = InputDefinition'
{
InputDefinition -> NonEmpty Attribute
attributes :: Prelude.NonEmpty Attribute
}
deriving (InputDefinition -> InputDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputDefinition -> InputDefinition -> Bool
$c/= :: InputDefinition -> InputDefinition -> Bool
== :: InputDefinition -> InputDefinition -> Bool
$c== :: InputDefinition -> InputDefinition -> Bool
Prelude.Eq, ReadPrec [InputDefinition]
ReadPrec InputDefinition
Int -> ReadS InputDefinition
ReadS [InputDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputDefinition]
$creadListPrec :: ReadPrec [InputDefinition]
readPrec :: ReadPrec InputDefinition
$creadPrec :: ReadPrec InputDefinition
readList :: ReadS [InputDefinition]
$creadList :: ReadS [InputDefinition]
readsPrec :: Int -> ReadS InputDefinition
$creadsPrec :: Int -> ReadS InputDefinition
Prelude.Read, Int -> InputDefinition -> ShowS
[InputDefinition] -> ShowS
InputDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputDefinition] -> ShowS
$cshowList :: [InputDefinition] -> ShowS
show :: InputDefinition -> String
$cshow :: InputDefinition -> String
showsPrec :: Int -> InputDefinition -> ShowS
$cshowsPrec :: Int -> InputDefinition -> ShowS
Prelude.Show, forall x. Rep InputDefinition x -> InputDefinition
forall x. InputDefinition -> Rep InputDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputDefinition x -> InputDefinition
$cfrom :: forall x. InputDefinition -> Rep InputDefinition x
Prelude.Generic)
newInputDefinition ::
Prelude.NonEmpty Attribute ->
InputDefinition
newInputDefinition :: NonEmpty Attribute -> InputDefinition
newInputDefinition NonEmpty Attribute
pAttributes_ =
InputDefinition'
{ $sel:attributes:InputDefinition' :: NonEmpty Attribute
attributes =
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Attribute
pAttributes_
}
inputDefinition_attributes :: Lens.Lens' InputDefinition (Prelude.NonEmpty Attribute)
inputDefinition_attributes :: Lens' InputDefinition (NonEmpty Attribute)
inputDefinition_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDefinition' {NonEmpty Attribute
attributes :: NonEmpty Attribute
$sel:attributes:InputDefinition' :: InputDefinition -> NonEmpty Attribute
attributes} -> NonEmpty Attribute
attributes) (\s :: InputDefinition
s@InputDefinition' {} NonEmpty Attribute
a -> InputDefinition
s {$sel:attributes:InputDefinition' :: NonEmpty Attribute
attributes = NonEmpty Attribute
a} :: InputDefinition) 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
instance Data.FromJSON InputDefinition where
parseJSON :: Value -> Parser InputDefinition
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"InputDefinition"
( \Object
x ->
NonEmpty Attribute -> InputDefinition
InputDefinition'
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
"attributes")
)
instance Prelude.Hashable InputDefinition where
hashWithSalt :: Int -> InputDefinition -> Int
hashWithSalt Int
_salt InputDefinition' {NonEmpty Attribute
attributes :: NonEmpty Attribute
$sel:attributes:InputDefinition' :: InputDefinition -> NonEmpty Attribute
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Attribute
attributes
instance Prelude.NFData InputDefinition where
rnf :: InputDefinition -> ()
rnf InputDefinition' {NonEmpty Attribute
attributes :: NonEmpty Attribute
$sel:attributes:InputDefinition' :: InputDefinition -> NonEmpty Attribute
..} = forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Attribute
attributes
instance Data.ToJSON InputDefinition where
toJSON :: InputDefinition -> Value
toJSON InputDefinition' {NonEmpty Attribute
attributes :: NonEmpty Attribute
$sel:attributes:InputDefinition' :: InputDefinition -> NonEmpty Attribute
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[forall a. a -> Maybe a
Prelude.Just (Key
"attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Attribute
attributes)]
)