{-# 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.Redshift.Types.RestoreStatus
-- 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.Redshift.Types.RestoreStatus where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal

-- | Describes the status of a cluster restore action. Returns null if the
-- cluster was not created by restoring a snapshot.
--
-- /See:/ 'newRestoreStatus' smart constructor.
data RestoreStatus = RestoreStatus'
  { -- | The status of the restore action. Returns starting, restoring,
    -- completed, or failed.
    RestoreStatus -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The estimate of the time remaining before the restore will complete.
    -- Returns 0 for a completed restore. This field is only updated when you
    -- restore to DC2 and DS2 node types.
    RestoreStatus -> Maybe Integer
estimatedTimeToCompletionInSeconds :: Prelude.Maybe Prelude.Integer,
    -- | The number of megabytes per second being transferred from the backup
    -- storage. Returns the average rate for a completed backup. This field is
    -- only updated when you restore to DC2 and DS2 node types.
    RestoreStatus -> Maybe Double
currentRestoreRateInMegaBytesPerSecond :: Prelude.Maybe Prelude.Double,
    -- | The number of megabytes that have been transferred from snapshot
    -- storage. This field is only updated when you restore to DC2 and DS2 node
    -- types.
    RestoreStatus -> Maybe Integer
progressInMegaBytes :: Prelude.Maybe Prelude.Integer,
    -- | The amount of time an in-progress restore has been running, or the
    -- amount of time it took a completed restore to finish. This field is only
    -- updated when you restore to DC2 and DS2 node types.
    RestoreStatus -> Maybe Integer
elapsedTimeInSeconds :: Prelude.Maybe Prelude.Integer,
    -- | The size of the set of snapshot data used to restore the cluster. This
    -- field is only updated when you restore to DC2 and DS2 node types.
    RestoreStatus -> Maybe Integer
snapshotSizeInMegaBytes :: Prelude.Maybe Prelude.Integer
  }
  deriving (RestoreStatus -> RestoreStatus -> Bool
(RestoreStatus -> RestoreStatus -> Bool)
-> (RestoreStatus -> RestoreStatus -> Bool) -> Eq RestoreStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreStatus -> RestoreStatus -> Bool
$c/= :: RestoreStatus -> RestoreStatus -> Bool
== :: RestoreStatus -> RestoreStatus -> Bool
$c== :: RestoreStatus -> RestoreStatus -> Bool
Prelude.Eq, ReadPrec [RestoreStatus]
ReadPrec RestoreStatus
Int -> ReadS RestoreStatus
ReadS [RestoreStatus]
(Int -> ReadS RestoreStatus)
-> ReadS [RestoreStatus]
-> ReadPrec RestoreStatus
-> ReadPrec [RestoreStatus]
-> Read RestoreStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreStatus]
$creadListPrec :: ReadPrec [RestoreStatus]
readPrec :: ReadPrec RestoreStatus
$creadPrec :: ReadPrec RestoreStatus
readList :: ReadS [RestoreStatus]
$creadList :: ReadS [RestoreStatus]
readsPrec :: Int -> ReadS RestoreStatus
$creadsPrec :: Int -> ReadS RestoreStatus
Prelude.Read, Int -> RestoreStatus -> ShowS
[RestoreStatus] -> ShowS
RestoreStatus -> String
(Int -> RestoreStatus -> ShowS)
-> (RestoreStatus -> String)
-> ([RestoreStatus] -> ShowS)
-> Show RestoreStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreStatus] -> ShowS
$cshowList :: [RestoreStatus] -> ShowS
show :: RestoreStatus -> String
$cshow :: RestoreStatus -> String
showsPrec :: Int -> RestoreStatus -> ShowS
$cshowsPrec :: Int -> RestoreStatus -> ShowS
Prelude.Show, (forall x. RestoreStatus -> Rep RestoreStatus x)
-> (forall x. Rep RestoreStatus x -> RestoreStatus)
-> Generic RestoreStatus
forall x. Rep RestoreStatus x -> RestoreStatus
forall x. RestoreStatus -> Rep RestoreStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreStatus x -> RestoreStatus
$cfrom :: forall x. RestoreStatus -> Rep RestoreStatus x
Prelude.Generic)

-- |
-- Create a value of 'RestoreStatus' 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', 'restoreStatus_status' - The status of the restore action. Returns starting, restoring,
-- completed, or failed.
--
-- 'estimatedTimeToCompletionInSeconds', 'restoreStatus_estimatedTimeToCompletionInSeconds' - The estimate of the time remaining before the restore will complete.
-- Returns 0 for a completed restore. This field is only updated when you
-- restore to DC2 and DS2 node types.
--
-- 'currentRestoreRateInMegaBytesPerSecond', 'restoreStatus_currentRestoreRateInMegaBytesPerSecond' - The number of megabytes per second being transferred from the backup
-- storage. Returns the average rate for a completed backup. This field is
-- only updated when you restore to DC2 and DS2 node types.
--
-- 'progressInMegaBytes', 'restoreStatus_progressInMegaBytes' - The number of megabytes that have been transferred from snapshot
-- storage. This field is only updated when you restore to DC2 and DS2 node
-- types.
--
-- 'elapsedTimeInSeconds', 'restoreStatus_elapsedTimeInSeconds' - The amount of time an in-progress restore has been running, or the
-- amount of time it took a completed restore to finish. This field is only
-- updated when you restore to DC2 and DS2 node types.
--
-- 'snapshotSizeInMegaBytes', 'restoreStatus_snapshotSizeInMegaBytes' - The size of the set of snapshot data used to restore the cluster. This
-- field is only updated when you restore to DC2 and DS2 node types.
newRestoreStatus ::
  RestoreStatus
newRestoreStatus :: RestoreStatus
newRestoreStatus =
  RestoreStatus' :: Maybe Text
-> Maybe Integer
-> Maybe Double
-> Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> RestoreStatus
RestoreStatus'
    { $sel:status:RestoreStatus' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:estimatedTimeToCompletionInSeconds:RestoreStatus' :: Maybe Integer
estimatedTimeToCompletionInSeconds = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:currentRestoreRateInMegaBytesPerSecond:RestoreStatus' :: Maybe Double
currentRestoreRateInMegaBytesPerSecond =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:progressInMegaBytes:RestoreStatus' :: Maybe Integer
progressInMegaBytes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:elapsedTimeInSeconds:RestoreStatus' :: Maybe Integer
elapsedTimeInSeconds = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotSizeInMegaBytes:RestoreStatus' :: Maybe Integer
snapshotSizeInMegaBytes = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the restore action. Returns starting, restoring,
-- completed, or failed.
restoreStatus_status :: Lens.Lens' RestoreStatus (Prelude.Maybe Prelude.Text)
restoreStatus_status :: (Maybe Text -> f (Maybe Text)) -> RestoreStatus -> f RestoreStatus
restoreStatus_status = (RestoreStatus -> Maybe Text)
-> (RestoreStatus -> Maybe Text -> RestoreStatus)
-> Lens RestoreStatus RestoreStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreStatus' {Maybe Text
status :: Maybe Text
$sel:status:RestoreStatus' :: RestoreStatus -> Maybe Text
status} -> Maybe Text
status) (\s :: RestoreStatus
s@RestoreStatus' {} Maybe Text
a -> RestoreStatus
s {$sel:status:RestoreStatus' :: Maybe Text
status = Maybe Text
a} :: RestoreStatus)

-- | The estimate of the time remaining before the restore will complete.
-- Returns 0 for a completed restore. This field is only updated when you
-- restore to DC2 and DS2 node types.
restoreStatus_estimatedTimeToCompletionInSeconds :: Lens.Lens' RestoreStatus (Prelude.Maybe Prelude.Integer)
restoreStatus_estimatedTimeToCompletionInSeconds :: (Maybe Integer -> f (Maybe Integer))
-> RestoreStatus -> f RestoreStatus
restoreStatus_estimatedTimeToCompletionInSeconds = (RestoreStatus -> Maybe Integer)
-> (RestoreStatus -> Maybe Integer -> RestoreStatus)
-> Lens RestoreStatus RestoreStatus (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreStatus' {Maybe Integer
estimatedTimeToCompletionInSeconds :: Maybe Integer
$sel:estimatedTimeToCompletionInSeconds:RestoreStatus' :: RestoreStatus -> Maybe Integer
estimatedTimeToCompletionInSeconds} -> Maybe Integer
estimatedTimeToCompletionInSeconds) (\s :: RestoreStatus
s@RestoreStatus' {} Maybe Integer
a -> RestoreStatus
s {$sel:estimatedTimeToCompletionInSeconds:RestoreStatus' :: Maybe Integer
estimatedTimeToCompletionInSeconds = Maybe Integer
a} :: RestoreStatus)

-- | The number of megabytes per second being transferred from the backup
-- storage. Returns the average rate for a completed backup. This field is
-- only updated when you restore to DC2 and DS2 node types.
restoreStatus_currentRestoreRateInMegaBytesPerSecond :: Lens.Lens' RestoreStatus (Prelude.Maybe Prelude.Double)
restoreStatus_currentRestoreRateInMegaBytesPerSecond :: (Maybe Double -> f (Maybe Double))
-> RestoreStatus -> f RestoreStatus
restoreStatus_currentRestoreRateInMegaBytesPerSecond = (RestoreStatus -> Maybe Double)
-> (RestoreStatus -> Maybe Double -> RestoreStatus)
-> Lens RestoreStatus RestoreStatus (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreStatus' {Maybe Double
currentRestoreRateInMegaBytesPerSecond :: Maybe Double
$sel:currentRestoreRateInMegaBytesPerSecond:RestoreStatus' :: RestoreStatus -> Maybe Double
currentRestoreRateInMegaBytesPerSecond} -> Maybe Double
currentRestoreRateInMegaBytesPerSecond) (\s :: RestoreStatus
s@RestoreStatus' {} Maybe Double
a -> RestoreStatus
s {$sel:currentRestoreRateInMegaBytesPerSecond:RestoreStatus' :: Maybe Double
currentRestoreRateInMegaBytesPerSecond = Maybe Double
a} :: RestoreStatus)

-- | The number of megabytes that have been transferred from snapshot
-- storage. This field is only updated when you restore to DC2 and DS2 node
-- types.
restoreStatus_progressInMegaBytes :: Lens.Lens' RestoreStatus (Prelude.Maybe Prelude.Integer)
restoreStatus_progressInMegaBytes :: (Maybe Integer -> f (Maybe Integer))
-> RestoreStatus -> f RestoreStatus
restoreStatus_progressInMegaBytes = (RestoreStatus -> Maybe Integer)
-> (RestoreStatus -> Maybe Integer -> RestoreStatus)
-> Lens RestoreStatus RestoreStatus (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreStatus' {Maybe Integer
progressInMegaBytes :: Maybe Integer
$sel:progressInMegaBytes:RestoreStatus' :: RestoreStatus -> Maybe Integer
progressInMegaBytes} -> Maybe Integer
progressInMegaBytes) (\s :: RestoreStatus
s@RestoreStatus' {} Maybe Integer
a -> RestoreStatus
s {$sel:progressInMegaBytes:RestoreStatus' :: Maybe Integer
progressInMegaBytes = Maybe Integer
a} :: RestoreStatus)

-- | The amount of time an in-progress restore has been running, or the
-- amount of time it took a completed restore to finish. This field is only
-- updated when you restore to DC2 and DS2 node types.
restoreStatus_elapsedTimeInSeconds :: Lens.Lens' RestoreStatus (Prelude.Maybe Prelude.Integer)
restoreStatus_elapsedTimeInSeconds :: (Maybe Integer -> f (Maybe Integer))
-> RestoreStatus -> f RestoreStatus
restoreStatus_elapsedTimeInSeconds = (RestoreStatus -> Maybe Integer)
-> (RestoreStatus -> Maybe Integer -> RestoreStatus)
-> Lens RestoreStatus RestoreStatus (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreStatus' {Maybe Integer
elapsedTimeInSeconds :: Maybe Integer
$sel:elapsedTimeInSeconds:RestoreStatus' :: RestoreStatus -> Maybe Integer
elapsedTimeInSeconds} -> Maybe Integer
elapsedTimeInSeconds) (\s :: RestoreStatus
s@RestoreStatus' {} Maybe Integer
a -> RestoreStatus
s {$sel:elapsedTimeInSeconds:RestoreStatus' :: Maybe Integer
elapsedTimeInSeconds = Maybe Integer
a} :: RestoreStatus)

-- | The size of the set of snapshot data used to restore the cluster. This
-- field is only updated when you restore to DC2 and DS2 node types.
restoreStatus_snapshotSizeInMegaBytes :: Lens.Lens' RestoreStatus (Prelude.Maybe Prelude.Integer)
restoreStatus_snapshotSizeInMegaBytes :: (Maybe Integer -> f (Maybe Integer))
-> RestoreStatus -> f RestoreStatus
restoreStatus_snapshotSizeInMegaBytes = (RestoreStatus -> Maybe Integer)
-> (RestoreStatus -> Maybe Integer -> RestoreStatus)
-> Lens RestoreStatus RestoreStatus (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreStatus' {Maybe Integer
snapshotSizeInMegaBytes :: Maybe Integer
$sel:snapshotSizeInMegaBytes:RestoreStatus' :: RestoreStatus -> Maybe Integer
snapshotSizeInMegaBytes} -> Maybe Integer
snapshotSizeInMegaBytes) (\s :: RestoreStatus
s@RestoreStatus' {} Maybe Integer
a -> RestoreStatus
s {$sel:snapshotSizeInMegaBytes:RestoreStatus' :: Maybe Integer
snapshotSizeInMegaBytes = Maybe Integer
a} :: RestoreStatus)

instance Core.FromXML RestoreStatus where
  parseXML :: [Node] -> Either String RestoreStatus
parseXML [Node]
x =
    Maybe Text
-> Maybe Integer
-> Maybe Double
-> Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> RestoreStatus
RestoreStatus'
      (Maybe Text
 -> Maybe Integer
 -> Maybe Double
 -> Maybe Integer
 -> Maybe Integer
 -> Maybe Integer
 -> RestoreStatus)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Integer
      -> Maybe Double
      -> Maybe Integer
      -> Maybe Integer
      -> Maybe Integer
      -> RestoreStatus)
forall (f :: * -> *) a b. Functor 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
"Status")
      Either
  String
  (Maybe Integer
   -> Maybe Double
   -> Maybe Integer
   -> Maybe Integer
   -> Maybe Integer
   -> RestoreStatus)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe Double
      -> Maybe Integer
      -> Maybe Integer
      -> Maybe Integer
      -> RestoreStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"EstimatedTimeToCompletionInSeconds")
      Either
  String
  (Maybe Double
   -> Maybe Integer
   -> Maybe Integer
   -> Maybe Integer
   -> RestoreStatus)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Integer -> Maybe Integer -> Maybe Integer -> RestoreStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CurrentRestoreRateInMegaBytesPerSecond")
      Either
  String
  (Maybe Integer -> Maybe Integer -> Maybe Integer -> RestoreStatus)
-> Either String (Maybe Integer)
-> Either String (Maybe Integer -> Maybe Integer -> RestoreStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ProgressInMegaBytes")
      Either String (Maybe Integer -> Maybe Integer -> RestoreStatus)
-> Either String (Maybe Integer)
-> Either String (Maybe Integer -> RestoreStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ElapsedTimeInSeconds")
      Either String (Maybe Integer -> RestoreStatus)
-> Either String (Maybe Integer) -> Either String RestoreStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SnapshotSizeInMegaBytes")

instance Prelude.Hashable RestoreStatus

instance Prelude.NFData RestoreStatus