{-# 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.GetBucketMetricData
-- 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 for an Amazon Lightsail
-- bucket.
--
-- Metrics report the utilization of a bucket. View and collect metric data
-- regularly to monitor the number of objects stored in a bucket (including
-- object versions) and the storage space used by those objects.
module Amazonka.Lightsail.GetBucketMetricData
  ( -- * Creating a Request
    GetBucketMetricData (..),
    newGetBucketMetricData,

    -- * Request Lenses
    getBucketMetricData_bucketName,
    getBucketMetricData_metricName,
    getBucketMetricData_startTime,
    getBucketMetricData_endTime,
    getBucketMetricData_period,
    getBucketMetricData_statistics,
    getBucketMetricData_unit,

    -- * Destructuring the Response
    GetBucketMetricDataResponse (..),
    newGetBucketMetricDataResponse,

    -- * Response Lenses
    getBucketMetricDataResponse_metricName,
    getBucketMetricDataResponse_metricData,
    getBucketMetricDataResponse_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:/ 'newGetBucketMetricData' smart constructor.
data GetBucketMetricData = GetBucketMetricData'
  { -- | The name of the bucket for which to get metric data.
    GetBucketMetricData -> Text
bucketName :: Prelude.Text,
    -- | The metric for which you want to return information.
    --
    -- Valid bucket metric names are listed below, along with the most useful
    -- statistics to include in your request, and the published unit value.
    --
    -- These bucket metrics are reported once per day.
    --
    -- -   __@BucketSizeBytes@__ - The amount of data in bytes stored in a
    --     bucket. This value is calculated by summing the size of all objects
    --     in the bucket (including object versions), including the size of all
    --     parts for all incomplete multipart uploads to the bucket.
    --
    --     Statistics: The most useful statistic is @Maximum@.
    --
    --     Unit: The published unit is @Bytes@.
    --
    -- -   __@NumberOfObjects@__ - The total number of objects stored in a
    --     bucket. This value is calculated by counting all objects in the
    --     bucket (including object versions) and the total number of parts for
    --     all incomplete multipart uploads to the bucket.
    --
    --     Statistics: The most useful statistic is @Average@.
    --
    --     Unit: The published unit is @Count@.
    GetBucketMetricData -> BucketMetricName
metricName :: BucketMetricName,
    -- | The timestamp indicating the earliest data to be returned.
    GetBucketMetricData -> POSIX
startTime :: Core.POSIX,
    -- | The timestamp indicating the latest data to be returned.
    GetBucketMetricData -> POSIX
endTime :: Core.POSIX,
    -- | The granularity, in seconds, of the returned data points.
    --
    -- Bucket storage metrics are reported once per day. Therefore, you should
    -- specify a period of 86400 seconds, which is the number of seconds in a
    -- day.
    GetBucketMetricData -> 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@ - The sum of all values submitted for the matching metric. 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.
    GetBucketMetricData -> [MetricStatistic]
statistics :: [MetricStatistic],
    -- | The unit for the metric data request.
    --
    -- Valid units depend on the metric data being requested. For the valid
    -- units with each available metric, see the @metricName@ parameter.
    GetBucketMetricData -> MetricUnit
unit :: MetricUnit
  }
  deriving (GetBucketMetricData -> GetBucketMetricData -> Bool
(GetBucketMetricData -> GetBucketMetricData -> Bool)
-> (GetBucketMetricData -> GetBucketMetricData -> Bool)
-> Eq GetBucketMetricData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBucketMetricData -> GetBucketMetricData -> Bool
$c/= :: GetBucketMetricData -> GetBucketMetricData -> Bool
== :: GetBucketMetricData -> GetBucketMetricData -> Bool
$c== :: GetBucketMetricData -> GetBucketMetricData -> Bool
Prelude.Eq, ReadPrec [GetBucketMetricData]
ReadPrec GetBucketMetricData
Int -> ReadS GetBucketMetricData
ReadS [GetBucketMetricData]
(Int -> ReadS GetBucketMetricData)
-> ReadS [GetBucketMetricData]
-> ReadPrec GetBucketMetricData
-> ReadPrec [GetBucketMetricData]
-> Read GetBucketMetricData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBucketMetricData]
$creadListPrec :: ReadPrec [GetBucketMetricData]
readPrec :: ReadPrec GetBucketMetricData
$creadPrec :: ReadPrec GetBucketMetricData
readList :: ReadS [GetBucketMetricData]
$creadList :: ReadS [GetBucketMetricData]
readsPrec :: Int -> ReadS GetBucketMetricData
$creadsPrec :: Int -> ReadS GetBucketMetricData
Prelude.Read, Int -> GetBucketMetricData -> ShowS
[GetBucketMetricData] -> ShowS
GetBucketMetricData -> String
(Int -> GetBucketMetricData -> ShowS)
-> (GetBucketMetricData -> String)
-> ([GetBucketMetricData] -> ShowS)
-> Show GetBucketMetricData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBucketMetricData] -> ShowS
$cshowList :: [GetBucketMetricData] -> ShowS
show :: GetBucketMetricData -> String
$cshow :: GetBucketMetricData -> String
showsPrec :: Int -> GetBucketMetricData -> ShowS
$cshowsPrec :: Int -> GetBucketMetricData -> ShowS
Prelude.Show, (forall x. GetBucketMetricData -> Rep GetBucketMetricData x)
-> (forall x. Rep GetBucketMetricData x -> GetBucketMetricData)
-> Generic GetBucketMetricData
forall x. Rep GetBucketMetricData x -> GetBucketMetricData
forall x. GetBucketMetricData -> Rep GetBucketMetricData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBucketMetricData x -> GetBucketMetricData
$cfrom :: forall x. GetBucketMetricData -> Rep GetBucketMetricData x
Prelude.Generic)

-- |
-- Create a value of 'GetBucketMetricData' 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:
--
-- 'bucketName', 'getBucketMetricData_bucketName' - The name of the bucket for which to get metric data.
--
-- 'metricName', 'getBucketMetricData_metricName' - The metric for which you want to return information.
--
-- Valid bucket metric names are listed below, along with the most useful
-- statistics to include in your request, and the published unit value.
--
-- These bucket metrics are reported once per day.
--
-- -   __@BucketSizeBytes@__ - The amount of data in bytes stored in a
--     bucket. This value is calculated by summing the size of all objects
--     in the bucket (including object versions), including the size of all
--     parts for all incomplete multipart uploads to the bucket.
--
--     Statistics: The most useful statistic is @Maximum@.
--
--     Unit: The published unit is @Bytes@.
--
-- -   __@NumberOfObjects@__ - The total number of objects stored in a
--     bucket. This value is calculated by counting all objects in the
--     bucket (including object versions) and the total number of parts for
--     all incomplete multipart uploads to the bucket.
--
--     Statistics: The most useful statistic is @Average@.
--
--     Unit: The published unit is @Count@.
--
-- 'startTime', 'getBucketMetricData_startTime' - The timestamp indicating the earliest data to be returned.
--
-- 'endTime', 'getBucketMetricData_endTime' - The timestamp indicating the latest data to be returned.
--
-- 'period', 'getBucketMetricData_period' - The granularity, in seconds, of the returned data points.
--
-- Bucket storage metrics are reported once per day. Therefore, you should
-- specify a period of 86400 seconds, which is the number of seconds in a
-- day.
--
-- 'statistics', 'getBucketMetricData_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@ - The sum of all values submitted for the matching metric. 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.
--
-- 'unit', 'getBucketMetricData_unit' - The unit for the metric data request.
--
-- Valid units depend on the metric data being requested. For the valid
-- units with each available metric, see the @metricName@ parameter.
newGetBucketMetricData ::
  -- | 'bucketName'
  Prelude.Text ->
  -- | 'metricName'
  BucketMetricName ->
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'period'
  Prelude.Natural ->
  -- | 'unit'
  MetricUnit ->
  GetBucketMetricData
newGetBucketMetricData :: Text
-> BucketMetricName
-> UTCTime
-> UTCTime
-> Natural
-> MetricUnit
-> GetBucketMetricData
newGetBucketMetricData
  Text
pBucketName_
  BucketMetricName
pMetricName_
  UTCTime
pStartTime_
  UTCTime
pEndTime_
  Natural
pPeriod_
  MetricUnit
pUnit_ =
    GetBucketMetricData' :: Text
-> BucketMetricName
-> POSIX
-> POSIX
-> Natural
-> [MetricStatistic]
-> MetricUnit
-> GetBucketMetricData
GetBucketMetricData'
      { $sel:bucketName:GetBucketMetricData' :: Text
bucketName = Text
pBucketName_,
        $sel:metricName:GetBucketMetricData' :: BucketMetricName
metricName = BucketMetricName
pMetricName_,
        $sel:startTime:GetBucketMetricData' :: 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:GetBucketMetricData' :: 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:GetBucketMetricData' :: Natural
period = Natural
pPeriod_,
        $sel:statistics:GetBucketMetricData' :: [MetricStatistic]
statistics = [MetricStatistic]
forall a. Monoid a => a
Prelude.mempty,
        $sel:unit:GetBucketMetricData' :: MetricUnit
unit = MetricUnit
pUnit_
      }

-- | The name of the bucket for which to get metric data.
getBucketMetricData_bucketName :: Lens.Lens' GetBucketMetricData Prelude.Text
getBucketMetricData_bucketName :: (Text -> f Text) -> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_bucketName = (GetBucketMetricData -> Text)
-> (GetBucketMetricData -> Text -> GetBucketMetricData)
-> Lens GetBucketMetricData GetBucketMetricData Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {Text
bucketName :: Text
$sel:bucketName:GetBucketMetricData' :: GetBucketMetricData -> Text
bucketName} -> Text
bucketName) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} Text
a -> GetBucketMetricData
s {$sel:bucketName:GetBucketMetricData' :: Text
bucketName = Text
a} :: GetBucketMetricData)

-- | The metric for which you want to return information.
--
-- Valid bucket metric names are listed below, along with the most useful
-- statistics to include in your request, and the published unit value.
--
-- These bucket metrics are reported once per day.
--
-- -   __@BucketSizeBytes@__ - The amount of data in bytes stored in a
--     bucket. This value is calculated by summing the size of all objects
--     in the bucket (including object versions), including the size of all
--     parts for all incomplete multipart uploads to the bucket.
--
--     Statistics: The most useful statistic is @Maximum@.
--
--     Unit: The published unit is @Bytes@.
--
-- -   __@NumberOfObjects@__ - The total number of objects stored in a
--     bucket. This value is calculated by counting all objects in the
--     bucket (including object versions) and the total number of parts for
--     all incomplete multipart uploads to the bucket.
--
--     Statistics: The most useful statistic is @Average@.
--
--     Unit: The published unit is @Count@.
getBucketMetricData_metricName :: Lens.Lens' GetBucketMetricData BucketMetricName
getBucketMetricData_metricName :: (BucketMetricName -> f BucketMetricName)
-> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_metricName = (GetBucketMetricData -> BucketMetricName)
-> (GetBucketMetricData -> BucketMetricName -> GetBucketMetricData)
-> Lens
     GetBucketMetricData
     GetBucketMetricData
     BucketMetricName
     BucketMetricName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {BucketMetricName
metricName :: BucketMetricName
$sel:metricName:GetBucketMetricData' :: GetBucketMetricData -> BucketMetricName
metricName} -> BucketMetricName
metricName) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} BucketMetricName
a -> GetBucketMetricData
s {$sel:metricName:GetBucketMetricData' :: BucketMetricName
metricName = BucketMetricName
a} :: GetBucketMetricData)

-- | The timestamp indicating the earliest data to be returned.
getBucketMetricData_startTime :: Lens.Lens' GetBucketMetricData Prelude.UTCTime
getBucketMetricData_startTime :: (UTCTime -> f UTCTime)
-> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_startTime = (GetBucketMetricData -> POSIX)
-> (GetBucketMetricData -> POSIX -> GetBucketMetricData)
-> Lens GetBucketMetricData GetBucketMetricData POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {POSIX
startTime :: POSIX
$sel:startTime:GetBucketMetricData' :: GetBucketMetricData -> POSIX
startTime} -> POSIX
startTime) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} POSIX
a -> GetBucketMetricData
s {$sel:startTime:GetBucketMetricData' :: POSIX
startTime = POSIX
a} :: GetBucketMetricData) ((POSIX -> f POSIX)
 -> GetBucketMetricData -> f GetBucketMetricData)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetBucketMetricData
-> f GetBucketMetricData
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 timestamp indicating the latest data to be returned.
getBucketMetricData_endTime :: Lens.Lens' GetBucketMetricData Prelude.UTCTime
getBucketMetricData_endTime :: (UTCTime -> f UTCTime)
-> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_endTime = (GetBucketMetricData -> POSIX)
-> (GetBucketMetricData -> POSIX -> GetBucketMetricData)
-> Lens GetBucketMetricData GetBucketMetricData POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {POSIX
endTime :: POSIX
$sel:endTime:GetBucketMetricData' :: GetBucketMetricData -> POSIX
endTime} -> POSIX
endTime) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} POSIX
a -> GetBucketMetricData
s {$sel:endTime:GetBucketMetricData' :: POSIX
endTime = POSIX
a} :: GetBucketMetricData) ((POSIX -> f POSIX)
 -> GetBucketMetricData -> f GetBucketMetricData)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetBucketMetricData
-> f GetBucketMetricData
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.
--
-- Bucket storage metrics are reported once per day. Therefore, you should
-- specify a period of 86400 seconds, which is the number of seconds in a
-- day.
getBucketMetricData_period :: Lens.Lens' GetBucketMetricData Prelude.Natural
getBucketMetricData_period :: (Natural -> f Natural)
-> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_period = (GetBucketMetricData -> Natural)
-> (GetBucketMetricData -> Natural -> GetBucketMetricData)
-> Lens GetBucketMetricData GetBucketMetricData Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {Natural
period :: Natural
$sel:period:GetBucketMetricData' :: GetBucketMetricData -> Natural
period} -> Natural
period) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} Natural
a -> GetBucketMetricData
s {$sel:period:GetBucketMetricData' :: Natural
period = Natural
a} :: GetBucketMetricData)

-- | 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@ - The sum of all values submitted for the matching metric. 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.
getBucketMetricData_statistics :: Lens.Lens' GetBucketMetricData [MetricStatistic]
getBucketMetricData_statistics :: ([MetricStatistic] -> f [MetricStatistic])
-> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_statistics = (GetBucketMetricData -> [MetricStatistic])
-> (GetBucketMetricData
    -> [MetricStatistic] -> GetBucketMetricData)
-> Lens
     GetBucketMetricData
     GetBucketMetricData
     [MetricStatistic]
     [MetricStatistic]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {[MetricStatistic]
statistics :: [MetricStatistic]
$sel:statistics:GetBucketMetricData' :: GetBucketMetricData -> [MetricStatistic]
statistics} -> [MetricStatistic]
statistics) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} [MetricStatistic]
a -> GetBucketMetricData
s {$sel:statistics:GetBucketMetricData' :: [MetricStatistic]
statistics = [MetricStatistic]
a} :: GetBucketMetricData) (([MetricStatistic] -> f [MetricStatistic])
 -> GetBucketMetricData -> f GetBucketMetricData)
-> (([MetricStatistic] -> f [MetricStatistic])
    -> [MetricStatistic] -> f [MetricStatistic])
-> ([MetricStatistic] -> f [MetricStatistic])
-> GetBucketMetricData
-> f GetBucketMetricData
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

-- | The unit for the metric data request.
--
-- Valid units depend on the metric data being requested. For the valid
-- units with each available metric, see the @metricName@ parameter.
getBucketMetricData_unit :: Lens.Lens' GetBucketMetricData MetricUnit
getBucketMetricData_unit :: (MetricUnit -> f MetricUnit)
-> GetBucketMetricData -> f GetBucketMetricData
getBucketMetricData_unit = (GetBucketMetricData -> MetricUnit)
-> (GetBucketMetricData -> MetricUnit -> GetBucketMetricData)
-> Lens
     GetBucketMetricData GetBucketMetricData MetricUnit MetricUnit
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricData' {MetricUnit
unit :: MetricUnit
$sel:unit:GetBucketMetricData' :: GetBucketMetricData -> MetricUnit
unit} -> MetricUnit
unit) (\s :: GetBucketMetricData
s@GetBucketMetricData' {} MetricUnit
a -> GetBucketMetricData
s {$sel:unit:GetBucketMetricData' :: MetricUnit
unit = MetricUnit
a} :: GetBucketMetricData)

instance Core.AWSRequest GetBucketMetricData where
  type
    AWSResponse GetBucketMetricData =
      GetBucketMetricDataResponse
  request :: GetBucketMetricData -> Request GetBucketMetricData
request = Service -> GetBucketMetricData -> Request GetBucketMetricData
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetBucketMetricData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetBucketMetricData)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetBucketMetricData))
-> Logger
-> Service
-> Proxy GetBucketMetricData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetBucketMetricData)))
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 BucketMetricName
-> Maybe [MetricDatapoint] -> Int -> GetBucketMetricDataResponse
GetBucketMetricDataResponse'
            (Maybe BucketMetricName
 -> Maybe [MetricDatapoint] -> Int -> GetBucketMetricDataResponse)
-> Either String (Maybe BucketMetricName)
-> Either
     String
     (Maybe [MetricDatapoint] -> Int -> GetBucketMetricDataResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe BucketMetricName)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"metricName")
            Either
  String
  (Maybe [MetricDatapoint] -> Int -> GetBucketMetricDataResponse)
-> Either String (Maybe [MetricDatapoint])
-> Either String (Int -> GetBucketMetricDataResponse)
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 -> GetBucketMetricDataResponse)
-> Either String Int -> Either String GetBucketMetricDataResponse
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 GetBucketMetricData

instance Prelude.NFData GetBucketMetricData

instance Core.ToHeaders GetBucketMetricData where
  toHeaders :: GetBucketMetricData -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetBucketMetricData -> 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.GetBucketMetricData" ::
                          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 GetBucketMetricData where
  toJSON :: GetBucketMetricData -> Value
toJSON GetBucketMetricData' {Natural
[MetricStatistic]
Text
POSIX
BucketMetricName
MetricUnit
unit :: MetricUnit
statistics :: [MetricStatistic]
period :: Natural
endTime :: POSIX
startTime :: POSIX
metricName :: BucketMetricName
bucketName :: Text
$sel:unit:GetBucketMetricData' :: GetBucketMetricData -> MetricUnit
$sel:statistics:GetBucketMetricData' :: GetBucketMetricData -> [MetricStatistic]
$sel:period:GetBucketMetricData' :: GetBucketMetricData -> Natural
$sel:endTime:GetBucketMetricData' :: GetBucketMetricData -> POSIX
$sel:startTime:GetBucketMetricData' :: GetBucketMetricData -> POSIX
$sel:metricName:GetBucketMetricData' :: GetBucketMetricData -> BucketMetricName
$sel:bucketName:GetBucketMetricData' :: GetBucketMetricData -> 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
"bucketName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucketName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"metricName" Text -> BucketMetricName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= BucketMetricName
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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"unit" Text -> MetricUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MetricUnit
unit)
          ]
      )

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

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

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

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

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

-- | An array of objects that describe the metric data returned.
getBucketMetricDataResponse_metricData :: Lens.Lens' GetBucketMetricDataResponse (Prelude.Maybe [MetricDatapoint])
getBucketMetricDataResponse_metricData :: (Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
-> GetBucketMetricDataResponse -> f GetBucketMetricDataResponse
getBucketMetricDataResponse_metricData = (GetBucketMetricDataResponse -> Maybe [MetricDatapoint])
-> (GetBucketMetricDataResponse
    -> Maybe [MetricDatapoint] -> GetBucketMetricDataResponse)
-> Lens
     GetBucketMetricDataResponse
     GetBucketMetricDataResponse
     (Maybe [MetricDatapoint])
     (Maybe [MetricDatapoint])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricDataResponse' {Maybe [MetricDatapoint]
metricData :: Maybe [MetricDatapoint]
$sel:metricData:GetBucketMetricDataResponse' :: GetBucketMetricDataResponse -> Maybe [MetricDatapoint]
metricData} -> Maybe [MetricDatapoint]
metricData) (\s :: GetBucketMetricDataResponse
s@GetBucketMetricDataResponse' {} Maybe [MetricDatapoint]
a -> GetBucketMetricDataResponse
s {$sel:metricData:GetBucketMetricDataResponse' :: Maybe [MetricDatapoint]
metricData = Maybe [MetricDatapoint]
a} :: GetBucketMetricDataResponse) ((Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
 -> GetBucketMetricDataResponse -> f GetBucketMetricDataResponse)
-> ((Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
    -> Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
-> (Maybe [MetricDatapoint] -> f (Maybe [MetricDatapoint]))
-> GetBucketMetricDataResponse
-> f GetBucketMetricDataResponse
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.
getBucketMetricDataResponse_httpStatus :: Lens.Lens' GetBucketMetricDataResponse Prelude.Int
getBucketMetricDataResponse_httpStatus :: (Int -> f Int)
-> GetBucketMetricDataResponse -> f GetBucketMetricDataResponse
getBucketMetricDataResponse_httpStatus = (GetBucketMetricDataResponse -> Int)
-> (GetBucketMetricDataResponse
    -> Int -> GetBucketMetricDataResponse)
-> Lens
     GetBucketMetricDataResponse GetBucketMetricDataResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketMetricDataResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetBucketMetricDataResponse' :: GetBucketMetricDataResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetBucketMetricDataResponse
s@GetBucketMetricDataResponse' {} Int
a -> GetBucketMetricDataResponse
s {$sel:httpStatus:GetBucketMetricDataResponse' :: Int
httpStatus = Int
a} :: GetBucketMetricDataResponse)

instance Prelude.NFData GetBucketMetricDataResponse