{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DescribeResize
-- 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)
--
-- Returns information about the last resize operation for the specified
-- cluster. If no resize operation has ever been initiated for the
-- specified cluster, a @HTTP 404@ error is returned. If a resize operation
-- was initiated and completed, the status of the resize remains as
-- @SUCCEEDED@ until the next resize.
--
-- A resize operation can be requested using ModifyCluster and specifying a
-- different number or type of nodes for the cluster.
module Amazonka.Redshift.DescribeResize
  ( -- * Creating a Request
    DescribeResize (..),
    newDescribeResize,

    -- * Request Lenses
    describeResize_clusterIdentifier,

    -- * Destructuring the Response
    ResizeProgressMessage (..),
    newResizeProgressMessage,

    -- * Response Lenses
    resizeProgressMessage_importTablesNotStarted,
    resizeProgressMessage_status,
    resizeProgressMessage_estimatedTimeToCompletionInSeconds,
    resizeProgressMessage_avgResizeRateInMegaBytesPerSecond,
    resizeProgressMessage_targetNumberOfNodes,
    resizeProgressMessage_targetEncryptionType,
    resizeProgressMessage_targetNodeType,
    resizeProgressMessage_importTablesInProgress,
    resizeProgressMessage_resizeType,
    resizeProgressMessage_importTablesCompleted,
    resizeProgressMessage_progressInMegaBytes,
    resizeProgressMessage_dataTransferProgressPercent,
    resizeProgressMessage_totalResizeDataInMegaBytes,
    resizeProgressMessage_targetClusterType,
    resizeProgressMessage_message,
    resizeProgressMessage_elapsedTimeInSeconds,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newDescribeResize' smart constructor.
data DescribeResize = DescribeResize'
  { -- | The unique identifier of a cluster whose resize progress you are
    -- requesting. This parameter is case-sensitive.
    --
    -- By default, resize operations for all clusters defined for an Amazon Web
    -- Services account are returned.
    DescribeResize -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (DescribeResize -> DescribeResize -> Bool
(DescribeResize -> DescribeResize -> Bool)
-> (DescribeResize -> DescribeResize -> Bool) -> Eq DescribeResize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeResize -> DescribeResize -> Bool
$c/= :: DescribeResize -> DescribeResize -> Bool
== :: DescribeResize -> DescribeResize -> Bool
$c== :: DescribeResize -> DescribeResize -> Bool
Prelude.Eq, ReadPrec [DescribeResize]
ReadPrec DescribeResize
Int -> ReadS DescribeResize
ReadS [DescribeResize]
(Int -> ReadS DescribeResize)
-> ReadS [DescribeResize]
-> ReadPrec DescribeResize
-> ReadPrec [DescribeResize]
-> Read DescribeResize
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeResize]
$creadListPrec :: ReadPrec [DescribeResize]
readPrec :: ReadPrec DescribeResize
$creadPrec :: ReadPrec DescribeResize
readList :: ReadS [DescribeResize]
$creadList :: ReadS [DescribeResize]
readsPrec :: Int -> ReadS DescribeResize
$creadsPrec :: Int -> ReadS DescribeResize
Prelude.Read, Int -> DescribeResize -> ShowS
[DescribeResize] -> ShowS
DescribeResize -> String
(Int -> DescribeResize -> ShowS)
-> (DescribeResize -> String)
-> ([DescribeResize] -> ShowS)
-> Show DescribeResize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeResize] -> ShowS
$cshowList :: [DescribeResize] -> ShowS
show :: DescribeResize -> String
$cshow :: DescribeResize -> String
showsPrec :: Int -> DescribeResize -> ShowS
$cshowsPrec :: Int -> DescribeResize -> ShowS
Prelude.Show, (forall x. DescribeResize -> Rep DescribeResize x)
-> (forall x. Rep DescribeResize x -> DescribeResize)
-> Generic DescribeResize
forall x. Rep DescribeResize x -> DescribeResize
forall x. DescribeResize -> Rep DescribeResize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeResize x -> DescribeResize
$cfrom :: forall x. DescribeResize -> Rep DescribeResize x
Prelude.Generic)

-- |
-- Create a value of 'DescribeResize' 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:
--
-- 'clusterIdentifier', 'describeResize_clusterIdentifier' - The unique identifier of a cluster whose resize progress you are
-- requesting. This parameter is case-sensitive.
--
-- By default, resize operations for all clusters defined for an Amazon Web
-- Services account are returned.
newDescribeResize ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  DescribeResize
newDescribeResize :: Text -> DescribeResize
newDescribeResize Text
pClusterIdentifier_ =
  DescribeResize' :: Text -> DescribeResize
DescribeResize'
    { $sel:clusterIdentifier:DescribeResize' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The unique identifier of a cluster whose resize progress you are
-- requesting. This parameter is case-sensitive.
--
-- By default, resize operations for all clusters defined for an Amazon Web
-- Services account are returned.
describeResize_clusterIdentifier :: Lens.Lens' DescribeResize Prelude.Text
describeResize_clusterIdentifier :: (Text -> f Text) -> DescribeResize -> f DescribeResize
describeResize_clusterIdentifier = (DescribeResize -> Text)
-> (DescribeResize -> Text -> DescribeResize)
-> Lens DescribeResize DescribeResize Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeResize' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DescribeResize' :: DescribeResize -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: DescribeResize
s@DescribeResize' {} Text
a -> DescribeResize
s {$sel:clusterIdentifier:DescribeResize' :: Text
clusterIdentifier = Text
a} :: DescribeResize)

instance Core.AWSRequest DescribeResize where
  type
    AWSResponse DescribeResize =
      ResizeProgressMessage
  request :: DescribeResize -> Request DescribeResize
request = Service -> DescribeResize -> Request DescribeResize
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeResize
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeResize)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeResize))
-> Logger
-> Service
-> Proxy DescribeResize
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeResize)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeResizeResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String ResizeProgressMessage
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable DescribeResize

instance Prelude.NFData DescribeResize

instance Core.ToHeaders DescribeResize where
  toHeaders :: DescribeResize -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeResize -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DescribeResize where
  toPath :: DescribeResize -> ByteString
toPath = ByteString -> DescribeResize -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeResize where
  toQuery :: DescribeResize -> QueryString
toQuery DescribeResize' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DescribeResize' :: DescribeResize -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeResize" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ClusterIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
clusterIdentifier
      ]