{-# 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.Amplify.Types.Step
-- 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.Amplify.Types.Step where

import Amazonka.Amplify.Types.JobStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes an execution step, for an execution job, for an Amplify app.
--
-- /See:/ 'newStep' smart constructor.
data Step = Step'
  { -- | The URL to the artifact for the execution step.
    Step -> Maybe Text
artifactsUrl :: Prelude.Maybe Prelude.Text,
    -- | The context for the current step. Includes a build image if the step is
    -- build.
    Step -> Maybe Text
context :: Prelude.Maybe Prelude.Text,
    -- | The URL to the logs for the execution step.
    Step -> Maybe Text
logUrl :: Prelude.Maybe Prelude.Text,
    -- | The list of screenshot URLs for the execution step, if relevant.
    Step -> Maybe (HashMap Text Text)
screenshots :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The reason for the current step status.
    Step -> Maybe Text
statusReason :: Prelude.Maybe Prelude.Text,
    -- | The URL to the test artifact for the execution step.
    Step -> Maybe Text
testArtifactsUrl :: Prelude.Maybe Prelude.Text,
    -- | The URL to the test configuration for the execution step.
    Step -> Maybe Text
testConfigUrl :: Prelude.Maybe Prelude.Text,
    -- | The name of the execution step.
    Step -> Text
stepName :: Prelude.Text,
    -- | The start date and time of the execution step.
    Step -> POSIX
startTime :: Data.POSIX,
    -- | The status of the execution step.
    Step -> JobStatus
status :: JobStatus,
    -- | The end date and time of the execution step.
    Step -> POSIX
endTime :: Data.POSIX
  }
  deriving (Step -> Step -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Step -> Step -> Bool
$c/= :: Step -> Step -> Bool
== :: Step -> Step -> Bool
$c== :: Step -> Step -> Bool
Prelude.Eq, ReadPrec [Step]
ReadPrec Step
Int -> ReadS Step
ReadS [Step]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Step]
$creadListPrec :: ReadPrec [Step]
readPrec :: ReadPrec Step
$creadPrec :: ReadPrec Step
readList :: ReadS [Step]
$creadList :: ReadS [Step]
readsPrec :: Int -> ReadS Step
$creadsPrec :: Int -> ReadS Step
Prelude.Read, Int -> Step -> ShowS
[Step] -> ShowS
Step -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Step] -> ShowS
$cshowList :: [Step] -> ShowS
show :: Step -> String
$cshow :: Step -> String
showsPrec :: Int -> Step -> ShowS
$cshowsPrec :: Int -> Step -> ShowS
Prelude.Show, forall x. Rep Step x -> Step
forall x. Step -> Rep Step x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Step x -> Step
$cfrom :: forall x. Step -> Rep Step x
Prelude.Generic)

-- |
-- Create a value of 'Step' 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:
--
-- 'artifactsUrl', 'step_artifactsUrl' - The URL to the artifact for the execution step.
--
-- 'context', 'step_context' - The context for the current step. Includes a build image if the step is
-- build.
--
-- 'logUrl', 'step_logUrl' - The URL to the logs for the execution step.
--
-- 'screenshots', 'step_screenshots' - The list of screenshot URLs for the execution step, if relevant.
--
-- 'statusReason', 'step_statusReason' - The reason for the current step status.
--
-- 'testArtifactsUrl', 'step_testArtifactsUrl' - The URL to the test artifact for the execution step.
--
-- 'testConfigUrl', 'step_testConfigUrl' - The URL to the test configuration for the execution step.
--
-- 'stepName', 'step_stepName' - The name of the execution step.
--
-- 'startTime', 'step_startTime' - The start date and time of the execution step.
--
-- 'status', 'step_status' - The status of the execution step.
--
-- 'endTime', 'step_endTime' - The end date and time of the execution step.
newStep ::
  -- | 'stepName'
  Prelude.Text ->
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'status'
  JobStatus ->
  -- | 'endTime'
  Prelude.UTCTime ->
  Step
newStep :: Text -> UTCTime -> JobStatus -> UTCTime -> Step
newStep Text
pStepName_ UTCTime
pStartTime_ JobStatus
pStatus_ UTCTime
pEndTime_ =
  Step'
    { $sel:artifactsUrl:Step' :: Maybe Text
artifactsUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:context:Step' :: Maybe Text
context = forall a. Maybe a
Prelude.Nothing,
      $sel:logUrl:Step' :: Maybe Text
logUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:screenshots:Step' :: Maybe (HashMap Text Text)
screenshots = forall a. Maybe a
Prelude.Nothing,
      $sel:statusReason:Step' :: Maybe Text
statusReason = forall a. Maybe a
Prelude.Nothing,
      $sel:testArtifactsUrl:Step' :: Maybe Text
testArtifactsUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:testConfigUrl:Step' :: Maybe Text
testConfigUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:stepName:Step' :: Text
stepName = Text
pStepName_,
      $sel:startTime:Step' :: POSIX
startTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:status:Step' :: JobStatus
status = JobStatus
pStatus_,
      $sel:endTime:Step' :: POSIX
endTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
    }

-- | The URL to the artifact for the execution step.
step_artifactsUrl :: Lens.Lens' Step (Prelude.Maybe Prelude.Text)
step_artifactsUrl :: Lens' Step (Maybe Text)
step_artifactsUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Text
artifactsUrl :: Maybe Text
$sel:artifactsUrl:Step' :: Step -> Maybe Text
artifactsUrl} -> Maybe Text
artifactsUrl) (\s :: Step
s@Step' {} Maybe Text
a -> Step
s {$sel:artifactsUrl:Step' :: Maybe Text
artifactsUrl = Maybe Text
a} :: Step)

-- | The context for the current step. Includes a build image if the step is
-- build.
step_context :: Lens.Lens' Step (Prelude.Maybe Prelude.Text)
step_context :: Lens' Step (Maybe Text)
step_context = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Text
context :: Maybe Text
$sel:context:Step' :: Step -> Maybe Text
context} -> Maybe Text
context) (\s :: Step
s@Step' {} Maybe Text
a -> Step
s {$sel:context:Step' :: Maybe Text
context = Maybe Text
a} :: Step)

-- | The URL to the logs for the execution step.
step_logUrl :: Lens.Lens' Step (Prelude.Maybe Prelude.Text)
step_logUrl :: Lens' Step (Maybe Text)
step_logUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Text
logUrl :: Maybe Text
$sel:logUrl:Step' :: Step -> Maybe Text
logUrl} -> Maybe Text
logUrl) (\s :: Step
s@Step' {} Maybe Text
a -> Step
s {$sel:logUrl:Step' :: Maybe Text
logUrl = Maybe Text
a} :: Step)

-- | The list of screenshot URLs for the execution step, if relevant.
step_screenshots :: Lens.Lens' Step (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
step_screenshots :: Lens' Step (Maybe (HashMap Text Text))
step_screenshots = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe (HashMap Text Text)
screenshots :: Maybe (HashMap Text Text)
$sel:screenshots:Step' :: Step -> Maybe (HashMap Text Text)
screenshots} -> Maybe (HashMap Text Text)
screenshots) (\s :: Step
s@Step' {} Maybe (HashMap Text Text)
a -> Step
s {$sel:screenshots:Step' :: Maybe (HashMap Text Text)
screenshots = Maybe (HashMap Text Text)
a} :: Step) 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 reason for the current step status.
step_statusReason :: Lens.Lens' Step (Prelude.Maybe Prelude.Text)
step_statusReason :: Lens' Step (Maybe Text)
step_statusReason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Text
statusReason :: Maybe Text
$sel:statusReason:Step' :: Step -> Maybe Text
statusReason} -> Maybe Text
statusReason) (\s :: Step
s@Step' {} Maybe Text
a -> Step
s {$sel:statusReason:Step' :: Maybe Text
statusReason = Maybe Text
a} :: Step)

-- | The URL to the test artifact for the execution step.
step_testArtifactsUrl :: Lens.Lens' Step (Prelude.Maybe Prelude.Text)
step_testArtifactsUrl :: Lens' Step (Maybe Text)
step_testArtifactsUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Text
testArtifactsUrl :: Maybe Text
$sel:testArtifactsUrl:Step' :: Step -> Maybe Text
testArtifactsUrl} -> Maybe Text
testArtifactsUrl) (\s :: Step
s@Step' {} Maybe Text
a -> Step
s {$sel:testArtifactsUrl:Step' :: Maybe Text
testArtifactsUrl = Maybe Text
a} :: Step)

-- | The URL to the test configuration for the execution step.
step_testConfigUrl :: Lens.Lens' Step (Prelude.Maybe Prelude.Text)
step_testConfigUrl :: Lens' Step (Maybe Text)
step_testConfigUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Text
testConfigUrl :: Maybe Text
$sel:testConfigUrl:Step' :: Step -> Maybe Text
testConfigUrl} -> Maybe Text
testConfigUrl) (\s :: Step
s@Step' {} Maybe Text
a -> Step
s {$sel:testConfigUrl:Step' :: Maybe Text
testConfigUrl = Maybe Text
a} :: Step)

-- | The name of the execution step.
step_stepName :: Lens.Lens' Step Prelude.Text
step_stepName :: Lens' Step Text
step_stepName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Text
stepName :: Text
$sel:stepName:Step' :: Step -> Text
stepName} -> Text
stepName) (\s :: Step
s@Step' {} Text
a -> Step
s {$sel:stepName:Step' :: Text
stepName = Text
a} :: Step)

-- | The start date and time of the execution step.
step_startTime :: Lens.Lens' Step Prelude.UTCTime
step_startTime :: Lens' Step UTCTime
step_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {POSIX
startTime :: POSIX
$sel:startTime:Step' :: Step -> POSIX
startTime} -> POSIX
startTime) (\s :: Step
s@Step' {} POSIX
a -> Step
s {$sel:startTime:Step' :: POSIX
startTime = POSIX
a} :: Step) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The status of the execution step.
step_status :: Lens.Lens' Step JobStatus
step_status :: Lens' Step JobStatus
step_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {JobStatus
status :: JobStatus
$sel:status:Step' :: Step -> JobStatus
status} -> JobStatus
status) (\s :: Step
s@Step' {} JobStatus
a -> Step
s {$sel:status:Step' :: JobStatus
status = JobStatus
a} :: Step)

-- | The end date and time of the execution step.
step_endTime :: Lens.Lens' Step Prelude.UTCTime
step_endTime :: Lens' Step UTCTime
step_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {POSIX
endTime :: POSIX
$sel:endTime:Step' :: Step -> POSIX
endTime} -> POSIX
endTime) (\s :: Step
s@Step' {} POSIX
a -> Step
s {$sel:endTime:Step' :: POSIX
endTime = POSIX
a} :: Step) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON Step where
  parseJSON :: Value -> Parser Step
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Step"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> POSIX
-> JobStatus
-> POSIX
-> Step
Step'
            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
"artifactsUrl")
            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
"context")
            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
"logUrl")
            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
"screenshots" 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
"statusReason")
            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
"testArtifactsUrl")
            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
"testConfigUrl")
            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
"stepName")
            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
"startTime")
            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")
            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
"endTime")
      )

instance Prelude.Hashable Step where
  hashWithSalt :: Int -> Step -> Int
hashWithSalt Int
_salt Step' {Maybe Text
Maybe (HashMap Text Text)
Text
POSIX
JobStatus
endTime :: POSIX
status :: JobStatus
startTime :: POSIX
stepName :: Text
testConfigUrl :: Maybe Text
testArtifactsUrl :: Maybe Text
statusReason :: Maybe Text
screenshots :: Maybe (HashMap Text Text)
logUrl :: Maybe Text
context :: Maybe Text
artifactsUrl :: Maybe Text
$sel:endTime:Step' :: Step -> POSIX
$sel:status:Step' :: Step -> JobStatus
$sel:startTime:Step' :: Step -> POSIX
$sel:stepName:Step' :: Step -> Text
$sel:testConfigUrl:Step' :: Step -> Maybe Text
$sel:testArtifactsUrl:Step' :: Step -> Maybe Text
$sel:statusReason:Step' :: Step -> Maybe Text
$sel:screenshots:Step' :: Step -> Maybe (HashMap Text Text)
$sel:logUrl:Step' :: Step -> Maybe Text
$sel:context:Step' :: Step -> Maybe Text
$sel:artifactsUrl:Step' :: Step -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
artifactsUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
context
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
screenshots
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
testArtifactsUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
testConfigUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stepName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` JobStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
endTime

instance Prelude.NFData Step where
  rnf :: Step -> ()
rnf Step' {Maybe Text
Maybe (HashMap Text Text)
Text
POSIX
JobStatus
endTime :: POSIX
status :: JobStatus
startTime :: POSIX
stepName :: Text
testConfigUrl :: Maybe Text
testArtifactsUrl :: Maybe Text
statusReason :: Maybe Text
screenshots :: Maybe (HashMap Text Text)
logUrl :: Maybe Text
context :: Maybe Text
artifactsUrl :: Maybe Text
$sel:endTime:Step' :: Step -> POSIX
$sel:status:Step' :: Step -> JobStatus
$sel:startTime:Step' :: Step -> POSIX
$sel:stepName:Step' :: Step -> Text
$sel:testConfigUrl:Step' :: Step -> Maybe Text
$sel:testArtifactsUrl:Step' :: Step -> Maybe Text
$sel:statusReason:Step' :: Step -> Maybe Text
$sel:screenshots:Step' :: Step -> Maybe (HashMap Text Text)
$sel:logUrl:Step' :: Step -> Maybe Text
$sel:context:Step' :: Step -> Maybe Text
$sel:artifactsUrl:Step' :: Step -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
artifactsUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
context
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
screenshots
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
testArtifactsUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
testConfigUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stepName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf JobStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
endTime