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

import Amazonka.CloudDirectory.Types.AttributeNameAndValue
import Amazonka.CloudDirectory.Types.ObjectReference
import Amazonka.CloudDirectory.Types.TypedLinkSchemaAndFacetName
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

-- | Contains all the information that is used to uniquely identify a typed
-- link. The parameters discussed in this topic are used to uniquely
-- specify the typed link being operated on. The AttachTypedLink API
-- returns a typed link specifier while the DetachTypedLink API accepts one
-- as input. Similarly, the ListIncomingTypedLinks and
-- ListOutgoingTypedLinks API operations provide typed link specifiers as
-- output. You can also construct a typed link specifier from scratch.
--
-- /See:/ 'newTypedLinkSpecifier' smart constructor.
data TypedLinkSpecifier = TypedLinkSpecifier'
  { -- | Identifies the typed link facet that is associated with the typed link.
    TypedLinkSpecifier -> TypedLinkSchemaAndFacetName
typedLinkFacet :: TypedLinkSchemaAndFacetName,
    -- | Identifies the source object that the typed link will attach to.
    TypedLinkSpecifier -> ObjectReference
sourceObjectReference :: ObjectReference,
    -- | Identifies the target object that the typed link will attach to.
    TypedLinkSpecifier -> ObjectReference
targetObjectReference :: ObjectReference,
    -- | Identifies the attribute value to update.
    TypedLinkSpecifier -> [AttributeNameAndValue]
identityAttributeValues :: [AttributeNameAndValue]
  }
  deriving (TypedLinkSpecifier -> TypedLinkSpecifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypedLinkSpecifier -> TypedLinkSpecifier -> Bool
$c/= :: TypedLinkSpecifier -> TypedLinkSpecifier -> Bool
== :: TypedLinkSpecifier -> TypedLinkSpecifier -> Bool
$c== :: TypedLinkSpecifier -> TypedLinkSpecifier -> Bool
Prelude.Eq, ReadPrec [TypedLinkSpecifier]
ReadPrec TypedLinkSpecifier
Int -> ReadS TypedLinkSpecifier
ReadS [TypedLinkSpecifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TypedLinkSpecifier]
$creadListPrec :: ReadPrec [TypedLinkSpecifier]
readPrec :: ReadPrec TypedLinkSpecifier
$creadPrec :: ReadPrec TypedLinkSpecifier
readList :: ReadS [TypedLinkSpecifier]
$creadList :: ReadS [TypedLinkSpecifier]
readsPrec :: Int -> ReadS TypedLinkSpecifier
$creadsPrec :: Int -> ReadS TypedLinkSpecifier
Prelude.Read, Int -> TypedLinkSpecifier -> ShowS
[TypedLinkSpecifier] -> ShowS
TypedLinkSpecifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TypedLinkSpecifier] -> ShowS
$cshowList :: [TypedLinkSpecifier] -> ShowS
show :: TypedLinkSpecifier -> String
$cshow :: TypedLinkSpecifier -> String
showsPrec :: Int -> TypedLinkSpecifier -> ShowS
$cshowsPrec :: Int -> TypedLinkSpecifier -> ShowS
Prelude.Show, forall x. Rep TypedLinkSpecifier x -> TypedLinkSpecifier
forall x. TypedLinkSpecifier -> Rep TypedLinkSpecifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TypedLinkSpecifier x -> TypedLinkSpecifier
$cfrom :: forall x. TypedLinkSpecifier -> Rep TypedLinkSpecifier x
Prelude.Generic)

-- |
-- Create a value of 'TypedLinkSpecifier' 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:
--
-- 'typedLinkFacet', 'typedLinkSpecifier_typedLinkFacet' - Identifies the typed link facet that is associated with the typed link.
--
-- 'sourceObjectReference', 'typedLinkSpecifier_sourceObjectReference' - Identifies the source object that the typed link will attach to.
--
-- 'targetObjectReference', 'typedLinkSpecifier_targetObjectReference' - Identifies the target object that the typed link will attach to.
--
-- 'identityAttributeValues', 'typedLinkSpecifier_identityAttributeValues' - Identifies the attribute value to update.
newTypedLinkSpecifier ::
  -- | 'typedLinkFacet'
  TypedLinkSchemaAndFacetName ->
  -- | 'sourceObjectReference'
  ObjectReference ->
  -- | 'targetObjectReference'
  ObjectReference ->
  TypedLinkSpecifier
newTypedLinkSpecifier :: TypedLinkSchemaAndFacetName
-> ObjectReference -> ObjectReference -> TypedLinkSpecifier
newTypedLinkSpecifier
  TypedLinkSchemaAndFacetName
pTypedLinkFacet_
  ObjectReference
pSourceObjectReference_
  ObjectReference
pTargetObjectReference_ =
    TypedLinkSpecifier'
      { $sel:typedLinkFacet:TypedLinkSpecifier' :: TypedLinkSchemaAndFacetName
typedLinkFacet =
          TypedLinkSchemaAndFacetName
pTypedLinkFacet_,
        $sel:sourceObjectReference:TypedLinkSpecifier' :: ObjectReference
sourceObjectReference = ObjectReference
pSourceObjectReference_,
        $sel:targetObjectReference:TypedLinkSpecifier' :: ObjectReference
targetObjectReference = ObjectReference
pTargetObjectReference_,
        $sel:identityAttributeValues:TypedLinkSpecifier' :: [AttributeNameAndValue]
identityAttributeValues = forall a. Monoid a => a
Prelude.mempty
      }

-- | Identifies the typed link facet that is associated with the typed link.
typedLinkSpecifier_typedLinkFacet :: Lens.Lens' TypedLinkSpecifier TypedLinkSchemaAndFacetName
typedLinkSpecifier_typedLinkFacet :: Lens' TypedLinkSpecifier TypedLinkSchemaAndFacetName
typedLinkSpecifier_typedLinkFacet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkSpecifier' {TypedLinkSchemaAndFacetName
typedLinkFacet :: TypedLinkSchemaAndFacetName
$sel:typedLinkFacet:TypedLinkSpecifier' :: TypedLinkSpecifier -> TypedLinkSchemaAndFacetName
typedLinkFacet} -> TypedLinkSchemaAndFacetName
typedLinkFacet) (\s :: TypedLinkSpecifier
s@TypedLinkSpecifier' {} TypedLinkSchemaAndFacetName
a -> TypedLinkSpecifier
s {$sel:typedLinkFacet:TypedLinkSpecifier' :: TypedLinkSchemaAndFacetName
typedLinkFacet = TypedLinkSchemaAndFacetName
a} :: TypedLinkSpecifier)

-- | Identifies the source object that the typed link will attach to.
typedLinkSpecifier_sourceObjectReference :: Lens.Lens' TypedLinkSpecifier ObjectReference
typedLinkSpecifier_sourceObjectReference :: Lens' TypedLinkSpecifier ObjectReference
typedLinkSpecifier_sourceObjectReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkSpecifier' {ObjectReference
sourceObjectReference :: ObjectReference
$sel:sourceObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
sourceObjectReference} -> ObjectReference
sourceObjectReference) (\s :: TypedLinkSpecifier
s@TypedLinkSpecifier' {} ObjectReference
a -> TypedLinkSpecifier
s {$sel:sourceObjectReference:TypedLinkSpecifier' :: ObjectReference
sourceObjectReference = ObjectReference
a} :: TypedLinkSpecifier)

-- | Identifies the target object that the typed link will attach to.
typedLinkSpecifier_targetObjectReference :: Lens.Lens' TypedLinkSpecifier ObjectReference
typedLinkSpecifier_targetObjectReference :: Lens' TypedLinkSpecifier ObjectReference
typedLinkSpecifier_targetObjectReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkSpecifier' {ObjectReference
targetObjectReference :: ObjectReference
$sel:targetObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
targetObjectReference} -> ObjectReference
targetObjectReference) (\s :: TypedLinkSpecifier
s@TypedLinkSpecifier' {} ObjectReference
a -> TypedLinkSpecifier
s {$sel:targetObjectReference:TypedLinkSpecifier' :: ObjectReference
targetObjectReference = ObjectReference
a} :: TypedLinkSpecifier)

-- | Identifies the attribute value to update.
typedLinkSpecifier_identityAttributeValues :: Lens.Lens' TypedLinkSpecifier [AttributeNameAndValue]
typedLinkSpecifier_identityAttributeValues :: Lens' TypedLinkSpecifier [AttributeNameAndValue]
typedLinkSpecifier_identityAttributeValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedLinkSpecifier' {[AttributeNameAndValue]
identityAttributeValues :: [AttributeNameAndValue]
$sel:identityAttributeValues:TypedLinkSpecifier' :: TypedLinkSpecifier -> [AttributeNameAndValue]
identityAttributeValues} -> [AttributeNameAndValue]
identityAttributeValues) (\s :: TypedLinkSpecifier
s@TypedLinkSpecifier' {} [AttributeNameAndValue]
a -> TypedLinkSpecifier
s {$sel:identityAttributeValues:TypedLinkSpecifier' :: [AttributeNameAndValue]
identityAttributeValues = [AttributeNameAndValue]
a} :: TypedLinkSpecifier) 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 Data.FromJSON TypedLinkSpecifier where
  parseJSON :: Value -> Parser TypedLinkSpecifier
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TypedLinkSpecifier"
      ( \Object
x ->
          TypedLinkSchemaAndFacetName
-> ObjectReference
-> ObjectReference
-> [AttributeNameAndValue]
-> TypedLinkSpecifier
TypedLinkSpecifier'
            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
"TypedLinkFacet")
            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
"SourceObjectReference")
            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
"TargetObjectReference")
            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
"IdentityAttributeValues"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable TypedLinkSpecifier where
  hashWithSalt :: Int -> TypedLinkSpecifier -> Int
hashWithSalt Int
_salt TypedLinkSpecifier' {[AttributeNameAndValue]
ObjectReference
TypedLinkSchemaAndFacetName
identityAttributeValues :: [AttributeNameAndValue]
targetObjectReference :: ObjectReference
sourceObjectReference :: ObjectReference
typedLinkFacet :: TypedLinkSchemaAndFacetName
$sel:identityAttributeValues:TypedLinkSpecifier' :: TypedLinkSpecifier -> [AttributeNameAndValue]
$sel:targetObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
$sel:sourceObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
$sel:typedLinkFacet:TypedLinkSpecifier' :: TypedLinkSpecifier -> TypedLinkSchemaAndFacetName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TypedLinkSchemaAndFacetName
typedLinkFacet
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
sourceObjectReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
targetObjectReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AttributeNameAndValue]
identityAttributeValues

instance Prelude.NFData TypedLinkSpecifier where
  rnf :: TypedLinkSpecifier -> ()
rnf TypedLinkSpecifier' {[AttributeNameAndValue]
ObjectReference
TypedLinkSchemaAndFacetName
identityAttributeValues :: [AttributeNameAndValue]
targetObjectReference :: ObjectReference
sourceObjectReference :: ObjectReference
typedLinkFacet :: TypedLinkSchemaAndFacetName
$sel:identityAttributeValues:TypedLinkSpecifier' :: TypedLinkSpecifier -> [AttributeNameAndValue]
$sel:targetObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
$sel:sourceObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
$sel:typedLinkFacet:TypedLinkSpecifier' :: TypedLinkSpecifier -> TypedLinkSchemaAndFacetName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf TypedLinkSchemaAndFacetName
typedLinkFacet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
sourceObjectReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
targetObjectReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AttributeNameAndValue]
identityAttributeValues

instance Data.ToJSON TypedLinkSpecifier where
  toJSON :: TypedLinkSpecifier -> Value
toJSON TypedLinkSpecifier' {[AttributeNameAndValue]
ObjectReference
TypedLinkSchemaAndFacetName
identityAttributeValues :: [AttributeNameAndValue]
targetObjectReference :: ObjectReference
sourceObjectReference :: ObjectReference
typedLinkFacet :: TypedLinkSchemaAndFacetName
$sel:identityAttributeValues:TypedLinkSpecifier' :: TypedLinkSpecifier -> [AttributeNameAndValue]
$sel:targetObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
$sel:sourceObjectReference:TypedLinkSpecifier' :: TypedLinkSpecifier -> ObjectReference
$sel:typedLinkFacet:TypedLinkSpecifier' :: TypedLinkSpecifier -> TypedLinkSchemaAndFacetName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"TypedLinkFacet" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TypedLinkSchemaAndFacetName
typedLinkFacet),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"SourceObjectReference"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ObjectReference
sourceObjectReference
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"TargetObjectReference"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ObjectReference
targetObjectReference
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"IdentityAttributeValues"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AttributeNameAndValue]
identityAttributeValues
              )
          ]
      )