{-# 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.CancelResize
-- 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)
--
-- Cancels a resize operation for a cluster.
module Amazonka.Redshift.CancelResize
  ( -- * Creating a Request
    CancelResize (..),
    newCancelResize,

    -- * Request Lenses
    cancelResize_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:/ 'newCancelResize' smart constructor.
data CancelResize = CancelResize'
  { -- | The unique identifier for the cluster that you want to cancel a resize
    -- operation for.
    CancelResize -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (CancelResize -> CancelResize -> Bool
(CancelResize -> CancelResize -> Bool)
-> (CancelResize -> CancelResize -> Bool) -> Eq CancelResize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelResize -> CancelResize -> Bool
$c/= :: CancelResize -> CancelResize -> Bool
== :: CancelResize -> CancelResize -> Bool
$c== :: CancelResize -> CancelResize -> Bool
Prelude.Eq, ReadPrec [CancelResize]
ReadPrec CancelResize
Int -> ReadS CancelResize
ReadS [CancelResize]
(Int -> ReadS CancelResize)
-> ReadS [CancelResize]
-> ReadPrec CancelResize
-> ReadPrec [CancelResize]
-> Read CancelResize
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelResize]
$creadListPrec :: ReadPrec [CancelResize]
readPrec :: ReadPrec CancelResize
$creadPrec :: ReadPrec CancelResize
readList :: ReadS [CancelResize]
$creadList :: ReadS [CancelResize]
readsPrec :: Int -> ReadS CancelResize
$creadsPrec :: Int -> ReadS CancelResize
Prelude.Read, Int -> CancelResize -> ShowS
[CancelResize] -> ShowS
CancelResize -> String
(Int -> CancelResize -> ShowS)
-> (CancelResize -> String)
-> ([CancelResize] -> ShowS)
-> Show CancelResize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelResize] -> ShowS
$cshowList :: [CancelResize] -> ShowS
show :: CancelResize -> String
$cshow :: CancelResize -> String
showsPrec :: Int -> CancelResize -> ShowS
$cshowsPrec :: Int -> CancelResize -> ShowS
Prelude.Show, (forall x. CancelResize -> Rep CancelResize x)
-> (forall x. Rep CancelResize x -> CancelResize)
-> Generic CancelResize
forall x. Rep CancelResize x -> CancelResize
forall x. CancelResize -> Rep CancelResize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelResize x -> CancelResize
$cfrom :: forall x. CancelResize -> Rep CancelResize x
Prelude.Generic)

-- |
-- Create a value of 'CancelResize' 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', 'cancelResize_clusterIdentifier' - The unique identifier for the cluster that you want to cancel a resize
-- operation for.
newCancelResize ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  CancelResize
newCancelResize :: Text -> CancelResize
newCancelResize Text
pClusterIdentifier_ =
  CancelResize' :: Text -> CancelResize
CancelResize'
    { $sel:clusterIdentifier:CancelResize' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The unique identifier for the cluster that you want to cancel a resize
-- operation for.
cancelResize_clusterIdentifier :: Lens.Lens' CancelResize Prelude.Text
cancelResize_clusterIdentifier :: (Text -> f Text) -> CancelResize -> f CancelResize
cancelResize_clusterIdentifier = (CancelResize -> Text)
-> (CancelResize -> Text -> CancelResize)
-> Lens CancelResize CancelResize Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelResize' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:CancelResize' :: CancelResize -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: CancelResize
s@CancelResize' {} Text
a -> CancelResize
s {$sel:clusterIdentifier:CancelResize' :: Text
clusterIdentifier = Text
a} :: CancelResize)

instance Core.AWSRequest CancelResize where
  type AWSResponse CancelResize = ResizeProgressMessage
  request :: CancelResize -> Request CancelResize
request = Service -> CancelResize -> Request CancelResize
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelResize
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelResize)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CancelResize))
-> Logger
-> Service
-> Proxy CancelResize
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelResize)))
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
"CancelResizeResult"
      (\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 CancelResize

instance Prelude.NFData CancelResize

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

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

instance Core.ToQuery CancelResize where
  toQuery :: CancelResize -> QueryString
toQuery CancelResize' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:CancelResize' :: CancelResize -> 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
"CancelResize" :: 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
      ]