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

import Amazonka.CloudFormation.Types.RequiresRecreation
import Amazonka.CloudFormation.Types.ResourceAttribute
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 field that CloudFormation will change, such as the name of a
-- resource\'s property, and whether the resource will be recreated.
--
-- /See:/ 'newResourceTargetDefinition' smart constructor.
data ResourceTargetDefinition = ResourceTargetDefinition'
  { -- | Indicates which resource attribute is triggering this update, such as a
    -- change in the resource attribute\'s @Metadata@, @Properties@, or @Tags@.
    ResourceTargetDefinition -> Maybe ResourceAttribute
attribute :: Prelude.Maybe ResourceAttribute,
    -- | If the @Attribute@ value is @Properties@, the name of the property. For
    -- all other attributes, the value is null.
    ResourceTargetDefinition -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | If the @Attribute@ value is @Properties@, indicates whether a change to
    -- this property causes the resource to be recreated. The value can be
    -- @Never@, @Always@, or @Conditionally@. To determine the conditions for a
    -- @Conditionally@ recreation, see the update behavior for that
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html property>
    -- in the CloudFormation User Guide.
    ResourceTargetDefinition -> Maybe RequiresRecreation
requiresRecreation :: Prelude.Maybe RequiresRecreation
  }
  deriving (ResourceTargetDefinition -> ResourceTargetDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceTargetDefinition -> ResourceTargetDefinition -> Bool
$c/= :: ResourceTargetDefinition -> ResourceTargetDefinition -> Bool
== :: ResourceTargetDefinition -> ResourceTargetDefinition -> Bool
$c== :: ResourceTargetDefinition -> ResourceTargetDefinition -> Bool
Prelude.Eq, ReadPrec [ResourceTargetDefinition]
ReadPrec ResourceTargetDefinition
Int -> ReadS ResourceTargetDefinition
ReadS [ResourceTargetDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceTargetDefinition]
$creadListPrec :: ReadPrec [ResourceTargetDefinition]
readPrec :: ReadPrec ResourceTargetDefinition
$creadPrec :: ReadPrec ResourceTargetDefinition
readList :: ReadS [ResourceTargetDefinition]
$creadList :: ReadS [ResourceTargetDefinition]
readsPrec :: Int -> ReadS ResourceTargetDefinition
$creadsPrec :: Int -> ReadS ResourceTargetDefinition
Prelude.Read, Int -> ResourceTargetDefinition -> ShowS
[ResourceTargetDefinition] -> ShowS
ResourceTargetDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceTargetDefinition] -> ShowS
$cshowList :: [ResourceTargetDefinition] -> ShowS
show :: ResourceTargetDefinition -> String
$cshow :: ResourceTargetDefinition -> String
showsPrec :: Int -> ResourceTargetDefinition -> ShowS
$cshowsPrec :: Int -> ResourceTargetDefinition -> ShowS
Prelude.Show, forall x.
Rep ResourceTargetDefinition x -> ResourceTargetDefinition
forall x.
ResourceTargetDefinition -> Rep ResourceTargetDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResourceTargetDefinition x -> ResourceTargetDefinition
$cfrom :: forall x.
ResourceTargetDefinition -> Rep ResourceTargetDefinition x
Prelude.Generic)

-- |
-- Create a value of 'ResourceTargetDefinition' 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:
--
-- 'attribute', 'resourceTargetDefinition_attribute' - Indicates which resource attribute is triggering this update, such as a
-- change in the resource attribute\'s @Metadata@, @Properties@, or @Tags@.
--
-- 'name', 'resourceTargetDefinition_name' - If the @Attribute@ value is @Properties@, the name of the property. For
-- all other attributes, the value is null.
--
-- 'requiresRecreation', 'resourceTargetDefinition_requiresRecreation' - If the @Attribute@ value is @Properties@, indicates whether a change to
-- this property causes the resource to be recreated. The value can be
-- @Never@, @Always@, or @Conditionally@. To determine the conditions for a
-- @Conditionally@ recreation, see the update behavior for that
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html property>
-- in the CloudFormation User Guide.
newResourceTargetDefinition ::
  ResourceTargetDefinition
newResourceTargetDefinition :: ResourceTargetDefinition
newResourceTargetDefinition =
  ResourceTargetDefinition'
    { $sel:attribute:ResourceTargetDefinition' :: Maybe ResourceAttribute
attribute =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceTargetDefinition' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:requiresRecreation:ResourceTargetDefinition' :: Maybe RequiresRecreation
requiresRecreation = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates which resource attribute is triggering this update, such as a
-- change in the resource attribute\'s @Metadata@, @Properties@, or @Tags@.
resourceTargetDefinition_attribute :: Lens.Lens' ResourceTargetDefinition (Prelude.Maybe ResourceAttribute)
resourceTargetDefinition_attribute :: Lens' ResourceTargetDefinition (Maybe ResourceAttribute)
resourceTargetDefinition_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTargetDefinition' {Maybe ResourceAttribute
attribute :: Maybe ResourceAttribute
$sel:attribute:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe ResourceAttribute
attribute} -> Maybe ResourceAttribute
attribute) (\s :: ResourceTargetDefinition
s@ResourceTargetDefinition' {} Maybe ResourceAttribute
a -> ResourceTargetDefinition
s {$sel:attribute:ResourceTargetDefinition' :: Maybe ResourceAttribute
attribute = Maybe ResourceAttribute
a} :: ResourceTargetDefinition)

-- | If the @Attribute@ value is @Properties@, the name of the property. For
-- all other attributes, the value is null.
resourceTargetDefinition_name :: Lens.Lens' ResourceTargetDefinition (Prelude.Maybe Prelude.Text)
resourceTargetDefinition_name :: Lens' ResourceTargetDefinition (Maybe Text)
resourceTargetDefinition_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTargetDefinition' {Maybe Text
name :: Maybe Text
$sel:name:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe Text
name} -> Maybe Text
name) (\s :: ResourceTargetDefinition
s@ResourceTargetDefinition' {} Maybe Text
a -> ResourceTargetDefinition
s {$sel:name:ResourceTargetDefinition' :: Maybe Text
name = Maybe Text
a} :: ResourceTargetDefinition)

-- | If the @Attribute@ value is @Properties@, indicates whether a change to
-- this property causes the resource to be recreated. The value can be
-- @Never@, @Always@, or @Conditionally@. To determine the conditions for a
-- @Conditionally@ recreation, see the update behavior for that
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html property>
-- in the CloudFormation User Guide.
resourceTargetDefinition_requiresRecreation :: Lens.Lens' ResourceTargetDefinition (Prelude.Maybe RequiresRecreation)
resourceTargetDefinition_requiresRecreation :: Lens' ResourceTargetDefinition (Maybe RequiresRecreation)
resourceTargetDefinition_requiresRecreation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTargetDefinition' {Maybe RequiresRecreation
requiresRecreation :: Maybe RequiresRecreation
$sel:requiresRecreation:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe RequiresRecreation
requiresRecreation} -> Maybe RequiresRecreation
requiresRecreation) (\s :: ResourceTargetDefinition
s@ResourceTargetDefinition' {} Maybe RequiresRecreation
a -> ResourceTargetDefinition
s {$sel:requiresRecreation:ResourceTargetDefinition' :: Maybe RequiresRecreation
requiresRecreation = Maybe RequiresRecreation
a} :: ResourceTargetDefinition)

instance Data.FromXML ResourceTargetDefinition where
  parseXML :: [Node] -> Either String ResourceTargetDefinition
parseXML [Node]
x =
    Maybe ResourceAttribute
-> Maybe Text
-> Maybe RequiresRecreation
-> ResourceTargetDefinition
ResourceTargetDefinition'
      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
"Attribute")
      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
"Name")
      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
"RequiresRecreation")

instance Prelude.Hashable ResourceTargetDefinition where
  hashWithSalt :: Int -> ResourceTargetDefinition -> Int
hashWithSalt Int
_salt ResourceTargetDefinition' {Maybe Text
Maybe RequiresRecreation
Maybe ResourceAttribute
requiresRecreation :: Maybe RequiresRecreation
name :: Maybe Text
attribute :: Maybe ResourceAttribute
$sel:requiresRecreation:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe RequiresRecreation
$sel:name:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe Text
$sel:attribute:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe ResourceAttribute
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceAttribute
attribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RequiresRecreation
requiresRecreation

instance Prelude.NFData ResourceTargetDefinition where
  rnf :: ResourceTargetDefinition -> ()
rnf ResourceTargetDefinition' {Maybe Text
Maybe RequiresRecreation
Maybe ResourceAttribute
requiresRecreation :: Maybe RequiresRecreation
name :: Maybe Text
attribute :: Maybe ResourceAttribute
$sel:requiresRecreation:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe RequiresRecreation
$sel:name:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe Text
$sel:attribute:ResourceTargetDefinition' :: ResourceTargetDefinition -> Maybe ResourceAttribute
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceAttribute
attribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RequiresRecreation
requiresRecreation