{-# 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.DescribeVault
-- 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)
--
-- This operation returns information about a vault, including the vault\'s
-- Amazon Resource Name (ARN), the date the vault was created, the number
-- of archives it contains, and the total size of all the archives in the
-- vault. The number of archives and their total size are as of the last
-- inventory generation. This means that if you add or remove an archive
-- from a vault, and then immediately use Describe Vault, the change in
-- contents will not be immediately reflected. If you want to retrieve the
-- latest inventory of the vault, use InitiateJob. Amazon S3 Glacier
-- generates vault inventories approximately daily. For more information,
-- see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/vault-inventory.html Downloading a Vault Inventory in Amazon S3 Glacier>.
--
-- An AWS account has full permission to perform all operations (actions).
-- However, AWS Identity and Access Management (IAM) users don\'t have any
-- permissions by default. You must grant them explicit permission to
-- perform specific actions. For more information, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html Access Control Using AWS Identity and Access Management (IAM)>.
--
-- For conceptual information and underlying REST API, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/retrieving-vault-info.html Retrieving Vault Metadata in Amazon S3 Glacier>
-- and
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-vault-get.html Describe Vault>
-- in the /Amazon Glacier Developer Guide/.
module Amazonka.Glacier.DescribeVault
  ( -- * Creating a Request
    DescribeVault (..),
    newDescribeVault,

    -- * Request Lenses
    describeVault_accountId,
    describeVault_vaultName,

    -- * Destructuring the Response
    DescribeVaultOutput (..),
    newDescribeVaultOutput,

    -- * Response Lenses
    describeVaultOutput_vaultName,
    describeVaultOutput_sizeInBytes,
    describeVaultOutput_lastInventoryDate,
    describeVaultOutput_vaultARN,
    describeVaultOutput_creationDate,
    describeVaultOutput_numberOfArchives,
  )
where

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

-- | Provides options for retrieving metadata for a specific vault in Amazon
-- Glacier.
--
-- /See:/ 'newDescribeVault' smart constructor.
data DescribeVault = DescribeVault'
  { -- | The @AccountId@ value is 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, do not include any hyphens (\'-\') in the ID.
    DescribeVault -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    DescribeVault -> Text
vaultName :: Prelude.Text
  }
  deriving (DescribeVault -> DescribeVault -> Bool
(DescribeVault -> DescribeVault -> Bool)
-> (DescribeVault -> DescribeVault -> Bool) -> Eq DescribeVault
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeVault -> DescribeVault -> Bool
$c/= :: DescribeVault -> DescribeVault -> Bool
== :: DescribeVault -> DescribeVault -> Bool
$c== :: DescribeVault -> DescribeVault -> Bool
Prelude.Eq, ReadPrec [DescribeVault]
ReadPrec DescribeVault
Int -> ReadS DescribeVault
ReadS [DescribeVault]
(Int -> ReadS DescribeVault)
-> ReadS [DescribeVault]
-> ReadPrec DescribeVault
-> ReadPrec [DescribeVault]
-> Read DescribeVault
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeVault]
$creadListPrec :: ReadPrec [DescribeVault]
readPrec :: ReadPrec DescribeVault
$creadPrec :: ReadPrec DescribeVault
readList :: ReadS [DescribeVault]
$creadList :: ReadS [DescribeVault]
readsPrec :: Int -> ReadS DescribeVault
$creadsPrec :: Int -> ReadS DescribeVault
Prelude.Read, Int -> DescribeVault -> ShowS
[DescribeVault] -> ShowS
DescribeVault -> String
(Int -> DescribeVault -> ShowS)
-> (DescribeVault -> String)
-> ([DescribeVault] -> ShowS)
-> Show DescribeVault
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeVault] -> ShowS
$cshowList :: [DescribeVault] -> ShowS
show :: DescribeVault -> String
$cshow :: DescribeVault -> String
showsPrec :: Int -> DescribeVault -> ShowS
$cshowsPrec :: Int -> DescribeVault -> ShowS
Prelude.Show, (forall x. DescribeVault -> Rep DescribeVault x)
-> (forall x. Rep DescribeVault x -> DescribeVault)
-> Generic DescribeVault
forall x. Rep DescribeVault x -> DescribeVault
forall x. DescribeVault -> Rep DescribeVault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeVault x -> DescribeVault
$cfrom :: forall x. DescribeVault -> Rep DescribeVault x
Prelude.Generic)

-- |
-- Create a value of 'DescribeVault' 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', 'describeVault_accountId' - The @AccountId@ value is 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, do not include any hyphens (\'-\') in the ID.
--
-- 'vaultName', 'describeVault_vaultName' - The name of the vault.
newDescribeVault ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  DescribeVault
newDescribeVault :: Text -> Text -> DescribeVault
newDescribeVault Text
pAccountId_ Text
pVaultName_ =
  DescribeVault' :: Text -> Text -> DescribeVault
DescribeVault'
    { $sel:accountId:DescribeVault' :: Text
accountId = Text
pAccountId_,
      $sel:vaultName:DescribeVault' :: Text
vaultName = Text
pVaultName_
    }

-- | The @AccountId@ value is 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, do not include any hyphens (\'-\') in the ID.
describeVault_accountId :: Lens.Lens' DescribeVault Prelude.Text
describeVault_accountId :: (Text -> f Text) -> DescribeVault -> f DescribeVault
describeVault_accountId = (DescribeVault -> Text)
-> (DescribeVault -> Text -> DescribeVault)
-> Lens DescribeVault DescribeVault Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeVault' {Text
accountId :: Text
$sel:accountId:DescribeVault' :: DescribeVault -> Text
accountId} -> Text
accountId) (\s :: DescribeVault
s@DescribeVault' {} Text
a -> DescribeVault
s {$sel:accountId:DescribeVault' :: Text
accountId = Text
a} :: DescribeVault)

-- | The name of the vault.
describeVault_vaultName :: Lens.Lens' DescribeVault Prelude.Text
describeVault_vaultName :: (Text -> f Text) -> DescribeVault -> f DescribeVault
describeVault_vaultName = (DescribeVault -> Text)
-> (DescribeVault -> Text -> DescribeVault)
-> Lens DescribeVault DescribeVault Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeVault' {Text
vaultName :: Text
$sel:vaultName:DescribeVault' :: DescribeVault -> Text
vaultName} -> Text
vaultName) (\s :: DescribeVault
s@DescribeVault' {} Text
a -> DescribeVault
s {$sel:vaultName:DescribeVault' :: Text
vaultName = Text
a} :: DescribeVault)

instance Core.AWSRequest DescribeVault where
  type AWSResponse DescribeVault = DescribeVaultOutput
  request :: DescribeVault -> Request DescribeVault
request =
    ByteString -> Request DescribeVault -> Request DescribeVault
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
      (Request DescribeVault -> Request DescribeVault)
-> (DescribeVault -> Request DescribeVault)
-> DescribeVault
-> Request DescribeVault
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> DescribeVault -> Request DescribeVault
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeVault)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeVault))
-> Logger
-> Service
-> Proxy DescribeVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeVault)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String DescribeVaultOutput
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable DescribeVault

instance Prelude.NFData DescribeVault

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

instance Core.ToPath DescribeVault where
  toPath :: DescribeVault -> ByteString
toPath DescribeVault' {Text
vaultName :: Text
accountId :: Text
$sel:vaultName:DescribeVault' :: DescribeVault -> Text
$sel:accountId:DescribeVault' :: DescribeVault -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/vaults/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
vaultName
      ]

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