{-# 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.DescribeStorage
-- 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 account level backups storage size and provisional storage.
module Amazonka.Redshift.DescribeStorage
  ( -- * Creating a Request
    DescribeStorage (..),
    newDescribeStorage,

    -- * Destructuring the Response
    DescribeStorageResponse (..),
    newDescribeStorageResponse,

    -- * Response Lenses
    describeStorageResponse_totalProvisionedStorageInMegaBytes,
    describeStorageResponse_totalBackupSizeInMegaBytes,
    describeStorageResponse_httpStatus,
  )
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:/ 'newDescribeStorage' smart constructor.
data DescribeStorage = DescribeStorage'
  {
  }
  deriving (DescribeStorage -> DescribeStorage -> Bool
(DescribeStorage -> DescribeStorage -> Bool)
-> (DescribeStorage -> DescribeStorage -> Bool)
-> Eq DescribeStorage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStorage -> DescribeStorage -> Bool
$c/= :: DescribeStorage -> DescribeStorage -> Bool
== :: DescribeStorage -> DescribeStorage -> Bool
$c== :: DescribeStorage -> DescribeStorage -> Bool
Prelude.Eq, ReadPrec [DescribeStorage]
ReadPrec DescribeStorage
Int -> ReadS DescribeStorage
ReadS [DescribeStorage]
(Int -> ReadS DescribeStorage)
-> ReadS [DescribeStorage]
-> ReadPrec DescribeStorage
-> ReadPrec [DescribeStorage]
-> Read DescribeStorage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStorage]
$creadListPrec :: ReadPrec [DescribeStorage]
readPrec :: ReadPrec DescribeStorage
$creadPrec :: ReadPrec DescribeStorage
readList :: ReadS [DescribeStorage]
$creadList :: ReadS [DescribeStorage]
readsPrec :: Int -> ReadS DescribeStorage
$creadsPrec :: Int -> ReadS DescribeStorage
Prelude.Read, Int -> DescribeStorage -> ShowS
[DescribeStorage] -> ShowS
DescribeStorage -> String
(Int -> DescribeStorage -> ShowS)
-> (DescribeStorage -> String)
-> ([DescribeStorage] -> ShowS)
-> Show DescribeStorage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStorage] -> ShowS
$cshowList :: [DescribeStorage] -> ShowS
show :: DescribeStorage -> String
$cshow :: DescribeStorage -> String
showsPrec :: Int -> DescribeStorage -> ShowS
$cshowsPrec :: Int -> DescribeStorage -> ShowS
Prelude.Show, (forall x. DescribeStorage -> Rep DescribeStorage x)
-> (forall x. Rep DescribeStorage x -> DescribeStorage)
-> Generic DescribeStorage
forall x. Rep DescribeStorage x -> DescribeStorage
forall x. DescribeStorage -> Rep DescribeStorage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStorage x -> DescribeStorage
$cfrom :: forall x. DescribeStorage -> Rep DescribeStorage x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStorage' 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.
newDescribeStorage ::
  DescribeStorage
newDescribeStorage :: DescribeStorage
newDescribeStorage = DescribeStorage
DescribeStorage'

instance Core.AWSRequest DescribeStorage where
  type
    AWSResponse DescribeStorage =
      DescribeStorageResponse
  request :: DescribeStorage -> Request DescribeStorage
request = Service -> DescribeStorage -> Request DescribeStorage
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeStorage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeStorage)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeStorage))
-> Logger
-> Service
-> Proxy DescribeStorage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeStorage)))
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
"DescribeStorageResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Double -> Maybe Double -> Int -> DescribeStorageResponse
DescribeStorageResponse'
            (Maybe Double -> Maybe Double -> Int -> DescribeStorageResponse)
-> Either String (Maybe Double)
-> Either String (Maybe Double -> Int -> DescribeStorageResponse)
forall (f :: * -> *) a b. Functor 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
"TotalProvisionedStorageInMegaBytes")
            Either String (Maybe Double -> Int -> DescribeStorageResponse)
-> Either String (Maybe Double)
-> Either String (Int -> DescribeStorageResponse)
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
"TotalBackupSizeInMegaBytes")
            Either String (Int -> DescribeStorageResponse)
-> Either String Int -> Either String DescribeStorageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeStorage

instance Prelude.NFData DescribeStorage

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

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

instance Core.ToQuery DescribeStorage where
  toQuery :: DescribeStorage -> QueryString
toQuery =
    QueryString -> DescribeStorage -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeStorage" :: Prelude.ByteString),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString)
          ]
      )

-- | /See:/ 'newDescribeStorageResponse' smart constructor.
data DescribeStorageResponse = DescribeStorageResponse'
  { -- | The total amount of storage currently provisioned.
    DescribeStorageResponse -> Maybe Double
totalProvisionedStorageInMegaBytes :: Prelude.Maybe Prelude.Double,
    -- | The total amount of storage currently used for snapshots.
    DescribeStorageResponse -> Maybe Double
totalBackupSizeInMegaBytes :: Prelude.Maybe Prelude.Double,
    -- | The response's http status code.
    DescribeStorageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeStorageResponse -> DescribeStorageResponse -> Bool
(DescribeStorageResponse -> DescribeStorageResponse -> Bool)
-> (DescribeStorageResponse -> DescribeStorageResponse -> Bool)
-> Eq DescribeStorageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStorageResponse -> DescribeStorageResponse -> Bool
$c/= :: DescribeStorageResponse -> DescribeStorageResponse -> Bool
== :: DescribeStorageResponse -> DescribeStorageResponse -> Bool
$c== :: DescribeStorageResponse -> DescribeStorageResponse -> Bool
Prelude.Eq, ReadPrec [DescribeStorageResponse]
ReadPrec DescribeStorageResponse
Int -> ReadS DescribeStorageResponse
ReadS [DescribeStorageResponse]
(Int -> ReadS DescribeStorageResponse)
-> ReadS [DescribeStorageResponse]
-> ReadPrec DescribeStorageResponse
-> ReadPrec [DescribeStorageResponse]
-> Read DescribeStorageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStorageResponse]
$creadListPrec :: ReadPrec [DescribeStorageResponse]
readPrec :: ReadPrec DescribeStorageResponse
$creadPrec :: ReadPrec DescribeStorageResponse
readList :: ReadS [DescribeStorageResponse]
$creadList :: ReadS [DescribeStorageResponse]
readsPrec :: Int -> ReadS DescribeStorageResponse
$creadsPrec :: Int -> ReadS DescribeStorageResponse
Prelude.Read, Int -> DescribeStorageResponse -> ShowS
[DescribeStorageResponse] -> ShowS
DescribeStorageResponse -> String
(Int -> DescribeStorageResponse -> ShowS)
-> (DescribeStorageResponse -> String)
-> ([DescribeStorageResponse] -> ShowS)
-> Show DescribeStorageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStorageResponse] -> ShowS
$cshowList :: [DescribeStorageResponse] -> ShowS
show :: DescribeStorageResponse -> String
$cshow :: DescribeStorageResponse -> String
showsPrec :: Int -> DescribeStorageResponse -> ShowS
$cshowsPrec :: Int -> DescribeStorageResponse -> ShowS
Prelude.Show, (forall x.
 DescribeStorageResponse -> Rep DescribeStorageResponse x)
-> (forall x.
    Rep DescribeStorageResponse x -> DescribeStorageResponse)
-> Generic DescribeStorageResponse
forall x. Rep DescribeStorageResponse x -> DescribeStorageResponse
forall x. DescribeStorageResponse -> Rep DescribeStorageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStorageResponse x -> DescribeStorageResponse
$cfrom :: forall x. DescribeStorageResponse -> Rep DescribeStorageResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStorageResponse' 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:
--
-- 'totalProvisionedStorageInMegaBytes', 'describeStorageResponse_totalProvisionedStorageInMegaBytes' - The total amount of storage currently provisioned.
--
-- 'totalBackupSizeInMegaBytes', 'describeStorageResponse_totalBackupSizeInMegaBytes' - The total amount of storage currently used for snapshots.
--
-- 'httpStatus', 'describeStorageResponse_httpStatus' - The response's http status code.
newDescribeStorageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeStorageResponse
newDescribeStorageResponse :: Int -> DescribeStorageResponse
newDescribeStorageResponse Int
pHttpStatus_ =
  DescribeStorageResponse' :: Maybe Double -> Maybe Double -> Int -> DescribeStorageResponse
DescribeStorageResponse'
    { $sel:totalProvisionedStorageInMegaBytes:DescribeStorageResponse' :: Maybe Double
totalProvisionedStorageInMegaBytes =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:totalBackupSizeInMegaBytes:DescribeStorageResponse' :: Maybe Double
totalBackupSizeInMegaBytes = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeStorageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The total amount of storage currently provisioned.
describeStorageResponse_totalProvisionedStorageInMegaBytes :: Lens.Lens' DescribeStorageResponse (Prelude.Maybe Prelude.Double)
describeStorageResponse_totalProvisionedStorageInMegaBytes :: (Maybe Double -> f (Maybe Double))
-> DescribeStorageResponse -> f DescribeStorageResponse
describeStorageResponse_totalProvisionedStorageInMegaBytes = (DescribeStorageResponse -> Maybe Double)
-> (DescribeStorageResponse
    -> Maybe Double -> DescribeStorageResponse)
-> Lens
     DescribeStorageResponse
     DescribeStorageResponse
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStorageResponse' {Maybe Double
totalProvisionedStorageInMegaBytes :: Maybe Double
$sel:totalProvisionedStorageInMegaBytes:DescribeStorageResponse' :: DescribeStorageResponse -> Maybe Double
totalProvisionedStorageInMegaBytes} -> Maybe Double
totalProvisionedStorageInMegaBytes) (\s :: DescribeStorageResponse
s@DescribeStorageResponse' {} Maybe Double
a -> DescribeStorageResponse
s {$sel:totalProvisionedStorageInMegaBytes:DescribeStorageResponse' :: Maybe Double
totalProvisionedStorageInMegaBytes = Maybe Double
a} :: DescribeStorageResponse)

-- | The total amount of storage currently used for snapshots.
describeStorageResponse_totalBackupSizeInMegaBytes :: Lens.Lens' DescribeStorageResponse (Prelude.Maybe Prelude.Double)
describeStorageResponse_totalBackupSizeInMegaBytes :: (Maybe Double -> f (Maybe Double))
-> DescribeStorageResponse -> f DescribeStorageResponse
describeStorageResponse_totalBackupSizeInMegaBytes = (DescribeStorageResponse -> Maybe Double)
-> (DescribeStorageResponse
    -> Maybe Double -> DescribeStorageResponse)
-> Lens
     DescribeStorageResponse
     DescribeStorageResponse
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStorageResponse' {Maybe Double
totalBackupSizeInMegaBytes :: Maybe Double
$sel:totalBackupSizeInMegaBytes:DescribeStorageResponse' :: DescribeStorageResponse -> Maybe Double
totalBackupSizeInMegaBytes} -> Maybe Double
totalBackupSizeInMegaBytes) (\s :: DescribeStorageResponse
s@DescribeStorageResponse' {} Maybe Double
a -> DescribeStorageResponse
s {$sel:totalBackupSizeInMegaBytes:DescribeStorageResponse' :: Maybe Double
totalBackupSizeInMegaBytes = Maybe Double
a} :: DescribeStorageResponse)

-- | The response's http status code.
describeStorageResponse_httpStatus :: Lens.Lens' DescribeStorageResponse Prelude.Int
describeStorageResponse_httpStatus :: (Int -> f Int)
-> DescribeStorageResponse -> f DescribeStorageResponse
describeStorageResponse_httpStatus = (DescribeStorageResponse -> Int)
-> (DescribeStorageResponse -> Int -> DescribeStorageResponse)
-> Lens DescribeStorageResponse DescribeStorageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStorageResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeStorageResponse' :: DescribeStorageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeStorageResponse
s@DescribeStorageResponse' {} Int
a -> DescribeStorageResponse
s {$sel:httpStatus:DescribeStorageResponse' :: Int
httpStatus = Int
a} :: DescribeStorageResponse)

instance Prelude.NFData DescribeStorageResponse