{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MigrationHub.Types.Task where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:progressPercent:Task' :: Maybe Natural
progressPercent = forall a. Maybe a
Prelude.Nothing,
      $sel:statusDetail:Task' :: Maybe Text
statusDetail = 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 :: Lens' Task (Maybe Natural)
task_progressPercent = 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 :: Lens' Task (Maybe Text)
task_statusDetail = 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 :: Lens' Task MigrationStatus
task_status = 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 Data.FromJSON Task where
  parseJSON :: Value -> Parser Task
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Task"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> MigrationStatus -> Task
Task'
            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
"ProgressPercent")
            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
"StatusDetail")
            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
"Status")
      )

instance Prelude.Hashable Task where
  hashWithSalt :: Int -> Task -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
progressPercent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusDetail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MigrationStatus
status

instance Prelude.NFData Task where
  rnf :: Task -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
progressPercent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MigrationStatus
status

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ProgressPercent" 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 Natural
progressPercent,
            (Key
"StatusDetail" 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
statusDetail,
            forall a. a -> Maybe a
Prelude.Just (Key
"Status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= MigrationStatus
status)
          ]
      )