{-# 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-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 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 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

-- | 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
(ListTagsForVault -> ListTagsForVault -> Bool)
-> (ListTagsForVault -> ListTagsForVault -> Bool)
-> Eq ListTagsForVault
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]
(Int -> ReadS ListTagsForVault)
-> ReadS [ListTagsForVault]
-> ReadPrec ListTagsForVault
-> ReadPrec [ListTagsForVault]
-> Read 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
(Int -> ListTagsForVault -> ShowS)
-> (ListTagsForVault -> String)
-> ([ListTagsForVault] -> ShowS)
-> Show ListTagsForVault
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. ListTagsForVault -> Rep ListTagsForVault x)
-> (forall x. Rep ListTagsForVault x -> ListTagsForVault)
-> Generic ListTagsForVault
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' :: Text -> Text -> ListTagsForVault
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 :: (Text -> f Text) -> ListTagsForVault -> f ListTagsForVault
listTagsForVault_accountId = (ListTagsForVault -> Text)
-> (ListTagsForVault -> Text -> ListTagsForVault)
-> Lens ListTagsForVault ListTagsForVault Text Text
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 :: (Text -> f Text) -> ListTagsForVault -> f ListTagsForVault
listTagsForVault_vaultName = (ListTagsForVault -> Text)
-> (ListTagsForVault -> Text -> ListTagsForVault)
-> Lens ListTagsForVault ListTagsForVault Text Text
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 :: ListTagsForVault -> Request ListTagsForVault
request =
    ByteString -> Request ListTagsForVault -> Request ListTagsForVault
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
      (Request ListTagsForVault -> Request ListTagsForVault)
-> (ListTagsForVault -> Request ListTagsForVault)
-> ListTagsForVault
-> Request ListTagsForVault
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> ListTagsForVault -> Request ListTagsForVault
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTagsForVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTagsForVault)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListTagsForVault))
-> Logger
-> Service
-> Proxy ListTagsForVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTagsForVault)))
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 ->
          Maybe (HashMap Text Text) -> Int -> ListTagsForVaultResponse
ListTagsForVaultResponse'
            (Maybe (HashMap Text Text) -> Int -> ListTagsForVaultResponse)
-> Either String (Maybe (HashMap Text Text))
-> Either String (Int -> ListTagsForVaultResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Tags" Either String (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text)
-> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListTagsForVaultResponse)
-> Either String Int -> Either String ListTagsForVaultResponse
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 ListTagsForVault

instance Prelude.NFData ListTagsForVault

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

instance Core.ToPath ListTagsForVault where
  toPath :: ListTagsForVault -> ByteString
toPath ListTagsForVault' {Text
vaultName :: Text
accountId :: Text
$sel:vaultName:ListTagsForVault' :: ListTagsForVault -> Text
$sel:accountId:ListTagsForVault' :: ListTagsForVault -> 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,
        ByteString
"/tags"
      ]

instance Core.ToQuery ListTagsForVault where
  toQuery :: ListTagsForVault -> QueryString
toQuery = QueryString -> ListTagsForVault -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool)
-> (ListTagsForVaultResponse -> ListTagsForVaultResponse -> Bool)
-> Eq ListTagsForVaultResponse
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]
(Int -> ReadS ListTagsForVaultResponse)
-> ReadS [ListTagsForVaultResponse]
-> ReadPrec ListTagsForVaultResponse
-> ReadPrec [ListTagsForVaultResponse]
-> Read 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
(Int -> ListTagsForVaultResponse -> ShowS)
-> (ListTagsForVaultResponse -> String)
-> ([ListTagsForVaultResponse] -> ShowS)
-> Show ListTagsForVaultResponse
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.
 ListTagsForVaultResponse -> Rep ListTagsForVaultResponse x)
-> (forall x.
    Rep ListTagsForVaultResponse x -> ListTagsForVaultResponse)
-> Generic ListTagsForVaultResponse
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' :: Maybe (HashMap Text Text) -> Int -> ListTagsForVaultResponse
ListTagsForVaultResponse'
    { $sel:tags:ListTagsForVaultResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListTagsForVaultResponse -> f ListTagsForVaultResponse
listTagsForVaultResponse_tags = (ListTagsForVaultResponse -> Maybe (HashMap Text Text))
-> (ListTagsForVaultResponse
    -> Maybe (HashMap Text Text) -> ListTagsForVaultResponse)
-> Lens
     ListTagsForVaultResponse
     ListTagsForVaultResponse
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ListTagsForVaultResponse -> f ListTagsForVaultResponse)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListTagsForVaultResponse
-> f ListTagsForVaultResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (Int -> f Int)
-> ListTagsForVaultResponse -> f ListTagsForVaultResponse
listTagsForVaultResponse_httpStatus = (ListTagsForVaultResponse -> Int)
-> (ListTagsForVaultResponse -> Int -> ListTagsForVaultResponse)
-> Lens ListTagsForVaultResponse ListTagsForVaultResponse Int Int
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