{-# 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.BotLocaleFilter
-- 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.BotLocaleFilter 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.BotLocaleFilterName
import Amazonka.LexV2Models.Types.BotLocaleFilterOperator
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'BotLocaleFilter' 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', 'botLocaleFilter_name' - The name of the field to filter the list of bots.
--
-- 'values', 'botLocaleFilter_values' - The value to use for filtering the list of bots.
--
-- 'operator', 'botLocaleFilter_operator' - The operator to use for the filter. Specify @EQ@ when the
-- @ListBotLocales@ operation should return only aliases that equal the
-- specified value. Specify @CO@ when the @ListBotLocales@ operation should
-- return aliases that contain the specified value.
newBotLocaleFilter ::
  -- | 'name'
  BotLocaleFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'operator'
  BotLocaleFilterOperator ->
  BotLocaleFilter
newBotLocaleFilter :: BotLocaleFilterName
-> NonEmpty Text -> BotLocaleFilterOperator -> BotLocaleFilter
newBotLocaleFilter BotLocaleFilterName
pName_ NonEmpty Text
pValues_ BotLocaleFilterOperator
pOperator_ =
  BotLocaleFilter'
    { $sel:name:BotLocaleFilter' :: BotLocaleFilterName
name = BotLocaleFilterName
pName_,
      $sel:values:BotLocaleFilter' :: 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:BotLocaleFilter' :: BotLocaleFilterOperator
operator = BotLocaleFilterOperator
pOperator_
    }

-- | The name of the field to filter the list of bots.
botLocaleFilter_name :: Lens.Lens' BotLocaleFilter BotLocaleFilterName
botLocaleFilter_name :: Lens' BotLocaleFilter BotLocaleFilterName
botLocaleFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotLocaleFilter' {BotLocaleFilterName
name :: BotLocaleFilterName
$sel:name:BotLocaleFilter' :: BotLocaleFilter -> BotLocaleFilterName
name} -> BotLocaleFilterName
name) (\s :: BotLocaleFilter
s@BotLocaleFilter' {} BotLocaleFilterName
a -> BotLocaleFilter
s {$sel:name:BotLocaleFilter' :: BotLocaleFilterName
name = BotLocaleFilterName
a} :: BotLocaleFilter)

-- | The value to use for filtering the list of bots.
botLocaleFilter_values :: Lens.Lens' BotLocaleFilter (Prelude.NonEmpty Prelude.Text)
botLocaleFilter_values :: Lens' BotLocaleFilter (NonEmpty Text)
botLocaleFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotLocaleFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:BotLocaleFilter' :: BotLocaleFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: BotLocaleFilter
s@BotLocaleFilter' {} NonEmpty Text
a -> BotLocaleFilter
s {$sel:values:BotLocaleFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: BotLocaleFilter) 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
-- @ListBotLocales@ operation should return only aliases that equal the
-- specified value. Specify @CO@ when the @ListBotLocales@ operation should
-- return aliases that contain the specified value.
botLocaleFilter_operator :: Lens.Lens' BotLocaleFilter BotLocaleFilterOperator
botLocaleFilter_operator :: Lens' BotLocaleFilter BotLocaleFilterOperator
botLocaleFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotLocaleFilter' {BotLocaleFilterOperator
operator :: BotLocaleFilterOperator
$sel:operator:BotLocaleFilter' :: BotLocaleFilter -> BotLocaleFilterOperator
operator} -> BotLocaleFilterOperator
operator) (\s :: BotLocaleFilter
s@BotLocaleFilter' {} BotLocaleFilterOperator
a -> BotLocaleFilter
s {$sel:operator:BotLocaleFilter' :: BotLocaleFilterOperator
operator = BotLocaleFilterOperator
a} :: BotLocaleFilter)

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

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

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