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

-- |
-- Create a value of 'TagValues' 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', 'tagValues_key' - The key for the tag.
--
-- 'matchOptions', 'tagValues_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@.
--
-- 'values', 'tagValues_values' - The specific value of the tag.
newTagValues ::
  TagValues
newTagValues :: TagValues
newTagValues =
  TagValues'
    { $sel:key:TagValues' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:matchOptions:TagValues' :: Maybe [MatchOption]
matchOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:values:TagValues' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The key for the tag.
tagValues_key :: Lens.Lens' TagValues (Prelude.Maybe Prelude.Text)
tagValues_key :: Lens' TagValues (Maybe Text)
tagValues_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagValues' {Maybe Text
key :: Maybe Text
$sel:key:TagValues' :: TagValues -> Maybe Text
key} -> Maybe Text
key) (\s :: TagValues
s@TagValues' {} Maybe Text
a -> TagValues
s {$sel:key:TagValues' :: Maybe Text
key = Maybe Text
a} :: TagValues)

-- | 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@.
tagValues_matchOptions :: Lens.Lens' TagValues (Prelude.Maybe [MatchOption])
tagValues_matchOptions :: Lens' TagValues (Maybe [MatchOption])
tagValues_matchOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagValues' {Maybe [MatchOption]
matchOptions :: Maybe [MatchOption]
$sel:matchOptions:TagValues' :: TagValues -> Maybe [MatchOption]
matchOptions} -> Maybe [MatchOption]
matchOptions) (\s :: TagValues
s@TagValues' {} Maybe [MatchOption]
a -> TagValues
s {$sel:matchOptions:TagValues' :: Maybe [MatchOption]
matchOptions = Maybe [MatchOption]
a} :: TagValues) 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 tag.
tagValues_values :: Lens.Lens' TagValues (Prelude.Maybe [Prelude.Text])
tagValues_values :: Lens' TagValues (Maybe [Text])
tagValues_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagValues' {Maybe [Text]
values :: Maybe [Text]
$sel:values:TagValues' :: TagValues -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: TagValues
s@TagValues' {} Maybe [Text]
a -> TagValues
s {$sel:values:TagValues' :: Maybe [Text]
values = Maybe [Text]
a} :: TagValues) 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 TagValues where
  parseJSON :: Value -> Parser TagValues
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TagValues"
      ( \Object
x ->
          Maybe Text -> Maybe [MatchOption] -> Maybe [Text] -> TagValues
TagValues'
            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 TagValues where
  hashWithSalt :: Int -> TagValues -> Int
hashWithSalt Int
_salt TagValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
$sel:values:TagValues' :: TagValues -> Maybe [Text]
$sel:matchOptions:TagValues' :: TagValues -> Maybe [MatchOption]
$sel:key:TagValues' :: TagValues -> 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 TagValues where
  rnf :: TagValues -> ()
rnf TagValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
$sel:values:TagValues' :: TagValues -> Maybe [Text]
$sel:matchOptions:TagValues' :: TagValues -> Maybe [MatchOption]
$sel:key:TagValues' :: TagValues -> 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 TagValues where
  toJSON :: TagValues -> Value
toJSON TagValues' {Maybe [Text]
Maybe [MatchOption]
Maybe Text
values :: Maybe [Text]
matchOptions :: Maybe [MatchOption]
key :: Maybe Text
$sel:values:TagValues' :: TagValues -> Maybe [Text]
$sel:matchOptions:TagValues' :: TagValues -> Maybe [MatchOption]
$sel:key:TagValues' :: TagValues -> 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
          ]
      )