{-# 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.MacieV2.GetUsageStatistics
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves (queries) quotas and aggregated usage data for one or more
-- accounts.
--
-- This operation returns paginated results.
module Amazonka.MacieV2.GetUsageStatistics
  ( -- * Creating a Request
    GetUsageStatistics (..),
    newGetUsageStatistics,

    -- * Request Lenses
    getUsageStatistics_filterBy,
    getUsageStatistics_maxResults,
    getUsageStatistics_nextToken,
    getUsageStatistics_sortBy,
    getUsageStatistics_timeRange,

    -- * Destructuring the Response
    GetUsageStatisticsResponse (..),
    newGetUsageStatisticsResponse,

    -- * Response Lenses
    getUsageStatisticsResponse_nextToken,
    getUsageStatisticsResponse_records,
    getUsageStatisticsResponse_timeRange,
    getUsageStatisticsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetUsageStatistics' smart constructor.
data GetUsageStatistics = GetUsageStatistics'
  { -- | An array of objects, one for each condition to use to filter the query
    -- results. If you specify more than one condition, Amazon Macie uses an
    -- AND operator to join the conditions.
    GetUsageStatistics -> Maybe [UsageStatisticsFilter]
filterBy :: Prelude.Maybe [UsageStatisticsFilter],
    -- | The maximum number of items to include in each page of the response.
    GetUsageStatistics -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The nextToken string that specifies which page of results to return in a
    -- paginated response.
    GetUsageStatistics -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The criteria to use to sort the query results.
    GetUsageStatistics -> Maybe UsageStatisticsSortBy
sortBy :: Prelude.Maybe UsageStatisticsSortBy,
    -- | The inclusive time period to query usage data for. Valid values are:
    -- MONTH_TO_DATE, for the current calendar month to date; and,
    -- PAST_30_DAYS, for the preceding 30 days. If you don\'t specify a value,
    -- Amazon Macie provides usage data for the preceding 30 days.
    GetUsageStatistics -> Maybe TimeRange
timeRange :: Prelude.Maybe TimeRange
  }
  deriving (GetUsageStatistics -> GetUsageStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUsageStatistics -> GetUsageStatistics -> Bool
$c/= :: GetUsageStatistics -> GetUsageStatistics -> Bool
== :: GetUsageStatistics -> GetUsageStatistics -> Bool
$c== :: GetUsageStatistics -> GetUsageStatistics -> Bool
Prelude.Eq, ReadPrec [GetUsageStatistics]
ReadPrec GetUsageStatistics
Int -> ReadS GetUsageStatistics
ReadS [GetUsageStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUsageStatistics]
$creadListPrec :: ReadPrec [GetUsageStatistics]
readPrec :: ReadPrec GetUsageStatistics
$creadPrec :: ReadPrec GetUsageStatistics
readList :: ReadS [GetUsageStatistics]
$creadList :: ReadS [GetUsageStatistics]
readsPrec :: Int -> ReadS GetUsageStatistics
$creadsPrec :: Int -> ReadS GetUsageStatistics
Prelude.Read, Int -> GetUsageStatistics -> ShowS
[GetUsageStatistics] -> ShowS
GetUsageStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUsageStatistics] -> ShowS
$cshowList :: [GetUsageStatistics] -> ShowS
show :: GetUsageStatistics -> String
$cshow :: GetUsageStatistics -> String
showsPrec :: Int -> GetUsageStatistics -> ShowS
$cshowsPrec :: Int -> GetUsageStatistics -> ShowS
Prelude.Show, forall x. Rep GetUsageStatistics x -> GetUsageStatistics
forall x. GetUsageStatistics -> Rep GetUsageStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUsageStatistics x -> GetUsageStatistics
$cfrom :: forall x. GetUsageStatistics -> Rep GetUsageStatistics x
Prelude.Generic)

-- |
-- Create a value of 'GetUsageStatistics' 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:
--
-- 'filterBy', 'getUsageStatistics_filterBy' - An array of objects, one for each condition to use to filter the query
-- results. If you specify more than one condition, Amazon Macie uses an
-- AND operator to join the conditions.
--
-- 'maxResults', 'getUsageStatistics_maxResults' - The maximum number of items to include in each page of the response.
--
-- 'nextToken', 'getUsageStatistics_nextToken' - The nextToken string that specifies which page of results to return in a
-- paginated response.
--
-- 'sortBy', 'getUsageStatistics_sortBy' - The criteria to use to sort the query results.
--
-- 'timeRange', 'getUsageStatistics_timeRange' - The inclusive time period to query usage data for. Valid values are:
-- MONTH_TO_DATE, for the current calendar month to date; and,
-- PAST_30_DAYS, for the preceding 30 days. If you don\'t specify a value,
-- Amazon Macie provides usage data for the preceding 30 days.
newGetUsageStatistics ::
  GetUsageStatistics
newGetUsageStatistics :: GetUsageStatistics
newGetUsageStatistics =
  GetUsageStatistics'
    { $sel:filterBy:GetUsageStatistics' :: Maybe [UsageStatisticsFilter]
filterBy = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetUsageStatistics' :: Maybe Int
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetUsageStatistics' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:GetUsageStatistics' :: Maybe UsageStatisticsSortBy
sortBy = forall a. Maybe a
Prelude.Nothing,
      $sel:timeRange:GetUsageStatistics' :: Maybe TimeRange
timeRange = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of objects, one for each condition to use to filter the query
-- results. If you specify more than one condition, Amazon Macie uses an
-- AND operator to join the conditions.
getUsageStatistics_filterBy :: Lens.Lens' GetUsageStatistics (Prelude.Maybe [UsageStatisticsFilter])
getUsageStatistics_filterBy :: Lens' GetUsageStatistics (Maybe [UsageStatisticsFilter])
getUsageStatistics_filterBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatistics' {Maybe [UsageStatisticsFilter]
filterBy :: Maybe [UsageStatisticsFilter]
$sel:filterBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe [UsageStatisticsFilter]
filterBy} -> Maybe [UsageStatisticsFilter]
filterBy) (\s :: GetUsageStatistics
s@GetUsageStatistics' {} Maybe [UsageStatisticsFilter]
a -> GetUsageStatistics
s {$sel:filterBy:GetUsageStatistics' :: Maybe [UsageStatisticsFilter]
filterBy = Maybe [UsageStatisticsFilter]
a} :: GetUsageStatistics) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The maximum number of items to include in each page of the response.
getUsageStatistics_maxResults :: Lens.Lens' GetUsageStatistics (Prelude.Maybe Prelude.Int)
getUsageStatistics_maxResults :: Lens' GetUsageStatistics (Maybe Int)
getUsageStatistics_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatistics' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:GetUsageStatistics' :: GetUsageStatistics -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: GetUsageStatistics
s@GetUsageStatistics' {} Maybe Int
a -> GetUsageStatistics
s {$sel:maxResults:GetUsageStatistics' :: Maybe Int
maxResults = Maybe Int
a} :: GetUsageStatistics)

-- | The nextToken string that specifies which page of results to return in a
-- paginated response.
getUsageStatistics_nextToken :: Lens.Lens' GetUsageStatistics (Prelude.Maybe Prelude.Text)
getUsageStatistics_nextToken :: Lens' GetUsageStatistics (Maybe Text)
getUsageStatistics_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatistics' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetUsageStatistics' :: GetUsageStatistics -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetUsageStatistics
s@GetUsageStatistics' {} Maybe Text
a -> GetUsageStatistics
s {$sel:nextToken:GetUsageStatistics' :: Maybe Text
nextToken = Maybe Text
a} :: GetUsageStatistics)

-- | The criteria to use to sort the query results.
getUsageStatistics_sortBy :: Lens.Lens' GetUsageStatistics (Prelude.Maybe UsageStatisticsSortBy)
getUsageStatistics_sortBy :: Lens' GetUsageStatistics (Maybe UsageStatisticsSortBy)
getUsageStatistics_sortBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatistics' {Maybe UsageStatisticsSortBy
sortBy :: Maybe UsageStatisticsSortBy
$sel:sortBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe UsageStatisticsSortBy
sortBy} -> Maybe UsageStatisticsSortBy
sortBy) (\s :: GetUsageStatistics
s@GetUsageStatistics' {} Maybe UsageStatisticsSortBy
a -> GetUsageStatistics
s {$sel:sortBy:GetUsageStatistics' :: Maybe UsageStatisticsSortBy
sortBy = Maybe UsageStatisticsSortBy
a} :: GetUsageStatistics)

-- | The inclusive time period to query usage data for. Valid values are:
-- MONTH_TO_DATE, for the current calendar month to date; and,
-- PAST_30_DAYS, for the preceding 30 days. If you don\'t specify a value,
-- Amazon Macie provides usage data for the preceding 30 days.
getUsageStatistics_timeRange :: Lens.Lens' GetUsageStatistics (Prelude.Maybe TimeRange)
getUsageStatistics_timeRange :: Lens' GetUsageStatistics (Maybe TimeRange)
getUsageStatistics_timeRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatistics' {Maybe TimeRange
timeRange :: Maybe TimeRange
$sel:timeRange:GetUsageStatistics' :: GetUsageStatistics -> Maybe TimeRange
timeRange} -> Maybe TimeRange
timeRange) (\s :: GetUsageStatistics
s@GetUsageStatistics' {} Maybe TimeRange
a -> GetUsageStatistics
s {$sel:timeRange:GetUsageStatistics' :: Maybe TimeRange
timeRange = Maybe TimeRange
a} :: GetUsageStatistics)

instance Core.AWSPager GetUsageStatistics where
  page :: GetUsageStatistics
-> AWSResponse GetUsageStatistics -> Maybe GetUsageStatistics
page GetUsageStatistics
rq AWSResponse GetUsageStatistics
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetUsageStatistics
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetUsageStatisticsResponse (Maybe Text)
getUsageStatisticsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetUsageStatistics
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetUsageStatisticsResponse (Maybe [UsageRecord])
getUsageStatisticsResponse_records
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ GetUsageStatistics
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetUsageStatistics (Maybe Text)
getUsageStatistics_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetUsageStatistics
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetUsageStatisticsResponse (Maybe Text)
getUsageStatisticsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetUsageStatistics where
  type
    AWSResponse GetUsageStatistics =
      GetUsageStatisticsResponse
  request :: (Service -> Service)
-> GetUsageStatistics -> Request GetUsageStatistics
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetUsageStatistics
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetUsageStatistics)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe [UsageRecord]
-> Maybe TimeRange
-> Int
-> GetUsageStatisticsResponse
GetUsageStatisticsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"records" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"timeRange")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetUsageStatistics where
  hashWithSalt :: Int -> GetUsageStatistics -> Int
hashWithSalt Int
_salt GetUsageStatistics' {Maybe Int
Maybe [UsageStatisticsFilter]
Maybe Text
Maybe TimeRange
Maybe UsageStatisticsSortBy
timeRange :: Maybe TimeRange
sortBy :: Maybe UsageStatisticsSortBy
nextToken :: Maybe Text
maxResults :: Maybe Int
filterBy :: Maybe [UsageStatisticsFilter]
$sel:timeRange:GetUsageStatistics' :: GetUsageStatistics -> Maybe TimeRange
$sel:sortBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe UsageStatisticsSortBy
$sel:nextToken:GetUsageStatistics' :: GetUsageStatistics -> Maybe Text
$sel:maxResults:GetUsageStatistics' :: GetUsageStatistics -> Maybe Int
$sel:filterBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe [UsageStatisticsFilter]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UsageStatisticsFilter]
filterBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageStatisticsSortBy
sortBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TimeRange
timeRange

instance Prelude.NFData GetUsageStatistics where
  rnf :: GetUsageStatistics -> ()
rnf GetUsageStatistics' {Maybe Int
Maybe [UsageStatisticsFilter]
Maybe Text
Maybe TimeRange
Maybe UsageStatisticsSortBy
timeRange :: Maybe TimeRange
sortBy :: Maybe UsageStatisticsSortBy
nextToken :: Maybe Text
maxResults :: Maybe Int
filterBy :: Maybe [UsageStatisticsFilter]
$sel:timeRange:GetUsageStatistics' :: GetUsageStatistics -> Maybe TimeRange
$sel:sortBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe UsageStatisticsSortBy
$sel:nextToken:GetUsageStatistics' :: GetUsageStatistics -> Maybe Text
$sel:maxResults:GetUsageStatistics' :: GetUsageStatistics -> Maybe Int
$sel:filterBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe [UsageStatisticsFilter]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [UsageStatisticsFilter]
filterBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsageStatisticsSortBy
sortBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeRange
timeRange

instance Data.ToHeaders GetUsageStatistics where
  toHeaders :: GetUsageStatistics -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetUsageStatistics where
  toJSON :: GetUsageStatistics -> Value
toJSON GetUsageStatistics' {Maybe Int
Maybe [UsageStatisticsFilter]
Maybe Text
Maybe TimeRange
Maybe UsageStatisticsSortBy
timeRange :: Maybe TimeRange
sortBy :: Maybe UsageStatisticsSortBy
nextToken :: Maybe Text
maxResults :: Maybe Int
filterBy :: Maybe [UsageStatisticsFilter]
$sel:timeRange:GetUsageStatistics' :: GetUsageStatistics -> Maybe TimeRange
$sel:sortBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe UsageStatisticsSortBy
$sel:nextToken:GetUsageStatistics' :: GetUsageStatistics -> Maybe Text
$sel:maxResults:GetUsageStatistics' :: GetUsageStatistics -> Maybe Int
$sel:filterBy:GetUsageStatistics' :: GetUsageStatistics -> Maybe [UsageStatisticsFilter]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"filterBy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [UsageStatisticsFilter]
filterBy,
            (Key
"maxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults,
            (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Key
"sortBy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UsageStatisticsSortBy
sortBy,
            (Key
"timeRange" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeRange
timeRange
          ]
      )

instance Data.ToPath GetUsageStatistics where
  toPath :: GetUsageStatistics -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/usage/statistics"

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

-- | /See:/ 'newGetUsageStatisticsResponse' smart constructor.
data GetUsageStatisticsResponse = GetUsageStatisticsResponse'
  { -- | The string to use in a subsequent request to get the next page of
    -- results in a paginated response. This value is null if there are no
    -- additional pages.
    GetUsageStatisticsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that contains the results of the query. Each object
    -- contains the data for an account that matches the filter criteria
    -- specified in the request.
    GetUsageStatisticsResponse -> Maybe [UsageRecord]
records :: Prelude.Maybe [UsageRecord],
    -- | The inclusive time period that the usage data applies to. Possible
    -- values are: MONTH_TO_DATE, for the current calendar month to date; and,
    -- PAST_30_DAYS, for the preceding 30 days.
    GetUsageStatisticsResponse -> Maybe TimeRange
timeRange :: Prelude.Maybe TimeRange,
    -- | The response's http status code.
    GetUsageStatisticsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetUsageStatisticsResponse -> GetUsageStatisticsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUsageStatisticsResponse -> GetUsageStatisticsResponse -> Bool
$c/= :: GetUsageStatisticsResponse -> GetUsageStatisticsResponse -> Bool
== :: GetUsageStatisticsResponse -> GetUsageStatisticsResponse -> Bool
$c== :: GetUsageStatisticsResponse -> GetUsageStatisticsResponse -> Bool
Prelude.Eq, ReadPrec [GetUsageStatisticsResponse]
ReadPrec GetUsageStatisticsResponse
Int -> ReadS GetUsageStatisticsResponse
ReadS [GetUsageStatisticsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUsageStatisticsResponse]
$creadListPrec :: ReadPrec [GetUsageStatisticsResponse]
readPrec :: ReadPrec GetUsageStatisticsResponse
$creadPrec :: ReadPrec GetUsageStatisticsResponse
readList :: ReadS [GetUsageStatisticsResponse]
$creadList :: ReadS [GetUsageStatisticsResponse]
readsPrec :: Int -> ReadS GetUsageStatisticsResponse
$creadsPrec :: Int -> ReadS GetUsageStatisticsResponse
Prelude.Read, Int -> GetUsageStatisticsResponse -> ShowS
[GetUsageStatisticsResponse] -> ShowS
GetUsageStatisticsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUsageStatisticsResponse] -> ShowS
$cshowList :: [GetUsageStatisticsResponse] -> ShowS
show :: GetUsageStatisticsResponse -> String
$cshow :: GetUsageStatisticsResponse -> String
showsPrec :: Int -> GetUsageStatisticsResponse -> ShowS
$cshowsPrec :: Int -> GetUsageStatisticsResponse -> ShowS
Prelude.Show, forall x.
Rep GetUsageStatisticsResponse x -> GetUsageStatisticsResponse
forall x.
GetUsageStatisticsResponse -> Rep GetUsageStatisticsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetUsageStatisticsResponse x -> GetUsageStatisticsResponse
$cfrom :: forall x.
GetUsageStatisticsResponse -> Rep GetUsageStatisticsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetUsageStatisticsResponse' 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:
--
-- 'nextToken', 'getUsageStatisticsResponse_nextToken' - The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
--
-- 'records', 'getUsageStatisticsResponse_records' - An array of objects that contains the results of the query. Each object
-- contains the data for an account that matches the filter criteria
-- specified in the request.
--
-- 'timeRange', 'getUsageStatisticsResponse_timeRange' - The inclusive time period that the usage data applies to. Possible
-- values are: MONTH_TO_DATE, for the current calendar month to date; and,
-- PAST_30_DAYS, for the preceding 30 days.
--
-- 'httpStatus', 'getUsageStatisticsResponse_httpStatus' - The response's http status code.
newGetUsageStatisticsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetUsageStatisticsResponse
newGetUsageStatisticsResponse :: Int -> GetUsageStatisticsResponse
newGetUsageStatisticsResponse Int
pHttpStatus_ =
  GetUsageStatisticsResponse'
    { $sel:nextToken:GetUsageStatisticsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:records:GetUsageStatisticsResponse' :: Maybe [UsageRecord]
records = forall a. Maybe a
Prelude.Nothing,
      $sel:timeRange:GetUsageStatisticsResponse' :: Maybe TimeRange
timeRange = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetUsageStatisticsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
getUsageStatisticsResponse_nextToken :: Lens.Lens' GetUsageStatisticsResponse (Prelude.Maybe Prelude.Text)
getUsageStatisticsResponse_nextToken :: Lens' GetUsageStatisticsResponse (Maybe Text)
getUsageStatisticsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatisticsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetUsageStatisticsResponse
s@GetUsageStatisticsResponse' {} Maybe Text
a -> GetUsageStatisticsResponse
s {$sel:nextToken:GetUsageStatisticsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetUsageStatisticsResponse)

-- | An array of objects that contains the results of the query. Each object
-- contains the data for an account that matches the filter criteria
-- specified in the request.
getUsageStatisticsResponse_records :: Lens.Lens' GetUsageStatisticsResponse (Prelude.Maybe [UsageRecord])
getUsageStatisticsResponse_records :: Lens' GetUsageStatisticsResponse (Maybe [UsageRecord])
getUsageStatisticsResponse_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatisticsResponse' {Maybe [UsageRecord]
records :: Maybe [UsageRecord]
$sel:records:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Maybe [UsageRecord]
records} -> Maybe [UsageRecord]
records) (\s :: GetUsageStatisticsResponse
s@GetUsageStatisticsResponse' {} Maybe [UsageRecord]
a -> GetUsageStatisticsResponse
s {$sel:records:GetUsageStatisticsResponse' :: Maybe [UsageRecord]
records = Maybe [UsageRecord]
a} :: GetUsageStatisticsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The inclusive time period that the usage data applies to. Possible
-- values are: MONTH_TO_DATE, for the current calendar month to date; and,
-- PAST_30_DAYS, for the preceding 30 days.
getUsageStatisticsResponse_timeRange :: Lens.Lens' GetUsageStatisticsResponse (Prelude.Maybe TimeRange)
getUsageStatisticsResponse_timeRange :: Lens' GetUsageStatisticsResponse (Maybe TimeRange)
getUsageStatisticsResponse_timeRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsageStatisticsResponse' {Maybe TimeRange
timeRange :: Maybe TimeRange
$sel:timeRange:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Maybe TimeRange
timeRange} -> Maybe TimeRange
timeRange) (\s :: GetUsageStatisticsResponse
s@GetUsageStatisticsResponse' {} Maybe TimeRange
a -> GetUsageStatisticsResponse
s {$sel:timeRange:GetUsageStatisticsResponse' :: Maybe TimeRange
timeRange = Maybe TimeRange
a} :: GetUsageStatisticsResponse)

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

instance Prelude.NFData GetUsageStatisticsResponse where
  rnf :: GetUsageStatisticsResponse -> ()
rnf GetUsageStatisticsResponse' {Int
Maybe [UsageRecord]
Maybe Text
Maybe TimeRange
httpStatus :: Int
timeRange :: Maybe TimeRange
records :: Maybe [UsageRecord]
nextToken :: Maybe Text
$sel:httpStatus:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Int
$sel:timeRange:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Maybe TimeRange
$sel:records:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Maybe [UsageRecord]
$sel:nextToken:GetUsageStatisticsResponse' :: GetUsageStatisticsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UsageRecord]
records
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeRange
timeRange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus