{-# 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.ListTagsForVault
-- 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 all the tags attached to a vault. The operation
-- returns an empty map if there are no tags. For more information about
-- tags, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/tagging.html Tagging Amazon S3 Glacier Resources>.
module Amazonka.Glacier.ListTagsForVault
  ( -- * Creating a Request
    ListTagsForVault (..),
    newListTagsForVault,

    -- * Request Lenses
    listTagsForVault_accountId,
    listTagsForVault_vaultName,

    -- * Destructuring the Response
    ListTagsForVaultResponse (..),
    newListTagsForVaultResponse,

    -- * Response Lenses
    listTagsForVaultResponse_tags,
    listTagsForVaultResponse_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

-- | The input value for @ListTagsForVaultInput@.
--
-- /See:/ 'newListTagsForVault' smart constructor.
data ListTagsForVault = ListTagsForVault'
  { -- | 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.
    ListTagsForVault -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    ListTagsForVault -> Text
vaultName :: Prelude.Text
  }
  deriving (ListTagsForVault -> ListTagsForVault -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForVault -> ListTagsForVault -> Bool
$c/= :: ListTagsForVault -> ListTagsForVault -> Bool
== :: ListTagsForVault -> ListTagsForVault -> Bool
$c== :: ListTagsForVault -> ListTagsForVault -> Bool
Prelude.Eq, ReadPrec [ListTagsForVault]
ReadPrec ListTagsForVault
Int -> ReadS ListTagsForVault
ReadS [ListTagsForVault]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForVault]
$creadListPrec :: ReadPrec [ListTagsForVault]
readPrec :: ReadPrec ListTagsForVault
$creadPrec :: ReadPrec ListTagsForVault
readList :: ReadS [ListTagsForVault]
$creadList :: ReadS [ListTagsForVault]
readsPrec :: Int -> ReadS ListTagsForVault
$creadsPrec :: Int -> ReadS ListTagsForVault
Prelude.Read, Int -> ListTagsForVault -> ShowS
[ListTagsForVault] -> ShowS
ListTagsForVault -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForVault] -> ShowS
$cshowList :: [ListTagsForVault] -> ShowS
show :: ListTagsForVault -> String
$cshow :: ListTagsForVault -> String
showsPrec :: Int -> ListTagsForVault -> ShowS
$cshowsPrec :: Int -> ListTagsForVault -> ShowS
Prelude.Show, forall x. Rep ListTagsForVault x -> ListTagsForVault
forall x. ListTagsForVault -> Rep ListTagsForVault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTagsForVault x -> ListTagsForVault
$cfrom :: forall x. ListTagsForVault -> Rep ListTagsForVault x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForVault' 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', 'listTagsForVault_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', 'listTagsForVault_vaultName' - The name of the vault.
newListTagsForVault ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  ListTagsForVault
newListTagsForVault :: Text -> Text -> ListTagsForVault
newListTagsForVault Text
pAccountId_ Text
pVaultName_ =
  ListTagsForVault'
    { $sel:accountId:ListTagsForVault' :: Text
accountId = Text
pAccountId_,
      $sel:vaultName:ListTagsForVault' :: 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.
listTagsForVault_accountId :: Lens.Lens' ListTagsForVault Prelude.Text
listTagsForVault_accountId :: Lens' ListTagsForVault Text
listTagsForVault_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForVault' {Text
accountId :: Text
$sel:accountId:ListTagsForVault' :: ListTagsForVault -> Text
accountId} -> Text
accountId) (\s :: ListTagsForVault
s@ListTagsForVault' {} Text
a -> ListTagsForVault
s {$sel:accountId:ListTagsForVault' :: Text
accountId = Text
a} :: ListTagsForVault)

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

instance Core.AWSRequest ListTagsForVault where
  type
    AWSResponse ListTagsForVault =
      ListTagsForVaultResponse
  request :: (Service -> Service)
-> ListTagsForVault -> Request ListTagsForVault
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 ListTagsForVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTagsForVault)))
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 (HashMap Text Text) -> Int -> ListTagsForVaultResponse
ListTagsForVaultResponse'
            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
"Tags" 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 ListTagsForVault where
  hashWithSalt :: Int -> ListTagsForVault -> Int
hashWithSalt Int
_salt ListTagsForVault' {Text
vaultName :: Text
accountId :: Text
$sel:vaultName:ListTagsForVault' :: ListTagsForVault -> Text
$sel:accountId:ListTagsForVault' :: ListTagsForVault -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vaultName

instance Prelude.NFData ListTagsForVault where
  rnf :: ListTagsForVault -> ()
rnf ListTagsForVault' {Text
vaultName :: Text
accountId :: Text
$sel:vaultName:ListTagsForVault' :: ListTagsForVault -> Text
$sel:accountId:ListTagsForVault' :: ListTagsForVault -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vaultName

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

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

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

-- | Contains the Amazon S3 Glacier response to your request.
--
-- /See:/ 'newListTagsForVaultResponse' smart constructor.
data ListTagsForVaultResponse = ListTagsForVaultResponse'
  { -- | The tags attached to the vault. Each tag is composed of a key and a
    -- value.
    ListTagsForVaultResponse -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The response's http status code.
    ListTagsForVaultResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool
$c/= :: ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool
== :: ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool
$c== :: ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool
Prelude.Eq, ReadPrec [ListTagsForVaultResponse]
ReadPrec ListTagsForVaultResponse
Int -> ReadS ListTagsForVaultResponse
ReadS [ListTagsForVaultResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForVaultResponse]
$creadListPrec :: ReadPrec [ListTagsForVaultResponse]
readPrec :: ReadPrec ListTagsForVaultResponse
$creadPrec :: ReadPrec ListTagsForVaultResponse
readList :: ReadS [ListTagsForVaultResponse]
$creadList :: ReadS [ListTagsForVaultResponse]
readsPrec :: Int -> ReadS ListTagsForVaultResponse
$creadsPrec :: Int -> ReadS ListTagsForVaultResponse
Prelude.Read, Int -> ListTagsForVaultResponse -> ShowS
[ListTagsForVaultResponse] -> ShowS
ListTagsForVaultResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForVaultResponse] -> ShowS
$cshowList :: [ListTagsForVaultResponse] -> ShowS
show :: ListTagsForVaultResponse -> String
$cshow :: ListTagsForVaultResponse -> String
showsPrec :: Int -> ListTagsForVaultResponse -> ShowS
$cshowsPrec :: Int -> ListTagsForVaultResponse -> ShowS
Prelude.Show, forall x.
Rep ListTagsForVaultResponse x -> ListTagsForVaultResponse
forall x.
ListTagsForVaultResponse -> Rep ListTagsForVaultResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTagsForVaultResponse x -> ListTagsForVaultResponse
$cfrom :: forall x.
ListTagsForVaultResponse -> Rep ListTagsForVaultResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForVaultResponse' 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:
--
-- 'tags', 'listTagsForVaultResponse_tags' - The tags attached to the vault. Each tag is composed of a key and a
-- value.
--
-- 'httpStatus', 'listTagsForVaultResponse_httpStatus' - The response's http status code.
newListTagsForVaultResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForVaultResponse
newListTagsForVaultResponse :: Int -> ListTagsForVaultResponse
newListTagsForVaultResponse Int
pHttpStatus_ =
  ListTagsForVaultResponse'
    { $sel:tags:ListTagsForVaultResponse' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTagsForVaultResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The tags attached to the vault. Each tag is composed of a key and a
-- value.
listTagsForVaultResponse_tags :: Lens.Lens' ListTagsForVaultResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listTagsForVaultResponse_tags :: Lens' ListTagsForVaultResponse (Maybe (HashMap Text Text))
listTagsForVaultResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForVaultResponse' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ListTagsForVaultResponse' :: ListTagsForVaultResponse -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ListTagsForVaultResponse
s@ListTagsForVaultResponse' {} Maybe (HashMap Text Text)
a -> ListTagsForVaultResponse
s {$sel:tags:ListTagsForVaultResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ListTagsForVaultResponse) 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.
listTagsForVaultResponse_httpStatus :: Lens.Lens' ListTagsForVaultResponse Prelude.Int
listTagsForVaultResponse_httpStatus :: Lens' ListTagsForVaultResponse Int
listTagsForVaultResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForVaultResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTagsForVaultResponse' :: ListTagsForVaultResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTagsForVaultResponse
s@ListTagsForVaultResponse' {} Int
a -> ListTagsForVaultResponse
s {$sel:httpStatus:ListTagsForVaultResponse' :: Int
httpStatus = Int
a} :: ListTagsForVaultResponse)

instance Prelude.NFData ListTagsForVaultResponse where
  rnf :: ListTagsForVaultResponse -> ()
rnf ListTagsForVaultResponse' {Int
Maybe (HashMap Text Text)
httpStatus :: Int
tags :: Maybe (HashMap Text Text)
$sel:httpStatus:ListTagsForVaultResponse' :: ListTagsForVaultResponse -> Int
$sel:tags:ListTagsForVaultResponse' :: ListTagsForVaultResponse -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus