{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | Is either @null@, if no hooks invoke for the resource, or contains the
    -- number of hooks that will invoke for the resource.
    Change -> Maybe Natural
hookInvocationCount :: Prelude.Maybe Prelude.Natural,
    -- | 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
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]
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
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. 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:
--
-- 'hookInvocationCount', 'change_hookInvocationCount' - Is either @null@, if no hooks invoke for the resource, or contains the
-- number of hooks that will invoke for the resource.
--
-- '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'
    { $sel:hookInvocationCount:Change' :: Maybe Natural
hookInvocationCount = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceChange:Change' :: Maybe ResourceChange
resourceChange = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Change' :: Maybe ChangeType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Is either @null@, if no hooks invoke for the resource, or contains the
-- number of hooks that will invoke for the resource.
change_hookInvocationCount :: Lens.Lens' Change (Prelude.Maybe Prelude.Natural)
change_hookInvocationCount :: Lens' Change (Maybe Natural)
change_hookInvocationCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {Maybe Natural
hookInvocationCount :: Maybe Natural
$sel:hookInvocationCount:Change' :: Change -> Maybe Natural
hookInvocationCount} -> Maybe Natural
hookInvocationCount) (\s :: Change
s@Change' {} Maybe Natural
a -> Change
s {$sel:hookInvocationCount:Change' :: Maybe Natural
hookInvocationCount = Maybe Natural
a} :: Change)

-- | A @ResourceChange@ structure that describes the resource and action that
-- CloudFormation will perform.
change_resourceChange :: Lens.Lens' Change (Prelude.Maybe ResourceChange)
change_resourceChange :: Lens' Change (Maybe ResourceChange)
change_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 :: Lens' Change (Maybe ChangeType)
change_type = 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 Data.FromXML Change where
  parseXML :: [Node] -> Either String Change
parseXML [Node]
x =
    Maybe Natural -> Maybe ResourceChange -> Maybe ChangeType -> Change
Change'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"HookInvocationCount")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ResourceChange")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Type")

instance Prelude.Hashable Change where
  hashWithSalt :: Int -> Change -> Int
hashWithSalt Int
_salt Change' {Maybe Natural
Maybe ChangeType
Maybe ResourceChange
type' :: Maybe ChangeType
resourceChange :: Maybe ResourceChange
hookInvocationCount :: Maybe Natural
$sel:type':Change' :: Change -> Maybe ChangeType
$sel:resourceChange:Change' :: Change -> Maybe ResourceChange
$sel:hookInvocationCount:Change' :: Change -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
hookInvocationCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceChange
resourceChange
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChangeType
type'

instance Prelude.NFData Change where
  rnf :: Change -> ()
rnf Change' {Maybe Natural
Maybe ChangeType
Maybe ResourceChange
type' :: Maybe ChangeType
resourceChange :: Maybe ResourceChange
hookInvocationCount :: Maybe Natural
$sel:type':Change' :: Change -> Maybe ChangeType
$sel:resourceChange:Change' :: Change -> Maybe ResourceChange
$sel:hookInvocationCount:Change' :: Change -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
hookInvocationCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceChange
resourceChange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeType
type'