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

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

-- | This object is a container for common summary information about the
-- change. The summary doesn\'t contain the whole change structure.
--
-- /See:/ 'newChangeSummary' smart constructor.
data ChangeSummary = ChangeSummary'
  { -- | Optional name for the change.
    ChangeSummary -> Maybe Text
changeName :: Prelude.Maybe Prelude.Text,
    -- | This object contains details specific to the change type of the
    -- requested change.
    ChangeSummary -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | An array of @ErrorDetail@ objects associated with the change.
    ChangeSummary -> Maybe [ErrorDetail]
errorDetailList :: Prelude.Maybe [ErrorDetail],
    -- | The entity to be changed.
    ChangeSummary -> Maybe Entity
entity :: Prelude.Maybe Entity,
    -- | The type of the change.
    ChangeSummary -> Maybe Text
changeType :: Prelude.Maybe Prelude.Text
  }
  deriving (ChangeSummary -> ChangeSummary -> Bool
(ChangeSummary -> ChangeSummary -> Bool)
-> (ChangeSummary -> ChangeSummary -> Bool) -> Eq ChangeSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangeSummary -> ChangeSummary -> Bool
$c/= :: ChangeSummary -> ChangeSummary -> Bool
== :: ChangeSummary -> ChangeSummary -> Bool
$c== :: ChangeSummary -> ChangeSummary -> Bool
Prelude.Eq, ReadPrec [ChangeSummary]
ReadPrec ChangeSummary
Int -> ReadS ChangeSummary
ReadS [ChangeSummary]
(Int -> ReadS ChangeSummary)
-> ReadS [ChangeSummary]
-> ReadPrec ChangeSummary
-> ReadPrec [ChangeSummary]
-> Read ChangeSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangeSummary]
$creadListPrec :: ReadPrec [ChangeSummary]
readPrec :: ReadPrec ChangeSummary
$creadPrec :: ReadPrec ChangeSummary
readList :: ReadS [ChangeSummary]
$creadList :: ReadS [ChangeSummary]
readsPrec :: Int -> ReadS ChangeSummary
$creadsPrec :: Int -> ReadS ChangeSummary
Prelude.Read, Int -> ChangeSummary -> ShowS
[ChangeSummary] -> ShowS
ChangeSummary -> String
(Int -> ChangeSummary -> ShowS)
-> (ChangeSummary -> String)
-> ([ChangeSummary] -> ShowS)
-> Show ChangeSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangeSummary] -> ShowS
$cshowList :: [ChangeSummary] -> ShowS
show :: ChangeSummary -> String
$cshow :: ChangeSummary -> String
showsPrec :: Int -> ChangeSummary -> ShowS
$cshowsPrec :: Int -> ChangeSummary -> ShowS
Prelude.Show, (forall x. ChangeSummary -> Rep ChangeSummary x)
-> (forall x. Rep ChangeSummary x -> ChangeSummary)
-> Generic ChangeSummary
forall x. Rep ChangeSummary x -> ChangeSummary
forall x. ChangeSummary -> Rep ChangeSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChangeSummary x -> ChangeSummary
$cfrom :: forall x. ChangeSummary -> Rep ChangeSummary x
Prelude.Generic)

-- |
-- Create a value of 'ChangeSummary' 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', 'changeSummary_changeName' - Optional name for the change.
--
-- 'details', 'changeSummary_details' - This object contains details specific to the change type of the
-- requested change.
--
-- 'errorDetailList', 'changeSummary_errorDetailList' - An array of @ErrorDetail@ objects associated with the change.
--
-- 'entity', 'changeSummary_entity' - The entity to be changed.
--
-- 'changeType', 'changeSummary_changeType' - The type of the change.
newChangeSummary ::
  ChangeSummary
newChangeSummary :: ChangeSummary
newChangeSummary =
  ChangeSummary' :: Maybe Text
-> Maybe Text
-> Maybe [ErrorDetail]
-> Maybe Entity
-> Maybe Text
-> ChangeSummary
ChangeSummary'
    { $sel:changeName:ChangeSummary' :: Maybe Text
changeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:details:ChangeSummary' :: Maybe Text
details = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorDetailList:ChangeSummary' :: Maybe [ErrorDetail]
errorDetailList = Maybe [ErrorDetail]
forall a. Maybe a
Prelude.Nothing,
      $sel:entity:ChangeSummary' :: Maybe Entity
entity = Maybe Entity
forall a. Maybe a
Prelude.Nothing,
      $sel:changeType:ChangeSummary' :: Maybe Text
changeType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | An array of @ErrorDetail@ objects associated with the change.
changeSummary_errorDetailList :: Lens.Lens' ChangeSummary (Prelude.Maybe [ErrorDetail])
changeSummary_errorDetailList :: (Maybe [ErrorDetail] -> f (Maybe [ErrorDetail]))
-> ChangeSummary -> f ChangeSummary
changeSummary_errorDetailList = (ChangeSummary -> Maybe [ErrorDetail])
-> (ChangeSummary -> Maybe [ErrorDetail] -> ChangeSummary)
-> Lens
     ChangeSummary
     ChangeSummary
     (Maybe [ErrorDetail])
     (Maybe [ErrorDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangeSummary' {Maybe [ErrorDetail]
errorDetailList :: Maybe [ErrorDetail]
$sel:errorDetailList:ChangeSummary' :: ChangeSummary -> Maybe [ErrorDetail]
errorDetailList} -> Maybe [ErrorDetail]
errorDetailList) (\s :: ChangeSummary
s@ChangeSummary' {} Maybe [ErrorDetail]
a -> ChangeSummary
s {$sel:errorDetailList:ChangeSummary' :: Maybe [ErrorDetail]
errorDetailList = Maybe [ErrorDetail]
a} :: ChangeSummary) ((Maybe [ErrorDetail] -> f (Maybe [ErrorDetail]))
 -> ChangeSummary -> f ChangeSummary)
-> ((Maybe [ErrorDetail] -> f (Maybe [ErrorDetail]))
    -> Maybe [ErrorDetail] -> f (Maybe [ErrorDetail]))
-> (Maybe [ErrorDetail] -> f (Maybe [ErrorDetail]))
-> ChangeSummary
-> f ChangeSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ErrorDetail] [ErrorDetail] [ErrorDetail] [ErrorDetail]
-> Iso
     (Maybe [ErrorDetail])
     (Maybe [ErrorDetail])
     (Maybe [ErrorDetail])
     (Maybe [ErrorDetail])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [ErrorDetail] [ErrorDetail] [ErrorDetail] [ErrorDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The type of the change.
changeSummary_changeType :: Lens.Lens' ChangeSummary (Prelude.Maybe Prelude.Text)
changeSummary_changeType :: (Maybe Text -> f (Maybe Text)) -> ChangeSummary -> f ChangeSummary
changeSummary_changeType = (ChangeSummary -> Maybe Text)
-> (ChangeSummary -> Maybe Text -> ChangeSummary)
-> Lens ChangeSummary ChangeSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangeSummary' {Maybe Text
changeType :: Maybe Text
$sel:changeType:ChangeSummary' :: ChangeSummary -> Maybe Text
changeType} -> Maybe Text
changeType) (\s :: ChangeSummary
s@ChangeSummary' {} Maybe Text
a -> ChangeSummary
s {$sel:changeType:ChangeSummary' :: Maybe Text
changeType = Maybe Text
a} :: ChangeSummary)

instance Core.FromJSON ChangeSummary where
  parseJSON :: Value -> Parser ChangeSummary
parseJSON =
    String
-> (Object -> Parser ChangeSummary)
-> Value
-> Parser ChangeSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChangeSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [ErrorDetail]
-> Maybe Entity
-> Maybe Text
-> ChangeSummary
ChangeSummary'
            (Maybe Text
 -> Maybe Text
 -> Maybe [ErrorDetail]
 -> Maybe Entity
 -> Maybe Text
 -> ChangeSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [ErrorDetail]
      -> Maybe Entity
      -> Maybe Text
      -> ChangeSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ChangeName")
            Parser
  (Maybe Text
   -> Maybe [ErrorDetail]
   -> Maybe Entity
   -> Maybe Text
   -> ChangeSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe [ErrorDetail]
      -> Maybe Entity -> Maybe Text -> ChangeSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Details")
            Parser
  (Maybe [ErrorDetail]
   -> Maybe Entity -> Maybe Text -> ChangeSummary)
-> Parser (Maybe [ErrorDetail])
-> Parser (Maybe Entity -> Maybe Text -> ChangeSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ErrorDetail]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorDetailList"
                            Parser (Maybe (Maybe [ErrorDetail]))
-> Maybe [ErrorDetail] -> Parser (Maybe [ErrorDetail])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ErrorDetail]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Entity -> Maybe Text -> ChangeSummary)
-> Parser (Maybe Entity) -> Parser (Maybe Text -> ChangeSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Entity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Entity")
            Parser (Maybe Text -> ChangeSummary)
-> Parser (Maybe Text) -> Parser ChangeSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ChangeType")
      )

instance Prelude.Hashable ChangeSummary

instance Prelude.NFData ChangeSummary