{-# 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.AppConfig.Types.Environment
-- 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.AppConfig.Types.Environment where

import Amazonka.AppConfig.Types.EnvironmentState
import Amazonka.AppConfig.Types.Monitor
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newEnvironment' smart constructor.
data Environment = Environment'
  { -- | The state of the environment. An environment can be in one of the
    -- following states: @READY_FOR_DEPLOYMENT@, @DEPLOYING@, @ROLLING_BACK@,
    -- or @ROLLED_BACK@
    Environment -> Maybe EnvironmentState
state :: Prelude.Maybe EnvironmentState,
    -- | Amazon CloudWatch alarms monitored during the deployment.
    Environment -> Maybe [Monitor]
monitors :: Prelude.Maybe [Monitor],
    -- | The application ID.
    Environment -> Maybe Text
applicationId :: Prelude.Maybe Prelude.Text,
    -- | The name of the environment.
    Environment -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The environment ID.
    Environment -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The description of the environment.
    Environment -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (Environment -> Environment -> Bool
(Environment -> Environment -> Bool)
-> (Environment -> Environment -> Bool) -> Eq Environment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Environment -> Environment -> Bool
$c/= :: Environment -> Environment -> Bool
== :: Environment -> Environment -> Bool
$c== :: Environment -> Environment -> Bool
Prelude.Eq, ReadPrec [Environment]
ReadPrec Environment
Int -> ReadS Environment
ReadS [Environment]
(Int -> ReadS Environment)
-> ReadS [Environment]
-> ReadPrec Environment
-> ReadPrec [Environment]
-> Read Environment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Environment]
$creadListPrec :: ReadPrec [Environment]
readPrec :: ReadPrec Environment
$creadPrec :: ReadPrec Environment
readList :: ReadS [Environment]
$creadList :: ReadS [Environment]
readsPrec :: Int -> ReadS Environment
$creadsPrec :: Int -> ReadS Environment
Prelude.Read, Int -> Environment -> ShowS
[Environment] -> ShowS
Environment -> String
(Int -> Environment -> ShowS)
-> (Environment -> String)
-> ([Environment] -> ShowS)
-> Show Environment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Environment] -> ShowS
$cshowList :: [Environment] -> ShowS
show :: Environment -> String
$cshow :: Environment -> String
showsPrec :: Int -> Environment -> ShowS
$cshowsPrec :: Int -> Environment -> ShowS
Prelude.Show, (forall x. Environment -> Rep Environment x)
-> (forall x. Rep Environment x -> Environment)
-> Generic Environment
forall x. Rep Environment x -> Environment
forall x. Environment -> Rep Environment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Environment x -> Environment
$cfrom :: forall x. Environment -> Rep Environment x
Prelude.Generic)

-- |
-- Create a value of 'Environment' 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:
--
-- 'state', 'environment_state' - The state of the environment. An environment can be in one of the
-- following states: @READY_FOR_DEPLOYMENT@, @DEPLOYING@, @ROLLING_BACK@,
-- or @ROLLED_BACK@
--
-- 'monitors', 'environment_monitors' - Amazon CloudWatch alarms monitored during the deployment.
--
-- 'applicationId', 'environment_applicationId' - The application ID.
--
-- 'name', 'environment_name' - The name of the environment.
--
-- 'id', 'environment_id' - The environment ID.
--
-- 'description', 'environment_description' - The description of the environment.
newEnvironment ::
  Environment
newEnvironment :: Environment
newEnvironment =
  Environment' :: Maybe EnvironmentState
-> Maybe [Monitor]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Environment
Environment'
    { $sel:state:Environment' :: Maybe EnvironmentState
state = Maybe EnvironmentState
forall a. Maybe a
Prelude.Nothing,
      $sel:monitors:Environment' :: Maybe [Monitor]
monitors = Maybe [Monitor]
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:Environment' :: Maybe Text
applicationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Environment' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Environment' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Environment' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The state of the environment. An environment can be in one of the
-- following states: @READY_FOR_DEPLOYMENT@, @DEPLOYING@, @ROLLING_BACK@,
-- or @ROLLED_BACK@
environment_state :: Lens.Lens' Environment (Prelude.Maybe EnvironmentState)
environment_state :: (Maybe EnvironmentState -> f (Maybe EnvironmentState))
-> Environment -> f Environment
environment_state = (Environment -> Maybe EnvironmentState)
-> (Environment -> Maybe EnvironmentState -> Environment)
-> Lens
     Environment
     Environment
     (Maybe EnvironmentState)
     (Maybe EnvironmentState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe EnvironmentState
state :: Maybe EnvironmentState
$sel:state:Environment' :: Environment -> Maybe EnvironmentState
state} -> Maybe EnvironmentState
state) (\s :: Environment
s@Environment' {} Maybe EnvironmentState
a -> Environment
s {$sel:state:Environment' :: Maybe EnvironmentState
state = Maybe EnvironmentState
a} :: Environment)

-- | Amazon CloudWatch alarms monitored during the deployment.
environment_monitors :: Lens.Lens' Environment (Prelude.Maybe [Monitor])
environment_monitors :: (Maybe [Monitor] -> f (Maybe [Monitor]))
-> Environment -> f Environment
environment_monitors = (Environment -> Maybe [Monitor])
-> (Environment -> Maybe [Monitor] -> Environment)
-> Lens Environment Environment (Maybe [Monitor]) (Maybe [Monitor])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe [Monitor]
monitors :: Maybe [Monitor]
$sel:monitors:Environment' :: Environment -> Maybe [Monitor]
monitors} -> Maybe [Monitor]
monitors) (\s :: Environment
s@Environment' {} Maybe [Monitor]
a -> Environment
s {$sel:monitors:Environment' :: Maybe [Monitor]
monitors = Maybe [Monitor]
a} :: Environment) ((Maybe [Monitor] -> f (Maybe [Monitor]))
 -> Environment -> f Environment)
-> ((Maybe [Monitor] -> f (Maybe [Monitor]))
    -> Maybe [Monitor] -> f (Maybe [Monitor]))
-> (Maybe [Monitor] -> f (Maybe [Monitor]))
-> Environment
-> f Environment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Monitor] [Monitor] [Monitor] [Monitor]
-> Iso
     (Maybe [Monitor])
     (Maybe [Monitor])
     (Maybe [Monitor])
     (Maybe [Monitor])
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 AnIso [Monitor] [Monitor] [Monitor] [Monitor]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The application ID.
environment_applicationId :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_applicationId :: (Maybe Text -> f (Maybe Text)) -> Environment -> f Environment
environment_applicationId = (Environment -> Maybe Text)
-> (Environment -> Maybe Text -> Environment)
-> Lens Environment Environment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe Text
applicationId :: Maybe Text
$sel:applicationId:Environment' :: Environment -> Maybe Text
applicationId} -> Maybe Text
applicationId) (\s :: Environment
s@Environment' {} Maybe Text
a -> Environment
s {$sel:applicationId:Environment' :: Maybe Text
applicationId = Maybe Text
a} :: Environment)

-- | The name of the environment.
environment_name :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_name :: (Maybe Text -> f (Maybe Text)) -> Environment -> f Environment
environment_name = (Environment -> Maybe Text)
-> (Environment -> Maybe Text -> Environment)
-> Lens Environment Environment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe Text
name :: Maybe Text
$sel:name:Environment' :: Environment -> Maybe Text
name} -> Maybe Text
name) (\s :: Environment
s@Environment' {} Maybe Text
a -> Environment
s {$sel:name:Environment' :: Maybe Text
name = Maybe Text
a} :: Environment)

-- | The environment ID.
environment_id :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_id :: (Maybe Text -> f (Maybe Text)) -> Environment -> f Environment
environment_id = (Environment -> Maybe Text)
-> (Environment -> Maybe Text -> Environment)
-> Lens Environment Environment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe Text
id :: Maybe Text
$sel:id:Environment' :: Environment -> Maybe Text
id} -> Maybe Text
id) (\s :: Environment
s@Environment' {} Maybe Text
a -> Environment
s {$sel:id:Environment' :: Maybe Text
id = Maybe Text
a} :: Environment)

-- | The description of the environment.
environment_description :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_description :: (Maybe Text -> f (Maybe Text)) -> Environment -> f Environment
environment_description = (Environment -> Maybe Text)
-> (Environment -> Maybe Text -> Environment)
-> Lens Environment Environment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe Text
description :: Maybe Text
$sel:description:Environment' :: Environment -> Maybe Text
description} -> Maybe Text
description) (\s :: Environment
s@Environment' {} Maybe Text
a -> Environment
s {$sel:description:Environment' :: Maybe Text
description = Maybe Text
a} :: Environment)

instance Core.FromJSON Environment where
  parseJSON :: Value -> Parser Environment
parseJSON =
    String
-> (Object -> Parser Environment) -> Value -> Parser Environment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Environment"
      ( \Object
x ->
          Maybe EnvironmentState
-> Maybe [Monitor]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Environment
Environment'
            (Maybe EnvironmentState
 -> Maybe [Monitor]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Environment)
-> Parser (Maybe EnvironmentState)
-> Parser
     (Maybe [Monitor]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Environment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EnvironmentState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe [Monitor]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Environment)
-> Parser (Maybe [Monitor])
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> Environment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Monitor]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Monitors" Parser (Maybe (Maybe [Monitor]))
-> Maybe [Monitor] -> Parser (Maybe [Monitor])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Monitor]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> Environment)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Environment)
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
"ApplicationId")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Environment)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Environment)
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
"Name")
            Parser (Maybe Text -> Maybe Text -> Environment)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Environment)
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
"Id")
            Parser (Maybe Text -> Environment)
-> Parser (Maybe Text) -> Parser Environment
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
"Description")
      )

instance Prelude.Hashable Environment

instance Prelude.NFData Environment