{-# 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.CostExplorer.Types.EC2ResourceUtilization
-- 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.CostExplorer.Types.EC2ResourceUtilization where

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.DiskResourceUtilization
import Amazonka.CostExplorer.Types.EBSResourceUtilization
import Amazonka.CostExplorer.Types.NetworkResourceUtilization
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Utilization metrics of the instance.
--
-- /See:/ 'newEC2ResourceUtilization' smart constructor.
data EC2ResourceUtilization = EC2ResourceUtilization'
  { -- | The maximum observed or expected CPU utilization of the instance.
    EC2ResourceUtilization -> Maybe Text
maxCpuUtilizationPercentage :: Prelude.Maybe Prelude.Text,
    -- | The network field that contains a list of network metrics that are
    -- associated with the current instance.
    EC2ResourceUtilization -> Maybe NetworkResourceUtilization
networkResourceUtilization :: Prelude.Maybe NetworkResourceUtilization,
    -- | The EBS field that contains a list of EBS metrics that are associated
    -- with the current instance.
    EC2ResourceUtilization -> Maybe EBSResourceUtilization
eBSResourceUtilization :: Prelude.Maybe EBSResourceUtilization,
    -- | The maximum observed or expected storage utilization of the instance.
    -- This doesn\'t include EBS storage.
    EC2ResourceUtilization -> Maybe Text
maxStorageUtilizationPercentage :: Prelude.Maybe Prelude.Text,
    -- | The maximum observed or expected memory utilization of the instance.
    EC2ResourceUtilization -> Maybe Text
maxMemoryUtilizationPercentage :: Prelude.Maybe Prelude.Text,
    -- | The field that contains a list of disk (local storage) metrics that are
    -- associated with the current instance.
    EC2ResourceUtilization -> Maybe DiskResourceUtilization
diskResourceUtilization :: Prelude.Maybe DiskResourceUtilization
  }
  deriving (EC2ResourceUtilization -> EC2ResourceUtilization -> Bool
(EC2ResourceUtilization -> EC2ResourceUtilization -> Bool)
-> (EC2ResourceUtilization -> EC2ResourceUtilization -> Bool)
-> Eq EC2ResourceUtilization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EC2ResourceUtilization -> EC2ResourceUtilization -> Bool
$c/= :: EC2ResourceUtilization -> EC2ResourceUtilization -> Bool
== :: EC2ResourceUtilization -> EC2ResourceUtilization -> Bool
$c== :: EC2ResourceUtilization -> EC2ResourceUtilization -> Bool
Prelude.Eq, ReadPrec [EC2ResourceUtilization]
ReadPrec EC2ResourceUtilization
Int -> ReadS EC2ResourceUtilization
ReadS [EC2ResourceUtilization]
(Int -> ReadS EC2ResourceUtilization)
-> ReadS [EC2ResourceUtilization]
-> ReadPrec EC2ResourceUtilization
-> ReadPrec [EC2ResourceUtilization]
-> Read EC2ResourceUtilization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EC2ResourceUtilization]
$creadListPrec :: ReadPrec [EC2ResourceUtilization]
readPrec :: ReadPrec EC2ResourceUtilization
$creadPrec :: ReadPrec EC2ResourceUtilization
readList :: ReadS [EC2ResourceUtilization]
$creadList :: ReadS [EC2ResourceUtilization]
readsPrec :: Int -> ReadS EC2ResourceUtilization
$creadsPrec :: Int -> ReadS EC2ResourceUtilization
Prelude.Read, Int -> EC2ResourceUtilization -> ShowS
[EC2ResourceUtilization] -> ShowS
EC2ResourceUtilization -> String
(Int -> EC2ResourceUtilization -> ShowS)
-> (EC2ResourceUtilization -> String)
-> ([EC2ResourceUtilization] -> ShowS)
-> Show EC2ResourceUtilization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EC2ResourceUtilization] -> ShowS
$cshowList :: [EC2ResourceUtilization] -> ShowS
show :: EC2ResourceUtilization -> String
$cshow :: EC2ResourceUtilization -> String
showsPrec :: Int -> EC2ResourceUtilization -> ShowS
$cshowsPrec :: Int -> EC2ResourceUtilization -> ShowS
Prelude.Show, (forall x. EC2ResourceUtilization -> Rep EC2ResourceUtilization x)
-> (forall x.
    Rep EC2ResourceUtilization x -> EC2ResourceUtilization)
-> Generic EC2ResourceUtilization
forall x. Rep EC2ResourceUtilization x -> EC2ResourceUtilization
forall x. EC2ResourceUtilization -> Rep EC2ResourceUtilization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EC2ResourceUtilization x -> EC2ResourceUtilization
$cfrom :: forall x. EC2ResourceUtilization -> Rep EC2ResourceUtilization x
Prelude.Generic)

-- |
-- Create a value of 'EC2ResourceUtilization' 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:
--
-- 'maxCpuUtilizationPercentage', 'eC2ResourceUtilization_maxCpuUtilizationPercentage' - The maximum observed or expected CPU utilization of the instance.
--
-- 'networkResourceUtilization', 'eC2ResourceUtilization_networkResourceUtilization' - The network field that contains a list of network metrics that are
-- associated with the current instance.
--
-- 'eBSResourceUtilization', 'eC2ResourceUtilization_eBSResourceUtilization' - The EBS field that contains a list of EBS metrics that are associated
-- with the current instance.
--
-- 'maxStorageUtilizationPercentage', 'eC2ResourceUtilization_maxStorageUtilizationPercentage' - The maximum observed or expected storage utilization of the instance.
-- This doesn\'t include EBS storage.
--
-- 'maxMemoryUtilizationPercentage', 'eC2ResourceUtilization_maxMemoryUtilizationPercentage' - The maximum observed or expected memory utilization of the instance.
--
-- 'diskResourceUtilization', 'eC2ResourceUtilization_diskResourceUtilization' - The field that contains a list of disk (local storage) metrics that are
-- associated with the current instance.
newEC2ResourceUtilization ::
  EC2ResourceUtilization
newEC2ResourceUtilization :: EC2ResourceUtilization
newEC2ResourceUtilization =
  EC2ResourceUtilization' :: Maybe Text
-> Maybe NetworkResourceUtilization
-> Maybe EBSResourceUtilization
-> Maybe Text
-> Maybe Text
-> Maybe DiskResourceUtilization
-> EC2ResourceUtilization
EC2ResourceUtilization'
    { $sel:maxCpuUtilizationPercentage:EC2ResourceUtilization' :: Maybe Text
maxCpuUtilizationPercentage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:networkResourceUtilization:EC2ResourceUtilization' :: Maybe NetworkResourceUtilization
networkResourceUtilization = Maybe NetworkResourceUtilization
forall a. Maybe a
Prelude.Nothing,
      $sel:eBSResourceUtilization:EC2ResourceUtilization' :: Maybe EBSResourceUtilization
eBSResourceUtilization = Maybe EBSResourceUtilization
forall a. Maybe a
Prelude.Nothing,
      $sel:maxStorageUtilizationPercentage:EC2ResourceUtilization' :: Maybe Text
maxStorageUtilizationPercentage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxMemoryUtilizationPercentage:EC2ResourceUtilization' :: Maybe Text
maxMemoryUtilizationPercentage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:diskResourceUtilization:EC2ResourceUtilization' :: Maybe DiskResourceUtilization
diskResourceUtilization = Maybe DiskResourceUtilization
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum observed or expected CPU utilization of the instance.
eC2ResourceUtilization_maxCpuUtilizationPercentage :: Lens.Lens' EC2ResourceUtilization (Prelude.Maybe Prelude.Text)
eC2ResourceUtilization_maxCpuUtilizationPercentage :: (Maybe Text -> f (Maybe Text))
-> EC2ResourceUtilization -> f EC2ResourceUtilization
eC2ResourceUtilization_maxCpuUtilizationPercentage = (EC2ResourceUtilization -> Maybe Text)
-> (EC2ResourceUtilization -> Maybe Text -> EC2ResourceUtilization)
-> Lens
     EC2ResourceUtilization
     EC2ResourceUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2ResourceUtilization' {Maybe Text
maxCpuUtilizationPercentage :: Maybe Text
$sel:maxCpuUtilizationPercentage:EC2ResourceUtilization' :: EC2ResourceUtilization -> Maybe Text
maxCpuUtilizationPercentage} -> Maybe Text
maxCpuUtilizationPercentage) (\s :: EC2ResourceUtilization
s@EC2ResourceUtilization' {} Maybe Text
a -> EC2ResourceUtilization
s {$sel:maxCpuUtilizationPercentage:EC2ResourceUtilization' :: Maybe Text
maxCpuUtilizationPercentage = Maybe Text
a} :: EC2ResourceUtilization)

-- | The network field that contains a list of network metrics that are
-- associated with the current instance.
eC2ResourceUtilization_networkResourceUtilization :: Lens.Lens' EC2ResourceUtilization (Prelude.Maybe NetworkResourceUtilization)
eC2ResourceUtilization_networkResourceUtilization :: (Maybe NetworkResourceUtilization
 -> f (Maybe NetworkResourceUtilization))
-> EC2ResourceUtilization -> f EC2ResourceUtilization
eC2ResourceUtilization_networkResourceUtilization = (EC2ResourceUtilization -> Maybe NetworkResourceUtilization)
-> (EC2ResourceUtilization
    -> Maybe NetworkResourceUtilization -> EC2ResourceUtilization)
-> Lens
     EC2ResourceUtilization
     EC2ResourceUtilization
     (Maybe NetworkResourceUtilization)
     (Maybe NetworkResourceUtilization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2ResourceUtilization' {Maybe NetworkResourceUtilization
networkResourceUtilization :: Maybe NetworkResourceUtilization
$sel:networkResourceUtilization:EC2ResourceUtilization' :: EC2ResourceUtilization -> Maybe NetworkResourceUtilization
networkResourceUtilization} -> Maybe NetworkResourceUtilization
networkResourceUtilization) (\s :: EC2ResourceUtilization
s@EC2ResourceUtilization' {} Maybe NetworkResourceUtilization
a -> EC2ResourceUtilization
s {$sel:networkResourceUtilization:EC2ResourceUtilization' :: Maybe NetworkResourceUtilization
networkResourceUtilization = Maybe NetworkResourceUtilization
a} :: EC2ResourceUtilization)

-- | The EBS field that contains a list of EBS metrics that are associated
-- with the current instance.
eC2ResourceUtilization_eBSResourceUtilization :: Lens.Lens' EC2ResourceUtilization (Prelude.Maybe EBSResourceUtilization)
eC2ResourceUtilization_eBSResourceUtilization :: (Maybe EBSResourceUtilization -> f (Maybe EBSResourceUtilization))
-> EC2ResourceUtilization -> f EC2ResourceUtilization
eC2ResourceUtilization_eBSResourceUtilization = (EC2ResourceUtilization -> Maybe EBSResourceUtilization)
-> (EC2ResourceUtilization
    -> Maybe EBSResourceUtilization -> EC2ResourceUtilization)
-> Lens
     EC2ResourceUtilization
     EC2ResourceUtilization
     (Maybe EBSResourceUtilization)
     (Maybe EBSResourceUtilization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2ResourceUtilization' {Maybe EBSResourceUtilization
eBSResourceUtilization :: Maybe EBSResourceUtilization
$sel:eBSResourceUtilization:EC2ResourceUtilization' :: EC2ResourceUtilization -> Maybe EBSResourceUtilization
eBSResourceUtilization} -> Maybe EBSResourceUtilization
eBSResourceUtilization) (\s :: EC2ResourceUtilization
s@EC2ResourceUtilization' {} Maybe EBSResourceUtilization
a -> EC2ResourceUtilization
s {$sel:eBSResourceUtilization:EC2ResourceUtilization' :: Maybe EBSResourceUtilization
eBSResourceUtilization = Maybe EBSResourceUtilization
a} :: EC2ResourceUtilization)

-- | The maximum observed or expected storage utilization of the instance.
-- This doesn\'t include EBS storage.
eC2ResourceUtilization_maxStorageUtilizationPercentage :: Lens.Lens' EC2ResourceUtilization (Prelude.Maybe Prelude.Text)
eC2ResourceUtilization_maxStorageUtilizationPercentage :: (Maybe Text -> f (Maybe Text))
-> EC2ResourceUtilization -> f EC2ResourceUtilization
eC2ResourceUtilization_maxStorageUtilizationPercentage = (EC2ResourceUtilization -> Maybe Text)
-> (EC2ResourceUtilization -> Maybe Text -> EC2ResourceUtilization)
-> Lens
     EC2ResourceUtilization
     EC2ResourceUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2ResourceUtilization' {Maybe Text
maxStorageUtilizationPercentage :: Maybe Text
$sel:maxStorageUtilizationPercentage:EC2ResourceUtilization' :: EC2ResourceUtilization -> Maybe Text
maxStorageUtilizationPercentage} -> Maybe Text
maxStorageUtilizationPercentage) (\s :: EC2ResourceUtilization
s@EC2ResourceUtilization' {} Maybe Text
a -> EC2ResourceUtilization
s {$sel:maxStorageUtilizationPercentage:EC2ResourceUtilization' :: Maybe Text
maxStorageUtilizationPercentage = Maybe Text
a} :: EC2ResourceUtilization)

-- | The maximum observed or expected memory utilization of the instance.
eC2ResourceUtilization_maxMemoryUtilizationPercentage :: Lens.Lens' EC2ResourceUtilization (Prelude.Maybe Prelude.Text)
eC2ResourceUtilization_maxMemoryUtilizationPercentage :: (Maybe Text -> f (Maybe Text))
-> EC2ResourceUtilization -> f EC2ResourceUtilization
eC2ResourceUtilization_maxMemoryUtilizationPercentage = (EC2ResourceUtilization -> Maybe Text)
-> (EC2ResourceUtilization -> Maybe Text -> EC2ResourceUtilization)
-> Lens
     EC2ResourceUtilization
     EC2ResourceUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2ResourceUtilization' {Maybe Text
maxMemoryUtilizationPercentage :: Maybe Text
$sel:maxMemoryUtilizationPercentage:EC2ResourceUtilization' :: EC2ResourceUtilization -> Maybe Text
maxMemoryUtilizationPercentage} -> Maybe Text
maxMemoryUtilizationPercentage) (\s :: EC2ResourceUtilization
s@EC2ResourceUtilization' {} Maybe Text
a -> EC2ResourceUtilization
s {$sel:maxMemoryUtilizationPercentage:EC2ResourceUtilization' :: Maybe Text
maxMemoryUtilizationPercentage = Maybe Text
a} :: EC2ResourceUtilization)

-- | The field that contains a list of disk (local storage) metrics that are
-- associated with the current instance.
eC2ResourceUtilization_diskResourceUtilization :: Lens.Lens' EC2ResourceUtilization (Prelude.Maybe DiskResourceUtilization)
eC2ResourceUtilization_diskResourceUtilization :: (Maybe DiskResourceUtilization
 -> f (Maybe DiskResourceUtilization))
-> EC2ResourceUtilization -> f EC2ResourceUtilization
eC2ResourceUtilization_diskResourceUtilization = (EC2ResourceUtilization -> Maybe DiskResourceUtilization)
-> (EC2ResourceUtilization
    -> Maybe DiskResourceUtilization -> EC2ResourceUtilization)
-> Lens
     EC2ResourceUtilization
     EC2ResourceUtilization
     (Maybe DiskResourceUtilization)
     (Maybe DiskResourceUtilization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2ResourceUtilization' {Maybe DiskResourceUtilization
diskResourceUtilization :: Maybe DiskResourceUtilization
$sel:diskResourceUtilization:EC2ResourceUtilization' :: EC2ResourceUtilization -> Maybe DiskResourceUtilization
diskResourceUtilization} -> Maybe DiskResourceUtilization
diskResourceUtilization) (\s :: EC2ResourceUtilization
s@EC2ResourceUtilization' {} Maybe DiskResourceUtilization
a -> EC2ResourceUtilization
s {$sel:diskResourceUtilization:EC2ResourceUtilization' :: Maybe DiskResourceUtilization
diskResourceUtilization = Maybe DiskResourceUtilization
a} :: EC2ResourceUtilization)

instance Core.FromJSON EC2ResourceUtilization where
  parseJSON :: Value -> Parser EC2ResourceUtilization
parseJSON =
    String
-> (Object -> Parser EC2ResourceUtilization)
-> Value
-> Parser EC2ResourceUtilization
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EC2ResourceUtilization"
      ( \Object
x ->
          Maybe Text
-> Maybe NetworkResourceUtilization
-> Maybe EBSResourceUtilization
-> Maybe Text
-> Maybe Text
-> Maybe DiskResourceUtilization
-> EC2ResourceUtilization
EC2ResourceUtilization'
            (Maybe Text
 -> Maybe NetworkResourceUtilization
 -> Maybe EBSResourceUtilization
 -> Maybe Text
 -> Maybe Text
 -> Maybe DiskResourceUtilization
 -> EC2ResourceUtilization)
-> Parser (Maybe Text)
-> Parser
     (Maybe NetworkResourceUtilization
      -> Maybe EBSResourceUtilization
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiskResourceUtilization
      -> EC2ResourceUtilization)
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
"MaxCpuUtilizationPercentage")
            Parser
  (Maybe NetworkResourceUtilization
   -> Maybe EBSResourceUtilization
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiskResourceUtilization
   -> EC2ResourceUtilization)
-> Parser (Maybe NetworkResourceUtilization)
-> Parser
     (Maybe EBSResourceUtilization
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiskResourceUtilization
      -> EC2ResourceUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NetworkResourceUtilization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NetworkResourceUtilization")
            Parser
  (Maybe EBSResourceUtilization
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiskResourceUtilization
   -> EC2ResourceUtilization)
-> Parser (Maybe EBSResourceUtilization)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe DiskResourceUtilization
      -> EC2ResourceUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EBSResourceUtilization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EBSResourceUtilization")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe DiskResourceUtilization
   -> EC2ResourceUtilization)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe DiskResourceUtilization -> EC2ResourceUtilization)
forall (f :: * -> *) a b. Applicative f => 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
"MaxStorageUtilizationPercentage")
            Parser
  (Maybe Text
   -> Maybe DiskResourceUtilization -> EC2ResourceUtilization)
-> Parser (Maybe Text)
-> Parser (Maybe DiskResourceUtilization -> EC2ResourceUtilization)
forall (f :: * -> *) a b. Applicative f => 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
"MaxMemoryUtilizationPercentage")
            Parser (Maybe DiskResourceUtilization -> EC2ResourceUtilization)
-> Parser (Maybe DiskResourceUtilization)
-> Parser EC2ResourceUtilization
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DiskResourceUtilization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DiskResourceUtilization")
      )

instance Prelude.Hashable EC2ResourceUtilization

instance Prelude.NFData EC2ResourceUtilization