{-# 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.RDS.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.RDS.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 a more specific list
-- of results from a describe operation. Filters can be used to match a set
-- of resources by specific criteria, such as IDs. The filters supported by
-- a describe operation are documented with the describe operation.
--
-- Currently, wildcards are not supported in filters.
--
-- The following actions can be filtered:
--
-- -   @DescribeDBClusterBacktracks@
--
-- -   @DescribeDBClusterEndpoints@
--
-- -   @DescribeDBClusters@
--
-- -   @DescribeDBInstances@
--
-- -   @DescribePendingMaintenanceActions@
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | The name of the filter. Filter names are case-sensitive.
    Filter -> Text
name :: Prelude.Text,
    -- | One or more filter values. Filter values are case-sensitive.
    Filter -> [Text]
values :: [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:
--
-- 'name', 'filter_name' - The name of the filter. Filter names are case-sensitive.
--
-- 'values', 'filter_values' - One or more filter values. Filter values are case-sensitive.
newFilter ::
  -- | 'name'
  Prelude.Text ->
  Filter
newFilter :: Text -> Filter
newFilter Text
pName_ =
  Filter' {$sel:name:Filter' :: Text
name = Text
pName_, $sel:values:Filter' :: [Text]
values = forall a. Monoid a => a
Prelude.mempty}

-- | The name of the filter. Filter names are case-sensitive.
filter_name :: Lens.Lens' Filter Prelude.Text
filter_name :: Lens' Filter Text
filter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Text
name :: Text
$sel:name:Filter' :: Filter -> Text
name} -> Text
name) (\s :: Filter
s@Filter' {} Text
a -> Filter
s {$sel:name:Filter' :: Text
name = Text
a} :: Filter)

-- | One or more filter values. Filter values are case-sensitive.
filter_values :: Lens.Lens' Filter [Prelude.Text]
filter_values :: Lens' Filter [Text]
filter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {[Text]
values :: [Text]
$sel:values:Filter' :: Filter -> [Text]
values} -> [Text]
values) (\s :: Filter
s@Filter' {} [Text]
a -> Filter
s {$sel:values:Filter' :: [Text]
values = [Text]
a} :: Filter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable Filter where
  hashWithSalt :: Int -> Filter -> Int
hashWithSalt Int
_salt Filter' {[Text]
Text
values :: [Text]
name :: Text
$sel:values:Filter' :: Filter -> [Text]
$sel:name:Filter' :: Filter -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values

instance Prelude.NFData Filter where
  rnf :: Filter -> ()
rnf Filter' {[Text]
Text
values :: [Text]
name :: Text
$sel:values:Filter' :: Filter -> [Text]
$sel:name:Filter' :: Filter -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
values

instance Data.ToQuery Filter where
  toQuery :: Filter -> QueryString
toQuery Filter' {[Text]
Text
values :: [Text]
name :: Text
$sel:values:Filter' :: Filter -> [Text]
$sel:name:Filter' :: Filter -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Name" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
name,
        ByteString
"Values" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"Value" [Text]
values
      ]