{-# 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.CostCategoryValues
-- 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.CostCategoryValues where

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

-- | The Cost Categories values used for filtering the costs.
--
-- If @Values@ and @Key@ are not specified, the @ABSENT@ @MatchOption@ is
-- applied to all Cost Categories. That is, it filters on resources that
-- aren\'t mapped to any Cost Categories.
--
-- If @Values@ is provided and @Key@ isn\'t specified, the @ABSENT@
-- @MatchOption@ is applied to the Cost Categories @Key@ only. That is, it
-- filters on resources without the given Cost Categories key.
--
-- /See:/ 'newCostCategoryValues' smart constructor.
data CostCategoryValues = CostCategoryValues'
  { CostCategoryValues -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | 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@ is @EQUALS@ and @CASE_SENSITIVE@.
    CostCategoryValues -> Maybe [MatchOption]
matchOptions :: Prelude.Maybe [MatchOption],
    -- | The specific value of the Cost Category.
    CostCategoryValues -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (CostCategoryValues -> CostCategoryValues -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CostCategoryValues -> CostCategoryValues -> Bool
$c/= :: CostCategoryValues -> CostCategoryValues -> Bool
== :: CostCategoryValues -> CostCategoryValues -> Bool
$c== :: CostCategoryValues -> CostCategoryValues -> Bool
Prelude.Eq, ReadPrec [CostCategoryValues]
ReadPrec CostCategoryValues
Int -> ReadS CostCategoryValues
ReadS [CostCategoryValues]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CostCategoryValues]
$creadListPrec :: ReadPrec [CostCategoryValues]
readPrec :: ReadPrec CostCategoryValues
$creadPrec :: ReadPrec CostCategoryValues
readList :: ReadS [CostCategoryValues]
$creadList :: ReadS [CostCategoryValues]
readsPrec :: Int -> ReadS CostCategoryValues
$creadsPrec :: Int -> ReadS CostCategoryValues
Prelude.Read, Int -> CostCategoryValues -> ShowS
[CostCategoryValues] -> ShowS
CostCategoryValues -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CostCategoryValues] -> ShowS
$cshowList :: [CostCategoryValues] -> ShowS
show :: CostCategoryValues -> String
$cshow :: CostCategoryValues -> String
showsPrec :: Int -> CostCategoryValues -> ShowS
$cshowsPrec :: Int -> CostCategoryValues -> ShowS
Prelude.Show, forall x. Rep CostCategoryValues x -> CostCategoryValues
forall x. CostCategoryValues -> Rep CostCategoryValues x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CostCategoryValues x -> CostCategoryValues
$cfrom :: forall x. CostCategoryValues -> Rep CostCategoryValues x
Prelude.Generic)

-- |
-- Create a value of 'CostCategoryValues' 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', 'costCategoryValues_key' - Undocumented member.
--
-- 'matchOptions', 'costCategoryValues_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@ is @EQUALS@ and @CASE_SENSITIVE@.
--
-- 'values', 'costCategoryValues_values' - The specific value of the Cost Category.
newCostCategoryValues ::
  CostCategoryValues
newCostCategoryValues :: CostCategoryValues
newCostCategoryValues =
  CostCategoryValues'
    { $sel:key:CostCategoryValues' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:matchOptions:CostCategoryValues' :: Maybe [MatchOption]
matchOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:values:CostCategoryValues' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
costCategoryValues_key :: Lens.Lens' CostCategoryValues (Prelude.Maybe Prelude.Text)
costCategoryValues_key :: Lens' CostCategoryValues (Maybe Text)
costCategoryValues_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryValues' {Maybe Text
key :: Maybe Text
$sel:key:CostCategoryValues' :: CostCategoryValues -> Maybe Text
key} -> Maybe Text
key) (\s :: CostCategoryValues
s@CostCategoryValues' {} Maybe Text
a -> CostCategoryValues
s {$sel:key:CostCategoryValues' :: Maybe Text
key = Maybe Text
a} :: CostCategoryValues)

-- | 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@ is @EQUALS@ and @CASE_SENSITIVE@.
costCategoryValues_matchOptions :: Lens.Lens' CostCategoryValues (Prelude.Maybe [MatchOption])
costCategoryValues_matchOptions :: Lens' CostCategoryValues (Maybe [MatchOption])
costCategoryValues_matchOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryValues' {Maybe [MatchOption]
matchOptions :: Maybe [MatchOption]
$sel:matchOptions:CostCategoryValues' :: CostCategoryValues -> Maybe [MatchOption]
matchOptions} -> Maybe [MatchOption]
matchOptions) (\s :: CostCategoryValues
s@CostCategoryValues' {} Maybe [MatchOption]
a -> CostCategoryValues
s {$sel:matchOptions:CostCategoryValues' :: Maybe [MatchOption]
matchOptions = Maybe [MatchOption]
a} :: CostCategoryValues) 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 specific value of the Cost Category.
costCategoryValues_values :: Lens.Lens' CostCategoryValues (Prelude.Maybe [Prelude.Text])
costCategoryValues_values :: Lens' CostCategoryValues (Maybe [Text])
costCategoryValues_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryValues' {Maybe [Text]
values :: Maybe [Text]
$sel:values:CostCategoryValues' :: CostCategoryValues -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: CostCategoryValues
s@CostCategoryValues' {} Maybe [Text]
a -> CostCategoryValues
s {$sel:values:CostCategoryValues' :: Maybe [Text]
values = Maybe [Text]
a} :: CostCategoryValues) 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 CostCategoryValues where
  parseJSON :: Value -> Parser CostCategoryValues
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CostCategoryValues"
      ( \Object
x ->
          Maybe Text
-> Maybe [MatchOption] -> Maybe [Text] -> CostCategoryValues
CostCategoryValues'
            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 CostCategoryValues where
  hashWithSalt :: Int -> CostCategoryValues -> Int
hashWithSalt Int
_salt CostCategoryValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
$sel:values:CostCategoryValues' :: CostCategoryValues -> Maybe [Text]
$sel:matchOptions:CostCategoryValues' :: CostCategoryValues -> Maybe [MatchOption]
$sel:key:CostCategoryValues' :: CostCategoryValues -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
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 CostCategoryValues where
  rnf :: CostCategoryValues -> ()
rnf CostCategoryValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
$sel:values:CostCategoryValues' :: CostCategoryValues -> Maybe [Text]
$sel:matchOptions:CostCategoryValues' :: CostCategoryValues -> Maybe [MatchOption]
$sel:key:CostCategoryValues' :: CostCategoryValues -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
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 CostCategoryValues where
  toJSON :: CostCategoryValues -> Value
toJSON CostCategoryValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
$sel:values:CostCategoryValues' :: CostCategoryValues -> Maybe [Text]
$sel:matchOptions:CostCategoryValues' :: CostCategoryValues -> Maybe [MatchOption]
$sel:key:CostCategoryValues' :: CostCategoryValues -> Maybe Text
..} =
    [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 Text
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
          ]
      )