{-# 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.ComputeOptimizer.Types.EBSUtilizationMetric
-- 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.ComputeOptimizer.Types.EBSUtilizationMetric where

import Amazonka.ComputeOptimizer.Types.EBSMetricName
import Amazonka.ComputeOptimizer.Types.MetricStatistic
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a utilization metric of an Amazon Elastic Block Store (Amazon
-- EBS) volume.
--
-- Compare the utilization metric data of your resource against its
-- projected utilization metric data to determine the performance
-- difference between your current resource and the recommended option.
--
-- /See:/ 'newEBSUtilizationMetric' smart constructor.
data EBSUtilizationMetric = EBSUtilizationMetric'
  { -- | The value of the utilization metric.
    EBSUtilizationMetric -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | The name of the utilization metric.
    --
    -- The following utilization metrics are available:
    --
    -- -   @VolumeReadOpsPerSecond@ - The completed read operations per second
    --     from the volume in a specified period of time.
    --
    --     Unit: Count
    --
    -- -   @VolumeWriteOpsPerSecond@ - The completed write operations per
    --     second to the volume in a specified period of time.
    --
    --     Unit: Count
    --
    -- -   @VolumeReadBytesPerSecond@ - The bytes read per second from the
    --     volume in a specified period of time.
    --
    --     Unit: Bytes
    --
    -- -   @VolumeWriteBytesPerSecond@ - The bytes written to the volume in a
    --     specified period of time.
    --
    --     Unit: Bytes
    EBSUtilizationMetric -> Maybe EBSMetricName
name :: Prelude.Maybe EBSMetricName,
    -- | The statistic of the utilization metric.
    --
    -- The Compute Optimizer API, Command Line Interface (CLI), and SDKs return
    -- utilization metrics using only the @Maximum@ statistic, which is the
    -- highest value observed during the specified period.
    --
    -- The Compute Optimizer console displays graphs for some utilization
    -- metrics using the @Average@ statistic, which is the value of @Sum@ \/
    -- @SampleCount@ during the specified period. For more information, see
    -- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html Viewing resource recommendations>
    -- in the /Compute Optimizer User Guide/. You can also get averaged
    -- utilization metric data for your resources using Amazon CloudWatch. For
    -- more information, see the
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html Amazon CloudWatch User Guide>.
    EBSUtilizationMetric -> Maybe MetricStatistic
statistic :: Prelude.Maybe MetricStatistic
  }
  deriving (EBSUtilizationMetric -> EBSUtilizationMetric -> Bool
(EBSUtilizationMetric -> EBSUtilizationMetric -> Bool)
-> (EBSUtilizationMetric -> EBSUtilizationMetric -> Bool)
-> Eq EBSUtilizationMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EBSUtilizationMetric -> EBSUtilizationMetric -> Bool
$c/= :: EBSUtilizationMetric -> EBSUtilizationMetric -> Bool
== :: EBSUtilizationMetric -> EBSUtilizationMetric -> Bool
$c== :: EBSUtilizationMetric -> EBSUtilizationMetric -> Bool
Prelude.Eq, ReadPrec [EBSUtilizationMetric]
ReadPrec EBSUtilizationMetric
Int -> ReadS EBSUtilizationMetric
ReadS [EBSUtilizationMetric]
(Int -> ReadS EBSUtilizationMetric)
-> ReadS [EBSUtilizationMetric]
-> ReadPrec EBSUtilizationMetric
-> ReadPrec [EBSUtilizationMetric]
-> Read EBSUtilizationMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EBSUtilizationMetric]
$creadListPrec :: ReadPrec [EBSUtilizationMetric]
readPrec :: ReadPrec EBSUtilizationMetric
$creadPrec :: ReadPrec EBSUtilizationMetric
readList :: ReadS [EBSUtilizationMetric]
$creadList :: ReadS [EBSUtilizationMetric]
readsPrec :: Int -> ReadS EBSUtilizationMetric
$creadsPrec :: Int -> ReadS EBSUtilizationMetric
Prelude.Read, Int -> EBSUtilizationMetric -> ShowS
[EBSUtilizationMetric] -> ShowS
EBSUtilizationMetric -> String
(Int -> EBSUtilizationMetric -> ShowS)
-> (EBSUtilizationMetric -> String)
-> ([EBSUtilizationMetric] -> ShowS)
-> Show EBSUtilizationMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EBSUtilizationMetric] -> ShowS
$cshowList :: [EBSUtilizationMetric] -> ShowS
show :: EBSUtilizationMetric -> String
$cshow :: EBSUtilizationMetric -> String
showsPrec :: Int -> EBSUtilizationMetric -> ShowS
$cshowsPrec :: Int -> EBSUtilizationMetric -> ShowS
Prelude.Show, (forall x. EBSUtilizationMetric -> Rep EBSUtilizationMetric x)
-> (forall x. Rep EBSUtilizationMetric x -> EBSUtilizationMetric)
-> Generic EBSUtilizationMetric
forall x. Rep EBSUtilizationMetric x -> EBSUtilizationMetric
forall x. EBSUtilizationMetric -> Rep EBSUtilizationMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EBSUtilizationMetric x -> EBSUtilizationMetric
$cfrom :: forall x. EBSUtilizationMetric -> Rep EBSUtilizationMetric x
Prelude.Generic)

-- |
-- Create a value of 'EBSUtilizationMetric' 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', 'eBSUtilizationMetric_value' - The value of the utilization metric.
--
-- 'name', 'eBSUtilizationMetric_name' - The name of the utilization metric.
--
-- The following utilization metrics are available:
--
-- -   @VolumeReadOpsPerSecond@ - The completed read operations per second
--     from the volume in a specified period of time.
--
--     Unit: Count
--
-- -   @VolumeWriteOpsPerSecond@ - The completed write operations per
--     second to the volume in a specified period of time.
--
--     Unit: Count
--
-- -   @VolumeReadBytesPerSecond@ - The bytes read per second from the
--     volume in a specified period of time.
--
--     Unit: Bytes
--
-- -   @VolumeWriteBytesPerSecond@ - The bytes written to the volume in a
--     specified period of time.
--
--     Unit: Bytes
--
-- 'statistic', 'eBSUtilizationMetric_statistic' - The statistic of the utilization metric.
--
-- The Compute Optimizer API, Command Line Interface (CLI), and SDKs return
-- utilization metrics using only the @Maximum@ statistic, which is the
-- highest value observed during the specified period.
--
-- The Compute Optimizer console displays graphs for some utilization
-- metrics using the @Average@ statistic, which is the value of @Sum@ \/
-- @SampleCount@ during the specified period. For more information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html Viewing resource recommendations>
-- in the /Compute Optimizer User Guide/. You can also get averaged
-- utilization metric data for your resources using Amazon CloudWatch. For
-- more information, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html Amazon CloudWatch User Guide>.
newEBSUtilizationMetric ::
  EBSUtilizationMetric
newEBSUtilizationMetric :: EBSUtilizationMetric
newEBSUtilizationMetric =
  EBSUtilizationMetric' :: Maybe Double
-> Maybe EBSMetricName
-> Maybe MetricStatistic
-> EBSUtilizationMetric
EBSUtilizationMetric'
    { $sel:value:EBSUtilizationMetric' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EBSUtilizationMetric' :: Maybe EBSMetricName
name = Maybe EBSMetricName
forall a. Maybe a
Prelude.Nothing,
      $sel:statistic:EBSUtilizationMetric' :: Maybe MetricStatistic
statistic = Maybe MetricStatistic
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the utilization metric.
eBSUtilizationMetric_value :: Lens.Lens' EBSUtilizationMetric (Prelude.Maybe Prelude.Double)
eBSUtilizationMetric_value :: (Maybe Double -> f (Maybe Double))
-> EBSUtilizationMetric -> f EBSUtilizationMetric
eBSUtilizationMetric_value = (EBSUtilizationMetric -> Maybe Double)
-> (EBSUtilizationMetric -> Maybe Double -> EBSUtilizationMetric)
-> Lens
     EBSUtilizationMetric
     EBSUtilizationMetric
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EBSUtilizationMetric' {Maybe Double
value :: Maybe Double
$sel:value:EBSUtilizationMetric' :: EBSUtilizationMetric -> Maybe Double
value} -> Maybe Double
value) (\s :: EBSUtilizationMetric
s@EBSUtilizationMetric' {} Maybe Double
a -> EBSUtilizationMetric
s {$sel:value:EBSUtilizationMetric' :: Maybe Double
value = Maybe Double
a} :: EBSUtilizationMetric)

-- | The name of the utilization metric.
--
-- The following utilization metrics are available:
--
-- -   @VolumeReadOpsPerSecond@ - The completed read operations per second
--     from the volume in a specified period of time.
--
--     Unit: Count
--
-- -   @VolumeWriteOpsPerSecond@ - The completed write operations per
--     second to the volume in a specified period of time.
--
--     Unit: Count
--
-- -   @VolumeReadBytesPerSecond@ - The bytes read per second from the
--     volume in a specified period of time.
--
--     Unit: Bytes
--
-- -   @VolumeWriteBytesPerSecond@ - The bytes written to the volume in a
--     specified period of time.
--
--     Unit: Bytes
eBSUtilizationMetric_name :: Lens.Lens' EBSUtilizationMetric (Prelude.Maybe EBSMetricName)
eBSUtilizationMetric_name :: (Maybe EBSMetricName -> f (Maybe EBSMetricName))
-> EBSUtilizationMetric -> f EBSUtilizationMetric
eBSUtilizationMetric_name = (EBSUtilizationMetric -> Maybe EBSMetricName)
-> (EBSUtilizationMetric
    -> Maybe EBSMetricName -> EBSUtilizationMetric)
-> Lens
     EBSUtilizationMetric
     EBSUtilizationMetric
     (Maybe EBSMetricName)
     (Maybe EBSMetricName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EBSUtilizationMetric' {Maybe EBSMetricName
name :: Maybe EBSMetricName
$sel:name:EBSUtilizationMetric' :: EBSUtilizationMetric -> Maybe EBSMetricName
name} -> Maybe EBSMetricName
name) (\s :: EBSUtilizationMetric
s@EBSUtilizationMetric' {} Maybe EBSMetricName
a -> EBSUtilizationMetric
s {$sel:name:EBSUtilizationMetric' :: Maybe EBSMetricName
name = Maybe EBSMetricName
a} :: EBSUtilizationMetric)

-- | The statistic of the utilization metric.
--
-- The Compute Optimizer API, Command Line Interface (CLI), and SDKs return
-- utilization metrics using only the @Maximum@ statistic, which is the
-- highest value observed during the specified period.
--
-- The Compute Optimizer console displays graphs for some utilization
-- metrics using the @Average@ statistic, which is the value of @Sum@ \/
-- @SampleCount@ during the specified period. For more information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html Viewing resource recommendations>
-- in the /Compute Optimizer User Guide/. You can also get averaged
-- utilization metric data for your resources using Amazon CloudWatch. For
-- more information, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html Amazon CloudWatch User Guide>.
eBSUtilizationMetric_statistic :: Lens.Lens' EBSUtilizationMetric (Prelude.Maybe MetricStatistic)
eBSUtilizationMetric_statistic :: (Maybe MetricStatistic -> f (Maybe MetricStatistic))
-> EBSUtilizationMetric -> f EBSUtilizationMetric
eBSUtilizationMetric_statistic = (EBSUtilizationMetric -> Maybe MetricStatistic)
-> (EBSUtilizationMetric
    -> Maybe MetricStatistic -> EBSUtilizationMetric)
-> Lens
     EBSUtilizationMetric
     EBSUtilizationMetric
     (Maybe MetricStatistic)
     (Maybe MetricStatistic)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EBSUtilizationMetric' {Maybe MetricStatistic
statistic :: Maybe MetricStatistic
$sel:statistic:EBSUtilizationMetric' :: EBSUtilizationMetric -> Maybe MetricStatistic
statistic} -> Maybe MetricStatistic
statistic) (\s :: EBSUtilizationMetric
s@EBSUtilizationMetric' {} Maybe MetricStatistic
a -> EBSUtilizationMetric
s {$sel:statistic:EBSUtilizationMetric' :: Maybe MetricStatistic
statistic = Maybe MetricStatistic
a} :: EBSUtilizationMetric)

instance Core.FromJSON EBSUtilizationMetric where
  parseJSON :: Value -> Parser EBSUtilizationMetric
parseJSON =
    String
-> (Object -> Parser EBSUtilizationMetric)
-> Value
-> Parser EBSUtilizationMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EBSUtilizationMetric"
      ( \Object
x ->
          Maybe Double
-> Maybe EBSMetricName
-> Maybe MetricStatistic
-> EBSUtilizationMetric
EBSUtilizationMetric'
            (Maybe Double
 -> Maybe EBSMetricName
 -> Maybe MetricStatistic
 -> EBSUtilizationMetric)
-> Parser (Maybe Double)
-> Parser
     (Maybe EBSMetricName
      -> Maybe MetricStatistic -> EBSUtilizationMetric)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"value")
            Parser
  (Maybe EBSMetricName
   -> Maybe MetricStatistic -> EBSUtilizationMetric)
-> Parser (Maybe EBSMetricName)
-> Parser (Maybe MetricStatistic -> EBSUtilizationMetric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EBSMetricName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
            Parser (Maybe MetricStatistic -> EBSUtilizationMetric)
-> Parser (Maybe MetricStatistic) -> Parser EBSUtilizationMetric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MetricStatistic)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"statistic")
      )

instance Prelude.Hashable EBSUtilizationMetric

instance Prelude.NFData EBSUtilizationMetric