{-# 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.Backup.ListBackupVaults
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of recovery point storage containers along with
-- information about them.
--
-- This operation returns paginated results.
module Amazonka.Backup.ListBackupVaults
  ( -- * Creating a Request
    ListBackupVaults (..),
    newListBackupVaults,

    -- * Request Lenses
    listBackupVaults_maxResults,
    listBackupVaults_nextToken,

    -- * Destructuring the Response
    ListBackupVaultsResponse (..),
    newListBackupVaultsResponse,

    -- * Response Lenses
    listBackupVaultsResponse_backupVaultList,
    listBackupVaultsResponse_nextToken,
    listBackupVaultsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListBackupVaults' smart constructor.
data ListBackupVaults = ListBackupVaults'
  { -- | The maximum number of items to be returned.
    ListBackupVaults -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The next item following a partial list of returned items. For example,
    -- if a request is made to return @maxResults@ number of items, @NextToken@
    -- allows you to return more items in your list starting at the location
    -- pointed to by the next token.
    ListBackupVaults -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListBackupVaults -> ListBackupVaults -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBackupVaults -> ListBackupVaults -> Bool
$c/= :: ListBackupVaults -> ListBackupVaults -> Bool
== :: ListBackupVaults -> ListBackupVaults -> Bool
$c== :: ListBackupVaults -> ListBackupVaults -> Bool
Prelude.Eq, ReadPrec [ListBackupVaults]
ReadPrec ListBackupVaults
Int -> ReadS ListBackupVaults
ReadS [ListBackupVaults]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBackupVaults]
$creadListPrec :: ReadPrec [ListBackupVaults]
readPrec :: ReadPrec ListBackupVaults
$creadPrec :: ReadPrec ListBackupVaults
readList :: ReadS [ListBackupVaults]
$creadList :: ReadS [ListBackupVaults]
readsPrec :: Int -> ReadS ListBackupVaults
$creadsPrec :: Int -> ReadS ListBackupVaults
Prelude.Read, Int -> ListBackupVaults -> ShowS
[ListBackupVaults] -> ShowS
ListBackupVaults -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBackupVaults] -> ShowS
$cshowList :: [ListBackupVaults] -> ShowS
show :: ListBackupVaults -> String
$cshow :: ListBackupVaults -> String
showsPrec :: Int -> ListBackupVaults -> ShowS
$cshowsPrec :: Int -> ListBackupVaults -> ShowS
Prelude.Show, forall x. Rep ListBackupVaults x -> ListBackupVaults
forall x. ListBackupVaults -> Rep ListBackupVaults x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBackupVaults x -> ListBackupVaults
$cfrom :: forall x. ListBackupVaults -> Rep ListBackupVaults x
Prelude.Generic)

-- |
-- Create a value of 'ListBackupVaults' 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:
--
-- 'maxResults', 'listBackupVaults_maxResults' - The maximum number of items to be returned.
--
-- 'nextToken', 'listBackupVaults_nextToken' - The next item following a partial list of returned items. For example,
-- if a request is made to return @maxResults@ number of items, @NextToken@
-- allows you to return more items in your list starting at the location
-- pointed to by the next token.
newListBackupVaults ::
  ListBackupVaults
newListBackupVaults :: ListBackupVaults
newListBackupVaults =
  ListBackupVaults'
    { $sel:maxResults:ListBackupVaults' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBackupVaults' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of items to be returned.
listBackupVaults_maxResults :: Lens.Lens' ListBackupVaults (Prelude.Maybe Prelude.Natural)
listBackupVaults_maxResults :: Lens' ListBackupVaults (Maybe Natural)
listBackupVaults_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackupVaults' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListBackupVaults' :: ListBackupVaults -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListBackupVaults
s@ListBackupVaults' {} Maybe Natural
a -> ListBackupVaults
s {$sel:maxResults:ListBackupVaults' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListBackupVaults)

-- | The next item following a partial list of returned items. For example,
-- if a request is made to return @maxResults@ number of items, @NextToken@
-- allows you to return more items in your list starting at the location
-- pointed to by the next token.
listBackupVaults_nextToken :: Lens.Lens' ListBackupVaults (Prelude.Maybe Prelude.Text)
listBackupVaults_nextToken :: Lens' ListBackupVaults (Maybe Text)
listBackupVaults_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackupVaults' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBackupVaults' :: ListBackupVaults -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBackupVaults
s@ListBackupVaults' {} Maybe Text
a -> ListBackupVaults
s {$sel:nextToken:ListBackupVaults' :: Maybe Text
nextToken = Maybe Text
a} :: ListBackupVaults)

instance Core.AWSPager ListBackupVaults where
  page :: ListBackupVaults
-> AWSResponse ListBackupVaults -> Maybe ListBackupVaults
page ListBackupVaults
rq AWSResponse ListBackupVaults
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBackupVaults
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListBackupVaultsResponse (Maybe Text)
listBackupVaultsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBackupVaults
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListBackupVaultsResponse (Maybe [BackupVaultListMember])
listBackupVaultsResponse_backupVaultList
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListBackupVaults
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListBackupVaults (Maybe Text)
listBackupVaults_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListBackupVaults
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListBackupVaultsResponse (Maybe Text)
listBackupVaultsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListBackupVaults where
  type
    AWSResponse ListBackupVaults =
      ListBackupVaultsResponse
  request :: (Service -> Service)
-> ListBackupVaults -> Request ListBackupVaults
request Service -> Service
overrides =
    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 ListBackupVaults
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBackupVaults)))
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 [BackupVaultListMember]
-> Maybe Text -> Int -> ListBackupVaultsResponse
ListBackupVaultsResponse'
            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
"BackupVaultList"
                            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            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 ListBackupVaults where
  hashWithSalt :: Int -> ListBackupVaults -> Int
hashWithSalt Int
_salt ListBackupVaults' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListBackupVaults' :: ListBackupVaults -> Maybe Text
$sel:maxResults:ListBackupVaults' :: ListBackupVaults -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListBackupVaults where
  rnf :: ListBackupVaults -> ()
rnf ListBackupVaults' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListBackupVaults' :: ListBackupVaults -> Maybe Text
$sel:maxResults:ListBackupVaults' :: ListBackupVaults -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListBackupVaults where
  toHeaders :: ListBackupVaults -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListBackupVaults where
  toPath :: ListBackupVaults -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/backup-vaults/"

instance Data.ToQuery ListBackupVaults where
  toQuery :: ListBackupVaults -> QueryString
toQuery ListBackupVaults' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListBackupVaults' :: ListBackupVaults -> Maybe Text
$sel:maxResults:ListBackupVaults' :: ListBackupVaults -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListBackupVaultsResponse' smart constructor.
data ListBackupVaultsResponse = ListBackupVaultsResponse'
  { -- | An array of backup vault list members containing vault metadata,
    -- including Amazon Resource Name (ARN), display name, creation date,
    -- number of saved recovery points, and encryption information if the
    -- resources saved in the backup vault are encrypted.
    ListBackupVaultsResponse -> Maybe [BackupVaultListMember]
backupVaultList :: Prelude.Maybe [BackupVaultListMember],
    -- | The next item following a partial list of returned items. For example,
    -- if a request is made to return @maxResults@ number of items, @NextToken@
    -- allows you to return more items in your list starting at the location
    -- pointed to by the next token.
    ListBackupVaultsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListBackupVaultsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListBackupVaultsResponse -> ListBackupVaultsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBackupVaultsResponse -> ListBackupVaultsResponse -> Bool
$c/= :: ListBackupVaultsResponse -> ListBackupVaultsResponse -> Bool
== :: ListBackupVaultsResponse -> ListBackupVaultsResponse -> Bool
$c== :: ListBackupVaultsResponse -> ListBackupVaultsResponse -> Bool
Prelude.Eq, ReadPrec [ListBackupVaultsResponse]
ReadPrec ListBackupVaultsResponse
Int -> ReadS ListBackupVaultsResponse
ReadS [ListBackupVaultsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBackupVaultsResponse]
$creadListPrec :: ReadPrec [ListBackupVaultsResponse]
readPrec :: ReadPrec ListBackupVaultsResponse
$creadPrec :: ReadPrec ListBackupVaultsResponse
readList :: ReadS [ListBackupVaultsResponse]
$creadList :: ReadS [ListBackupVaultsResponse]
readsPrec :: Int -> ReadS ListBackupVaultsResponse
$creadsPrec :: Int -> ReadS ListBackupVaultsResponse
Prelude.Read, Int -> ListBackupVaultsResponse -> ShowS
[ListBackupVaultsResponse] -> ShowS
ListBackupVaultsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBackupVaultsResponse] -> ShowS
$cshowList :: [ListBackupVaultsResponse] -> ShowS
show :: ListBackupVaultsResponse -> String
$cshow :: ListBackupVaultsResponse -> String
showsPrec :: Int -> ListBackupVaultsResponse -> ShowS
$cshowsPrec :: Int -> ListBackupVaultsResponse -> ShowS
Prelude.Show, forall x.
Rep ListBackupVaultsResponse x -> ListBackupVaultsResponse
forall x.
ListBackupVaultsResponse -> Rep ListBackupVaultsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListBackupVaultsResponse x -> ListBackupVaultsResponse
$cfrom :: forall x.
ListBackupVaultsResponse -> Rep ListBackupVaultsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListBackupVaultsResponse' 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:
--
-- 'backupVaultList', 'listBackupVaultsResponse_backupVaultList' - An array of backup vault list members containing vault metadata,
-- including Amazon Resource Name (ARN), display name, creation date,
-- number of saved recovery points, and encryption information if the
-- resources saved in the backup vault are encrypted.
--
-- 'nextToken', 'listBackupVaultsResponse_nextToken' - The next item following a partial list of returned items. For example,
-- if a request is made to return @maxResults@ number of items, @NextToken@
-- allows you to return more items in your list starting at the location
-- pointed to by the next token.
--
-- 'httpStatus', 'listBackupVaultsResponse_httpStatus' - The response's http status code.
newListBackupVaultsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListBackupVaultsResponse
newListBackupVaultsResponse :: Int -> ListBackupVaultsResponse
newListBackupVaultsResponse Int
pHttpStatus_ =
  ListBackupVaultsResponse'
    { $sel:backupVaultList:ListBackupVaultsResponse' :: Maybe [BackupVaultListMember]
backupVaultList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBackupVaultsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListBackupVaultsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of backup vault list members containing vault metadata,
-- including Amazon Resource Name (ARN), display name, creation date,
-- number of saved recovery points, and encryption information if the
-- resources saved in the backup vault are encrypted.
listBackupVaultsResponse_backupVaultList :: Lens.Lens' ListBackupVaultsResponse (Prelude.Maybe [BackupVaultListMember])
listBackupVaultsResponse_backupVaultList :: Lens' ListBackupVaultsResponse (Maybe [BackupVaultListMember])
listBackupVaultsResponse_backupVaultList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackupVaultsResponse' {Maybe [BackupVaultListMember]
backupVaultList :: Maybe [BackupVaultListMember]
$sel:backupVaultList:ListBackupVaultsResponse' :: ListBackupVaultsResponse -> Maybe [BackupVaultListMember]
backupVaultList} -> Maybe [BackupVaultListMember]
backupVaultList) (\s :: ListBackupVaultsResponse
s@ListBackupVaultsResponse' {} Maybe [BackupVaultListMember]
a -> ListBackupVaultsResponse
s {$sel:backupVaultList:ListBackupVaultsResponse' :: Maybe [BackupVaultListMember]
backupVaultList = Maybe [BackupVaultListMember]
a} :: ListBackupVaultsResponse) 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 next item following a partial list of returned items. For example,
-- if a request is made to return @maxResults@ number of items, @NextToken@
-- allows you to return more items in your list starting at the location
-- pointed to by the next token.
listBackupVaultsResponse_nextToken :: Lens.Lens' ListBackupVaultsResponse (Prelude.Maybe Prelude.Text)
listBackupVaultsResponse_nextToken :: Lens' ListBackupVaultsResponse (Maybe Text)
listBackupVaultsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackupVaultsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBackupVaultsResponse' :: ListBackupVaultsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBackupVaultsResponse
s@ListBackupVaultsResponse' {} Maybe Text
a -> ListBackupVaultsResponse
s {$sel:nextToken:ListBackupVaultsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListBackupVaultsResponse)

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

instance Prelude.NFData ListBackupVaultsResponse where
  rnf :: ListBackupVaultsResponse -> ()
rnf ListBackupVaultsResponse' {Int
Maybe [BackupVaultListMember]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
backupVaultList :: Maybe [BackupVaultListMember]
$sel:httpStatus:ListBackupVaultsResponse' :: ListBackupVaultsResponse -> Int
$sel:nextToken:ListBackupVaultsResponse' :: ListBackupVaultsResponse -> Maybe Text
$sel:backupVaultList:ListBackupVaultsResponse' :: ListBackupVaultsResponse -> Maybe [BackupVaultListMember]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [BackupVaultListMember]
backupVaultList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus