{-# 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.BatchDetachObject
-- 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.BatchDetachObject 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 a DetachObject operation.
--
-- /See:/ 'newBatchDetachObject' smart constructor.
data BatchDetachObject = BatchDetachObject'
  { -- | The batch reference name. See
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
    -- for more information.
    BatchDetachObject -> Maybe Text
batchReferenceName :: Prelude.Maybe Prelude.Text,
    -- | Parent reference from which the object with the specified link name is
    -- detached.
    BatchDetachObject -> ObjectReference
parentReference :: ObjectReference,
    -- | The name of the link.
    BatchDetachObject -> Text
linkName :: Prelude.Text
  }
  deriving (BatchDetachObject -> BatchDetachObject -> Bool
(BatchDetachObject -> BatchDetachObject -> Bool)
-> (BatchDetachObject -> BatchDetachObject -> Bool)
-> Eq BatchDetachObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDetachObject -> BatchDetachObject -> Bool
$c/= :: BatchDetachObject -> BatchDetachObject -> Bool
== :: BatchDetachObject -> BatchDetachObject -> Bool
$c== :: BatchDetachObject -> BatchDetachObject -> Bool
Prelude.Eq, ReadPrec [BatchDetachObject]
ReadPrec BatchDetachObject
Int -> ReadS BatchDetachObject
ReadS [BatchDetachObject]
(Int -> ReadS BatchDetachObject)
-> ReadS [BatchDetachObject]
-> ReadPrec BatchDetachObject
-> ReadPrec [BatchDetachObject]
-> Read BatchDetachObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDetachObject]
$creadListPrec :: ReadPrec [BatchDetachObject]
readPrec :: ReadPrec BatchDetachObject
$creadPrec :: ReadPrec BatchDetachObject
readList :: ReadS [BatchDetachObject]
$creadList :: ReadS [BatchDetachObject]
readsPrec :: Int -> ReadS BatchDetachObject
$creadsPrec :: Int -> ReadS BatchDetachObject
Prelude.Read, Int -> BatchDetachObject -> ShowS
[BatchDetachObject] -> ShowS
BatchDetachObject -> String
(Int -> BatchDetachObject -> ShowS)
-> (BatchDetachObject -> String)
-> ([BatchDetachObject] -> ShowS)
-> Show BatchDetachObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDetachObject] -> ShowS
$cshowList :: [BatchDetachObject] -> ShowS
show :: BatchDetachObject -> String
$cshow :: BatchDetachObject -> String
showsPrec :: Int -> BatchDetachObject -> ShowS
$cshowsPrec :: Int -> BatchDetachObject -> ShowS
Prelude.Show, (forall x. BatchDetachObject -> Rep BatchDetachObject x)
-> (forall x. Rep BatchDetachObject x -> BatchDetachObject)
-> Generic BatchDetachObject
forall x. Rep BatchDetachObject x -> BatchDetachObject
forall x. BatchDetachObject -> Rep BatchDetachObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDetachObject x -> BatchDetachObject
$cfrom :: forall x. BatchDetachObject -> Rep BatchDetachObject x
Prelude.Generic)

-- |
-- Create a value of 'BatchDetachObject' 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:
--
-- 'batchReferenceName', 'batchDetachObject_batchReferenceName' - The batch reference name. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
-- for more information.
--
-- 'parentReference', 'batchDetachObject_parentReference' - Parent reference from which the object with the specified link name is
-- detached.
--
-- 'linkName', 'batchDetachObject_linkName' - The name of the link.
newBatchDetachObject ::
  -- | 'parentReference'
  ObjectReference ->
  -- | 'linkName'
  Prelude.Text ->
  BatchDetachObject
newBatchDetachObject :: ObjectReference -> Text -> BatchDetachObject
newBatchDetachObject ObjectReference
pParentReference_ Text
pLinkName_ =
  BatchDetachObject' :: Maybe Text -> ObjectReference -> Text -> BatchDetachObject
BatchDetachObject'
    { $sel:batchReferenceName:BatchDetachObject' :: Maybe Text
batchReferenceName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parentReference:BatchDetachObject' :: ObjectReference
parentReference = ObjectReference
pParentReference_,
      $sel:linkName:BatchDetachObject' :: Text
linkName = Text
pLinkName_
    }

-- | The batch reference name. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
-- for more information.
batchDetachObject_batchReferenceName :: Lens.Lens' BatchDetachObject (Prelude.Maybe Prelude.Text)
batchDetachObject_batchReferenceName :: (Maybe Text -> f (Maybe Text))
-> BatchDetachObject -> f BatchDetachObject
batchDetachObject_batchReferenceName = (BatchDetachObject -> Maybe Text)
-> (BatchDetachObject -> Maybe Text -> BatchDetachObject)
-> Lens
     BatchDetachObject BatchDetachObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetachObject' {Maybe Text
batchReferenceName :: Maybe Text
$sel:batchReferenceName:BatchDetachObject' :: BatchDetachObject -> Maybe Text
batchReferenceName} -> Maybe Text
batchReferenceName) (\s :: BatchDetachObject
s@BatchDetachObject' {} Maybe Text
a -> BatchDetachObject
s {$sel:batchReferenceName:BatchDetachObject' :: Maybe Text
batchReferenceName = Maybe Text
a} :: BatchDetachObject)

-- | Parent reference from which the object with the specified link name is
-- detached.
batchDetachObject_parentReference :: Lens.Lens' BatchDetachObject ObjectReference
batchDetachObject_parentReference :: (ObjectReference -> f ObjectReference)
-> BatchDetachObject -> f BatchDetachObject
batchDetachObject_parentReference = (BatchDetachObject -> ObjectReference)
-> (BatchDetachObject -> ObjectReference -> BatchDetachObject)
-> Lens
     BatchDetachObject BatchDetachObject ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetachObject' {ObjectReference
parentReference :: ObjectReference
$sel:parentReference:BatchDetachObject' :: BatchDetachObject -> ObjectReference
parentReference} -> ObjectReference
parentReference) (\s :: BatchDetachObject
s@BatchDetachObject' {} ObjectReference
a -> BatchDetachObject
s {$sel:parentReference:BatchDetachObject' :: ObjectReference
parentReference = ObjectReference
a} :: BatchDetachObject)

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

instance Prelude.Hashable BatchDetachObject

instance Prelude.NFData BatchDetachObject

instance Core.ToJSON BatchDetachObject where
  toJSON :: BatchDetachObject -> Value
toJSON BatchDetachObject' {Maybe Text
Text
ObjectReference
linkName :: Text
parentReference :: ObjectReference
batchReferenceName :: Maybe Text
$sel:linkName:BatchDetachObject' :: BatchDetachObject -> Text
$sel:parentReference:BatchDetachObject' :: BatchDetachObject -> ObjectReference
$sel:batchReferenceName:BatchDetachObject' :: BatchDetachObject -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BatchReferenceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
batchReferenceName,
            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
"LinkName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
linkName)
          ]
      )