{-# 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.Cloud9.Types.EnvironmentLifecycle
-- 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.Cloud9.Types.EnvironmentLifecycle where

import Amazonka.Cloud9.Types.EnvironmentLifecycleStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the current creation or deletion lifecycle state of an
-- Cloud9 development environment.
--
-- /See:/ 'newEnvironmentLifecycle' smart constructor.
data EnvironmentLifecycle = EnvironmentLifecycle'
  { -- | The current creation or deletion lifecycle state of the environment.
    --
    -- -   @CREATING@: The environment is in the process of being created.
    --
    -- -   @CREATED@: The environment was successfully created.
    --
    -- -   @CREATE_FAILED@: The environment failed to be created.
    --
    -- -   @DELETING@: The environment is in the process of being deleted.
    --
    -- -   @DELETE_FAILED@: The environment failed to delete.
    EnvironmentLifecycle -> Maybe EnvironmentLifecycleStatus
status :: Prelude.Maybe EnvironmentLifecycleStatus,
    -- | If the environment failed to delete, the Amazon Resource Name (ARN) of
    -- the related Amazon Web Services resource.
    EnvironmentLifecycle -> Maybe Text
failureResource :: Prelude.Maybe Prelude.Text,
    -- | Any informational message about the lifecycle state of the environment.
    EnvironmentLifecycle -> Maybe Text
reason :: Prelude.Maybe Prelude.Text
  }
  deriving (EnvironmentLifecycle -> EnvironmentLifecycle -> Bool
(EnvironmentLifecycle -> EnvironmentLifecycle -> Bool)
-> (EnvironmentLifecycle -> EnvironmentLifecycle -> Bool)
-> Eq EnvironmentLifecycle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentLifecycle -> EnvironmentLifecycle -> Bool
$c/= :: EnvironmentLifecycle -> EnvironmentLifecycle -> Bool
== :: EnvironmentLifecycle -> EnvironmentLifecycle -> Bool
$c== :: EnvironmentLifecycle -> EnvironmentLifecycle -> Bool
Prelude.Eq, ReadPrec [EnvironmentLifecycle]
ReadPrec EnvironmentLifecycle
Int -> ReadS EnvironmentLifecycle
ReadS [EnvironmentLifecycle]
(Int -> ReadS EnvironmentLifecycle)
-> ReadS [EnvironmentLifecycle]
-> ReadPrec EnvironmentLifecycle
-> ReadPrec [EnvironmentLifecycle]
-> Read EnvironmentLifecycle
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnvironmentLifecycle]
$creadListPrec :: ReadPrec [EnvironmentLifecycle]
readPrec :: ReadPrec EnvironmentLifecycle
$creadPrec :: ReadPrec EnvironmentLifecycle
readList :: ReadS [EnvironmentLifecycle]
$creadList :: ReadS [EnvironmentLifecycle]
readsPrec :: Int -> ReadS EnvironmentLifecycle
$creadsPrec :: Int -> ReadS EnvironmentLifecycle
Prelude.Read, Int -> EnvironmentLifecycle -> ShowS
[EnvironmentLifecycle] -> ShowS
EnvironmentLifecycle -> String
(Int -> EnvironmentLifecycle -> ShowS)
-> (EnvironmentLifecycle -> String)
-> ([EnvironmentLifecycle] -> ShowS)
-> Show EnvironmentLifecycle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentLifecycle] -> ShowS
$cshowList :: [EnvironmentLifecycle] -> ShowS
show :: EnvironmentLifecycle -> String
$cshow :: EnvironmentLifecycle -> String
showsPrec :: Int -> EnvironmentLifecycle -> ShowS
$cshowsPrec :: Int -> EnvironmentLifecycle -> ShowS
Prelude.Show, (forall x. EnvironmentLifecycle -> Rep EnvironmentLifecycle x)
-> (forall x. Rep EnvironmentLifecycle x -> EnvironmentLifecycle)
-> Generic EnvironmentLifecycle
forall x. Rep EnvironmentLifecycle x -> EnvironmentLifecycle
forall x. EnvironmentLifecycle -> Rep EnvironmentLifecycle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentLifecycle x -> EnvironmentLifecycle
$cfrom :: forall x. EnvironmentLifecycle -> Rep EnvironmentLifecycle x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentLifecycle' 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:
--
-- 'status', 'environmentLifecycle_status' - The current creation or deletion lifecycle state of the environment.
--
-- -   @CREATING@: The environment is in the process of being created.
--
-- -   @CREATED@: The environment was successfully created.
--
-- -   @CREATE_FAILED@: The environment failed to be created.
--
-- -   @DELETING@: The environment is in the process of being deleted.
--
-- -   @DELETE_FAILED@: The environment failed to delete.
--
-- 'failureResource', 'environmentLifecycle_failureResource' - If the environment failed to delete, the Amazon Resource Name (ARN) of
-- the related Amazon Web Services resource.
--
-- 'reason', 'environmentLifecycle_reason' - Any informational message about the lifecycle state of the environment.
newEnvironmentLifecycle ::
  EnvironmentLifecycle
newEnvironmentLifecycle :: EnvironmentLifecycle
newEnvironmentLifecycle =
  EnvironmentLifecycle' :: Maybe EnvironmentLifecycleStatus
-> Maybe Text -> Maybe Text -> EnvironmentLifecycle
EnvironmentLifecycle'
    { $sel:status:EnvironmentLifecycle' :: Maybe EnvironmentLifecycleStatus
status = Maybe EnvironmentLifecycleStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:failureResource:EnvironmentLifecycle' :: Maybe Text
failureResource = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:EnvironmentLifecycle' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The current creation or deletion lifecycle state of the environment.
--
-- -   @CREATING@: The environment is in the process of being created.
--
-- -   @CREATED@: The environment was successfully created.
--
-- -   @CREATE_FAILED@: The environment failed to be created.
--
-- -   @DELETING@: The environment is in the process of being deleted.
--
-- -   @DELETE_FAILED@: The environment failed to delete.
environmentLifecycle_status :: Lens.Lens' EnvironmentLifecycle (Prelude.Maybe EnvironmentLifecycleStatus)
environmentLifecycle_status :: (Maybe EnvironmentLifecycleStatus
 -> f (Maybe EnvironmentLifecycleStatus))
-> EnvironmentLifecycle -> f EnvironmentLifecycle
environmentLifecycle_status = (EnvironmentLifecycle -> Maybe EnvironmentLifecycleStatus)
-> (EnvironmentLifecycle
    -> Maybe EnvironmentLifecycleStatus -> EnvironmentLifecycle)
-> Lens
     EnvironmentLifecycle
     EnvironmentLifecycle
     (Maybe EnvironmentLifecycleStatus)
     (Maybe EnvironmentLifecycleStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentLifecycle' {Maybe EnvironmentLifecycleStatus
status :: Maybe EnvironmentLifecycleStatus
$sel:status:EnvironmentLifecycle' :: EnvironmentLifecycle -> Maybe EnvironmentLifecycleStatus
status} -> Maybe EnvironmentLifecycleStatus
status) (\s :: EnvironmentLifecycle
s@EnvironmentLifecycle' {} Maybe EnvironmentLifecycleStatus
a -> EnvironmentLifecycle
s {$sel:status:EnvironmentLifecycle' :: Maybe EnvironmentLifecycleStatus
status = Maybe EnvironmentLifecycleStatus
a} :: EnvironmentLifecycle)

-- | If the environment failed to delete, the Amazon Resource Name (ARN) of
-- the related Amazon Web Services resource.
environmentLifecycle_failureResource :: Lens.Lens' EnvironmentLifecycle (Prelude.Maybe Prelude.Text)
environmentLifecycle_failureResource :: (Maybe Text -> f (Maybe Text))
-> EnvironmentLifecycle -> f EnvironmentLifecycle
environmentLifecycle_failureResource = (EnvironmentLifecycle -> Maybe Text)
-> (EnvironmentLifecycle -> Maybe Text -> EnvironmentLifecycle)
-> Lens
     EnvironmentLifecycle EnvironmentLifecycle (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentLifecycle' {Maybe Text
failureResource :: Maybe Text
$sel:failureResource:EnvironmentLifecycle' :: EnvironmentLifecycle -> Maybe Text
failureResource} -> Maybe Text
failureResource) (\s :: EnvironmentLifecycle
s@EnvironmentLifecycle' {} Maybe Text
a -> EnvironmentLifecycle
s {$sel:failureResource:EnvironmentLifecycle' :: Maybe Text
failureResource = Maybe Text
a} :: EnvironmentLifecycle)

-- | Any informational message about the lifecycle state of the environment.
environmentLifecycle_reason :: Lens.Lens' EnvironmentLifecycle (Prelude.Maybe Prelude.Text)
environmentLifecycle_reason :: (Maybe Text -> f (Maybe Text))
-> EnvironmentLifecycle -> f EnvironmentLifecycle
environmentLifecycle_reason = (EnvironmentLifecycle -> Maybe Text)
-> (EnvironmentLifecycle -> Maybe Text -> EnvironmentLifecycle)
-> Lens
     EnvironmentLifecycle EnvironmentLifecycle (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentLifecycle' {Maybe Text
reason :: Maybe Text
$sel:reason:EnvironmentLifecycle' :: EnvironmentLifecycle -> Maybe Text
reason} -> Maybe Text
reason) (\s :: EnvironmentLifecycle
s@EnvironmentLifecycle' {} Maybe Text
a -> EnvironmentLifecycle
s {$sel:reason:EnvironmentLifecycle' :: Maybe Text
reason = Maybe Text
a} :: EnvironmentLifecycle)

instance Core.FromJSON EnvironmentLifecycle where
  parseJSON :: Value -> Parser EnvironmentLifecycle
parseJSON =
    String
-> (Object -> Parser EnvironmentLifecycle)
-> Value
-> Parser EnvironmentLifecycle
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EnvironmentLifecycle"
      ( \Object
x ->
          Maybe EnvironmentLifecycleStatus
-> Maybe Text -> Maybe Text -> EnvironmentLifecycle
EnvironmentLifecycle'
            (Maybe EnvironmentLifecycleStatus
 -> Maybe Text -> Maybe Text -> EnvironmentLifecycle)
-> Parser (Maybe EnvironmentLifecycleStatus)
-> Parser (Maybe Text -> Maybe Text -> EnvironmentLifecycle)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EnvironmentLifecycleStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser (Maybe Text -> Maybe Text -> EnvironmentLifecycle)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> EnvironmentLifecycle)
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
"failureResource")
            Parser (Maybe Text -> EnvironmentLifecycle)
-> Parser (Maybe Text) -> Parser EnvironmentLifecycle
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
"reason")
      )

instance Prelude.Hashable EnvironmentLifecycle

instance Prelude.NFData EnvironmentLifecycle