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

import Amazonka.CloudFormation.Types.ChangeType
import Amazonka.CloudFormation.Types.ResourceChange
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The @Change@ structure describes the changes CloudFormation will perform
-- if you execute the change set.
--
-- /See:/ 'newChange' smart constructor.
data Change = Change'
  { -- | A @ResourceChange@ structure that describes the resource and action that
    -- CloudFormation will perform.
    Change -> Maybe ResourceChange
resourceChange :: Prelude.Maybe ResourceChange,
    -- | The type of entity that CloudFormation changes. Currently, the only
    -- entity type is @Resource@.
    Change -> Maybe ChangeType
type' :: Prelude.Maybe ChangeType
  }
  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:
--
-- 'resourceChange', 'change_resourceChange' - A @ResourceChange@ structure that describes the resource and action that
-- CloudFormation will perform.
--
-- 'type'', 'change_type' - The type of entity that CloudFormation changes. Currently, the only
-- entity type is @Resource@.
newChange ::
  Change
newChange :: Change
newChange =
  Change' :: Maybe ResourceChange -> Maybe ChangeType -> Change
Change'
    { $sel:resourceChange:Change' :: Maybe ResourceChange
resourceChange = Maybe ResourceChange
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Change' :: Maybe ChangeType
type' = Maybe ChangeType
forall a. Maybe a
Prelude.Nothing
    }

-- | A @ResourceChange@ structure that describes the resource and action that
-- CloudFormation will perform.
change_resourceChange :: Lens.Lens' Change (Prelude.Maybe ResourceChange)
change_resourceChange :: (Maybe ResourceChange -> f (Maybe ResourceChange))
-> Change -> f Change
change_resourceChange = (Change -> Maybe ResourceChange)
-> (Change -> Maybe ResourceChange -> Change)
-> Lens Change Change (Maybe ResourceChange) (Maybe ResourceChange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Maybe ResourceChange
resourceChange :: Maybe ResourceChange
$sel:resourceChange:Change' :: Change -> Maybe ResourceChange
resourceChange} -> Maybe ResourceChange
resourceChange) (\s :: Change
s@Change' {} Maybe ResourceChange
a -> Change
s {$sel:resourceChange:Change' :: Maybe ResourceChange
resourceChange = Maybe ResourceChange
a} :: Change)

-- | The type of entity that CloudFormation changes. Currently, the only
-- entity type is @Resource@.
change_type :: Lens.Lens' Change (Prelude.Maybe ChangeType)
change_type :: (Maybe ChangeType -> f (Maybe ChangeType)) -> Change -> f Change
change_type = (Change -> Maybe ChangeType)
-> (Change -> Maybe ChangeType -> Change)
-> Lens Change Change (Maybe ChangeType) (Maybe ChangeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Maybe ChangeType
type' :: Maybe ChangeType
$sel:type':Change' :: Change -> Maybe ChangeType
type'} -> Maybe ChangeType
type') (\s :: Change
s@Change' {} Maybe ChangeType
a -> Change
s {$sel:type':Change' :: Maybe ChangeType
type' = Maybe ChangeType
a} :: Change)

instance Core.FromXML Change where
  parseXML :: [Node] -> Either String Change
parseXML [Node]
x =
    Maybe ResourceChange -> Maybe ChangeType -> Change
Change'
      (Maybe ResourceChange -> Maybe ChangeType -> Change)
-> Either String (Maybe ResourceChange)
-> Either String (Maybe ChangeType -> Change)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ResourceChange)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResourceChange")
      Either String (Maybe ChangeType -> Change)
-> Either String (Maybe ChangeType) -> Either String Change
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ChangeType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Type")

instance Prelude.Hashable Change

instance Prelude.NFData Change