{-# 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.Pinpoint.Types.AttributeDimension where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.AttributeType
import qualified Amazonka.Prelude as Prelude
data AttributeDimension = AttributeDimension'
{
AttributeDimension -> Maybe AttributeType
attributeType :: Prelude.Maybe AttributeType,
AttributeDimension -> [Text]
values :: [Prelude.Text]
}
deriving (AttributeDimension -> AttributeDimension -> Bool
(AttributeDimension -> AttributeDimension -> Bool)
-> (AttributeDimension -> AttributeDimension -> Bool)
-> Eq AttributeDimension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeDimension -> AttributeDimension -> Bool
$c/= :: AttributeDimension -> AttributeDimension -> Bool
== :: AttributeDimension -> AttributeDimension -> Bool
$c== :: AttributeDimension -> AttributeDimension -> Bool
Prelude.Eq, ReadPrec [AttributeDimension]
ReadPrec AttributeDimension
Int -> ReadS AttributeDimension
ReadS [AttributeDimension]
(Int -> ReadS AttributeDimension)
-> ReadS [AttributeDimension]
-> ReadPrec AttributeDimension
-> ReadPrec [AttributeDimension]
-> Read AttributeDimension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttributeDimension]
$creadListPrec :: ReadPrec [AttributeDimension]
readPrec :: ReadPrec AttributeDimension
$creadPrec :: ReadPrec AttributeDimension
readList :: ReadS [AttributeDimension]
$creadList :: ReadS [AttributeDimension]
readsPrec :: Int -> ReadS AttributeDimension
$creadsPrec :: Int -> ReadS AttributeDimension
Prelude.Read, Int -> AttributeDimension -> ShowS
[AttributeDimension] -> ShowS
AttributeDimension -> String
(Int -> AttributeDimension -> ShowS)
-> (AttributeDimension -> String)
-> ([AttributeDimension] -> ShowS)
-> Show AttributeDimension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributeDimension] -> ShowS
$cshowList :: [AttributeDimension] -> ShowS
show :: AttributeDimension -> String
$cshow :: AttributeDimension -> String
showsPrec :: Int -> AttributeDimension -> ShowS
$cshowsPrec :: Int -> AttributeDimension -> ShowS
Prelude.Show, (forall x. AttributeDimension -> Rep AttributeDimension x)
-> (forall x. Rep AttributeDimension x -> AttributeDimension)
-> Generic AttributeDimension
forall x. Rep AttributeDimension x -> AttributeDimension
forall x. AttributeDimension -> Rep AttributeDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributeDimension x -> AttributeDimension
$cfrom :: forall x. AttributeDimension -> Rep AttributeDimension x
Prelude.Generic)
newAttributeDimension ::
AttributeDimension
newAttributeDimension :: AttributeDimension
newAttributeDimension =
AttributeDimension' :: Maybe AttributeType -> [Text] -> AttributeDimension
AttributeDimension'
{ $sel:attributeType:AttributeDimension' :: Maybe AttributeType
attributeType =
Maybe AttributeType
forall a. Maybe a
Prelude.Nothing,
$sel:values:AttributeDimension' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty
}
attributeDimension_attributeType :: Lens.Lens' AttributeDimension (Prelude.Maybe AttributeType)
attributeDimension_attributeType :: (Maybe AttributeType -> f (Maybe AttributeType))
-> AttributeDimension -> f AttributeDimension
attributeDimension_attributeType = (AttributeDimension -> Maybe AttributeType)
-> (AttributeDimension
-> Maybe AttributeType -> AttributeDimension)
-> Lens
AttributeDimension
AttributeDimension
(Maybe AttributeType)
(Maybe AttributeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeDimension' {Maybe AttributeType
attributeType :: Maybe AttributeType
$sel:attributeType:AttributeDimension' :: AttributeDimension -> Maybe AttributeType
attributeType} -> Maybe AttributeType
attributeType) (\s :: AttributeDimension
s@AttributeDimension' {} Maybe AttributeType
a -> AttributeDimension
s {$sel:attributeType:AttributeDimension' :: Maybe AttributeType
attributeType = Maybe AttributeType
a} :: AttributeDimension)
attributeDimension_values :: Lens.Lens' AttributeDimension [Prelude.Text]
attributeDimension_values :: ([Text] -> f [Text]) -> AttributeDimension -> f AttributeDimension
attributeDimension_values = (AttributeDimension -> [Text])
-> (AttributeDimension -> [Text] -> AttributeDimension)
-> Lens AttributeDimension AttributeDimension [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeDimension' {[Text]
values :: [Text]
$sel:values:AttributeDimension' :: AttributeDimension -> [Text]
values} -> [Text]
values) (\s :: AttributeDimension
s@AttributeDimension' {} [Text]
a -> AttributeDimension
s {$sel:values:AttributeDimension' :: [Text]
values = [Text]
a} :: AttributeDimension) (([Text] -> f [Text])
-> AttributeDimension -> f AttributeDimension)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> AttributeDimension
-> f AttributeDimension
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON AttributeDimension where
parseJSON :: Value -> Parser AttributeDimension
parseJSON =
String
-> (Object -> Parser AttributeDimension)
-> Value
-> Parser AttributeDimension
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AttributeDimension"
( \Object
x ->
Maybe AttributeType -> [Text] -> AttributeDimension
AttributeDimension'
(Maybe AttributeType -> [Text] -> AttributeDimension)
-> Parser (Maybe AttributeType)
-> Parser ([Text] -> AttributeDimension)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AttributeType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttributeType")
Parser ([Text] -> AttributeDimension)
-> Parser [Text] -> Parser AttributeDimension
forall (f :: * -> *) a b. Applicative f => 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
"Values" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable AttributeDimension
instance Prelude.NFData AttributeDimension
instance Core.ToJSON AttributeDimension where
toJSON :: AttributeDimension -> Value
toJSON AttributeDimension' {[Text]
Maybe AttributeType
values :: [Text]
attributeType :: Maybe AttributeType
$sel:values:AttributeDimension' :: AttributeDimension -> [Text]
$sel:attributeType:AttributeDimension' :: AttributeDimension -> Maybe AttributeType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"AttributeType" Text -> AttributeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AttributeType -> Pair) -> Maybe AttributeType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributeType
attributeType,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
values)
]
)