{-# 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-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.TagValues 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 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 @Values@ is provided and @Key@ 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 specific value of the tag.
    TagValues -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | 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]
  }
  deriving (TagValues -> TagValues -> Bool
(TagValues -> TagValues -> Bool)
-> (TagValues -> TagValues -> Bool) -> Eq TagValues
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]
(Int -> ReadS TagValues)
-> ReadS [TagValues]
-> ReadPrec TagValues
-> ReadPrec [TagValues]
-> Read 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
(Int -> TagValues -> ShowS)
-> (TagValues -> String)
-> ([TagValues] -> ShowS)
-> Show TagValues
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. TagValues -> Rep TagValues x)
-> (forall x. Rep TagValues x -> TagValues) -> Generic TagValues
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:
--
-- 'values', 'tagValues_values' - The specific value of the tag.
--
-- '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@.
newTagValues ::
  TagValues
newTagValues :: TagValues
newTagValues =
  TagValues' :: Maybe [Text] -> Maybe Text -> Maybe [MatchOption] -> TagValues
TagValues'
    { $sel:values:TagValues' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:TagValues' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:matchOptions:TagValues' :: Maybe [MatchOption]
matchOptions = Maybe [MatchOption]
forall a. Maybe a
Prelude.Nothing
    }

-- | The specific value of the tag.
tagValues_values :: Lens.Lens' TagValues (Prelude.Maybe [Prelude.Text])
tagValues_values :: (Maybe [Text] -> f (Maybe [Text])) -> TagValues -> f TagValues
tagValues_values = (TagValues -> Maybe [Text])
-> (TagValues -> Maybe [Text] -> TagValues)
-> Lens TagValues TagValues (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> TagValues -> f TagValues)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> TagValues
-> f TagValues
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 key for the tag.
tagValues_key :: Lens.Lens' TagValues (Prelude.Maybe Prelude.Text)
tagValues_key :: (Maybe Text -> f (Maybe Text)) -> TagValues -> f TagValues
tagValues_key = (TagValues -> Maybe Text)
-> (TagValues -> Maybe Text -> TagValues)
-> Lens TagValues TagValues (Maybe Text) (Maybe Text)
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 :: (Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> TagValues -> f TagValues
tagValues_matchOptions = (TagValues -> Maybe [MatchOption])
-> (TagValues -> Maybe [MatchOption] -> TagValues)
-> Lens
     TagValues TagValues (Maybe [MatchOption]) (Maybe [MatchOption])
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) ((Maybe [MatchOption] -> f (Maybe [MatchOption]))
 -> TagValues -> f TagValues)
-> ((Maybe [MatchOption] -> f (Maybe [MatchOption]))
    -> Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> (Maybe [MatchOption] -> f (Maybe [MatchOption]))
-> TagValues
-> f TagValues
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 TagValues where
  parseJSON :: Value -> Parser TagValues
parseJSON =
    String -> (Object -> Parser TagValues) -> Value -> Parser TagValues
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TagValues"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> Maybe [MatchOption] -> TagValues
TagValues'
            (Maybe [Text] -> Maybe Text -> Maybe [MatchOption] -> TagValues)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe [MatchOption] -> TagValues)
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] -> TagValues)
-> Parser (Maybe Text) -> Parser (Maybe [MatchOption] -> TagValues)
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] -> TagValues)
-> Parser (Maybe [MatchOption]) -> Parser TagValues
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 TagValues

instance Prelude.NFData TagValues

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