{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains @Name@, @ARN@, @Attributes@, @ @@Rule@@s@, 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 name of the Facet.
    Facet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The object type that is associated with the facet. See
    -- CreateFacetRequest$ObjectType for more details.
    Facet -> Maybe ObjectType
objectType :: Prelude.Maybe ObjectType
  }
  deriving (Facet -> Facet -> Bool
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]
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
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. 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.
--
-- 'name', 'facet_name' - The name of the Facet.
--
-- 'objectType', 'facet_objectType' - The object type that is associated with the facet. See
-- CreateFacetRequest$ObjectType for more details.
newFacet ::
  Facet
newFacet :: Facet
newFacet =
  Facet'
    { $sel:facetStyle:Facet' :: Maybe FacetStyle
facetStyle = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Facet' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:objectType:Facet' :: Maybe ObjectType
objectType = 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 :: Lens' Facet (Maybe FacetStyle)
facet_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 name of the Facet.
facet_name :: Lens.Lens' Facet (Prelude.Maybe Prelude.Text)
facet_name :: Lens' Facet (Maybe Text)
facet_name = 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)

-- | 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 :: Lens' Facet (Maybe ObjectType)
facet_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)

instance Data.FromJSON Facet where
  parseJSON :: Value -> Parser Facet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Facet"
      ( \Object
x ->
          Maybe FacetStyle -> Maybe Text -> Maybe ObjectType -> Facet
Facet'
            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
"FacetStyle")
            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
"Name")
            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
"ObjectType")
      )

instance Prelude.Hashable Facet where
  hashWithSalt :: Int -> Facet -> Int
hashWithSalt Int
_salt Facet' {Maybe Text
Maybe FacetStyle
Maybe ObjectType
objectType :: Maybe ObjectType
name :: Maybe Text
facetStyle :: Maybe FacetStyle
$sel:objectType:Facet' :: Facet -> Maybe ObjectType
$sel:name:Facet' :: Facet -> Maybe Text
$sel:facetStyle:Facet' :: Facet -> Maybe FacetStyle
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FacetStyle
facetStyle
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ObjectType
objectType

instance Prelude.NFData Facet where
  rnf :: Facet -> ()
rnf Facet' {Maybe Text
Maybe FacetStyle
Maybe ObjectType
objectType :: Maybe ObjectType
name :: Maybe Text
facetStyle :: Maybe FacetStyle
$sel:objectType:Facet' :: Facet -> Maybe ObjectType
$sel:name:Facet' :: Facet -> Maybe Text
$sel:facetStyle:Facet' :: Facet -> Maybe FacetStyle
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FacetStyle
facetStyle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ObjectType
objectType