{-# 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.ResilienceHub.Types.ResourceMapping
-- 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.ResilienceHub.Types.ResourceMapping 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.ResilienceHub.Types.PhysicalResourceId
import Amazonka.ResilienceHub.Types.ResourceMappingType

-- | Defines a resource mapping.
--
-- /See:/ 'newResourceMapping' smart constructor.
data ResourceMapping = ResourceMapping'
  { -- | The name of the application this resource is mapped to.
    ResourceMapping -> Maybe Text
appRegistryAppName :: Prelude.Maybe Prelude.Text,
    -- | The name of the CloudFormation stack this resource is mapped to.
    ResourceMapping -> Maybe Text
logicalStackName :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource group this resource is mapped to.
    ResourceMapping -> Maybe Text
resourceGroupName :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource this resource is mapped to.
    ResourceMapping -> Maybe Text
resourceName :: Prelude.Maybe Prelude.Text,
    -- | The short name of the Terraform source.
    ResourceMapping -> Maybe Text
terraformSourceName :: Prelude.Maybe Prelude.Text,
    -- | Specifies the type of resource mapping.
    --
    -- [AppRegistryApp]
    --     The resource is mapped to another application. The name of the
    --     application is contained in the @appRegistryAppName@ property.
    --
    -- [CfnStack]
    --     The resource is mapped to a CloudFormation stack. The name of the
    --     CloudFormation stack is contained in the @logicalStackName@
    --     property.
    --
    -- [Resource]
    --     The resource is mapped to another resource. The name of the resource
    --     is contained in the @resourceName@ property.
    --
    -- [ResourceGroup]
    --     The resource is mapped to a resource group. The name of the resource
    --     group is contained in the @resourceGroupName@ property.
    ResourceMapping -> ResourceMappingType
mappingType :: ResourceMappingType,
    -- | The identifier of this resource.
    ResourceMapping -> PhysicalResourceId
physicalResourceId :: PhysicalResourceId
  }
  deriving (ResourceMapping -> ResourceMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceMapping -> ResourceMapping -> Bool
$c/= :: ResourceMapping -> ResourceMapping -> Bool
== :: ResourceMapping -> ResourceMapping -> Bool
$c== :: ResourceMapping -> ResourceMapping -> Bool
Prelude.Eq, ReadPrec [ResourceMapping]
ReadPrec ResourceMapping
Int -> ReadS ResourceMapping
ReadS [ResourceMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceMapping]
$creadListPrec :: ReadPrec [ResourceMapping]
readPrec :: ReadPrec ResourceMapping
$creadPrec :: ReadPrec ResourceMapping
readList :: ReadS [ResourceMapping]
$creadList :: ReadS [ResourceMapping]
readsPrec :: Int -> ReadS ResourceMapping
$creadsPrec :: Int -> ReadS ResourceMapping
Prelude.Read, Int -> ResourceMapping -> ShowS
[ResourceMapping] -> ShowS
ResourceMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceMapping] -> ShowS
$cshowList :: [ResourceMapping] -> ShowS
show :: ResourceMapping -> String
$cshow :: ResourceMapping -> String
showsPrec :: Int -> ResourceMapping -> ShowS
$cshowsPrec :: Int -> ResourceMapping -> ShowS
Prelude.Show, forall x. Rep ResourceMapping x -> ResourceMapping
forall x. ResourceMapping -> Rep ResourceMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceMapping x -> ResourceMapping
$cfrom :: forall x. ResourceMapping -> Rep ResourceMapping x
Prelude.Generic)

-- |
-- Create a value of 'ResourceMapping' 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:
--
-- 'appRegistryAppName', 'resourceMapping_appRegistryAppName' - The name of the application this resource is mapped to.
--
-- 'logicalStackName', 'resourceMapping_logicalStackName' - The name of the CloudFormation stack this resource is mapped to.
--
-- 'resourceGroupName', 'resourceMapping_resourceGroupName' - The name of the resource group this resource is mapped to.
--
-- 'resourceName', 'resourceMapping_resourceName' - The name of the resource this resource is mapped to.
--
-- 'terraformSourceName', 'resourceMapping_terraformSourceName' - The short name of the Terraform source.
--
-- 'mappingType', 'resourceMapping_mappingType' - Specifies the type of resource mapping.
--
-- [AppRegistryApp]
--     The resource is mapped to another application. The name of the
--     application is contained in the @appRegistryAppName@ property.
--
-- [CfnStack]
--     The resource is mapped to a CloudFormation stack. The name of the
--     CloudFormation stack is contained in the @logicalStackName@
--     property.
--
-- [Resource]
--     The resource is mapped to another resource. The name of the resource
--     is contained in the @resourceName@ property.
--
-- [ResourceGroup]
--     The resource is mapped to a resource group. The name of the resource
--     group is contained in the @resourceGroupName@ property.
--
-- 'physicalResourceId', 'resourceMapping_physicalResourceId' - The identifier of this resource.
newResourceMapping ::
  -- | 'mappingType'
  ResourceMappingType ->
  -- | 'physicalResourceId'
  PhysicalResourceId ->
  ResourceMapping
newResourceMapping :: ResourceMappingType -> PhysicalResourceId -> ResourceMapping
newResourceMapping ResourceMappingType
pMappingType_ PhysicalResourceId
pPhysicalResourceId_ =
  ResourceMapping'
    { $sel:appRegistryAppName:ResourceMapping' :: Maybe Text
appRegistryAppName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:logicalStackName:ResourceMapping' :: Maybe Text
logicalStackName = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceGroupName:ResourceMapping' :: Maybe Text
resourceGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceName:ResourceMapping' :: Maybe Text
resourceName = forall a. Maybe a
Prelude.Nothing,
      $sel:terraformSourceName:ResourceMapping' :: Maybe Text
terraformSourceName = forall a. Maybe a
Prelude.Nothing,
      $sel:mappingType:ResourceMapping' :: ResourceMappingType
mappingType = ResourceMappingType
pMappingType_,
      $sel:physicalResourceId:ResourceMapping' :: PhysicalResourceId
physicalResourceId = PhysicalResourceId
pPhysicalResourceId_
    }

-- | The name of the application this resource is mapped to.
resourceMapping_appRegistryAppName :: Lens.Lens' ResourceMapping (Prelude.Maybe Prelude.Text)
resourceMapping_appRegistryAppName :: Lens' ResourceMapping (Maybe Text)
resourceMapping_appRegistryAppName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {Maybe Text
appRegistryAppName :: Maybe Text
$sel:appRegistryAppName:ResourceMapping' :: ResourceMapping -> Maybe Text
appRegistryAppName} -> Maybe Text
appRegistryAppName) (\s :: ResourceMapping
s@ResourceMapping' {} Maybe Text
a -> ResourceMapping
s {$sel:appRegistryAppName:ResourceMapping' :: Maybe Text
appRegistryAppName = Maybe Text
a} :: ResourceMapping)

-- | The name of the CloudFormation stack this resource is mapped to.
resourceMapping_logicalStackName :: Lens.Lens' ResourceMapping (Prelude.Maybe Prelude.Text)
resourceMapping_logicalStackName :: Lens' ResourceMapping (Maybe Text)
resourceMapping_logicalStackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {Maybe Text
logicalStackName :: Maybe Text
$sel:logicalStackName:ResourceMapping' :: ResourceMapping -> Maybe Text
logicalStackName} -> Maybe Text
logicalStackName) (\s :: ResourceMapping
s@ResourceMapping' {} Maybe Text
a -> ResourceMapping
s {$sel:logicalStackName:ResourceMapping' :: Maybe Text
logicalStackName = Maybe Text
a} :: ResourceMapping)

-- | The name of the resource group this resource is mapped to.
resourceMapping_resourceGroupName :: Lens.Lens' ResourceMapping (Prelude.Maybe Prelude.Text)
resourceMapping_resourceGroupName :: Lens' ResourceMapping (Maybe Text)
resourceMapping_resourceGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {Maybe Text
resourceGroupName :: Maybe Text
$sel:resourceGroupName:ResourceMapping' :: ResourceMapping -> Maybe Text
resourceGroupName} -> Maybe Text
resourceGroupName) (\s :: ResourceMapping
s@ResourceMapping' {} Maybe Text
a -> ResourceMapping
s {$sel:resourceGroupName:ResourceMapping' :: Maybe Text
resourceGroupName = Maybe Text
a} :: ResourceMapping)

-- | The name of the resource this resource is mapped to.
resourceMapping_resourceName :: Lens.Lens' ResourceMapping (Prelude.Maybe Prelude.Text)
resourceMapping_resourceName :: Lens' ResourceMapping (Maybe Text)
resourceMapping_resourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {Maybe Text
resourceName :: Maybe Text
$sel:resourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
resourceName} -> Maybe Text
resourceName) (\s :: ResourceMapping
s@ResourceMapping' {} Maybe Text
a -> ResourceMapping
s {$sel:resourceName:ResourceMapping' :: Maybe Text
resourceName = Maybe Text
a} :: ResourceMapping)

-- | The short name of the Terraform source.
resourceMapping_terraformSourceName :: Lens.Lens' ResourceMapping (Prelude.Maybe Prelude.Text)
resourceMapping_terraformSourceName :: Lens' ResourceMapping (Maybe Text)
resourceMapping_terraformSourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {Maybe Text
terraformSourceName :: Maybe Text
$sel:terraformSourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
terraformSourceName} -> Maybe Text
terraformSourceName) (\s :: ResourceMapping
s@ResourceMapping' {} Maybe Text
a -> ResourceMapping
s {$sel:terraformSourceName:ResourceMapping' :: Maybe Text
terraformSourceName = Maybe Text
a} :: ResourceMapping)

-- | Specifies the type of resource mapping.
--
-- [AppRegistryApp]
--     The resource is mapped to another application. The name of the
--     application is contained in the @appRegistryAppName@ property.
--
-- [CfnStack]
--     The resource is mapped to a CloudFormation stack. The name of the
--     CloudFormation stack is contained in the @logicalStackName@
--     property.
--
-- [Resource]
--     The resource is mapped to another resource. The name of the resource
--     is contained in the @resourceName@ property.
--
-- [ResourceGroup]
--     The resource is mapped to a resource group. The name of the resource
--     group is contained in the @resourceGroupName@ property.
resourceMapping_mappingType :: Lens.Lens' ResourceMapping ResourceMappingType
resourceMapping_mappingType :: Lens' ResourceMapping ResourceMappingType
resourceMapping_mappingType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {ResourceMappingType
mappingType :: ResourceMappingType
$sel:mappingType:ResourceMapping' :: ResourceMapping -> ResourceMappingType
mappingType} -> ResourceMappingType
mappingType) (\s :: ResourceMapping
s@ResourceMapping' {} ResourceMappingType
a -> ResourceMapping
s {$sel:mappingType:ResourceMapping' :: ResourceMappingType
mappingType = ResourceMappingType
a} :: ResourceMapping)

-- | The identifier of this resource.
resourceMapping_physicalResourceId :: Lens.Lens' ResourceMapping PhysicalResourceId
resourceMapping_physicalResourceId :: Lens' ResourceMapping PhysicalResourceId
resourceMapping_physicalResourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMapping' {PhysicalResourceId
physicalResourceId :: PhysicalResourceId
$sel:physicalResourceId:ResourceMapping' :: ResourceMapping -> PhysicalResourceId
physicalResourceId} -> PhysicalResourceId
physicalResourceId) (\s :: ResourceMapping
s@ResourceMapping' {} PhysicalResourceId
a -> ResourceMapping
s {$sel:physicalResourceId:ResourceMapping' :: PhysicalResourceId
physicalResourceId = PhysicalResourceId
a} :: ResourceMapping)

instance Data.FromJSON ResourceMapping where
  parseJSON :: Value -> Parser ResourceMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceMapping"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ResourceMappingType
-> PhysicalResourceId
-> ResourceMapping
ResourceMapping'
            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
"appRegistryAppName")
            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
"logicalStackName")
            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
"resourceGroupName")
            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
"resourceName")
            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
"terraformSourceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"mappingType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"physicalResourceId")
      )

instance Prelude.Hashable ResourceMapping where
  hashWithSalt :: Int -> ResourceMapping -> Int
hashWithSalt Int
_salt ResourceMapping' {Maybe Text
PhysicalResourceId
ResourceMappingType
physicalResourceId :: PhysicalResourceId
mappingType :: ResourceMappingType
terraformSourceName :: Maybe Text
resourceName :: Maybe Text
resourceGroupName :: Maybe Text
logicalStackName :: Maybe Text
appRegistryAppName :: Maybe Text
$sel:physicalResourceId:ResourceMapping' :: ResourceMapping -> PhysicalResourceId
$sel:mappingType:ResourceMapping' :: ResourceMapping -> ResourceMappingType
$sel:terraformSourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:resourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:resourceGroupName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:logicalStackName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:appRegistryAppName:ResourceMapping' :: ResourceMapping -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
appRegistryAppName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logicalStackName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
terraformSourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceMappingType
mappingType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PhysicalResourceId
physicalResourceId

instance Prelude.NFData ResourceMapping where
  rnf :: ResourceMapping -> ()
rnf ResourceMapping' {Maybe Text
PhysicalResourceId
ResourceMappingType
physicalResourceId :: PhysicalResourceId
mappingType :: ResourceMappingType
terraformSourceName :: Maybe Text
resourceName :: Maybe Text
resourceGroupName :: Maybe Text
logicalStackName :: Maybe Text
appRegistryAppName :: Maybe Text
$sel:physicalResourceId:ResourceMapping' :: ResourceMapping -> PhysicalResourceId
$sel:mappingType:ResourceMapping' :: ResourceMapping -> ResourceMappingType
$sel:terraformSourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:resourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:resourceGroupName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:logicalStackName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:appRegistryAppName:ResourceMapping' :: ResourceMapping -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
appRegistryAppName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logicalStackName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
terraformSourceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceMappingType
mappingType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PhysicalResourceId
physicalResourceId

instance Data.ToJSON ResourceMapping where
  toJSON :: ResourceMapping -> Value
toJSON ResourceMapping' {Maybe Text
PhysicalResourceId
ResourceMappingType
physicalResourceId :: PhysicalResourceId
mappingType :: ResourceMappingType
terraformSourceName :: Maybe Text
resourceName :: Maybe Text
resourceGroupName :: Maybe Text
logicalStackName :: Maybe Text
appRegistryAppName :: Maybe Text
$sel:physicalResourceId:ResourceMapping' :: ResourceMapping -> PhysicalResourceId
$sel:mappingType:ResourceMapping' :: ResourceMapping -> ResourceMappingType
$sel:terraformSourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:resourceName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:resourceGroupName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:logicalStackName:ResourceMapping' :: ResourceMapping -> Maybe Text
$sel:appRegistryAppName:ResourceMapping' :: ResourceMapping -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"appRegistryAppName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
appRegistryAppName,
            (Key
"logicalStackName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
logicalStackName,
            (Key
"resourceGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceGroupName,
            (Key
"resourceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceName,
            (Key
"terraformSourceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
terraformSourceName,
            forall a. a -> Maybe a
Prelude.Just (Key
"mappingType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResourceMappingType
mappingType),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"physicalResourceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PhysicalResourceId
physicalResourceId)
          ]
      )