{-# 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.CostExplorer.GetCostForecast
-- 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)
--
-- Retrieves a forecast for how much Amazon Web Services predicts that you
-- will spend over the forecast time period that you select, based on your
-- past costs.
module Amazonka.CostExplorer.GetCostForecast
  ( -- * Creating a Request
    GetCostForecast (..),
    newGetCostForecast,

    -- * Request Lenses
    getCostForecast_predictionIntervalLevel,
    getCostForecast_filter,
    getCostForecast_timePeriod,
    getCostForecast_metric,
    getCostForecast_granularity,

    -- * Destructuring the Response
    GetCostForecastResponse (..),
    newGetCostForecastResponse,

    -- * Response Lenses
    getCostForecastResponse_forecastResultsByTime,
    getCostForecastResponse_total,
    getCostForecastResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetCostForecast' smart constructor.
data GetCostForecast = GetCostForecast'
  { -- | Cost Explorer always returns the mean forecast as a single point. You
    -- can request a prediction interval around the mean by specifying a
    -- confidence level. The higher the confidence level, the more confident
    -- Cost Explorer is about the actual value falling in the prediction
    -- interval. Higher confidence levels result in wider prediction intervals.
    GetCostForecast -> Maybe Natural
predictionIntervalLevel :: Prelude.Maybe Prelude.Natural,
    -- | The filters that you want to use to filter your forecast. The
    -- @GetCostForecast@ API supports filtering by the following dimensions:
    --
    -- -   @AZ@
    --
    -- -   @INSTANCE_TYPE@
    --
    -- -   @LINKED_ACCOUNT@
    --
    -- -   @LINKED_ACCOUNT_NAME@
    --
    -- -   @OPERATION@
    --
    -- -   @PURCHASE_TYPE@
    --
    -- -   @REGION@
    --
    -- -   @SERVICE@
    --
    -- -   @USAGE_TYPE@
    --
    -- -   @USAGE_TYPE_GROUP@
    --
    -- -   @RECORD_TYPE@
    --
    -- -   @OPERATING_SYSTEM@
    --
    -- -   @TENANCY@
    --
    -- -   @SCOPE@
    --
    -- -   @PLATFORM@
    --
    -- -   @SUBSCRIPTION_ID@
    --
    -- -   @LEGAL_ENTITY_NAME@
    --
    -- -   @DEPLOYMENT_OPTION@
    --
    -- -   @DATABASE_ENGINE@
    --
    -- -   @INSTANCE_TYPE_FAMILY@
    --
    -- -   @BILLING_ENTITY@
    --
    -- -   @RESERVATION_ID@
    --
    -- -   @SAVINGS_PLAN_ARN@
    GetCostForecast -> Maybe Expression
filter' :: Prelude.Maybe Expression,
    -- | The period of time that you want the forecast to cover. The start date
    -- must be equal to or no later than the current date to avoid a validation
    -- error.
    GetCostForecast -> DateInterval
timePeriod :: DateInterval,
    -- | Which metric Cost Explorer uses to create your forecast. For more
    -- information about blended and unblended rates, see
    -- <http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/ Why does the \"blended\" annotation appear on some line items in my bill?>.
    --
    -- Valid values for a @GetCostForecast@ call are the following:
    --
    -- -   AMORTIZED_COST
    --
    -- -   BLENDED_COST
    --
    -- -   NET_AMORTIZED_COST
    --
    -- -   NET_UNBLENDED_COST
    --
    -- -   UNBLENDED_COST
    GetCostForecast -> Metric
metric :: Metric,
    -- | How granular you want the forecast to be. You can get 3 months of
    -- @DAILY@ forecasts or 12 months of @MONTHLY@ forecasts.
    --
    -- The @GetCostForecast@ operation supports only @DAILY@ and @MONTHLY@
    -- granularities.
    GetCostForecast -> Granularity
granularity :: Granularity
  }
  deriving (GetCostForecast -> GetCostForecast -> Bool
(GetCostForecast -> GetCostForecast -> Bool)
-> (GetCostForecast -> GetCostForecast -> Bool)
-> Eq GetCostForecast
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCostForecast -> GetCostForecast -> Bool
$c/= :: GetCostForecast -> GetCostForecast -> Bool
== :: GetCostForecast -> GetCostForecast -> Bool
$c== :: GetCostForecast -> GetCostForecast -> Bool
Prelude.Eq, ReadPrec [GetCostForecast]
ReadPrec GetCostForecast
Int -> ReadS GetCostForecast
ReadS [GetCostForecast]
(Int -> ReadS GetCostForecast)
-> ReadS [GetCostForecast]
-> ReadPrec GetCostForecast
-> ReadPrec [GetCostForecast]
-> Read GetCostForecast
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCostForecast]
$creadListPrec :: ReadPrec [GetCostForecast]
readPrec :: ReadPrec GetCostForecast
$creadPrec :: ReadPrec GetCostForecast
readList :: ReadS [GetCostForecast]
$creadList :: ReadS [GetCostForecast]
readsPrec :: Int -> ReadS GetCostForecast
$creadsPrec :: Int -> ReadS GetCostForecast
Prelude.Read, Int -> GetCostForecast -> ShowS
[GetCostForecast] -> ShowS
GetCostForecast -> String
(Int -> GetCostForecast -> ShowS)
-> (GetCostForecast -> String)
-> ([GetCostForecast] -> ShowS)
-> Show GetCostForecast
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCostForecast] -> ShowS
$cshowList :: [GetCostForecast] -> ShowS
show :: GetCostForecast -> String
$cshow :: GetCostForecast -> String
showsPrec :: Int -> GetCostForecast -> ShowS
$cshowsPrec :: Int -> GetCostForecast -> ShowS
Prelude.Show, (forall x. GetCostForecast -> Rep GetCostForecast x)
-> (forall x. Rep GetCostForecast x -> GetCostForecast)
-> Generic GetCostForecast
forall x. Rep GetCostForecast x -> GetCostForecast
forall x. GetCostForecast -> Rep GetCostForecast x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCostForecast x -> GetCostForecast
$cfrom :: forall x. GetCostForecast -> Rep GetCostForecast x
Prelude.Generic)

-- |
-- Create a value of 'GetCostForecast' 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:
--
-- 'predictionIntervalLevel', 'getCostForecast_predictionIntervalLevel' - Cost Explorer always returns the mean forecast as a single point. You
-- can request a prediction interval around the mean by specifying a
-- confidence level. The higher the confidence level, the more confident
-- Cost Explorer is about the actual value falling in the prediction
-- interval. Higher confidence levels result in wider prediction intervals.
--
-- 'filter'', 'getCostForecast_filter' - The filters that you want to use to filter your forecast. The
-- @GetCostForecast@ API supports filtering by the following dimensions:
--
-- -   @AZ@
--
-- -   @INSTANCE_TYPE@
--
-- -   @LINKED_ACCOUNT@
--
-- -   @LINKED_ACCOUNT_NAME@
--
-- -   @OPERATION@
--
-- -   @PURCHASE_TYPE@
--
-- -   @REGION@
--
-- -   @SERVICE@
--
-- -   @USAGE_TYPE@
--
-- -   @USAGE_TYPE_GROUP@
--
-- -   @RECORD_TYPE@
--
-- -   @OPERATING_SYSTEM@
--
-- -   @TENANCY@
--
-- -   @SCOPE@
--
-- -   @PLATFORM@
--
-- -   @SUBSCRIPTION_ID@
--
-- -   @LEGAL_ENTITY_NAME@
--
-- -   @DEPLOYMENT_OPTION@
--
-- -   @DATABASE_ENGINE@
--
-- -   @INSTANCE_TYPE_FAMILY@
--
-- -   @BILLING_ENTITY@
--
-- -   @RESERVATION_ID@
--
-- -   @SAVINGS_PLAN_ARN@
--
-- 'timePeriod', 'getCostForecast_timePeriod' - The period of time that you want the forecast to cover. The start date
-- must be equal to or no later than the current date to avoid a validation
-- error.
--
-- 'metric', 'getCostForecast_metric' - Which metric Cost Explorer uses to create your forecast. For more
-- information about blended and unblended rates, see
-- <http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/ Why does the \"blended\" annotation appear on some line items in my bill?>.
--
-- Valid values for a @GetCostForecast@ call are the following:
--
-- -   AMORTIZED_COST
--
-- -   BLENDED_COST
--
-- -   NET_AMORTIZED_COST
--
-- -   NET_UNBLENDED_COST
--
-- -   UNBLENDED_COST
--
-- 'granularity', 'getCostForecast_granularity' - How granular you want the forecast to be. You can get 3 months of
-- @DAILY@ forecasts or 12 months of @MONTHLY@ forecasts.
--
-- The @GetCostForecast@ operation supports only @DAILY@ and @MONTHLY@
-- granularities.
newGetCostForecast ::
  -- | 'timePeriod'
  DateInterval ->
  -- | 'metric'
  Metric ->
  -- | 'granularity'
  Granularity ->
  GetCostForecast
newGetCostForecast :: DateInterval -> Metric -> Granularity -> GetCostForecast
newGetCostForecast
  DateInterval
pTimePeriod_
  Metric
pMetric_
  Granularity
pGranularity_ =
    GetCostForecast' :: Maybe Natural
-> Maybe Expression
-> DateInterval
-> Metric
-> Granularity
-> GetCostForecast
GetCostForecast'
      { $sel:predictionIntervalLevel:GetCostForecast' :: Maybe Natural
predictionIntervalLevel =
          Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:filter':GetCostForecast' :: Maybe Expression
filter' = Maybe Expression
forall a. Maybe a
Prelude.Nothing,
        $sel:timePeriod:GetCostForecast' :: DateInterval
timePeriod = DateInterval
pTimePeriod_,
        $sel:metric:GetCostForecast' :: Metric
metric = Metric
pMetric_,
        $sel:granularity:GetCostForecast' :: Granularity
granularity = Granularity
pGranularity_
      }

-- | Cost Explorer always returns the mean forecast as a single point. You
-- can request a prediction interval around the mean by specifying a
-- confidence level. The higher the confidence level, the more confident
-- Cost Explorer is about the actual value falling in the prediction
-- interval. Higher confidence levels result in wider prediction intervals.
getCostForecast_predictionIntervalLevel :: Lens.Lens' GetCostForecast (Prelude.Maybe Prelude.Natural)
getCostForecast_predictionIntervalLevel :: (Maybe Natural -> f (Maybe Natural))
-> GetCostForecast -> f GetCostForecast
getCostForecast_predictionIntervalLevel = (GetCostForecast -> Maybe Natural)
-> (GetCostForecast -> Maybe Natural -> GetCostForecast)
-> Lens
     GetCostForecast GetCostForecast (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecast' {Maybe Natural
predictionIntervalLevel :: Maybe Natural
$sel:predictionIntervalLevel:GetCostForecast' :: GetCostForecast -> Maybe Natural
predictionIntervalLevel} -> Maybe Natural
predictionIntervalLevel) (\s :: GetCostForecast
s@GetCostForecast' {} Maybe Natural
a -> GetCostForecast
s {$sel:predictionIntervalLevel:GetCostForecast' :: Maybe Natural
predictionIntervalLevel = Maybe Natural
a} :: GetCostForecast)

-- | The filters that you want to use to filter your forecast. The
-- @GetCostForecast@ API supports filtering by the following dimensions:
--
-- -   @AZ@
--
-- -   @INSTANCE_TYPE@
--
-- -   @LINKED_ACCOUNT@
--
-- -   @LINKED_ACCOUNT_NAME@
--
-- -   @OPERATION@
--
-- -   @PURCHASE_TYPE@
--
-- -   @REGION@
--
-- -   @SERVICE@
--
-- -   @USAGE_TYPE@
--
-- -   @USAGE_TYPE_GROUP@
--
-- -   @RECORD_TYPE@
--
-- -   @OPERATING_SYSTEM@
--
-- -   @TENANCY@
--
-- -   @SCOPE@
--
-- -   @PLATFORM@
--
-- -   @SUBSCRIPTION_ID@
--
-- -   @LEGAL_ENTITY_NAME@
--
-- -   @DEPLOYMENT_OPTION@
--
-- -   @DATABASE_ENGINE@
--
-- -   @INSTANCE_TYPE_FAMILY@
--
-- -   @BILLING_ENTITY@
--
-- -   @RESERVATION_ID@
--
-- -   @SAVINGS_PLAN_ARN@
getCostForecast_filter :: Lens.Lens' GetCostForecast (Prelude.Maybe Expression)
getCostForecast_filter :: (Maybe Expression -> f (Maybe Expression))
-> GetCostForecast -> f GetCostForecast
getCostForecast_filter = (GetCostForecast -> Maybe Expression)
-> (GetCostForecast -> Maybe Expression -> GetCostForecast)
-> Lens
     GetCostForecast
     GetCostForecast
     (Maybe Expression)
     (Maybe Expression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecast' {Maybe Expression
filter' :: Maybe Expression
$sel:filter':GetCostForecast' :: GetCostForecast -> Maybe Expression
filter'} -> Maybe Expression
filter') (\s :: GetCostForecast
s@GetCostForecast' {} Maybe Expression
a -> GetCostForecast
s {$sel:filter':GetCostForecast' :: Maybe Expression
filter' = Maybe Expression
a} :: GetCostForecast)

-- | The period of time that you want the forecast to cover. The start date
-- must be equal to or no later than the current date to avoid a validation
-- error.
getCostForecast_timePeriod :: Lens.Lens' GetCostForecast DateInterval
getCostForecast_timePeriod :: (DateInterval -> f DateInterval)
-> GetCostForecast -> f GetCostForecast
getCostForecast_timePeriod = (GetCostForecast -> DateInterval)
-> (GetCostForecast -> DateInterval -> GetCostForecast)
-> Lens GetCostForecast GetCostForecast DateInterval DateInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecast' {DateInterval
timePeriod :: DateInterval
$sel:timePeriod:GetCostForecast' :: GetCostForecast -> DateInterval
timePeriod} -> DateInterval
timePeriod) (\s :: GetCostForecast
s@GetCostForecast' {} DateInterval
a -> GetCostForecast
s {$sel:timePeriod:GetCostForecast' :: DateInterval
timePeriod = DateInterval
a} :: GetCostForecast)

-- | Which metric Cost Explorer uses to create your forecast. For more
-- information about blended and unblended rates, see
-- <http://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/ Why does the \"blended\" annotation appear on some line items in my bill?>.
--
-- Valid values for a @GetCostForecast@ call are the following:
--
-- -   AMORTIZED_COST
--
-- -   BLENDED_COST
--
-- -   NET_AMORTIZED_COST
--
-- -   NET_UNBLENDED_COST
--
-- -   UNBLENDED_COST
getCostForecast_metric :: Lens.Lens' GetCostForecast Metric
getCostForecast_metric :: (Metric -> f Metric) -> GetCostForecast -> f GetCostForecast
getCostForecast_metric = (GetCostForecast -> Metric)
-> (GetCostForecast -> Metric -> GetCostForecast)
-> Lens GetCostForecast GetCostForecast Metric Metric
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecast' {Metric
metric :: Metric
$sel:metric:GetCostForecast' :: GetCostForecast -> Metric
metric} -> Metric
metric) (\s :: GetCostForecast
s@GetCostForecast' {} Metric
a -> GetCostForecast
s {$sel:metric:GetCostForecast' :: Metric
metric = Metric
a} :: GetCostForecast)

-- | How granular you want the forecast to be. You can get 3 months of
-- @DAILY@ forecasts or 12 months of @MONTHLY@ forecasts.
--
-- The @GetCostForecast@ operation supports only @DAILY@ and @MONTHLY@
-- granularities.
getCostForecast_granularity :: Lens.Lens' GetCostForecast Granularity
getCostForecast_granularity :: (Granularity -> f Granularity)
-> GetCostForecast -> f GetCostForecast
getCostForecast_granularity = (GetCostForecast -> Granularity)
-> (GetCostForecast -> Granularity -> GetCostForecast)
-> Lens GetCostForecast GetCostForecast Granularity Granularity
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecast' {Granularity
granularity :: Granularity
$sel:granularity:GetCostForecast' :: GetCostForecast -> Granularity
granularity} -> Granularity
granularity) (\s :: GetCostForecast
s@GetCostForecast' {} Granularity
a -> GetCostForecast
s {$sel:granularity:GetCostForecast' :: Granularity
granularity = Granularity
a} :: GetCostForecast)

instance Core.AWSRequest GetCostForecast where
  type
    AWSResponse GetCostForecast =
      GetCostForecastResponse
  request :: GetCostForecast -> Request GetCostForecast
request = Service -> GetCostForecast -> Request GetCostForecast
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetCostForecast
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCostForecast)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetCostForecast))
-> Logger
-> Service
-> Proxy GetCostForecast
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCostForecast)))
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 [ForecastResult]
-> Maybe MetricValue -> Int -> GetCostForecastResponse
GetCostForecastResponse'
            (Maybe [ForecastResult]
 -> Maybe MetricValue -> Int -> GetCostForecastResponse)
-> Either String (Maybe [ForecastResult])
-> Either
     String (Maybe MetricValue -> Int -> GetCostForecastResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Key -> Either String (Maybe (Maybe [ForecastResult]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"ForecastResultsByTime"
                            Either String (Maybe (Maybe [ForecastResult]))
-> Maybe [ForecastResult] -> Either String (Maybe [ForecastResult])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ForecastResult]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe MetricValue -> Int -> GetCostForecastResponse)
-> Either String (Maybe MetricValue)
-> Either String (Int -> GetCostForecastResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Key -> Either String (Maybe MetricValue)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Total")
            Either String (Int -> GetCostForecastResponse)
-> Either String Int -> Either String GetCostForecastResponse
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 GetCostForecast

instance Prelude.NFData GetCostForecast

instance Core.ToHeaders GetCostForecast where
  toHeaders :: GetCostForecast -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetCostForecast -> 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
"AWSInsightsIndexService.GetCostForecast" ::
                          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 GetCostForecast where
  toJSON :: GetCostForecast -> Value
toJSON GetCostForecast' {Maybe Natural
Maybe Expression
DateInterval
Granularity
Metric
granularity :: Granularity
metric :: Metric
timePeriod :: DateInterval
filter' :: Maybe Expression
predictionIntervalLevel :: Maybe Natural
$sel:granularity:GetCostForecast' :: GetCostForecast -> Granularity
$sel:metric:GetCostForecast' :: GetCostForecast -> Metric
$sel:timePeriod:GetCostForecast' :: GetCostForecast -> DateInterval
$sel:filter':GetCostForecast' :: GetCostForecast -> Maybe Expression
$sel:predictionIntervalLevel:GetCostForecast' :: GetCostForecast -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"PredictionIntervalLevel" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
predictionIntervalLevel,
            (Key
"Filter" Key -> Expression -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) (Expression -> Pair) -> Maybe Expression -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Expression
filter',
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"TimePeriod" Key -> DateInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= DateInterval
timePeriod),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"Metric" Key -> Metric -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= Metric
metric),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"Granularity" Key -> Granularity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= Granularity
granularity)
          ]
      )

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

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

-- | /See:/ 'newGetCostForecastResponse' smart constructor.
data GetCostForecastResponse = GetCostForecastResponse'
  { -- | The forecasts for your query, in order. For @DAILY@ forecasts, this is a
    -- list of days. For @MONTHLY@ forecasts, this is a list of months.
    GetCostForecastResponse -> Maybe [ForecastResult]
forecastResultsByTime :: Prelude.Maybe [ForecastResult],
    -- | How much you are forecasted to spend over the forecast period, in @USD@.
    GetCostForecastResponse -> Maybe MetricValue
total :: Prelude.Maybe MetricValue,
    -- | The response's http status code.
    GetCostForecastResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetCostForecastResponse -> GetCostForecastResponse -> Bool
(GetCostForecastResponse -> GetCostForecastResponse -> Bool)
-> (GetCostForecastResponse -> GetCostForecastResponse -> Bool)
-> Eq GetCostForecastResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCostForecastResponse -> GetCostForecastResponse -> Bool
$c/= :: GetCostForecastResponse -> GetCostForecastResponse -> Bool
== :: GetCostForecastResponse -> GetCostForecastResponse -> Bool
$c== :: GetCostForecastResponse -> GetCostForecastResponse -> Bool
Prelude.Eq, ReadPrec [GetCostForecastResponse]
ReadPrec GetCostForecastResponse
Int -> ReadS GetCostForecastResponse
ReadS [GetCostForecastResponse]
(Int -> ReadS GetCostForecastResponse)
-> ReadS [GetCostForecastResponse]
-> ReadPrec GetCostForecastResponse
-> ReadPrec [GetCostForecastResponse]
-> Read GetCostForecastResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCostForecastResponse]
$creadListPrec :: ReadPrec [GetCostForecastResponse]
readPrec :: ReadPrec GetCostForecastResponse
$creadPrec :: ReadPrec GetCostForecastResponse
readList :: ReadS [GetCostForecastResponse]
$creadList :: ReadS [GetCostForecastResponse]
readsPrec :: Int -> ReadS GetCostForecastResponse
$creadsPrec :: Int -> ReadS GetCostForecastResponse
Prelude.Read, Int -> GetCostForecastResponse -> ShowS
[GetCostForecastResponse] -> ShowS
GetCostForecastResponse -> String
(Int -> GetCostForecastResponse -> ShowS)
-> (GetCostForecastResponse -> String)
-> ([GetCostForecastResponse] -> ShowS)
-> Show GetCostForecastResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCostForecastResponse] -> ShowS
$cshowList :: [GetCostForecastResponse] -> ShowS
show :: GetCostForecastResponse -> String
$cshow :: GetCostForecastResponse -> String
showsPrec :: Int -> GetCostForecastResponse -> ShowS
$cshowsPrec :: Int -> GetCostForecastResponse -> ShowS
Prelude.Show, (forall x.
 GetCostForecastResponse -> Rep GetCostForecastResponse x)
-> (forall x.
    Rep GetCostForecastResponse x -> GetCostForecastResponse)
-> Generic GetCostForecastResponse
forall x. Rep GetCostForecastResponse x -> GetCostForecastResponse
forall x. GetCostForecastResponse -> Rep GetCostForecastResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCostForecastResponse x -> GetCostForecastResponse
$cfrom :: forall x. GetCostForecastResponse -> Rep GetCostForecastResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCostForecastResponse' 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:
--
-- 'forecastResultsByTime', 'getCostForecastResponse_forecastResultsByTime' - The forecasts for your query, in order. For @DAILY@ forecasts, this is a
-- list of days. For @MONTHLY@ forecasts, this is a list of months.
--
-- 'total', 'getCostForecastResponse_total' - How much you are forecasted to spend over the forecast period, in @USD@.
--
-- 'httpStatus', 'getCostForecastResponse_httpStatus' - The response's http status code.
newGetCostForecastResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCostForecastResponse
newGetCostForecastResponse :: Int -> GetCostForecastResponse
newGetCostForecastResponse Int
pHttpStatus_ =
  GetCostForecastResponse' :: Maybe [ForecastResult]
-> Maybe MetricValue -> Int -> GetCostForecastResponse
GetCostForecastResponse'
    { $sel:forecastResultsByTime:GetCostForecastResponse' :: Maybe [ForecastResult]
forecastResultsByTime =
        Maybe [ForecastResult]
forall a. Maybe a
Prelude.Nothing,
      $sel:total:GetCostForecastResponse' :: Maybe MetricValue
total = Maybe MetricValue
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCostForecastResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The forecasts for your query, in order. For @DAILY@ forecasts, this is a
-- list of days. For @MONTHLY@ forecasts, this is a list of months.
getCostForecastResponse_forecastResultsByTime :: Lens.Lens' GetCostForecastResponse (Prelude.Maybe [ForecastResult])
getCostForecastResponse_forecastResultsByTime :: (Maybe [ForecastResult] -> f (Maybe [ForecastResult]))
-> GetCostForecastResponse -> f GetCostForecastResponse
getCostForecastResponse_forecastResultsByTime = (GetCostForecastResponse -> Maybe [ForecastResult])
-> (GetCostForecastResponse
    -> Maybe [ForecastResult] -> GetCostForecastResponse)
-> Lens
     GetCostForecastResponse
     GetCostForecastResponse
     (Maybe [ForecastResult])
     (Maybe [ForecastResult])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecastResponse' {Maybe [ForecastResult]
forecastResultsByTime :: Maybe [ForecastResult]
$sel:forecastResultsByTime:GetCostForecastResponse' :: GetCostForecastResponse -> Maybe [ForecastResult]
forecastResultsByTime} -> Maybe [ForecastResult]
forecastResultsByTime) (\s :: GetCostForecastResponse
s@GetCostForecastResponse' {} Maybe [ForecastResult]
a -> GetCostForecastResponse
s {$sel:forecastResultsByTime:GetCostForecastResponse' :: Maybe [ForecastResult]
forecastResultsByTime = Maybe [ForecastResult]
a} :: GetCostForecastResponse) ((Maybe [ForecastResult] -> f (Maybe [ForecastResult]))
 -> GetCostForecastResponse -> f GetCostForecastResponse)
-> ((Maybe [ForecastResult] -> f (Maybe [ForecastResult]))
    -> Maybe [ForecastResult] -> f (Maybe [ForecastResult]))
-> (Maybe [ForecastResult] -> f (Maybe [ForecastResult]))
-> GetCostForecastResponse
-> f GetCostForecastResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ForecastResult] [ForecastResult] [ForecastResult] [ForecastResult]
-> Iso
     (Maybe [ForecastResult])
     (Maybe [ForecastResult])
     (Maybe [ForecastResult])
     (Maybe [ForecastResult])
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
  [ForecastResult] [ForecastResult] [ForecastResult] [ForecastResult]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | How much you are forecasted to spend over the forecast period, in @USD@.
getCostForecastResponse_total :: Lens.Lens' GetCostForecastResponse (Prelude.Maybe MetricValue)
getCostForecastResponse_total :: (Maybe MetricValue -> f (Maybe MetricValue))
-> GetCostForecastResponse -> f GetCostForecastResponse
getCostForecastResponse_total = (GetCostForecastResponse -> Maybe MetricValue)
-> (GetCostForecastResponse
    -> Maybe MetricValue -> GetCostForecastResponse)
-> Lens
     GetCostForecastResponse
     GetCostForecastResponse
     (Maybe MetricValue)
     (Maybe MetricValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostForecastResponse' {Maybe MetricValue
total :: Maybe MetricValue
$sel:total:GetCostForecastResponse' :: GetCostForecastResponse -> Maybe MetricValue
total} -> Maybe MetricValue
total) (\s :: GetCostForecastResponse
s@GetCostForecastResponse' {} Maybe MetricValue
a -> GetCostForecastResponse
s {$sel:total:GetCostForecastResponse' :: Maybe MetricValue
total = Maybe MetricValue
a} :: GetCostForecastResponse)

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

instance Prelude.NFData GetCostForecastResponse