{-# 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.LexV2Models.Types.SlotFilter
-- 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.LexV2Models.Types.SlotFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.SlotFilterName
import Amazonka.LexV2Models.Types.SlotFilterOperator
import qualified Amazonka.Prelude as Prelude

-- | Filters the response from the @ListSlots@ operation.
--
-- /See:/ 'newSlotFilter' smart constructor.
data SlotFilter = SlotFilter'
  { -- | The name of the field to use for filtering.
    SlotFilter -> SlotFilterName
name :: SlotFilterName,
    -- | The value to use to filter the response.
    SlotFilter -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text,
    -- | The operator to use for the filter. Specify @EQ@ when the @ListSlots@
    -- operation should return only aliases that equal the specified value.
    -- Specify @CO@ when the @ListSlots@ operation should return aliases that
    -- contain the specified value.
    SlotFilter -> SlotFilterOperator
operator :: SlotFilterOperator
  }
  deriving (SlotFilter -> SlotFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotFilter -> SlotFilter -> Bool
$c/= :: SlotFilter -> SlotFilter -> Bool
== :: SlotFilter -> SlotFilter -> Bool
$c== :: SlotFilter -> SlotFilter -> Bool
Prelude.Eq, ReadPrec [SlotFilter]
ReadPrec SlotFilter
Int -> ReadS SlotFilter
ReadS [SlotFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotFilter]
$creadListPrec :: ReadPrec [SlotFilter]
readPrec :: ReadPrec SlotFilter
$creadPrec :: ReadPrec SlotFilter
readList :: ReadS [SlotFilter]
$creadList :: ReadS [SlotFilter]
readsPrec :: Int -> ReadS SlotFilter
$creadsPrec :: Int -> ReadS SlotFilter
Prelude.Read, Int -> SlotFilter -> ShowS
[SlotFilter] -> ShowS
SlotFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotFilter] -> ShowS
$cshowList :: [SlotFilter] -> ShowS
show :: SlotFilter -> String
$cshow :: SlotFilter -> String
showsPrec :: Int -> SlotFilter -> ShowS
$cshowsPrec :: Int -> SlotFilter -> ShowS
Prelude.Show, forall x. Rep SlotFilter x -> SlotFilter
forall x. SlotFilter -> Rep SlotFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotFilter x -> SlotFilter
$cfrom :: forall x. SlotFilter -> Rep SlotFilter x
Prelude.Generic)

-- |
-- Create a value of 'SlotFilter' 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', 'slotFilter_name' - The name of the field to use for filtering.
--
-- 'values', 'slotFilter_values' - The value to use to filter the response.
--
-- 'operator', 'slotFilter_operator' - The operator to use for the filter. Specify @EQ@ when the @ListSlots@
-- operation should return only aliases that equal the specified value.
-- Specify @CO@ when the @ListSlots@ operation should return aliases that
-- contain the specified value.
newSlotFilter ::
  -- | 'name'
  SlotFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'operator'
  SlotFilterOperator ->
  SlotFilter
newSlotFilter :: SlotFilterName -> NonEmpty Text -> SlotFilterOperator -> SlotFilter
newSlotFilter SlotFilterName
pName_ NonEmpty Text
pValues_ SlotFilterOperator
pOperator_ =
  SlotFilter'
    { $sel:name:SlotFilter' :: SlotFilterName
name = SlotFilterName
pName_,
      $sel:values:SlotFilter' :: 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_,
      $sel:operator:SlotFilter' :: SlotFilterOperator
operator = SlotFilterOperator
pOperator_
    }

-- | The name of the field to use for filtering.
slotFilter_name :: Lens.Lens' SlotFilter SlotFilterName
slotFilter_name :: Lens' SlotFilter SlotFilterName
slotFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotFilter' {SlotFilterName
name :: SlotFilterName
$sel:name:SlotFilter' :: SlotFilter -> SlotFilterName
name} -> SlotFilterName
name) (\s :: SlotFilter
s@SlotFilter' {} SlotFilterName
a -> SlotFilter
s {$sel:name:SlotFilter' :: SlotFilterName
name = SlotFilterName
a} :: SlotFilter)

-- | The value to use to filter the response.
slotFilter_values :: Lens.Lens' SlotFilter (Prelude.NonEmpty Prelude.Text)
slotFilter_values :: Lens' SlotFilter (NonEmpty Text)
slotFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:SlotFilter' :: SlotFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: SlotFilter
s@SlotFilter' {} NonEmpty Text
a -> SlotFilter
s {$sel:values:SlotFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: SlotFilter) 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

-- | The operator to use for the filter. Specify @EQ@ when the @ListSlots@
-- operation should return only aliases that equal the specified value.
-- Specify @CO@ when the @ListSlots@ operation should return aliases that
-- contain the specified value.
slotFilter_operator :: Lens.Lens' SlotFilter SlotFilterOperator
slotFilter_operator :: Lens' SlotFilter SlotFilterOperator
slotFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotFilter' {SlotFilterOperator
operator :: SlotFilterOperator
$sel:operator:SlotFilter' :: SlotFilter -> SlotFilterOperator
operator} -> SlotFilterOperator
operator) (\s :: SlotFilter
s@SlotFilter' {} SlotFilterOperator
a -> SlotFilter
s {$sel:operator:SlotFilter' :: SlotFilterOperator
operator = SlotFilterOperator
a} :: SlotFilter)

instance Prelude.Hashable SlotFilter where
  hashWithSalt :: Int -> SlotFilter -> Int
hashWithSalt Int
_salt SlotFilter' {NonEmpty Text
SlotFilterName
SlotFilterOperator
operator :: SlotFilterOperator
values :: NonEmpty Text
name :: SlotFilterName
$sel:operator:SlotFilter' :: SlotFilter -> SlotFilterOperator
$sel:values:SlotFilter' :: SlotFilter -> NonEmpty Text
$sel:name:SlotFilter' :: SlotFilter -> SlotFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SlotFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SlotFilterOperator
operator

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

instance Data.ToJSON SlotFilter where
  toJSON :: SlotFilter -> Value
toJSON SlotFilter' {NonEmpty Text
SlotFilterName
SlotFilterOperator
operator :: SlotFilterOperator
values :: NonEmpty Text
name :: SlotFilterName
$sel:operator:SlotFilter' :: SlotFilter -> SlotFilterOperator
$sel:values:SlotFilter' :: SlotFilter -> NonEmpty Text
$sel:name:SlotFilter' :: SlotFilter -> SlotFilterName
..} =
    [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..= SlotFilterName
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
values),
            forall a. a -> Maybe a
Prelude.Just (Key
"operator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SlotFilterOperator
operator)
          ]
      )