{-# 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.ServiceCatalog.Types.ProductViewAggregationValue
-- 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.ServiceCatalog.Types.ProductViewAggregationValue where

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

-- | A single product view aggregation value\/count pair, containing metadata
-- about each product to which the calling user has access.
--
-- /See:/ 'newProductViewAggregationValue' smart constructor.
data ProductViewAggregationValue = ProductViewAggregationValue'
  { -- | An approximate count of the products that match the value.
    ProductViewAggregationValue -> Maybe Int
approximateCount :: Prelude.Maybe Prelude.Int,
    -- | The value of the product view aggregation.
    ProductViewAggregationValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ProductViewAggregationValue -> ProductViewAggregationValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProductViewAggregationValue -> ProductViewAggregationValue -> Bool
$c/= :: ProductViewAggregationValue -> ProductViewAggregationValue -> Bool
== :: ProductViewAggregationValue -> ProductViewAggregationValue -> Bool
$c== :: ProductViewAggregationValue -> ProductViewAggregationValue -> Bool
Prelude.Eq, ReadPrec [ProductViewAggregationValue]
ReadPrec ProductViewAggregationValue
Int -> ReadS ProductViewAggregationValue
ReadS [ProductViewAggregationValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProductViewAggregationValue]
$creadListPrec :: ReadPrec [ProductViewAggregationValue]
readPrec :: ReadPrec ProductViewAggregationValue
$creadPrec :: ReadPrec ProductViewAggregationValue
readList :: ReadS [ProductViewAggregationValue]
$creadList :: ReadS [ProductViewAggregationValue]
readsPrec :: Int -> ReadS ProductViewAggregationValue
$creadsPrec :: Int -> ReadS ProductViewAggregationValue
Prelude.Read, Int -> ProductViewAggregationValue -> ShowS
[ProductViewAggregationValue] -> ShowS
ProductViewAggregationValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProductViewAggregationValue] -> ShowS
$cshowList :: [ProductViewAggregationValue] -> ShowS
show :: ProductViewAggregationValue -> String
$cshow :: ProductViewAggregationValue -> String
showsPrec :: Int -> ProductViewAggregationValue -> ShowS
$cshowsPrec :: Int -> ProductViewAggregationValue -> ShowS
Prelude.Show, forall x.
Rep ProductViewAggregationValue x -> ProductViewAggregationValue
forall x.
ProductViewAggregationValue -> Rep ProductViewAggregationValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProductViewAggregationValue x -> ProductViewAggregationValue
$cfrom :: forall x.
ProductViewAggregationValue -> Rep ProductViewAggregationValue x
Prelude.Generic)

-- |
-- Create a value of 'ProductViewAggregationValue' 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:
--
-- 'approximateCount', 'productViewAggregationValue_approximateCount' - An approximate count of the products that match the value.
--
-- 'value', 'productViewAggregationValue_value' - The value of the product view aggregation.
newProductViewAggregationValue ::
  ProductViewAggregationValue
newProductViewAggregationValue :: ProductViewAggregationValue
newProductViewAggregationValue =
  ProductViewAggregationValue'
    { $sel:approximateCount:ProductViewAggregationValue' :: Maybe Int
approximateCount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:value:ProductViewAggregationValue' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | An approximate count of the products that match the value.
productViewAggregationValue_approximateCount :: Lens.Lens' ProductViewAggregationValue (Prelude.Maybe Prelude.Int)
productViewAggregationValue_approximateCount :: Lens' ProductViewAggregationValue (Maybe Int)
productViewAggregationValue_approximateCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductViewAggregationValue' {Maybe Int
approximateCount :: Maybe Int
$sel:approximateCount:ProductViewAggregationValue' :: ProductViewAggregationValue -> Maybe Int
approximateCount} -> Maybe Int
approximateCount) (\s :: ProductViewAggregationValue
s@ProductViewAggregationValue' {} Maybe Int
a -> ProductViewAggregationValue
s {$sel:approximateCount:ProductViewAggregationValue' :: Maybe Int
approximateCount = Maybe Int
a} :: ProductViewAggregationValue)

-- | The value of the product view aggregation.
productViewAggregationValue_value :: Lens.Lens' ProductViewAggregationValue (Prelude.Maybe Prelude.Text)
productViewAggregationValue_value :: Lens' ProductViewAggregationValue (Maybe Text)
productViewAggregationValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductViewAggregationValue' {Maybe Text
value :: Maybe Text
$sel:value:ProductViewAggregationValue' :: ProductViewAggregationValue -> Maybe Text
value} -> Maybe Text
value) (\s :: ProductViewAggregationValue
s@ProductViewAggregationValue' {} Maybe Text
a -> ProductViewAggregationValue
s {$sel:value:ProductViewAggregationValue' :: Maybe Text
value = Maybe Text
a} :: ProductViewAggregationValue)

instance Data.FromJSON ProductViewAggregationValue where
  parseJSON :: Value -> Parser ProductViewAggregationValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProductViewAggregationValue"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> ProductViewAggregationValue
ProductViewAggregationValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ApproximateCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
      )

instance Prelude.Hashable ProductViewAggregationValue where
  hashWithSalt :: Int -> ProductViewAggregationValue -> Int
hashWithSalt Int
_salt ProductViewAggregationValue' {Maybe Int
Maybe Text
value :: Maybe Text
approximateCount :: Maybe Int
$sel:value:ProductViewAggregationValue' :: ProductViewAggregationValue -> Maybe Text
$sel:approximateCount:ProductViewAggregationValue' :: ProductViewAggregationValue -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
approximateCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData ProductViewAggregationValue where
  rnf :: ProductViewAggregationValue -> ()
rnf ProductViewAggregationValue' {Maybe Int
Maybe Text
value :: Maybe Text
approximateCount :: Maybe Int
$sel:value:ProductViewAggregationValue' :: ProductViewAggregationValue -> Maybe Text
$sel:approximateCount:ProductViewAggregationValue' :: ProductViewAggregationValue -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
approximateCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value