{-# 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.MacieV2.DescribeBuckets
-- 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)
--
-- Retrieves (queries) statistical data and other information about one or
-- more S3 buckets that Amazon Macie monitors and analyzes.
--
-- This operation returns paginated results.
module Amazonka.MacieV2.DescribeBuckets
  ( -- * Creating a Request
    DescribeBuckets (..),
    newDescribeBuckets,

    -- * Request Lenses
    describeBuckets_sortCriteria,
    describeBuckets_nextToken,
    describeBuckets_criteria,
    describeBuckets_maxResults,

    -- * Destructuring the Response
    DescribeBucketsResponse (..),
    newDescribeBucketsResponse,

    -- * Response Lenses
    describeBucketsResponse_buckets,
    describeBucketsResponse_nextToken,
    describeBucketsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeBuckets' smart constructor.
data DescribeBuckets = DescribeBuckets'
  { -- | The criteria to use to sort the query results.
    DescribeBuckets -> Maybe BucketSortCriteria
sortCriteria :: Prelude.Maybe BucketSortCriteria,
    -- | The nextToken string that specifies which page of results to return in a
    -- paginated response.
    DescribeBuckets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The criteria to use to filter the query results.
    DescribeBuckets
-> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria :: Prelude.Maybe (Prelude.HashMap Prelude.Text BucketCriteriaAdditionalProperties),
    -- | The maximum number of items to include in each page of the response. The
    -- default value is 50.
    DescribeBuckets -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int
  }
  deriving (DescribeBuckets -> DescribeBuckets -> Bool
(DescribeBuckets -> DescribeBuckets -> Bool)
-> (DescribeBuckets -> DescribeBuckets -> Bool)
-> Eq DescribeBuckets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBuckets -> DescribeBuckets -> Bool
$c/= :: DescribeBuckets -> DescribeBuckets -> Bool
== :: DescribeBuckets -> DescribeBuckets -> Bool
$c== :: DescribeBuckets -> DescribeBuckets -> Bool
Prelude.Eq, ReadPrec [DescribeBuckets]
ReadPrec DescribeBuckets
Int -> ReadS DescribeBuckets
ReadS [DescribeBuckets]
(Int -> ReadS DescribeBuckets)
-> ReadS [DescribeBuckets]
-> ReadPrec DescribeBuckets
-> ReadPrec [DescribeBuckets]
-> Read DescribeBuckets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBuckets]
$creadListPrec :: ReadPrec [DescribeBuckets]
readPrec :: ReadPrec DescribeBuckets
$creadPrec :: ReadPrec DescribeBuckets
readList :: ReadS [DescribeBuckets]
$creadList :: ReadS [DescribeBuckets]
readsPrec :: Int -> ReadS DescribeBuckets
$creadsPrec :: Int -> ReadS DescribeBuckets
Prelude.Read, Int -> DescribeBuckets -> ShowS
[DescribeBuckets] -> ShowS
DescribeBuckets -> String
(Int -> DescribeBuckets -> ShowS)
-> (DescribeBuckets -> String)
-> ([DescribeBuckets] -> ShowS)
-> Show DescribeBuckets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBuckets] -> ShowS
$cshowList :: [DescribeBuckets] -> ShowS
show :: DescribeBuckets -> String
$cshow :: DescribeBuckets -> String
showsPrec :: Int -> DescribeBuckets -> ShowS
$cshowsPrec :: Int -> DescribeBuckets -> ShowS
Prelude.Show, (forall x. DescribeBuckets -> Rep DescribeBuckets x)
-> (forall x. Rep DescribeBuckets x -> DescribeBuckets)
-> Generic DescribeBuckets
forall x. Rep DescribeBuckets x -> DescribeBuckets
forall x. DescribeBuckets -> Rep DescribeBuckets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBuckets x -> DescribeBuckets
$cfrom :: forall x. DescribeBuckets -> Rep DescribeBuckets x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBuckets' 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:
--
-- 'sortCriteria', 'describeBuckets_sortCriteria' - The criteria to use to sort the query results.
--
-- 'nextToken', 'describeBuckets_nextToken' - The nextToken string that specifies which page of results to return in a
-- paginated response.
--
-- 'criteria', 'describeBuckets_criteria' - The criteria to use to filter the query results.
--
-- 'maxResults', 'describeBuckets_maxResults' - The maximum number of items to include in each page of the response. The
-- default value is 50.
newDescribeBuckets ::
  DescribeBuckets
newDescribeBuckets :: DescribeBuckets
newDescribeBuckets =
  DescribeBuckets' :: Maybe BucketSortCriteria
-> Maybe Text
-> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
-> Maybe Int
-> DescribeBuckets
DescribeBuckets'
    { $sel:sortCriteria:DescribeBuckets' :: Maybe BucketSortCriteria
sortCriteria = Maybe BucketSortCriteria
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeBuckets' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:criteria:DescribeBuckets' :: Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria = Maybe (HashMap Text BucketCriteriaAdditionalProperties)
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeBuckets' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The criteria to use to sort the query results.
describeBuckets_sortCriteria :: Lens.Lens' DescribeBuckets (Prelude.Maybe BucketSortCriteria)
describeBuckets_sortCriteria :: (Maybe BucketSortCriteria -> f (Maybe BucketSortCriteria))
-> DescribeBuckets -> f DescribeBuckets
describeBuckets_sortCriteria = (DescribeBuckets -> Maybe BucketSortCriteria)
-> (DescribeBuckets -> Maybe BucketSortCriteria -> DescribeBuckets)
-> Lens
     DescribeBuckets
     DescribeBuckets
     (Maybe BucketSortCriteria)
     (Maybe BucketSortCriteria)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBuckets' {Maybe BucketSortCriteria
sortCriteria :: Maybe BucketSortCriteria
$sel:sortCriteria:DescribeBuckets' :: DescribeBuckets -> Maybe BucketSortCriteria
sortCriteria} -> Maybe BucketSortCriteria
sortCriteria) (\s :: DescribeBuckets
s@DescribeBuckets' {} Maybe BucketSortCriteria
a -> DescribeBuckets
s {$sel:sortCriteria:DescribeBuckets' :: Maybe BucketSortCriteria
sortCriteria = Maybe BucketSortCriteria
a} :: DescribeBuckets)

-- | The nextToken string that specifies which page of results to return in a
-- paginated response.
describeBuckets_nextToken :: Lens.Lens' DescribeBuckets (Prelude.Maybe Prelude.Text)
describeBuckets_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeBuckets -> f DescribeBuckets
describeBuckets_nextToken = (DescribeBuckets -> Maybe Text)
-> (DescribeBuckets -> Maybe Text -> DescribeBuckets)
-> Lens DescribeBuckets DescribeBuckets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBuckets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeBuckets' :: DescribeBuckets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeBuckets
s@DescribeBuckets' {} Maybe Text
a -> DescribeBuckets
s {$sel:nextToken:DescribeBuckets' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeBuckets)

-- | The criteria to use to filter the query results.
describeBuckets_criteria :: Lens.Lens' DescribeBuckets (Prelude.Maybe (Prelude.HashMap Prelude.Text BucketCriteriaAdditionalProperties))
describeBuckets_criteria :: (Maybe (HashMap Text BucketCriteriaAdditionalProperties)
 -> f (Maybe (HashMap Text BucketCriteriaAdditionalProperties)))
-> DescribeBuckets -> f DescribeBuckets
describeBuckets_criteria = (DescribeBuckets
 -> Maybe (HashMap Text BucketCriteriaAdditionalProperties))
-> (DescribeBuckets
    -> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
    -> DescribeBuckets)
-> Lens
     DescribeBuckets
     DescribeBuckets
     (Maybe (HashMap Text BucketCriteriaAdditionalProperties))
     (Maybe (HashMap Text BucketCriteriaAdditionalProperties))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBuckets' {Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria :: Maybe (HashMap Text BucketCriteriaAdditionalProperties)
$sel:criteria:DescribeBuckets' :: DescribeBuckets
-> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria} -> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria) (\s :: DescribeBuckets
s@DescribeBuckets' {} Maybe (HashMap Text BucketCriteriaAdditionalProperties)
a -> DescribeBuckets
s {$sel:criteria:DescribeBuckets' :: Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria = Maybe (HashMap Text BucketCriteriaAdditionalProperties)
a} :: DescribeBuckets) ((Maybe (HashMap Text BucketCriteriaAdditionalProperties)
  -> f (Maybe (HashMap Text BucketCriteriaAdditionalProperties)))
 -> DescribeBuckets -> f DescribeBuckets)
-> ((Maybe (HashMap Text BucketCriteriaAdditionalProperties)
     -> f (Maybe (HashMap Text BucketCriteriaAdditionalProperties)))
    -> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
    -> f (Maybe (HashMap Text BucketCriteriaAdditionalProperties)))
-> (Maybe (HashMap Text BucketCriteriaAdditionalProperties)
    -> f (Maybe (HashMap Text BucketCriteriaAdditionalProperties)))
-> DescribeBuckets
-> f DescribeBuckets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text BucketCriteriaAdditionalProperties)
  (HashMap Text BucketCriteriaAdditionalProperties)
  (HashMap Text BucketCriteriaAdditionalProperties)
  (HashMap Text BucketCriteriaAdditionalProperties)
-> Iso
     (Maybe (HashMap Text BucketCriteriaAdditionalProperties))
     (Maybe (HashMap Text BucketCriteriaAdditionalProperties))
     (Maybe (HashMap Text BucketCriteriaAdditionalProperties))
     (Maybe (HashMap Text BucketCriteriaAdditionalProperties))
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 BucketCriteriaAdditionalProperties)
  (HashMap Text BucketCriteriaAdditionalProperties)
  (HashMap Text BucketCriteriaAdditionalProperties)
  (HashMap Text BucketCriteriaAdditionalProperties)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The maximum number of items to include in each page of the response. The
-- default value is 50.
describeBuckets_maxResults :: Lens.Lens' DescribeBuckets (Prelude.Maybe Prelude.Int)
describeBuckets_maxResults :: (Maybe Int -> f (Maybe Int))
-> DescribeBuckets -> f DescribeBuckets
describeBuckets_maxResults = (DescribeBuckets -> Maybe Int)
-> (DescribeBuckets -> Maybe Int -> DescribeBuckets)
-> Lens DescribeBuckets DescribeBuckets (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBuckets' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:DescribeBuckets' :: DescribeBuckets -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: DescribeBuckets
s@DescribeBuckets' {} Maybe Int
a -> DescribeBuckets
s {$sel:maxResults:DescribeBuckets' :: Maybe Int
maxResults = Maybe Int
a} :: DescribeBuckets)

instance Core.AWSPager DescribeBuckets where
  page :: DescribeBuckets
-> AWSResponse DescribeBuckets -> Maybe DescribeBuckets
page DescribeBuckets
rq AWSResponse DescribeBuckets
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeBuckets
DescribeBucketsResponse
rs
            DescribeBucketsResponse
-> Getting (First Text) DescribeBucketsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeBucketsResponse
-> Const (First Text) DescribeBucketsResponse
Lens' DescribeBucketsResponse (Maybe Text)
describeBucketsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeBucketsResponse
 -> Const (First Text) DescribeBucketsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeBucketsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeBuckets
forall a. Maybe a
Prelude.Nothing
    | Maybe [BucketMetadata] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeBuckets
DescribeBucketsResponse
rs
            DescribeBucketsResponse
-> Getting
     (First [BucketMetadata]) DescribeBucketsResponse [BucketMetadata]
-> Maybe [BucketMetadata]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [BucketMetadata]
 -> Const (First [BucketMetadata]) (Maybe [BucketMetadata]))
-> DescribeBucketsResponse
-> Const (First [BucketMetadata]) DescribeBucketsResponse
Lens' DescribeBucketsResponse (Maybe [BucketMetadata])
describeBucketsResponse_buckets ((Maybe [BucketMetadata]
  -> Const (First [BucketMetadata]) (Maybe [BucketMetadata]))
 -> DescribeBucketsResponse
 -> Const (First [BucketMetadata]) DescribeBucketsResponse)
-> (([BucketMetadata]
     -> Const (First [BucketMetadata]) [BucketMetadata])
    -> Maybe [BucketMetadata]
    -> Const (First [BucketMetadata]) (Maybe [BucketMetadata]))
-> Getting
     (First [BucketMetadata]) DescribeBucketsResponse [BucketMetadata]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BucketMetadata]
 -> Const (First [BucketMetadata]) [BucketMetadata])
-> Maybe [BucketMetadata]
-> Const (First [BucketMetadata]) (Maybe [BucketMetadata])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeBuckets
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeBuckets -> Maybe DescribeBuckets
forall a. a -> Maybe a
Prelude.Just (DescribeBuckets -> Maybe DescribeBuckets)
-> DescribeBuckets -> Maybe DescribeBuckets
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeBuckets
rq
          DescribeBuckets
-> (DescribeBuckets -> DescribeBuckets) -> DescribeBuckets
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeBuckets -> Identity DescribeBuckets
Lens DescribeBuckets DescribeBuckets (Maybe Text) (Maybe Text)
describeBuckets_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeBuckets -> Identity DescribeBuckets)
-> Maybe Text -> DescribeBuckets -> DescribeBuckets
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeBuckets
DescribeBucketsResponse
rs
          DescribeBucketsResponse
-> Getting (First Text) DescribeBucketsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeBucketsResponse
-> Const (First Text) DescribeBucketsResponse
Lens' DescribeBucketsResponse (Maybe Text)
describeBucketsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeBucketsResponse
 -> Const (First Text) DescribeBucketsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeBucketsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeBuckets where
  type
    AWSResponse DescribeBuckets =
      DescribeBucketsResponse
  request :: DescribeBuckets -> Request DescribeBuckets
request = Service -> DescribeBuckets -> Request DescribeBuckets
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeBuckets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeBuckets)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeBuckets))
-> Logger
-> Service
-> Proxy DescribeBuckets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeBuckets)))
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 [BucketMetadata]
-> Maybe Text -> Int -> DescribeBucketsResponse
DescribeBucketsResponse'
            (Maybe [BucketMetadata]
 -> Maybe Text -> Int -> DescribeBucketsResponse)
-> Either String (Maybe [BucketMetadata])
-> Either String (Maybe Text -> Int -> DescribeBucketsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [BucketMetadata]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"buckets" Either String (Maybe (Maybe [BucketMetadata]))
-> Maybe [BucketMetadata] -> Either String (Maybe [BucketMetadata])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BucketMetadata]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeBucketsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeBucketsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> DescribeBucketsResponse)
-> Either String Int -> Either String DescribeBucketsResponse
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 DescribeBuckets

instance Prelude.NFData DescribeBuckets

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

instance Core.ToJSON DescribeBuckets where
  toJSON :: DescribeBuckets -> Value
toJSON DescribeBuckets' {Maybe Int
Maybe Text
Maybe (HashMap Text BucketCriteriaAdditionalProperties)
Maybe BucketSortCriteria
maxResults :: Maybe Int
criteria :: Maybe (HashMap Text BucketCriteriaAdditionalProperties)
nextToken :: Maybe Text
sortCriteria :: Maybe BucketSortCriteria
$sel:maxResults:DescribeBuckets' :: DescribeBuckets -> Maybe Int
$sel:criteria:DescribeBuckets' :: DescribeBuckets
-> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
$sel:nextToken:DescribeBuckets' :: DescribeBuckets -> Maybe Text
$sel:sortCriteria:DescribeBuckets' :: DescribeBuckets -> Maybe BucketSortCriteria
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sortCriteria" Text -> BucketSortCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (BucketSortCriteria -> Pair)
-> Maybe BucketSortCriteria -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BucketSortCriteria
sortCriteria,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"criteria" Text -> HashMap Text BucketCriteriaAdditionalProperties -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text BucketCriteriaAdditionalProperties -> Pair)
-> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text BucketCriteriaAdditionalProperties)
criteria,
            (Text
"maxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults
          ]
      )

instance Core.ToPath DescribeBuckets where
  toPath :: DescribeBuckets -> ByteString
toPath = ByteString -> DescribeBuckets -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/datasources/s3"

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

-- | /See:/ 'newDescribeBucketsResponse' smart constructor.
data DescribeBucketsResponse = DescribeBucketsResponse'
  { -- | An array of objects, one for each bucket that meets the filter criteria
    -- specified in the request.
    DescribeBucketsResponse -> Maybe [BucketMetadata]
buckets :: Prelude.Maybe [BucketMetadata],
    -- | The string to use in a subsequent request to get the next page of
    -- results in a paginated response. This value is null if there are no
    -- additional pages.
    DescribeBucketsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeBucketsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeBucketsResponse -> DescribeBucketsResponse -> Bool
(DescribeBucketsResponse -> DescribeBucketsResponse -> Bool)
-> (DescribeBucketsResponse -> DescribeBucketsResponse -> Bool)
-> Eq DescribeBucketsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBucketsResponse -> DescribeBucketsResponse -> Bool
$c/= :: DescribeBucketsResponse -> DescribeBucketsResponse -> Bool
== :: DescribeBucketsResponse -> DescribeBucketsResponse -> Bool
$c== :: DescribeBucketsResponse -> DescribeBucketsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeBucketsResponse]
ReadPrec DescribeBucketsResponse
Int -> ReadS DescribeBucketsResponse
ReadS [DescribeBucketsResponse]
(Int -> ReadS DescribeBucketsResponse)
-> ReadS [DescribeBucketsResponse]
-> ReadPrec DescribeBucketsResponse
-> ReadPrec [DescribeBucketsResponse]
-> Read DescribeBucketsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBucketsResponse]
$creadListPrec :: ReadPrec [DescribeBucketsResponse]
readPrec :: ReadPrec DescribeBucketsResponse
$creadPrec :: ReadPrec DescribeBucketsResponse
readList :: ReadS [DescribeBucketsResponse]
$creadList :: ReadS [DescribeBucketsResponse]
readsPrec :: Int -> ReadS DescribeBucketsResponse
$creadsPrec :: Int -> ReadS DescribeBucketsResponse
Prelude.Read, Int -> DescribeBucketsResponse -> ShowS
[DescribeBucketsResponse] -> ShowS
DescribeBucketsResponse -> String
(Int -> DescribeBucketsResponse -> ShowS)
-> (DescribeBucketsResponse -> String)
-> ([DescribeBucketsResponse] -> ShowS)
-> Show DescribeBucketsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBucketsResponse] -> ShowS
$cshowList :: [DescribeBucketsResponse] -> ShowS
show :: DescribeBucketsResponse -> String
$cshow :: DescribeBucketsResponse -> String
showsPrec :: Int -> DescribeBucketsResponse -> ShowS
$cshowsPrec :: Int -> DescribeBucketsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeBucketsResponse -> Rep DescribeBucketsResponse x)
-> (forall x.
    Rep DescribeBucketsResponse x -> DescribeBucketsResponse)
-> Generic DescribeBucketsResponse
forall x. Rep DescribeBucketsResponse x -> DescribeBucketsResponse
forall x. DescribeBucketsResponse -> Rep DescribeBucketsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBucketsResponse x -> DescribeBucketsResponse
$cfrom :: forall x. DescribeBucketsResponse -> Rep DescribeBucketsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBucketsResponse' 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', 'describeBucketsResponse_buckets' - An array of objects, one for each bucket that meets the filter criteria
-- specified in the request.
--
-- 'nextToken', 'describeBucketsResponse_nextToken' - The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
--
-- 'httpStatus', 'describeBucketsResponse_httpStatus' - The response's http status code.
newDescribeBucketsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeBucketsResponse
newDescribeBucketsResponse :: Int -> DescribeBucketsResponse
newDescribeBucketsResponse Int
pHttpStatus_ =
  DescribeBucketsResponse' :: Maybe [BucketMetadata]
-> Maybe Text -> Int -> DescribeBucketsResponse
DescribeBucketsResponse'
    { $sel:buckets:DescribeBucketsResponse' :: Maybe [BucketMetadata]
buckets = Maybe [BucketMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeBucketsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeBucketsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects, one for each bucket that meets the filter criteria
-- specified in the request.
describeBucketsResponse_buckets :: Lens.Lens' DescribeBucketsResponse (Prelude.Maybe [BucketMetadata])
describeBucketsResponse_buckets :: (Maybe [BucketMetadata] -> f (Maybe [BucketMetadata]))
-> DescribeBucketsResponse -> f DescribeBucketsResponse
describeBucketsResponse_buckets = (DescribeBucketsResponse -> Maybe [BucketMetadata])
-> (DescribeBucketsResponse
    -> Maybe [BucketMetadata] -> DescribeBucketsResponse)
-> Lens' DescribeBucketsResponse (Maybe [BucketMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBucketsResponse' {Maybe [BucketMetadata]
buckets :: Maybe [BucketMetadata]
$sel:buckets:DescribeBucketsResponse' :: DescribeBucketsResponse -> Maybe [BucketMetadata]
buckets} -> Maybe [BucketMetadata]
buckets) (\s :: DescribeBucketsResponse
s@DescribeBucketsResponse' {} Maybe [BucketMetadata]
a -> DescribeBucketsResponse
s {$sel:buckets:DescribeBucketsResponse' :: Maybe [BucketMetadata]
buckets = Maybe [BucketMetadata]
a} :: DescribeBucketsResponse) ((Maybe [BucketMetadata] -> f (Maybe [BucketMetadata]))
 -> DescribeBucketsResponse -> f DescribeBucketsResponse)
-> ((Maybe [BucketMetadata] -> f (Maybe [BucketMetadata]))
    -> Maybe [BucketMetadata] -> f (Maybe [BucketMetadata]))
-> (Maybe [BucketMetadata] -> f (Maybe [BucketMetadata]))
-> DescribeBucketsResponse
-> f DescribeBucketsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [BucketMetadata] [BucketMetadata] [BucketMetadata] [BucketMetadata]
-> Iso
     (Maybe [BucketMetadata])
     (Maybe [BucketMetadata])
     (Maybe [BucketMetadata])
     (Maybe [BucketMetadata])
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
  [BucketMetadata] [BucketMetadata] [BucketMetadata] [BucketMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
describeBucketsResponse_nextToken :: Lens.Lens' DescribeBucketsResponse (Prelude.Maybe Prelude.Text)
describeBucketsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeBucketsResponse -> f DescribeBucketsResponse
describeBucketsResponse_nextToken = (DescribeBucketsResponse -> Maybe Text)
-> (DescribeBucketsResponse
    -> Maybe Text -> DescribeBucketsResponse)
-> Lens' DescribeBucketsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBucketsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeBucketsResponse' :: DescribeBucketsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeBucketsResponse
s@DescribeBucketsResponse' {} Maybe Text
a -> DescribeBucketsResponse
s {$sel:nextToken:DescribeBucketsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeBucketsResponse)

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

instance Prelude.NFData DescribeBucketsResponse