{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.DimensionValues
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CostExplorer.Types.DimensionValues where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CostExplorer.Types.Dimension
import Amazonka.CostExplorer.Types.MatchOption
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The metadata that you can use to filter and group your results. You can
-- use @GetDimensionValues@ to find specific values.
--
-- /See:/ 'newDimensionValues' smart constructor.
data DimensionValues = DimensionValues'
  { -- | The names of the metadata types that you can use to filter and group
    -- your results. For example, @AZ@ returns a list of Availability Zones.
    --
    -- Not all dimensions are supported in each API. Refer to the documentation
    -- for each specific API to see what is supported.
    --
    -- @LINK_ACCOUNT_NAME@ and @SERVICE_CODE@ can only be used in
    -- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>.
    --
    -- @ANOMALY_TOTAL_IMPACT_ABSOLUTE@ and @ANOMALY_TOTAL_IMPACT_PERCENTAGE@
    -- can only be used in
    -- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_AnomalySubscription.html AnomalySubscriptions>.
    DimensionValues -> Maybe Dimension
key :: Prelude.Maybe Dimension,
    -- | The match options that you can use to filter your results.
    --
    -- @MatchOptions@ is only applicable for actions related to Cost Category
    -- and Anomaly Subscriptions. Refer to the documentation for each specific
    -- API to see what is supported.
    --
    -- The default values for @MatchOptions@ are @EQUALS@ and @CASE_SENSITIVE@.
    DimensionValues -> Maybe [MatchOption]
matchOptions :: Prelude.Maybe [MatchOption],
    -- | The metadata values that you can use to filter and group your results.
    -- You can use @GetDimensionValues@ to find specific values.
    DimensionValues -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DimensionValues -> DimensionValues -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DimensionValues -> DimensionValues -> Bool
$c/= :: DimensionValues -> DimensionValues -> Bool
== :: DimensionValues -> DimensionValues -> Bool
$c== :: DimensionValues -> DimensionValues -> Bool
Prelude.Eq, ReadPrec [DimensionValues]
ReadPrec DimensionValues
Int -> ReadS DimensionValues
ReadS [DimensionValues]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DimensionValues]
$creadListPrec :: ReadPrec [DimensionValues]
readPrec :: ReadPrec DimensionValues
$creadPrec :: ReadPrec DimensionValues
readList :: ReadS [DimensionValues]
$creadList :: ReadS [DimensionValues]
readsPrec :: Int -> ReadS DimensionValues
$creadsPrec :: Int -> ReadS DimensionValues
Prelude.Read, Int -> DimensionValues -> ShowS
[DimensionValues] -> ShowS
DimensionValues -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DimensionValues] -> ShowS
$cshowList :: [DimensionValues] -> ShowS
show :: DimensionValues -> String
$cshow :: DimensionValues -> String
showsPrec :: Int -> DimensionValues -> ShowS
$cshowsPrec :: Int -> DimensionValues -> ShowS
Prelude.Show, forall x. Rep DimensionValues x -> DimensionValues
forall x. DimensionValues -> Rep DimensionValues x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DimensionValues x -> DimensionValues
$cfrom :: forall x. DimensionValues -> Rep DimensionValues x
Prelude.Generic)

-- |
-- Create a value of 'DimensionValues' 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:
--
-- 'key', 'dimensionValues_key' - The names of the metadata types that you can use to filter and group
-- your results. For example, @AZ@ returns a list of Availability Zones.
--
-- Not all dimensions are supported in each API. Refer to the documentation
-- for each specific API to see what is supported.
--
-- @LINK_ACCOUNT_NAME@ and @SERVICE_CODE@ can only be used in
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>.
--
-- @ANOMALY_TOTAL_IMPACT_ABSOLUTE@ and @ANOMALY_TOTAL_IMPACT_PERCENTAGE@
-- can only be used in
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_AnomalySubscription.html AnomalySubscriptions>.
--
-- 'matchOptions', 'dimensionValues_matchOptions' - The match options that you can use to filter your results.
--
-- @MatchOptions@ is only applicable for actions related to Cost Category
-- and Anomaly Subscriptions. Refer to the documentation for each specific
-- API to see what is supported.
--
-- The default values for @MatchOptions@ are @EQUALS@ and @CASE_SENSITIVE@.
--
-- 'values', 'dimensionValues_values' - The metadata values that you can use to filter and group your results.
-- You can use @GetDimensionValues@ to find specific values.
newDimensionValues ::
  DimensionValues
newDimensionValues :: DimensionValues
newDimensionValues =
  DimensionValues'
    { $sel:key:DimensionValues' :: Maybe Dimension
key = forall a. Maybe a
Prelude.Nothing,
      $sel:matchOptions:DimensionValues' :: Maybe [MatchOption]
matchOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:values:DimensionValues' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The names of the metadata types that you can use to filter and group
-- your results. For example, @AZ@ returns a list of Availability Zones.
--
-- Not all dimensions are supported in each API. Refer to the documentation
-- for each specific API to see what is supported.
--
-- @LINK_ACCOUNT_NAME@ and @SERVICE_CODE@ can only be used in
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html CostCategoryRule>.
--
-- @ANOMALY_TOTAL_IMPACT_ABSOLUTE@ and @ANOMALY_TOTAL_IMPACT_PERCENTAGE@
-- can only be used in
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_AnomalySubscription.html AnomalySubscriptions>.
dimensionValues_key :: Lens.Lens' DimensionValues (Prelude.Maybe Dimension)
dimensionValues_key :: Lens' DimensionValues (Maybe Dimension)
dimensionValues_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionValues' {Maybe Dimension
key :: Maybe Dimension
$sel:key:DimensionValues' :: DimensionValues -> Maybe Dimension
key} -> Maybe Dimension
key) (\s :: DimensionValues
s@DimensionValues' {} Maybe Dimension
a -> DimensionValues
s {$sel:key:DimensionValues' :: Maybe Dimension
key = Maybe Dimension
a} :: DimensionValues)

-- | The match options that you can use to filter your results.
--
-- @MatchOptions@ is only applicable for actions related to Cost Category
-- and Anomaly Subscriptions. Refer to the documentation for each specific
-- API to see what is supported.
--
-- The default values for @MatchOptions@ are @EQUALS@ and @CASE_SENSITIVE@.
dimensionValues_matchOptions :: Lens.Lens' DimensionValues (Prelude.Maybe [MatchOption])
dimensionValues_matchOptions :: Lens' DimensionValues (Maybe [MatchOption])
dimensionValues_matchOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionValues' {Maybe [MatchOption]
matchOptions :: Maybe [MatchOption]
$sel:matchOptions:DimensionValues' :: DimensionValues -> Maybe [MatchOption]
matchOptions} -> Maybe [MatchOption]
matchOptions) (\s :: DimensionValues
s@DimensionValues' {} Maybe [MatchOption]
a -> DimensionValues
s {$sel:matchOptions:DimensionValues' :: Maybe [MatchOption]
matchOptions = Maybe [MatchOption]
a} :: DimensionValues) 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 metadata values that you can use to filter and group your results.
-- You can use @GetDimensionValues@ to find specific values.
dimensionValues_values :: Lens.Lens' DimensionValues (Prelude.Maybe [Prelude.Text])
dimensionValues_values :: Lens' DimensionValues (Maybe [Text])
dimensionValues_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionValues' {Maybe [Text]
values :: Maybe [Text]
$sel:values:DimensionValues' :: DimensionValues -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: DimensionValues
s@DimensionValues' {} Maybe [Text]
a -> DimensionValues
s {$sel:values:DimensionValues' :: Maybe [Text]
values = Maybe [Text]
a} :: DimensionValues) 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

instance Data.FromJSON DimensionValues where
  parseJSON :: Value -> Parser DimensionValues
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DimensionValues"
      ( \Object
x ->
          Maybe Dimension
-> Maybe [MatchOption] -> Maybe [Text] -> DimensionValues
DimensionValues'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MatchOptions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= 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 -> Parser (Maybe a)
Data..:? Key
"Values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable DimensionValues where
  hashWithSalt :: Int -> DimensionValues -> Int
hashWithSalt Int
_salt DimensionValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Dimension
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Dimension
$sel:values:DimensionValues' :: DimensionValues -> Maybe [Text]
$sel:matchOptions:DimensionValues' :: DimensionValues -> Maybe [MatchOption]
$sel:key:DimensionValues' :: DimensionValues -> Maybe Dimension
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Dimension
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MatchOption]
matchOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData DimensionValues where
  rnf :: DimensionValues -> ()
rnf DimensionValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Dimension
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Dimension
$sel:values:DimensionValues' :: DimensionValues -> Maybe [Text]
$sel:matchOptions:DimensionValues' :: DimensionValues -> Maybe [MatchOption]
$sel:key:DimensionValues' :: DimensionValues -> Maybe Dimension
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Dimension
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MatchOption]
matchOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

instance Data.ToJSON DimensionValues where
  toJSON :: DimensionValues -> Value
toJSON DimensionValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Dimension
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Dimension
$sel:values:DimensionValues' :: DimensionValues -> Maybe [Text]
$sel:matchOptions:DimensionValues' :: DimensionValues -> Maybe [MatchOption]
$sel:key:DimensionValues' :: DimensionValues -> Maybe Dimension
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Key" 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 Dimension
key,
            (Key
"MatchOptions" 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 [MatchOption]
matchOptions,
            (Key
"Values" 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]
values
          ]
      )