{-# 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.ImportFilter
-- 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.ImportFilter 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.ImportFilterName
import Amazonka.LexV2Models.Types.ImportFilterOperator
import qualified Amazonka.Prelude as Prelude

-- | Filters the response from the
-- <https://docs.aws.amazon.com/lexv2/latest/dg/API_ListImports.html ListImports>
-- operation.
--
-- /See:/ 'newImportFilter' smart constructor.
data ImportFilter = ImportFilter'
  { -- | The name of the field to use for filtering.
    ImportFilter -> ImportFilterName
name :: ImportFilterName,
    -- | The values to use to filter the response. The values must be @Bot@,
    -- @BotLocale@, or @CustomVocabulary@.
    ImportFilter -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text,
    -- | The operator to use for the filter. Specify EQ when the @ListImports@
    -- operation should return only resource types that equal the specified
    -- value. Specify CO when the @ListImports@ operation should return
    -- resource types that contain the specified value.
    ImportFilter -> ImportFilterOperator
operator :: ImportFilterOperator
  }
  deriving (ImportFilter -> ImportFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportFilter -> ImportFilter -> Bool
$c/= :: ImportFilter -> ImportFilter -> Bool
== :: ImportFilter -> ImportFilter -> Bool
$c== :: ImportFilter -> ImportFilter -> Bool
Prelude.Eq, ReadPrec [ImportFilter]
ReadPrec ImportFilter
Int -> ReadS ImportFilter
ReadS [ImportFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportFilter]
$creadListPrec :: ReadPrec [ImportFilter]
readPrec :: ReadPrec ImportFilter
$creadPrec :: ReadPrec ImportFilter
readList :: ReadS [ImportFilter]
$creadList :: ReadS [ImportFilter]
readsPrec :: Int -> ReadS ImportFilter
$creadsPrec :: Int -> ReadS ImportFilter
Prelude.Read, Int -> ImportFilter -> ShowS
[ImportFilter] -> ShowS
ImportFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportFilter] -> ShowS
$cshowList :: [ImportFilter] -> ShowS
show :: ImportFilter -> String
$cshow :: ImportFilter -> String
showsPrec :: Int -> ImportFilter -> ShowS
$cshowsPrec :: Int -> ImportFilter -> ShowS
Prelude.Show, forall x. Rep ImportFilter x -> ImportFilter
forall x. ImportFilter -> Rep ImportFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportFilter x -> ImportFilter
$cfrom :: forall x. ImportFilter -> Rep ImportFilter x
Prelude.Generic)

-- |
-- Create a value of 'ImportFilter' 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', 'importFilter_name' - The name of the field to use for filtering.
--
-- 'values', 'importFilter_values' - The values to use to filter the response. The values must be @Bot@,
-- @BotLocale@, or @CustomVocabulary@.
--
-- 'operator', 'importFilter_operator' - The operator to use for the filter. Specify EQ when the @ListImports@
-- operation should return only resource types that equal the specified
-- value. Specify CO when the @ListImports@ operation should return
-- resource types that contain the specified value.
newImportFilter ::
  -- | 'name'
  ImportFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'operator'
  ImportFilterOperator ->
  ImportFilter
newImportFilter :: ImportFilterName
-> NonEmpty Text -> ImportFilterOperator -> ImportFilter
newImportFilter ImportFilterName
pName_ NonEmpty Text
pValues_ ImportFilterOperator
pOperator_ =
  ImportFilter'
    { $sel:name:ImportFilter' :: ImportFilterName
name = ImportFilterName
pName_,
      $sel:values:ImportFilter' :: 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:ImportFilter' :: ImportFilterOperator
operator = ImportFilterOperator
pOperator_
    }

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

-- | The values to use to filter the response. The values must be @Bot@,
-- @BotLocale@, or @CustomVocabulary@.
importFilter_values :: Lens.Lens' ImportFilter (Prelude.NonEmpty Prelude.Text)
importFilter_values :: Lens' ImportFilter (NonEmpty Text)
importFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:ImportFilter' :: ImportFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: ImportFilter
s@ImportFilter' {} NonEmpty Text
a -> ImportFilter
s {$sel:values:ImportFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: ImportFilter) 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 @ListImports@
-- operation should return only resource types that equal the specified
-- value. Specify CO when the @ListImports@ operation should return
-- resource types that contain the specified value.
importFilter_operator :: Lens.Lens' ImportFilter ImportFilterOperator
importFilter_operator :: Lens' ImportFilter ImportFilterOperator
importFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportFilter' {ImportFilterOperator
operator :: ImportFilterOperator
$sel:operator:ImportFilter' :: ImportFilter -> ImportFilterOperator
operator} -> ImportFilterOperator
operator) (\s :: ImportFilter
s@ImportFilter' {} ImportFilterOperator
a -> ImportFilter
s {$sel:operator:ImportFilter' :: ImportFilterOperator
operator = ImportFilterOperator
a} :: ImportFilter)

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

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

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