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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.WriteRequest
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
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]
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
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. 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'
    { $sel:itemCollectionKey:ItemCollectionMetrics' :: Maybe (HashMap Text AttributeValue)
itemCollectionKey =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sizeEstimateRangeGB:ItemCollectionMetrics' :: Maybe [Double]
sizeEstimateRangeGB = 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 :: Lens' ItemCollectionMetrics (Maybe (HashMap Text AttributeValue))
itemCollectionMetrics_itemCollectionKey = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ItemCollectionMetrics (Maybe [Double])
itemCollectionMetrics_sizeEstimateRangeGB = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ItemCollectionMetrics where
  parseJSON :: Value -> Parser ItemCollectionMetrics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ItemCollectionMetrics"
      ( \Object
x ->
          Maybe (HashMap Text AttributeValue)
-> Maybe [Double] -> ItemCollectionMetrics
ItemCollectionMetrics'
            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
"ItemCollectionKey"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"SizeEstimateRangeGB"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ItemCollectionMetrics where
  hashWithSalt :: Int -> ItemCollectionMetrics -> Int
hashWithSalt Int
_salt ItemCollectionMetrics' {Maybe [Double]
Maybe (HashMap Text AttributeValue)
sizeEstimateRangeGB :: Maybe [Double]
itemCollectionKey :: Maybe (HashMap Text AttributeValue)
$sel:sizeEstimateRangeGB:ItemCollectionMetrics' :: ItemCollectionMetrics -> Maybe [Double]
$sel:itemCollectionKey:ItemCollectionMetrics' :: ItemCollectionMetrics -> Maybe (HashMap Text AttributeValue)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text AttributeValue)
itemCollectionKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Double]
sizeEstimateRangeGB

instance Prelude.NFData ItemCollectionMetrics where
  rnf :: ItemCollectionMetrics -> ()
rnf ItemCollectionMetrics' {Maybe [Double]
Maybe (HashMap Text AttributeValue)
sizeEstimateRangeGB :: Maybe [Double]
itemCollectionKey :: Maybe (HashMap Text AttributeValue)
$sel:sizeEstimateRangeGB:ItemCollectionMetrics' :: ItemCollectionMetrics -> Maybe [Double]
$sel:itemCollectionKey:ItemCollectionMetrics' :: ItemCollectionMetrics -> Maybe (HashMap Text AttributeValue)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text AttributeValue)
itemCollectionKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Double]
sizeEstimateRangeGB