{-# 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.DynamoDB.Types.ItemCollectionMetrics
-- 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.DynamoDB.Types.ItemCollectionMetrics where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.AttributeValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about item collections, if any, that were affected by the
-- operation. @ItemCollectionMetrics@ is only returned if the request asked
-- for it. If the table does not have any local secondary indexes, this
-- information is not returned in the response.
--
-- /See:/ 'newItemCollectionMetrics' smart constructor.
data ItemCollectionMetrics = ItemCollectionMetrics'
  { -- | The partition key value of the item collection. This value is the same
    -- as the partition key value of the item.
    ItemCollectionMetrics -> Maybe (HashMap Text AttributeValue)
itemCollectionKey :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
    -- | An estimate of item collection size, in gigabytes. This value is a
    -- two-element array containing a lower bound and an upper bound for the
    -- estimate. The estimate includes the size of all the items in the table,
    -- plus the size of all attributes projected into all of the local
    -- secondary indexes on that table. Use this estimate to measure whether a
    -- local secondary index is approaching its size limit.
    --
    -- The estimate is subject to change over time; therefore, do not rely on
    -- the precision or accuracy of the estimate.
    ItemCollectionMetrics -> Maybe [Double]
sizeEstimateRangeGB :: Prelude.Maybe [Prelude.Double]
  }
  deriving (ItemCollectionMetrics -> ItemCollectionMetrics -> Bool
(ItemCollectionMetrics -> ItemCollectionMetrics -> Bool)
-> (ItemCollectionMetrics -> ItemCollectionMetrics -> Bool)
-> Eq ItemCollectionMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ItemCollectionMetrics -> ItemCollectionMetrics -> Bool
$c/= :: ItemCollectionMetrics -> ItemCollectionMetrics -> Bool
== :: ItemCollectionMetrics -> ItemCollectionMetrics -> Bool
$c== :: ItemCollectionMetrics -> ItemCollectionMetrics -> Bool
Prelude.Eq, ReadPrec [ItemCollectionMetrics]
ReadPrec ItemCollectionMetrics
Int -> ReadS ItemCollectionMetrics
ReadS [ItemCollectionMetrics]
(Int -> ReadS ItemCollectionMetrics)
-> ReadS [ItemCollectionMetrics]
-> ReadPrec ItemCollectionMetrics
-> ReadPrec [ItemCollectionMetrics]
-> Read ItemCollectionMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ItemCollectionMetrics]
$creadListPrec :: ReadPrec [ItemCollectionMetrics]
readPrec :: ReadPrec ItemCollectionMetrics
$creadPrec :: ReadPrec ItemCollectionMetrics
readList :: ReadS [ItemCollectionMetrics]
$creadList :: ReadS [ItemCollectionMetrics]
readsPrec :: Int -> ReadS ItemCollectionMetrics
$creadsPrec :: Int -> ReadS ItemCollectionMetrics
Prelude.Read, Int -> ItemCollectionMetrics -> ShowS
[ItemCollectionMetrics] -> ShowS
ItemCollectionMetrics -> String
(Int -> ItemCollectionMetrics -> ShowS)
-> (ItemCollectionMetrics -> String)
-> ([ItemCollectionMetrics] -> ShowS)
-> Show ItemCollectionMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ItemCollectionMetrics] -> ShowS
$cshowList :: [ItemCollectionMetrics] -> ShowS
show :: ItemCollectionMetrics -> String
$cshow :: ItemCollectionMetrics -> String
showsPrec :: Int -> ItemCollectionMetrics -> ShowS
$cshowsPrec :: Int -> ItemCollectionMetrics -> ShowS
Prelude.Show, (forall x. ItemCollectionMetrics -> Rep ItemCollectionMetrics x)
-> (forall x. Rep ItemCollectionMetrics x -> ItemCollectionMetrics)
-> Generic ItemCollectionMetrics
forall x. Rep ItemCollectionMetrics x -> ItemCollectionMetrics
forall x. ItemCollectionMetrics -> Rep ItemCollectionMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ItemCollectionMetrics x -> ItemCollectionMetrics
$cfrom :: forall x. ItemCollectionMetrics -> Rep ItemCollectionMetrics x
Prelude.Generic)

-- |
-- Create a value of 'ItemCollectionMetrics' 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:
--
-- 'itemCollectionKey', 'itemCollectionMetrics_itemCollectionKey' - The partition key value of the item collection. This value is the same
-- as the partition key value of the item.
--
-- 'sizeEstimateRangeGB', 'itemCollectionMetrics_sizeEstimateRangeGB' - An estimate of item collection size, in gigabytes. This value is a
-- two-element array containing a lower bound and an upper bound for the
-- estimate. The estimate includes the size of all the items in the table,
-- plus the size of all attributes projected into all of the local
-- secondary indexes on that table. Use this estimate to measure whether a
-- local secondary index is approaching its size limit.
--
-- The estimate is subject to change over time; therefore, do not rely on
-- the precision or accuracy of the estimate.
newItemCollectionMetrics ::
  ItemCollectionMetrics
newItemCollectionMetrics :: ItemCollectionMetrics
newItemCollectionMetrics =
  ItemCollectionMetrics' :: Maybe (HashMap Text AttributeValue)
-> Maybe [Double] -> ItemCollectionMetrics
ItemCollectionMetrics'
    { $sel:itemCollectionKey:ItemCollectionMetrics' :: Maybe (HashMap Text AttributeValue)
itemCollectionKey =
        Maybe (HashMap Text AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:sizeEstimateRangeGB:ItemCollectionMetrics' :: Maybe [Double]
sizeEstimateRangeGB = Maybe [Double]
forall a. Maybe a
Prelude.Nothing
    }

-- | The partition key value of the item collection. This value is the same
-- as the partition key value of the item.
itemCollectionMetrics_itemCollectionKey :: Lens.Lens' ItemCollectionMetrics (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
itemCollectionMetrics_itemCollectionKey :: (Maybe (HashMap Text AttributeValue)
 -> f (Maybe (HashMap Text AttributeValue)))
-> ItemCollectionMetrics -> f ItemCollectionMetrics
itemCollectionMetrics_itemCollectionKey = (ItemCollectionMetrics -> Maybe (HashMap Text AttributeValue))
-> (ItemCollectionMetrics
    -> Maybe (HashMap Text AttributeValue) -> ItemCollectionMetrics)
-> Lens
     ItemCollectionMetrics
     ItemCollectionMetrics
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemCollectionMetrics' {Maybe (HashMap Text AttributeValue)
itemCollectionKey :: Maybe (HashMap Text AttributeValue)
$sel:itemCollectionKey:ItemCollectionMetrics' :: ItemCollectionMetrics -> Maybe (HashMap Text AttributeValue)
itemCollectionKey} -> Maybe (HashMap Text AttributeValue)
itemCollectionKey) (\s :: ItemCollectionMetrics
s@ItemCollectionMetrics' {} Maybe (HashMap Text AttributeValue)
a -> ItemCollectionMetrics
s {$sel:itemCollectionKey:ItemCollectionMetrics' :: Maybe (HashMap Text AttributeValue)
itemCollectionKey = Maybe (HashMap Text AttributeValue)
a} :: ItemCollectionMetrics) ((Maybe (HashMap Text AttributeValue)
  -> f (Maybe (HashMap Text AttributeValue)))
 -> ItemCollectionMetrics -> f ItemCollectionMetrics)
-> ((Maybe (HashMap Text AttributeValue)
     -> f (Maybe (HashMap Text AttributeValue)))
    -> Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> (Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> ItemCollectionMetrics
-> f ItemCollectionMetrics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
-> Iso
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
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 AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An estimate of item collection size, in gigabytes. This value is a
-- two-element array containing a lower bound and an upper bound for the
-- estimate. The estimate includes the size of all the items in the table,
-- plus the size of all attributes projected into all of the local
-- secondary indexes on that table. Use this estimate to measure whether a
-- local secondary index is approaching its size limit.
--
-- The estimate is subject to change over time; therefore, do not rely on
-- the precision or accuracy of the estimate.
itemCollectionMetrics_sizeEstimateRangeGB :: Lens.Lens' ItemCollectionMetrics (Prelude.Maybe [Prelude.Double])
itemCollectionMetrics_sizeEstimateRangeGB :: (Maybe [Double] -> f (Maybe [Double]))
-> ItemCollectionMetrics -> f ItemCollectionMetrics
itemCollectionMetrics_sizeEstimateRangeGB = (ItemCollectionMetrics -> Maybe [Double])
-> (ItemCollectionMetrics
    -> Maybe [Double] -> ItemCollectionMetrics)
-> Lens
     ItemCollectionMetrics
     ItemCollectionMetrics
     (Maybe [Double])
     (Maybe [Double])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemCollectionMetrics' {Maybe [Double]
sizeEstimateRangeGB :: Maybe [Double]
$sel:sizeEstimateRangeGB:ItemCollectionMetrics' :: ItemCollectionMetrics -> Maybe [Double]
sizeEstimateRangeGB} -> Maybe [Double]
sizeEstimateRangeGB) (\s :: ItemCollectionMetrics
s@ItemCollectionMetrics' {} Maybe [Double]
a -> ItemCollectionMetrics
s {$sel:sizeEstimateRangeGB:ItemCollectionMetrics' :: Maybe [Double]
sizeEstimateRangeGB = Maybe [Double]
a} :: ItemCollectionMetrics) ((Maybe [Double] -> f (Maybe [Double]))
 -> ItemCollectionMetrics -> f ItemCollectionMetrics)
-> ((Maybe [Double] -> f (Maybe [Double]))
    -> Maybe [Double] -> f (Maybe [Double]))
-> (Maybe [Double] -> f (Maybe [Double]))
-> ItemCollectionMetrics
-> f ItemCollectionMetrics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Double] [Double] [Double] [Double]
-> Iso
     (Maybe [Double]) (Maybe [Double]) (Maybe [Double]) (Maybe [Double])
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 [Double] [Double] [Double] [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ItemCollectionMetrics where
  parseJSON :: Value -> Parser ItemCollectionMetrics
parseJSON =
    String
-> (Object -> Parser ItemCollectionMetrics)
-> Value
-> Parser ItemCollectionMetrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ItemCollectionMetrics"
      ( \Object
x ->
          Maybe (HashMap Text AttributeValue)
-> Maybe [Double] -> ItemCollectionMetrics
ItemCollectionMetrics'
            (Maybe (HashMap Text AttributeValue)
 -> Maybe [Double] -> ItemCollectionMetrics)
-> Parser (Maybe (HashMap Text AttributeValue))
-> Parser (Maybe [Double] -> ItemCollectionMetrics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text AttributeValue)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ItemCollectionKey"
                            Parser (Maybe (Maybe (HashMap Text AttributeValue)))
-> Maybe (HashMap Text AttributeValue)
-> Parser (Maybe (HashMap Text AttributeValue))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text AttributeValue)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Double] -> ItemCollectionMetrics)
-> Parser (Maybe [Double]) -> Parser ItemCollectionMetrics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Double]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SizeEstimateRangeGB"
                            Parser (Maybe (Maybe [Double]))
-> Maybe [Double] -> Parser (Maybe [Double])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Double]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ItemCollectionMetrics

instance Prelude.NFData ItemCollectionMetrics