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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataPipeline.Types.PipelineObject
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 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,
    -- | 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),
    -- | The ID of the pipeline that provided the task.
    TaskObject -> Maybe Text
pipelineId :: 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
  }
  deriving (TaskObject -> TaskObject -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'objects', 'taskObject_objects' - Connection information for the location where the task runner will
-- publish the output of the task.
--
-- 'pipelineId', 'taskObject_pipelineId' - The ID of the pipeline that provided the task.
--
-- 'taskId', 'taskObject_taskId' - An internal identifier for the task. This ID is passed to the
-- SetTaskStatus and ReportTaskProgress actions.
newTaskObject ::
  TaskObject
newTaskObject :: TaskObject
newTaskObject =
  TaskObject'
    { $sel:attemptId:TaskObject' :: Maybe Text
attemptId = forall a. Maybe a
Prelude.Nothing,
      $sel:objects:TaskObject' :: Maybe (HashMap Text PipelineObject)
objects = forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineId:TaskObject' :: Maybe Text
pipelineId = forall a. Maybe a
Prelude.Nothing,
      $sel:taskId:TaskObject' :: Maybe Text
taskId = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' TaskObject (Maybe Text)
taskObject_attemptId = 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)

-- | 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 :: Lens' TaskObject (Maybe (HashMap Text PipelineObject))
taskObject_objects = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the pipeline that provided the task.
taskObject_pipelineId :: Lens.Lens' TaskObject (Prelude.Maybe Prelude.Text)
taskObject_pipelineId :: Lens' TaskObject (Maybe Text)
taskObject_pipelineId = 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)

-- | 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 :: Lens' TaskObject (Maybe Text)
taskObject_taskId = 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)

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

instance Prelude.Hashable TaskObject where
  hashWithSalt :: Int -> TaskObject -> Int
hashWithSalt Int
_salt TaskObject' {Maybe Text
Maybe (HashMap Text PipelineObject)
taskId :: Maybe Text
pipelineId :: Maybe Text
objects :: Maybe (HashMap Text PipelineObject)
attemptId :: Maybe Text
$sel:taskId:TaskObject' :: TaskObject -> Maybe Text
$sel:pipelineId:TaskObject' :: TaskObject -> Maybe Text
$sel:objects:TaskObject' :: TaskObject -> Maybe (HashMap Text PipelineObject)
$sel:attemptId:TaskObject' :: TaskObject -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attemptId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text PipelineObject)
objects
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pipelineId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
taskId

instance Prelude.NFData TaskObject where
  rnf :: TaskObject -> ()
rnf TaskObject' {Maybe Text
Maybe (HashMap Text PipelineObject)
taskId :: Maybe Text
pipelineId :: Maybe Text
objects :: Maybe (HashMap Text PipelineObject)
attemptId :: Maybe Text
$sel:taskId:TaskObject' :: TaskObject -> Maybe Text
$sel:pipelineId:TaskObject' :: TaskObject -> Maybe Text
$sel:objects:TaskObject' :: TaskObject -> Maybe (HashMap Text PipelineObject)
$sel:attemptId:TaskObject' :: TaskObject -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attemptId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text PipelineObject)
objects
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pipelineId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
taskId