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

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

-- | A filter name and value pair that is used to return more specific
-- results from a describe operation. Filters can be used to match a set of
-- resources by specific criteria, such as tags, attributes, or IDs.
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | The name of an attribute to use as a filter.
    Filter -> Maybe Text
attribute :: Prelude.Maybe Prelude.Text,
    -- | The type of search (For example, eq, geq, leq)
    Filter -> Maybe Text
operation :: Prelude.Maybe Prelude.Text,
    -- | Value of the filter.
    Filter -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (Filter -> Filter -> Bool
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, ReadPrec [Filter]
ReadPrec Filter
Int -> ReadS Filter
ReadS [Filter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Filter]
$creadListPrec :: ReadPrec [Filter]
readPrec :: ReadPrec Filter
$creadPrec :: ReadPrec Filter
readList :: ReadS [Filter]
$creadList :: ReadS [Filter]
readsPrec :: Int -> ReadS Filter
$creadsPrec :: Int -> ReadS Filter
Prelude.Read, Int -> Filter -> ShowS
[Filter] -> ShowS
Filter -> String
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. 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:
--
-- 'attribute', 'filter_attribute' - The name of an attribute to use as a filter.
--
-- 'operation', 'filter_operation' - The type of search (For example, eq, geq, leq)
--
-- 'value', 'filter_value' - Value of the filter.
newFilter ::
  Filter
newFilter :: Filter
newFilter =
  Filter'
    { $sel:attribute:Filter' :: Maybe Text
attribute = forall a. Maybe a
Prelude.Nothing,
      $sel:operation:Filter' :: Maybe Text
operation = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Filter' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of an attribute to use as a filter.
filter_attribute :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_attribute :: Lens' Filter (Maybe Text)
filter_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
attribute :: Maybe Text
$sel:attribute:Filter' :: Filter -> Maybe Text
attribute} -> Maybe Text
attribute) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:attribute:Filter' :: Maybe Text
attribute = Maybe Text
a} :: Filter)

-- | The type of search (For example, eq, geq, leq)
filter_operation :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_operation :: Lens' Filter (Maybe Text)
filter_operation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
operation :: Maybe Text
$sel:operation:Filter' :: Filter -> Maybe Text
operation} -> Maybe Text
operation) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:operation:Filter' :: Maybe Text
operation = Maybe Text
a} :: Filter)

-- | Value of the filter.
filter_value :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_value :: Lens' Filter (Maybe Text)
filter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
value :: Maybe Text
$sel:value:Filter' :: Filter -> Maybe Text
value} -> Maybe Text
value) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:value:Filter' :: Maybe Text
value = Maybe Text
a} :: Filter)

instance Prelude.Hashable Filter where
  hashWithSalt :: Int -> Filter -> Int
hashWithSalt Int
_salt Filter' {Maybe Text
value :: Maybe Text
operation :: Maybe Text
attribute :: Maybe Text
$sel:value:Filter' :: Filter -> Maybe Text
$sel:operation:Filter' :: Filter -> Maybe Text
$sel:attribute:Filter' :: Filter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData Filter where
  rnf :: Filter -> ()
rnf Filter' {Maybe Text
value :: Maybe Text
operation :: Maybe Text
attribute :: Maybe Text
$sel:value:Filter' :: Filter -> Maybe Text
$sel:operation:Filter' :: Filter -> Maybe Text
$sel:attribute:Filter' :: Filter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON Filter where
  toJSON :: Filter -> Value
toJSON Filter' {Maybe Text
value :: Maybe Text
operation :: Maybe Text
attribute :: Maybe Text
$sel:value:Filter' :: Filter -> Maybe Text
$sel:operation:Filter' :: Filter -> Maybe Text
$sel:attribute:Filter' :: Filter -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Attribute" 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
attribute,
            (Key
"Operation" 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
operation,
            (Key
"Value" 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
value
          ]
      )