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

import Amazonka.CloudFormation.Types.DifferenceType
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

-- | Information about a resource property whose actual value differs from
-- its expected value, as defined in the stack template and any values
-- specified as template parameters. These will be present only for
-- resources whose @StackResourceDriftStatus@ is @MODIFIED@. For more
-- information, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html Detecting Unregulated Configuration Changes to Stacks and Resources>.
--
-- /See:/ 'newPropertyDifference' smart constructor.
data PropertyDifference = PropertyDifference'
  { -- | The fully-qualified path to the resource property.
    PropertyDifference -> Text
propertyPath :: Prelude.Text,
    -- | The expected property value of the resource property, as defined in the
    -- stack template and any values specified as template parameters.
    PropertyDifference -> Text
expectedValue :: Prelude.Text,
    -- | The actual property value of the resource property.
    PropertyDifference -> Text
actualValue :: Prelude.Text,
    -- | The type of property difference.
    --
    -- -   @ADD@: A value has been added to a resource property that\'s an
    --     array or list data type.
    --
    -- -   @REMOVE@: The property has been removed from the current resource
    --     configuration.
    --
    -- -   @NOT_EQUAL@: The current property value differs from its expected
    --     value (as defined in the stack template and any values specified as
    --     template parameters).
    PropertyDifference -> DifferenceType
differenceType :: DifferenceType
  }
  deriving (PropertyDifference -> PropertyDifference -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyDifference -> PropertyDifference -> Bool
$c/= :: PropertyDifference -> PropertyDifference -> Bool
== :: PropertyDifference -> PropertyDifference -> Bool
$c== :: PropertyDifference -> PropertyDifference -> Bool
Prelude.Eq, ReadPrec [PropertyDifference]
ReadPrec PropertyDifference
Int -> ReadS PropertyDifference
ReadS [PropertyDifference]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyDifference]
$creadListPrec :: ReadPrec [PropertyDifference]
readPrec :: ReadPrec PropertyDifference
$creadPrec :: ReadPrec PropertyDifference
readList :: ReadS [PropertyDifference]
$creadList :: ReadS [PropertyDifference]
readsPrec :: Int -> ReadS PropertyDifference
$creadsPrec :: Int -> ReadS PropertyDifference
Prelude.Read, Int -> PropertyDifference -> ShowS
[PropertyDifference] -> ShowS
PropertyDifference -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyDifference] -> ShowS
$cshowList :: [PropertyDifference] -> ShowS
show :: PropertyDifference -> String
$cshow :: PropertyDifference -> String
showsPrec :: Int -> PropertyDifference -> ShowS
$cshowsPrec :: Int -> PropertyDifference -> ShowS
Prelude.Show, forall x. Rep PropertyDifference x -> PropertyDifference
forall x. PropertyDifference -> Rep PropertyDifference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyDifference x -> PropertyDifference
$cfrom :: forall x. PropertyDifference -> Rep PropertyDifference x
Prelude.Generic)

-- |
-- Create a value of 'PropertyDifference' 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:
--
-- 'propertyPath', 'propertyDifference_propertyPath' - The fully-qualified path to the resource property.
--
-- 'expectedValue', 'propertyDifference_expectedValue' - The expected property value of the resource property, as defined in the
-- stack template and any values specified as template parameters.
--
-- 'actualValue', 'propertyDifference_actualValue' - The actual property value of the resource property.
--
-- 'differenceType', 'propertyDifference_differenceType' - The type of property difference.
--
-- -   @ADD@: A value has been added to a resource property that\'s an
--     array or list data type.
--
-- -   @REMOVE@: The property has been removed from the current resource
--     configuration.
--
-- -   @NOT_EQUAL@: The current property value differs from its expected
--     value (as defined in the stack template and any values specified as
--     template parameters).
newPropertyDifference ::
  -- | 'propertyPath'
  Prelude.Text ->
  -- | 'expectedValue'
  Prelude.Text ->
  -- | 'actualValue'
  Prelude.Text ->
  -- | 'differenceType'
  DifferenceType ->
  PropertyDifference
newPropertyDifference :: Text -> Text -> Text -> DifferenceType -> PropertyDifference
newPropertyDifference
  Text
pPropertyPath_
  Text
pExpectedValue_
  Text
pActualValue_
  DifferenceType
pDifferenceType_ =
    PropertyDifference'
      { $sel:propertyPath:PropertyDifference' :: Text
propertyPath = Text
pPropertyPath_,
        $sel:expectedValue:PropertyDifference' :: Text
expectedValue = Text
pExpectedValue_,
        $sel:actualValue:PropertyDifference' :: Text
actualValue = Text
pActualValue_,
        $sel:differenceType:PropertyDifference' :: DifferenceType
differenceType = DifferenceType
pDifferenceType_
      }

-- | The fully-qualified path to the resource property.
propertyDifference_propertyPath :: Lens.Lens' PropertyDifference Prelude.Text
propertyDifference_propertyPath :: Lens' PropertyDifference Text
propertyDifference_propertyPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyDifference' {Text
propertyPath :: Text
$sel:propertyPath:PropertyDifference' :: PropertyDifference -> Text
propertyPath} -> Text
propertyPath) (\s :: PropertyDifference
s@PropertyDifference' {} Text
a -> PropertyDifference
s {$sel:propertyPath:PropertyDifference' :: Text
propertyPath = Text
a} :: PropertyDifference)

-- | The expected property value of the resource property, as defined in the
-- stack template and any values specified as template parameters.
propertyDifference_expectedValue :: Lens.Lens' PropertyDifference Prelude.Text
propertyDifference_expectedValue :: Lens' PropertyDifference Text
propertyDifference_expectedValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyDifference' {Text
expectedValue :: Text
$sel:expectedValue:PropertyDifference' :: PropertyDifference -> Text
expectedValue} -> Text
expectedValue) (\s :: PropertyDifference
s@PropertyDifference' {} Text
a -> PropertyDifference
s {$sel:expectedValue:PropertyDifference' :: Text
expectedValue = Text
a} :: PropertyDifference)

-- | The actual property value of the resource property.
propertyDifference_actualValue :: Lens.Lens' PropertyDifference Prelude.Text
propertyDifference_actualValue :: Lens' PropertyDifference Text
propertyDifference_actualValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyDifference' {Text
actualValue :: Text
$sel:actualValue:PropertyDifference' :: PropertyDifference -> Text
actualValue} -> Text
actualValue) (\s :: PropertyDifference
s@PropertyDifference' {} Text
a -> PropertyDifference
s {$sel:actualValue:PropertyDifference' :: Text
actualValue = Text
a} :: PropertyDifference)

-- | The type of property difference.
--
-- -   @ADD@: A value has been added to a resource property that\'s an
--     array or list data type.
--
-- -   @REMOVE@: The property has been removed from the current resource
--     configuration.
--
-- -   @NOT_EQUAL@: The current property value differs from its expected
--     value (as defined in the stack template and any values specified as
--     template parameters).
propertyDifference_differenceType :: Lens.Lens' PropertyDifference DifferenceType
propertyDifference_differenceType :: Lens' PropertyDifference DifferenceType
propertyDifference_differenceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyDifference' {DifferenceType
differenceType :: DifferenceType
$sel:differenceType:PropertyDifference' :: PropertyDifference -> DifferenceType
differenceType} -> DifferenceType
differenceType) (\s :: PropertyDifference
s@PropertyDifference' {} DifferenceType
a -> PropertyDifference
s {$sel:differenceType:PropertyDifference' :: DifferenceType
differenceType = DifferenceType
a} :: PropertyDifference)

instance Data.FromXML PropertyDifference where
  parseXML :: [Node] -> Either String PropertyDifference
parseXML [Node]
x =
    Text -> Text -> Text -> DifferenceType -> PropertyDifference
PropertyDifference'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"PropertyPath")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ExpectedValue")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ActualValue")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"DifferenceType")

instance Prelude.Hashable PropertyDifference where
  hashWithSalt :: Int -> PropertyDifference -> Int
hashWithSalt Int
_salt PropertyDifference' {Text
DifferenceType
differenceType :: DifferenceType
actualValue :: Text
expectedValue :: Text
propertyPath :: Text
$sel:differenceType:PropertyDifference' :: PropertyDifference -> DifferenceType
$sel:actualValue:PropertyDifference' :: PropertyDifference -> Text
$sel:expectedValue:PropertyDifference' :: PropertyDifference -> Text
$sel:propertyPath:PropertyDifference' :: PropertyDifference -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
propertyPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
expectedValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
actualValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DifferenceType
differenceType

instance Prelude.NFData PropertyDifference where
  rnf :: PropertyDifference -> ()
rnf PropertyDifference' {Text
DifferenceType
differenceType :: DifferenceType
actualValue :: Text
expectedValue :: Text
propertyPath :: Text
$sel:differenceType:PropertyDifference' :: PropertyDifference -> DifferenceType
$sel:actualValue:PropertyDifference' :: PropertyDifference -> Text
$sel:expectedValue:PropertyDifference' :: PropertyDifference -> Text
$sel:propertyPath:PropertyDifference' :: PropertyDifference -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
propertyPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
expectedValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
actualValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DifferenceType
differenceType