{-# 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.FacetAttributeReference
-- 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.FacetAttributeReference where

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

-- | The facet attribute reference that specifies the attribute definition
-- that contains the attribute facet name and attribute name.
--
-- /See:/ 'newFacetAttributeReference' smart constructor.
data FacetAttributeReference = FacetAttributeReference'
  { -- | The target facet name that is associated with the facet reference. See
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html Attribute References>
    -- for more information.
    FacetAttributeReference -> Text
targetFacetName :: Prelude.Text,
    -- | The target attribute name that is associated with the facet reference.
    -- See
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html Attribute References>
    -- for more information.
    FacetAttributeReference -> Text
targetAttributeName :: Prelude.Text
  }
  deriving (FacetAttributeReference -> FacetAttributeReference -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FacetAttributeReference -> FacetAttributeReference -> Bool
$c/= :: FacetAttributeReference -> FacetAttributeReference -> Bool
== :: FacetAttributeReference -> FacetAttributeReference -> Bool
$c== :: FacetAttributeReference -> FacetAttributeReference -> Bool
Prelude.Eq, ReadPrec [FacetAttributeReference]
ReadPrec FacetAttributeReference
Int -> ReadS FacetAttributeReference
ReadS [FacetAttributeReference]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FacetAttributeReference]
$creadListPrec :: ReadPrec [FacetAttributeReference]
readPrec :: ReadPrec FacetAttributeReference
$creadPrec :: ReadPrec FacetAttributeReference
readList :: ReadS [FacetAttributeReference]
$creadList :: ReadS [FacetAttributeReference]
readsPrec :: Int -> ReadS FacetAttributeReference
$creadsPrec :: Int -> ReadS FacetAttributeReference
Prelude.Read, Int -> FacetAttributeReference -> ShowS
[FacetAttributeReference] -> ShowS
FacetAttributeReference -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FacetAttributeReference] -> ShowS
$cshowList :: [FacetAttributeReference] -> ShowS
show :: FacetAttributeReference -> String
$cshow :: FacetAttributeReference -> String
showsPrec :: Int -> FacetAttributeReference -> ShowS
$cshowsPrec :: Int -> FacetAttributeReference -> ShowS
Prelude.Show, forall x. Rep FacetAttributeReference x -> FacetAttributeReference
forall x. FacetAttributeReference -> Rep FacetAttributeReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FacetAttributeReference x -> FacetAttributeReference
$cfrom :: forall x. FacetAttributeReference -> Rep FacetAttributeReference x
Prelude.Generic)

-- |
-- Create a value of 'FacetAttributeReference' 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:
--
-- 'targetFacetName', 'facetAttributeReference_targetFacetName' - The target facet name that is associated with the facet reference. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html Attribute References>
-- for more information.
--
-- 'targetAttributeName', 'facetAttributeReference_targetAttributeName' - The target attribute name that is associated with the facet reference.
-- See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html Attribute References>
-- for more information.
newFacetAttributeReference ::
  -- | 'targetFacetName'
  Prelude.Text ->
  -- | 'targetAttributeName'
  Prelude.Text ->
  FacetAttributeReference
newFacetAttributeReference :: Text -> Text -> FacetAttributeReference
newFacetAttributeReference
  Text
pTargetFacetName_
  Text
pTargetAttributeName_ =
    FacetAttributeReference'
      { $sel:targetFacetName:FacetAttributeReference' :: Text
targetFacetName =
          Text
pTargetFacetName_,
        $sel:targetAttributeName:FacetAttributeReference' :: Text
targetAttributeName = Text
pTargetAttributeName_
      }

-- | The target facet name that is associated with the facet reference. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html Attribute References>
-- for more information.
facetAttributeReference_targetFacetName :: Lens.Lens' FacetAttributeReference Prelude.Text
facetAttributeReference_targetFacetName :: Lens' FacetAttributeReference Text
facetAttributeReference_targetFacetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeReference' {Text
targetFacetName :: Text
$sel:targetFacetName:FacetAttributeReference' :: FacetAttributeReference -> Text
targetFacetName} -> Text
targetFacetName) (\s :: FacetAttributeReference
s@FacetAttributeReference' {} Text
a -> FacetAttributeReference
s {$sel:targetFacetName:FacetAttributeReference' :: Text
targetFacetName = Text
a} :: FacetAttributeReference)

-- | The target attribute name that is associated with the facet reference.
-- See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html Attribute References>
-- for more information.
facetAttributeReference_targetAttributeName :: Lens.Lens' FacetAttributeReference Prelude.Text
facetAttributeReference_targetAttributeName :: Lens' FacetAttributeReference Text
facetAttributeReference_targetAttributeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeReference' {Text
targetAttributeName :: Text
$sel:targetAttributeName:FacetAttributeReference' :: FacetAttributeReference -> Text
targetAttributeName} -> Text
targetAttributeName) (\s :: FacetAttributeReference
s@FacetAttributeReference' {} Text
a -> FacetAttributeReference
s {$sel:targetAttributeName:FacetAttributeReference' :: Text
targetAttributeName = Text
a} :: FacetAttributeReference)

instance Data.FromJSON FacetAttributeReference where
  parseJSON :: Value -> Parser FacetAttributeReference
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FacetAttributeReference"
      ( \Object
x ->
          Text -> Text -> FacetAttributeReference
FacetAttributeReference'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TargetFacetName")
            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
"TargetAttributeName")
      )

instance Prelude.Hashable FacetAttributeReference where
  hashWithSalt :: Int -> FacetAttributeReference -> Int
hashWithSalt Int
_salt FacetAttributeReference' {Text
targetAttributeName :: Text
targetFacetName :: Text
$sel:targetAttributeName:FacetAttributeReference' :: FacetAttributeReference -> Text
$sel:targetFacetName:FacetAttributeReference' :: FacetAttributeReference -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
targetFacetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
targetAttributeName

instance Prelude.NFData FacetAttributeReference where
  rnf :: FacetAttributeReference -> ()
rnf FacetAttributeReference' {Text
targetAttributeName :: Text
targetFacetName :: Text
$sel:targetAttributeName:FacetAttributeReference' :: FacetAttributeReference -> Text
$sel:targetFacetName:FacetAttributeReference' :: FacetAttributeReference -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
targetFacetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
targetAttributeName

instance Data.ToJSON FacetAttributeReference where
  toJSON :: FacetAttributeReference -> Value
toJSON FacetAttributeReference' {Text
targetAttributeName :: Text
targetFacetName :: Text
$sel:targetAttributeName:FacetAttributeReference' :: FacetAttributeReference -> Text
$sel:targetFacetName:FacetAttributeReference' :: FacetAttributeReference -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"TargetFacetName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
targetFacetName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TargetAttributeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
targetAttributeName)
          ]
      )