{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newEnvironment' smart constructor.
data Environment = Environment'
  { -- | The application ID.
    Environment -> Maybe Text
applicationId :: Prelude.Maybe Prelude.Text,
    -- | The description of the environment.
    Environment -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The environment ID.
    Environment -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | Amazon CloudWatch alarms monitored during the deployment.
    Environment -> Maybe [Monitor]
monitors :: Prelude.Maybe [Monitor],
    -- | The name of the environment.
    Environment -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (Environment -> Environment -> Bool
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]
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
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. 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:
--
-- 'applicationId', 'environment_applicationId' - The application ID.
--
-- 'description', 'environment_description' - The description of the environment.
--
-- 'id', 'environment_id' - The environment ID.
--
-- 'monitors', 'environment_monitors' - Amazon CloudWatch alarms monitored during the deployment.
--
-- 'name', 'environment_name' - The name of the environment.
--
-- '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@
newEnvironment ::
  Environment
newEnvironment :: Environment
newEnvironment =
  Environment'
    { $sel:applicationId:Environment' :: Maybe Text
applicationId = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Environment' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Environment' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:monitors:Environment' :: Maybe [Monitor]
monitors = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Environment' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:state:Environment' :: Maybe EnvironmentState
state = forall a. Maybe a
Prelude.Nothing
    }

-- | The application ID.
environment_applicationId :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_applicationId :: Lens' Environment (Maybe Text)
environment_applicationId = 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 description of the environment.
environment_description :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_description :: Lens' Environment (Maybe Text)
environment_description = 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)

-- | The environment ID.
environment_id :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_id :: Lens' Environment (Maybe Text)
environment_id = 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)

-- | Amazon CloudWatch alarms monitored during the deployment.
environment_monitors :: Lens.Lens' Environment (Prelude.Maybe [Monitor])
environment_monitors :: Lens' Environment (Maybe [Monitor])
environment_monitors = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the environment.
environment_name :: Lens.Lens' Environment (Prelude.Maybe Prelude.Text)
environment_name :: Lens' Environment (Maybe Text)
environment_name = 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 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 :: Lens' Environment (Maybe EnvironmentState)
environment_state = 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)

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

instance Prelude.Hashable Environment where
  hashWithSalt :: Int -> Environment -> Int
hashWithSalt Int
_salt Environment' {Maybe [Monitor]
Maybe Text
Maybe EnvironmentState
state :: Maybe EnvironmentState
name :: Maybe Text
monitors :: Maybe [Monitor]
id :: Maybe Text
description :: Maybe Text
applicationId :: Maybe Text
$sel:state:Environment' :: Environment -> Maybe EnvironmentState
$sel:name:Environment' :: Environment -> Maybe Text
$sel:monitors:Environment' :: Environment -> Maybe [Monitor]
$sel:id:Environment' :: Environment -> Maybe Text
$sel:description:Environment' :: Environment -> Maybe Text
$sel:applicationId:Environment' :: Environment -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Monitor]
monitors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EnvironmentState
state

instance Prelude.NFData Environment where
  rnf :: Environment -> ()
rnf Environment' {Maybe [Monitor]
Maybe Text
Maybe EnvironmentState
state :: Maybe EnvironmentState
name :: Maybe Text
monitors :: Maybe [Monitor]
id :: Maybe Text
description :: Maybe Text
applicationId :: Maybe Text
$sel:state:Environment' :: Environment -> Maybe EnvironmentState
$sel:name:Environment' :: Environment -> Maybe Text
$sel:monitors:Environment' :: Environment -> Maybe [Monitor]
$sel:id:Environment' :: Environment -> Maybe Text
$sel:description:Environment' :: Environment -> Maybe Text
$sel:applicationId:Environment' :: Environment -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Monitor]
monitors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EnvironmentState
state