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

import Amazonka.CloudFormation.Types.DifferenceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 is 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
(PropertyDifference -> PropertyDifference -> Bool)
-> (PropertyDifference -> PropertyDifference -> Bool)
-> Eq PropertyDifference
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]
(Int -> ReadS PropertyDifference)
-> ReadS [PropertyDifference]
-> ReadPrec PropertyDifference
-> ReadPrec [PropertyDifference]
-> Read 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
(Int -> PropertyDifference -> ShowS)
-> (PropertyDifference -> String)
-> ([PropertyDifference] -> ShowS)
-> Show PropertyDifference
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. PropertyDifference -> Rep PropertyDifference x)
-> (forall x. Rep PropertyDifference x -> PropertyDifference)
-> Generic PropertyDifference
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 is 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' :: Text -> Text -> Text -> DifferenceType -> PropertyDifference
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 :: (Text -> f Text) -> PropertyDifference -> f PropertyDifference
propertyDifference_propertyPath = (PropertyDifference -> Text)
-> (PropertyDifference -> Text -> PropertyDifference)
-> Lens PropertyDifference PropertyDifference Text Text
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 :: (Text -> f Text) -> PropertyDifference -> f PropertyDifference
propertyDifference_expectedValue = (PropertyDifference -> Text)
-> (PropertyDifference -> Text -> PropertyDifference)
-> Lens PropertyDifference PropertyDifference Text Text
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 :: (Text -> f Text) -> PropertyDifference -> f PropertyDifference
propertyDifference_actualValue = (PropertyDifference -> Text)
-> (PropertyDifference -> Text -> PropertyDifference)
-> Lens PropertyDifference PropertyDifference Text Text
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 is 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 :: (DifferenceType -> f DifferenceType)
-> PropertyDifference -> f PropertyDifference
propertyDifference_differenceType = (PropertyDifference -> DifferenceType)
-> (PropertyDifference -> DifferenceType -> PropertyDifference)
-> Lens
     PropertyDifference PropertyDifference DifferenceType 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 Core.FromXML PropertyDifference where
  parseXML :: [Node] -> Either String PropertyDifference
parseXML [Node]
x =
    Text -> Text -> Text -> DifferenceType -> PropertyDifference
PropertyDifference'
      (Text -> Text -> Text -> DifferenceType -> PropertyDifference)
-> Either String Text
-> Either
     String (Text -> Text -> DifferenceType -> PropertyDifference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"PropertyPath")
      Either
  String (Text -> Text -> DifferenceType -> PropertyDifference)
-> Either String Text
-> Either String (Text -> DifferenceType -> PropertyDifference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ExpectedValue")
      Either String (Text -> DifferenceType -> PropertyDifference)
-> Either String Text
-> Either String (DifferenceType -> PropertyDifference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ActualValue")
      Either String (DifferenceType -> PropertyDifference)
-> Either String DifferenceType -> Either String PropertyDifference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String DifferenceType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DifferenceType")

instance Prelude.Hashable PropertyDifference

instance Prelude.NFData PropertyDifference