{-# 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.DataPipeline.Types.TaskObject
-- 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.DataPipeline.Types.TaskObject where

import qualified Amazonka.Core as Core
import Amazonka.DataPipeline.Types.PipelineObject
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a pipeline task that is assigned to a task
-- runner.
--
-- /See:/ 'newTaskObject' smart constructor.
data TaskObject = TaskObject'
  { -- | The ID of the pipeline that provided the task.
    TaskObject -> Maybe Text
pipelineId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the pipeline task attempt object. AWS Data Pipeline uses this
    -- value to track how many times a task is attempted.
    TaskObject -> Maybe Text
attemptId :: Prelude.Maybe Prelude.Text,
    -- | An internal identifier for the task. This ID is passed to the
    -- SetTaskStatus and ReportTaskProgress actions.
    TaskObject -> Maybe Text
taskId :: Prelude.Maybe Prelude.Text,
    -- | Connection information for the location where the task runner will
    -- publish the output of the task.
    TaskObject -> Maybe (HashMap Text PipelineObject)
objects :: Prelude.Maybe (Prelude.HashMap Prelude.Text PipelineObject)
  }
  deriving (TaskObject -> TaskObject -> Bool
(TaskObject -> TaskObject -> Bool)
-> (TaskObject -> TaskObject -> Bool) -> Eq TaskObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaskObject -> TaskObject -> Bool
$c/= :: TaskObject -> TaskObject -> Bool
== :: TaskObject -> TaskObject -> Bool
$c== :: TaskObject -> TaskObject -> Bool
Prelude.Eq, ReadPrec [TaskObject]
ReadPrec TaskObject
Int -> ReadS TaskObject
ReadS [TaskObject]
(Int -> ReadS TaskObject)
-> ReadS [TaskObject]
-> ReadPrec TaskObject
-> ReadPrec [TaskObject]
-> Read TaskObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TaskObject]
$creadListPrec :: ReadPrec [TaskObject]
readPrec :: ReadPrec TaskObject
$creadPrec :: ReadPrec TaskObject
readList :: ReadS [TaskObject]
$creadList :: ReadS [TaskObject]
readsPrec :: Int -> ReadS TaskObject
$creadsPrec :: Int -> ReadS TaskObject
Prelude.Read, Int -> TaskObject -> ShowS
[TaskObject] -> ShowS
TaskObject -> String
(Int -> TaskObject -> ShowS)
-> (TaskObject -> String)
-> ([TaskObject] -> ShowS)
-> Show TaskObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaskObject] -> ShowS
$cshowList :: [TaskObject] -> ShowS
show :: TaskObject -> String
$cshow :: TaskObject -> String
showsPrec :: Int -> TaskObject -> ShowS
$cshowsPrec :: Int -> TaskObject -> ShowS
Prelude.Show, (forall x. TaskObject -> Rep TaskObject x)
-> (forall x. Rep TaskObject x -> TaskObject) -> Generic TaskObject
forall x. Rep TaskObject x -> TaskObject
forall x. TaskObject -> Rep TaskObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TaskObject x -> TaskObject
$cfrom :: forall x. TaskObject -> Rep TaskObject x
Prelude.Generic)

-- |
-- Create a value of 'TaskObject' 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:
--
-- 'pipelineId', 'taskObject_pipelineId' - The ID of the pipeline that provided the task.
--
-- 'attemptId', 'taskObject_attemptId' - The ID of the pipeline task attempt object. AWS Data Pipeline uses this
-- value to track how many times a task is attempted.
--
-- 'taskId', 'taskObject_taskId' - An internal identifier for the task. This ID is passed to the
-- SetTaskStatus and ReportTaskProgress actions.
--
-- 'objects', 'taskObject_objects' - Connection information for the location where the task runner will
-- publish the output of the task.
newTaskObject ::
  TaskObject
newTaskObject :: TaskObject
newTaskObject =
  TaskObject' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text PipelineObject)
-> TaskObject
TaskObject'
    { $sel:pipelineId:TaskObject' :: Maybe Text
pipelineId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attemptId:TaskObject' :: Maybe Text
attemptId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:taskId:TaskObject' :: Maybe Text
taskId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:objects:TaskObject' :: Maybe (HashMap Text PipelineObject)
objects = Maybe (HashMap Text PipelineObject)
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the pipeline that provided the task.
taskObject_pipelineId :: Lens.Lens' TaskObject (Prelude.Maybe Prelude.Text)
taskObject_pipelineId :: (Maybe Text -> f (Maybe Text)) -> TaskObject -> f TaskObject
taskObject_pipelineId = (TaskObject -> Maybe Text)
-> (TaskObject -> Maybe Text -> TaskObject)
-> Lens TaskObject TaskObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskObject' {Maybe Text
pipelineId :: Maybe Text
$sel:pipelineId:TaskObject' :: TaskObject -> Maybe Text
pipelineId} -> Maybe Text
pipelineId) (\s :: TaskObject
s@TaskObject' {} Maybe Text
a -> TaskObject
s {$sel:pipelineId:TaskObject' :: Maybe Text
pipelineId = Maybe Text
a} :: TaskObject)

-- | The ID of the pipeline task attempt object. AWS Data Pipeline uses this
-- value to track how many times a task is attempted.
taskObject_attemptId :: Lens.Lens' TaskObject (Prelude.Maybe Prelude.Text)
taskObject_attemptId :: (Maybe Text -> f (Maybe Text)) -> TaskObject -> f TaskObject
taskObject_attemptId = (TaskObject -> Maybe Text)
-> (TaskObject -> Maybe Text -> TaskObject)
-> Lens TaskObject TaskObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskObject' {Maybe Text
attemptId :: Maybe Text
$sel:attemptId:TaskObject' :: TaskObject -> Maybe Text
attemptId} -> Maybe Text
attemptId) (\s :: TaskObject
s@TaskObject' {} Maybe Text
a -> TaskObject
s {$sel:attemptId:TaskObject' :: Maybe Text
attemptId = Maybe Text
a} :: TaskObject)

-- | An internal identifier for the task. This ID is passed to the
-- SetTaskStatus and ReportTaskProgress actions.
taskObject_taskId :: Lens.Lens' TaskObject (Prelude.Maybe Prelude.Text)
taskObject_taskId :: (Maybe Text -> f (Maybe Text)) -> TaskObject -> f TaskObject
taskObject_taskId = (TaskObject -> Maybe Text)
-> (TaskObject -> Maybe Text -> TaskObject)
-> Lens TaskObject TaskObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskObject' {Maybe Text
taskId :: Maybe Text
$sel:taskId:TaskObject' :: TaskObject -> Maybe Text
taskId} -> Maybe Text
taskId) (\s :: TaskObject
s@TaskObject' {} Maybe Text
a -> TaskObject
s {$sel:taskId:TaskObject' :: Maybe Text
taskId = Maybe Text
a} :: TaskObject)

-- | Connection information for the location where the task runner will
-- publish the output of the task.
taskObject_objects :: Lens.Lens' TaskObject (Prelude.Maybe (Prelude.HashMap Prelude.Text PipelineObject))
taskObject_objects :: (Maybe (HashMap Text PipelineObject)
 -> f (Maybe (HashMap Text PipelineObject)))
-> TaskObject -> f TaskObject
taskObject_objects = (TaskObject -> Maybe (HashMap Text PipelineObject))
-> (TaskObject
    -> Maybe (HashMap Text PipelineObject) -> TaskObject)
-> Lens
     TaskObject
     TaskObject
     (Maybe (HashMap Text PipelineObject))
     (Maybe (HashMap Text PipelineObject))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskObject' {Maybe (HashMap Text PipelineObject)
objects :: Maybe (HashMap Text PipelineObject)
$sel:objects:TaskObject' :: TaskObject -> Maybe (HashMap Text PipelineObject)
objects} -> Maybe (HashMap Text PipelineObject)
objects) (\s :: TaskObject
s@TaskObject' {} Maybe (HashMap Text PipelineObject)
a -> TaskObject
s {$sel:objects:TaskObject' :: Maybe (HashMap Text PipelineObject)
objects = Maybe (HashMap Text PipelineObject)
a} :: TaskObject) ((Maybe (HashMap Text PipelineObject)
  -> f (Maybe (HashMap Text PipelineObject)))
 -> TaskObject -> f TaskObject)
-> ((Maybe (HashMap Text PipelineObject)
     -> f (Maybe (HashMap Text PipelineObject)))
    -> Maybe (HashMap Text PipelineObject)
    -> f (Maybe (HashMap Text PipelineObject)))
-> (Maybe (HashMap Text PipelineObject)
    -> f (Maybe (HashMap Text PipelineObject)))
-> TaskObject
-> f TaskObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text PipelineObject)
  (HashMap Text PipelineObject)
  (HashMap Text PipelineObject)
  (HashMap Text PipelineObject)
-> Iso
     (Maybe (HashMap Text PipelineObject))
     (Maybe (HashMap Text PipelineObject))
     (Maybe (HashMap Text PipelineObject))
     (Maybe (HashMap Text PipelineObject))
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 AnIso
  (HashMap Text PipelineObject)
  (HashMap Text PipelineObject)
  (HashMap Text PipelineObject)
  (HashMap Text PipelineObject)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON TaskObject where
  parseJSON :: Value -> Parser TaskObject
parseJSON =
    String
-> (Object -> Parser TaskObject) -> Value -> Parser TaskObject
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TaskObject"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text PipelineObject)
-> TaskObject
TaskObject'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text PipelineObject)
 -> TaskObject)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe (HashMap Text PipelineObject) -> TaskObject)
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
"pipelineId")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe (HashMap Text PipelineObject) -> TaskObject)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe (HashMap Text PipelineObject) -> TaskObject)
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
"attemptId")
            Parser
  (Maybe Text -> Maybe (HashMap Text PipelineObject) -> TaskObject)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text PipelineObject) -> TaskObject)
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
"taskId")
            Parser (Maybe (HashMap Text PipelineObject) -> TaskObject)
-> Parser (Maybe (HashMap Text PipelineObject))
-> Parser TaskObject
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text PipelineObject)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"objects" Parser (Maybe (Maybe (HashMap Text PipelineObject)))
-> Maybe (HashMap Text PipelineObject)
-> Parser (Maybe (HashMap Text PipelineObject))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text PipelineObject)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TaskObject

instance Prelude.NFData TaskObject