{-# 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.Discovery.Types.TagFilter
-- 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.Discovery.Types.TagFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The tag filter. Valid names are: @tagKey@, @tagValue@,
-- @configurationId@.
--
-- /See:/ 'newTagFilter' smart constructor.
data TagFilter = TagFilter'
  { -- | A name of the tag filter.
    TagFilter -> Text
name :: Prelude.Text,
    -- | Values for the tag filter.
    TagFilter -> [Text]
values :: [Prelude.Text]
  }
  deriving (TagFilter -> TagFilter -> Bool
(TagFilter -> TagFilter -> Bool)
-> (TagFilter -> TagFilter -> Bool) -> Eq TagFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagFilter -> TagFilter -> Bool
$c/= :: TagFilter -> TagFilter -> Bool
== :: TagFilter -> TagFilter -> Bool
$c== :: TagFilter -> TagFilter -> Bool
Prelude.Eq, ReadPrec [TagFilter]
ReadPrec TagFilter
Int -> ReadS TagFilter
ReadS [TagFilter]
(Int -> ReadS TagFilter)
-> ReadS [TagFilter]
-> ReadPrec TagFilter
-> ReadPrec [TagFilter]
-> Read TagFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagFilter]
$creadListPrec :: ReadPrec [TagFilter]
readPrec :: ReadPrec TagFilter
$creadPrec :: ReadPrec TagFilter
readList :: ReadS [TagFilter]
$creadList :: ReadS [TagFilter]
readsPrec :: Int -> ReadS TagFilter
$creadsPrec :: Int -> ReadS TagFilter
Prelude.Read, Int -> TagFilter -> ShowS
[TagFilter] -> ShowS
TagFilter -> String
(Int -> TagFilter -> ShowS)
-> (TagFilter -> String)
-> ([TagFilter] -> ShowS)
-> Show TagFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagFilter] -> ShowS
$cshowList :: [TagFilter] -> ShowS
show :: TagFilter -> String
$cshow :: TagFilter -> String
showsPrec :: Int -> TagFilter -> ShowS
$cshowsPrec :: Int -> TagFilter -> ShowS
Prelude.Show, (forall x. TagFilter -> Rep TagFilter x)
-> (forall x. Rep TagFilter x -> TagFilter) -> Generic TagFilter
forall x. Rep TagFilter x -> TagFilter
forall x. TagFilter -> Rep TagFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagFilter x -> TagFilter
$cfrom :: forall x. TagFilter -> Rep TagFilter x
Prelude.Generic)

-- |
-- Create a value of 'TagFilter' 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:
--
-- 'name', 'tagFilter_name' - A name of the tag filter.
--
-- 'values', 'tagFilter_values' - Values for the tag filter.
newTagFilter ::
  -- | 'name'
  Prelude.Text ->
  TagFilter
newTagFilter :: Text -> TagFilter
newTagFilter Text
pName_ =
  TagFilter' :: Text -> [Text] -> TagFilter
TagFilter' {$sel:name:TagFilter' :: Text
name = Text
pName_, $sel:values:TagFilter' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | A name of the tag filter.
tagFilter_name :: Lens.Lens' TagFilter Prelude.Text
tagFilter_name :: (Text -> f Text) -> TagFilter -> f TagFilter
tagFilter_name = (TagFilter -> Text)
-> (TagFilter -> Text -> TagFilter)
-> Lens TagFilter TagFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagFilter' {Text
name :: Text
$sel:name:TagFilter' :: TagFilter -> Text
name} -> Text
name) (\s :: TagFilter
s@TagFilter' {} Text
a -> TagFilter
s {$sel:name:TagFilter' :: Text
name = Text
a} :: TagFilter)

-- | Values for the tag filter.
tagFilter_values :: Lens.Lens' TagFilter [Prelude.Text]
tagFilter_values :: ([Text] -> f [Text]) -> TagFilter -> f TagFilter
tagFilter_values = (TagFilter -> [Text])
-> (TagFilter -> [Text] -> TagFilter)
-> Lens TagFilter TagFilter [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagFilter' {[Text]
values :: [Text]
$sel:values:TagFilter' :: TagFilter -> [Text]
values} -> [Text]
values) (\s :: TagFilter
s@TagFilter' {} [Text]
a -> TagFilter
s {$sel:values:TagFilter' :: [Text]
values = [Text]
a} :: TagFilter) (([Text] -> f [Text]) -> TagFilter -> f TagFilter)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> TagFilter
-> f TagFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable TagFilter

instance Prelude.NFData TagFilter

instance Core.ToJSON TagFilter where
  toJSON :: TagFilter -> Value
toJSON TagFilter' {[Text]
Text
values :: [Text]
name :: Text
$sel:values:TagFilter' :: TagFilter -> [Text]
$sel:name:TagFilter' :: TagFilter -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
values)
          ]
      )