{-# 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.IdentityStore.Types.Filter
-- 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.IdentityStore.Types.Filter where

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

-- | A query filter used by @ListUsers@ and @ListGroup@. This filter object
-- provides the attribute name and attribute value to search users or
-- groups.
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | The attribute path that is used to specify which attribute name to
    -- search. Length limit is 255 characters. For example, @UserName@ is a
    -- valid attribute path for the @ListUsers@ API, and @DisplayName@ is a
    -- valid attribute path for the @ListGroups@ API.
    Filter -> Text
attributePath :: Prelude.Text,
    -- | Represents the data for an attribute. Each attribute value is described
    -- as a name-value pair.
    Filter -> Sensitive Text
attributeValue :: Core.Sensitive Prelude.Text
  }
  deriving (Filter -> Filter -> Bool
(Filter -> Filter -> Bool)
-> (Filter -> Filter -> Bool) -> Eq Filter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filter -> Filter -> Bool
$c/= :: Filter -> Filter -> Bool
== :: Filter -> Filter -> Bool
$c== :: Filter -> Filter -> Bool
Prelude.Eq, Int -> Filter -> ShowS
[Filter] -> ShowS
Filter -> String
(Int -> Filter -> ShowS)
-> (Filter -> String) -> ([Filter] -> ShowS) -> Show Filter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filter] -> ShowS
$cshowList :: [Filter] -> ShowS
show :: Filter -> String
$cshow :: Filter -> String
showsPrec :: Int -> Filter -> ShowS
$cshowsPrec :: Int -> Filter -> ShowS
Prelude.Show, (forall x. Filter -> Rep Filter x)
-> (forall x. Rep Filter x -> Filter) -> Generic Filter
forall x. Rep Filter x -> Filter
forall x. Filter -> Rep Filter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filter x -> Filter
$cfrom :: forall x. Filter -> Rep Filter x
Prelude.Generic)

-- |
-- Create a value of 'Filter' 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:
--
-- 'attributePath', 'filter_attributePath' - The attribute path that is used to specify which attribute name to
-- search. Length limit is 255 characters. For example, @UserName@ is a
-- valid attribute path for the @ListUsers@ API, and @DisplayName@ is a
-- valid attribute path for the @ListGroups@ API.
--
-- 'attributeValue', 'filter_attributeValue' - Represents the data for an attribute. Each attribute value is described
-- as a name-value pair.
newFilter ::
  -- | 'attributePath'
  Prelude.Text ->
  -- | 'attributeValue'
  Prelude.Text ->
  Filter
newFilter :: Text -> Text -> Filter
newFilter Text
pAttributePath_ Text
pAttributeValue_ =
  Filter' :: Text -> Sensitive Text -> Filter
Filter'
    { $sel:attributePath:Filter' :: Text
attributePath = Text
pAttributePath_,
      $sel:attributeValue:Filter' :: Sensitive Text
attributeValue =
        Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAttributeValue_
    }

-- | The attribute path that is used to specify which attribute name to
-- search. Length limit is 255 characters. For example, @UserName@ is a
-- valid attribute path for the @ListUsers@ API, and @DisplayName@ is a
-- valid attribute path for the @ListGroups@ API.
filter_attributePath :: Lens.Lens' Filter Prelude.Text
filter_attributePath :: (Text -> f Text) -> Filter -> f Filter
filter_attributePath = (Filter -> Text)
-> (Filter -> Text -> Filter) -> Lens Filter Filter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Text
attributePath :: Text
$sel:attributePath:Filter' :: Filter -> Text
attributePath} -> Text
attributePath) (\s :: Filter
s@Filter' {} Text
a -> Filter
s {$sel:attributePath:Filter' :: Text
attributePath = Text
a} :: Filter)

-- | Represents the data for an attribute. Each attribute value is described
-- as a name-value pair.
filter_attributeValue :: Lens.Lens' Filter Prelude.Text
filter_attributeValue :: (Text -> f Text) -> Filter -> f Filter
filter_attributeValue = (Filter -> Sensitive Text)
-> (Filter -> Sensitive Text -> Filter)
-> Lens Filter Filter (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Sensitive Text
attributeValue :: Sensitive Text
$sel:attributeValue:Filter' :: Filter -> Sensitive Text
attributeValue} -> Sensitive Text
attributeValue) (\s :: Filter
s@Filter' {} Sensitive Text
a -> Filter
s {$sel:attributeValue:Filter' :: Sensitive Text
attributeValue = Sensitive Text
a} :: Filter) ((Sensitive Text -> f (Sensitive Text)) -> Filter -> f Filter)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> Filter
-> f Filter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Prelude.Hashable Filter

instance Prelude.NFData Filter

instance Core.ToJSON Filter where
  toJSON :: Filter -> Value
toJSON Filter' {Text
Sensitive Text
attributeValue :: Sensitive Text
attributePath :: Text
$sel:attributeValue:Filter' :: Filter -> Sensitive Text
$sel:attributePath:Filter' :: Filter -> 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
"AttributePath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
attributePath),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeValue" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
attributeValue)
          ]
      )