{-# 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-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.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.Lens as Lens
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
(BatchAttachTypedLink -> BatchAttachTypedLink -> Bool)
-> (BatchAttachTypedLink -> BatchAttachTypedLink -> Bool)
-> Eq BatchAttachTypedLink
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]
(Int -> ReadS BatchAttachTypedLink)
-> ReadS [BatchAttachTypedLink]
-> ReadPrec BatchAttachTypedLink
-> ReadPrec [BatchAttachTypedLink]
-> Read 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
(Int -> BatchAttachTypedLink -> ShowS)
-> (BatchAttachTypedLink -> String)
-> ([BatchAttachTypedLink] -> ShowS)
-> Show BatchAttachTypedLink
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. BatchAttachTypedLink -> Rep BatchAttachTypedLink x)
-> (forall x. Rep BatchAttachTypedLink x -> BatchAttachTypedLink)
-> Generic BatchAttachTypedLink
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' :: ObjectReference
-> ObjectReference
-> TypedLinkSchemaAndFacetName
-> [AttributeNameAndValue]
-> BatchAttachTypedLink
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 = [AttributeNameAndValue]
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 :: (ObjectReference -> f ObjectReference)
-> BatchAttachTypedLink -> f BatchAttachTypedLink
batchAttachTypedLink_sourceObjectReference = (BatchAttachTypedLink -> ObjectReference)
-> (BatchAttachTypedLink
    -> ObjectReference -> BatchAttachTypedLink)
-> Lens
     BatchAttachTypedLink
     BatchAttachTypedLink
     ObjectReference
     ObjectReference
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 :: (ObjectReference -> f ObjectReference)
-> BatchAttachTypedLink -> f BatchAttachTypedLink
batchAttachTypedLink_targetObjectReference = (BatchAttachTypedLink -> ObjectReference)
-> (BatchAttachTypedLink
    -> ObjectReference -> BatchAttachTypedLink)
-> Lens
     BatchAttachTypedLink
     BatchAttachTypedLink
     ObjectReference
     ObjectReference
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 :: (TypedLinkSchemaAndFacetName -> f TypedLinkSchemaAndFacetName)
-> BatchAttachTypedLink -> f BatchAttachTypedLink
batchAttachTypedLink_typedLinkFacet = (BatchAttachTypedLink -> TypedLinkSchemaAndFacetName)
-> (BatchAttachTypedLink
    -> TypedLinkSchemaAndFacetName -> BatchAttachTypedLink)
-> Lens
     BatchAttachTypedLink
     BatchAttachTypedLink
     TypedLinkSchemaAndFacetName
     TypedLinkSchemaAndFacetName
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 :: ([AttributeNameAndValue] -> f [AttributeNameAndValue])
-> BatchAttachTypedLink -> f BatchAttachTypedLink
batchAttachTypedLink_attributes = (BatchAttachTypedLink -> [AttributeNameAndValue])
-> (BatchAttachTypedLink
    -> [AttributeNameAndValue] -> BatchAttachTypedLink)
-> Lens
     BatchAttachTypedLink
     BatchAttachTypedLink
     [AttributeNameAndValue]
     [AttributeNameAndValue]
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) (([AttributeNameAndValue] -> f [AttributeNameAndValue])
 -> BatchAttachTypedLink -> f BatchAttachTypedLink)
-> (([AttributeNameAndValue] -> f [AttributeNameAndValue])
    -> [AttributeNameAndValue] -> f [AttributeNameAndValue])
-> ([AttributeNameAndValue] -> f [AttributeNameAndValue])
-> BatchAttachTypedLink
-> f BatchAttachTypedLink
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AttributeNameAndValue] -> f [AttributeNameAndValue])
-> [AttributeNameAndValue] -> f [AttributeNameAndValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable BatchAttachTypedLink

instance Prelude.NFData BatchAttachTypedLink

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"SourceObjectReference"
                  Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
sourceObjectReference
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"TargetObjectReference"
                  Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
targetObjectReference
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TypedLinkFacet" Text -> TypedLinkSchemaAndFacetName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TypedLinkSchemaAndFacetName
typedLinkFacet),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Attributes" Text -> [AttributeNameAndValue] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [AttributeNameAndValue]
attributes)
          ]
      )