{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudSearchDomains.Types.BucketInfo
-- 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)
module Amazonka.CloudSearchDomains.Types.BucketInfo where

import Amazonka.CloudSearchDomains.Types.Bucket
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A container for the calculated facet values and counts.
--
-- /See:/ 'newBucketInfo' smart constructor.
data BucketInfo = BucketInfo'
  { -- | A list of the calculated facet values and counts.
    BucketInfo -> Maybe [Bucket]
buckets :: Prelude.Maybe [Bucket]
  }
  deriving (BucketInfo -> BucketInfo -> Bool
(BucketInfo -> BucketInfo -> Bool)
-> (BucketInfo -> BucketInfo -> Bool) -> Eq BucketInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketInfo -> BucketInfo -> Bool
$c/= :: BucketInfo -> BucketInfo -> Bool
== :: BucketInfo -> BucketInfo -> Bool
$c== :: BucketInfo -> BucketInfo -> Bool
Prelude.Eq, ReadPrec [BucketInfo]
ReadPrec BucketInfo
Int -> ReadS BucketInfo
ReadS [BucketInfo]
(Int -> ReadS BucketInfo)
-> ReadS [BucketInfo]
-> ReadPrec BucketInfo
-> ReadPrec [BucketInfo]
-> Read BucketInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketInfo]
$creadListPrec :: ReadPrec [BucketInfo]
readPrec :: ReadPrec BucketInfo
$creadPrec :: ReadPrec BucketInfo
readList :: ReadS [BucketInfo]
$creadList :: ReadS [BucketInfo]
readsPrec :: Int -> ReadS BucketInfo
$creadsPrec :: Int -> ReadS BucketInfo
Prelude.Read, Int -> BucketInfo -> ShowS
[BucketInfo] -> ShowS
BucketInfo -> String
(Int -> BucketInfo -> ShowS)
-> (BucketInfo -> String)
-> ([BucketInfo] -> ShowS)
-> Show BucketInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketInfo] -> ShowS
$cshowList :: [BucketInfo] -> ShowS
show :: BucketInfo -> String
$cshow :: BucketInfo -> String
showsPrec :: Int -> BucketInfo -> ShowS
$cshowsPrec :: Int -> BucketInfo -> ShowS
Prelude.Show, (forall x. BucketInfo -> Rep BucketInfo x)
-> (forall x. Rep BucketInfo x -> BucketInfo) -> Generic BucketInfo
forall x. Rep BucketInfo x -> BucketInfo
forall x. BucketInfo -> Rep BucketInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BucketInfo x -> BucketInfo
$cfrom :: forall x. BucketInfo -> Rep BucketInfo x
Prelude.Generic)

-- |
-- Create a value of 'BucketInfo' 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', 'bucketInfo_buckets' - A list of the calculated facet values and counts.
newBucketInfo ::
  BucketInfo
newBucketInfo :: BucketInfo
newBucketInfo =
  BucketInfo' :: Maybe [Bucket] -> BucketInfo
BucketInfo' {$sel:buckets:BucketInfo' :: Maybe [Bucket]
buckets = Maybe [Bucket]
forall a. Maybe a
Prelude.Nothing}

-- | A list of the calculated facet values and counts.
bucketInfo_buckets :: Lens.Lens' BucketInfo (Prelude.Maybe [Bucket])
bucketInfo_buckets :: (Maybe [Bucket] -> f (Maybe [Bucket]))
-> BucketInfo -> f BucketInfo
bucketInfo_buckets = (BucketInfo -> Maybe [Bucket])
-> (BucketInfo -> Maybe [Bucket] -> BucketInfo)
-> Lens BucketInfo BucketInfo (Maybe [Bucket]) (Maybe [Bucket])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketInfo' {Maybe [Bucket]
buckets :: Maybe [Bucket]
$sel:buckets:BucketInfo' :: BucketInfo -> Maybe [Bucket]
buckets} -> Maybe [Bucket]
buckets) (\s :: BucketInfo
s@BucketInfo' {} Maybe [Bucket]
a -> BucketInfo
s {$sel:buckets:BucketInfo' :: Maybe [Bucket]
buckets = Maybe [Bucket]
a} :: BucketInfo) ((Maybe [Bucket] -> f (Maybe [Bucket]))
 -> BucketInfo -> f BucketInfo)
-> ((Maybe [Bucket] -> f (Maybe [Bucket]))
    -> Maybe [Bucket] -> f (Maybe [Bucket]))
-> (Maybe [Bucket] -> f (Maybe [Bucket]))
-> BucketInfo
-> f BucketInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Bucket] [Bucket] [Bucket] [Bucket]
-> Iso
     (Maybe [Bucket]) (Maybe [Bucket]) (Maybe [Bucket]) (Maybe [Bucket])
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 [Bucket] [Bucket] [Bucket] [Bucket]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON BucketInfo where
  parseJSON :: Value -> Parser BucketInfo
parseJSON =
    String
-> (Object -> Parser BucketInfo) -> Value -> Parser BucketInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BucketInfo"
      ( \Object
x ->
          Maybe [Bucket] -> BucketInfo
BucketInfo'
            (Maybe [Bucket] -> BucketInfo)
-> Parser (Maybe [Bucket]) -> Parser BucketInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Bucket]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"buckets" Parser (Maybe (Maybe [Bucket]))
-> Maybe [Bucket] -> Parser (Maybe [Bucket])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Bucket]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BucketInfo

instance Prelude.NFData BucketInfo