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

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.MatchOption
import qualified Amazonka.Lens as Lens
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'
  { -- | The specific value of the Cost Category.
    CostCategoryValues -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    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]
  }
  deriving (CostCategoryValues -> CostCategoryValues -> Bool
(CostCategoryValues -> CostCategoryValues -> Bool)
-> (CostCategoryValues -> CostCategoryValues -> Bool)
-> Eq CostCategoryValues
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]
(Int -> ReadS CostCategoryValues)
-> ReadS [CostCategoryValues]
-> ReadPrec CostCategoryValues
-> ReadPrec [CostCategoryValues]
-> Read 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
(Int -> CostCategoryValues -> ShowS)
-> (CostCategoryValues -> String)
-> ([CostCategoryValues] -> ShowS)
-> Show CostCategoryValues
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. CostCategoryValues -> Rep CostCategoryValues x)
-> (forall x. Rep CostCategoryValues x -> CostCategoryValues)
-> Generic CostCategoryValues
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:
--
-- 'values', 'costCategoryValues_values' - The specific value of the Cost Category.
--
-- '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@.
newCostCategoryValues ::
  CostCategoryValues
newCostCategoryValues :: CostCategoryValues
newCostCategoryValues =
  CostCategoryValues' :: Maybe [Text]
-> Maybe Text -> Maybe [MatchOption] -> CostCategoryValues
CostCategoryValues'
    { $sel:values:CostCategoryValues' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:CostCategoryValues' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:matchOptions:CostCategoryValues' :: Maybe [MatchOption]
matchOptions = Maybe [MatchOption]
forall a. Maybe a
Prelude.Nothing
    }

-- | The specific value of the Cost Category.
costCategoryValues_values :: Lens.Lens' CostCategoryValues (Prelude.Maybe [Prelude.Text])
costCategoryValues_values :: (Maybe [Text] -> f (Maybe [Text]))
-> CostCategoryValues -> f CostCategoryValues
costCategoryValues_values = (CostCategoryValues -> Maybe [Text])
-> (CostCategoryValues -> Maybe [Text] -> CostCategoryValues)
-> Lens
     CostCategoryValues CostCategoryValues (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> CostCategoryValues -> f CostCategoryValues)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CostCategoryValues
-> f CostCategoryValues
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

-- | Undocumented member.
costCategoryValues_key :: Lens.Lens' CostCategoryValues (Prelude.Maybe Prelude.Text)
costCategoryValues_key :: (Maybe Text -> f (Maybe Text))
-> CostCategoryValues -> f CostCategoryValues
costCategoryValues_key = (CostCategoryValues -> Maybe Text)
-> (CostCategoryValues -> Maybe Text -> CostCategoryValues)
-> Lens
     CostCategoryValues CostCategoryValues (Maybe Text) (Maybe Text)
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 :: (Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> CostCategoryValues -> f CostCategoryValues
costCategoryValues_matchOptions = (CostCategoryValues -> Maybe [MatchOption])
-> (CostCategoryValues
    -> Maybe [MatchOption] -> CostCategoryValues)
-> Lens
     CostCategoryValues
     CostCategoryValues
     (Maybe [MatchOption])
     (Maybe [MatchOption])
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) ((Maybe [MatchOption] -> f (Maybe [MatchOption]))
 -> CostCategoryValues -> f CostCategoryValues)
-> ((Maybe [MatchOption] -> f (Maybe [MatchOption]))
    -> Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> (Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> CostCategoryValues
-> f CostCategoryValues
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 CostCategoryValues where
  parseJSON :: Value -> Parser CostCategoryValues
parseJSON =
    String
-> (Object -> Parser CostCategoryValues)
-> Value
-> Parser CostCategoryValues
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CostCategoryValues"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text -> Maybe [MatchOption] -> CostCategoryValues
CostCategoryValues'
            (Maybe [Text]
 -> Maybe Text -> Maybe [MatchOption] -> CostCategoryValues)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe [MatchOption] -> CostCategoryValues)
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 Text -> Maybe [MatchOption] -> CostCategoryValues)
-> Parser (Maybe Text)
-> Parser (Maybe [MatchOption] -> CostCategoryValues)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Key")
            Parser (Maybe [MatchOption] -> CostCategoryValues)
-> Parser (Maybe [MatchOption]) -> Parser CostCategoryValues
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 CostCategoryValues

instance Prelude.NFData CostCategoryValues

instance Core.ToJSON CostCategoryValues where
  toJSON :: CostCategoryValues -> Value
toJSON CostCategoryValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
values :: Maybe [Text]
$sel:matchOptions:CostCategoryValues' :: CostCategoryValues -> Maybe [MatchOption]
$sel:key:CostCategoryValues' :: CostCategoryValues -> Maybe Text
$sel:values:CostCategoryValues' :: CostCategoryValues -> 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 -> 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
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
          ]
      )