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

import Amazonka.CloudDirectory.Types.TypedLinkAttributeDefinition
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

-- | Defines the typed links structure and its attributes. To create a typed
-- link facet, use the CreateTypedLinkFacet API.
--
-- /See:/ 'newTypedLinkFacet' smart constructor.
data TypedLinkFacet = TypedLinkFacet'
  { -- | The unique name of the typed link facet.
    TypedLinkFacet -> Text
name :: Prelude.Text,
    -- | A set of key-value pairs associated with the typed link. Typed link
    -- attributes are used when you have data values that are related to the
    -- link itself, and not to one of the two objects being linked. Identity
    -- attributes also serve to distinguish the link from others of the same
    -- type between the same objects.
    TypedLinkFacet -> [TypedLinkAttributeDefinition]
attributes :: [TypedLinkAttributeDefinition],
    -- | The set of attributes that distinguish links made from this facet from
    -- each other, in the order of significance. Listing typed links can filter
    -- on the values of these attributes. See ListOutgoingTypedLinks and
    -- ListIncomingTypedLinks for details.
    TypedLinkFacet -> [Text]
identityAttributeOrder :: [Prelude.Text]
  }
  deriving (TypedLinkFacet -> TypedLinkFacet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypedLinkFacet -> TypedLinkFacet -> Bool
$c/= :: TypedLinkFacet -> TypedLinkFacet -> Bool
== :: TypedLinkFacet -> TypedLinkFacet -> Bool
$c== :: TypedLinkFacet -> TypedLinkFacet -> Bool
Prelude.Eq, ReadPrec [TypedLinkFacet]
ReadPrec TypedLinkFacet
Int -> ReadS TypedLinkFacet
ReadS [TypedLinkFacet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TypedLinkFacet]
$creadListPrec :: ReadPrec [TypedLinkFacet]
readPrec :: ReadPrec TypedLinkFacet
$creadPrec :: ReadPrec TypedLinkFacet
readList :: ReadS [TypedLinkFacet]
$creadList :: ReadS [TypedLinkFacet]
readsPrec :: Int -> ReadS TypedLinkFacet
$creadsPrec :: Int -> ReadS TypedLinkFacet
Prelude.Read, Int -> TypedLinkFacet -> ShowS
[TypedLinkFacet] -> ShowS
TypedLinkFacet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TypedLinkFacet] -> ShowS
$cshowList :: [TypedLinkFacet] -> ShowS
show :: TypedLinkFacet -> String
$cshow :: TypedLinkFacet -> String
showsPrec :: Int -> TypedLinkFacet -> ShowS
$cshowsPrec :: Int -> TypedLinkFacet -> ShowS
Prelude.Show, forall x. Rep TypedLinkFacet x -> TypedLinkFacet
forall x. TypedLinkFacet -> Rep TypedLinkFacet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TypedLinkFacet x -> TypedLinkFacet
$cfrom :: forall x. TypedLinkFacet -> Rep TypedLinkFacet x
Prelude.Generic)

-- |
-- Create a value of 'TypedLinkFacet' 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:
--
-- 'name', 'typedLinkFacet_name' - The unique name of the typed link facet.
--
-- 'attributes', 'typedLinkFacet_attributes' - A set of key-value pairs associated with the typed link. Typed link
-- attributes are used when you have data values that are related to the
-- link itself, and not to one of the two objects being linked. Identity
-- attributes also serve to distinguish the link from others of the same
-- type between the same objects.
--
-- 'identityAttributeOrder', 'typedLinkFacet_identityAttributeOrder' - The set of attributes that distinguish links made from this facet from
-- each other, in the order of significance. Listing typed links can filter
-- on the values of these attributes. See ListOutgoingTypedLinks and
-- ListIncomingTypedLinks for details.
newTypedLinkFacet ::
  -- | 'name'
  Prelude.Text ->
  TypedLinkFacet
newTypedLinkFacet :: Text -> TypedLinkFacet
newTypedLinkFacet Text
pName_ =
  TypedLinkFacet'
    { $sel:name:TypedLinkFacet' :: Text
name = Text
pName_,
      $sel:attributes:TypedLinkFacet' :: [TypedLinkAttributeDefinition]
attributes = forall a. Monoid a => a
Prelude.mempty,
      $sel:identityAttributeOrder:TypedLinkFacet' :: [Text]
identityAttributeOrder = forall a. Monoid a => a
Prelude.mempty
    }

-- | The unique name of the typed link facet.
typedLinkFacet_name :: Lens.Lens' TypedLinkFacet Prelude.Text
typedLinkFacet_name :: Lens' TypedLinkFacet Text
typedLinkFacet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkFacet' {Text
name :: Text
$sel:name:TypedLinkFacet' :: TypedLinkFacet -> Text
name} -> Text
name) (\s :: TypedLinkFacet
s@TypedLinkFacet' {} Text
a -> TypedLinkFacet
s {$sel:name:TypedLinkFacet' :: Text
name = Text
a} :: TypedLinkFacet)

-- | A set of key-value pairs associated with the typed link. Typed link
-- attributes are used when you have data values that are related to the
-- link itself, and not to one of the two objects being linked. Identity
-- attributes also serve to distinguish the link from others of the same
-- type between the same objects.
typedLinkFacet_attributes :: Lens.Lens' TypedLinkFacet [TypedLinkAttributeDefinition]
typedLinkFacet_attributes :: Lens' TypedLinkFacet [TypedLinkAttributeDefinition]
typedLinkFacet_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkFacet' {[TypedLinkAttributeDefinition]
attributes :: [TypedLinkAttributeDefinition]
$sel:attributes:TypedLinkFacet' :: TypedLinkFacet -> [TypedLinkAttributeDefinition]
attributes} -> [TypedLinkAttributeDefinition]
attributes) (\s :: TypedLinkFacet
s@TypedLinkFacet' {} [TypedLinkAttributeDefinition]
a -> TypedLinkFacet
s {$sel:attributes:TypedLinkFacet' :: [TypedLinkAttributeDefinition]
attributes = [TypedLinkAttributeDefinition]
a} :: TypedLinkFacet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The set of attributes that distinguish links made from this facet from
-- each other, in the order of significance. Listing typed links can filter
-- on the values of these attributes. See ListOutgoingTypedLinks and
-- ListIncomingTypedLinks for details.
typedLinkFacet_identityAttributeOrder :: Lens.Lens' TypedLinkFacet [Prelude.Text]
typedLinkFacet_identityAttributeOrder :: Lens' TypedLinkFacet [Text]
typedLinkFacet_identityAttributeOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkFacet' {[Text]
identityAttributeOrder :: [Text]
$sel:identityAttributeOrder:TypedLinkFacet' :: TypedLinkFacet -> [Text]
identityAttributeOrder} -> [Text]
identityAttributeOrder) (\s :: TypedLinkFacet
s@TypedLinkFacet' {} [Text]
a -> TypedLinkFacet
s {$sel:identityAttributeOrder:TypedLinkFacet' :: [Text]
identityAttributeOrder = [Text]
a} :: TypedLinkFacet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable TypedLinkFacet where
  hashWithSalt :: Int -> TypedLinkFacet -> Int
hashWithSalt Int
_salt TypedLinkFacet' {[Text]
[TypedLinkAttributeDefinition]
Text
identityAttributeOrder :: [Text]
attributes :: [TypedLinkAttributeDefinition]
name :: Text
$sel:identityAttributeOrder:TypedLinkFacet' :: TypedLinkFacet -> [Text]
$sel:attributes:TypedLinkFacet' :: TypedLinkFacet -> [TypedLinkAttributeDefinition]
$sel:name:TypedLinkFacet' :: TypedLinkFacet -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [TypedLinkAttributeDefinition]
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
identityAttributeOrder

instance Prelude.NFData TypedLinkFacet where
  rnf :: TypedLinkFacet -> ()
rnf TypedLinkFacet' {[Text]
[TypedLinkAttributeDefinition]
Text
identityAttributeOrder :: [Text]
attributes :: [TypedLinkAttributeDefinition]
name :: Text
$sel:identityAttributeOrder:TypedLinkFacet' :: TypedLinkFacet -> [Text]
$sel:attributes:TypedLinkFacet' :: TypedLinkFacet -> [TypedLinkAttributeDefinition]
$sel:name:TypedLinkFacet' :: TypedLinkFacet -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [TypedLinkAttributeDefinition]
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
identityAttributeOrder

instance Data.ToJSON TypedLinkFacet where
  toJSON :: TypedLinkFacet -> Value
toJSON TypedLinkFacet' {[Text]
[TypedLinkAttributeDefinition]
Text
identityAttributeOrder :: [Text]
attributes :: [TypedLinkAttributeDefinition]
name :: Text
$sel:identityAttributeOrder:TypedLinkFacet' :: TypedLinkFacet -> [Text]
$sel:attributes:TypedLinkFacet' :: TypedLinkFacet -> [TypedLinkAttributeDefinition]
$sel:name:TypedLinkFacet' :: TypedLinkFacet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [TypedLinkAttributeDefinition]
attributes),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"IdentityAttributeOrder"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
identityAttributeOrder
              )
          ]
      )