{-# 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-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)
module Amazonka.CostExplorer.Types.DimensionValues where

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.Dimension
import Amazonka.CostExplorer.Types.MatchOption
import qualified Amazonka.Lens as Lens
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 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],
    -- | 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.
    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.
    -- The default values for @MatchOptions@ are @EQUALS@ and @CASE_SENSITIVE@.
    DimensionValues -> Maybe [MatchOption]
matchOptions :: Prelude.Maybe [MatchOption]
  }
  deriving (DimensionValues -> DimensionValues -> Bool
(DimensionValues -> DimensionValues -> Bool)
-> (DimensionValues -> DimensionValues -> Bool)
-> Eq DimensionValues
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]
(Int -> ReadS DimensionValues)
-> ReadS [DimensionValues]
-> ReadPrec DimensionValues
-> ReadPrec [DimensionValues]
-> Read 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
(Int -> DimensionValues -> ShowS)
-> (DimensionValues -> String)
-> ([DimensionValues] -> ShowS)
-> Show DimensionValues
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. DimensionValues -> Rep DimensionValues x)
-> (forall x. Rep DimensionValues x -> DimensionValues)
-> Generic DimensionValues
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:
--
-- 'values', 'dimensionValues_values' - The metadata values that you can use to filter and group your results.
-- You can use @GetDimensionValues@ to find specific values.
--
-- '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.
--
-- 'matchOptions', 'dimensionValues_matchOptions' - The match options that you can use to filter your results.
-- @MatchOptions@ is only applicable for actions related to Cost Category.
-- The default values for @MatchOptions@ are @EQUALS@ and @CASE_SENSITIVE@.
newDimensionValues ::
  DimensionValues
newDimensionValues :: DimensionValues
newDimensionValues =
  DimensionValues' :: Maybe [Text]
-> Maybe Dimension -> Maybe [MatchOption] -> DimensionValues
DimensionValues'
    { $sel:values:DimensionValues' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:DimensionValues' :: Maybe Dimension
key = Maybe Dimension
forall a. Maybe a
Prelude.Nothing,
      $sel:matchOptions:DimensionValues' :: Maybe [MatchOption]
matchOptions = Maybe [MatchOption]
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text]))
-> DimensionValues -> f DimensionValues
dimensionValues_values = (DimensionValues -> Maybe [Text])
-> (DimensionValues -> Maybe [Text] -> DimensionValues)
-> Lens
     DimensionValues DimensionValues (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> DimensionValues -> f DimensionValues)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DimensionValues
-> f DimensionValues
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 names of the metadata types that you can use to filter and group
-- your results. For example, @AZ@ returns a list of Availability Zones.
dimensionValues_key :: Lens.Lens' DimensionValues (Prelude.Maybe Dimension)
dimensionValues_key :: (Maybe Dimension -> f (Maybe Dimension))
-> DimensionValues -> f DimensionValues
dimensionValues_key = (DimensionValues -> Maybe Dimension)
-> (DimensionValues -> Maybe Dimension -> DimensionValues)
-> Lens
     DimensionValues DimensionValues (Maybe Dimension) (Maybe Dimension)
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.
-- The default values for @MatchOptions@ are @EQUALS@ and @CASE_SENSITIVE@.
dimensionValues_matchOptions :: Lens.Lens' DimensionValues (Prelude.Maybe [MatchOption])
dimensionValues_matchOptions :: (Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> DimensionValues -> f DimensionValues
dimensionValues_matchOptions = (DimensionValues -> Maybe [MatchOption])
-> (DimensionValues -> Maybe [MatchOption] -> DimensionValues)
-> Lens
     DimensionValues
     DimensionValues
     (Maybe [MatchOption])
     (Maybe [MatchOption])
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) ((Maybe [MatchOption] -> f (Maybe [MatchOption]))
 -> DimensionValues -> f DimensionValues)
-> ((Maybe [MatchOption] -> f (Maybe [MatchOption]))
    -> Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> (Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> DimensionValues
-> f DimensionValues
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [MatchOption] [MatchOption] [MatchOption] [MatchOption]
-> Iso
     (Maybe [MatchOption])
     (Maybe [MatchOption])
     (Maybe [MatchOption])
     (Maybe [MatchOption])
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 [MatchOption] [MatchOption] [MatchOption] [MatchOption]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable DimensionValues

instance Prelude.NFData DimensionValues

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