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

import Amazonka.CloudDirectory.Types.ObjectReference
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the output of an AttachObject operation.
--
-- /See:/ 'newBatchAttachObject' smart constructor.
data BatchAttachObject = BatchAttachObject'
  { -- | The parent object reference.
    BatchAttachObject -> ObjectReference
parentReference :: ObjectReference,
    -- | The child object reference that is to be attached to the object.
    BatchAttachObject -> ObjectReference
childReference :: ObjectReference,
    -- | The name of the link.
    BatchAttachObject -> Text
linkName :: Prelude.Text
  }
  deriving (BatchAttachObject -> BatchAttachObject -> Bool
(BatchAttachObject -> BatchAttachObject -> Bool)
-> (BatchAttachObject -> BatchAttachObject -> Bool)
-> Eq BatchAttachObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchAttachObject -> BatchAttachObject -> Bool
$c/= :: BatchAttachObject -> BatchAttachObject -> Bool
== :: BatchAttachObject -> BatchAttachObject -> Bool
$c== :: BatchAttachObject -> BatchAttachObject -> Bool
Prelude.Eq, ReadPrec [BatchAttachObject]
ReadPrec BatchAttachObject
Int -> ReadS BatchAttachObject
ReadS [BatchAttachObject]
(Int -> ReadS BatchAttachObject)
-> ReadS [BatchAttachObject]
-> ReadPrec BatchAttachObject
-> ReadPrec [BatchAttachObject]
-> Read BatchAttachObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchAttachObject]
$creadListPrec :: ReadPrec [BatchAttachObject]
readPrec :: ReadPrec BatchAttachObject
$creadPrec :: ReadPrec BatchAttachObject
readList :: ReadS [BatchAttachObject]
$creadList :: ReadS [BatchAttachObject]
readsPrec :: Int -> ReadS BatchAttachObject
$creadsPrec :: Int -> ReadS BatchAttachObject
Prelude.Read, Int -> BatchAttachObject -> ShowS
[BatchAttachObject] -> ShowS
BatchAttachObject -> String
(Int -> BatchAttachObject -> ShowS)
-> (BatchAttachObject -> String)
-> ([BatchAttachObject] -> ShowS)
-> Show BatchAttachObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchAttachObject] -> ShowS
$cshowList :: [BatchAttachObject] -> ShowS
show :: BatchAttachObject -> String
$cshow :: BatchAttachObject -> String
showsPrec :: Int -> BatchAttachObject -> ShowS
$cshowsPrec :: Int -> BatchAttachObject -> ShowS
Prelude.Show, (forall x. BatchAttachObject -> Rep BatchAttachObject x)
-> (forall x. Rep BatchAttachObject x -> BatchAttachObject)
-> Generic BatchAttachObject
forall x. Rep BatchAttachObject x -> BatchAttachObject
forall x. BatchAttachObject -> Rep BatchAttachObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchAttachObject x -> BatchAttachObject
$cfrom :: forall x. BatchAttachObject -> Rep BatchAttachObject x
Prelude.Generic)

-- |
-- Create a value of 'BatchAttachObject' 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:
--
-- 'parentReference', 'batchAttachObject_parentReference' - The parent object reference.
--
-- 'childReference', 'batchAttachObject_childReference' - The child object reference that is to be attached to the object.
--
-- 'linkName', 'batchAttachObject_linkName' - The name of the link.
newBatchAttachObject ::
  -- | 'parentReference'
  ObjectReference ->
  -- | 'childReference'
  ObjectReference ->
  -- | 'linkName'
  Prelude.Text ->
  BatchAttachObject
newBatchAttachObject :: ObjectReference -> ObjectReference -> Text -> BatchAttachObject
newBatchAttachObject
  ObjectReference
pParentReference_
  ObjectReference
pChildReference_
  Text
pLinkName_ =
    BatchAttachObject' :: ObjectReference -> ObjectReference -> Text -> BatchAttachObject
BatchAttachObject'
      { $sel:parentReference:BatchAttachObject' :: ObjectReference
parentReference =
          ObjectReference
pParentReference_,
        $sel:childReference:BatchAttachObject' :: ObjectReference
childReference = ObjectReference
pChildReference_,
        $sel:linkName:BatchAttachObject' :: Text
linkName = Text
pLinkName_
      }

-- | The parent object reference.
batchAttachObject_parentReference :: Lens.Lens' BatchAttachObject ObjectReference
batchAttachObject_parentReference :: (ObjectReference -> f ObjectReference)
-> BatchAttachObject -> f BatchAttachObject
batchAttachObject_parentReference = (BatchAttachObject -> ObjectReference)
-> (BatchAttachObject -> ObjectReference -> BatchAttachObject)
-> Lens
     BatchAttachObject BatchAttachObject ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachObject' {ObjectReference
parentReference :: ObjectReference
$sel:parentReference:BatchAttachObject' :: BatchAttachObject -> ObjectReference
parentReference} -> ObjectReference
parentReference) (\s :: BatchAttachObject
s@BatchAttachObject' {} ObjectReference
a -> BatchAttachObject
s {$sel:parentReference:BatchAttachObject' :: ObjectReference
parentReference = ObjectReference
a} :: BatchAttachObject)

-- | The child object reference that is to be attached to the object.
batchAttachObject_childReference :: Lens.Lens' BatchAttachObject ObjectReference
batchAttachObject_childReference :: (ObjectReference -> f ObjectReference)
-> BatchAttachObject -> f BatchAttachObject
batchAttachObject_childReference = (BatchAttachObject -> ObjectReference)
-> (BatchAttachObject -> ObjectReference -> BatchAttachObject)
-> Lens
     BatchAttachObject BatchAttachObject ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachObject' {ObjectReference
childReference :: ObjectReference
$sel:childReference:BatchAttachObject' :: BatchAttachObject -> ObjectReference
childReference} -> ObjectReference
childReference) (\s :: BatchAttachObject
s@BatchAttachObject' {} ObjectReference
a -> BatchAttachObject
s {$sel:childReference:BatchAttachObject' :: ObjectReference
childReference = ObjectReference
a} :: BatchAttachObject)

-- | The name of the link.
batchAttachObject_linkName :: Lens.Lens' BatchAttachObject Prelude.Text
batchAttachObject_linkName :: (Text -> f Text) -> BatchAttachObject -> f BatchAttachObject
batchAttachObject_linkName = (BatchAttachObject -> Text)
-> (BatchAttachObject -> Text -> BatchAttachObject)
-> Lens BatchAttachObject BatchAttachObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachObject' {Text
linkName :: Text
$sel:linkName:BatchAttachObject' :: BatchAttachObject -> Text
linkName} -> Text
linkName) (\s :: BatchAttachObject
s@BatchAttachObject' {} Text
a -> BatchAttachObject
s {$sel:linkName:BatchAttachObject' :: Text
linkName = Text
a} :: BatchAttachObject)

instance Prelude.Hashable BatchAttachObject

instance Prelude.NFData BatchAttachObject

instance Core.ToJSON BatchAttachObject where
  toJSON :: BatchAttachObject -> Value
toJSON BatchAttachObject' {Text
ObjectReference
linkName :: Text
childReference :: ObjectReference
parentReference :: ObjectReference
$sel:linkName:BatchAttachObject' :: BatchAttachObject -> Text
$sel:childReference:BatchAttachObject' :: BatchAttachObject -> ObjectReference
$sel:parentReference:BatchAttachObject' :: BatchAttachObject -> 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
"ParentReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
parentReference),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ChildReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
childReference),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LinkName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
linkName)
          ]
      )