{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Lightsail.GetContainerServiceMetricData
-- 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)
--
-- Returns the data points of a specific metric of your Amazon Lightsail
-- container service.
--
-- Metrics report the utilization of your resources. Monitor and collect
-- metric data regularly to maintain the reliability, availability, and
-- performance of your resources.
module Amazonka.Lightsail.GetContainerServiceMetricData
  ( -- * Creating a Request
    GetContainerServiceMetricData (..),
    newGetContainerServiceMetricData,

    -- * Request Lenses
    getContainerServiceMetricData_serviceName,
    getContainerServiceMetricData_metricName,
    getContainerServiceMetricData_startTime,
    getContainerServiceMetricData_endTime,
    getContainerServiceMetricData_period,
    getContainerServiceMetricData_statistics,

    -- * Destructuring the Response
    GetContainerServiceMetricDataResponse (..),
    newGetContainerServiceMetricDataResponse,

    -- * Response Lenses
    getContainerServiceMetricDataResponse_metricName,
    getContainerServiceMetricDataResponse_metricData,
    getContainerServiceMetricDataResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetContainerServiceMetricData' smart constructor.
data GetContainerServiceMetricData = GetContainerServiceMetricData'
  { -- | The name of the container service for which to get metric data.
    GetContainerServiceMetricData -> Text
serviceName :: Prelude.Text,
    -- | The metric for which you want to return information.
    --
    -- Valid container service metric names are listed below, along with the
    -- most useful statistics to include in your request, and the published
    -- unit value.
    --
    -- -   @CPUUtilization@ - The average percentage of compute units that are
    --     currently in use across all nodes of the container service. This
    --     metric identifies the processing power required to run containers on
    --     each node of the container service.
    --
    --     Statistics: The most useful statistics are @Maximum@ and @Average@.
    --
    --     Unit: The published unit is @Percent@.
    --
    -- -   @MemoryUtilization@ - The average percentage of available memory
    --     that is currently in use across all nodes of the container service.
    --     This metric identifies the memory required to run containers on each
    --     node of the container service.
    --
    --     Statistics: The most useful statistics are @Maximum@ and @Average@.
    --
    --     Unit: The published unit is @Percent@.
    GetContainerServiceMetricData -> ContainerServiceMetricName
metricName :: ContainerServiceMetricName,
    -- | The start time of the time period.
    GetContainerServiceMetricData -> POSIX
startTime :: Core.POSIX,
    -- | The end time of the time period.
    GetContainerServiceMetricData -> POSIX
endTime :: Core.POSIX,
    -- | The granularity, in seconds, of the returned data points.
    --
    -- All container service metric data is available in 5-minute (300 seconds)
    -- granularity.
    GetContainerServiceMetricData -> Natural
period :: Prelude.Natural,
    -- | The statistic for the metric.
    --
    -- The following statistics are available:
    --
    -- -   @Minimum@ - The lowest value observed during the specified period.
    --     Use this value to determine low volumes of activity for your
    --     application.
    --
    -- -   @Maximum@ - The highest value observed during the specified period.
    --     Use this value to determine high volumes of activity for your
    --     application.
    --
    -- -   @Sum@ - All values submitted for the matching metric added together.
    --     You can use this statistic to determine the total volume of a
    --     metric.
    --
    -- -   @Average@ - The value of @Sum@ \/ @SampleCount@ during the specified
    --     period. By comparing this statistic with the @Minimum@ and @Maximum@
    --     values, you can determine the full scope of a metric and how close
    --     the average use is to the @Minimum@ and @Maximum@ values. This
    --     comparison helps you to know when to increase or decrease your
    --     resources.
    --
    -- -   @SampleCount@ - The count, or number, of data points used for the
    --     statistical calculation.
    GetContainerServiceMetricData -> [MetricStatistic]
statistics :: [MetricStatistic]
  }
  deriving (GetContainerServiceMetricData
-> GetContainerServiceMetricData -> Bool
(GetContainerServiceMetricData
 -> GetContainerServiceMetricData -> Bool)
-> (GetContainerServiceMetricData
    -> GetContainerServiceMetricData -> Bool)
-> Eq GetContainerServiceMetricData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerServiceMetricData
-> GetContainerServiceMetricData -> Bool
$c/= :: GetContainerServiceMetricData
-> GetContainerServiceMetricData -> Bool
== :: GetContainerServiceMetricData
-> GetContainerServiceMetricData -> Bool
$c== :: GetContainerServiceMetricData
-> GetContainerServiceMetricData -> Bool
Prelude.Eq, ReadPrec [GetContainerServiceMetricData]
ReadPrec GetContainerServiceMetricData
Int -> ReadS GetContainerServiceMetricData
ReadS [GetContainerServiceMetricData]
(Int -> ReadS GetContainerServiceMetricData)
-> ReadS [GetContainerServiceMetricData]
-> ReadPrec GetContainerServiceMetricData
-> ReadPrec [GetContainerServiceMetricData]
-> Read GetContainerServiceMetricData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerServiceMetricData]
$creadListPrec :: ReadPrec [GetContainerServiceMetricData]
readPrec :: ReadPrec GetContainerServiceMetricData
$creadPrec :: ReadPrec GetContainerServiceMetricData
readList :: ReadS [GetContainerServiceMetricData]
$creadList :: ReadS [GetContainerServiceMetricData]
readsPrec :: Int -> ReadS GetContainerServiceMetricData
$creadsPrec :: Int -> ReadS GetContainerServiceMetricData
Prelude.Read, Int -> GetContainerServiceMetricData -> ShowS
[GetContainerServiceMetricData] -> ShowS
GetContainerServiceMetricData -> String
(Int -> GetContainerServiceMetricData -> ShowS)
-> (GetContainerServiceMetricData -> String)
-> ([GetContainerServiceMetricData] -> ShowS)
-> Show GetContainerServiceMetricData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerServiceMetricData] -> ShowS
$cshowList :: [GetContainerServiceMetricData] -> ShowS
show :: GetContainerServiceMetricData -> String
$cshow :: GetContainerServiceMetricData -> String
showsPrec :: Int -> GetContainerServiceMetricData -> ShowS
$cshowsPrec :: Int -> GetContainerServiceMetricData -> ShowS
Prelude.Show, (forall x.
 GetContainerServiceMetricData
 -> Rep GetContainerServiceMetricData x)
-> (forall x.
    Rep GetContainerServiceMetricData x
    -> GetContainerServiceMetricData)
-> Generic GetContainerServiceMetricData
forall x.
Rep GetContainerServiceMetricData x
-> GetContainerServiceMetricData
forall x.
GetContainerServiceMetricData
-> Rep GetContainerServiceMetricData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContainerServiceMetricData x
-> GetContainerServiceMetricData
$cfrom :: forall x.
GetContainerServiceMetricData
-> Rep GetContainerServiceMetricData x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerServiceMetricData' 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:
--
-- 'serviceName', 'getContainerServiceMetricData_serviceName' - The name of the container service for which to get metric data.
--
-- 'metricName', 'getContainerServiceMetricData_metricName' - The metric for which you want to return information.
--
-- Valid container service metric names are listed below, along with the
-- most useful statistics to include in your request, and the published
-- unit value.
--
-- -   @CPUUtilization@ - The average percentage of compute units that are
--     currently in use across all nodes of the container service. This
--     metric identifies the processing power required to run containers on
--     each node of the container service.
--
--     Statistics: The most useful statistics are @Maximum@ and @Average@.
--
--     Unit: The published unit is @Percent@.
--
-- -   @MemoryUtilization@ - The average percentage of available memory
--     that is currently in use across all nodes of the container service.
--     This metric identifies the memory required to run containers on each
--     node of the container service.
--
--     Statistics: The most useful statistics are @Maximum@ and @Average@.
--
--     Unit: The published unit is @Percent@.
--
-- 'startTime', 'getContainerServiceMetricData_startTime' - The start time of the time period.
--
-- 'endTime', 'getContainerServiceMetricData_endTime' - The end time of the time period.
--
-- 'period', 'getContainerServiceMetricData_period' - The granularity, in seconds, of the returned data points.
--
-- All container service metric data is available in 5-minute (300 seconds)
-- granularity.
--
-- 'statistics', 'getContainerServiceMetricData_statistics' - The statistic for the metric.
--
-- The following statistics are available:
--
-- -   @Minimum@ - The lowest value observed during the specified period.
--     Use this value to determine low volumes of activity for your
--     application.
--
-- -   @Maximum@ - The highest value observed during the specified period.
--     Use this value to determine high volumes of activity for your
--     application.
--
-- -   @Sum@ - All values submitted for the matching metric added together.
--     You can use this statistic to determine the total volume of a
--     metric.
--
-- -   @Average@ - The value of @Sum@ \/ @SampleCount@ during the specified
--     period. By comparing this statistic with the @Minimum@ and @Maximum@
--     values, you can determine the full scope of a metric and how close
--     the average use is to the @Minimum@ and @Maximum@ values. This
--     comparison helps you to know when to increase or decrease your
--     resources.
--
-- -   @SampleCount@ - The count, or number, of data points used for the
--     statistical calculation.
newGetContainerServiceMetricData ::
  -- | 'serviceName'
  Prelude.Text ->
  -- | 'metricName'
  ContainerServiceMetricName ->
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'period'
  Prelude.Natural ->
  GetContainerServiceMetricData
newGetContainerServiceMetricData :: Text
-> ContainerServiceMetricName
-> UTCTime
-> UTCTime
-> Natural
-> GetContainerServiceMetricData
newGetContainerServiceMetricData
  Text
pServiceName_
  ContainerServiceMetricName
pMetricName_
  UTCTime
pStartTime_
  UTCTime
pEndTime_
  Natural
pPeriod_ =
    GetContainerServiceMetricData' :: Text
-> ContainerServiceMetricName
-> POSIX
-> POSIX
-> Natural
-> [MetricStatistic]
-> GetContainerServiceMetricData
GetContainerServiceMetricData'
      { $sel:serviceName:GetContainerServiceMetricData' :: Text
serviceName =
          Text
pServiceName_,
        $sel:metricName:GetContainerServiceMetricData' :: ContainerServiceMetricName
metricName = ContainerServiceMetricName
pMetricName_,
        $sel:startTime:GetContainerServiceMetricData' :: POSIX
startTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
        $sel:endTime:GetContainerServiceMetricData' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_,
        $sel:period:GetContainerServiceMetricData' :: Natural
period = Natural
pPeriod_,
        $sel:statistics:GetContainerServiceMetricData' :: [MetricStatistic]
statistics = [MetricStatistic]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The name of the container service for which to get metric data.
getContainerServiceMetricData_serviceName :: Lens.Lens' GetContainerServiceMetricData Prelude.Text
getContainerServiceMetricData_serviceName :: (Text -> f Text)
-> GetContainerServiceMetricData -> f GetContainerServiceMetricData
getContainerServiceMetricData_serviceName = (GetContainerServiceMetricData -> Text)
-> (GetContainerServiceMetricData
    -> Text -> GetContainerServiceMetricData)
-> Lens
     GetContainerServiceMetricData
     GetContainerServiceMetricData
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricData' {Text
serviceName :: Text
$sel:serviceName:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> Text
serviceName} -> Text
serviceName) (\s :: GetContainerServiceMetricData
s@GetContainerServiceMetricData' {} Text
a -> GetContainerServiceMetricData
s {$sel:serviceName:GetContainerServiceMetricData' :: Text
serviceName = Text
a} :: GetContainerServiceMetricData)

-- | The metric for which you want to return information.
--
-- Valid container service metric names are listed below, along with the
-- most useful statistics to include in your request, and the published
-- unit value.
--
-- -   @CPUUtilization@ - The average percentage of compute units that are
--     currently in use across all nodes of the container service. This
--     metric identifies the processing power required to run containers on
--     each node of the container service.
--
--     Statistics: The most useful statistics are @Maximum@ and @Average@.
--
--     Unit: The published unit is @Percent@.
--
-- -   @MemoryUtilization@ - The average percentage of available memory
--     that is currently in use across all nodes of the container service.
--     This metric identifies the memory required to run containers on each
--     node of the container service.
--
--     Statistics: The most useful statistics are @Maximum@ and @Average@.
--
--     Unit: The published unit is @Percent@.
getContainerServiceMetricData_metricName :: Lens.Lens' GetContainerServiceMetricData ContainerServiceMetricName
getContainerServiceMetricData_metricName :: (ContainerServiceMetricName -> f ContainerServiceMetricName)
-> GetContainerServiceMetricData -> f GetContainerServiceMetricData
getContainerServiceMetricData_metricName = (GetContainerServiceMetricData -> ContainerServiceMetricName)
-> (GetContainerServiceMetricData
    -> ContainerServiceMetricName -> GetContainerServiceMetricData)
-> Lens
     GetContainerServiceMetricData
     GetContainerServiceMetricData
     ContainerServiceMetricName
     ContainerServiceMetricName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricData' {ContainerServiceMetricName
metricName :: ContainerServiceMetricName
$sel:metricName:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> ContainerServiceMetricName
metricName} -> ContainerServiceMetricName
metricName) (\s :: GetContainerServiceMetricData
s@GetContainerServiceMetricData' {} ContainerServiceMetricName
a -> GetContainerServiceMetricData
s {$sel:metricName:GetContainerServiceMetricData' :: ContainerServiceMetricName
metricName = ContainerServiceMetricName
a} :: GetContainerServiceMetricData)

-- | The start time of the time period.
getContainerServiceMetricData_startTime :: Lens.Lens' GetContainerServiceMetricData Prelude.UTCTime
getContainerServiceMetricData_startTime :: (UTCTime -> f UTCTime)
-> GetContainerServiceMetricData -> f GetContainerServiceMetricData
getContainerServiceMetricData_startTime = (GetContainerServiceMetricData -> POSIX)
-> (GetContainerServiceMetricData
    -> POSIX -> GetContainerServiceMetricData)
-> Lens
     GetContainerServiceMetricData
     GetContainerServiceMetricData
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricData' {POSIX
startTime :: POSIX
$sel:startTime:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> POSIX
startTime} -> POSIX
startTime) (\s :: GetContainerServiceMetricData
s@GetContainerServiceMetricData' {} POSIX
a -> GetContainerServiceMetricData
s {$sel:startTime:GetContainerServiceMetricData' :: POSIX
startTime = POSIX
a} :: GetContainerServiceMetricData) ((POSIX -> f POSIX)
 -> GetContainerServiceMetricData
 -> f GetContainerServiceMetricData)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetContainerServiceMetricData
-> f GetContainerServiceMetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The end time of the time period.
getContainerServiceMetricData_endTime :: Lens.Lens' GetContainerServiceMetricData Prelude.UTCTime
getContainerServiceMetricData_endTime :: (UTCTime -> f UTCTime)
-> GetContainerServiceMetricData -> f GetContainerServiceMetricData
getContainerServiceMetricData_endTime = (GetContainerServiceMetricData -> POSIX)
-> (GetContainerServiceMetricData
    -> POSIX -> GetContainerServiceMetricData)
-> Lens
     GetContainerServiceMetricData
     GetContainerServiceMetricData
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricData' {POSIX
endTime :: POSIX
$sel:endTime:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> POSIX
endTime} -> POSIX
endTime) (\s :: GetContainerServiceMetricData
s@GetContainerServiceMetricData' {} POSIX
a -> GetContainerServiceMetricData
s {$sel:endTime:GetContainerServiceMetricData' :: POSIX
endTime = POSIX
a} :: GetContainerServiceMetricData) ((POSIX -> f POSIX)
 -> GetContainerServiceMetricData
 -> f GetContainerServiceMetricData)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetContainerServiceMetricData
-> f GetContainerServiceMetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The granularity, in seconds, of the returned data points.
--
-- All container service metric data is available in 5-minute (300 seconds)
-- granularity.
getContainerServiceMetricData_period :: Lens.Lens' GetContainerServiceMetricData Prelude.Natural
getContainerServiceMetricData_period :: (Natural -> f Natural)
-> GetContainerServiceMetricData -> f GetContainerServiceMetricData
getContainerServiceMetricData_period = (GetContainerServiceMetricData -> Natural)
-> (GetContainerServiceMetricData
    -> Natural -> GetContainerServiceMetricData)
-> Lens
     GetContainerServiceMetricData
     GetContainerServiceMetricData
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricData' {Natural
period :: Natural
$sel:period:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> Natural
period} -> Natural
period) (\s :: GetContainerServiceMetricData
s@GetContainerServiceMetricData' {} Natural
a -> GetContainerServiceMetricData
s {$sel:period:GetContainerServiceMetricData' :: Natural
period = Natural
a} :: GetContainerServiceMetricData)

-- | The statistic for the metric.
--
-- The following statistics are available:
--
-- -   @Minimum@ - The lowest value observed during the specified period.
--     Use this value to determine low volumes of activity for your
--     application.
--
-- -   @Maximum@ - The highest value observed during the specified period.
--     Use this value to determine high volumes of activity for your
--     application.
--
-- -   @Sum@ - All values submitted for the matching metric added together.
--     You can use this statistic to determine the total volume of a
--     metric.
--
-- -   @Average@ - The value of @Sum@ \/ @SampleCount@ during the specified
--     period. By comparing this statistic with the @Minimum@ and @Maximum@
--     values, you can determine the full scope of a metric and how close
--     the average use is to the @Minimum@ and @Maximum@ values. This
--     comparison helps you to know when to increase or decrease your
--     resources.
--
-- -   @SampleCount@ - The count, or number, of data points used for the
--     statistical calculation.
getContainerServiceMetricData_statistics :: Lens.Lens' GetContainerServiceMetricData [MetricStatistic]
getContainerServiceMetricData_statistics :: ([MetricStatistic] -> f [MetricStatistic])
-> GetContainerServiceMetricData -> f GetContainerServiceMetricData
getContainerServiceMetricData_statistics = (GetContainerServiceMetricData -> [MetricStatistic])
-> (GetContainerServiceMetricData
    -> [MetricStatistic] -> GetContainerServiceMetricData)
-> Lens
     GetContainerServiceMetricData
     GetContainerServiceMetricData
     [MetricStatistic]
     [MetricStatistic]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricData' {[MetricStatistic]
statistics :: [MetricStatistic]
$sel:statistics:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> [MetricStatistic]
statistics} -> [MetricStatistic]
statistics) (\s :: GetContainerServiceMetricData
s@GetContainerServiceMetricData' {} [MetricStatistic]
a -> GetContainerServiceMetricData
s {$sel:statistics:GetContainerServiceMetricData' :: [MetricStatistic]
statistics = [MetricStatistic]
a} :: GetContainerServiceMetricData) (([MetricStatistic] -> f [MetricStatistic])
 -> GetContainerServiceMetricData
 -> f GetContainerServiceMetricData)
-> (([MetricStatistic] -> f [MetricStatistic])
    -> [MetricStatistic] -> f [MetricStatistic])
-> ([MetricStatistic] -> f [MetricStatistic])
-> GetContainerServiceMetricData
-> f GetContainerServiceMetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MetricStatistic] -> f [MetricStatistic])
-> [MetricStatistic] -> f [MetricStatistic]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.AWSRequest
    GetContainerServiceMetricData
  where
  type
    AWSResponse GetContainerServiceMetricData =
      GetContainerServiceMetricDataResponse
  request :: GetContainerServiceMetricData
-> Request GetContainerServiceMetricData
request = Service
-> GetContainerServiceMetricData
-> Request GetContainerServiceMetricData
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetContainerServiceMetricData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContainerServiceMetricData)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetContainerServiceMetricData))
-> Logger
-> Service
-> Proxy GetContainerServiceMetricData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContainerServiceMetricData)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ContainerServiceMetricName
-> Maybe [MetricDatapoint]
-> Int
-> GetContainerServiceMetricDataResponse
GetContainerServiceMetricDataResponse'
            (Maybe ContainerServiceMetricName
 -> Maybe [MetricDatapoint]
 -> Int
 -> GetContainerServiceMetricDataResponse)
-> Either String (Maybe ContainerServiceMetricName)
-> Either
     String
     (Maybe [MetricDatapoint]
      -> Int -> GetContainerServiceMetricDataResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ContainerServiceMetricName)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"metricName")
            Either
  String
  (Maybe [MetricDatapoint]
   -> Int -> GetContainerServiceMetricDataResponse)
-> Either String (Maybe [MetricDatapoint])
-> Either String (Int -> GetContainerServiceMetricDataResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [MetricDatapoint]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"metricData" Either String (Maybe (Maybe [MetricDatapoint]))
-> Maybe [MetricDatapoint]
-> Either String (Maybe [MetricDatapoint])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [MetricDatapoint]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetContainerServiceMetricDataResponse)
-> Either String Int
-> Either String GetContainerServiceMetricDataResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    GetContainerServiceMetricData

instance Prelude.NFData GetContainerServiceMetricData

instance Core.ToHeaders GetContainerServiceMetricData where
  toHeaders :: GetContainerServiceMetricData -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetContainerServiceMetricData -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.GetContainerServiceMetricData" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetContainerServiceMetricData where
  toJSON :: GetContainerServiceMetricData -> Value
toJSON GetContainerServiceMetricData' {Natural
[MetricStatistic]
Text
POSIX
ContainerServiceMetricName
statistics :: [MetricStatistic]
period :: Natural
endTime :: POSIX
startTime :: POSIX
metricName :: ContainerServiceMetricName
serviceName :: Text
$sel:statistics:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> [MetricStatistic]
$sel:period:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> Natural
$sel:endTime:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> POSIX
$sel:startTime:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> POSIX
$sel:metricName:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> ContainerServiceMetricName
$sel:serviceName:GetContainerServiceMetricData' :: GetContainerServiceMetricData -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"serviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"metricName" Text -> ContainerServiceMetricName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContainerServiceMetricName
metricName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
startTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"endTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
endTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"period" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
period),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"statistics" Text -> [MetricStatistic] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [MetricStatistic]
statistics)
          ]
      )

instance Core.ToPath GetContainerServiceMetricData where
  toPath :: GetContainerServiceMetricData -> ByteString
toPath = ByteString -> GetContainerServiceMetricData -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetContainerServiceMetricData where
  toQuery :: GetContainerServiceMetricData -> QueryString
toQuery = QueryString -> GetContainerServiceMetricData -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetContainerServiceMetricDataResponse' smart constructor.
data GetContainerServiceMetricDataResponse = GetContainerServiceMetricDataResponse'
  { -- | The name of the metric returned.
    GetContainerServiceMetricDataResponse
-> Maybe ContainerServiceMetricName
metricName :: Prelude.Maybe ContainerServiceMetricName,
    -- | An array of objects that describe the metric data returned.
    GetContainerServiceMetricDataResponse -> Maybe [MetricDatapoint]
metricData :: Prelude.Maybe [MetricDatapoint],
    -- | The response's http status code.
    GetContainerServiceMetricDataResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetContainerServiceMetricDataResponse
-> GetContainerServiceMetricDataResponse -> Bool
(GetContainerServiceMetricDataResponse
 -> GetContainerServiceMetricDataResponse -> Bool)
-> (GetContainerServiceMetricDataResponse
    -> GetContainerServiceMetricDataResponse -> Bool)
-> Eq GetContainerServiceMetricDataResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerServiceMetricDataResponse
-> GetContainerServiceMetricDataResponse -> Bool
$c/= :: GetContainerServiceMetricDataResponse
-> GetContainerServiceMetricDataResponse -> Bool
== :: GetContainerServiceMetricDataResponse
-> GetContainerServiceMetricDataResponse -> Bool
$c== :: GetContainerServiceMetricDataResponse
-> GetContainerServiceMetricDataResponse -> Bool
Prelude.Eq, ReadPrec [GetContainerServiceMetricDataResponse]
ReadPrec GetContainerServiceMetricDataResponse
Int -> ReadS GetContainerServiceMetricDataResponse
ReadS [GetContainerServiceMetricDataResponse]
(Int -> ReadS GetContainerServiceMetricDataResponse)
-> ReadS [GetContainerServiceMetricDataResponse]
-> ReadPrec GetContainerServiceMetricDataResponse
-> ReadPrec [GetContainerServiceMetricDataResponse]
-> Read GetContainerServiceMetricDataResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerServiceMetricDataResponse]
$creadListPrec :: ReadPrec [GetContainerServiceMetricDataResponse]
readPrec :: ReadPrec GetContainerServiceMetricDataResponse
$creadPrec :: ReadPrec GetContainerServiceMetricDataResponse
readList :: ReadS [GetContainerServiceMetricDataResponse]
$creadList :: ReadS [GetContainerServiceMetricDataResponse]
readsPrec :: Int -> ReadS GetContainerServiceMetricDataResponse
$creadsPrec :: Int -> ReadS GetContainerServiceMetricDataResponse
Prelude.Read, Int -> GetContainerServiceMetricDataResponse -> ShowS
[GetContainerServiceMetricDataResponse] -> ShowS
GetContainerServiceMetricDataResponse -> String
(Int -> GetContainerServiceMetricDataResponse -> ShowS)
-> (GetContainerServiceMetricDataResponse -> String)
-> ([GetContainerServiceMetricDataResponse] -> ShowS)
-> Show GetContainerServiceMetricDataResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerServiceMetricDataResponse] -> ShowS
$cshowList :: [GetContainerServiceMetricDataResponse] -> ShowS
show :: GetContainerServiceMetricDataResponse -> String
$cshow :: GetContainerServiceMetricDataResponse -> String
showsPrec :: Int -> GetContainerServiceMetricDataResponse -> ShowS
$cshowsPrec :: Int -> GetContainerServiceMetricDataResponse -> ShowS
Prelude.Show, (forall x.
 GetContainerServiceMetricDataResponse
 -> Rep GetContainerServiceMetricDataResponse x)
-> (forall x.
    Rep GetContainerServiceMetricDataResponse x
    -> GetContainerServiceMetricDataResponse)
-> Generic GetContainerServiceMetricDataResponse
forall x.
Rep GetContainerServiceMetricDataResponse x
-> GetContainerServiceMetricDataResponse
forall x.
GetContainerServiceMetricDataResponse
-> Rep GetContainerServiceMetricDataResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContainerServiceMetricDataResponse x
-> GetContainerServiceMetricDataResponse
$cfrom :: forall x.
GetContainerServiceMetricDataResponse
-> Rep GetContainerServiceMetricDataResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerServiceMetricDataResponse' 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:
--
-- 'metricName', 'getContainerServiceMetricDataResponse_metricName' - The name of the metric returned.
--
-- 'metricData', 'getContainerServiceMetricDataResponse_metricData' - An array of objects that describe the metric data returned.
--
-- 'httpStatus', 'getContainerServiceMetricDataResponse_httpStatus' - The response's http status code.
newGetContainerServiceMetricDataResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContainerServiceMetricDataResponse
newGetContainerServiceMetricDataResponse :: Int -> GetContainerServiceMetricDataResponse
newGetContainerServiceMetricDataResponse Int
pHttpStatus_ =
  GetContainerServiceMetricDataResponse' :: Maybe ContainerServiceMetricName
-> Maybe [MetricDatapoint]
-> Int
-> GetContainerServiceMetricDataResponse
GetContainerServiceMetricDataResponse'
    { $sel:metricName:GetContainerServiceMetricDataResponse' :: Maybe ContainerServiceMetricName
metricName =
        Maybe ContainerServiceMetricName
forall a. Maybe a
Prelude.Nothing,
      $sel:metricData:GetContainerServiceMetricDataResponse' :: Maybe [MetricDatapoint]
metricData = Maybe [MetricDatapoint]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContainerServiceMetricDataResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the metric returned.
getContainerServiceMetricDataResponse_metricName :: Lens.Lens' GetContainerServiceMetricDataResponse (Prelude.Maybe ContainerServiceMetricName)
getContainerServiceMetricDataResponse_metricName :: (Maybe ContainerServiceMetricName
 -> f (Maybe ContainerServiceMetricName))
-> GetContainerServiceMetricDataResponse
-> f GetContainerServiceMetricDataResponse
getContainerServiceMetricDataResponse_metricName = (GetContainerServiceMetricDataResponse
 -> Maybe ContainerServiceMetricName)
-> (GetContainerServiceMetricDataResponse
    -> Maybe ContainerServiceMetricName
    -> GetContainerServiceMetricDataResponse)
-> Lens
     GetContainerServiceMetricDataResponse
     GetContainerServiceMetricDataResponse
     (Maybe ContainerServiceMetricName)
     (Maybe ContainerServiceMetricName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricDataResponse' {Maybe ContainerServiceMetricName
metricName :: Maybe ContainerServiceMetricName
$sel:metricName:GetContainerServiceMetricDataResponse' :: GetContainerServiceMetricDataResponse
-> Maybe ContainerServiceMetricName
metricName} -> Maybe ContainerServiceMetricName
metricName) (\s :: GetContainerServiceMetricDataResponse
s@GetContainerServiceMetricDataResponse' {} Maybe ContainerServiceMetricName
a -> GetContainerServiceMetricDataResponse
s {$sel:metricName:GetContainerServiceMetricDataResponse' :: Maybe ContainerServiceMetricName
metricName = Maybe ContainerServiceMetricName
a} :: GetContainerServiceMetricDataResponse)

-- | An array of objects that describe the metric data returned.
getContainerServiceMetricDataResponse_metricData :: Lens.Lens' GetContainerServiceMetricDataResponse (Prelude.Maybe [MetricDatapoint])
getContainerServiceMetricDataResponse_metricData :: (Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
-> GetContainerServiceMetricDataResponse
-> f GetContainerServiceMetricDataResponse
getContainerServiceMetricDataResponse_metricData = (GetContainerServiceMetricDataResponse -> Maybe [MetricDatapoint])
-> (GetContainerServiceMetricDataResponse
    -> Maybe [MetricDatapoint]
    -> GetContainerServiceMetricDataResponse)
-> Lens
     GetContainerServiceMetricDataResponse
     GetContainerServiceMetricDataResponse
     (Maybe [MetricDatapoint])
     (Maybe [MetricDatapoint])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricDataResponse' {Maybe [MetricDatapoint]
metricData :: Maybe [MetricDatapoint]
$sel:metricData:GetContainerServiceMetricDataResponse' :: GetContainerServiceMetricDataResponse -> Maybe [MetricDatapoint]
metricData} -> Maybe [MetricDatapoint]
metricData) (\s :: GetContainerServiceMetricDataResponse
s@GetContainerServiceMetricDataResponse' {} Maybe [MetricDatapoint]
a -> GetContainerServiceMetricDataResponse
s {$sel:metricData:GetContainerServiceMetricDataResponse' :: Maybe [MetricDatapoint]
metricData = Maybe [MetricDatapoint]
a} :: GetContainerServiceMetricDataResponse) ((Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
 -> GetContainerServiceMetricDataResponse
 -> f GetContainerServiceMetricDataResponse)
-> ((Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
    -> Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
-> (Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
-> GetContainerServiceMetricDataResponse
-> f GetContainerServiceMetricDataResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricDatapoint]
  [MetricDatapoint]
  [MetricDatapoint]
  [MetricDatapoint]
-> Iso
     (Maybe [MetricDatapoint])
     (Maybe [MetricDatapoint])
     (Maybe [MetricDatapoint])
     (Maybe [MetricDatapoint])
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
  [MetricDatapoint]
  [MetricDatapoint]
  [MetricDatapoint]
  [MetricDatapoint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
getContainerServiceMetricDataResponse_httpStatus :: Lens.Lens' GetContainerServiceMetricDataResponse Prelude.Int
getContainerServiceMetricDataResponse_httpStatus :: (Int -> f Int)
-> GetContainerServiceMetricDataResponse
-> f GetContainerServiceMetricDataResponse
getContainerServiceMetricDataResponse_httpStatus = (GetContainerServiceMetricDataResponse -> Int)
-> (GetContainerServiceMetricDataResponse
    -> Int -> GetContainerServiceMetricDataResponse)
-> Lens
     GetContainerServiceMetricDataResponse
     GetContainerServiceMetricDataResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerServiceMetricDataResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetContainerServiceMetricDataResponse' :: GetContainerServiceMetricDataResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetContainerServiceMetricDataResponse
s@GetContainerServiceMetricDataResponse' {} Int
a -> GetContainerServiceMetricDataResponse
s {$sel:httpStatus:GetContainerServiceMetricDataResponse' :: Int
httpStatus = Int
a} :: GetContainerServiceMetricDataResponse)

instance
  Prelude.NFData
    GetContainerServiceMetricDataResponse