{-# 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.CloudDirectory.Types.FacetAttributeDefinition where
import Amazonka.CloudDirectory.Types.FacetAttributeType
import Amazonka.CloudDirectory.Types.Rule
import Amazonka.CloudDirectory.Types.TypedAttributeValue
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data FacetAttributeDefinition = FacetAttributeDefinition'
{
FacetAttributeDefinition -> Maybe (HashMap Text Rule)
rules :: Prelude.Maybe (Prelude.HashMap Prelude.Text Rule),
FacetAttributeDefinition -> Maybe TypedAttributeValue
defaultValue :: Prelude.Maybe TypedAttributeValue,
FacetAttributeDefinition -> Maybe Bool
isImmutable :: Prelude.Maybe Prelude.Bool,
FacetAttributeDefinition -> FacetAttributeType
type' :: FacetAttributeType
}
deriving (FacetAttributeDefinition -> FacetAttributeDefinition -> Bool
(FacetAttributeDefinition -> FacetAttributeDefinition -> Bool)
-> (FacetAttributeDefinition -> FacetAttributeDefinition -> Bool)
-> Eq FacetAttributeDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FacetAttributeDefinition -> FacetAttributeDefinition -> Bool
$c/= :: FacetAttributeDefinition -> FacetAttributeDefinition -> Bool
== :: FacetAttributeDefinition -> FacetAttributeDefinition -> Bool
$c== :: FacetAttributeDefinition -> FacetAttributeDefinition -> Bool
Prelude.Eq, ReadPrec [FacetAttributeDefinition]
ReadPrec FacetAttributeDefinition
Int -> ReadS FacetAttributeDefinition
ReadS [FacetAttributeDefinition]
(Int -> ReadS FacetAttributeDefinition)
-> ReadS [FacetAttributeDefinition]
-> ReadPrec FacetAttributeDefinition
-> ReadPrec [FacetAttributeDefinition]
-> Read FacetAttributeDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FacetAttributeDefinition]
$creadListPrec :: ReadPrec [FacetAttributeDefinition]
readPrec :: ReadPrec FacetAttributeDefinition
$creadPrec :: ReadPrec FacetAttributeDefinition
readList :: ReadS [FacetAttributeDefinition]
$creadList :: ReadS [FacetAttributeDefinition]
readsPrec :: Int -> ReadS FacetAttributeDefinition
$creadsPrec :: Int -> ReadS FacetAttributeDefinition
Prelude.Read, Int -> FacetAttributeDefinition -> ShowS
[FacetAttributeDefinition] -> ShowS
FacetAttributeDefinition -> String
(Int -> FacetAttributeDefinition -> ShowS)
-> (FacetAttributeDefinition -> String)
-> ([FacetAttributeDefinition] -> ShowS)
-> Show FacetAttributeDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FacetAttributeDefinition] -> ShowS
$cshowList :: [FacetAttributeDefinition] -> ShowS
show :: FacetAttributeDefinition -> String
$cshow :: FacetAttributeDefinition -> String
showsPrec :: Int -> FacetAttributeDefinition -> ShowS
$cshowsPrec :: Int -> FacetAttributeDefinition -> ShowS
Prelude.Show, (forall x.
FacetAttributeDefinition -> Rep FacetAttributeDefinition x)
-> (forall x.
Rep FacetAttributeDefinition x -> FacetAttributeDefinition)
-> Generic FacetAttributeDefinition
forall x.
Rep FacetAttributeDefinition x -> FacetAttributeDefinition
forall x.
FacetAttributeDefinition -> Rep FacetAttributeDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FacetAttributeDefinition x -> FacetAttributeDefinition
$cfrom :: forall x.
FacetAttributeDefinition -> Rep FacetAttributeDefinition x
Prelude.Generic)
newFacetAttributeDefinition ::
FacetAttributeType ->
FacetAttributeDefinition
newFacetAttributeDefinition :: FacetAttributeType -> FacetAttributeDefinition
newFacetAttributeDefinition FacetAttributeType
pType_ =
FacetAttributeDefinition' :: Maybe (HashMap Text Rule)
-> Maybe TypedAttributeValue
-> Maybe Bool
-> FacetAttributeType
-> FacetAttributeDefinition
FacetAttributeDefinition'
{ $sel:rules:FacetAttributeDefinition' :: Maybe (HashMap Text Rule)
rules = Maybe (HashMap Text Rule)
forall a. Maybe a
Prelude.Nothing,
$sel:defaultValue:FacetAttributeDefinition' :: Maybe TypedAttributeValue
defaultValue = Maybe TypedAttributeValue
forall a. Maybe a
Prelude.Nothing,
$sel:isImmutable:FacetAttributeDefinition' :: Maybe Bool
isImmutable = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:type':FacetAttributeDefinition' :: FacetAttributeType
type' = FacetAttributeType
pType_
}
facetAttributeDefinition_rules :: Lens.Lens' FacetAttributeDefinition (Prelude.Maybe (Prelude.HashMap Prelude.Text Rule))
facetAttributeDefinition_rules :: (Maybe (HashMap Text Rule) -> f (Maybe (HashMap Text Rule)))
-> FacetAttributeDefinition -> f FacetAttributeDefinition
facetAttributeDefinition_rules = (FacetAttributeDefinition -> Maybe (HashMap Text Rule))
-> (FacetAttributeDefinition
-> Maybe (HashMap Text Rule) -> FacetAttributeDefinition)
-> Lens
FacetAttributeDefinition
FacetAttributeDefinition
(Maybe (HashMap Text Rule))
(Maybe (HashMap Text Rule))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeDefinition' {Maybe (HashMap Text Rule)
rules :: Maybe (HashMap Text Rule)
$sel:rules:FacetAttributeDefinition' :: FacetAttributeDefinition -> Maybe (HashMap Text Rule)
rules} -> Maybe (HashMap Text Rule)
rules) (\s :: FacetAttributeDefinition
s@FacetAttributeDefinition' {} Maybe (HashMap Text Rule)
a -> FacetAttributeDefinition
s {$sel:rules:FacetAttributeDefinition' :: Maybe (HashMap Text Rule)
rules = Maybe (HashMap Text Rule)
a} :: FacetAttributeDefinition) ((Maybe (HashMap Text Rule) -> f (Maybe (HashMap Text Rule)))
-> FacetAttributeDefinition -> f FacetAttributeDefinition)
-> ((Maybe (HashMap Text Rule) -> f (Maybe (HashMap Text Rule)))
-> Maybe (HashMap Text Rule) -> f (Maybe (HashMap Text Rule)))
-> (Maybe (HashMap Text Rule) -> f (Maybe (HashMap Text Rule)))
-> FacetAttributeDefinition
-> f FacetAttributeDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Rule)
(HashMap Text Rule)
(HashMap Text Rule)
(HashMap Text Rule)
-> Iso
(Maybe (HashMap Text Rule))
(Maybe (HashMap Text Rule))
(Maybe (HashMap Text Rule))
(Maybe (HashMap Text Rule))
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
(HashMap Text Rule)
(HashMap Text Rule)
(HashMap Text Rule)
(HashMap Text Rule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
facetAttributeDefinition_defaultValue :: Lens.Lens' FacetAttributeDefinition (Prelude.Maybe TypedAttributeValue)
facetAttributeDefinition_defaultValue :: (Maybe TypedAttributeValue -> f (Maybe TypedAttributeValue))
-> FacetAttributeDefinition -> f FacetAttributeDefinition
facetAttributeDefinition_defaultValue = (FacetAttributeDefinition -> Maybe TypedAttributeValue)
-> (FacetAttributeDefinition
-> Maybe TypedAttributeValue -> FacetAttributeDefinition)
-> Lens
FacetAttributeDefinition
FacetAttributeDefinition
(Maybe TypedAttributeValue)
(Maybe TypedAttributeValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeDefinition' {Maybe TypedAttributeValue
defaultValue :: Maybe TypedAttributeValue
$sel:defaultValue:FacetAttributeDefinition' :: FacetAttributeDefinition -> Maybe TypedAttributeValue
defaultValue} -> Maybe TypedAttributeValue
defaultValue) (\s :: FacetAttributeDefinition
s@FacetAttributeDefinition' {} Maybe TypedAttributeValue
a -> FacetAttributeDefinition
s {$sel:defaultValue:FacetAttributeDefinition' :: Maybe TypedAttributeValue
defaultValue = Maybe TypedAttributeValue
a} :: FacetAttributeDefinition)
facetAttributeDefinition_isImmutable :: Lens.Lens' FacetAttributeDefinition (Prelude.Maybe Prelude.Bool)
facetAttributeDefinition_isImmutable :: (Maybe Bool -> f (Maybe Bool))
-> FacetAttributeDefinition -> f FacetAttributeDefinition
facetAttributeDefinition_isImmutable = (FacetAttributeDefinition -> Maybe Bool)
-> (FacetAttributeDefinition
-> Maybe Bool -> FacetAttributeDefinition)
-> Lens
FacetAttributeDefinition
FacetAttributeDefinition
(Maybe Bool)
(Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeDefinition' {Maybe Bool
isImmutable :: Maybe Bool
$sel:isImmutable:FacetAttributeDefinition' :: FacetAttributeDefinition -> Maybe Bool
isImmutable} -> Maybe Bool
isImmutable) (\s :: FacetAttributeDefinition
s@FacetAttributeDefinition' {} Maybe Bool
a -> FacetAttributeDefinition
s {$sel:isImmutable:FacetAttributeDefinition' :: Maybe Bool
isImmutable = Maybe Bool
a} :: FacetAttributeDefinition)
facetAttributeDefinition_type :: Lens.Lens' FacetAttributeDefinition FacetAttributeType
facetAttributeDefinition_type :: (FacetAttributeType -> f FacetAttributeType)
-> FacetAttributeDefinition -> f FacetAttributeDefinition
facetAttributeDefinition_type = (FacetAttributeDefinition -> FacetAttributeType)
-> (FacetAttributeDefinition
-> FacetAttributeType -> FacetAttributeDefinition)
-> Lens
FacetAttributeDefinition
FacetAttributeDefinition
FacetAttributeType
FacetAttributeType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeDefinition' {FacetAttributeType
type' :: FacetAttributeType
$sel:type':FacetAttributeDefinition' :: FacetAttributeDefinition -> FacetAttributeType
type'} -> FacetAttributeType
type') (\s :: FacetAttributeDefinition
s@FacetAttributeDefinition' {} FacetAttributeType
a -> FacetAttributeDefinition
s {$sel:type':FacetAttributeDefinition' :: FacetAttributeType
type' = FacetAttributeType
a} :: FacetAttributeDefinition)
instance Core.FromJSON FacetAttributeDefinition where
parseJSON :: Value -> Parser FacetAttributeDefinition
parseJSON =
String
-> (Object -> Parser FacetAttributeDefinition)
-> Value
-> Parser FacetAttributeDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"FacetAttributeDefinition"
( \Object
x ->
Maybe (HashMap Text Rule)
-> Maybe TypedAttributeValue
-> Maybe Bool
-> FacetAttributeType
-> FacetAttributeDefinition
FacetAttributeDefinition'
(Maybe (HashMap Text Rule)
-> Maybe TypedAttributeValue
-> Maybe Bool
-> FacetAttributeType
-> FacetAttributeDefinition)
-> Parser (Maybe (HashMap Text Rule))
-> Parser
(Maybe TypedAttributeValue
-> Maybe Bool -> FacetAttributeType -> FacetAttributeDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Rule)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rules" Parser (Maybe (Maybe (HashMap Text Rule)))
-> Maybe (HashMap Text Rule) -> Parser (Maybe (HashMap Text Rule))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Rule)
forall a. Monoid a => a
Prelude.mempty)
Parser
(Maybe TypedAttributeValue
-> Maybe Bool -> FacetAttributeType -> FacetAttributeDefinition)
-> Parser (Maybe TypedAttributeValue)
-> Parser
(Maybe Bool -> FacetAttributeType -> FacetAttributeDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TypedAttributeValue)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DefaultValue")
Parser
(Maybe Bool -> FacetAttributeType -> FacetAttributeDefinition)
-> Parser (Maybe Bool)
-> Parser (FacetAttributeType -> FacetAttributeDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IsImmutable")
Parser (FacetAttributeType -> FacetAttributeDefinition)
-> Parser FacetAttributeType -> Parser FacetAttributeDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser FacetAttributeType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
)
instance Prelude.Hashable FacetAttributeDefinition
instance Prelude.NFData FacetAttributeDefinition
instance Core.ToJSON FacetAttributeDefinition where
toJSON :: FacetAttributeDefinition -> Value
toJSON FacetAttributeDefinition' {Maybe Bool
Maybe (HashMap Text Rule)
Maybe TypedAttributeValue
FacetAttributeType
type' :: FacetAttributeType
isImmutable :: Maybe Bool
defaultValue :: Maybe TypedAttributeValue
rules :: Maybe (HashMap Text Rule)
$sel:type':FacetAttributeDefinition' :: FacetAttributeDefinition -> FacetAttributeType
$sel:isImmutable:FacetAttributeDefinition' :: FacetAttributeDefinition -> Maybe Bool
$sel:defaultValue:FacetAttributeDefinition' :: FacetAttributeDefinition -> Maybe TypedAttributeValue
$sel:rules:FacetAttributeDefinition' :: FacetAttributeDefinition -> Maybe (HashMap Text Rule)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Rules" Text -> HashMap Text Rule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Rule -> Pair)
-> Maybe (HashMap Text Rule) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Rule)
rules,
(Text
"DefaultValue" Text -> TypedAttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TypedAttributeValue -> Pair)
-> Maybe TypedAttributeValue -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TypedAttributeValue
defaultValue,
(Text
"IsImmutable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isImmutable,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> FacetAttributeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FacetAttributeType
type')
]
)