{-# 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.MigrationHub.Types.DiscoveredResource
-- 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.MigrationHub.Types.DiscoveredResource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Object representing the on-premises resource being migrated.
--
-- /See:/ 'newDiscoveredResource' smart constructor.
data DiscoveredResource = DiscoveredResource'
  { -- | A description that can be free-form text to record additional detail
    -- about the discovered resource for clarity or later reference.
    DiscoveredResource -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The configurationId in Application Discovery Service that uniquely
    -- identifies the on-premise resource.
    DiscoveredResource -> Text
configurationId :: Prelude.Text
  }
  deriving (DiscoveredResource -> DiscoveredResource -> Bool
(DiscoveredResource -> DiscoveredResource -> Bool)
-> (DiscoveredResource -> DiscoveredResource -> Bool)
-> Eq DiscoveredResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DiscoveredResource -> DiscoveredResource -> Bool
$c/= :: DiscoveredResource -> DiscoveredResource -> Bool
== :: DiscoveredResource -> DiscoveredResource -> Bool
$c== :: DiscoveredResource -> DiscoveredResource -> Bool
Prelude.Eq, ReadPrec [DiscoveredResource]
ReadPrec DiscoveredResource
Int -> ReadS DiscoveredResource
ReadS [DiscoveredResource]
(Int -> ReadS DiscoveredResource)
-> ReadS [DiscoveredResource]
-> ReadPrec DiscoveredResource
-> ReadPrec [DiscoveredResource]
-> Read DiscoveredResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DiscoveredResource]
$creadListPrec :: ReadPrec [DiscoveredResource]
readPrec :: ReadPrec DiscoveredResource
$creadPrec :: ReadPrec DiscoveredResource
readList :: ReadS [DiscoveredResource]
$creadList :: ReadS [DiscoveredResource]
readsPrec :: Int -> ReadS DiscoveredResource
$creadsPrec :: Int -> ReadS DiscoveredResource
Prelude.Read, Int -> DiscoveredResource -> ShowS
[DiscoveredResource] -> ShowS
DiscoveredResource -> String
(Int -> DiscoveredResource -> ShowS)
-> (DiscoveredResource -> String)
-> ([DiscoveredResource] -> ShowS)
-> Show DiscoveredResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DiscoveredResource] -> ShowS
$cshowList :: [DiscoveredResource] -> ShowS
show :: DiscoveredResource -> String
$cshow :: DiscoveredResource -> String
showsPrec :: Int -> DiscoveredResource -> ShowS
$cshowsPrec :: Int -> DiscoveredResource -> ShowS
Prelude.Show, (forall x. DiscoveredResource -> Rep DiscoveredResource x)
-> (forall x. Rep DiscoveredResource x -> DiscoveredResource)
-> Generic DiscoveredResource
forall x. Rep DiscoveredResource x -> DiscoveredResource
forall x. DiscoveredResource -> Rep DiscoveredResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DiscoveredResource x -> DiscoveredResource
$cfrom :: forall x. DiscoveredResource -> Rep DiscoveredResource x
Prelude.Generic)

-- |
-- Create a value of 'DiscoveredResource' 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:
--
-- 'description', 'discoveredResource_description' - A description that can be free-form text to record additional detail
-- about the discovered resource for clarity or later reference.
--
-- 'configurationId', 'discoveredResource_configurationId' - The configurationId in Application Discovery Service that uniquely
-- identifies the on-premise resource.
newDiscoveredResource ::
  -- | 'configurationId'
  Prelude.Text ->
  DiscoveredResource
newDiscoveredResource :: Text -> DiscoveredResource
newDiscoveredResource Text
pConfigurationId_ =
  DiscoveredResource' :: Maybe Text -> Text -> DiscoveredResource
DiscoveredResource'
    { $sel:description:DiscoveredResource' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationId:DiscoveredResource' :: Text
configurationId = Text
pConfigurationId_
    }

-- | A description that can be free-form text to record additional detail
-- about the discovered resource for clarity or later reference.
discoveredResource_description :: Lens.Lens' DiscoveredResource (Prelude.Maybe Prelude.Text)
discoveredResource_description :: (Maybe Text -> f (Maybe Text))
-> DiscoveredResource -> f DiscoveredResource
discoveredResource_description = (DiscoveredResource -> Maybe Text)
-> (DiscoveredResource -> Maybe Text -> DiscoveredResource)
-> Lens
     DiscoveredResource DiscoveredResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoveredResource' {Maybe Text
description :: Maybe Text
$sel:description:DiscoveredResource' :: DiscoveredResource -> Maybe Text
description} -> Maybe Text
description) (\s :: DiscoveredResource
s@DiscoveredResource' {} Maybe Text
a -> DiscoveredResource
s {$sel:description:DiscoveredResource' :: Maybe Text
description = Maybe Text
a} :: DiscoveredResource)

-- | The configurationId in Application Discovery Service that uniquely
-- identifies the on-premise resource.
discoveredResource_configurationId :: Lens.Lens' DiscoveredResource Prelude.Text
discoveredResource_configurationId :: (Text -> f Text) -> DiscoveredResource -> f DiscoveredResource
discoveredResource_configurationId = (DiscoveredResource -> Text)
-> (DiscoveredResource -> Text -> DiscoveredResource)
-> Lens DiscoveredResource DiscoveredResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoveredResource' {Text
configurationId :: Text
$sel:configurationId:DiscoveredResource' :: DiscoveredResource -> Text
configurationId} -> Text
configurationId) (\s :: DiscoveredResource
s@DiscoveredResource' {} Text
a -> DiscoveredResource
s {$sel:configurationId:DiscoveredResource' :: Text
configurationId = Text
a} :: DiscoveredResource)

instance Core.FromJSON DiscoveredResource where
  parseJSON :: Value -> Parser DiscoveredResource
parseJSON =
    String
-> (Object -> Parser DiscoveredResource)
-> Value
-> Parser DiscoveredResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DiscoveredResource"
      ( \Object
x ->
          Maybe Text -> Text -> DiscoveredResource
DiscoveredResource'
            (Maybe Text -> Text -> DiscoveredResource)
-> Parser (Maybe Text) -> Parser (Text -> DiscoveredResource)
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
"Description")
            Parser (Text -> DiscoveredResource)
-> Parser Text -> Parser DiscoveredResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConfigurationId")
      )

instance Prelude.Hashable DiscoveredResource

instance Prelude.NFData DiscoveredResource

instance Core.ToJSON DiscoveredResource where
  toJSON :: DiscoveredResource -> Value
toJSON DiscoveredResource' {Maybe Text
Text
configurationId :: Text
description :: Maybe Text
$sel:configurationId:DiscoveredResource' :: DiscoveredResource -> Text
$sel:description:DiscoveredResource' :: DiscoveredResource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConfigurationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
configurationId)
          ]
      )