{-# 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.CodeBuild.Types.PhaseContext
-- 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.CodeBuild.Types.PhaseContext where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Additional information about a build phase that has an error. You can
-- use this information for troubleshooting.
--
-- /See:/ 'newPhaseContext' smart constructor.
data PhaseContext = PhaseContext'
  { -- | An explanation of the build phase\'s context. This might include a
    -- command ID and an exit code.
    PhaseContext -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The status code for the context of the build phase.
    PhaseContext -> Maybe Text
statusCode :: Prelude.Maybe Prelude.Text
  }
  deriving (PhaseContext -> PhaseContext -> Bool
(PhaseContext -> PhaseContext -> Bool)
-> (PhaseContext -> PhaseContext -> Bool) -> Eq PhaseContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhaseContext -> PhaseContext -> Bool
$c/= :: PhaseContext -> PhaseContext -> Bool
== :: PhaseContext -> PhaseContext -> Bool
$c== :: PhaseContext -> PhaseContext -> Bool
Prelude.Eq, ReadPrec [PhaseContext]
ReadPrec PhaseContext
Int -> ReadS PhaseContext
ReadS [PhaseContext]
(Int -> ReadS PhaseContext)
-> ReadS [PhaseContext]
-> ReadPrec PhaseContext
-> ReadPrec [PhaseContext]
-> Read PhaseContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhaseContext]
$creadListPrec :: ReadPrec [PhaseContext]
readPrec :: ReadPrec PhaseContext
$creadPrec :: ReadPrec PhaseContext
readList :: ReadS [PhaseContext]
$creadList :: ReadS [PhaseContext]
readsPrec :: Int -> ReadS PhaseContext
$creadsPrec :: Int -> ReadS PhaseContext
Prelude.Read, Int -> PhaseContext -> ShowS
[PhaseContext] -> ShowS
PhaseContext -> String
(Int -> PhaseContext -> ShowS)
-> (PhaseContext -> String)
-> ([PhaseContext] -> ShowS)
-> Show PhaseContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhaseContext] -> ShowS
$cshowList :: [PhaseContext] -> ShowS
show :: PhaseContext -> String
$cshow :: PhaseContext -> String
showsPrec :: Int -> PhaseContext -> ShowS
$cshowsPrec :: Int -> PhaseContext -> ShowS
Prelude.Show, (forall x. PhaseContext -> Rep PhaseContext x)
-> (forall x. Rep PhaseContext x -> PhaseContext)
-> Generic PhaseContext
forall x. Rep PhaseContext x -> PhaseContext
forall x. PhaseContext -> Rep PhaseContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhaseContext x -> PhaseContext
$cfrom :: forall x. PhaseContext -> Rep PhaseContext x
Prelude.Generic)

-- |
-- Create a value of 'PhaseContext' 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:
--
-- 'message', 'phaseContext_message' - An explanation of the build phase\'s context. This might include a
-- command ID and an exit code.
--
-- 'statusCode', 'phaseContext_statusCode' - The status code for the context of the build phase.
newPhaseContext ::
  PhaseContext
newPhaseContext :: PhaseContext
newPhaseContext =
  PhaseContext' :: Maybe Text -> Maybe Text -> PhaseContext
PhaseContext'
    { $sel:message:PhaseContext' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusCode:PhaseContext' :: Maybe Text
statusCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An explanation of the build phase\'s context. This might include a
-- command ID and an exit code.
phaseContext_message :: Lens.Lens' PhaseContext (Prelude.Maybe Prelude.Text)
phaseContext_message :: (Maybe Text -> f (Maybe Text)) -> PhaseContext -> f PhaseContext
phaseContext_message = (PhaseContext -> Maybe Text)
-> (PhaseContext -> Maybe Text -> PhaseContext)
-> Lens PhaseContext PhaseContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhaseContext' {Maybe Text
message :: Maybe Text
$sel:message:PhaseContext' :: PhaseContext -> Maybe Text
message} -> Maybe Text
message) (\s :: PhaseContext
s@PhaseContext' {} Maybe Text
a -> PhaseContext
s {$sel:message:PhaseContext' :: Maybe Text
message = Maybe Text
a} :: PhaseContext)

-- | The status code for the context of the build phase.
phaseContext_statusCode :: Lens.Lens' PhaseContext (Prelude.Maybe Prelude.Text)
phaseContext_statusCode :: (Maybe Text -> f (Maybe Text)) -> PhaseContext -> f PhaseContext
phaseContext_statusCode = (PhaseContext -> Maybe Text)
-> (PhaseContext -> Maybe Text -> PhaseContext)
-> Lens PhaseContext PhaseContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhaseContext' {Maybe Text
statusCode :: Maybe Text
$sel:statusCode:PhaseContext' :: PhaseContext -> Maybe Text
statusCode} -> Maybe Text
statusCode) (\s :: PhaseContext
s@PhaseContext' {} Maybe Text
a -> PhaseContext
s {$sel:statusCode:PhaseContext' :: Maybe Text
statusCode = Maybe Text
a} :: PhaseContext)

instance Core.FromJSON PhaseContext where
  parseJSON :: Value -> Parser PhaseContext
parseJSON =
    String
-> (Object -> Parser PhaseContext) -> Value -> Parser PhaseContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PhaseContext"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> PhaseContext
PhaseContext'
            (Maybe Text -> Maybe Text -> PhaseContext)
-> Parser (Maybe Text) -> Parser (Maybe Text -> PhaseContext)
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
"message")
            Parser (Maybe Text -> PhaseContext)
-> Parser (Maybe Text) -> Parser PhaseContext
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
"statusCode")
      )

instance Prelude.Hashable PhaseContext

instance Prelude.NFData PhaseContext