{-# 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 Amazonka.IoT.Types.AggregationTypeName
import qualified Amazonka.Lens as Lens
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
(AggregationType -> AggregationType -> Bool)
-> (AggregationType -> AggregationType -> Bool)
-> Eq AggregationType
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]
(Int -> ReadS AggregationType)
-> ReadS [AggregationType]
-> ReadPrec AggregationType
-> ReadPrec [AggregationType]
-> Read 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
(Int -> AggregationType -> ShowS)
-> (AggregationType -> String)
-> ([AggregationType] -> ShowS)
-> Show AggregationType
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. AggregationType -> Rep AggregationType x)
-> (forall x. Rep AggregationType x -> AggregationType)
-> Generic AggregationType
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' :: Maybe [Text] -> AggregationTypeName -> AggregationType
AggregationType'
{ $sel:values:AggregationType' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:name:AggregationType' :: AggregationTypeName
name = AggregationTypeName
pName_
}
aggregationType_values :: Lens.Lens' AggregationType (Prelude.Maybe [Prelude.Text])
aggregationType_values :: (Maybe [Text] -> f (Maybe [Text]))
-> AggregationType -> f AggregationType
aggregationType_values = (AggregationType -> Maybe [Text])
-> (AggregationType -> Maybe [Text] -> AggregationType)
-> Lens
AggregationType AggregationType (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
-> AggregationType -> f AggregationType)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AggregationType
-> f AggregationType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
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 :: (AggregationTypeName -> f AggregationTypeName)
-> AggregationType -> f AggregationType
aggregationType_name = (AggregationType -> AggregationTypeName)
-> (AggregationType -> AggregationTypeName -> AggregationType)
-> Lens
AggregationType
AggregationType
AggregationTypeName
AggregationTypeName
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 Core.FromJSON AggregationType where
parseJSON :: Value -> Parser AggregationType
parseJSON =
String
-> (Object -> Parser AggregationType)
-> Value
-> Parser AggregationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AggregationType"
( \Object
x ->
Maybe [Text] -> AggregationTypeName -> AggregationType
AggregationType'
(Maybe [Text] -> AggregationTypeName -> AggregationType)
-> Parser (Maybe [Text])
-> Parser (AggregationTypeName -> AggregationType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"values" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (AggregationTypeName -> AggregationType)
-> Parser AggregationTypeName -> Parser AggregationType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AggregationTypeName
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
)
instance Prelude.Hashable AggregationType
instance Prelude.NFData AggregationType
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"values" 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]
values,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> AggregationTypeName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AggregationTypeName
name)
]
)