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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ServiceCatalog.Types.ChangeAction
import Amazonka.ServiceCatalog.Types.Replacement
import Amazonka.ServiceCatalog.Types.ResourceAttribute
import Amazonka.ServiceCatalog.Types.ResourceChangeDetail

-- | Information about a resource change that will occur when a plan is
-- executed.
--
-- /See:/ 'newResourceChange' smart constructor.
data ResourceChange = ResourceChange'
  { -- | The ID of the resource, as defined in the CloudFormation template.
    ResourceChange -> Maybe Text
logicalResourceId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the resource, if it was already created.
    ResourceChange -> Maybe Text
physicalResourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of resource.
    ResourceChange -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The change action.
    ResourceChange -> Maybe ChangeAction
action :: Prelude.Maybe ChangeAction,
    -- | The change scope.
    ResourceChange -> Maybe [ResourceAttribute]
scope :: Prelude.Maybe [ResourceAttribute],
    -- | Information about the resource changes.
    ResourceChange -> Maybe [ResourceChangeDetail]
details :: Prelude.Maybe [ResourceChangeDetail],
    -- | If the change type is @Modify@, indicates whether the existing resource
    -- is deleted and replaced with a new one.
    ResourceChange -> Maybe Replacement
replacement :: Prelude.Maybe Replacement
  }
  deriving (ResourceChange -> ResourceChange -> Bool
(ResourceChange -> ResourceChange -> Bool)
-> (ResourceChange -> ResourceChange -> Bool) -> Eq ResourceChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceChange -> ResourceChange -> Bool
$c/= :: ResourceChange -> ResourceChange -> Bool
== :: ResourceChange -> ResourceChange -> Bool
$c== :: ResourceChange -> ResourceChange -> Bool
Prelude.Eq, ReadPrec [ResourceChange]
ReadPrec ResourceChange
Int -> ReadS ResourceChange
ReadS [ResourceChange]
(Int -> ReadS ResourceChange)
-> ReadS [ResourceChange]
-> ReadPrec ResourceChange
-> ReadPrec [ResourceChange]
-> Read ResourceChange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceChange]
$creadListPrec :: ReadPrec [ResourceChange]
readPrec :: ReadPrec ResourceChange
$creadPrec :: ReadPrec ResourceChange
readList :: ReadS [ResourceChange]
$creadList :: ReadS [ResourceChange]
readsPrec :: Int -> ReadS ResourceChange
$creadsPrec :: Int -> ReadS ResourceChange
Prelude.Read, Int -> ResourceChange -> ShowS
[ResourceChange] -> ShowS
ResourceChange -> String
(Int -> ResourceChange -> ShowS)
-> (ResourceChange -> String)
-> ([ResourceChange] -> ShowS)
-> Show ResourceChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceChange] -> ShowS
$cshowList :: [ResourceChange] -> ShowS
show :: ResourceChange -> String
$cshow :: ResourceChange -> String
showsPrec :: Int -> ResourceChange -> ShowS
$cshowsPrec :: Int -> ResourceChange -> ShowS
Prelude.Show, (forall x. ResourceChange -> Rep ResourceChange x)
-> (forall x. Rep ResourceChange x -> ResourceChange)
-> Generic ResourceChange
forall x. Rep ResourceChange x -> ResourceChange
forall x. ResourceChange -> Rep ResourceChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceChange x -> ResourceChange
$cfrom :: forall x. ResourceChange -> Rep ResourceChange x
Prelude.Generic)

-- |
-- Create a value of 'ResourceChange' 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:
--
-- 'logicalResourceId', 'resourceChange_logicalResourceId' - The ID of the resource, as defined in the CloudFormation template.
--
-- 'physicalResourceId', 'resourceChange_physicalResourceId' - The ID of the resource, if it was already created.
--
-- 'resourceType', 'resourceChange_resourceType' - The type of resource.
--
-- 'action', 'resourceChange_action' - The change action.
--
-- 'scope', 'resourceChange_scope' - The change scope.
--
-- 'details', 'resourceChange_details' - Information about the resource changes.
--
-- 'replacement', 'resourceChange_replacement' - If the change type is @Modify@, indicates whether the existing resource
-- is deleted and replaced with a new one.
newResourceChange ::
  ResourceChange
newResourceChange :: ResourceChange
newResourceChange =
  ResourceChange' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ChangeAction
-> Maybe [ResourceAttribute]
-> Maybe [ResourceChangeDetail]
-> Maybe Replacement
-> ResourceChange
ResourceChange'
    { $sel:logicalResourceId:ResourceChange' :: Maybe Text
logicalResourceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:physicalResourceId:ResourceChange' :: Maybe Text
physicalResourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ResourceChange' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:ResourceChange' :: Maybe ChangeAction
action = Maybe ChangeAction
forall a. Maybe a
Prelude.Nothing,
      $sel:scope:ResourceChange' :: Maybe [ResourceAttribute]
scope = Maybe [ResourceAttribute]
forall a. Maybe a
Prelude.Nothing,
      $sel:details:ResourceChange' :: Maybe [ResourceChangeDetail]
details = Maybe [ResourceChangeDetail]
forall a. Maybe a
Prelude.Nothing,
      $sel:replacement:ResourceChange' :: Maybe Replacement
replacement = Maybe Replacement
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the resource, as defined in the CloudFormation template.
resourceChange_logicalResourceId :: Lens.Lens' ResourceChange (Prelude.Maybe Prelude.Text)
resourceChange_logicalResourceId :: (Maybe Text -> f (Maybe Text))
-> ResourceChange -> f ResourceChange
resourceChange_logicalResourceId = (ResourceChange -> Maybe Text)
-> (ResourceChange -> Maybe Text -> ResourceChange)
-> Lens ResourceChange ResourceChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe Text
logicalResourceId :: Maybe Text
$sel:logicalResourceId:ResourceChange' :: ResourceChange -> Maybe Text
logicalResourceId} -> Maybe Text
logicalResourceId) (\s :: ResourceChange
s@ResourceChange' {} Maybe Text
a -> ResourceChange
s {$sel:logicalResourceId:ResourceChange' :: Maybe Text
logicalResourceId = Maybe Text
a} :: ResourceChange)

-- | The ID of the resource, if it was already created.
resourceChange_physicalResourceId :: Lens.Lens' ResourceChange (Prelude.Maybe Prelude.Text)
resourceChange_physicalResourceId :: (Maybe Text -> f (Maybe Text))
-> ResourceChange -> f ResourceChange
resourceChange_physicalResourceId = (ResourceChange -> Maybe Text)
-> (ResourceChange -> Maybe Text -> ResourceChange)
-> Lens ResourceChange ResourceChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe Text
physicalResourceId :: Maybe Text
$sel:physicalResourceId:ResourceChange' :: ResourceChange -> Maybe Text
physicalResourceId} -> Maybe Text
physicalResourceId) (\s :: ResourceChange
s@ResourceChange' {} Maybe Text
a -> ResourceChange
s {$sel:physicalResourceId:ResourceChange' :: Maybe Text
physicalResourceId = Maybe Text
a} :: ResourceChange)

-- | The type of resource.
resourceChange_resourceType :: Lens.Lens' ResourceChange (Prelude.Maybe Prelude.Text)
resourceChange_resourceType :: (Maybe Text -> f (Maybe Text))
-> ResourceChange -> f ResourceChange
resourceChange_resourceType = (ResourceChange -> Maybe Text)
-> (ResourceChange -> Maybe Text -> ResourceChange)
-> Lens ResourceChange ResourceChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ResourceChange' :: ResourceChange -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ResourceChange
s@ResourceChange' {} Maybe Text
a -> ResourceChange
s {$sel:resourceType:ResourceChange' :: Maybe Text
resourceType = Maybe Text
a} :: ResourceChange)

-- | The change action.
resourceChange_action :: Lens.Lens' ResourceChange (Prelude.Maybe ChangeAction)
resourceChange_action :: (Maybe ChangeAction -> f (Maybe ChangeAction))
-> ResourceChange -> f ResourceChange
resourceChange_action = (ResourceChange -> Maybe ChangeAction)
-> (ResourceChange -> Maybe ChangeAction -> ResourceChange)
-> Lens
     ResourceChange
     ResourceChange
     (Maybe ChangeAction)
     (Maybe ChangeAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe ChangeAction
action :: Maybe ChangeAction
$sel:action:ResourceChange' :: ResourceChange -> Maybe ChangeAction
action} -> Maybe ChangeAction
action) (\s :: ResourceChange
s@ResourceChange' {} Maybe ChangeAction
a -> ResourceChange
s {$sel:action:ResourceChange' :: Maybe ChangeAction
action = Maybe ChangeAction
a} :: ResourceChange)

-- | The change scope.
resourceChange_scope :: Lens.Lens' ResourceChange (Prelude.Maybe [ResourceAttribute])
resourceChange_scope :: (Maybe [ResourceAttribute] -> f (Maybe [ResourceAttribute]))
-> ResourceChange -> f ResourceChange
resourceChange_scope = (ResourceChange -> Maybe [ResourceAttribute])
-> (ResourceChange -> Maybe [ResourceAttribute] -> ResourceChange)
-> Lens
     ResourceChange
     ResourceChange
     (Maybe [ResourceAttribute])
     (Maybe [ResourceAttribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe [ResourceAttribute]
scope :: Maybe [ResourceAttribute]
$sel:scope:ResourceChange' :: ResourceChange -> Maybe [ResourceAttribute]
scope} -> Maybe [ResourceAttribute]
scope) (\s :: ResourceChange
s@ResourceChange' {} Maybe [ResourceAttribute]
a -> ResourceChange
s {$sel:scope:ResourceChange' :: Maybe [ResourceAttribute]
scope = Maybe [ResourceAttribute]
a} :: ResourceChange) ((Maybe [ResourceAttribute] -> f (Maybe [ResourceAttribute]))
 -> ResourceChange -> f ResourceChange)
-> ((Maybe [ResourceAttribute] -> f (Maybe [ResourceAttribute]))
    -> Maybe [ResourceAttribute] -> f (Maybe [ResourceAttribute]))
-> (Maybe [ResourceAttribute] -> f (Maybe [ResourceAttribute]))
-> ResourceChange
-> f ResourceChange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceAttribute]
  [ResourceAttribute]
  [ResourceAttribute]
  [ResourceAttribute]
-> Iso
     (Maybe [ResourceAttribute])
     (Maybe [ResourceAttribute])
     (Maybe [ResourceAttribute])
     (Maybe [ResourceAttribute])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ResourceAttribute]
  [ResourceAttribute]
  [ResourceAttribute]
  [ResourceAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Information about the resource changes.
resourceChange_details :: Lens.Lens' ResourceChange (Prelude.Maybe [ResourceChangeDetail])
resourceChange_details :: (Maybe [ResourceChangeDetail] -> f (Maybe [ResourceChangeDetail]))
-> ResourceChange -> f ResourceChange
resourceChange_details = (ResourceChange -> Maybe [ResourceChangeDetail])
-> (ResourceChange
    -> Maybe [ResourceChangeDetail] -> ResourceChange)
-> Lens
     ResourceChange
     ResourceChange
     (Maybe [ResourceChangeDetail])
     (Maybe [ResourceChangeDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe [ResourceChangeDetail]
details :: Maybe [ResourceChangeDetail]
$sel:details:ResourceChange' :: ResourceChange -> Maybe [ResourceChangeDetail]
details} -> Maybe [ResourceChangeDetail]
details) (\s :: ResourceChange
s@ResourceChange' {} Maybe [ResourceChangeDetail]
a -> ResourceChange
s {$sel:details:ResourceChange' :: Maybe [ResourceChangeDetail]
details = Maybe [ResourceChangeDetail]
a} :: ResourceChange) ((Maybe [ResourceChangeDetail] -> f (Maybe [ResourceChangeDetail]))
 -> ResourceChange -> f ResourceChange)
-> ((Maybe [ResourceChangeDetail]
     -> f (Maybe [ResourceChangeDetail]))
    -> Maybe [ResourceChangeDetail]
    -> f (Maybe [ResourceChangeDetail]))
-> (Maybe [ResourceChangeDetail]
    -> f (Maybe [ResourceChangeDetail]))
-> ResourceChange
-> f ResourceChange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceChangeDetail]
  [ResourceChangeDetail]
  [ResourceChangeDetail]
  [ResourceChangeDetail]
-> Iso
     (Maybe [ResourceChangeDetail])
     (Maybe [ResourceChangeDetail])
     (Maybe [ResourceChangeDetail])
     (Maybe [ResourceChangeDetail])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ResourceChangeDetail]
  [ResourceChangeDetail]
  [ResourceChangeDetail]
  [ResourceChangeDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If the change type is @Modify@, indicates whether the existing resource
-- is deleted and replaced with a new one.
resourceChange_replacement :: Lens.Lens' ResourceChange (Prelude.Maybe Replacement)
resourceChange_replacement :: (Maybe Replacement -> f (Maybe Replacement))
-> ResourceChange -> f ResourceChange
resourceChange_replacement = (ResourceChange -> Maybe Replacement)
-> (ResourceChange -> Maybe Replacement -> ResourceChange)
-> Lens
     ResourceChange
     ResourceChange
     (Maybe Replacement)
     (Maybe Replacement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceChange' {Maybe Replacement
replacement :: Maybe Replacement
$sel:replacement:ResourceChange' :: ResourceChange -> Maybe Replacement
replacement} -> Maybe Replacement
replacement) (\s :: ResourceChange
s@ResourceChange' {} Maybe Replacement
a -> ResourceChange
s {$sel:replacement:ResourceChange' :: Maybe Replacement
replacement = Maybe Replacement
a} :: ResourceChange)

instance Core.FromJSON ResourceChange where
  parseJSON :: Value -> Parser ResourceChange
parseJSON =
    String
-> (Object -> Parser ResourceChange)
-> Value
-> Parser ResourceChange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceChange"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ChangeAction
-> Maybe [ResourceAttribute]
-> Maybe [ResourceChangeDetail]
-> Maybe Replacement
-> ResourceChange
ResourceChange'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe ChangeAction
 -> Maybe [ResourceAttribute]
 -> Maybe [ResourceChangeDetail]
 -> Maybe Replacement
 -> ResourceChange)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe ChangeAction
      -> Maybe [ResourceAttribute]
      -> Maybe [ResourceChangeDetail]
      -> Maybe Replacement
      -> ResourceChange)
forall (f :: * -> *) a b. Functor 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
"LogicalResourceId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe ChangeAction
   -> Maybe [ResourceAttribute]
   -> Maybe [ResourceChangeDetail]
   -> Maybe Replacement
   -> ResourceChange)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe ChangeAction
      -> Maybe [ResourceAttribute]
      -> Maybe [ResourceChangeDetail]
      -> Maybe Replacement
      -> ResourceChange)
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
"PhysicalResourceId")
            Parser
  (Maybe Text
   -> Maybe ChangeAction
   -> Maybe [ResourceAttribute]
   -> Maybe [ResourceChangeDetail]
   -> Maybe Replacement
   -> ResourceChange)
-> Parser (Maybe Text)
-> Parser
     (Maybe ChangeAction
      -> Maybe [ResourceAttribute]
      -> Maybe [ResourceChangeDetail]
      -> Maybe Replacement
      -> ResourceChange)
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
"ResourceType")
            Parser
  (Maybe ChangeAction
   -> Maybe [ResourceAttribute]
   -> Maybe [ResourceChangeDetail]
   -> Maybe Replacement
   -> ResourceChange)
-> Parser (Maybe ChangeAction)
-> Parser
     (Maybe [ResourceAttribute]
      -> Maybe [ResourceChangeDetail]
      -> Maybe Replacement
      -> ResourceChange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChangeAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Action")
            Parser
  (Maybe [ResourceAttribute]
   -> Maybe [ResourceChangeDetail]
   -> Maybe Replacement
   -> ResourceChange)
-> Parser (Maybe [ResourceAttribute])
-> Parser
     (Maybe [ResourceChangeDetail]
      -> Maybe Replacement -> ResourceChange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ResourceAttribute]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Scope" Parser (Maybe (Maybe [ResourceAttribute]))
-> Maybe [ResourceAttribute] -> Parser (Maybe [ResourceAttribute])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ResourceAttribute]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [ResourceChangeDetail]
   -> Maybe Replacement -> ResourceChange)
-> Parser (Maybe [ResourceChangeDetail])
-> Parser (Maybe Replacement -> ResourceChange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ResourceChangeDetail]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Details" Parser (Maybe (Maybe [ResourceChangeDetail]))
-> Maybe [ResourceChangeDetail]
-> Parser (Maybe [ResourceChangeDetail])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ResourceChangeDetail]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Replacement -> ResourceChange)
-> Parser (Maybe Replacement) -> Parser ResourceChange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Replacement)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Replacement")
      )

instance Prelude.Hashable ResourceChange

instance Prelude.NFData ResourceChange