{-# 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.CodeStar.Types.ProjectStatus
-- 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.CodeStar.Types.ProjectStatus where

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

-- | An indication of whether a project creation or deletion is failed or
-- successful.
--
-- /See:/ 'newProjectStatus' smart constructor.
data ProjectStatus = ProjectStatus'
  { -- | In the case of a project creation or deletion failure, a reason for the
    -- failure.
    ProjectStatus -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The phase of completion for a project creation or deletion.
    ProjectStatus -> Text
state :: Prelude.Text
  }
  deriving (ProjectStatus -> ProjectStatus -> Bool
(ProjectStatus -> ProjectStatus -> Bool)
-> (ProjectStatus -> ProjectStatus -> Bool) -> Eq ProjectStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProjectStatus -> ProjectStatus -> Bool
$c/= :: ProjectStatus -> ProjectStatus -> Bool
== :: ProjectStatus -> ProjectStatus -> Bool
$c== :: ProjectStatus -> ProjectStatus -> Bool
Prelude.Eq, ReadPrec [ProjectStatus]
ReadPrec ProjectStatus
Int -> ReadS ProjectStatus
ReadS [ProjectStatus]
(Int -> ReadS ProjectStatus)
-> ReadS [ProjectStatus]
-> ReadPrec ProjectStatus
-> ReadPrec [ProjectStatus]
-> Read ProjectStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProjectStatus]
$creadListPrec :: ReadPrec [ProjectStatus]
readPrec :: ReadPrec ProjectStatus
$creadPrec :: ReadPrec ProjectStatus
readList :: ReadS [ProjectStatus]
$creadList :: ReadS [ProjectStatus]
readsPrec :: Int -> ReadS ProjectStatus
$creadsPrec :: Int -> ReadS ProjectStatus
Prelude.Read, Int -> ProjectStatus -> ShowS
[ProjectStatus] -> ShowS
ProjectStatus -> String
(Int -> ProjectStatus -> ShowS)
-> (ProjectStatus -> String)
-> ([ProjectStatus] -> ShowS)
-> Show ProjectStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProjectStatus] -> ShowS
$cshowList :: [ProjectStatus] -> ShowS
show :: ProjectStatus -> String
$cshow :: ProjectStatus -> String
showsPrec :: Int -> ProjectStatus -> ShowS
$cshowsPrec :: Int -> ProjectStatus -> ShowS
Prelude.Show, (forall x. ProjectStatus -> Rep ProjectStatus x)
-> (forall x. Rep ProjectStatus x -> ProjectStatus)
-> Generic ProjectStatus
forall x. Rep ProjectStatus x -> ProjectStatus
forall x. ProjectStatus -> Rep ProjectStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProjectStatus x -> ProjectStatus
$cfrom :: forall x. ProjectStatus -> Rep ProjectStatus x
Prelude.Generic)

-- |
-- Create a value of 'ProjectStatus' 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:
--
-- 'reason', 'projectStatus_reason' - In the case of a project creation or deletion failure, a reason for the
-- failure.
--
-- 'state', 'projectStatus_state' - The phase of completion for a project creation or deletion.
newProjectStatus ::
  -- | 'state'
  Prelude.Text ->
  ProjectStatus
newProjectStatus :: Text -> ProjectStatus
newProjectStatus Text
pState_ =
  ProjectStatus' :: Maybe Text -> Text -> ProjectStatus
ProjectStatus'
    { $sel:reason:ProjectStatus' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:ProjectStatus' :: Text
state = Text
pState_
    }

-- | In the case of a project creation or deletion failure, a reason for the
-- failure.
projectStatus_reason :: Lens.Lens' ProjectStatus (Prelude.Maybe Prelude.Text)
projectStatus_reason :: (Maybe Text -> f (Maybe Text)) -> ProjectStatus -> f ProjectStatus
projectStatus_reason = (ProjectStatus -> Maybe Text)
-> (ProjectStatus -> Maybe Text -> ProjectStatus)
-> Lens ProjectStatus ProjectStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectStatus' {Maybe Text
reason :: Maybe Text
$sel:reason:ProjectStatus' :: ProjectStatus -> Maybe Text
reason} -> Maybe Text
reason) (\s :: ProjectStatus
s@ProjectStatus' {} Maybe Text
a -> ProjectStatus
s {$sel:reason:ProjectStatus' :: Maybe Text
reason = Maybe Text
a} :: ProjectStatus)

-- | The phase of completion for a project creation or deletion.
projectStatus_state :: Lens.Lens' ProjectStatus Prelude.Text
projectStatus_state :: (Text -> f Text) -> ProjectStatus -> f ProjectStatus
projectStatus_state = (ProjectStatus -> Text)
-> (ProjectStatus -> Text -> ProjectStatus)
-> Lens ProjectStatus ProjectStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectStatus' {Text
state :: Text
$sel:state:ProjectStatus' :: ProjectStatus -> Text
state} -> Text
state) (\s :: ProjectStatus
s@ProjectStatus' {} Text
a -> ProjectStatus
s {$sel:state:ProjectStatus' :: Text
state = Text
a} :: ProjectStatus)

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

instance Prelude.Hashable ProjectStatus

instance Prelude.NFData ProjectStatus