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

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

-- | 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
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]
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
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. 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'
    { $sel:batchReferenceName:BatchDetachObject' :: Maybe Text
batchReferenceName =
        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 :: Lens' BatchDetachObject (Maybe Text)
batchDetachObject_batchReferenceName = 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 :: Lens' BatchDetachObject ObjectReference
batchDetachObject_parentReference = 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 :: Lens' BatchDetachObject Text
batchDetachObject_linkName = 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 where
  hashWithSalt :: Int -> BatchDetachObject -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
batchReferenceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
parentReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
linkName

instance Prelude.NFData BatchDetachObject where
  rnf :: BatchDetachObject -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
batchReferenceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
parentReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
linkName

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BatchReferenceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
batchReferenceName,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ParentReference" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ObjectReference
parentReference),
            forall a. a -> Maybe a
Prelude.Just (Key
"LinkName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
linkName)
          ]
      )