{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudDirectory.Types.Facet
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudDirectory.Types.Facet where

import Amazonka.CloudDirectory.Types.FacetStyle
import Amazonka.CloudDirectory.Types.ObjectType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains @Name@, @ARN@, @Attributes@, @ Rules@, and
-- @ObjectTypes@. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_whatarefacets.html Facets>
-- for more information.
--
-- /See:/ 'newFacet' smart constructor.
data Facet = Facet'
  { -- | There are two different styles that you can define on any given facet,
    -- @Static@ and @Dynamic@. For static facets, all attributes must be
    -- defined in the schema. For dynamic facets, attributes can be defined
    -- during data plane operations.
    Facet -> Maybe FacetStyle
facetStyle :: Prelude.Maybe FacetStyle,
    -- | The object type that is associated with the facet. See
    -- CreateFacetRequest$ObjectType for more details.
    Facet -> Maybe ObjectType
objectType :: Prelude.Maybe ObjectType,
    -- | The name of the Facet.
    Facet -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Facet -> Facet -> Bool
(Facet -> Facet -> Bool) -> (Facet -> Facet -> Bool) -> Eq Facet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Facet -> Facet -> Bool
$c/= :: Facet -> Facet -> Bool
== :: Facet -> Facet -> Bool
$c== :: Facet -> Facet -> Bool
Prelude.Eq, ReadPrec [Facet]
ReadPrec Facet
Int -> ReadS Facet
ReadS [Facet]
(Int -> ReadS Facet)
-> ReadS [Facet]
-> ReadPrec Facet
-> ReadPrec [Facet]
-> Read Facet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Facet]
$creadListPrec :: ReadPrec [Facet]
readPrec :: ReadPrec Facet
$creadPrec :: ReadPrec Facet
readList :: ReadS [Facet]
$creadList :: ReadS [Facet]
readsPrec :: Int -> ReadS Facet
$creadsPrec :: Int -> ReadS Facet
Prelude.Read, Int -> Facet -> ShowS
[Facet] -> ShowS
Facet -> String
(Int -> Facet -> ShowS)
-> (Facet -> String) -> ([Facet] -> ShowS) -> Show Facet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Facet] -> ShowS
$cshowList :: [Facet] -> ShowS
show :: Facet -> String
$cshow :: Facet -> String
showsPrec :: Int -> Facet -> ShowS
$cshowsPrec :: Int -> Facet -> ShowS
Prelude.Show, (forall x. Facet -> Rep Facet x)
-> (forall x. Rep Facet x -> Facet) -> Generic Facet
forall x. Rep Facet x -> Facet
forall x. Facet -> Rep Facet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Facet x -> Facet
$cfrom :: forall x. Facet -> Rep Facet x
Prelude.Generic)

-- |
-- Create a value of 'Facet' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'facetStyle', 'facet_facetStyle' - There are two different styles that you can define on any given facet,
-- @Static@ and @Dynamic@. For static facets, all attributes must be
-- defined in the schema. For dynamic facets, attributes can be defined
-- during data plane operations.
--
-- 'objectType', 'facet_objectType' - The object type that is associated with the facet. See
-- CreateFacetRequest$ObjectType for more details.
--
-- 'name', 'facet_name' - The name of the Facet.
newFacet ::
  Facet
newFacet :: Facet
newFacet =
  Facet' :: Maybe FacetStyle -> Maybe ObjectType -> Maybe Text -> Facet
Facet'
    { $sel:facetStyle:Facet' :: Maybe FacetStyle
facetStyle = Maybe FacetStyle
forall a. Maybe a
Prelude.Nothing,
      $sel:objectType:Facet' :: Maybe ObjectType
objectType = Maybe ObjectType
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Facet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | There are two different styles that you can define on any given facet,
-- @Static@ and @Dynamic@. For static facets, all attributes must be
-- defined in the schema. For dynamic facets, attributes can be defined
-- during data plane operations.
facet_facetStyle :: Lens.Lens' Facet (Prelude.Maybe FacetStyle)
facet_facetStyle :: (Maybe FacetStyle -> f (Maybe FacetStyle)) -> Facet -> f Facet
facet_facetStyle = (Facet -> Maybe FacetStyle)
-> (Facet -> Maybe FacetStyle -> Facet)
-> Lens Facet Facet (Maybe FacetStyle) (Maybe FacetStyle)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Facet' {Maybe FacetStyle
facetStyle :: Maybe FacetStyle
$sel:facetStyle:Facet' :: Facet -> Maybe FacetStyle
facetStyle} -> Maybe FacetStyle
facetStyle) (\s :: Facet
s@Facet' {} Maybe FacetStyle
a -> Facet
s {$sel:facetStyle:Facet' :: Maybe FacetStyle
facetStyle = Maybe FacetStyle
a} :: Facet)

-- | The object type that is associated with the facet. See
-- CreateFacetRequest$ObjectType for more details.
facet_objectType :: Lens.Lens' Facet (Prelude.Maybe ObjectType)
facet_objectType :: (Maybe ObjectType -> f (Maybe ObjectType)) -> Facet -> f Facet
facet_objectType = (Facet -> Maybe ObjectType)
-> (Facet -> Maybe ObjectType -> Facet)
-> Lens Facet Facet (Maybe ObjectType) (Maybe ObjectType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Facet' {Maybe ObjectType
objectType :: Maybe ObjectType
$sel:objectType:Facet' :: Facet -> Maybe ObjectType
objectType} -> Maybe ObjectType
objectType) (\s :: Facet
s@Facet' {} Maybe ObjectType
a -> Facet
s {$sel:objectType:Facet' :: Maybe ObjectType
objectType = Maybe ObjectType
a} :: Facet)

-- | The name of the Facet.
facet_name :: Lens.Lens' Facet (Prelude.Maybe Prelude.Text)
facet_name :: (Maybe Text -> f (Maybe Text)) -> Facet -> f Facet
facet_name = (Facet -> Maybe Text)
-> (Facet -> Maybe Text -> Facet)
-> Lens Facet Facet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Facet' {Maybe Text
name :: Maybe Text
$sel:name:Facet' :: Facet -> Maybe Text
name} -> Maybe Text
name) (\s :: Facet
s@Facet' {} Maybe Text
a -> Facet
s {$sel:name:Facet' :: Maybe Text
name = Maybe Text
a} :: Facet)

instance Core.FromJSON Facet where
  parseJSON :: Value -> Parser Facet
parseJSON =
    String -> (Object -> Parser Facet) -> Value -> Parser Facet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Facet"
      ( \Object
x ->
          Maybe FacetStyle -> Maybe ObjectType -> Maybe Text -> Facet
Facet'
            (Maybe FacetStyle -> Maybe ObjectType -> Maybe Text -> Facet)
-> Parser (Maybe FacetStyle)
-> Parser (Maybe ObjectType -> Maybe Text -> Facet)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FacetStyle)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FacetStyle")
            Parser (Maybe ObjectType -> Maybe Text -> Facet)
-> Parser (Maybe ObjectType) -> Parser (Maybe Text -> Facet)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ObjectType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ObjectType")
            Parser (Maybe Text -> Facet) -> Parser (Maybe Text) -> Parser Facet
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
"Name")
      )

instance Prelude.Hashable Facet

instance Prelude.NFData Facet