{-# 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.GetCostCategories
-- 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 an array of Cost Category names and values incurred cost.
--
-- If some Cost Category names and values are not associated with any cost,
-- they will not be returned by this API.
module Amazonka.CostExplorer.GetCostCategories
  ( -- * Creating a Request
    GetCostCategories (..),
    newGetCostCategories,

    -- * Request Lenses
    getCostCategories_nextPageToken,
    getCostCategories_searchString,
    getCostCategories_costCategoryName,
    getCostCategories_filter,
    getCostCategories_maxResults,
    getCostCategories_sortBy,
    getCostCategories_timePeriod,

    -- * Destructuring the Response
    GetCostCategoriesResponse (..),
    newGetCostCategoriesResponse,

    -- * Response Lenses
    getCostCategoriesResponse_nextPageToken,
    getCostCategoriesResponse_costCategoryNames,
    getCostCategoriesResponse_costCategoryValues,
    getCostCategoriesResponse_httpStatus,
    getCostCategoriesResponse_returnSize,
    getCostCategoriesResponse_totalSize,
  )
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:/ 'newGetCostCategories' smart constructor.
data GetCostCategories = GetCostCategories'
  { -- | If the number of objects that are still available for retrieval exceeds
    -- the limit, Amazon Web Services returns a NextPageToken value in the
    -- response. To retrieve the next batch of objects, provide the
    -- NextPageToken from the prior call in your next request.
    GetCostCategories -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | The value that you want to search the filter values for.
    --
    -- If you do not specify a @CostCategoryName@, @SearchString@ will be used
    -- to filter Cost Category names that match the @SearchString@ pattern. If
    -- you do specifiy a @CostCategoryName@, @SearchString@ will be used to
    -- filter Cost Category values that match the @SearchString@ pattern.
    GetCostCategories -> Maybe Text
searchString :: Prelude.Maybe Prelude.Text,
    GetCostCategories -> Maybe Text
costCategoryName :: Prelude.Maybe Prelude.Text,
    GetCostCategories -> Maybe Expression
filter' :: Prelude.Maybe Expression,
    -- | This field is only used when @SortBy@ is provided in the request.
    --
    -- The maximum number of objects that to be returned for this request. If
    -- @MaxResults@ is not specified with @SortBy@, the request will return
    -- 1000 results as the default value for this parameter.
    --
    -- For @GetCostCategories@, MaxResults has an upper limit of 1000.
    GetCostCategories -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The value by which you want to sort the data.
    --
    -- The key represents cost and usage metrics. The following values are
    -- supported:
    --
    -- -   @BlendedCost@
    --
    -- -   @UnblendedCost@
    --
    -- -   @AmortizedCost@
    --
    -- -   @NetAmortizedCost@
    --
    -- -   @NetUnblendedCost@
    --
    -- -   @UsageQuantity@
    --
    -- -   @NormalizedUsageAmount@
    --
    -- Supported values for @SortOrder@ are @ASCENDING@ or @DESCENDING@.
    --
    -- When using @SortBy@, @NextPageToken@ and @SearchString@ are not
    -- supported.
    GetCostCategories -> Maybe [SortDefinition]
sortBy :: Prelude.Maybe [SortDefinition],
    GetCostCategories -> DateInterval
timePeriod :: DateInterval
  }
  deriving (GetCostCategories -> GetCostCategories -> Bool
(GetCostCategories -> GetCostCategories -> Bool)
-> (GetCostCategories -> GetCostCategories -> Bool)
-> Eq GetCostCategories
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCostCategories -> GetCostCategories -> Bool
$c/= :: GetCostCategories -> GetCostCategories -> Bool
== :: GetCostCategories -> GetCostCategories -> Bool
$c== :: GetCostCategories -> GetCostCategories -> Bool
Prelude.Eq, ReadPrec [GetCostCategories]
ReadPrec GetCostCategories
Int -> ReadS GetCostCategories
ReadS [GetCostCategories]
(Int -> ReadS GetCostCategories)
-> ReadS [GetCostCategories]
-> ReadPrec GetCostCategories
-> ReadPrec [GetCostCategories]
-> Read GetCostCategories
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCostCategories]
$creadListPrec :: ReadPrec [GetCostCategories]
readPrec :: ReadPrec GetCostCategories
$creadPrec :: ReadPrec GetCostCategories
readList :: ReadS [GetCostCategories]
$creadList :: ReadS [GetCostCategories]
readsPrec :: Int -> ReadS GetCostCategories
$creadsPrec :: Int -> ReadS GetCostCategories
Prelude.Read, Int -> GetCostCategories -> ShowS
[GetCostCategories] -> ShowS
GetCostCategories -> String
(Int -> GetCostCategories -> ShowS)
-> (GetCostCategories -> String)
-> ([GetCostCategories] -> ShowS)
-> Show GetCostCategories
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCostCategories] -> ShowS
$cshowList :: [GetCostCategories] -> ShowS
show :: GetCostCategories -> String
$cshow :: GetCostCategories -> String
showsPrec :: Int -> GetCostCategories -> ShowS
$cshowsPrec :: Int -> GetCostCategories -> ShowS
Prelude.Show, (forall x. GetCostCategories -> Rep GetCostCategories x)
-> (forall x. Rep GetCostCategories x -> GetCostCategories)
-> Generic GetCostCategories
forall x. Rep GetCostCategories x -> GetCostCategories
forall x. GetCostCategories -> Rep GetCostCategories x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCostCategories x -> GetCostCategories
$cfrom :: forall x. GetCostCategories -> Rep GetCostCategories x
Prelude.Generic)

-- |
-- Create a value of 'GetCostCategories' 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:
--
-- 'nextPageToken', 'getCostCategories_nextPageToken' - If the number of objects that are still available for retrieval exceeds
-- the limit, Amazon Web Services returns a NextPageToken value in the
-- response. To retrieve the next batch of objects, provide the
-- NextPageToken from the prior call in your next request.
--
-- 'searchString', 'getCostCategories_searchString' - The value that you want to search the filter values for.
--
-- If you do not specify a @CostCategoryName@, @SearchString@ will be used
-- to filter Cost Category names that match the @SearchString@ pattern. If
-- you do specifiy a @CostCategoryName@, @SearchString@ will be used to
-- filter Cost Category values that match the @SearchString@ pattern.
--
-- 'costCategoryName', 'getCostCategories_costCategoryName' - Undocumented member.
--
-- 'filter'', 'getCostCategories_filter' - Undocumented member.
--
-- 'maxResults', 'getCostCategories_maxResults' - This field is only used when @SortBy@ is provided in the request.
--
-- The maximum number of objects that to be returned for this request. If
-- @MaxResults@ is not specified with @SortBy@, the request will return
-- 1000 results as the default value for this parameter.
--
-- For @GetCostCategories@, MaxResults has an upper limit of 1000.
--
-- 'sortBy', 'getCostCategories_sortBy' - The value by which you want to sort the data.
--
-- The key represents cost and usage metrics. The following values are
-- supported:
--
-- -   @BlendedCost@
--
-- -   @UnblendedCost@
--
-- -   @AmortizedCost@
--
-- -   @NetAmortizedCost@
--
-- -   @NetUnblendedCost@
--
-- -   @UsageQuantity@
--
-- -   @NormalizedUsageAmount@
--
-- Supported values for @SortOrder@ are @ASCENDING@ or @DESCENDING@.
--
-- When using @SortBy@, @NextPageToken@ and @SearchString@ are not
-- supported.
--
-- 'timePeriod', 'getCostCategories_timePeriod' - Undocumented member.
newGetCostCategories ::
  -- | 'timePeriod'
  DateInterval ->
  GetCostCategories
newGetCostCategories :: DateInterval -> GetCostCategories
newGetCostCategories DateInterval
pTimePeriod_ =
  GetCostCategories' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Expression
-> Maybe Natural
-> Maybe [SortDefinition]
-> DateInterval
-> GetCostCategories
GetCostCategories'
    { $sel:nextPageToken:GetCostCategories' :: Maybe Text
nextPageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:searchString:GetCostCategories' :: Maybe Text
searchString = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:costCategoryName:GetCostCategories' :: Maybe Text
costCategoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':GetCostCategories' :: Maybe Expression
filter' = Maybe Expression
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetCostCategories' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:GetCostCategories' :: Maybe [SortDefinition]
sortBy = Maybe [SortDefinition]
forall a. Maybe a
Prelude.Nothing,
      $sel:timePeriod:GetCostCategories' :: DateInterval
timePeriod = DateInterval
pTimePeriod_
    }

-- | If the number of objects that are still available for retrieval exceeds
-- the limit, Amazon Web Services returns a NextPageToken value in the
-- response. To retrieve the next batch of objects, provide the
-- NextPageToken from the prior call in your next request.
getCostCategories_nextPageToken :: Lens.Lens' GetCostCategories (Prelude.Maybe Prelude.Text)
getCostCategories_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> GetCostCategories -> f GetCostCategories
getCostCategories_nextPageToken = (GetCostCategories -> Maybe Text)
-> (GetCostCategories -> Maybe Text -> GetCostCategories)
-> Lens
     GetCostCategories GetCostCategories (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:GetCostCategories' :: GetCostCategories -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: GetCostCategories
s@GetCostCategories' {} Maybe Text
a -> GetCostCategories
s {$sel:nextPageToken:GetCostCategories' :: Maybe Text
nextPageToken = Maybe Text
a} :: GetCostCategories)

-- | The value that you want to search the filter values for.
--
-- If you do not specify a @CostCategoryName@, @SearchString@ will be used
-- to filter Cost Category names that match the @SearchString@ pattern. If
-- you do specifiy a @CostCategoryName@, @SearchString@ will be used to
-- filter Cost Category values that match the @SearchString@ pattern.
getCostCategories_searchString :: Lens.Lens' GetCostCategories (Prelude.Maybe Prelude.Text)
getCostCategories_searchString :: (Maybe Text -> f (Maybe Text))
-> GetCostCategories -> f GetCostCategories
getCostCategories_searchString = (GetCostCategories -> Maybe Text)
-> (GetCostCategories -> Maybe Text -> GetCostCategories)
-> Lens
     GetCostCategories GetCostCategories (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {Maybe Text
searchString :: Maybe Text
$sel:searchString:GetCostCategories' :: GetCostCategories -> Maybe Text
searchString} -> Maybe Text
searchString) (\s :: GetCostCategories
s@GetCostCategories' {} Maybe Text
a -> GetCostCategories
s {$sel:searchString:GetCostCategories' :: Maybe Text
searchString = Maybe Text
a} :: GetCostCategories)

-- | Undocumented member.
getCostCategories_costCategoryName :: Lens.Lens' GetCostCategories (Prelude.Maybe Prelude.Text)
getCostCategories_costCategoryName :: (Maybe Text -> f (Maybe Text))
-> GetCostCategories -> f GetCostCategories
getCostCategories_costCategoryName = (GetCostCategories -> Maybe Text)
-> (GetCostCategories -> Maybe Text -> GetCostCategories)
-> Lens
     GetCostCategories GetCostCategories (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {Maybe Text
costCategoryName :: Maybe Text
$sel:costCategoryName:GetCostCategories' :: GetCostCategories -> Maybe Text
costCategoryName} -> Maybe Text
costCategoryName) (\s :: GetCostCategories
s@GetCostCategories' {} Maybe Text
a -> GetCostCategories
s {$sel:costCategoryName:GetCostCategories' :: Maybe Text
costCategoryName = Maybe Text
a} :: GetCostCategories)

-- | Undocumented member.
getCostCategories_filter :: Lens.Lens' GetCostCategories (Prelude.Maybe Expression)
getCostCategories_filter :: (Maybe Expression -> f (Maybe Expression))
-> GetCostCategories -> f GetCostCategories
getCostCategories_filter = (GetCostCategories -> Maybe Expression)
-> (GetCostCategories -> Maybe Expression -> GetCostCategories)
-> Lens
     GetCostCategories
     GetCostCategories
     (Maybe Expression)
     (Maybe Expression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {Maybe Expression
filter' :: Maybe Expression
$sel:filter':GetCostCategories' :: GetCostCategories -> Maybe Expression
filter'} -> Maybe Expression
filter') (\s :: GetCostCategories
s@GetCostCategories' {} Maybe Expression
a -> GetCostCategories
s {$sel:filter':GetCostCategories' :: Maybe Expression
filter' = Maybe Expression
a} :: GetCostCategories)

-- | This field is only used when @SortBy@ is provided in the request.
--
-- The maximum number of objects that to be returned for this request. If
-- @MaxResults@ is not specified with @SortBy@, the request will return
-- 1000 results as the default value for this parameter.
--
-- For @GetCostCategories@, MaxResults has an upper limit of 1000.
getCostCategories_maxResults :: Lens.Lens' GetCostCategories (Prelude.Maybe Prelude.Natural)
getCostCategories_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetCostCategories -> f GetCostCategories
getCostCategories_maxResults = (GetCostCategories -> Maybe Natural)
-> (GetCostCategories -> Maybe Natural -> GetCostCategories)
-> Lens
     GetCostCategories GetCostCategories (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetCostCategories' :: GetCostCategories -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetCostCategories
s@GetCostCategories' {} Maybe Natural
a -> GetCostCategories
s {$sel:maxResults:GetCostCategories' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetCostCategories)

-- | The value by which you want to sort the data.
--
-- The key represents cost and usage metrics. The following values are
-- supported:
--
-- -   @BlendedCost@
--
-- -   @UnblendedCost@
--
-- -   @AmortizedCost@
--
-- -   @NetAmortizedCost@
--
-- -   @NetUnblendedCost@
--
-- -   @UsageQuantity@
--
-- -   @NormalizedUsageAmount@
--
-- Supported values for @SortOrder@ are @ASCENDING@ or @DESCENDING@.
--
-- When using @SortBy@, @NextPageToken@ and @SearchString@ are not
-- supported.
getCostCategories_sortBy :: Lens.Lens' GetCostCategories (Prelude.Maybe [SortDefinition])
getCostCategories_sortBy :: (Maybe [SortDefinition] -> f (Maybe [SortDefinition]))
-> GetCostCategories -> f GetCostCategories
getCostCategories_sortBy = (GetCostCategories -> Maybe [SortDefinition])
-> (GetCostCategories
    -> Maybe [SortDefinition] -> GetCostCategories)
-> Lens
     GetCostCategories
     GetCostCategories
     (Maybe [SortDefinition])
     (Maybe [SortDefinition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {Maybe [SortDefinition]
sortBy :: Maybe [SortDefinition]
$sel:sortBy:GetCostCategories' :: GetCostCategories -> Maybe [SortDefinition]
sortBy} -> Maybe [SortDefinition]
sortBy) (\s :: GetCostCategories
s@GetCostCategories' {} Maybe [SortDefinition]
a -> GetCostCategories
s {$sel:sortBy:GetCostCategories' :: Maybe [SortDefinition]
sortBy = Maybe [SortDefinition]
a} :: GetCostCategories) ((Maybe [SortDefinition] -> f (Maybe [SortDefinition]))
 -> GetCostCategories -> f GetCostCategories)
-> ((Maybe [SortDefinition] -> f (Maybe [SortDefinition]))
    -> Maybe [SortDefinition] -> f (Maybe [SortDefinition]))
-> (Maybe [SortDefinition] -> f (Maybe [SortDefinition]))
-> GetCostCategories
-> f GetCostCategories
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SortDefinition] [SortDefinition] [SortDefinition] [SortDefinition]
-> Iso
     (Maybe [SortDefinition])
     (Maybe [SortDefinition])
     (Maybe [SortDefinition])
     (Maybe [SortDefinition])
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
  [SortDefinition] [SortDefinition] [SortDefinition] [SortDefinition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
getCostCategories_timePeriod :: Lens.Lens' GetCostCategories DateInterval
getCostCategories_timePeriod :: (DateInterval -> f DateInterval)
-> GetCostCategories -> f GetCostCategories
getCostCategories_timePeriod = (GetCostCategories -> DateInterval)
-> (GetCostCategories -> DateInterval -> GetCostCategories)
-> Lens
     GetCostCategories GetCostCategories DateInterval DateInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategories' {DateInterval
timePeriod :: DateInterval
$sel:timePeriod:GetCostCategories' :: GetCostCategories -> DateInterval
timePeriod} -> DateInterval
timePeriod) (\s :: GetCostCategories
s@GetCostCategories' {} DateInterval
a -> GetCostCategories
s {$sel:timePeriod:GetCostCategories' :: DateInterval
timePeriod = DateInterval
a} :: GetCostCategories)

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

instance Prelude.Hashable GetCostCategories

instance Prelude.NFData GetCostCategories

instance Core.ToHeaders GetCostCategories where
  toHeaders :: GetCostCategories -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetCostCategories -> 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.GetCostCategories" ::
                          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 GetCostCategories where
  toJSON :: GetCostCategories -> Value
toJSON GetCostCategories' {Maybe Natural
Maybe [SortDefinition]
Maybe Text
Maybe Expression
DateInterval
timePeriod :: DateInterval
sortBy :: Maybe [SortDefinition]
maxResults :: Maybe Natural
filter' :: Maybe Expression
costCategoryName :: Maybe Text
searchString :: Maybe Text
nextPageToken :: Maybe Text
$sel:timePeriod:GetCostCategories' :: GetCostCategories -> DateInterval
$sel:sortBy:GetCostCategories' :: GetCostCategories -> Maybe [SortDefinition]
$sel:maxResults:GetCostCategories' :: GetCostCategories -> Maybe Natural
$sel:filter':GetCostCategories' :: GetCostCategories -> Maybe Expression
$sel:costCategoryName:GetCostCategories' :: GetCostCategories -> Maybe Text
$sel:searchString:GetCostCategories' :: GetCostCategories -> Maybe Text
$sel:nextPageToken:GetCostCategories' :: GetCostCategories -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextPageToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextPageToken,
            (Text
"SearchString" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
searchString,
            (Text
"CostCategoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
costCategoryName,
            (Text
"Filter" Text -> Expression -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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',
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Text
"SortBy" Text -> [SortDefinition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (Text
"TimePeriod" Text -> DateInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DateInterval
timePeriod)
          ]
      )

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

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

-- | /See:/ 'newGetCostCategoriesResponse' smart constructor.
data GetCostCategoriesResponse = GetCostCategoriesResponse'
  { -- | If the number of objects that are still available for retrieval exceeds
    -- the limit, Amazon Web Services returns a NextPageToken value in the
    -- response. To retrieve the next batch of objects, provide the marker from
    -- the prior call in your next request.
    GetCostCategoriesResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | The names of the Cost Categories.
    GetCostCategoriesResponse -> Maybe [Text]
costCategoryNames :: Prelude.Maybe [Prelude.Text],
    -- | The Cost Category values.
    --
    -- @CostCategoryValues@ are not returned if @CostCategoryName@ is not
    -- specified in the request.
    GetCostCategoriesResponse -> Maybe [Text]
costCategoryValues :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    GetCostCategoriesResponse -> Int
httpStatus :: Prelude.Int,
    -- | The number of objects returned.
    GetCostCategoriesResponse -> Int
returnSize :: Prelude.Int,
    -- | The total number of objects.
    GetCostCategoriesResponse -> Int
totalSize :: Prelude.Int
  }
  deriving (GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool
(GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool)
-> (GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool)
-> Eq GetCostCategoriesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool
$c/= :: GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool
== :: GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool
$c== :: GetCostCategoriesResponse -> GetCostCategoriesResponse -> Bool
Prelude.Eq, ReadPrec [GetCostCategoriesResponse]
ReadPrec GetCostCategoriesResponse
Int -> ReadS GetCostCategoriesResponse
ReadS [GetCostCategoriesResponse]
(Int -> ReadS GetCostCategoriesResponse)
-> ReadS [GetCostCategoriesResponse]
-> ReadPrec GetCostCategoriesResponse
-> ReadPrec [GetCostCategoriesResponse]
-> Read GetCostCategoriesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCostCategoriesResponse]
$creadListPrec :: ReadPrec [GetCostCategoriesResponse]
readPrec :: ReadPrec GetCostCategoriesResponse
$creadPrec :: ReadPrec GetCostCategoriesResponse
readList :: ReadS [GetCostCategoriesResponse]
$creadList :: ReadS [GetCostCategoriesResponse]
readsPrec :: Int -> ReadS GetCostCategoriesResponse
$creadsPrec :: Int -> ReadS GetCostCategoriesResponse
Prelude.Read, Int -> GetCostCategoriesResponse -> ShowS
[GetCostCategoriesResponse] -> ShowS
GetCostCategoriesResponse -> String
(Int -> GetCostCategoriesResponse -> ShowS)
-> (GetCostCategoriesResponse -> String)
-> ([GetCostCategoriesResponse] -> ShowS)
-> Show GetCostCategoriesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCostCategoriesResponse] -> ShowS
$cshowList :: [GetCostCategoriesResponse] -> ShowS
show :: GetCostCategoriesResponse -> String
$cshow :: GetCostCategoriesResponse -> String
showsPrec :: Int -> GetCostCategoriesResponse -> ShowS
$cshowsPrec :: Int -> GetCostCategoriesResponse -> ShowS
Prelude.Show, (forall x.
 GetCostCategoriesResponse -> Rep GetCostCategoriesResponse x)
-> (forall x.
    Rep GetCostCategoriesResponse x -> GetCostCategoriesResponse)
-> Generic GetCostCategoriesResponse
forall x.
Rep GetCostCategoriesResponse x -> GetCostCategoriesResponse
forall x.
GetCostCategoriesResponse -> Rep GetCostCategoriesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCostCategoriesResponse x -> GetCostCategoriesResponse
$cfrom :: forall x.
GetCostCategoriesResponse -> Rep GetCostCategoriesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCostCategoriesResponse' 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:
--
-- 'nextPageToken', 'getCostCategoriesResponse_nextPageToken' - If the number of objects that are still available for retrieval exceeds
-- the limit, Amazon Web Services returns a NextPageToken value in the
-- response. To retrieve the next batch of objects, provide the marker from
-- the prior call in your next request.
--
-- 'costCategoryNames', 'getCostCategoriesResponse_costCategoryNames' - The names of the Cost Categories.
--
-- 'costCategoryValues', 'getCostCategoriesResponse_costCategoryValues' - The Cost Category values.
--
-- @CostCategoryValues@ are not returned if @CostCategoryName@ is not
-- specified in the request.
--
-- 'httpStatus', 'getCostCategoriesResponse_httpStatus' - The response's http status code.
--
-- 'returnSize', 'getCostCategoriesResponse_returnSize' - The number of objects returned.
--
-- 'totalSize', 'getCostCategoriesResponse_totalSize' - The total number of objects.
newGetCostCategoriesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'returnSize'
  Prelude.Int ->
  -- | 'totalSize'
  Prelude.Int ->
  GetCostCategoriesResponse
newGetCostCategoriesResponse :: Int -> Int -> Int -> GetCostCategoriesResponse
newGetCostCategoriesResponse
  Int
pHttpStatus_
  Int
pReturnSize_
  Int
pTotalSize_ =
    GetCostCategoriesResponse' :: Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> Int
-> Int
-> Int
-> GetCostCategoriesResponse
GetCostCategoriesResponse'
      { $sel:nextPageToken:GetCostCategoriesResponse' :: Maybe Text
nextPageToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:costCategoryNames:GetCostCategoriesResponse' :: Maybe [Text]
costCategoryNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:costCategoryValues:GetCostCategoriesResponse' :: Maybe [Text]
costCategoryValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetCostCategoriesResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:returnSize:GetCostCategoriesResponse' :: Int
returnSize = Int
pReturnSize_,
        $sel:totalSize:GetCostCategoriesResponse' :: Int
totalSize = Int
pTotalSize_
      }

-- | If the number of objects that are still available for retrieval exceeds
-- the limit, Amazon Web Services returns a NextPageToken value in the
-- response. To retrieve the next batch of objects, provide the marker from
-- the prior call in your next request.
getCostCategoriesResponse_nextPageToken :: Lens.Lens' GetCostCategoriesResponse (Prelude.Maybe Prelude.Text)
getCostCategoriesResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> GetCostCategoriesResponse -> f GetCostCategoriesResponse
getCostCategoriesResponse_nextPageToken = (GetCostCategoriesResponse -> Maybe Text)
-> (GetCostCategoriesResponse
    -> Maybe Text -> GetCostCategoriesResponse)
-> Lens
     GetCostCategoriesResponse
     GetCostCategoriesResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategoriesResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:GetCostCategoriesResponse' :: GetCostCategoriesResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: GetCostCategoriesResponse
s@GetCostCategoriesResponse' {} Maybe Text
a -> GetCostCategoriesResponse
s {$sel:nextPageToken:GetCostCategoriesResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: GetCostCategoriesResponse)

-- | The names of the Cost Categories.
getCostCategoriesResponse_costCategoryNames :: Lens.Lens' GetCostCategoriesResponse (Prelude.Maybe [Prelude.Text])
getCostCategoriesResponse_costCategoryNames :: (Maybe [Text] -> f (Maybe [Text]))
-> GetCostCategoriesResponse -> f GetCostCategoriesResponse
getCostCategoriesResponse_costCategoryNames = (GetCostCategoriesResponse -> Maybe [Text])
-> (GetCostCategoriesResponse
    -> Maybe [Text] -> GetCostCategoriesResponse)
-> Lens
     GetCostCategoriesResponse
     GetCostCategoriesResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategoriesResponse' {Maybe [Text]
costCategoryNames :: Maybe [Text]
$sel:costCategoryNames:GetCostCategoriesResponse' :: GetCostCategoriesResponse -> Maybe [Text]
costCategoryNames} -> Maybe [Text]
costCategoryNames) (\s :: GetCostCategoriesResponse
s@GetCostCategoriesResponse' {} Maybe [Text]
a -> GetCostCategoriesResponse
s {$sel:costCategoryNames:GetCostCategoriesResponse' :: Maybe [Text]
costCategoryNames = Maybe [Text]
a} :: GetCostCategoriesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetCostCategoriesResponse -> f GetCostCategoriesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetCostCategoriesResponse
-> f GetCostCategoriesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Cost Category values.
--
-- @CostCategoryValues@ are not returned if @CostCategoryName@ is not
-- specified in the request.
getCostCategoriesResponse_costCategoryValues :: Lens.Lens' GetCostCategoriesResponse (Prelude.Maybe [Prelude.Text])
getCostCategoriesResponse_costCategoryValues :: (Maybe [Text] -> f (Maybe [Text]))
-> GetCostCategoriesResponse -> f GetCostCategoriesResponse
getCostCategoriesResponse_costCategoryValues = (GetCostCategoriesResponse -> Maybe [Text])
-> (GetCostCategoriesResponse
    -> Maybe [Text] -> GetCostCategoriesResponse)
-> Lens
     GetCostCategoriesResponse
     GetCostCategoriesResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategoriesResponse' {Maybe [Text]
costCategoryValues :: Maybe [Text]
$sel:costCategoryValues:GetCostCategoriesResponse' :: GetCostCategoriesResponse -> Maybe [Text]
costCategoryValues} -> Maybe [Text]
costCategoryValues) (\s :: GetCostCategoriesResponse
s@GetCostCategoriesResponse' {} Maybe [Text]
a -> GetCostCategoriesResponse
s {$sel:costCategoryValues:GetCostCategoriesResponse' :: Maybe [Text]
costCategoryValues = Maybe [Text]
a} :: GetCostCategoriesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetCostCategoriesResponse -> f GetCostCategoriesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetCostCategoriesResponse
-> f GetCostCategoriesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The number of objects returned.
getCostCategoriesResponse_returnSize :: Lens.Lens' GetCostCategoriesResponse Prelude.Int
getCostCategoriesResponse_returnSize :: (Int -> f Int)
-> GetCostCategoriesResponse -> f GetCostCategoriesResponse
getCostCategoriesResponse_returnSize = (GetCostCategoriesResponse -> Int)
-> (GetCostCategoriesResponse -> Int -> GetCostCategoriesResponse)
-> Lens GetCostCategoriesResponse GetCostCategoriesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategoriesResponse' {Int
returnSize :: Int
$sel:returnSize:GetCostCategoriesResponse' :: GetCostCategoriesResponse -> Int
returnSize} -> Int
returnSize) (\s :: GetCostCategoriesResponse
s@GetCostCategoriesResponse' {} Int
a -> GetCostCategoriesResponse
s {$sel:returnSize:GetCostCategoriesResponse' :: Int
returnSize = Int
a} :: GetCostCategoriesResponse)

-- | The total number of objects.
getCostCategoriesResponse_totalSize :: Lens.Lens' GetCostCategoriesResponse Prelude.Int
getCostCategoriesResponse_totalSize :: (Int -> f Int)
-> GetCostCategoriesResponse -> f GetCostCategoriesResponse
getCostCategoriesResponse_totalSize = (GetCostCategoriesResponse -> Int)
-> (GetCostCategoriesResponse -> Int -> GetCostCategoriesResponse)
-> Lens GetCostCategoriesResponse GetCostCategoriesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCostCategoriesResponse' {Int
totalSize :: Int
$sel:totalSize:GetCostCategoriesResponse' :: GetCostCategoriesResponse -> Int
totalSize} -> Int
totalSize) (\s :: GetCostCategoriesResponse
s@GetCostCategoriesResponse' {} Int
a -> GetCostCategoriesResponse
s {$sel:totalSize:GetCostCategoriesResponse' :: Int
totalSize = Int
a} :: GetCostCategoriesResponse)

instance Prelude.NFData GetCostCategoriesResponse