{-# 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.BotFilter
-- 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.BotFilter 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.BotFilterName
import Amazonka.LexV2Models.Types.BotFilterOperator
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'BotFilter' 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', 'botFilter_name' - The name of the field to filter the list of bots.
--
-- 'values', 'botFilter_values' - The value to use for filtering the list of bots.
--
-- 'operator', 'botFilter_operator' - The operator to use for the filter. Specify @EQ@ when the @ListBots@
-- operation should return only aliases that equal the specified value.
-- Specify @CO@ when the @ListBots@ operation should return aliases that
-- contain the specified value.
newBotFilter ::
  -- | 'name'
  BotFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'operator'
  BotFilterOperator ->
  BotFilter
newBotFilter :: BotFilterName -> NonEmpty Text -> BotFilterOperator -> BotFilter
newBotFilter BotFilterName
pName_ NonEmpty Text
pValues_ BotFilterOperator
pOperator_ =
  BotFilter'
    { $sel:name:BotFilter' :: BotFilterName
name = BotFilterName
pName_,
      $sel:values:BotFilter' :: 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:BotFilter' :: BotFilterOperator
operator = BotFilterOperator
pOperator_
    }

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

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

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

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

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