{-# 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.SSMIncidents.Types.RelatedItemsUpdate
-- 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.SSMIncidents.Types.RelatedItemsUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSMIncidents.Types.ItemIdentifier
import Amazonka.SSMIncidents.Types.RelatedItem

-- | Details about the related item you\'re adding.
--
-- /See:/ 'newRelatedItemsUpdate' smart constructor.
data RelatedItemsUpdate = RelatedItemsUpdate'
  { -- | Details about the related item you\'re deleting.
    RelatedItemsUpdate -> Maybe ItemIdentifier
itemToRemove :: Prelude.Maybe ItemIdentifier,
    -- | Details about the related item you\'re adding.
    RelatedItemsUpdate -> Maybe RelatedItem
itemToAdd :: Prelude.Maybe RelatedItem
  }
  deriving (RelatedItemsUpdate -> RelatedItemsUpdate -> Bool
(RelatedItemsUpdate -> RelatedItemsUpdate -> Bool)
-> (RelatedItemsUpdate -> RelatedItemsUpdate -> Bool)
-> Eq RelatedItemsUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelatedItemsUpdate -> RelatedItemsUpdate -> Bool
$c/= :: RelatedItemsUpdate -> RelatedItemsUpdate -> Bool
== :: RelatedItemsUpdate -> RelatedItemsUpdate -> Bool
$c== :: RelatedItemsUpdate -> RelatedItemsUpdate -> Bool
Prelude.Eq, ReadPrec [RelatedItemsUpdate]
ReadPrec RelatedItemsUpdate
Int -> ReadS RelatedItemsUpdate
ReadS [RelatedItemsUpdate]
(Int -> ReadS RelatedItemsUpdate)
-> ReadS [RelatedItemsUpdate]
-> ReadPrec RelatedItemsUpdate
-> ReadPrec [RelatedItemsUpdate]
-> Read RelatedItemsUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelatedItemsUpdate]
$creadListPrec :: ReadPrec [RelatedItemsUpdate]
readPrec :: ReadPrec RelatedItemsUpdate
$creadPrec :: ReadPrec RelatedItemsUpdate
readList :: ReadS [RelatedItemsUpdate]
$creadList :: ReadS [RelatedItemsUpdate]
readsPrec :: Int -> ReadS RelatedItemsUpdate
$creadsPrec :: Int -> ReadS RelatedItemsUpdate
Prelude.Read, Int -> RelatedItemsUpdate -> ShowS
[RelatedItemsUpdate] -> ShowS
RelatedItemsUpdate -> String
(Int -> RelatedItemsUpdate -> ShowS)
-> (RelatedItemsUpdate -> String)
-> ([RelatedItemsUpdate] -> ShowS)
-> Show RelatedItemsUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelatedItemsUpdate] -> ShowS
$cshowList :: [RelatedItemsUpdate] -> ShowS
show :: RelatedItemsUpdate -> String
$cshow :: RelatedItemsUpdate -> String
showsPrec :: Int -> RelatedItemsUpdate -> ShowS
$cshowsPrec :: Int -> RelatedItemsUpdate -> ShowS
Prelude.Show, (forall x. RelatedItemsUpdate -> Rep RelatedItemsUpdate x)
-> (forall x. Rep RelatedItemsUpdate x -> RelatedItemsUpdate)
-> Generic RelatedItemsUpdate
forall x. Rep RelatedItemsUpdate x -> RelatedItemsUpdate
forall x. RelatedItemsUpdate -> Rep RelatedItemsUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelatedItemsUpdate x -> RelatedItemsUpdate
$cfrom :: forall x. RelatedItemsUpdate -> Rep RelatedItemsUpdate x
Prelude.Generic)

-- |
-- Create a value of 'RelatedItemsUpdate' 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:
--
-- 'itemToRemove', 'relatedItemsUpdate_itemToRemove' - Details about the related item you\'re deleting.
--
-- 'itemToAdd', 'relatedItemsUpdate_itemToAdd' - Details about the related item you\'re adding.
newRelatedItemsUpdate ::
  RelatedItemsUpdate
newRelatedItemsUpdate :: RelatedItemsUpdate
newRelatedItemsUpdate =
  RelatedItemsUpdate' :: Maybe ItemIdentifier -> Maybe RelatedItem -> RelatedItemsUpdate
RelatedItemsUpdate'
    { $sel:itemToRemove:RelatedItemsUpdate' :: Maybe ItemIdentifier
itemToRemove = Maybe ItemIdentifier
forall a. Maybe a
Prelude.Nothing,
      $sel:itemToAdd:RelatedItemsUpdate' :: Maybe RelatedItem
itemToAdd = Maybe RelatedItem
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about the related item you\'re deleting.
relatedItemsUpdate_itemToRemove :: Lens.Lens' RelatedItemsUpdate (Prelude.Maybe ItemIdentifier)
relatedItemsUpdate_itemToRemove :: (Maybe ItemIdentifier -> f (Maybe ItemIdentifier))
-> RelatedItemsUpdate -> f RelatedItemsUpdate
relatedItemsUpdate_itemToRemove = (RelatedItemsUpdate -> Maybe ItemIdentifier)
-> (RelatedItemsUpdate
    -> Maybe ItemIdentifier -> RelatedItemsUpdate)
-> Lens
     RelatedItemsUpdate
     RelatedItemsUpdate
     (Maybe ItemIdentifier)
     (Maybe ItemIdentifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelatedItemsUpdate' {Maybe ItemIdentifier
itemToRemove :: Maybe ItemIdentifier
$sel:itemToRemove:RelatedItemsUpdate' :: RelatedItemsUpdate -> Maybe ItemIdentifier
itemToRemove} -> Maybe ItemIdentifier
itemToRemove) (\s :: RelatedItemsUpdate
s@RelatedItemsUpdate' {} Maybe ItemIdentifier
a -> RelatedItemsUpdate
s {$sel:itemToRemove:RelatedItemsUpdate' :: Maybe ItemIdentifier
itemToRemove = Maybe ItemIdentifier
a} :: RelatedItemsUpdate)

-- | Details about the related item you\'re adding.
relatedItemsUpdate_itemToAdd :: Lens.Lens' RelatedItemsUpdate (Prelude.Maybe RelatedItem)
relatedItemsUpdate_itemToAdd :: (Maybe RelatedItem -> f (Maybe RelatedItem))
-> RelatedItemsUpdate -> f RelatedItemsUpdate
relatedItemsUpdate_itemToAdd = (RelatedItemsUpdate -> Maybe RelatedItem)
-> (RelatedItemsUpdate -> Maybe RelatedItem -> RelatedItemsUpdate)
-> Lens
     RelatedItemsUpdate
     RelatedItemsUpdate
     (Maybe RelatedItem)
     (Maybe RelatedItem)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelatedItemsUpdate' {Maybe RelatedItem
itemToAdd :: Maybe RelatedItem
$sel:itemToAdd:RelatedItemsUpdate' :: RelatedItemsUpdate -> Maybe RelatedItem
itemToAdd} -> Maybe RelatedItem
itemToAdd) (\s :: RelatedItemsUpdate
s@RelatedItemsUpdate' {} Maybe RelatedItem
a -> RelatedItemsUpdate
s {$sel:itemToAdd:RelatedItemsUpdate' :: Maybe RelatedItem
itemToAdd = Maybe RelatedItem
a} :: RelatedItemsUpdate)

instance Prelude.Hashable RelatedItemsUpdate

instance Prelude.NFData RelatedItemsUpdate

instance Core.ToJSON RelatedItemsUpdate where
  toJSON :: RelatedItemsUpdate -> Value
toJSON RelatedItemsUpdate' {Maybe ItemIdentifier
Maybe RelatedItem
itemToAdd :: Maybe RelatedItem
itemToRemove :: Maybe ItemIdentifier
$sel:itemToAdd:RelatedItemsUpdate' :: RelatedItemsUpdate -> Maybe RelatedItem
$sel:itemToRemove:RelatedItemsUpdate' :: RelatedItemsUpdate -> Maybe ItemIdentifier
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"itemToRemove" Text -> ItemIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ItemIdentifier -> Pair) -> Maybe ItemIdentifier -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ItemIdentifier
itemToRemove,
            (Text
"itemToAdd" Text -> RelatedItem -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RelatedItem -> Pair) -> Maybe RelatedItem -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RelatedItem
itemToAdd
          ]
      )