{-# 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.Glacier.ListProvisionedCapacity
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation lists the provisioned capacity units for the specified
-- AWS account.
module Amazonka.Glacier.ListProvisionedCapacity
  ( -- * Creating a Request
    ListProvisionedCapacity (..),
    newListProvisionedCapacity,

    -- * Request Lenses
    listProvisionedCapacity_accountId,

    -- * Destructuring the Response
    ListProvisionedCapacityResponse (..),
    newListProvisionedCapacityResponse,

    -- * Response Lenses
    listProvisionedCapacityResponse_provisionedCapacityList,
    listProvisionedCapacityResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glacier.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListProvisionedCapacity' smart constructor.
data ListProvisionedCapacity = ListProvisionedCapacity'
  { -- | The AWS account ID of the account that owns the vault. You can either
    -- specify an AWS account ID or optionally a single \'-\' (hyphen), in
    -- which case Amazon S3 Glacier uses the AWS account ID associated with the
    -- credentials used to sign the request. If you use an account ID, don\'t
    -- include any hyphens (\'-\') in the ID.
    ListProvisionedCapacity -> Text
accountId :: Prelude.Text
  }
  deriving (ListProvisionedCapacity -> ListProvisionedCapacity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProvisionedCapacity -> ListProvisionedCapacity -> Bool
$c/= :: ListProvisionedCapacity -> ListProvisionedCapacity -> Bool
== :: ListProvisionedCapacity -> ListProvisionedCapacity -> Bool
$c== :: ListProvisionedCapacity -> ListProvisionedCapacity -> Bool
Prelude.Eq, ReadPrec [ListProvisionedCapacity]
ReadPrec ListProvisionedCapacity
Int -> ReadS ListProvisionedCapacity
ReadS [ListProvisionedCapacity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProvisionedCapacity]
$creadListPrec :: ReadPrec [ListProvisionedCapacity]
readPrec :: ReadPrec ListProvisionedCapacity
$creadPrec :: ReadPrec ListProvisionedCapacity
readList :: ReadS [ListProvisionedCapacity]
$creadList :: ReadS [ListProvisionedCapacity]
readsPrec :: Int -> ReadS ListProvisionedCapacity
$creadsPrec :: Int -> ReadS ListProvisionedCapacity
Prelude.Read, Int -> ListProvisionedCapacity -> ShowS
[ListProvisionedCapacity] -> ShowS
ListProvisionedCapacity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProvisionedCapacity] -> ShowS
$cshowList :: [ListProvisionedCapacity] -> ShowS
show :: ListProvisionedCapacity -> String
$cshow :: ListProvisionedCapacity -> String
showsPrec :: Int -> ListProvisionedCapacity -> ShowS
$cshowsPrec :: Int -> ListProvisionedCapacity -> ShowS
Prelude.Show, forall x. Rep ListProvisionedCapacity x -> ListProvisionedCapacity
forall x. ListProvisionedCapacity -> Rep ListProvisionedCapacity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListProvisionedCapacity x -> ListProvisionedCapacity
$cfrom :: forall x. ListProvisionedCapacity -> Rep ListProvisionedCapacity x
Prelude.Generic)

-- |
-- Create a value of 'ListProvisionedCapacity' 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:
--
-- 'accountId', 'listProvisionedCapacity_accountId' - The AWS account ID of the account that owns the vault. You can either
-- specify an AWS account ID or optionally a single \'-\' (hyphen), in
-- which case Amazon S3 Glacier uses the AWS account ID associated with the
-- credentials used to sign the request. If you use an account ID, don\'t
-- include any hyphens (\'-\') in the ID.
newListProvisionedCapacity ::
  -- | 'accountId'
  Prelude.Text ->
  ListProvisionedCapacity
newListProvisionedCapacity :: Text -> ListProvisionedCapacity
newListProvisionedCapacity Text
pAccountId_ =
  ListProvisionedCapacity' {$sel:accountId:ListProvisionedCapacity' :: Text
accountId = Text
pAccountId_}

-- | The AWS account ID of the account that owns the vault. You can either
-- specify an AWS account ID or optionally a single \'-\' (hyphen), in
-- which case Amazon S3 Glacier uses the AWS account ID associated with the
-- credentials used to sign the request. If you use an account ID, don\'t
-- include any hyphens (\'-\') in the ID.
listProvisionedCapacity_accountId :: Lens.Lens' ListProvisionedCapacity Prelude.Text
listProvisionedCapacity_accountId :: Lens' ListProvisionedCapacity Text
listProvisionedCapacity_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProvisionedCapacity' {Text
accountId :: Text
$sel:accountId:ListProvisionedCapacity' :: ListProvisionedCapacity -> Text
accountId} -> Text
accountId) (\s :: ListProvisionedCapacity
s@ListProvisionedCapacity' {} Text
a -> ListProvisionedCapacity
s {$sel:accountId:ListProvisionedCapacity' :: Text
accountId = Text
a} :: ListProvisionedCapacity)

instance Core.AWSRequest ListProvisionedCapacity where
  type
    AWSResponse ListProvisionedCapacity =
      ListProvisionedCapacityResponse
  request :: (Service -> Service)
-> ListProvisionedCapacity -> Request ListProvisionedCapacity
request Service -> Service
overrides =
    forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core.version Service
defaultService)
      forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListProvisionedCapacity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListProvisionedCapacity)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ProvisionedCapacityDescription]
-> Int -> ListProvisionedCapacityResponse
ListProvisionedCapacityResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ProvisionedCapacityList"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListProvisionedCapacity where
  hashWithSalt :: Int -> ListProvisionedCapacity -> Int
hashWithSalt Int
_salt ListProvisionedCapacity' {Text
accountId :: Text
$sel:accountId:ListProvisionedCapacity' :: ListProvisionedCapacity -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId

instance Prelude.NFData ListProvisionedCapacity where
  rnf :: ListProvisionedCapacity -> ()
rnf ListProvisionedCapacity' {Text
accountId :: Text
$sel:accountId:ListProvisionedCapacity' :: ListProvisionedCapacity -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
accountId

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

instance Data.ToPath ListProvisionedCapacity where
  toPath :: ListProvisionedCapacity -> ByteString
toPath ListProvisionedCapacity' {Text
accountId :: Text
$sel:accountId:ListProvisionedCapacity' :: ListProvisionedCapacity -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
accountId, ByteString
"/provisioned-capacity"]

instance Data.ToQuery ListProvisionedCapacity where
  toQuery :: ListProvisionedCapacity -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListProvisionedCapacityResponse' smart constructor.
data ListProvisionedCapacityResponse = ListProvisionedCapacityResponse'
  { -- | The response body contains the following JSON fields.
    ListProvisionedCapacityResponse
-> Maybe [ProvisionedCapacityDescription]
provisionedCapacityList :: Prelude.Maybe [ProvisionedCapacityDescription],
    -- | The response's http status code.
    ListProvisionedCapacityResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListProvisionedCapacityResponse
-> ListProvisionedCapacityResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProvisionedCapacityResponse
-> ListProvisionedCapacityResponse -> Bool
$c/= :: ListProvisionedCapacityResponse
-> ListProvisionedCapacityResponse -> Bool
== :: ListProvisionedCapacityResponse
-> ListProvisionedCapacityResponse -> Bool
$c== :: ListProvisionedCapacityResponse
-> ListProvisionedCapacityResponse -> Bool
Prelude.Eq, ReadPrec [ListProvisionedCapacityResponse]
ReadPrec ListProvisionedCapacityResponse
Int -> ReadS ListProvisionedCapacityResponse
ReadS [ListProvisionedCapacityResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProvisionedCapacityResponse]
$creadListPrec :: ReadPrec [ListProvisionedCapacityResponse]
readPrec :: ReadPrec ListProvisionedCapacityResponse
$creadPrec :: ReadPrec ListProvisionedCapacityResponse
readList :: ReadS [ListProvisionedCapacityResponse]
$creadList :: ReadS [ListProvisionedCapacityResponse]
readsPrec :: Int -> ReadS ListProvisionedCapacityResponse
$creadsPrec :: Int -> ReadS ListProvisionedCapacityResponse
Prelude.Read, Int -> ListProvisionedCapacityResponse -> ShowS
[ListProvisionedCapacityResponse] -> ShowS
ListProvisionedCapacityResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProvisionedCapacityResponse] -> ShowS
$cshowList :: [ListProvisionedCapacityResponse] -> ShowS
show :: ListProvisionedCapacityResponse -> String
$cshow :: ListProvisionedCapacityResponse -> String
showsPrec :: Int -> ListProvisionedCapacityResponse -> ShowS
$cshowsPrec :: Int -> ListProvisionedCapacityResponse -> ShowS
Prelude.Show, forall x.
Rep ListProvisionedCapacityResponse x
-> ListProvisionedCapacityResponse
forall x.
ListProvisionedCapacityResponse
-> Rep ListProvisionedCapacityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListProvisionedCapacityResponse x
-> ListProvisionedCapacityResponse
$cfrom :: forall x.
ListProvisionedCapacityResponse
-> Rep ListProvisionedCapacityResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListProvisionedCapacityResponse' 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:
--
-- 'provisionedCapacityList', 'listProvisionedCapacityResponse_provisionedCapacityList' - The response body contains the following JSON fields.
--
-- 'httpStatus', 'listProvisionedCapacityResponse_httpStatus' - The response's http status code.
newListProvisionedCapacityResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListProvisionedCapacityResponse
newListProvisionedCapacityResponse :: Int -> ListProvisionedCapacityResponse
newListProvisionedCapacityResponse Int
pHttpStatus_ =
  ListProvisionedCapacityResponse'
    { $sel:provisionedCapacityList:ListProvisionedCapacityResponse' :: Maybe [ProvisionedCapacityDescription]
provisionedCapacityList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListProvisionedCapacityResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The response body contains the following JSON fields.
listProvisionedCapacityResponse_provisionedCapacityList :: Lens.Lens' ListProvisionedCapacityResponse (Prelude.Maybe [ProvisionedCapacityDescription])
listProvisionedCapacityResponse_provisionedCapacityList :: Lens'
  ListProvisionedCapacityResponse
  (Maybe [ProvisionedCapacityDescription])
listProvisionedCapacityResponse_provisionedCapacityList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProvisionedCapacityResponse' {Maybe [ProvisionedCapacityDescription]
provisionedCapacityList :: Maybe [ProvisionedCapacityDescription]
$sel:provisionedCapacityList:ListProvisionedCapacityResponse' :: ListProvisionedCapacityResponse
-> Maybe [ProvisionedCapacityDescription]
provisionedCapacityList} -> Maybe [ProvisionedCapacityDescription]
provisionedCapacityList) (\s :: ListProvisionedCapacityResponse
s@ListProvisionedCapacityResponse' {} Maybe [ProvisionedCapacityDescription]
a -> ListProvisionedCapacityResponse
s {$sel:provisionedCapacityList:ListProvisionedCapacityResponse' :: Maybe [ProvisionedCapacityDescription]
provisionedCapacityList = Maybe [ProvisionedCapacityDescription]
a} :: ListProvisionedCapacityResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListProvisionedCapacityResponse
  where
  rnf :: ListProvisionedCapacityResponse -> ()
rnf ListProvisionedCapacityResponse' {Int
Maybe [ProvisionedCapacityDescription]
httpStatus :: Int
provisionedCapacityList :: Maybe [ProvisionedCapacityDescription]
$sel:httpStatus:ListProvisionedCapacityResponse' :: ListProvisionedCapacityResponse -> Int
$sel:provisionedCapacityList:ListProvisionedCapacityResponse' :: ListProvisionedCapacityResponse
-> Maybe [ProvisionedCapacityDescription]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ProvisionedCapacityDescription]
provisionedCapacityList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus