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

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

-- | Represents the output of a CreateObject operation.
--
-- /See:/ 'newBatchCreateObject' smart constructor.
data BatchCreateObject = BatchCreateObject'
  { -- | If specified, the parent reference to which this object will be
    -- attached.
    BatchCreateObject -> Maybe ObjectReference
parentReference :: Prelude.Maybe ObjectReference,
    -- | The name of the link.
    BatchCreateObject -> Maybe Text
linkName :: Prelude.Maybe Prelude.Text,
    -- | The batch reference name. See
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
    -- for more information.
    BatchCreateObject -> Maybe Text
batchReferenceName :: Prelude.Maybe Prelude.Text,
    -- | A list of @FacetArns@ that will be associated with the object. For more
    -- information, see arns.
    BatchCreateObject -> [SchemaFacet]
schemaFacet :: [SchemaFacet],
    -- | An attribute map, which contains an attribute ARN as the key and
    -- attribute value as the map value.
    BatchCreateObject -> [AttributeKeyAndValue]
objectAttributeList :: [AttributeKeyAndValue]
  }
  deriving (BatchCreateObject -> BatchCreateObject -> Bool
(BatchCreateObject -> BatchCreateObject -> Bool)
-> (BatchCreateObject -> BatchCreateObject -> Bool)
-> Eq BatchCreateObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateObject -> BatchCreateObject -> Bool
$c/= :: BatchCreateObject -> BatchCreateObject -> Bool
== :: BatchCreateObject -> BatchCreateObject -> Bool
$c== :: BatchCreateObject -> BatchCreateObject -> Bool
Prelude.Eq, ReadPrec [BatchCreateObject]
ReadPrec BatchCreateObject
Int -> ReadS BatchCreateObject
ReadS [BatchCreateObject]
(Int -> ReadS BatchCreateObject)
-> ReadS [BatchCreateObject]
-> ReadPrec BatchCreateObject
-> ReadPrec [BatchCreateObject]
-> Read BatchCreateObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreateObject]
$creadListPrec :: ReadPrec [BatchCreateObject]
readPrec :: ReadPrec BatchCreateObject
$creadPrec :: ReadPrec BatchCreateObject
readList :: ReadS [BatchCreateObject]
$creadList :: ReadS [BatchCreateObject]
readsPrec :: Int -> ReadS BatchCreateObject
$creadsPrec :: Int -> ReadS BatchCreateObject
Prelude.Read, Int -> BatchCreateObject -> ShowS
[BatchCreateObject] -> ShowS
BatchCreateObject -> String
(Int -> BatchCreateObject -> ShowS)
-> (BatchCreateObject -> String)
-> ([BatchCreateObject] -> ShowS)
-> Show BatchCreateObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateObject] -> ShowS
$cshowList :: [BatchCreateObject] -> ShowS
show :: BatchCreateObject -> String
$cshow :: BatchCreateObject -> String
showsPrec :: Int -> BatchCreateObject -> ShowS
$cshowsPrec :: Int -> BatchCreateObject -> ShowS
Prelude.Show, (forall x. BatchCreateObject -> Rep BatchCreateObject x)
-> (forall x. Rep BatchCreateObject x -> BatchCreateObject)
-> Generic BatchCreateObject
forall x. Rep BatchCreateObject x -> BatchCreateObject
forall x. BatchCreateObject -> Rep BatchCreateObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchCreateObject x -> BatchCreateObject
$cfrom :: forall x. BatchCreateObject -> Rep BatchCreateObject x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateObject' 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', 'batchCreateObject_parentReference' - If specified, the parent reference to which this object will be
-- attached.
--
-- 'linkName', 'batchCreateObject_linkName' - The name of the link.
--
-- 'batchReferenceName', 'batchCreateObject_batchReferenceName' - The batch reference name. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
-- for more information.
--
-- 'schemaFacet', 'batchCreateObject_schemaFacet' - A list of @FacetArns@ that will be associated with the object. For more
-- information, see arns.
--
-- 'objectAttributeList', 'batchCreateObject_objectAttributeList' - An attribute map, which contains an attribute ARN as the key and
-- attribute value as the map value.
newBatchCreateObject ::
  BatchCreateObject
newBatchCreateObject :: BatchCreateObject
newBatchCreateObject =
  BatchCreateObject' :: Maybe ObjectReference
-> Maybe Text
-> Maybe Text
-> [SchemaFacet]
-> [AttributeKeyAndValue]
-> BatchCreateObject
BatchCreateObject'
    { $sel:parentReference:BatchCreateObject' :: Maybe ObjectReference
parentReference =
        Maybe ObjectReference
forall a. Maybe a
Prelude.Nothing,
      $sel:linkName:BatchCreateObject' :: Maybe Text
linkName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:batchReferenceName:BatchCreateObject' :: Maybe Text
batchReferenceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:schemaFacet:BatchCreateObject' :: [SchemaFacet]
schemaFacet = [SchemaFacet]
forall a. Monoid a => a
Prelude.mempty,
      $sel:objectAttributeList:BatchCreateObject' :: [AttributeKeyAndValue]
objectAttributeList = [AttributeKeyAndValue]
forall a. Monoid a => a
Prelude.mempty
    }

-- | If specified, the parent reference to which this object will be
-- attached.
batchCreateObject_parentReference :: Lens.Lens' BatchCreateObject (Prelude.Maybe ObjectReference)
batchCreateObject_parentReference :: (Maybe ObjectReference -> f (Maybe ObjectReference))
-> BatchCreateObject -> f BatchCreateObject
batchCreateObject_parentReference = (BatchCreateObject -> Maybe ObjectReference)
-> (BatchCreateObject
    -> Maybe ObjectReference -> BatchCreateObject)
-> Lens
     BatchCreateObject
     BatchCreateObject
     (Maybe ObjectReference)
     (Maybe ObjectReference)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateObject' {Maybe ObjectReference
parentReference :: Maybe ObjectReference
$sel:parentReference:BatchCreateObject' :: BatchCreateObject -> Maybe ObjectReference
parentReference} -> Maybe ObjectReference
parentReference) (\s :: BatchCreateObject
s@BatchCreateObject' {} Maybe ObjectReference
a -> BatchCreateObject
s {$sel:parentReference:BatchCreateObject' :: Maybe ObjectReference
parentReference = Maybe ObjectReference
a} :: BatchCreateObject)

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

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

-- | A list of @FacetArns@ that will be associated with the object. For more
-- information, see arns.
batchCreateObject_schemaFacet :: Lens.Lens' BatchCreateObject [SchemaFacet]
batchCreateObject_schemaFacet :: ([SchemaFacet] -> f [SchemaFacet])
-> BatchCreateObject -> f BatchCreateObject
batchCreateObject_schemaFacet = (BatchCreateObject -> [SchemaFacet])
-> (BatchCreateObject -> [SchemaFacet] -> BatchCreateObject)
-> Lens
     BatchCreateObject BatchCreateObject [SchemaFacet] [SchemaFacet]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateObject' {[SchemaFacet]
schemaFacet :: [SchemaFacet]
$sel:schemaFacet:BatchCreateObject' :: BatchCreateObject -> [SchemaFacet]
schemaFacet} -> [SchemaFacet]
schemaFacet) (\s :: BatchCreateObject
s@BatchCreateObject' {} [SchemaFacet]
a -> BatchCreateObject
s {$sel:schemaFacet:BatchCreateObject' :: [SchemaFacet]
schemaFacet = [SchemaFacet]
a} :: BatchCreateObject) (([SchemaFacet] -> f [SchemaFacet])
 -> BatchCreateObject -> f BatchCreateObject)
-> (([SchemaFacet] -> f [SchemaFacet])
    -> [SchemaFacet] -> f [SchemaFacet])
-> ([SchemaFacet] -> f [SchemaFacet])
-> BatchCreateObject
-> f BatchCreateObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([SchemaFacet] -> f [SchemaFacet])
-> [SchemaFacet] -> f [SchemaFacet]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An attribute map, which contains an attribute ARN as the key and
-- attribute value as the map value.
batchCreateObject_objectAttributeList :: Lens.Lens' BatchCreateObject [AttributeKeyAndValue]
batchCreateObject_objectAttributeList :: ([AttributeKeyAndValue] -> f [AttributeKeyAndValue])
-> BatchCreateObject -> f BatchCreateObject
batchCreateObject_objectAttributeList = (BatchCreateObject -> [AttributeKeyAndValue])
-> (BatchCreateObject
    -> [AttributeKeyAndValue] -> BatchCreateObject)
-> Lens
     BatchCreateObject
     BatchCreateObject
     [AttributeKeyAndValue]
     [AttributeKeyAndValue]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateObject' {[AttributeKeyAndValue]
objectAttributeList :: [AttributeKeyAndValue]
$sel:objectAttributeList:BatchCreateObject' :: BatchCreateObject -> [AttributeKeyAndValue]
objectAttributeList} -> [AttributeKeyAndValue]
objectAttributeList) (\s :: BatchCreateObject
s@BatchCreateObject' {} [AttributeKeyAndValue]
a -> BatchCreateObject
s {$sel:objectAttributeList:BatchCreateObject' :: [AttributeKeyAndValue]
objectAttributeList = [AttributeKeyAndValue]
a} :: BatchCreateObject) (([AttributeKeyAndValue] -> f [AttributeKeyAndValue])
 -> BatchCreateObject -> f BatchCreateObject)
-> (([AttributeKeyAndValue] -> f [AttributeKeyAndValue])
    -> [AttributeKeyAndValue] -> f [AttributeKeyAndValue])
-> ([AttributeKeyAndValue] -> f [AttributeKeyAndValue])
-> BatchCreateObject
-> f BatchCreateObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AttributeKeyAndValue] -> f [AttributeKeyAndValue])
-> [AttributeKeyAndValue] -> f [AttributeKeyAndValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable BatchCreateObject

instance Prelude.NFData BatchCreateObject

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