{-# 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.PinpointSmsVoiceV2.Types.PoolFilter
-- 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.PinpointSmsVoiceV2.Types.PoolFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.PinpointSmsVoiceV2.Types.PoolFilterName
import qualified Amazonka.Prelude as Prelude

-- | The information for a pool that meets a specified criteria.
--
-- /See:/ 'newPoolFilter' smart constructor.
data PoolFilter = PoolFilter'
  { -- | The name of the attribute to filter on.
    PoolFilter -> PoolFilterName
name :: PoolFilterName,
    -- | An array values to filter for.
    PoolFilter -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text
  }
  deriving (PoolFilter -> PoolFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PoolFilter -> PoolFilter -> Bool
$c/= :: PoolFilter -> PoolFilter -> Bool
== :: PoolFilter -> PoolFilter -> Bool
$c== :: PoolFilter -> PoolFilter -> Bool
Prelude.Eq, ReadPrec [PoolFilter]
ReadPrec PoolFilter
Int -> ReadS PoolFilter
ReadS [PoolFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PoolFilter]
$creadListPrec :: ReadPrec [PoolFilter]
readPrec :: ReadPrec PoolFilter
$creadPrec :: ReadPrec PoolFilter
readList :: ReadS [PoolFilter]
$creadList :: ReadS [PoolFilter]
readsPrec :: Int -> ReadS PoolFilter
$creadsPrec :: Int -> ReadS PoolFilter
Prelude.Read, Int -> PoolFilter -> ShowS
[PoolFilter] -> ShowS
PoolFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PoolFilter] -> ShowS
$cshowList :: [PoolFilter] -> ShowS
show :: PoolFilter -> String
$cshow :: PoolFilter -> String
showsPrec :: Int -> PoolFilter -> ShowS
$cshowsPrec :: Int -> PoolFilter -> ShowS
Prelude.Show, forall x. Rep PoolFilter x -> PoolFilter
forall x. PoolFilter -> Rep PoolFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PoolFilter x -> PoolFilter
$cfrom :: forall x. PoolFilter -> Rep PoolFilter x
Prelude.Generic)

-- |
-- Create a value of 'PoolFilter' 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', 'poolFilter_name' - The name of the attribute to filter on.
--
-- 'values', 'poolFilter_values' - An array values to filter for.
newPoolFilter ::
  -- | 'name'
  PoolFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  PoolFilter
newPoolFilter :: PoolFilterName -> NonEmpty Text -> PoolFilter
newPoolFilter PoolFilterName
pName_ NonEmpty Text
pValues_ =
  PoolFilter'
    { $sel:name:PoolFilter' :: PoolFilterName
name = PoolFilterName
pName_,
      $sel:values:PoolFilter' :: NonEmpty Text
values = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pValues_
    }

-- | The name of the attribute to filter on.
poolFilter_name :: Lens.Lens' PoolFilter PoolFilterName
poolFilter_name :: Lens' PoolFilter PoolFilterName
poolFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PoolFilter' {PoolFilterName
name :: PoolFilterName
$sel:name:PoolFilter' :: PoolFilter -> PoolFilterName
name} -> PoolFilterName
name) (\s :: PoolFilter
s@PoolFilter' {} PoolFilterName
a -> PoolFilter
s {$sel:name:PoolFilter' :: PoolFilterName
name = PoolFilterName
a} :: PoolFilter)

-- | An array values to filter for.
poolFilter_values :: Lens.Lens' PoolFilter (Prelude.NonEmpty Prelude.Text)
poolFilter_values :: Lens' PoolFilter (NonEmpty Text)
poolFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PoolFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:PoolFilter' :: PoolFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: PoolFilter
s@PoolFilter' {} NonEmpty Text
a -> PoolFilter
s {$sel:values:PoolFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: PoolFilter) 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 PoolFilter where
  hashWithSalt :: Int -> PoolFilter -> Int
hashWithSalt Int
_salt PoolFilter' {NonEmpty Text
PoolFilterName
values :: NonEmpty Text
name :: PoolFilterName
$sel:values:PoolFilter' :: PoolFilter -> NonEmpty Text
$sel:name:PoolFilter' :: PoolFilter -> PoolFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PoolFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
values

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

instance Data.ToJSON PoolFilter where
  toJSON :: PoolFilter -> Value
toJSON PoolFilter' {NonEmpty Text
PoolFilterName
values :: NonEmpty Text
name :: PoolFilterName
$sel:values:PoolFilter' :: PoolFilter -> NonEmpty Text
$sel:name:PoolFilter' :: PoolFilter -> PoolFilterName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PoolFilterName
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
values)
          ]
      )