{-# 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.FacetAttribute where
import Amazonka.CloudDirectory.Types.FacetAttributeDefinition
import Amazonka.CloudDirectory.Types.FacetAttributeReference
import Amazonka.CloudDirectory.Types.RequiredAttributeBehavior
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data FacetAttribute = FacetAttribute'
{
FacetAttribute -> Maybe FacetAttributeDefinition
attributeDefinition :: Prelude.Maybe FacetAttributeDefinition,
FacetAttribute -> Maybe FacetAttributeReference
attributeReference :: Prelude.Maybe FacetAttributeReference,
FacetAttribute -> Maybe RequiredAttributeBehavior
requiredBehavior :: Prelude.Maybe RequiredAttributeBehavior,
FacetAttribute -> Text
name :: Prelude.Text
}
deriving (FacetAttribute -> FacetAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FacetAttribute -> FacetAttribute -> Bool
$c/= :: FacetAttribute -> FacetAttribute -> Bool
== :: FacetAttribute -> FacetAttribute -> Bool
$c== :: FacetAttribute -> FacetAttribute -> Bool
Prelude.Eq, ReadPrec [FacetAttribute]
ReadPrec FacetAttribute
Int -> ReadS FacetAttribute
ReadS [FacetAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FacetAttribute]
$creadListPrec :: ReadPrec [FacetAttribute]
readPrec :: ReadPrec FacetAttribute
$creadPrec :: ReadPrec FacetAttribute
readList :: ReadS [FacetAttribute]
$creadList :: ReadS [FacetAttribute]
readsPrec :: Int -> ReadS FacetAttribute
$creadsPrec :: Int -> ReadS FacetAttribute
Prelude.Read, Int -> FacetAttribute -> ShowS
[FacetAttribute] -> ShowS
FacetAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FacetAttribute] -> ShowS
$cshowList :: [FacetAttribute] -> ShowS
show :: FacetAttribute -> String
$cshow :: FacetAttribute -> String
showsPrec :: Int -> FacetAttribute -> ShowS
$cshowsPrec :: Int -> FacetAttribute -> ShowS
Prelude.Show, forall x. Rep FacetAttribute x -> FacetAttribute
forall x. FacetAttribute -> Rep FacetAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FacetAttribute x -> FacetAttribute
$cfrom :: forall x. FacetAttribute -> Rep FacetAttribute x
Prelude.Generic)
newFacetAttribute ::
Prelude.Text ->
FacetAttribute
newFacetAttribute :: Text -> FacetAttribute
newFacetAttribute Text
pName_ =
FacetAttribute'
{ $sel:attributeDefinition:FacetAttribute' :: Maybe FacetAttributeDefinition
attributeDefinition =
forall a. Maybe a
Prelude.Nothing,
$sel:attributeReference:FacetAttribute' :: Maybe FacetAttributeReference
attributeReference = forall a. Maybe a
Prelude.Nothing,
$sel:requiredBehavior:FacetAttribute' :: Maybe RequiredAttributeBehavior
requiredBehavior = forall a. Maybe a
Prelude.Nothing,
$sel:name:FacetAttribute' :: Text
name = Text
pName_
}
facetAttribute_attributeDefinition :: Lens.Lens' FacetAttribute (Prelude.Maybe FacetAttributeDefinition)
facetAttribute_attributeDefinition :: Lens' FacetAttribute (Maybe FacetAttributeDefinition)
facetAttribute_attributeDefinition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttribute' {Maybe FacetAttributeDefinition
attributeDefinition :: Maybe FacetAttributeDefinition
$sel:attributeDefinition:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeDefinition
attributeDefinition} -> Maybe FacetAttributeDefinition
attributeDefinition) (\s :: FacetAttribute
s@FacetAttribute' {} Maybe FacetAttributeDefinition
a -> FacetAttribute
s {$sel:attributeDefinition:FacetAttribute' :: Maybe FacetAttributeDefinition
attributeDefinition = Maybe FacetAttributeDefinition
a} :: FacetAttribute)
facetAttribute_attributeReference :: Lens.Lens' FacetAttribute (Prelude.Maybe FacetAttributeReference)
facetAttribute_attributeReference :: Lens' FacetAttribute (Maybe FacetAttributeReference)
facetAttribute_attributeReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttribute' {Maybe FacetAttributeReference
attributeReference :: Maybe FacetAttributeReference
$sel:attributeReference:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeReference
attributeReference} -> Maybe FacetAttributeReference
attributeReference) (\s :: FacetAttribute
s@FacetAttribute' {} Maybe FacetAttributeReference
a -> FacetAttribute
s {$sel:attributeReference:FacetAttribute' :: Maybe FacetAttributeReference
attributeReference = Maybe FacetAttributeReference
a} :: FacetAttribute)
facetAttribute_requiredBehavior :: Lens.Lens' FacetAttribute (Prelude.Maybe RequiredAttributeBehavior)
facetAttribute_requiredBehavior :: Lens' FacetAttribute (Maybe RequiredAttributeBehavior)
facetAttribute_requiredBehavior = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttribute' {Maybe RequiredAttributeBehavior
requiredBehavior :: Maybe RequiredAttributeBehavior
$sel:requiredBehavior:FacetAttribute' :: FacetAttribute -> Maybe RequiredAttributeBehavior
requiredBehavior} -> Maybe RequiredAttributeBehavior
requiredBehavior) (\s :: FacetAttribute
s@FacetAttribute' {} Maybe RequiredAttributeBehavior
a -> FacetAttribute
s {$sel:requiredBehavior:FacetAttribute' :: Maybe RequiredAttributeBehavior
requiredBehavior = Maybe RequiredAttributeBehavior
a} :: FacetAttribute)
facetAttribute_name :: Lens.Lens' FacetAttribute Prelude.Text
facetAttribute_name :: Lens' FacetAttribute Text
facetAttribute_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttribute' {Text
name :: Text
$sel:name:FacetAttribute' :: FacetAttribute -> Text
name} -> Text
name) (\s :: FacetAttribute
s@FacetAttribute' {} Text
a -> FacetAttribute
s {$sel:name:FacetAttribute' :: Text
name = Text
a} :: FacetAttribute)
instance Data.FromJSON FacetAttribute where
parseJSON :: Value -> Parser FacetAttribute
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"FacetAttribute"
( \Object
x ->
Maybe FacetAttributeDefinition
-> Maybe FacetAttributeReference
-> Maybe RequiredAttributeBehavior
-> Text
-> FacetAttribute
FacetAttribute'
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
"AttributeDefinition")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AttributeReference")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RequiredBehavior")
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 FacetAttribute where
hashWithSalt :: Int -> FacetAttribute -> Int
hashWithSalt Int
_salt FacetAttribute' {Maybe FacetAttributeReference
Maybe RequiredAttributeBehavior
Maybe FacetAttributeDefinition
Text
name :: Text
requiredBehavior :: Maybe RequiredAttributeBehavior
attributeReference :: Maybe FacetAttributeReference
attributeDefinition :: Maybe FacetAttributeDefinition
$sel:name:FacetAttribute' :: FacetAttribute -> Text
$sel:requiredBehavior:FacetAttribute' :: FacetAttribute -> Maybe RequiredAttributeBehavior
$sel:attributeReference:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeReference
$sel:attributeDefinition:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeDefinition
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FacetAttributeDefinition
attributeDefinition
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FacetAttributeReference
attributeReference
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RequiredAttributeBehavior
requiredBehavior
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
instance Prelude.NFData FacetAttribute where
rnf :: FacetAttribute -> ()
rnf FacetAttribute' {Maybe FacetAttributeReference
Maybe RequiredAttributeBehavior
Maybe FacetAttributeDefinition
Text
name :: Text
requiredBehavior :: Maybe RequiredAttributeBehavior
attributeReference :: Maybe FacetAttributeReference
attributeDefinition :: Maybe FacetAttributeDefinition
$sel:name:FacetAttribute' :: FacetAttribute -> Text
$sel:requiredBehavior:FacetAttribute' :: FacetAttribute -> Maybe RequiredAttributeBehavior
$sel:attributeReference:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeReference
$sel:attributeDefinition:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeDefinition
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe FacetAttributeDefinition
attributeDefinition
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FacetAttributeReference
attributeReference
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RequiredAttributeBehavior
requiredBehavior
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
instance Data.ToJSON FacetAttribute where
toJSON :: FacetAttribute -> Value
toJSON FacetAttribute' {Maybe FacetAttributeReference
Maybe RequiredAttributeBehavior
Maybe FacetAttributeDefinition
Text
name :: Text
requiredBehavior :: Maybe RequiredAttributeBehavior
attributeReference :: Maybe FacetAttributeReference
attributeDefinition :: Maybe FacetAttributeDefinition
$sel:name:FacetAttribute' :: FacetAttribute -> Text
$sel:requiredBehavior:FacetAttribute' :: FacetAttribute -> Maybe RequiredAttributeBehavior
$sel:attributeReference:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeReference
$sel:attributeDefinition:FacetAttribute' :: FacetAttribute -> Maybe FacetAttributeDefinition
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"AttributeDefinition" 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 FacetAttributeDefinition
attributeDefinition,
(Key
"AttributeReference" 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 FacetAttributeReference
attributeReference,
(Key
"RequiredBehavior" 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 RequiredAttributeBehavior
requiredBehavior,
forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
]
)