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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | The value of the product view aggregation.
    ProductViewAggregationValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | An approximate count of the products that match the value.
    ProductViewAggregationValue -> Maybe Int
approximateCount :: Prelude.Maybe Prelude.Int
  }
  deriving (ProductViewAggregationValue -> ProductViewAggregationValue -> Bool
(ProductViewAggregationValue
 -> ProductViewAggregationValue -> Bool)
-> (ProductViewAggregationValue
    -> ProductViewAggregationValue -> Bool)
-> Eq ProductViewAggregationValue
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]
(Int -> ReadS ProductViewAggregationValue)
-> ReadS [ProductViewAggregationValue]
-> ReadPrec ProductViewAggregationValue
-> ReadPrec [ProductViewAggregationValue]
-> Read 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
(Int -> ProductViewAggregationValue -> ShowS)
-> (ProductViewAggregationValue -> String)
-> ([ProductViewAggregationValue] -> ShowS)
-> Show ProductViewAggregationValue
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.
 ProductViewAggregationValue -> Rep ProductViewAggregationValue x)
-> (forall x.
    Rep ProductViewAggregationValue x -> ProductViewAggregationValue)
-> Generic ProductViewAggregationValue
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:
--
-- 'value', 'productViewAggregationValue_value' - The value of the product view aggregation.
--
-- 'approximateCount', 'productViewAggregationValue_approximateCount' - An approximate count of the products that match the value.
newProductViewAggregationValue ::
  ProductViewAggregationValue
newProductViewAggregationValue :: ProductViewAggregationValue
newProductViewAggregationValue =
  ProductViewAggregationValue' :: Maybe Text -> Maybe Int -> ProductViewAggregationValue
ProductViewAggregationValue'
    { $sel:value:ProductViewAggregationValue' :: Maybe Text
value =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:approximateCount:ProductViewAggregationValue' :: Maybe Int
approximateCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the product view aggregation.
productViewAggregationValue_value :: Lens.Lens' ProductViewAggregationValue (Prelude.Maybe Prelude.Text)
productViewAggregationValue_value :: (Maybe Text -> f (Maybe Text))
-> ProductViewAggregationValue -> f ProductViewAggregationValue
productViewAggregationValue_value = (ProductViewAggregationValue -> Maybe Text)
-> (ProductViewAggregationValue
    -> Maybe Text -> ProductViewAggregationValue)
-> Lens
     ProductViewAggregationValue
     ProductViewAggregationValue
     (Maybe Text)
     (Maybe Text)
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)

-- | An approximate count of the products that match the value.
productViewAggregationValue_approximateCount :: Lens.Lens' ProductViewAggregationValue (Prelude.Maybe Prelude.Int)
productViewAggregationValue_approximateCount :: (Maybe Int -> f (Maybe Int))
-> ProductViewAggregationValue -> f ProductViewAggregationValue
productViewAggregationValue_approximateCount = (ProductViewAggregationValue -> Maybe Int)
-> (ProductViewAggregationValue
    -> Maybe Int -> ProductViewAggregationValue)
-> Lens
     ProductViewAggregationValue
     ProductViewAggregationValue
     (Maybe Int)
     (Maybe Int)
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)

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

instance Prelude.Hashable ProductViewAggregationValue

instance Prelude.NFData ProductViewAggregationValue