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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MigrationHub.Types.MigrationStatus
import qualified Amazonka.Prelude as Prelude

-- | Task object encapsulating task information.
--
-- /See:/ 'newTask' smart constructor.
data Task = Task'
  { -- | Indication of the percentage completion of the task.
    Task -> Maybe Natural
progressPercent :: Prelude.Maybe Prelude.Natural,
    -- | Details of task status as notified by a migration tool. A tool might use
    -- this field to provide clarifying information about the status that is
    -- unique to that tool or that explains an error state.
    Task -> Maybe Text
statusDetail :: Prelude.Maybe Prelude.Text,
    -- | Status of the task - Not Started, In-Progress, Complete.
    Task -> MigrationStatus
status :: MigrationStatus
  }
  deriving (Task -> Task -> Bool
(Task -> Task -> Bool) -> (Task -> Task -> Bool) -> Eq Task
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Task -> Task -> Bool
$c/= :: Task -> Task -> Bool
== :: Task -> Task -> Bool
$c== :: Task -> Task -> Bool
Prelude.Eq, ReadPrec [Task]
ReadPrec Task
Int -> ReadS Task
ReadS [Task]
(Int -> ReadS Task)
-> ReadS [Task] -> ReadPrec Task -> ReadPrec [Task] -> Read Task
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Task]
$creadListPrec :: ReadPrec [Task]
readPrec :: ReadPrec Task
$creadPrec :: ReadPrec Task
readList :: ReadS [Task]
$creadList :: ReadS [Task]
readsPrec :: Int -> ReadS Task
$creadsPrec :: Int -> ReadS Task
Prelude.Read, Int -> Task -> ShowS
[Task] -> ShowS
Task -> String
(Int -> Task -> ShowS)
-> (Task -> String) -> ([Task] -> ShowS) -> Show Task
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Task] -> ShowS
$cshowList :: [Task] -> ShowS
show :: Task -> String
$cshow :: Task -> String
showsPrec :: Int -> Task -> ShowS
$cshowsPrec :: Int -> Task -> ShowS
Prelude.Show, (forall x. Task -> Rep Task x)
-> (forall x. Rep Task x -> Task) -> Generic Task
forall x. Rep Task x -> Task
forall x. Task -> Rep Task x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Task x -> Task
$cfrom :: forall x. Task -> Rep Task x
Prelude.Generic)

-- |
-- Create a value of 'Task' 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:
--
-- 'progressPercent', 'task_progressPercent' - Indication of the percentage completion of the task.
--
-- 'statusDetail', 'task_statusDetail' - Details of task status as notified by a migration tool. A tool might use
-- this field to provide clarifying information about the status that is
-- unique to that tool or that explains an error state.
--
-- 'status', 'task_status' - Status of the task - Not Started, In-Progress, Complete.
newTask ::
  -- | 'status'
  MigrationStatus ->
  Task
newTask :: MigrationStatus -> Task
newTask MigrationStatus
pStatus_ =
  Task' :: Maybe Natural -> Maybe Text -> MigrationStatus -> Task
Task'
    { $sel:progressPercent:Task' :: Maybe Natural
progressPercent = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:statusDetail:Task' :: Maybe Text
statusDetail = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:Task' :: MigrationStatus
status = MigrationStatus
pStatus_
    }

-- | Indication of the percentage completion of the task.
task_progressPercent :: Lens.Lens' Task (Prelude.Maybe Prelude.Natural)
task_progressPercent :: (Maybe Natural -> f (Maybe Natural)) -> Task -> f Task
task_progressPercent = (Task -> Maybe Natural)
-> (Task -> Maybe Natural -> Task)
-> Lens Task Task (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Task' {Maybe Natural
progressPercent :: Maybe Natural
$sel:progressPercent:Task' :: Task -> Maybe Natural
progressPercent} -> Maybe Natural
progressPercent) (\s :: Task
s@Task' {} Maybe Natural
a -> Task
s {$sel:progressPercent:Task' :: Maybe Natural
progressPercent = Maybe Natural
a} :: Task)

-- | Details of task status as notified by a migration tool. A tool might use
-- this field to provide clarifying information about the status that is
-- unique to that tool or that explains an error state.
task_statusDetail :: Lens.Lens' Task (Prelude.Maybe Prelude.Text)
task_statusDetail :: (Maybe Text -> f (Maybe Text)) -> Task -> f Task
task_statusDetail = (Task -> Maybe Text)
-> (Task -> Maybe Text -> Task)
-> Lens Task Task (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Task' {Maybe Text
statusDetail :: Maybe Text
$sel:statusDetail:Task' :: Task -> Maybe Text
statusDetail} -> Maybe Text
statusDetail) (\s :: Task
s@Task' {} Maybe Text
a -> Task
s {$sel:statusDetail:Task' :: Maybe Text
statusDetail = Maybe Text
a} :: Task)

-- | Status of the task - Not Started, In-Progress, Complete.
task_status :: Lens.Lens' Task MigrationStatus
task_status :: (MigrationStatus -> f MigrationStatus) -> Task -> f Task
task_status = (Task -> MigrationStatus)
-> (Task -> MigrationStatus -> Task)
-> Lens Task Task MigrationStatus MigrationStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Task' {MigrationStatus
status :: MigrationStatus
$sel:status:Task' :: Task -> MigrationStatus
status} -> MigrationStatus
status) (\s :: Task
s@Task' {} MigrationStatus
a -> Task
s {$sel:status:Task' :: MigrationStatus
status = MigrationStatus
a} :: Task)

instance Core.FromJSON Task where
  parseJSON :: Value -> Parser Task
parseJSON =
    String -> (Object -> Parser Task) -> Value -> Parser Task
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Task"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> MigrationStatus -> Task
Task'
            (Maybe Natural -> Maybe Text -> MigrationStatus -> Task)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> MigrationStatus -> Task)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProgressPercent")
            Parser (Maybe Text -> MigrationStatus -> Task)
-> Parser (Maybe Text) -> Parser (MigrationStatus -> Task)
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
"StatusDetail")
            Parser (MigrationStatus -> Task)
-> Parser MigrationStatus -> Parser Task
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MigrationStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Status")
      )

instance Prelude.Hashable Task

instance Prelude.NFData Task

instance Core.ToJSON Task where
  toJSON :: Task -> Value
toJSON Task' {Maybe Natural
Maybe Text
MigrationStatus
status :: MigrationStatus
statusDetail :: Maybe Text
progressPercent :: Maybe Natural
$sel:status:Task' :: Task -> MigrationStatus
$sel:statusDetail:Task' :: Task -> Maybe Text
$sel:progressPercent:Task' :: Task -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProgressPercent" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
progressPercent,
            (Text
"StatusDetail" 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
statusDetail,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Status" Text -> MigrationStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MigrationStatus
status)
          ]
      )