{-# 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.IoT.Types.BucketsAggregationType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.BucketsAggregationType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.TermsAggregation
import qualified Amazonka.Prelude as Prelude

-- | The type of bucketed aggregation performed.
--
-- /See:/ 'newBucketsAggregationType' smart constructor.
data BucketsAggregationType = BucketsAggregationType'
  { -- | Performs an aggregation that will return a list of buckets. The list of
    -- buckets is a ranked list of the number of occurrences of an aggregation
    -- field value.
    BucketsAggregationType -> Maybe TermsAggregation
termsAggregation :: Prelude.Maybe TermsAggregation
  }
  deriving (BucketsAggregationType -> BucketsAggregationType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketsAggregationType -> BucketsAggregationType -> Bool
$c/= :: BucketsAggregationType -> BucketsAggregationType -> Bool
== :: BucketsAggregationType -> BucketsAggregationType -> Bool
$c== :: BucketsAggregationType -> BucketsAggregationType -> Bool
Prelude.Eq, ReadPrec [BucketsAggregationType]
ReadPrec BucketsAggregationType
Int -> ReadS BucketsAggregationType
ReadS [BucketsAggregationType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketsAggregationType]
$creadListPrec :: ReadPrec [BucketsAggregationType]
readPrec :: ReadPrec BucketsAggregationType
$creadPrec :: ReadPrec BucketsAggregationType
readList :: ReadS [BucketsAggregationType]
$creadList :: ReadS [BucketsAggregationType]
readsPrec :: Int -> ReadS BucketsAggregationType
$creadsPrec :: Int -> ReadS BucketsAggregationType
Prelude.Read, Int -> BucketsAggregationType -> ShowS
[BucketsAggregationType] -> ShowS
BucketsAggregationType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketsAggregationType] -> ShowS
$cshowList :: [BucketsAggregationType] -> ShowS
show :: BucketsAggregationType -> String
$cshow :: BucketsAggregationType -> String
showsPrec :: Int -> BucketsAggregationType -> ShowS
$cshowsPrec :: Int -> BucketsAggregationType -> ShowS
Prelude.Show, forall x. Rep BucketsAggregationType x -> BucketsAggregationType
forall x. BucketsAggregationType -> Rep BucketsAggregationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BucketsAggregationType x -> BucketsAggregationType
$cfrom :: forall x. BucketsAggregationType -> Rep BucketsAggregationType x
Prelude.Generic)

-- |
-- Create a value of 'BucketsAggregationType' 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:
--
-- 'termsAggregation', 'bucketsAggregationType_termsAggregation' - Performs an aggregation that will return a list of buckets. The list of
-- buckets is a ranked list of the number of occurrences of an aggregation
-- field value.
newBucketsAggregationType ::
  BucketsAggregationType
newBucketsAggregationType :: BucketsAggregationType
newBucketsAggregationType =
  BucketsAggregationType'
    { $sel:termsAggregation:BucketsAggregationType' :: Maybe TermsAggregation
termsAggregation =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Performs an aggregation that will return a list of buckets. The list of
-- buckets is a ranked list of the number of occurrences of an aggregation
-- field value.
bucketsAggregationType_termsAggregation :: Lens.Lens' BucketsAggregationType (Prelude.Maybe TermsAggregation)
bucketsAggregationType_termsAggregation :: Lens' BucketsAggregationType (Maybe TermsAggregation)
bucketsAggregationType_termsAggregation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketsAggregationType' {Maybe TermsAggregation
termsAggregation :: Maybe TermsAggregation
$sel:termsAggregation:BucketsAggregationType' :: BucketsAggregationType -> Maybe TermsAggregation
termsAggregation} -> Maybe TermsAggregation
termsAggregation) (\s :: BucketsAggregationType
s@BucketsAggregationType' {} Maybe TermsAggregation
a -> BucketsAggregationType
s {$sel:termsAggregation:BucketsAggregationType' :: Maybe TermsAggregation
termsAggregation = Maybe TermsAggregation
a} :: BucketsAggregationType)

instance Prelude.Hashable BucketsAggregationType where
  hashWithSalt :: Int -> BucketsAggregationType -> Int
hashWithSalt Int
_salt BucketsAggregationType' {Maybe TermsAggregation
termsAggregation :: Maybe TermsAggregation
$sel:termsAggregation:BucketsAggregationType' :: BucketsAggregationType -> Maybe TermsAggregation
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TermsAggregation
termsAggregation

instance Prelude.NFData BucketsAggregationType where
  rnf :: BucketsAggregationType -> ()
rnf BucketsAggregationType' {Maybe TermsAggregation
termsAggregation :: Maybe TermsAggregation
$sel:termsAggregation:BucketsAggregationType' :: BucketsAggregationType -> Maybe TermsAggregation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TermsAggregation
termsAggregation

instance Data.ToJSON BucketsAggregationType where
  toJSON :: BucketsAggregationType -> Value
toJSON BucketsAggregationType' {Maybe TermsAggregation
termsAggregation :: Maybe TermsAggregation
$sel:termsAggregation:BucketsAggregationType' :: BucketsAggregationType -> Maybe TermsAggregation
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"termsAggregation" 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 TermsAggregation
termsAggregation
          ]
      )