{-# 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.GetSavingsPlansUtilization
-- 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 the Savings Plans utilization for your account across date
-- ranges with daily or monthly granularity. Management account in an
-- organization have access to member accounts. You can use
-- @GetDimensionValues@ in @SAVINGS_PLANS@ to determine the possible
-- dimension values.
--
-- You cannot group by any dimension values for
-- @GetSavingsPlansUtilization@.
module Amazonka.CostExplorer.GetSavingsPlansUtilization
  ( -- * Creating a Request
    GetSavingsPlansUtilization (..),
    newGetSavingsPlansUtilization,

    -- * Request Lenses
    getSavingsPlansUtilization_granularity,
    getSavingsPlansUtilization_filter,
    getSavingsPlansUtilization_sortBy,
    getSavingsPlansUtilization_timePeriod,

    -- * Destructuring the Response
    GetSavingsPlansUtilizationResponse (..),
    newGetSavingsPlansUtilizationResponse,

    -- * Response Lenses
    getSavingsPlansUtilizationResponse_savingsPlansUtilizationsByTime,
    getSavingsPlansUtilizationResponse_httpStatus,
    getSavingsPlansUtilizationResponse_total,
  )
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:/ 'newGetSavingsPlansUtilization' smart constructor.
data GetSavingsPlansUtilization = GetSavingsPlansUtilization'
  { -- | The granularity of the Amazon Web Services utillization data for your
    -- Savings Plans.
    --
    -- The @GetSavingsPlansUtilization@ operation supports only @DAILY@ and
    -- @MONTHLY@ granularities.
    GetSavingsPlansUtilization -> Maybe Granularity
granularity :: Prelude.Maybe Granularity,
    -- | Filters Savings Plans utilization coverage data for active Savings Plans
    -- dimensions. You can filter data with the following dimensions:
    --
    -- -   @LINKED_ACCOUNT@
    --
    -- -   @SAVINGS_PLAN_ARN@
    --
    -- -   @SAVINGS_PLANS_TYPE@
    --
    -- -   @REGION@
    --
    -- -   @PAYMENT_OPTION@
    --
    -- -   @INSTANCE_TYPE_FAMILY@
    --
    -- @GetSavingsPlansUtilization@ uses the same
    -- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html Expression>
    -- object as the other operations, but only @AND@ is supported among each
    -- dimension.
    GetSavingsPlansUtilization -> Maybe Expression
filter' :: Prelude.Maybe Expression,
    -- | The value by which you want to sort the data.
    --
    -- The following values are supported for @Key@:
    --
    -- -   @UtilizationPercentage@
    --
    -- -   @TotalCommitment@
    --
    -- -   @UsedCommitment@
    --
    -- -   @UnusedCommitment@
    --
    -- -   @NetSavings@
    --
    -- Supported values for @SortOrder@ are @ASCENDING@ or @DESCENDING@.
    GetSavingsPlansUtilization -> Maybe SortDefinition
sortBy :: Prelude.Maybe SortDefinition,
    -- | The time period that you want the usage and costs for. The @Start@ date
    -- must be within 13 months. The @End@ date must be after the @Start@ date,
    -- and before the current date. Future dates can\'t be used as an @End@
    -- date.
    GetSavingsPlansUtilization -> DateInterval
timePeriod :: DateInterval
  }
  deriving (GetSavingsPlansUtilization -> GetSavingsPlansUtilization -> Bool
(GetSavingsPlansUtilization -> GetSavingsPlansUtilization -> Bool)
-> (GetSavingsPlansUtilization
    -> GetSavingsPlansUtilization -> Bool)
-> Eq GetSavingsPlansUtilization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSavingsPlansUtilization -> GetSavingsPlansUtilization -> Bool
$c/= :: GetSavingsPlansUtilization -> GetSavingsPlansUtilization -> Bool
== :: GetSavingsPlansUtilization -> GetSavingsPlansUtilization -> Bool
$c== :: GetSavingsPlansUtilization -> GetSavingsPlansUtilization -> Bool
Prelude.Eq, ReadPrec [GetSavingsPlansUtilization]
ReadPrec GetSavingsPlansUtilization
Int -> ReadS GetSavingsPlansUtilization
ReadS [GetSavingsPlansUtilization]
(Int -> ReadS GetSavingsPlansUtilization)
-> ReadS [GetSavingsPlansUtilization]
-> ReadPrec GetSavingsPlansUtilization
-> ReadPrec [GetSavingsPlansUtilization]
-> Read GetSavingsPlansUtilization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSavingsPlansUtilization]
$creadListPrec :: ReadPrec [GetSavingsPlansUtilization]
readPrec :: ReadPrec GetSavingsPlansUtilization
$creadPrec :: ReadPrec GetSavingsPlansUtilization
readList :: ReadS [GetSavingsPlansUtilization]
$creadList :: ReadS [GetSavingsPlansUtilization]
readsPrec :: Int -> ReadS GetSavingsPlansUtilization
$creadsPrec :: Int -> ReadS GetSavingsPlansUtilization
Prelude.Read, Int -> GetSavingsPlansUtilization -> ShowS
[GetSavingsPlansUtilization] -> ShowS
GetSavingsPlansUtilization -> String
(Int -> GetSavingsPlansUtilization -> ShowS)
-> (GetSavingsPlansUtilization -> String)
-> ([GetSavingsPlansUtilization] -> ShowS)
-> Show GetSavingsPlansUtilization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSavingsPlansUtilization] -> ShowS
$cshowList :: [GetSavingsPlansUtilization] -> ShowS
show :: GetSavingsPlansUtilization -> String
$cshow :: GetSavingsPlansUtilization -> String
showsPrec :: Int -> GetSavingsPlansUtilization -> ShowS
$cshowsPrec :: Int -> GetSavingsPlansUtilization -> ShowS
Prelude.Show, (forall x.
 GetSavingsPlansUtilization -> Rep GetSavingsPlansUtilization x)
-> (forall x.
    Rep GetSavingsPlansUtilization x -> GetSavingsPlansUtilization)
-> Generic GetSavingsPlansUtilization
forall x.
Rep GetSavingsPlansUtilization x -> GetSavingsPlansUtilization
forall x.
GetSavingsPlansUtilization -> Rep GetSavingsPlansUtilization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSavingsPlansUtilization x -> GetSavingsPlansUtilization
$cfrom :: forall x.
GetSavingsPlansUtilization -> Rep GetSavingsPlansUtilization x
Prelude.Generic)

-- |
-- Create a value of 'GetSavingsPlansUtilization' 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:
--
-- 'granularity', 'getSavingsPlansUtilization_granularity' - The granularity of the Amazon Web Services utillization data for your
-- Savings Plans.
--
-- The @GetSavingsPlansUtilization@ operation supports only @DAILY@ and
-- @MONTHLY@ granularities.
--
-- 'filter'', 'getSavingsPlansUtilization_filter' - Filters Savings Plans utilization coverage data for active Savings Plans
-- dimensions. You can filter data with the following dimensions:
--
-- -   @LINKED_ACCOUNT@
--
-- -   @SAVINGS_PLAN_ARN@
--
-- -   @SAVINGS_PLANS_TYPE@
--
-- -   @REGION@
--
-- -   @PAYMENT_OPTION@
--
-- -   @INSTANCE_TYPE_FAMILY@
--
-- @GetSavingsPlansUtilization@ uses the same
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html Expression>
-- object as the other operations, but only @AND@ is supported among each
-- dimension.
--
-- 'sortBy', 'getSavingsPlansUtilization_sortBy' - The value by which you want to sort the data.
--
-- The following values are supported for @Key@:
--
-- -   @UtilizationPercentage@
--
-- -   @TotalCommitment@
--
-- -   @UsedCommitment@
--
-- -   @UnusedCommitment@
--
-- -   @NetSavings@
--
-- Supported values for @SortOrder@ are @ASCENDING@ or @DESCENDING@.
--
-- 'timePeriod', 'getSavingsPlansUtilization_timePeriod' - The time period that you want the usage and costs for. The @Start@ date
-- must be within 13 months. The @End@ date must be after the @Start@ date,
-- and before the current date. Future dates can\'t be used as an @End@
-- date.
newGetSavingsPlansUtilization ::
  -- | 'timePeriod'
  DateInterval ->
  GetSavingsPlansUtilization
newGetSavingsPlansUtilization :: DateInterval -> GetSavingsPlansUtilization
newGetSavingsPlansUtilization DateInterval
pTimePeriod_ =
  GetSavingsPlansUtilization' :: Maybe Granularity
-> Maybe Expression
-> Maybe SortDefinition
-> DateInterval
-> GetSavingsPlansUtilization
GetSavingsPlansUtilization'
    { $sel:granularity:GetSavingsPlansUtilization' :: Maybe Granularity
granularity =
        Maybe Granularity
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':GetSavingsPlansUtilization' :: Maybe Expression
filter' = Maybe Expression
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:GetSavingsPlansUtilization' :: Maybe SortDefinition
sortBy = Maybe SortDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:timePeriod:GetSavingsPlansUtilization' :: DateInterval
timePeriod = DateInterval
pTimePeriod_
    }

-- | The granularity of the Amazon Web Services utillization data for your
-- Savings Plans.
--
-- The @GetSavingsPlansUtilization@ operation supports only @DAILY@ and
-- @MONTHLY@ granularities.
getSavingsPlansUtilization_granularity :: Lens.Lens' GetSavingsPlansUtilization (Prelude.Maybe Granularity)
getSavingsPlansUtilization_granularity :: (Maybe Granularity -> f (Maybe Granularity))
-> GetSavingsPlansUtilization -> f GetSavingsPlansUtilization
getSavingsPlansUtilization_granularity = (GetSavingsPlansUtilization -> Maybe Granularity)
-> (GetSavingsPlansUtilization
    -> Maybe Granularity -> GetSavingsPlansUtilization)
-> Lens
     GetSavingsPlansUtilization
     GetSavingsPlansUtilization
     (Maybe Granularity)
     (Maybe Granularity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSavingsPlansUtilization' {Maybe Granularity
granularity :: Maybe Granularity
$sel:granularity:GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> Maybe Granularity
granularity} -> Maybe Granularity
granularity) (\s :: GetSavingsPlansUtilization
s@GetSavingsPlansUtilization' {} Maybe Granularity
a -> GetSavingsPlansUtilization
s {$sel:granularity:GetSavingsPlansUtilization' :: Maybe Granularity
granularity = Maybe Granularity
a} :: GetSavingsPlansUtilization)

-- | Filters Savings Plans utilization coverage data for active Savings Plans
-- dimensions. You can filter data with the following dimensions:
--
-- -   @LINKED_ACCOUNT@
--
-- -   @SAVINGS_PLAN_ARN@
--
-- -   @SAVINGS_PLANS_TYPE@
--
-- -   @REGION@
--
-- -   @PAYMENT_OPTION@
--
-- -   @INSTANCE_TYPE_FAMILY@
--
-- @GetSavingsPlansUtilization@ uses the same
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html Expression>
-- object as the other operations, but only @AND@ is supported among each
-- dimension.
getSavingsPlansUtilization_filter :: Lens.Lens' GetSavingsPlansUtilization (Prelude.Maybe Expression)
getSavingsPlansUtilization_filter :: (Maybe Expression -> f (Maybe Expression))
-> GetSavingsPlansUtilization -> f GetSavingsPlansUtilization
getSavingsPlansUtilization_filter = (GetSavingsPlansUtilization -> Maybe Expression)
-> (GetSavingsPlansUtilization
    -> Maybe Expression -> GetSavingsPlansUtilization)
-> Lens
     GetSavingsPlansUtilization
     GetSavingsPlansUtilization
     (Maybe Expression)
     (Maybe Expression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSavingsPlansUtilization' {Maybe Expression
filter' :: Maybe Expression
$sel:filter':GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> Maybe Expression
filter'} -> Maybe Expression
filter') (\s :: GetSavingsPlansUtilization
s@GetSavingsPlansUtilization' {} Maybe Expression
a -> GetSavingsPlansUtilization
s {$sel:filter':GetSavingsPlansUtilization' :: Maybe Expression
filter' = Maybe Expression
a} :: GetSavingsPlansUtilization)

-- | The value by which you want to sort the data.
--
-- The following values are supported for @Key@:
--
-- -   @UtilizationPercentage@
--
-- -   @TotalCommitment@
--
-- -   @UsedCommitment@
--
-- -   @UnusedCommitment@
--
-- -   @NetSavings@
--
-- Supported values for @SortOrder@ are @ASCENDING@ or @DESCENDING@.
getSavingsPlansUtilization_sortBy :: Lens.Lens' GetSavingsPlansUtilization (Prelude.Maybe SortDefinition)
getSavingsPlansUtilization_sortBy :: (Maybe SortDefinition -> f (Maybe SortDefinition))
-> GetSavingsPlansUtilization -> f GetSavingsPlansUtilization
getSavingsPlansUtilization_sortBy = (GetSavingsPlansUtilization -> Maybe SortDefinition)
-> (GetSavingsPlansUtilization
    -> Maybe SortDefinition -> GetSavingsPlansUtilization)
-> Lens
     GetSavingsPlansUtilization
     GetSavingsPlansUtilization
     (Maybe SortDefinition)
     (Maybe SortDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSavingsPlansUtilization' {Maybe SortDefinition
sortBy :: Maybe SortDefinition
$sel:sortBy:GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> Maybe SortDefinition
sortBy} -> Maybe SortDefinition
sortBy) (\s :: GetSavingsPlansUtilization
s@GetSavingsPlansUtilization' {} Maybe SortDefinition
a -> GetSavingsPlansUtilization
s {$sel:sortBy:GetSavingsPlansUtilization' :: Maybe SortDefinition
sortBy = Maybe SortDefinition
a} :: GetSavingsPlansUtilization)

-- | The time period that you want the usage and costs for. The @Start@ date
-- must be within 13 months. The @End@ date must be after the @Start@ date,
-- and before the current date. Future dates can\'t be used as an @End@
-- date.
getSavingsPlansUtilization_timePeriod :: Lens.Lens' GetSavingsPlansUtilization DateInterval
getSavingsPlansUtilization_timePeriod :: (DateInterval -> f DateInterval)
-> GetSavingsPlansUtilization -> f GetSavingsPlansUtilization
getSavingsPlansUtilization_timePeriod = (GetSavingsPlansUtilization -> DateInterval)
-> (GetSavingsPlansUtilization
    -> DateInterval -> GetSavingsPlansUtilization)
-> Lens
     GetSavingsPlansUtilization
     GetSavingsPlansUtilization
     DateInterval
     DateInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSavingsPlansUtilization' {DateInterval
timePeriod :: DateInterval
$sel:timePeriod:GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> DateInterval
timePeriod} -> DateInterval
timePeriod) (\s :: GetSavingsPlansUtilization
s@GetSavingsPlansUtilization' {} DateInterval
a -> GetSavingsPlansUtilization
s {$sel:timePeriod:GetSavingsPlansUtilization' :: DateInterval
timePeriod = DateInterval
a} :: GetSavingsPlansUtilization)

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

instance Prelude.Hashable GetSavingsPlansUtilization

instance Prelude.NFData GetSavingsPlansUtilization

instance Core.ToHeaders GetSavingsPlansUtilization where
  toHeaders :: GetSavingsPlansUtilization -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSavingsPlansUtilization -> 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.GetSavingsPlansUtilization" ::
                          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 GetSavingsPlansUtilization where
  toJSON :: GetSavingsPlansUtilization -> Value
toJSON GetSavingsPlansUtilization' {Maybe Granularity
Maybe SortDefinition
Maybe Expression
DateInterval
timePeriod :: DateInterval
sortBy :: Maybe SortDefinition
filter' :: Maybe Expression
granularity :: Maybe Granularity
$sel:timePeriod:GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> DateInterval
$sel:sortBy:GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> Maybe SortDefinition
$sel:filter':GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> Maybe Expression
$sel:granularity:GetSavingsPlansUtilization' :: GetSavingsPlansUtilization -> Maybe Granularity
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Granularity" Key -> Granularity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) (Granularity -> Pair) -> Maybe Granularity -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Granularity
granularity,
            (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',
            (Key
"SortBy" Key -> SortDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) (SortDefinition -> Pair) -> Maybe SortDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortDefinition
sortBy,
            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)
          ]
      )

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

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

-- | /See:/ 'newGetSavingsPlansUtilizationResponse' smart constructor.
data GetSavingsPlansUtilizationResponse = GetSavingsPlansUtilizationResponse'
  { -- | The amount of cost\/commitment you used your Savings Plans. This allows
    -- you to specify date ranges.
    GetSavingsPlansUtilizationResponse
-> Maybe [SavingsPlansUtilizationByTime]
savingsPlansUtilizationsByTime :: Prelude.Maybe [SavingsPlansUtilizationByTime],
    -- | The response's http status code.
    GetSavingsPlansUtilizationResponse -> Int
httpStatus :: Prelude.Int,
    -- | The total amount of cost\/commitment that you used your Savings Plans,
    -- regardless of date ranges.
    GetSavingsPlansUtilizationResponse
-> SavingsPlansUtilizationAggregates
total :: SavingsPlansUtilizationAggregates
  }
  deriving (GetSavingsPlansUtilizationResponse
-> GetSavingsPlansUtilizationResponse -> Bool
(GetSavingsPlansUtilizationResponse
 -> GetSavingsPlansUtilizationResponse -> Bool)
-> (GetSavingsPlansUtilizationResponse
    -> GetSavingsPlansUtilizationResponse -> Bool)
-> Eq GetSavingsPlansUtilizationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSavingsPlansUtilizationResponse
-> GetSavingsPlansUtilizationResponse -> Bool
$c/= :: GetSavingsPlansUtilizationResponse
-> GetSavingsPlansUtilizationResponse -> Bool
== :: GetSavingsPlansUtilizationResponse
-> GetSavingsPlansUtilizationResponse -> Bool
$c== :: GetSavingsPlansUtilizationResponse
-> GetSavingsPlansUtilizationResponse -> Bool
Prelude.Eq, ReadPrec [GetSavingsPlansUtilizationResponse]
ReadPrec GetSavingsPlansUtilizationResponse
Int -> ReadS GetSavingsPlansUtilizationResponse
ReadS [GetSavingsPlansUtilizationResponse]
(Int -> ReadS GetSavingsPlansUtilizationResponse)
-> ReadS [GetSavingsPlansUtilizationResponse]
-> ReadPrec GetSavingsPlansUtilizationResponse
-> ReadPrec [GetSavingsPlansUtilizationResponse]
-> Read GetSavingsPlansUtilizationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSavingsPlansUtilizationResponse]
$creadListPrec :: ReadPrec [GetSavingsPlansUtilizationResponse]
readPrec :: ReadPrec GetSavingsPlansUtilizationResponse
$creadPrec :: ReadPrec GetSavingsPlansUtilizationResponse
readList :: ReadS [GetSavingsPlansUtilizationResponse]
$creadList :: ReadS [GetSavingsPlansUtilizationResponse]
readsPrec :: Int -> ReadS GetSavingsPlansUtilizationResponse
$creadsPrec :: Int -> ReadS GetSavingsPlansUtilizationResponse
Prelude.Read, Int -> GetSavingsPlansUtilizationResponse -> ShowS
[GetSavingsPlansUtilizationResponse] -> ShowS
GetSavingsPlansUtilizationResponse -> String
(Int -> GetSavingsPlansUtilizationResponse -> ShowS)
-> (GetSavingsPlansUtilizationResponse -> String)
-> ([GetSavingsPlansUtilizationResponse] -> ShowS)
-> Show GetSavingsPlansUtilizationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSavingsPlansUtilizationResponse] -> ShowS
$cshowList :: [GetSavingsPlansUtilizationResponse] -> ShowS
show :: GetSavingsPlansUtilizationResponse -> String
$cshow :: GetSavingsPlansUtilizationResponse -> String
showsPrec :: Int -> GetSavingsPlansUtilizationResponse -> ShowS
$cshowsPrec :: Int -> GetSavingsPlansUtilizationResponse -> ShowS
Prelude.Show, (forall x.
 GetSavingsPlansUtilizationResponse
 -> Rep GetSavingsPlansUtilizationResponse x)
-> (forall x.
    Rep GetSavingsPlansUtilizationResponse x
    -> GetSavingsPlansUtilizationResponse)
-> Generic GetSavingsPlansUtilizationResponse
forall x.
Rep GetSavingsPlansUtilizationResponse x
-> GetSavingsPlansUtilizationResponse
forall x.
GetSavingsPlansUtilizationResponse
-> Rep GetSavingsPlansUtilizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSavingsPlansUtilizationResponse x
-> GetSavingsPlansUtilizationResponse
$cfrom :: forall x.
GetSavingsPlansUtilizationResponse
-> Rep GetSavingsPlansUtilizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSavingsPlansUtilizationResponse' 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:
--
-- 'savingsPlansUtilizationsByTime', 'getSavingsPlansUtilizationResponse_savingsPlansUtilizationsByTime' - The amount of cost\/commitment you used your Savings Plans. This allows
-- you to specify date ranges.
--
-- 'httpStatus', 'getSavingsPlansUtilizationResponse_httpStatus' - The response's http status code.
--
-- 'total', 'getSavingsPlansUtilizationResponse_total' - The total amount of cost\/commitment that you used your Savings Plans,
-- regardless of date ranges.
newGetSavingsPlansUtilizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'total'
  SavingsPlansUtilizationAggregates ->
  GetSavingsPlansUtilizationResponse
newGetSavingsPlansUtilizationResponse :: Int
-> SavingsPlansUtilizationAggregates
-> GetSavingsPlansUtilizationResponse
newGetSavingsPlansUtilizationResponse
  Int
pHttpStatus_
  SavingsPlansUtilizationAggregates
pTotal_ =
    GetSavingsPlansUtilizationResponse' :: Maybe [SavingsPlansUtilizationByTime]
-> Int
-> SavingsPlansUtilizationAggregates
-> GetSavingsPlansUtilizationResponse
GetSavingsPlansUtilizationResponse'
      { $sel:savingsPlansUtilizationsByTime:GetSavingsPlansUtilizationResponse' :: Maybe [SavingsPlansUtilizationByTime]
savingsPlansUtilizationsByTime =
          Maybe [SavingsPlansUtilizationByTime]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetSavingsPlansUtilizationResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:total:GetSavingsPlansUtilizationResponse' :: SavingsPlansUtilizationAggregates
total = SavingsPlansUtilizationAggregates
pTotal_
      }

-- | The amount of cost\/commitment you used your Savings Plans. This allows
-- you to specify date ranges.
getSavingsPlansUtilizationResponse_savingsPlansUtilizationsByTime :: Lens.Lens' GetSavingsPlansUtilizationResponse (Prelude.Maybe [SavingsPlansUtilizationByTime])
getSavingsPlansUtilizationResponse_savingsPlansUtilizationsByTime :: (Maybe [SavingsPlansUtilizationByTime]
 -> f (Maybe [SavingsPlansUtilizationByTime]))
-> GetSavingsPlansUtilizationResponse
-> f GetSavingsPlansUtilizationResponse
getSavingsPlansUtilizationResponse_savingsPlansUtilizationsByTime = (GetSavingsPlansUtilizationResponse
 -> Maybe [SavingsPlansUtilizationByTime])
-> (GetSavingsPlansUtilizationResponse
    -> Maybe [SavingsPlansUtilizationByTime]
    -> GetSavingsPlansUtilizationResponse)
-> Lens
     GetSavingsPlansUtilizationResponse
     GetSavingsPlansUtilizationResponse
     (Maybe [SavingsPlansUtilizationByTime])
     (Maybe [SavingsPlansUtilizationByTime])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSavingsPlansUtilizationResponse' {Maybe [SavingsPlansUtilizationByTime]
savingsPlansUtilizationsByTime :: Maybe [SavingsPlansUtilizationByTime]
$sel:savingsPlansUtilizationsByTime:GetSavingsPlansUtilizationResponse' :: GetSavingsPlansUtilizationResponse
-> Maybe [SavingsPlansUtilizationByTime]
savingsPlansUtilizationsByTime} -> Maybe [SavingsPlansUtilizationByTime]
savingsPlansUtilizationsByTime) (\s :: GetSavingsPlansUtilizationResponse
s@GetSavingsPlansUtilizationResponse' {} Maybe [SavingsPlansUtilizationByTime]
a -> GetSavingsPlansUtilizationResponse
s {$sel:savingsPlansUtilizationsByTime:GetSavingsPlansUtilizationResponse' :: Maybe [SavingsPlansUtilizationByTime]
savingsPlansUtilizationsByTime = Maybe [SavingsPlansUtilizationByTime]
a} :: GetSavingsPlansUtilizationResponse) ((Maybe [SavingsPlansUtilizationByTime]
  -> f (Maybe [SavingsPlansUtilizationByTime]))
 -> GetSavingsPlansUtilizationResponse
 -> f GetSavingsPlansUtilizationResponse)
-> ((Maybe [SavingsPlansUtilizationByTime]
     -> f (Maybe [SavingsPlansUtilizationByTime]))
    -> Maybe [SavingsPlansUtilizationByTime]
    -> f (Maybe [SavingsPlansUtilizationByTime]))
-> (Maybe [SavingsPlansUtilizationByTime]
    -> f (Maybe [SavingsPlansUtilizationByTime]))
-> GetSavingsPlansUtilizationResponse
-> f GetSavingsPlansUtilizationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SavingsPlansUtilizationByTime]
  [SavingsPlansUtilizationByTime]
  [SavingsPlansUtilizationByTime]
  [SavingsPlansUtilizationByTime]
-> Iso
     (Maybe [SavingsPlansUtilizationByTime])
     (Maybe [SavingsPlansUtilizationByTime])
     (Maybe [SavingsPlansUtilizationByTime])
     (Maybe [SavingsPlansUtilizationByTime])
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
  [SavingsPlansUtilizationByTime]
  [SavingsPlansUtilizationByTime]
  [SavingsPlansUtilizationByTime]
  [SavingsPlansUtilizationByTime]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The total amount of cost\/commitment that you used your Savings Plans,
-- regardless of date ranges.
getSavingsPlansUtilizationResponse_total :: Lens.Lens' GetSavingsPlansUtilizationResponse SavingsPlansUtilizationAggregates
getSavingsPlansUtilizationResponse_total :: (SavingsPlansUtilizationAggregates
 -> f SavingsPlansUtilizationAggregates)
-> GetSavingsPlansUtilizationResponse
-> f GetSavingsPlansUtilizationResponse
getSavingsPlansUtilizationResponse_total = (GetSavingsPlansUtilizationResponse
 -> SavingsPlansUtilizationAggregates)
-> (GetSavingsPlansUtilizationResponse
    -> SavingsPlansUtilizationAggregates
    -> GetSavingsPlansUtilizationResponse)
-> Lens
     GetSavingsPlansUtilizationResponse
     GetSavingsPlansUtilizationResponse
     SavingsPlansUtilizationAggregates
     SavingsPlansUtilizationAggregates
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSavingsPlansUtilizationResponse' {SavingsPlansUtilizationAggregates
total :: SavingsPlansUtilizationAggregates
$sel:total:GetSavingsPlansUtilizationResponse' :: GetSavingsPlansUtilizationResponse
-> SavingsPlansUtilizationAggregates
total} -> SavingsPlansUtilizationAggregates
total) (\s :: GetSavingsPlansUtilizationResponse
s@GetSavingsPlansUtilizationResponse' {} SavingsPlansUtilizationAggregates
a -> GetSavingsPlansUtilizationResponse
s {$sel:total:GetSavingsPlansUtilizationResponse' :: SavingsPlansUtilizationAggregates
total = SavingsPlansUtilizationAggregates
a} :: GetSavingsPlansUtilizationResponse)

instance
  Prelude.NFData
    GetSavingsPlansUtilizationResponse