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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(FacetAttributeReference -> FacetAttributeReference -> Bool)
-> (FacetAttributeReference -> FacetAttributeReference -> Bool)
-> Eq FacetAttributeReference
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]
(Int -> ReadS FacetAttributeReference)
-> ReadS [FacetAttributeReference]
-> ReadPrec FacetAttributeReference
-> ReadPrec [FacetAttributeReference]
-> Read 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
(Int -> FacetAttributeReference -> ShowS)
-> (FacetAttributeReference -> String)
-> ([FacetAttributeReference] -> ShowS)
-> Show FacetAttributeReference
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.
 FacetAttributeReference -> Rep FacetAttributeReference x)
-> (forall x.
    Rep FacetAttributeReference x -> FacetAttributeReference)
-> Generic FacetAttributeReference
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' :: Text -> Text -> FacetAttributeReference
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 :: (Text -> f Text)
-> FacetAttributeReference -> f FacetAttributeReference
facetAttributeReference_targetFacetName = (FacetAttributeReference -> Text)
-> (FacetAttributeReference -> Text -> FacetAttributeReference)
-> Lens FacetAttributeReference FacetAttributeReference Text Text
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 :: (Text -> f Text)
-> FacetAttributeReference -> f FacetAttributeReference
facetAttributeReference_targetAttributeName = (FacetAttributeReference -> Text)
-> (FacetAttributeReference -> Text -> FacetAttributeReference)
-> Lens FacetAttributeReference FacetAttributeReference Text Text
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 Core.FromJSON FacetAttributeReference where
  parseJSON :: Value -> Parser FacetAttributeReference
parseJSON =
    String
-> (Object -> Parser FacetAttributeReference)
-> Value
-> Parser FacetAttributeReference
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FacetAttributeReference"
      ( \Object
x ->
          Text -> Text -> FacetAttributeReference
FacetAttributeReference'
            (Text -> Text -> FacetAttributeReference)
-> Parser Text -> Parser (Text -> FacetAttributeReference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TargetFacetName")
            Parser (Text -> FacetAttributeReference)
-> Parser Text -> Parser FacetAttributeReference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TargetAttributeName")
      )

instance Prelude.Hashable FacetAttributeReference

instance Prelude.NFData FacetAttributeReference

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TargetFacetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
targetFacetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TargetAttributeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
targetAttributeName)
          ]
      )