{-# 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.QLDBSession.Types.IOUsage
-- 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.QLDBSession.Types.IOUsage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains I\/O usage metrics for a command that was invoked.
--
-- /See:/ 'newIOUsage' smart constructor.
data IOUsage = IOUsage'
  { -- | The number of read I\/O requests that the command made.
    IOUsage -> Maybe Integer
readIOs :: Prelude.Maybe Prelude.Integer,
    -- | The number of write I\/O requests that the command made.
    IOUsage -> Maybe Integer
writeIOs :: Prelude.Maybe Prelude.Integer
  }
  deriving (IOUsage -> IOUsage -> Bool
(IOUsage -> IOUsage -> Bool)
-> (IOUsage -> IOUsage -> Bool) -> Eq IOUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IOUsage -> IOUsage -> Bool
$c/= :: IOUsage -> IOUsage -> Bool
== :: IOUsage -> IOUsage -> Bool
$c== :: IOUsage -> IOUsage -> Bool
Prelude.Eq, ReadPrec [IOUsage]
ReadPrec IOUsage
Int -> ReadS IOUsage
ReadS [IOUsage]
(Int -> ReadS IOUsage)
-> ReadS [IOUsage]
-> ReadPrec IOUsage
-> ReadPrec [IOUsage]
-> Read IOUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IOUsage]
$creadListPrec :: ReadPrec [IOUsage]
readPrec :: ReadPrec IOUsage
$creadPrec :: ReadPrec IOUsage
readList :: ReadS [IOUsage]
$creadList :: ReadS [IOUsage]
readsPrec :: Int -> ReadS IOUsage
$creadsPrec :: Int -> ReadS IOUsage
Prelude.Read, Int -> IOUsage -> ShowS
[IOUsage] -> ShowS
IOUsage -> String
(Int -> IOUsage -> ShowS)
-> (IOUsage -> String) -> ([IOUsage] -> ShowS) -> Show IOUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IOUsage] -> ShowS
$cshowList :: [IOUsage] -> ShowS
show :: IOUsage -> String
$cshow :: IOUsage -> String
showsPrec :: Int -> IOUsage -> ShowS
$cshowsPrec :: Int -> IOUsage -> ShowS
Prelude.Show, (forall x. IOUsage -> Rep IOUsage x)
-> (forall x. Rep IOUsage x -> IOUsage) -> Generic IOUsage
forall x. Rep IOUsage x -> IOUsage
forall x. IOUsage -> Rep IOUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IOUsage x -> IOUsage
$cfrom :: forall x. IOUsage -> Rep IOUsage x
Prelude.Generic)

-- |
-- Create a value of 'IOUsage' 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:
--
-- 'readIOs', 'iOUsage_readIOs' - The number of read I\/O requests that the command made.
--
-- 'writeIOs', 'iOUsage_writeIOs' - The number of write I\/O requests that the command made.
newIOUsage ::
  IOUsage
newIOUsage :: IOUsage
newIOUsage =
  IOUsage' :: Maybe Integer -> Maybe Integer -> IOUsage
IOUsage'
    { $sel:readIOs:IOUsage' :: Maybe Integer
readIOs = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:writeIOs:IOUsage' :: Maybe Integer
writeIOs = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of read I\/O requests that the command made.
iOUsage_readIOs :: Lens.Lens' IOUsage (Prelude.Maybe Prelude.Integer)
iOUsage_readIOs :: (Maybe Integer -> f (Maybe Integer)) -> IOUsage -> f IOUsage
iOUsage_readIOs = (IOUsage -> Maybe Integer)
-> (IOUsage -> Maybe Integer -> IOUsage)
-> Lens IOUsage IOUsage (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IOUsage' {Maybe Integer
readIOs :: Maybe Integer
$sel:readIOs:IOUsage' :: IOUsage -> Maybe Integer
readIOs} -> Maybe Integer
readIOs) (\s :: IOUsage
s@IOUsage' {} Maybe Integer
a -> IOUsage
s {$sel:readIOs:IOUsage' :: Maybe Integer
readIOs = Maybe Integer
a} :: IOUsage)

-- | The number of write I\/O requests that the command made.
iOUsage_writeIOs :: Lens.Lens' IOUsage (Prelude.Maybe Prelude.Integer)
iOUsage_writeIOs :: (Maybe Integer -> f (Maybe Integer)) -> IOUsage -> f IOUsage
iOUsage_writeIOs = (IOUsage -> Maybe Integer)
-> (IOUsage -> Maybe Integer -> IOUsage)
-> Lens IOUsage IOUsage (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IOUsage' {Maybe Integer
writeIOs :: Maybe Integer
$sel:writeIOs:IOUsage' :: IOUsage -> Maybe Integer
writeIOs} -> Maybe Integer
writeIOs) (\s :: IOUsage
s@IOUsage' {} Maybe Integer
a -> IOUsage
s {$sel:writeIOs:IOUsage' :: Maybe Integer
writeIOs = Maybe Integer
a} :: IOUsage)

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

instance Prelude.Hashable IOUsage

instance Prelude.NFData IOUsage