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

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

-- | 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
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]
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
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. 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'
    { $sel:reason:ProjectStatus' :: Maybe Text
reason = 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 :: Lens' ProjectStatus (Maybe Text)
projectStatus_reason = 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 :: Lens' ProjectStatus Text
projectStatus_state = 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 Data.FromJSON ProjectStatus where
  parseJSON :: Value -> Parser ProjectStatus
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProjectStatus"
      ( \Object
x ->
          Maybe Text -> Text -> ProjectStatus
ProjectStatus'
            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
"reason")
            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
"state")
      )

instance Prelude.Hashable ProjectStatus where
  hashWithSalt :: Int -> ProjectStatus -> Int
hashWithSalt Int
_salt ProjectStatus' {Maybe Text
Text
state :: Text
reason :: Maybe Text
$sel:state:ProjectStatus' :: ProjectStatus -> Text
$sel:reason:ProjectStatus' :: ProjectStatus -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
state

instance Prelude.NFData ProjectStatus where
  rnf :: ProjectStatus -> ()
rnf ProjectStatus' {Maybe Text
Text
state :: Text
reason :: Maybe Text
$sel:state:ProjectStatus' :: ProjectStatus -> Text
$sel:reason:ProjectStatus' :: ProjectStatus -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
state