{-# 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.SnowDeviceManagement.Types.ExecutionSummary
-- 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.SnowDeviceManagement.Types.ExecutionSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SnowDeviceManagement.Types.ExecutionState

-- | The summary of a task execution on a specified device.
--
-- /See:/ 'newExecutionSummary' smart constructor.
data ExecutionSummary = ExecutionSummary'
  { -- | The ID of the execution.
    ExecutionSummary -> Maybe Text
executionId :: Prelude.Maybe Prelude.Text,
    -- | The state of the execution.
    ExecutionSummary -> Maybe ExecutionState
state :: Prelude.Maybe ExecutionState,
    -- | The ID of the task.
    ExecutionSummary -> Maybe Text
taskId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the managed device that the task is being executed on.
    ExecutionSummary -> Maybe Text
managedDeviceId :: Prelude.Maybe Prelude.Text
  }
  deriving (ExecutionSummary -> ExecutionSummary -> Bool
(ExecutionSummary -> ExecutionSummary -> Bool)
-> (ExecutionSummary -> ExecutionSummary -> Bool)
-> Eq ExecutionSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionSummary -> ExecutionSummary -> Bool
$c/= :: ExecutionSummary -> ExecutionSummary -> Bool
== :: ExecutionSummary -> ExecutionSummary -> Bool
$c== :: ExecutionSummary -> ExecutionSummary -> Bool
Prelude.Eq, ReadPrec [ExecutionSummary]
ReadPrec ExecutionSummary
Int -> ReadS ExecutionSummary
ReadS [ExecutionSummary]
(Int -> ReadS ExecutionSummary)
-> ReadS [ExecutionSummary]
-> ReadPrec ExecutionSummary
-> ReadPrec [ExecutionSummary]
-> Read ExecutionSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionSummary]
$creadListPrec :: ReadPrec [ExecutionSummary]
readPrec :: ReadPrec ExecutionSummary
$creadPrec :: ReadPrec ExecutionSummary
readList :: ReadS [ExecutionSummary]
$creadList :: ReadS [ExecutionSummary]
readsPrec :: Int -> ReadS ExecutionSummary
$creadsPrec :: Int -> ReadS ExecutionSummary
Prelude.Read, Int -> ExecutionSummary -> ShowS
[ExecutionSummary] -> ShowS
ExecutionSummary -> String
(Int -> ExecutionSummary -> ShowS)
-> (ExecutionSummary -> String)
-> ([ExecutionSummary] -> ShowS)
-> Show ExecutionSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionSummary] -> ShowS
$cshowList :: [ExecutionSummary] -> ShowS
show :: ExecutionSummary -> String
$cshow :: ExecutionSummary -> String
showsPrec :: Int -> ExecutionSummary -> ShowS
$cshowsPrec :: Int -> ExecutionSummary -> ShowS
Prelude.Show, (forall x. ExecutionSummary -> Rep ExecutionSummary x)
-> (forall x. Rep ExecutionSummary x -> ExecutionSummary)
-> Generic ExecutionSummary
forall x. Rep ExecutionSummary x -> ExecutionSummary
forall x. ExecutionSummary -> Rep ExecutionSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionSummary x -> ExecutionSummary
$cfrom :: forall x. ExecutionSummary -> Rep ExecutionSummary x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionSummary' 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:
--
-- 'executionId', 'executionSummary_executionId' - The ID of the execution.
--
-- 'state', 'executionSummary_state' - The state of the execution.
--
-- 'taskId', 'executionSummary_taskId' - The ID of the task.
--
-- 'managedDeviceId', 'executionSummary_managedDeviceId' - The ID of the managed device that the task is being executed on.
newExecutionSummary ::
  ExecutionSummary
newExecutionSummary :: ExecutionSummary
newExecutionSummary =
  ExecutionSummary' :: Maybe Text
-> Maybe ExecutionState
-> Maybe Text
-> Maybe Text
-> ExecutionSummary
ExecutionSummary'
    { $sel:executionId:ExecutionSummary' :: Maybe Text
executionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:ExecutionSummary' :: Maybe ExecutionState
state = Maybe ExecutionState
forall a. Maybe a
Prelude.Nothing,
      $sel:taskId:ExecutionSummary' :: Maybe Text
taskId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:managedDeviceId:ExecutionSummary' :: Maybe Text
managedDeviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the execution.
executionSummary_executionId :: Lens.Lens' ExecutionSummary (Prelude.Maybe Prelude.Text)
executionSummary_executionId :: (Maybe Text -> f (Maybe Text))
-> ExecutionSummary -> f ExecutionSummary
executionSummary_executionId = (ExecutionSummary -> Maybe Text)
-> (ExecutionSummary -> Maybe Text -> ExecutionSummary)
-> Lens ExecutionSummary ExecutionSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionSummary' {Maybe Text
executionId :: Maybe Text
$sel:executionId:ExecutionSummary' :: ExecutionSummary -> Maybe Text
executionId} -> Maybe Text
executionId) (\s :: ExecutionSummary
s@ExecutionSummary' {} Maybe Text
a -> ExecutionSummary
s {$sel:executionId:ExecutionSummary' :: Maybe Text
executionId = Maybe Text
a} :: ExecutionSummary)

-- | The state of the execution.
executionSummary_state :: Lens.Lens' ExecutionSummary (Prelude.Maybe ExecutionState)
executionSummary_state :: (Maybe ExecutionState -> f (Maybe ExecutionState))
-> ExecutionSummary -> f ExecutionSummary
executionSummary_state = (ExecutionSummary -> Maybe ExecutionState)
-> (ExecutionSummary -> Maybe ExecutionState -> ExecutionSummary)
-> Lens
     ExecutionSummary
     ExecutionSummary
     (Maybe ExecutionState)
     (Maybe ExecutionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionSummary' {Maybe ExecutionState
state :: Maybe ExecutionState
$sel:state:ExecutionSummary' :: ExecutionSummary -> Maybe ExecutionState
state} -> Maybe ExecutionState
state) (\s :: ExecutionSummary
s@ExecutionSummary' {} Maybe ExecutionState
a -> ExecutionSummary
s {$sel:state:ExecutionSummary' :: Maybe ExecutionState
state = Maybe ExecutionState
a} :: ExecutionSummary)

-- | The ID of the task.
executionSummary_taskId :: Lens.Lens' ExecutionSummary (Prelude.Maybe Prelude.Text)
executionSummary_taskId :: (Maybe Text -> f (Maybe Text))
-> ExecutionSummary -> f ExecutionSummary
executionSummary_taskId = (ExecutionSummary -> Maybe Text)
-> (ExecutionSummary -> Maybe Text -> ExecutionSummary)
-> Lens ExecutionSummary ExecutionSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionSummary' {Maybe Text
taskId :: Maybe Text
$sel:taskId:ExecutionSummary' :: ExecutionSummary -> Maybe Text
taskId} -> Maybe Text
taskId) (\s :: ExecutionSummary
s@ExecutionSummary' {} Maybe Text
a -> ExecutionSummary
s {$sel:taskId:ExecutionSummary' :: Maybe Text
taskId = Maybe Text
a} :: ExecutionSummary)

-- | The ID of the managed device that the task is being executed on.
executionSummary_managedDeviceId :: Lens.Lens' ExecutionSummary (Prelude.Maybe Prelude.Text)
executionSummary_managedDeviceId :: (Maybe Text -> f (Maybe Text))
-> ExecutionSummary -> f ExecutionSummary
executionSummary_managedDeviceId = (ExecutionSummary -> Maybe Text)
-> (ExecutionSummary -> Maybe Text -> ExecutionSummary)
-> Lens ExecutionSummary ExecutionSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionSummary' {Maybe Text
managedDeviceId :: Maybe Text
$sel:managedDeviceId:ExecutionSummary' :: ExecutionSummary -> Maybe Text
managedDeviceId} -> Maybe Text
managedDeviceId) (\s :: ExecutionSummary
s@ExecutionSummary' {} Maybe Text
a -> ExecutionSummary
s {$sel:managedDeviceId:ExecutionSummary' :: Maybe Text
managedDeviceId = Maybe Text
a} :: ExecutionSummary)

instance Core.FromJSON ExecutionSummary where
  parseJSON :: Value -> Parser ExecutionSummary
parseJSON =
    String
-> (Object -> Parser ExecutionSummary)
-> Value
-> Parser ExecutionSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutionSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe ExecutionState
-> Maybe Text
-> Maybe Text
-> ExecutionSummary
ExecutionSummary'
            (Maybe Text
 -> Maybe ExecutionState
 -> Maybe Text
 -> Maybe Text
 -> ExecutionSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe ExecutionState
      -> Maybe Text -> Maybe Text -> ExecutionSummary)
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
"executionId")
            Parser
  (Maybe ExecutionState
   -> Maybe Text -> Maybe Text -> ExecutionSummary)
-> Parser (Maybe ExecutionState)
-> Parser (Maybe Text -> Maybe Text -> ExecutionSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExecutionState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"state")
            Parser (Maybe Text -> Maybe Text -> ExecutionSummary)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ExecutionSummary)
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 Text -> ExecutionSummary)
-> Parser (Maybe Text) -> Parser ExecutionSummary
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
"managedDeviceId")
      )

instance Prelude.Hashable ExecutionSummary

instance Prelude.NFData ExecutionSummary