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

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

-- | An ARN of the AWS cloud resource target receiving the migration (e.g.,
-- AMI, EC2 instance, RDS instance, etc.).
--
-- /See:/ 'newCreatedArtifact' smart constructor.
data CreatedArtifact = CreatedArtifact'
  { -- | A description that can be free-form text to record additional detail
    -- about the artifact for clarity or for later reference.
    CreatedArtifact -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | An ARN that uniquely identifies the result of a migration task.
    CreatedArtifact -> Text
name :: Prelude.Text
  }
  deriving (CreatedArtifact -> CreatedArtifact -> Bool
(CreatedArtifact -> CreatedArtifact -> Bool)
-> (CreatedArtifact -> CreatedArtifact -> Bool)
-> Eq CreatedArtifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatedArtifact -> CreatedArtifact -> Bool
$c/= :: CreatedArtifact -> CreatedArtifact -> Bool
== :: CreatedArtifact -> CreatedArtifact -> Bool
$c== :: CreatedArtifact -> CreatedArtifact -> Bool
Prelude.Eq, ReadPrec [CreatedArtifact]
ReadPrec CreatedArtifact
Int -> ReadS CreatedArtifact
ReadS [CreatedArtifact]
(Int -> ReadS CreatedArtifact)
-> ReadS [CreatedArtifact]
-> ReadPrec CreatedArtifact
-> ReadPrec [CreatedArtifact]
-> Read CreatedArtifact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatedArtifact]
$creadListPrec :: ReadPrec [CreatedArtifact]
readPrec :: ReadPrec CreatedArtifact
$creadPrec :: ReadPrec CreatedArtifact
readList :: ReadS [CreatedArtifact]
$creadList :: ReadS [CreatedArtifact]
readsPrec :: Int -> ReadS CreatedArtifact
$creadsPrec :: Int -> ReadS CreatedArtifact
Prelude.Read, Int -> CreatedArtifact -> ShowS
[CreatedArtifact] -> ShowS
CreatedArtifact -> String
(Int -> CreatedArtifact -> ShowS)
-> (CreatedArtifact -> String)
-> ([CreatedArtifact] -> ShowS)
-> Show CreatedArtifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatedArtifact] -> ShowS
$cshowList :: [CreatedArtifact] -> ShowS
show :: CreatedArtifact -> String
$cshow :: CreatedArtifact -> String
showsPrec :: Int -> CreatedArtifact -> ShowS
$cshowsPrec :: Int -> CreatedArtifact -> ShowS
Prelude.Show, (forall x. CreatedArtifact -> Rep CreatedArtifact x)
-> (forall x. Rep CreatedArtifact x -> CreatedArtifact)
-> Generic CreatedArtifact
forall x. Rep CreatedArtifact x -> CreatedArtifact
forall x. CreatedArtifact -> Rep CreatedArtifact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatedArtifact x -> CreatedArtifact
$cfrom :: forall x. CreatedArtifact -> Rep CreatedArtifact x
Prelude.Generic)

-- |
-- Create a value of 'CreatedArtifact' 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', 'createdArtifact_description' - A description that can be free-form text to record additional detail
-- about the artifact for clarity or for later reference.
--
-- 'name', 'createdArtifact_name' - An ARN that uniquely identifies the result of a migration task.
newCreatedArtifact ::
  -- | 'name'
  Prelude.Text ->
  CreatedArtifact
newCreatedArtifact :: Text -> CreatedArtifact
newCreatedArtifact Text
pName_ =
  CreatedArtifact' :: Maybe Text -> Text -> CreatedArtifact
CreatedArtifact'
    { $sel:description:CreatedArtifact' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreatedArtifact' :: Text
name = Text
pName_
    }

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

-- | An ARN that uniquely identifies the result of a migration task.
createdArtifact_name :: Lens.Lens' CreatedArtifact Prelude.Text
createdArtifact_name :: (Text -> f Text) -> CreatedArtifact -> f CreatedArtifact
createdArtifact_name = (CreatedArtifact -> Text)
-> (CreatedArtifact -> Text -> CreatedArtifact)
-> Lens CreatedArtifact CreatedArtifact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatedArtifact' {Text
name :: Text
$sel:name:CreatedArtifact' :: CreatedArtifact -> Text
name} -> Text
name) (\s :: CreatedArtifact
s@CreatedArtifact' {} Text
a -> CreatedArtifact
s {$sel:name:CreatedArtifact' :: Text
name = Text
a} :: CreatedArtifact)

instance Core.FromJSON CreatedArtifact where
  parseJSON :: Value -> Parser CreatedArtifact
parseJSON =
    String
-> (Object -> Parser CreatedArtifact)
-> Value
-> Parser CreatedArtifact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CreatedArtifact"
      ( \Object
x ->
          Maybe Text -> Text -> CreatedArtifact
CreatedArtifact'
            (Maybe Text -> Text -> CreatedArtifact)
-> Parser (Maybe Text) -> Parser (Text -> CreatedArtifact)
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 -> CreatedArtifact)
-> Parser Text -> Parser CreatedArtifact
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
"Name")
      )

instance Prelude.Hashable CreatedArtifact

instance Prelude.NFData CreatedArtifact

instance Core.ToJSON CreatedArtifact where
  toJSON :: CreatedArtifact -> Value
toJSON CreatedArtifact' {Maybe Text
Text
name :: Text
description :: Maybe Text
$sel:name:CreatedArtifact' :: CreatedArtifact -> Text
$sel:description:CreatedArtifact' :: CreatedArtifact -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )