{-# 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.ServiceCatalog.Types.StackInstance
-- 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.ServiceCatalog.Types.StackInstance where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ServiceCatalog.Types.StackInstanceStatus

-- | An AWS CloudFormation stack, in a specific account and region, that\'s
-- part of a stack set operation. A stack instance is a reference to an
-- attempted or actual stack in a given account within a given region. A
-- stack instance can exist without a stack—for example, if the stack
-- couldn\'t be created for some reason. A stack instance is associated
-- with only one stack set. Each stack instance contains the ID of its
-- associated stack set, as well as the ID of the actual stack and the
-- stack status.
--
-- /See:/ 'newStackInstance' smart constructor.
data StackInstance = StackInstance'
  { -- | The name of the AWS account that the stack instance is associated with.
    StackInstance -> Maybe Text
account :: Prelude.Maybe Prelude.Text,
    -- | The name of the AWS region that the stack instance is associated with.
    StackInstance -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The status of the stack instance, in terms of its synchronization with
    -- its associated stack set.
    --
    -- -   @INOPERABLE@: A @DeleteStackInstances@ operation has failed and left
    --     the stack in an unstable state. Stacks in this state are excluded
    --     from further @UpdateStackSet@ operations. You might need to perform
    --     a @DeleteStackInstances@ operation, with @RetainStacks@ set to true,
    --     to delete the stack instance, and then delete the stack manually.
    --
    -- -   @OUTDATED@: The stack isn\'t currently up to date with the stack set
    --     because either the associated stack failed during a @CreateStackSet@
    --     or @UpdateStackSet@ operation, or the stack was part of a
    --     @CreateStackSet@ or @UpdateStackSet@ operation that failed or was
    --     stopped before the stack was created or updated.
    --
    -- -   @CURRENT@: The stack is currently up to date with the stack set.
    StackInstance -> Maybe StackInstanceStatus
stackInstanceStatus :: Prelude.Maybe StackInstanceStatus
  }
  deriving (StackInstance -> StackInstance -> Bool
(StackInstance -> StackInstance -> Bool)
-> (StackInstance -> StackInstance -> Bool) -> Eq StackInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StackInstance -> StackInstance -> Bool
$c/= :: StackInstance -> StackInstance -> Bool
== :: StackInstance -> StackInstance -> Bool
$c== :: StackInstance -> StackInstance -> Bool
Prelude.Eq, ReadPrec [StackInstance]
ReadPrec StackInstance
Int -> ReadS StackInstance
ReadS [StackInstance]
(Int -> ReadS StackInstance)
-> ReadS [StackInstance]
-> ReadPrec StackInstance
-> ReadPrec [StackInstance]
-> Read StackInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StackInstance]
$creadListPrec :: ReadPrec [StackInstance]
readPrec :: ReadPrec StackInstance
$creadPrec :: ReadPrec StackInstance
readList :: ReadS [StackInstance]
$creadList :: ReadS [StackInstance]
readsPrec :: Int -> ReadS StackInstance
$creadsPrec :: Int -> ReadS StackInstance
Prelude.Read, Int -> StackInstance -> ShowS
[StackInstance] -> ShowS
StackInstance -> String
(Int -> StackInstance -> ShowS)
-> (StackInstance -> String)
-> ([StackInstance] -> ShowS)
-> Show StackInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StackInstance] -> ShowS
$cshowList :: [StackInstance] -> ShowS
show :: StackInstance -> String
$cshow :: StackInstance -> String
showsPrec :: Int -> StackInstance -> ShowS
$cshowsPrec :: Int -> StackInstance -> ShowS
Prelude.Show, (forall x. StackInstance -> Rep StackInstance x)
-> (forall x. Rep StackInstance x -> StackInstance)
-> Generic StackInstance
forall x. Rep StackInstance x -> StackInstance
forall x. StackInstance -> Rep StackInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StackInstance x -> StackInstance
$cfrom :: forall x. StackInstance -> Rep StackInstance x
Prelude.Generic)

-- |
-- Create a value of 'StackInstance' 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:
--
-- 'account', 'stackInstance_account' - The name of the AWS account that the stack instance is associated with.
--
-- 'region', 'stackInstance_region' - The name of the AWS region that the stack instance is associated with.
--
-- 'stackInstanceStatus', 'stackInstance_stackInstanceStatus' - The status of the stack instance, in terms of its synchronization with
-- its associated stack set.
--
-- -   @INOPERABLE@: A @DeleteStackInstances@ operation has failed and left
--     the stack in an unstable state. Stacks in this state are excluded
--     from further @UpdateStackSet@ operations. You might need to perform
--     a @DeleteStackInstances@ operation, with @RetainStacks@ set to true,
--     to delete the stack instance, and then delete the stack manually.
--
-- -   @OUTDATED@: The stack isn\'t currently up to date with the stack set
--     because either the associated stack failed during a @CreateStackSet@
--     or @UpdateStackSet@ operation, or the stack was part of a
--     @CreateStackSet@ or @UpdateStackSet@ operation that failed or was
--     stopped before the stack was created or updated.
--
-- -   @CURRENT@: The stack is currently up to date with the stack set.
newStackInstance ::
  StackInstance
newStackInstance :: StackInstance
newStackInstance =
  StackInstance' :: Maybe Text
-> Maybe Text -> Maybe StackInstanceStatus -> StackInstance
StackInstance'
    { $sel:account:StackInstance' :: Maybe Text
account = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:StackInstance' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stackInstanceStatus:StackInstance' :: Maybe StackInstanceStatus
stackInstanceStatus = Maybe StackInstanceStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the AWS account that the stack instance is associated with.
stackInstance_account :: Lens.Lens' StackInstance (Prelude.Maybe Prelude.Text)
stackInstance_account :: (Maybe Text -> f (Maybe Text)) -> StackInstance -> f StackInstance
stackInstance_account = (StackInstance -> Maybe Text)
-> (StackInstance -> Maybe Text -> StackInstance)
-> Lens StackInstance StackInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StackInstance' {Maybe Text
account :: Maybe Text
$sel:account:StackInstance' :: StackInstance -> Maybe Text
account} -> Maybe Text
account) (\s :: StackInstance
s@StackInstance' {} Maybe Text
a -> StackInstance
s {$sel:account:StackInstance' :: Maybe Text
account = Maybe Text
a} :: StackInstance)

-- | The name of the AWS region that the stack instance is associated with.
stackInstance_region :: Lens.Lens' StackInstance (Prelude.Maybe Prelude.Text)
stackInstance_region :: (Maybe Text -> f (Maybe Text)) -> StackInstance -> f StackInstance
stackInstance_region = (StackInstance -> Maybe Text)
-> (StackInstance -> Maybe Text -> StackInstance)
-> Lens StackInstance StackInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StackInstance' {Maybe Text
region :: Maybe Text
$sel:region:StackInstance' :: StackInstance -> Maybe Text
region} -> Maybe Text
region) (\s :: StackInstance
s@StackInstance' {} Maybe Text
a -> StackInstance
s {$sel:region:StackInstance' :: Maybe Text
region = Maybe Text
a} :: StackInstance)

-- | The status of the stack instance, in terms of its synchronization with
-- its associated stack set.
--
-- -   @INOPERABLE@: A @DeleteStackInstances@ operation has failed and left
--     the stack in an unstable state. Stacks in this state are excluded
--     from further @UpdateStackSet@ operations. You might need to perform
--     a @DeleteStackInstances@ operation, with @RetainStacks@ set to true,
--     to delete the stack instance, and then delete the stack manually.
--
-- -   @OUTDATED@: The stack isn\'t currently up to date with the stack set
--     because either the associated stack failed during a @CreateStackSet@
--     or @UpdateStackSet@ operation, or the stack was part of a
--     @CreateStackSet@ or @UpdateStackSet@ operation that failed or was
--     stopped before the stack was created or updated.
--
-- -   @CURRENT@: The stack is currently up to date with the stack set.
stackInstance_stackInstanceStatus :: Lens.Lens' StackInstance (Prelude.Maybe StackInstanceStatus)
stackInstance_stackInstanceStatus :: (Maybe StackInstanceStatus -> f (Maybe StackInstanceStatus))
-> StackInstance -> f StackInstance
stackInstance_stackInstanceStatus = (StackInstance -> Maybe StackInstanceStatus)
-> (StackInstance -> Maybe StackInstanceStatus -> StackInstance)
-> Lens
     StackInstance
     StackInstance
     (Maybe StackInstanceStatus)
     (Maybe StackInstanceStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StackInstance' {Maybe StackInstanceStatus
stackInstanceStatus :: Maybe StackInstanceStatus
$sel:stackInstanceStatus:StackInstance' :: StackInstance -> Maybe StackInstanceStatus
stackInstanceStatus} -> Maybe StackInstanceStatus
stackInstanceStatus) (\s :: StackInstance
s@StackInstance' {} Maybe StackInstanceStatus
a -> StackInstance
s {$sel:stackInstanceStatus:StackInstance' :: Maybe StackInstanceStatus
stackInstanceStatus = Maybe StackInstanceStatus
a} :: StackInstance)

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

instance Prelude.Hashable StackInstance

instance Prelude.NFData StackInstance