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