{-# 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.AmplifyBackend.ListS3Buckets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The list of S3 buckets in your account.
module Amazonka.AmplifyBackend.ListS3Buckets
  ( -- * Creating a Request
    ListS3Buckets (..),
    newListS3Buckets,

    -- * Request Lenses
    listS3Buckets_nextToken,

    -- * Destructuring the Response
    ListS3BucketsResponse (..),
    newListS3BucketsResponse,

    -- * Response Lenses
    listS3BucketsResponse_buckets,
    listS3BucketsResponse_nextToken,
    listS3BucketsResponse_httpStatus,
  )
where

import Amazonka.AmplifyBackend.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

-- | The request body for S3Buckets.
--
-- /See:/ 'newListS3Buckets' smart constructor.
data ListS3Buckets = ListS3Buckets'
  { -- | Reserved for future use.
    ListS3Buckets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListS3Buckets -> ListS3Buckets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListS3Buckets -> ListS3Buckets -> Bool
$c/= :: ListS3Buckets -> ListS3Buckets -> Bool
== :: ListS3Buckets -> ListS3Buckets -> Bool
$c== :: ListS3Buckets -> ListS3Buckets -> Bool
Prelude.Eq, ReadPrec [ListS3Buckets]
ReadPrec ListS3Buckets
Int -> ReadS ListS3Buckets
ReadS [ListS3Buckets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListS3Buckets]
$creadListPrec :: ReadPrec [ListS3Buckets]
readPrec :: ReadPrec ListS3Buckets
$creadPrec :: ReadPrec ListS3Buckets
readList :: ReadS [ListS3Buckets]
$creadList :: ReadS [ListS3Buckets]
readsPrec :: Int -> ReadS ListS3Buckets
$creadsPrec :: Int -> ReadS ListS3Buckets
Prelude.Read, Int -> ListS3Buckets -> ShowS
[ListS3Buckets] -> ShowS
ListS3Buckets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListS3Buckets] -> ShowS
$cshowList :: [ListS3Buckets] -> ShowS
show :: ListS3Buckets -> String
$cshow :: ListS3Buckets -> String
showsPrec :: Int -> ListS3Buckets -> ShowS
$cshowsPrec :: Int -> ListS3Buckets -> ShowS
Prelude.Show, forall x. Rep ListS3Buckets x -> ListS3Buckets
forall x. ListS3Buckets -> Rep ListS3Buckets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListS3Buckets x -> ListS3Buckets
$cfrom :: forall x. ListS3Buckets -> Rep ListS3Buckets x
Prelude.Generic)

-- |
-- Create a value of 'ListS3Buckets' 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:
--
-- 'nextToken', 'listS3Buckets_nextToken' - Reserved for future use.
newListS3Buckets ::
  ListS3Buckets
newListS3Buckets :: ListS3Buckets
newListS3Buckets =
  ListS3Buckets' {$sel:nextToken:ListS3Buckets' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing}

-- | Reserved for future use.
listS3Buckets_nextToken :: Lens.Lens' ListS3Buckets (Prelude.Maybe Prelude.Text)
listS3Buckets_nextToken :: Lens' ListS3Buckets (Maybe Text)
listS3Buckets_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListS3Buckets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListS3Buckets' :: ListS3Buckets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListS3Buckets
s@ListS3Buckets' {} Maybe Text
a -> ListS3Buckets
s {$sel:nextToken:ListS3Buckets' :: Maybe Text
nextToken = Maybe Text
a} :: ListS3Buckets)

instance Core.AWSRequest ListS3Buckets where
  type
    AWSResponse ListS3Buckets =
      ListS3BucketsResponse
  request :: (Service -> Service) -> ListS3Buckets -> Request ListS3Buckets
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListS3Buckets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListS3Buckets)))
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 [S3BucketInfo] -> Maybe Text -> Int -> ListS3BucketsResponse
ListS3BucketsResponse'
            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
"buckets" 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 ListS3Buckets where
  hashWithSalt :: Int -> ListS3Buckets -> Int
hashWithSalt Int
_salt ListS3Buckets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListS3Buckets' :: ListS3Buckets -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

instance Data.ToHeaders ListS3Buckets where
  toHeaders :: ListS3Buckets -> 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.ToJSON ListS3Buckets where
  toJSON :: ListS3Buckets -> Value
toJSON ListS3Buckets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListS3Buckets' :: ListS3Buckets -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken]
      )

instance Data.ToPath ListS3Buckets where
  toPath :: ListS3Buckets -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/s3Buckets"

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

-- | /See:/ 'newListS3BucketsResponse' smart constructor.
data ListS3BucketsResponse = ListS3BucketsResponse'
  { -- | The list of S3 buckets.
    ListS3BucketsResponse -> Maybe [S3BucketInfo]
buckets :: Prelude.Maybe [S3BucketInfo],
    -- | Reserved for future use.
    ListS3BucketsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListS3BucketsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListS3BucketsResponse -> ListS3BucketsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListS3BucketsResponse -> ListS3BucketsResponse -> Bool
$c/= :: ListS3BucketsResponse -> ListS3BucketsResponse -> Bool
== :: ListS3BucketsResponse -> ListS3BucketsResponse -> Bool
$c== :: ListS3BucketsResponse -> ListS3BucketsResponse -> Bool
Prelude.Eq, ReadPrec [ListS3BucketsResponse]
ReadPrec ListS3BucketsResponse
Int -> ReadS ListS3BucketsResponse
ReadS [ListS3BucketsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListS3BucketsResponse]
$creadListPrec :: ReadPrec [ListS3BucketsResponse]
readPrec :: ReadPrec ListS3BucketsResponse
$creadPrec :: ReadPrec ListS3BucketsResponse
readList :: ReadS [ListS3BucketsResponse]
$creadList :: ReadS [ListS3BucketsResponse]
readsPrec :: Int -> ReadS ListS3BucketsResponse
$creadsPrec :: Int -> ReadS ListS3BucketsResponse
Prelude.Read, Int -> ListS3BucketsResponse -> ShowS
[ListS3BucketsResponse] -> ShowS
ListS3BucketsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListS3BucketsResponse] -> ShowS
$cshowList :: [ListS3BucketsResponse] -> ShowS
show :: ListS3BucketsResponse -> String
$cshow :: ListS3BucketsResponse -> String
showsPrec :: Int -> ListS3BucketsResponse -> ShowS
$cshowsPrec :: Int -> ListS3BucketsResponse -> ShowS
Prelude.Show, forall x. Rep ListS3BucketsResponse x -> ListS3BucketsResponse
forall x. ListS3BucketsResponse -> Rep ListS3BucketsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListS3BucketsResponse x -> ListS3BucketsResponse
$cfrom :: forall x. ListS3BucketsResponse -> Rep ListS3BucketsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListS3BucketsResponse' 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:
--
-- 'buckets', 'listS3BucketsResponse_buckets' - The list of S3 buckets.
--
-- 'nextToken', 'listS3BucketsResponse_nextToken' - Reserved for future use.
--
-- 'httpStatus', 'listS3BucketsResponse_httpStatus' - The response's http status code.
newListS3BucketsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListS3BucketsResponse
newListS3BucketsResponse :: Int -> ListS3BucketsResponse
newListS3BucketsResponse Int
pHttpStatus_ =
  ListS3BucketsResponse'
    { $sel:buckets:ListS3BucketsResponse' :: Maybe [S3BucketInfo]
buckets = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListS3BucketsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListS3BucketsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of S3 buckets.
listS3BucketsResponse_buckets :: Lens.Lens' ListS3BucketsResponse (Prelude.Maybe [S3BucketInfo])
listS3BucketsResponse_buckets :: Lens' ListS3BucketsResponse (Maybe [S3BucketInfo])
listS3BucketsResponse_buckets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListS3BucketsResponse' {Maybe [S3BucketInfo]
buckets :: Maybe [S3BucketInfo]
$sel:buckets:ListS3BucketsResponse' :: ListS3BucketsResponse -> Maybe [S3BucketInfo]
buckets} -> Maybe [S3BucketInfo]
buckets) (\s :: ListS3BucketsResponse
s@ListS3BucketsResponse' {} Maybe [S3BucketInfo]
a -> ListS3BucketsResponse
s {$sel:buckets:ListS3BucketsResponse' :: Maybe [S3BucketInfo]
buckets = Maybe [S3BucketInfo]
a} :: ListS3BucketsResponse) 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

-- | Reserved for future use.
listS3BucketsResponse_nextToken :: Lens.Lens' ListS3BucketsResponse (Prelude.Maybe Prelude.Text)
listS3BucketsResponse_nextToken :: Lens' ListS3BucketsResponse (Maybe Text)
listS3BucketsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListS3BucketsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListS3BucketsResponse' :: ListS3BucketsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListS3BucketsResponse
s@ListS3BucketsResponse' {} Maybe Text
a -> ListS3BucketsResponse
s {$sel:nextToken:ListS3BucketsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListS3BucketsResponse)

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

instance Prelude.NFData ListS3BucketsResponse where
  rnf :: ListS3BucketsResponse -> ()
rnf ListS3BucketsResponse' {Int
Maybe [S3BucketInfo]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
buckets :: Maybe [S3BucketInfo]
$sel:httpStatus:ListS3BucketsResponse' :: ListS3BucketsResponse -> Int
$sel:nextToken:ListS3BucketsResponse' :: ListS3BucketsResponse -> Maybe Text
$sel:buckets:ListS3BucketsResponse' :: ListS3BucketsResponse -> Maybe [S3BucketInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [S3BucketInfo]
buckets
      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