{-# 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.BatchAttachTypedLink
-- 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.BatchAttachTypedLink 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

-- | Attaches a typed link to a specified source and target object inside a
-- BatchRead operation. For more information, see AttachTypedLink and
-- BatchReadRequest$Operations.
--
-- /See:/ 'newBatchAttachTypedLink' smart constructor.
data BatchAttachTypedLink = BatchAttachTypedLink'
  { -- | Identifies the source object that the typed link will attach to.
    BatchAttachTypedLink -> ObjectReference
sourceObjectReference :: ObjectReference,
    -- | Identifies the target object that the typed link will attach to.
    BatchAttachTypedLink -> ObjectReference
targetObjectReference :: ObjectReference,
    -- | Identifies the typed link facet that is associated with the typed link.
    BatchAttachTypedLink -> TypedLinkSchemaAndFacetName
typedLinkFacet :: TypedLinkSchemaAndFacetName,
    -- | A set of attributes that are associated with the typed link.
    BatchAttachTypedLink -> [AttributeNameAndValue]
attributes :: [AttributeNameAndValue]
  }
  deriving (BatchAttachTypedLink -> BatchAttachTypedLink -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchAttachTypedLink -> BatchAttachTypedLink -> Bool
$c/= :: BatchAttachTypedLink -> BatchAttachTypedLink -> Bool
== :: BatchAttachTypedLink -> BatchAttachTypedLink -> Bool
$c== :: BatchAttachTypedLink -> BatchAttachTypedLink -> Bool
Prelude.Eq, ReadPrec [BatchAttachTypedLink]
ReadPrec BatchAttachTypedLink
Int -> ReadS BatchAttachTypedLink
ReadS [BatchAttachTypedLink]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchAttachTypedLink]
$creadListPrec :: ReadPrec [BatchAttachTypedLink]
readPrec :: ReadPrec BatchAttachTypedLink
$creadPrec :: ReadPrec BatchAttachTypedLink
readList :: ReadS [BatchAttachTypedLink]
$creadList :: ReadS [BatchAttachTypedLink]
readsPrec :: Int -> ReadS BatchAttachTypedLink
$creadsPrec :: Int -> ReadS BatchAttachTypedLink
Prelude.Read, Int -> BatchAttachTypedLink -> ShowS
[BatchAttachTypedLink] -> ShowS
BatchAttachTypedLink -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchAttachTypedLink] -> ShowS
$cshowList :: [BatchAttachTypedLink] -> ShowS
show :: BatchAttachTypedLink -> String
$cshow :: BatchAttachTypedLink -> String
showsPrec :: Int -> BatchAttachTypedLink -> ShowS
$cshowsPrec :: Int -> BatchAttachTypedLink -> ShowS
Prelude.Show, forall x. Rep BatchAttachTypedLink x -> BatchAttachTypedLink
forall x. BatchAttachTypedLink -> Rep BatchAttachTypedLink x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchAttachTypedLink x -> BatchAttachTypedLink
$cfrom :: forall x. BatchAttachTypedLink -> Rep BatchAttachTypedLink x
Prelude.Generic)

-- |
-- Create a value of 'BatchAttachTypedLink' 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:
--
-- 'sourceObjectReference', 'batchAttachTypedLink_sourceObjectReference' - Identifies the source object that the typed link will attach to.
--
-- 'targetObjectReference', 'batchAttachTypedLink_targetObjectReference' - Identifies the target object that the typed link will attach to.
--
-- 'typedLinkFacet', 'batchAttachTypedLink_typedLinkFacet' - Identifies the typed link facet that is associated with the typed link.
--
-- 'attributes', 'batchAttachTypedLink_attributes' - A set of attributes that are associated with the typed link.
newBatchAttachTypedLink ::
  -- | 'sourceObjectReference'
  ObjectReference ->
  -- | 'targetObjectReference'
  ObjectReference ->
  -- | 'typedLinkFacet'
  TypedLinkSchemaAndFacetName ->
  BatchAttachTypedLink
newBatchAttachTypedLink :: ObjectReference
-> ObjectReference
-> TypedLinkSchemaAndFacetName
-> BatchAttachTypedLink
newBatchAttachTypedLink
  ObjectReference
pSourceObjectReference_
  ObjectReference
pTargetObjectReference_
  TypedLinkSchemaAndFacetName
pTypedLinkFacet_ =
    BatchAttachTypedLink'
      { $sel:sourceObjectReference:BatchAttachTypedLink' :: ObjectReference
sourceObjectReference =
          ObjectReference
pSourceObjectReference_,
        $sel:targetObjectReference:BatchAttachTypedLink' :: ObjectReference
targetObjectReference = ObjectReference
pTargetObjectReference_,
        $sel:typedLinkFacet:BatchAttachTypedLink' :: TypedLinkSchemaAndFacetName
typedLinkFacet = TypedLinkSchemaAndFacetName
pTypedLinkFacet_,
        $sel:attributes:BatchAttachTypedLink' :: [AttributeNameAndValue]
attributes = forall a. Monoid a => a
Prelude.mempty
      }

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

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

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

-- | A set of attributes that are associated with the typed link.
batchAttachTypedLink_attributes :: Lens.Lens' BatchAttachTypedLink [AttributeNameAndValue]
batchAttachTypedLink_attributes :: Lens' BatchAttachTypedLink [AttributeNameAndValue]
batchAttachTypedLink_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachTypedLink' {[AttributeNameAndValue]
attributes :: [AttributeNameAndValue]
$sel:attributes:BatchAttachTypedLink' :: BatchAttachTypedLink -> [AttributeNameAndValue]
attributes} -> [AttributeNameAndValue]
attributes) (\s :: BatchAttachTypedLink
s@BatchAttachTypedLink' {} [AttributeNameAndValue]
a -> BatchAttachTypedLink
s {$sel:attributes:BatchAttachTypedLink' :: [AttributeNameAndValue]
attributes = [AttributeNameAndValue]
a} :: BatchAttachTypedLink) 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 BatchAttachTypedLink where
  hashWithSalt :: Int -> BatchAttachTypedLink -> Int
hashWithSalt Int
_salt BatchAttachTypedLink' {[AttributeNameAndValue]
ObjectReference
TypedLinkSchemaAndFacetName
attributes :: [AttributeNameAndValue]
typedLinkFacet :: TypedLinkSchemaAndFacetName
targetObjectReference :: ObjectReference
sourceObjectReference :: ObjectReference
$sel:attributes:BatchAttachTypedLink' :: BatchAttachTypedLink -> [AttributeNameAndValue]
$sel:typedLinkFacet:BatchAttachTypedLink' :: BatchAttachTypedLink -> TypedLinkSchemaAndFacetName
$sel:targetObjectReference:BatchAttachTypedLink' :: BatchAttachTypedLink -> ObjectReference
$sel:sourceObjectReference:BatchAttachTypedLink' :: BatchAttachTypedLink -> ObjectReference
..} =
    Int
_salt
      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` TypedLinkSchemaAndFacetName
typedLinkFacet
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AttributeNameAndValue]
attributes

instance Prelude.NFData BatchAttachTypedLink where
  rnf :: BatchAttachTypedLink -> ()
rnf BatchAttachTypedLink' {[AttributeNameAndValue]
ObjectReference
TypedLinkSchemaAndFacetName
attributes :: [AttributeNameAndValue]
typedLinkFacet :: TypedLinkSchemaAndFacetName
targetObjectReference :: ObjectReference
sourceObjectReference :: ObjectReference
$sel:attributes:BatchAttachTypedLink' :: BatchAttachTypedLink -> [AttributeNameAndValue]
$sel:typedLinkFacet:BatchAttachTypedLink' :: BatchAttachTypedLink -> TypedLinkSchemaAndFacetName
$sel:targetObjectReference:BatchAttachTypedLink' :: BatchAttachTypedLink -> ObjectReference
$sel:sourceObjectReference:BatchAttachTypedLink' :: BatchAttachTypedLink -> ObjectReference
..} =
    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 TypedLinkSchemaAndFacetName
typedLinkFacet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AttributeNameAndValue]
attributes

instance Data.ToJSON BatchAttachTypedLink where
  toJSON :: BatchAttachTypedLink -> Value
toJSON BatchAttachTypedLink' {[AttributeNameAndValue]
ObjectReference
TypedLinkSchemaAndFacetName
attributes :: [AttributeNameAndValue]
typedLinkFacet :: TypedLinkSchemaAndFacetName
targetObjectReference :: ObjectReference
sourceObjectReference :: ObjectReference
$sel:attributes:BatchAttachTypedLink' :: BatchAttachTypedLink -> [AttributeNameAndValue]
$sel:typedLinkFacet:BatchAttachTypedLink' :: BatchAttachTypedLink -> TypedLinkSchemaAndFacetName
$sel:targetObjectReference:BatchAttachTypedLink' :: BatchAttachTypedLink -> ObjectReference
$sel:sourceObjectReference:BatchAttachTypedLink' :: BatchAttachTypedLink -> ObjectReference
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
"TypedLinkFacet" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TypedLinkSchemaAndFacetName
typedLinkFacet),
            forall a. a -> Maybe a
Prelude.Just (Key
"Attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AttributeNameAndValue]
attributes)
          ]
      )