{-# 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.PhysicalResource
-- 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.PhysicalResource 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.AppComponent
import Amazonka.ResilienceHub.Types.LogicalResourceId
import Amazonka.ResilienceHub.Types.PhysicalResourceId

-- | Defines a physical resource. A physical resource is a resource that
-- exists in your account. It can be identified using an Amazon Resource
-- Name (ARN) or a Resilience Hub-native identifier.
--
-- /See:/ 'newPhysicalResource' smart constructor.
data PhysicalResource = PhysicalResource'
  { -- | The application components that belong to this resource.
    PhysicalResource -> Maybe [AppComponent]
appComponents :: Prelude.Maybe [AppComponent],
    -- | The name of the resource.
    PhysicalResource -> Maybe Text
resourceName :: Prelude.Maybe Prelude.Text,
    -- | The logical identifier of the resource.
    PhysicalResource -> LogicalResourceId
logicalResourceId :: LogicalResourceId,
    -- | The physical identifier of the resource.
    PhysicalResource -> PhysicalResourceId
physicalResourceId :: PhysicalResourceId,
    -- | The type of resource.
    PhysicalResource -> Text
resourceType :: Prelude.Text
  }
  deriving (PhysicalResource -> PhysicalResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalResource -> PhysicalResource -> Bool
$c/= :: PhysicalResource -> PhysicalResource -> Bool
== :: PhysicalResource -> PhysicalResource -> Bool
$c== :: PhysicalResource -> PhysicalResource -> Bool
Prelude.Eq, ReadPrec [PhysicalResource]
ReadPrec PhysicalResource
Int -> ReadS PhysicalResource
ReadS [PhysicalResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhysicalResource]
$creadListPrec :: ReadPrec [PhysicalResource]
readPrec :: ReadPrec PhysicalResource
$creadPrec :: ReadPrec PhysicalResource
readList :: ReadS [PhysicalResource]
$creadList :: ReadS [PhysicalResource]
readsPrec :: Int -> ReadS PhysicalResource
$creadsPrec :: Int -> ReadS PhysicalResource
Prelude.Read, Int -> PhysicalResource -> ShowS
[PhysicalResource] -> ShowS
PhysicalResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhysicalResource] -> ShowS
$cshowList :: [PhysicalResource] -> ShowS
show :: PhysicalResource -> String
$cshow :: PhysicalResource -> String
showsPrec :: Int -> PhysicalResource -> ShowS
$cshowsPrec :: Int -> PhysicalResource -> ShowS
Prelude.Show, forall x. Rep PhysicalResource x -> PhysicalResource
forall x. PhysicalResource -> Rep PhysicalResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhysicalResource x -> PhysicalResource
$cfrom :: forall x. PhysicalResource -> Rep PhysicalResource x
Prelude.Generic)

-- |
-- Create a value of 'PhysicalResource' 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:
--
-- 'appComponents', 'physicalResource_appComponents' - The application components that belong to this resource.
--
-- 'resourceName', 'physicalResource_resourceName' - The name of the resource.
--
-- 'logicalResourceId', 'physicalResource_logicalResourceId' - The logical identifier of the resource.
--
-- 'physicalResourceId', 'physicalResource_physicalResourceId' - The physical identifier of the resource.
--
-- 'resourceType', 'physicalResource_resourceType' - The type of resource.
newPhysicalResource ::
  -- | 'logicalResourceId'
  LogicalResourceId ->
  -- | 'physicalResourceId'
  PhysicalResourceId ->
  -- | 'resourceType'
  Prelude.Text ->
  PhysicalResource
newPhysicalResource :: LogicalResourceId -> PhysicalResourceId -> Text -> PhysicalResource
newPhysicalResource
  LogicalResourceId
pLogicalResourceId_
  PhysicalResourceId
pPhysicalResourceId_
  Text
pResourceType_ =
    PhysicalResource'
      { $sel:appComponents:PhysicalResource' :: Maybe [AppComponent]
appComponents = forall a. Maybe a
Prelude.Nothing,
        $sel:resourceName:PhysicalResource' :: Maybe Text
resourceName = forall a. Maybe a
Prelude.Nothing,
        $sel:logicalResourceId:PhysicalResource' :: LogicalResourceId
logicalResourceId = LogicalResourceId
pLogicalResourceId_,
        $sel:physicalResourceId:PhysicalResource' :: PhysicalResourceId
physicalResourceId = PhysicalResourceId
pPhysicalResourceId_,
        $sel:resourceType:PhysicalResource' :: Text
resourceType = Text
pResourceType_
      }

-- | The application components that belong to this resource.
physicalResource_appComponents :: Lens.Lens' PhysicalResource (Prelude.Maybe [AppComponent])
physicalResource_appComponents :: Lens' PhysicalResource (Maybe [AppComponent])
physicalResource_appComponents = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhysicalResource' {Maybe [AppComponent]
appComponents :: Maybe [AppComponent]
$sel:appComponents:PhysicalResource' :: PhysicalResource -> Maybe [AppComponent]
appComponents} -> Maybe [AppComponent]
appComponents) (\s :: PhysicalResource
s@PhysicalResource' {} Maybe [AppComponent]
a -> PhysicalResource
s {$sel:appComponents:PhysicalResource' :: Maybe [AppComponent]
appComponents = Maybe [AppComponent]
a} :: PhysicalResource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the resource.
physicalResource_resourceName :: Lens.Lens' PhysicalResource (Prelude.Maybe Prelude.Text)
physicalResource_resourceName :: Lens' PhysicalResource (Maybe Text)
physicalResource_resourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhysicalResource' {Maybe Text
resourceName :: Maybe Text
$sel:resourceName:PhysicalResource' :: PhysicalResource -> Maybe Text
resourceName} -> Maybe Text
resourceName) (\s :: PhysicalResource
s@PhysicalResource' {} Maybe Text
a -> PhysicalResource
s {$sel:resourceName:PhysicalResource' :: Maybe Text
resourceName = Maybe Text
a} :: PhysicalResource)

-- | The logical identifier of the resource.
physicalResource_logicalResourceId :: Lens.Lens' PhysicalResource LogicalResourceId
physicalResource_logicalResourceId :: Lens' PhysicalResource LogicalResourceId
physicalResource_logicalResourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhysicalResource' {LogicalResourceId
logicalResourceId :: LogicalResourceId
$sel:logicalResourceId:PhysicalResource' :: PhysicalResource -> LogicalResourceId
logicalResourceId} -> LogicalResourceId
logicalResourceId) (\s :: PhysicalResource
s@PhysicalResource' {} LogicalResourceId
a -> PhysicalResource
s {$sel:logicalResourceId:PhysicalResource' :: LogicalResourceId
logicalResourceId = LogicalResourceId
a} :: PhysicalResource)

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

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

instance Data.FromJSON PhysicalResource where
  parseJSON :: Value -> Parser PhysicalResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PhysicalResource"
      ( \Object
x ->
          Maybe [AppComponent]
-> Maybe Text
-> LogicalResourceId
-> PhysicalResourceId
-> Text
-> PhysicalResource
PhysicalResource'
            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
"appComponents" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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 a
Data..: Key
"logicalResourceId")
            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")
            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
"resourceType")
      )

instance Prelude.Hashable PhysicalResource where
  hashWithSalt :: Int -> PhysicalResource -> Int
hashWithSalt Int
_salt PhysicalResource' {Maybe [AppComponent]
Maybe Text
Text
LogicalResourceId
PhysicalResourceId
resourceType :: Text
physicalResourceId :: PhysicalResourceId
logicalResourceId :: LogicalResourceId
resourceName :: Maybe Text
appComponents :: Maybe [AppComponent]
$sel:resourceType:PhysicalResource' :: PhysicalResource -> Text
$sel:physicalResourceId:PhysicalResource' :: PhysicalResource -> PhysicalResourceId
$sel:logicalResourceId:PhysicalResource' :: PhysicalResource -> LogicalResourceId
$sel:resourceName:PhysicalResource' :: PhysicalResource -> Maybe Text
$sel:appComponents:PhysicalResource' :: PhysicalResource -> Maybe [AppComponent]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AppComponent]
appComponents
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LogicalResourceId
logicalResourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PhysicalResourceId
physicalResourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceType

instance Prelude.NFData PhysicalResource where
  rnf :: PhysicalResource -> ()
rnf PhysicalResource' {Maybe [AppComponent]
Maybe Text
Text
LogicalResourceId
PhysicalResourceId
resourceType :: Text
physicalResourceId :: PhysicalResourceId
logicalResourceId :: LogicalResourceId
resourceName :: Maybe Text
appComponents :: Maybe [AppComponent]
$sel:resourceType:PhysicalResource' :: PhysicalResource -> Text
$sel:physicalResourceId:PhysicalResource' :: PhysicalResource -> PhysicalResourceId
$sel:logicalResourceId:PhysicalResource' :: PhysicalResource -> LogicalResourceId
$sel:resourceName:PhysicalResource' :: PhysicalResource -> Maybe Text
$sel:appComponents:PhysicalResource' :: PhysicalResource -> Maybe [AppComponent]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AppComponent]
appComponents
      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 LogicalResourceId
logicalResourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PhysicalResourceId
physicalResourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceType