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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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@, indicates whether a change to this
    -- property causes the resource to be re-created.
    ResourceTargetDefinition -> Maybe RequiresRecreation
requiresRecreation :: Prelude.Maybe RequiresRecreation,
    -- | 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
  }
  deriving (ResourceTargetDefinition -> ResourceTargetDefinition -> Bool
(ResourceTargetDefinition -> ResourceTargetDefinition -> Bool)
-> (ResourceTargetDefinition -> ResourceTargetDefinition -> Bool)
-> Eq ResourceTargetDefinition
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]
(Int -> ReadS ResourceTargetDefinition)
-> ReadS [ResourceTargetDefinition]
-> ReadPrec ResourceTargetDefinition
-> ReadPrec [ResourceTargetDefinition]
-> Read 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
(Int -> ResourceTargetDefinition -> ShowS)
-> (ResourceTargetDefinition -> String)
-> ([ResourceTargetDefinition] -> ShowS)
-> Show ResourceTargetDefinition
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.
 ResourceTargetDefinition -> Rep ResourceTargetDefinition x)
-> (forall x.
    Rep ResourceTargetDefinition x -> ResourceTargetDefinition)
-> Generic ResourceTargetDefinition
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.
--
-- 'requiresRecreation', 'resourceTargetDefinition_requiresRecreation' - If the attribute is @Properties@, indicates whether a change to this
-- property causes the resource to be re-created.
--
-- 'name', 'resourceTargetDefinition_name' - If the attribute is @Properties@, the value is the name of the property.
-- Otherwise, the value is null.
newResourceTargetDefinition ::
  ResourceTargetDefinition
newResourceTargetDefinition :: ResourceTargetDefinition
newResourceTargetDefinition =
  ResourceTargetDefinition' :: Maybe ResourceAttribute
-> Maybe RequiresRecreation
-> Maybe Text
-> ResourceTargetDefinition
ResourceTargetDefinition'
    { $sel:attribute:ResourceTargetDefinition' :: Maybe ResourceAttribute
attribute =
        Maybe ResourceAttribute
forall a. Maybe a
Prelude.Nothing,
      $sel:requiresRecreation:ResourceTargetDefinition' :: Maybe RequiresRecreation
requiresRecreation = Maybe RequiresRecreation
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceTargetDefinition' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The attribute to be changed.
resourceTargetDefinition_attribute :: Lens.Lens' ResourceTargetDefinition (Prelude.Maybe ResourceAttribute)
resourceTargetDefinition_attribute :: (Maybe ResourceAttribute -> f (Maybe ResourceAttribute))
-> ResourceTargetDefinition -> f ResourceTargetDefinition
resourceTargetDefinition_attribute = (ResourceTargetDefinition -> Maybe ResourceAttribute)
-> (ResourceTargetDefinition
    -> Maybe ResourceAttribute -> ResourceTargetDefinition)
-> Lens
     ResourceTargetDefinition
     ResourceTargetDefinition
     (Maybe ResourceAttribute)
     (Maybe ResourceAttribute)
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@, indicates whether a change to this
-- property causes the resource to be re-created.
resourceTargetDefinition_requiresRecreation :: Lens.Lens' ResourceTargetDefinition (Prelude.Maybe RequiresRecreation)
resourceTargetDefinition_requiresRecreation :: (Maybe RequiresRecreation -> f (Maybe RequiresRecreation))
-> ResourceTargetDefinition -> f ResourceTargetDefinition
resourceTargetDefinition_requiresRecreation = (ResourceTargetDefinition -> Maybe RequiresRecreation)
-> (ResourceTargetDefinition
    -> Maybe RequiresRecreation -> ResourceTargetDefinition)
-> Lens
     ResourceTargetDefinition
     ResourceTargetDefinition
     (Maybe RequiresRecreation)
     (Maybe 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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ResourceTargetDefinition -> f ResourceTargetDefinition
resourceTargetDefinition_name = (ResourceTargetDefinition -> Maybe Text)
-> (ResourceTargetDefinition
    -> Maybe Text -> ResourceTargetDefinition)
-> Lens
     ResourceTargetDefinition
     ResourceTargetDefinition
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON ResourceTargetDefinition where
  parseJSON :: Value -> Parser ResourceTargetDefinition
parseJSON =
    String
-> (Object -> Parser ResourceTargetDefinition)
-> Value
-> Parser ResourceTargetDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceTargetDefinition"
      ( \Object
x ->
          Maybe ResourceAttribute
-> Maybe RequiresRecreation
-> Maybe Text
-> ResourceTargetDefinition
ResourceTargetDefinition'
            (Maybe ResourceAttribute
 -> Maybe RequiresRecreation
 -> Maybe Text
 -> ResourceTargetDefinition)
-> Parser (Maybe ResourceAttribute)
-> Parser
     (Maybe RequiresRecreation
      -> Maybe Text -> ResourceTargetDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ResourceAttribute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attribute")
            Parser
  (Maybe RequiresRecreation
   -> Maybe Text -> ResourceTargetDefinition)
-> Parser (Maybe RequiresRecreation)
-> Parser (Maybe Text -> ResourceTargetDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RequiresRecreation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequiresRecreation")
            Parser (Maybe Text -> ResourceTargetDefinition)
-> Parser (Maybe Text) -> Parser ResourceTargetDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable ResourceTargetDefinition

instance Prelude.NFData ResourceTargetDefinition