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

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
import Amazonka.ServiceCatalog.Types.RequiresRecreation
import Amazonka.ServiceCatalog.Types.ResourceAttribute

-- | Information about a change to a resource attribute.
--
-- /See:/ 'newResourceTargetDefinition' smart constructor.
data ResourceTargetDefinition = ResourceTargetDefinition'
  { -- | The attribute to be changed.
    ResourceTargetDefinition -> Maybe ResourceAttribute
attribute :: Prelude.Maybe ResourceAttribute,
    -- | If the attribute is @Properties@, the value is the name of the property.
    -- Otherwise, the value is null.
    ResourceTargetDefinition -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | If the attribute is @Properties@, indicates whether a change to this
    -- property causes the resource to be re-created.
    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' - The attribute to be changed.
--
-- 'name', 'resourceTargetDefinition_name' - If the attribute is @Properties@, the value is the name of the property.
-- Otherwise, the value is null.
--
-- 'requiresRecreation', 'resourceTargetDefinition_requiresRecreation' - If the attribute is @Properties@, indicates whether a change to this
-- property causes the resource to be re-created.
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
    }

-- | The attribute to be changed.
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 is @Properties@, the value is the name of the property.
-- Otherwise, 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 is @Properties@, indicates whether a change to this
-- property causes the resource to be re-created.
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.FromJSON ResourceTargetDefinition where
  parseJSON :: Value -> Parser ResourceTargetDefinition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceTargetDefinition"
      ( \Object
x ->
          Maybe ResourceAttribute
-> Maybe Text
-> Maybe RequiresRecreation
-> ResourceTargetDefinition
ResourceTargetDefinition'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Attribute")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"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