{-# 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.SlotTypeFilter
-- 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.SlotTypeFilter 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.SlotTypeFilterName
import Amazonka.LexV2Models.Types.SlotTypeFilterOperator
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'SlotTypeFilter' 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', 'slotTypeFilter_name' - The name of the field to use for filtering.
--
-- 'values', 'slotTypeFilter_values' - The value to use to filter the response.
--
-- 'operator', 'slotTypeFilter_operator' - The operator to use for the filter. Specify @EQ@ when the
-- @ListSlotTypes@ operation should return only aliases that equal the
-- specified value. Specify @CO@ when the @ListSlotTypes@ operation should
-- return aliases that contain the specified value.
newSlotTypeFilter ::
  -- | 'name'
  SlotTypeFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'operator'
  SlotTypeFilterOperator ->
  SlotTypeFilter
newSlotTypeFilter :: SlotTypeFilterName
-> NonEmpty Text -> SlotTypeFilterOperator -> SlotTypeFilter
newSlotTypeFilter SlotTypeFilterName
pName_ NonEmpty Text
pValues_ SlotTypeFilterOperator
pOperator_ =
  SlotTypeFilter'
    { $sel:name:SlotTypeFilter' :: SlotTypeFilterName
name = SlotTypeFilterName
pName_,
      $sel:values:SlotTypeFilter' :: 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:SlotTypeFilter' :: SlotTypeFilterOperator
operator = SlotTypeFilterOperator
pOperator_
    }

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

-- | The value to use to filter the response.
slotTypeFilter_values :: Lens.Lens' SlotTypeFilter (Prelude.NonEmpty Prelude.Text)
slotTypeFilter_values :: Lens' SlotTypeFilter (NonEmpty Text)
slotTypeFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:SlotTypeFilter' :: SlotTypeFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: SlotTypeFilter
s@SlotTypeFilter' {} NonEmpty Text
a -> SlotTypeFilter
s {$sel:values:SlotTypeFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: SlotTypeFilter) 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
-- @ListSlotTypes@ operation should return only aliases that equal the
-- specified value. Specify @CO@ when the @ListSlotTypes@ operation should
-- return aliases that contain the specified value.
slotTypeFilter_operator :: Lens.Lens' SlotTypeFilter SlotTypeFilterOperator
slotTypeFilter_operator :: Lens' SlotTypeFilter SlotTypeFilterOperator
slotTypeFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeFilter' {SlotTypeFilterOperator
operator :: SlotTypeFilterOperator
$sel:operator:SlotTypeFilter' :: SlotTypeFilter -> SlotTypeFilterOperator
operator} -> SlotTypeFilterOperator
operator) (\s :: SlotTypeFilter
s@SlotTypeFilter' {} SlotTypeFilterOperator
a -> SlotTypeFilter
s {$sel:operator:SlotTypeFilter' :: SlotTypeFilterOperator
operator = SlotTypeFilterOperator
a} :: SlotTypeFilter)

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

instance Prelude.NFData SlotTypeFilter where
  rnf :: SlotTypeFilter -> ()
rnf SlotTypeFilter' {NonEmpty Text
SlotTypeFilterName
SlotTypeFilterOperator
operator :: SlotTypeFilterOperator
values :: NonEmpty Text
name :: SlotTypeFilterName
$sel:operator:SlotTypeFilter' :: SlotTypeFilter -> SlotTypeFilterOperator
$sel:values:SlotTypeFilter' :: SlotTypeFilter -> NonEmpty Text
$sel:name:SlotTypeFilter' :: SlotTypeFilter -> SlotTypeFilterName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf SlotTypeFilterName
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 SlotTypeFilterOperator
operator

instance Data.ToJSON SlotTypeFilter where
  toJSON :: SlotTypeFilter -> Value
toJSON SlotTypeFilter' {NonEmpty Text
SlotTypeFilterName
SlotTypeFilterOperator
operator :: SlotTypeFilterOperator
values :: NonEmpty Text
name :: SlotTypeFilterName
$sel:operator:SlotTypeFilter' :: SlotTypeFilter -> SlotTypeFilterOperator
$sel:values:SlotTypeFilter' :: SlotTypeFilter -> NonEmpty Text
$sel:name:SlotTypeFilter' :: SlotTypeFilter -> SlotTypeFilterName
..} =
    [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..= SlotTypeFilterName
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..= SlotTypeFilterOperator
operator)
          ]
      )