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

import Amazonka.CloudDirectory.Types.TypedLinkAttributeDefinition
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TypedLinkFacet -> TypedLinkFacet -> Bool)
-> (TypedLinkFacet -> TypedLinkFacet -> Bool) -> Eq TypedLinkFacet
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]
(Int -> ReadS TypedLinkFacet)
-> ReadS [TypedLinkFacet]
-> ReadPrec TypedLinkFacet
-> ReadPrec [TypedLinkFacet]
-> Read 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
(Int -> TypedLinkFacet -> ShowS)
-> (TypedLinkFacet -> String)
-> ([TypedLinkFacet] -> ShowS)
-> Show TypedLinkFacet
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. TypedLinkFacet -> Rep TypedLinkFacet x)
-> (forall x. Rep TypedLinkFacet x -> TypedLinkFacet)
-> Generic TypedLinkFacet
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' :: Text -> [TypedLinkAttributeDefinition] -> [Text] -> TypedLinkFacet
TypedLinkFacet'
    { $sel:name:TypedLinkFacet' :: Text
name = Text
pName_,
      $sel:attributes:TypedLinkFacet' :: [TypedLinkAttributeDefinition]
attributes = [TypedLinkAttributeDefinition]
forall a. Monoid a => a
Prelude.mempty,
      $sel:identityAttributeOrder:TypedLinkFacet' :: [Text]
identityAttributeOrder = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The unique name of the typed link facet.
typedLinkFacet_name :: Lens.Lens' TypedLinkFacet Prelude.Text
typedLinkFacet_name :: (Text -> f Text) -> TypedLinkFacet -> f TypedLinkFacet
typedLinkFacet_name = (TypedLinkFacet -> Text)
-> (TypedLinkFacet -> Text -> TypedLinkFacet)
-> Lens TypedLinkFacet TypedLinkFacet Text Text
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 :: ([TypedLinkAttributeDefinition]
 -> f [TypedLinkAttributeDefinition])
-> TypedLinkFacet -> f TypedLinkFacet
typedLinkFacet_attributes = (TypedLinkFacet -> [TypedLinkAttributeDefinition])
-> (TypedLinkFacet
    -> [TypedLinkAttributeDefinition] -> TypedLinkFacet)
-> Lens
     TypedLinkFacet
     TypedLinkFacet
     [TypedLinkAttributeDefinition]
     [TypedLinkAttributeDefinition]
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) (([TypedLinkAttributeDefinition]
  -> f [TypedLinkAttributeDefinition])
 -> TypedLinkFacet -> f TypedLinkFacet)
-> (([TypedLinkAttributeDefinition]
     -> f [TypedLinkAttributeDefinition])
    -> [TypedLinkAttributeDefinition]
    -> f [TypedLinkAttributeDefinition])
-> ([TypedLinkAttributeDefinition]
    -> f [TypedLinkAttributeDefinition])
-> TypedLinkFacet
-> f TypedLinkFacet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TypedLinkAttributeDefinition]
 -> f [TypedLinkAttributeDefinition])
-> [TypedLinkAttributeDefinition]
-> f [TypedLinkAttributeDefinition]
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 :: ([Text] -> f [Text]) -> TypedLinkFacet -> f TypedLinkFacet
typedLinkFacet_identityAttributeOrder = (TypedLinkFacet -> [Text])
-> (TypedLinkFacet -> [Text] -> TypedLinkFacet)
-> Lens TypedLinkFacet TypedLinkFacet [Text] [Text]
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) (([Text] -> f [Text]) -> TypedLinkFacet -> f TypedLinkFacet)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> TypedLinkFacet
-> f TypedLinkFacet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable TypedLinkFacet

instance Prelude.NFData TypedLinkFacet

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Attributes" Text -> [TypedLinkAttributeDefinition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [TypedLinkAttributeDefinition]
attributes),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"IdentityAttributeOrder"
                  Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
identityAttributeOrder
              )
          ]
      )