{-# 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.MarketplaceCatalog.Types.Change
-- 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.MarketplaceCatalog.Types.Change where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MarketplaceCatalog.Types.Entity
import qualified Amazonka.Prelude as Prelude

-- | An object that contains the @ChangeType@, @Details@, and @Entity@.
--
-- /See:/ 'newChange' smart constructor.
data Change = Change'
  { -- | Optional name for the change.
    Change -> Maybe Text
changeName :: Prelude.Maybe Prelude.Text,
    -- | Change types are single string values that describe your intention for
    -- the change. Each change type is unique for each @EntityType@ provided in
    -- the change\'s scope.
    Change -> Text
changeType :: Prelude.Text,
    -- | The entity to be changed.
    Change -> Entity
entity :: Entity,
    -- | This object contains details specific to the change type of the
    -- requested change.
    Change -> Text
details :: Prelude.Text
  }
  deriving (Change -> Change -> Bool
(Change -> Change -> Bool)
-> (Change -> Change -> Bool) -> Eq Change
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Change -> Change -> Bool
$c/= :: Change -> Change -> Bool
== :: Change -> Change -> Bool
$c== :: Change -> Change -> Bool
Prelude.Eq, ReadPrec [Change]
ReadPrec Change
Int -> ReadS Change
ReadS [Change]
(Int -> ReadS Change)
-> ReadS [Change]
-> ReadPrec Change
-> ReadPrec [Change]
-> Read Change
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Change]
$creadListPrec :: ReadPrec [Change]
readPrec :: ReadPrec Change
$creadPrec :: ReadPrec Change
readList :: ReadS [Change]
$creadList :: ReadS [Change]
readsPrec :: Int -> ReadS Change
$creadsPrec :: Int -> ReadS Change
Prelude.Read, Int -> Change -> ShowS
[Change] -> ShowS
Change -> String
(Int -> Change -> ShowS)
-> (Change -> String) -> ([Change] -> ShowS) -> Show Change
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Change] -> ShowS
$cshowList :: [Change] -> ShowS
show :: Change -> String
$cshow :: Change -> String
showsPrec :: Int -> Change -> ShowS
$cshowsPrec :: Int -> Change -> ShowS
Prelude.Show, (forall x. Change -> Rep Change x)
-> (forall x. Rep Change x -> Change) -> Generic Change
forall x. Rep Change x -> Change
forall x. Change -> Rep Change x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Change x -> Change
$cfrom :: forall x. Change -> Rep Change x
Prelude.Generic)

-- |
-- Create a value of 'Change' 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:
--
-- 'changeName', 'change_changeName' - Optional name for the change.
--
-- 'changeType', 'change_changeType' - Change types are single string values that describe your intention for
-- the change. Each change type is unique for each @EntityType@ provided in
-- the change\'s scope.
--
-- 'entity', 'change_entity' - The entity to be changed.
--
-- 'details', 'change_details' - This object contains details specific to the change type of the
-- requested change.
newChange ::
  -- | 'changeType'
  Prelude.Text ->
  -- | 'entity'
  Entity ->
  -- | 'details'
  Prelude.Text ->
  Change
newChange :: Text -> Entity -> Text -> Change
newChange Text
pChangeType_ Entity
pEntity_ Text
pDetails_ =
  Change' :: Maybe Text -> Text -> Entity -> Text -> Change
Change'
    { $sel:changeName:Change' :: Maybe Text
changeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:changeType:Change' :: Text
changeType = Text
pChangeType_,
      $sel:entity:Change' :: Entity
entity = Entity
pEntity_,
      $sel:details:Change' :: Text
details = Text
pDetails_
    }

-- | Optional name for the change.
change_changeName :: Lens.Lens' Change (Prelude.Maybe Prelude.Text)
change_changeName :: (Maybe Text -> f (Maybe Text)) -> Change -> f Change
change_changeName = (Change -> Maybe Text)
-> (Change -> Maybe Text -> Change)
-> Lens Change Change (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Maybe Text
changeName :: Maybe Text
$sel:changeName:Change' :: Change -> Maybe Text
changeName} -> Maybe Text
changeName) (\s :: Change
s@Change' {} Maybe Text
a -> Change
s {$sel:changeName:Change' :: Maybe Text
changeName = Maybe Text
a} :: Change)

-- | Change types are single string values that describe your intention for
-- the change. Each change type is unique for each @EntityType@ provided in
-- the change\'s scope.
change_changeType :: Lens.Lens' Change Prelude.Text
change_changeType :: (Text -> f Text) -> Change -> f Change
change_changeType = (Change -> Text)
-> (Change -> Text -> Change) -> Lens Change Change Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Text
changeType :: Text
$sel:changeType:Change' :: Change -> Text
changeType} -> Text
changeType) (\s :: Change
s@Change' {} Text
a -> Change
s {$sel:changeType:Change' :: Text
changeType = Text
a} :: Change)

-- | The entity to be changed.
change_entity :: Lens.Lens' Change Entity
change_entity :: (Entity -> f Entity) -> Change -> f Change
change_entity = (Change -> Entity)
-> (Change -> Entity -> Change) -> Lens Change Change Entity Entity
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Entity
entity :: Entity
$sel:entity:Change' :: Change -> Entity
entity} -> Entity
entity) (\s :: Change
s@Change' {} Entity
a -> Change
s {$sel:entity:Change' :: Entity
entity = Entity
a} :: Change)

-- | This object contains details specific to the change type of the
-- requested change.
change_details :: Lens.Lens' Change Prelude.Text
change_details :: (Text -> f Text) -> Change -> f Change
change_details = (Change -> Text)
-> (Change -> Text -> Change) -> Lens Change Change Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Text
details :: Text
$sel:details:Change' :: Change -> Text
details} -> Text
details) (\s :: Change
s@Change' {} Text
a -> Change
s {$sel:details:Change' :: Text
details = Text
a} :: Change)

instance Prelude.Hashable Change

instance Prelude.NFData Change

instance Core.ToJSON Change where
  toJSON :: Change -> Value
toJSON Change' {Maybe Text
Text
Entity
details :: Text
entity :: Entity
changeType :: Text
changeName :: Maybe Text
$sel:details:Change' :: Change -> Text
$sel:entity:Change' :: Change -> Entity
$sel:changeType:Change' :: Change -> Text
$sel:changeName:Change' :: Change -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ChangeName" 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
changeName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ChangeType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
changeType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Entity" Text -> Entity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Entity
entity),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Details" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
details)
          ]
      )