{-# 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.RDS.Types.FailoverState
-- 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.RDS.Types.FailoverState where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.FailoverStatus

-- | Contains the state of scheduled or in-process failover operations on an
-- Aurora global database (GlobalCluster). This Data type is empty unless a
-- failover operation is scheduled or is currently underway on the Aurora
-- global database.
--
-- /See:/ 'newFailoverState' smart constructor.
data FailoverState = FailoverState'
  { -- | The current status of the Aurora global database (GlobalCluster).
    -- Possible values are as follows:
    --
    -- -   pending – A request to fail over the Aurora global database
    --     (GlobalCluster) has been received by the service. The
    --     @GlobalCluster@\'s primary DB cluster and the specified secondary DB
    --     cluster are being verified before the failover process can start.
    --
    -- -   failing-over – This status covers the range of Aurora internal
    --     operations that take place during the failover process, such as
    --     demoting the primary Aurora DB cluster, promoting the secondary
    --     Aurora DB, and synchronizing replicas.
    --
    -- -   cancelling – The request to fail over the Aurora global database
    --     (GlobalCluster) was cancelled and the primary Aurora DB cluster and
    --     the selected secondary Aurora DB cluster are returning to their
    --     previous states.
    FailoverState -> Maybe FailoverStatus
status :: Prelude.Maybe FailoverStatus,
    -- | The Amazon Resource Name (ARN) of the Aurora DB cluster that is
    -- currently being promoted, and which is associated with this state.
    FailoverState -> Maybe Text
toDbClusterArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Aurora DB cluster that is
    -- currently being demoted, and which is associated with this state.
    FailoverState -> Maybe Text
fromDbClusterArn :: Prelude.Maybe Prelude.Text
  }
  deriving (FailoverState -> FailoverState -> Bool
(FailoverState -> FailoverState -> Bool)
-> (FailoverState -> FailoverState -> Bool) -> Eq FailoverState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailoverState -> FailoverState -> Bool
$c/= :: FailoverState -> FailoverState -> Bool
== :: FailoverState -> FailoverState -> Bool
$c== :: FailoverState -> FailoverState -> Bool
Prelude.Eq, ReadPrec [FailoverState]
ReadPrec FailoverState
Int -> ReadS FailoverState
ReadS [FailoverState]
(Int -> ReadS FailoverState)
-> ReadS [FailoverState]
-> ReadPrec FailoverState
-> ReadPrec [FailoverState]
-> Read FailoverState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailoverState]
$creadListPrec :: ReadPrec [FailoverState]
readPrec :: ReadPrec FailoverState
$creadPrec :: ReadPrec FailoverState
readList :: ReadS [FailoverState]
$creadList :: ReadS [FailoverState]
readsPrec :: Int -> ReadS FailoverState
$creadsPrec :: Int -> ReadS FailoverState
Prelude.Read, Int -> FailoverState -> ShowS
[FailoverState] -> ShowS
FailoverState -> String
(Int -> FailoverState -> ShowS)
-> (FailoverState -> String)
-> ([FailoverState] -> ShowS)
-> Show FailoverState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailoverState] -> ShowS
$cshowList :: [FailoverState] -> ShowS
show :: FailoverState -> String
$cshow :: FailoverState -> String
showsPrec :: Int -> FailoverState -> ShowS
$cshowsPrec :: Int -> FailoverState -> ShowS
Prelude.Show, (forall x. FailoverState -> Rep FailoverState x)
-> (forall x. Rep FailoverState x -> FailoverState)
-> Generic FailoverState
forall x. Rep FailoverState x -> FailoverState
forall x. FailoverState -> Rep FailoverState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailoverState x -> FailoverState
$cfrom :: forall x. FailoverState -> Rep FailoverState x
Prelude.Generic)

-- |
-- Create a value of 'FailoverState' 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', 'failoverState_status' - The current status of the Aurora global database (GlobalCluster).
-- Possible values are as follows:
--
-- -   pending – A request to fail over the Aurora global database
--     (GlobalCluster) has been received by the service. The
--     @GlobalCluster@\'s primary DB cluster and the specified secondary DB
--     cluster are being verified before the failover process can start.
--
-- -   failing-over – This status covers the range of Aurora internal
--     operations that take place during the failover process, such as
--     demoting the primary Aurora DB cluster, promoting the secondary
--     Aurora DB, and synchronizing replicas.
--
-- -   cancelling – The request to fail over the Aurora global database
--     (GlobalCluster) was cancelled and the primary Aurora DB cluster and
--     the selected secondary Aurora DB cluster are returning to their
--     previous states.
--
-- 'toDbClusterArn', 'failoverState_toDbClusterArn' - The Amazon Resource Name (ARN) of the Aurora DB cluster that is
-- currently being promoted, and which is associated with this state.
--
-- 'fromDbClusterArn', 'failoverState_fromDbClusterArn' - The Amazon Resource Name (ARN) of the Aurora DB cluster that is
-- currently being demoted, and which is associated with this state.
newFailoverState ::
  FailoverState
newFailoverState :: FailoverState
newFailoverState =
  FailoverState' :: Maybe FailoverStatus -> Maybe Text -> Maybe Text -> FailoverState
FailoverState'
    { $sel:status:FailoverState' :: Maybe FailoverStatus
status = Maybe FailoverStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:toDbClusterArn:FailoverState' :: Maybe Text
toDbClusterArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fromDbClusterArn:FailoverState' :: Maybe Text
fromDbClusterArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The current status of the Aurora global database (GlobalCluster).
-- Possible values are as follows:
--
-- -   pending – A request to fail over the Aurora global database
--     (GlobalCluster) has been received by the service. The
--     @GlobalCluster@\'s primary DB cluster and the specified secondary DB
--     cluster are being verified before the failover process can start.
--
-- -   failing-over – This status covers the range of Aurora internal
--     operations that take place during the failover process, such as
--     demoting the primary Aurora DB cluster, promoting the secondary
--     Aurora DB, and synchronizing replicas.
--
-- -   cancelling – The request to fail over the Aurora global database
--     (GlobalCluster) was cancelled and the primary Aurora DB cluster and
--     the selected secondary Aurora DB cluster are returning to their
--     previous states.
failoverState_status :: Lens.Lens' FailoverState (Prelude.Maybe FailoverStatus)
failoverState_status :: (Maybe FailoverStatus -> f (Maybe FailoverStatus))
-> FailoverState -> f FailoverState
failoverState_status = (FailoverState -> Maybe FailoverStatus)
-> (FailoverState -> Maybe FailoverStatus -> FailoverState)
-> Lens
     FailoverState
     FailoverState
     (Maybe FailoverStatus)
     (Maybe FailoverStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverState' {Maybe FailoverStatus
status :: Maybe FailoverStatus
$sel:status:FailoverState' :: FailoverState -> Maybe FailoverStatus
status} -> Maybe FailoverStatus
status) (\s :: FailoverState
s@FailoverState' {} Maybe FailoverStatus
a -> FailoverState
s {$sel:status:FailoverState' :: Maybe FailoverStatus
status = Maybe FailoverStatus
a} :: FailoverState)

-- | The Amazon Resource Name (ARN) of the Aurora DB cluster that is
-- currently being promoted, and which is associated with this state.
failoverState_toDbClusterArn :: Lens.Lens' FailoverState (Prelude.Maybe Prelude.Text)
failoverState_toDbClusterArn :: (Maybe Text -> f (Maybe Text)) -> FailoverState -> f FailoverState
failoverState_toDbClusterArn = (FailoverState -> Maybe Text)
-> (FailoverState -> Maybe Text -> FailoverState)
-> Lens FailoverState FailoverState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverState' {Maybe Text
toDbClusterArn :: Maybe Text
$sel:toDbClusterArn:FailoverState' :: FailoverState -> Maybe Text
toDbClusterArn} -> Maybe Text
toDbClusterArn) (\s :: FailoverState
s@FailoverState' {} Maybe Text
a -> FailoverState
s {$sel:toDbClusterArn:FailoverState' :: Maybe Text
toDbClusterArn = Maybe Text
a} :: FailoverState)

-- | The Amazon Resource Name (ARN) of the Aurora DB cluster that is
-- currently being demoted, and which is associated with this state.
failoverState_fromDbClusterArn :: Lens.Lens' FailoverState (Prelude.Maybe Prelude.Text)
failoverState_fromDbClusterArn :: (Maybe Text -> f (Maybe Text)) -> FailoverState -> f FailoverState
failoverState_fromDbClusterArn = (FailoverState -> Maybe Text)
-> (FailoverState -> Maybe Text -> FailoverState)
-> Lens FailoverState FailoverState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailoverState' {Maybe Text
fromDbClusterArn :: Maybe Text
$sel:fromDbClusterArn:FailoverState' :: FailoverState -> Maybe Text
fromDbClusterArn} -> Maybe Text
fromDbClusterArn) (\s :: FailoverState
s@FailoverState' {} Maybe Text
a -> FailoverState
s {$sel:fromDbClusterArn:FailoverState' :: Maybe Text
fromDbClusterArn = Maybe Text
a} :: FailoverState)

instance Core.FromXML FailoverState where
  parseXML :: [Node] -> Either String FailoverState
parseXML [Node]
x =
    Maybe FailoverStatus -> Maybe Text -> Maybe Text -> FailoverState
FailoverState'
      (Maybe FailoverStatus -> Maybe Text -> Maybe Text -> FailoverState)
-> Either String (Maybe FailoverStatus)
-> Either String (Maybe Text -> Maybe Text -> FailoverState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe FailoverStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either String (Maybe Text -> Maybe Text -> FailoverState)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> FailoverState)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ToDbClusterArn")
      Either String (Maybe Text -> FailoverState)
-> Either String (Maybe Text) -> Either String FailoverState
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"FromDbClusterArn")

instance Prelude.Hashable FailoverState

instance Prelude.NFData FailoverState