{-# 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.IoT.Types.IndexingFilter
-- 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.IoT.Types.IndexingFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Provides additional filters for specific data sources. Named shadow is
-- the only data source that currently supports and requires a filter. To
-- add named shadows to your fleet indexing configuration, set
-- @namedShadowIndexingMode@ to be @ON@ and specify your shadow names in
-- @filter@.
--
-- /See:/ 'newIndexingFilter' smart constructor.
data IndexingFilter = IndexingFilter'
  { -- | The shadow names that you select to index. The default maximum number of
    -- shadow names for indexing is 10. To increase the limit, see
    -- <https://docs.aws.amazon.com/general/latest/gr/iot_device_management.html#fleet-indexing-limits Amazon Web Services IoT Device Management Quotas>
    -- in the /Amazon Web Services General Reference/.
    IndexingFilter -> Maybe [Text]
namedShadowNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (IndexingFilter -> IndexingFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IndexingFilter -> IndexingFilter -> Bool
$c/= :: IndexingFilter -> IndexingFilter -> Bool
== :: IndexingFilter -> IndexingFilter -> Bool
$c== :: IndexingFilter -> IndexingFilter -> Bool
Prelude.Eq, ReadPrec [IndexingFilter]
ReadPrec IndexingFilter
Int -> ReadS IndexingFilter
ReadS [IndexingFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IndexingFilter]
$creadListPrec :: ReadPrec [IndexingFilter]
readPrec :: ReadPrec IndexingFilter
$creadPrec :: ReadPrec IndexingFilter
readList :: ReadS [IndexingFilter]
$creadList :: ReadS [IndexingFilter]
readsPrec :: Int -> ReadS IndexingFilter
$creadsPrec :: Int -> ReadS IndexingFilter
Prelude.Read, Int -> IndexingFilter -> ShowS
[IndexingFilter] -> ShowS
IndexingFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IndexingFilter] -> ShowS
$cshowList :: [IndexingFilter] -> ShowS
show :: IndexingFilter -> String
$cshow :: IndexingFilter -> String
showsPrec :: Int -> IndexingFilter -> ShowS
$cshowsPrec :: Int -> IndexingFilter -> ShowS
Prelude.Show, forall x. Rep IndexingFilter x -> IndexingFilter
forall x. IndexingFilter -> Rep IndexingFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IndexingFilter x -> IndexingFilter
$cfrom :: forall x. IndexingFilter -> Rep IndexingFilter x
Prelude.Generic)

-- |
-- Create a value of 'IndexingFilter' 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:
--
-- 'namedShadowNames', 'indexingFilter_namedShadowNames' - The shadow names that you select to index. The default maximum number of
-- shadow names for indexing is 10. To increase the limit, see
-- <https://docs.aws.amazon.com/general/latest/gr/iot_device_management.html#fleet-indexing-limits Amazon Web Services IoT Device Management Quotas>
-- in the /Amazon Web Services General Reference/.
newIndexingFilter ::
  IndexingFilter
newIndexingFilter :: IndexingFilter
newIndexingFilter =
  IndexingFilter' {$sel:namedShadowNames:IndexingFilter' :: Maybe [Text]
namedShadowNames = forall a. Maybe a
Prelude.Nothing}

-- | The shadow names that you select to index. The default maximum number of
-- shadow names for indexing is 10. To increase the limit, see
-- <https://docs.aws.amazon.com/general/latest/gr/iot_device_management.html#fleet-indexing-limits Amazon Web Services IoT Device Management Quotas>
-- in the /Amazon Web Services General Reference/.
indexingFilter_namedShadowNames :: Lens.Lens' IndexingFilter (Prelude.Maybe [Prelude.Text])
indexingFilter_namedShadowNames :: Lens' IndexingFilter (Maybe [Text])
indexingFilter_namedShadowNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IndexingFilter' {Maybe [Text]
namedShadowNames :: Maybe [Text]
$sel:namedShadowNames:IndexingFilter' :: IndexingFilter -> Maybe [Text]
namedShadowNames} -> Maybe [Text]
namedShadowNames) (\s :: IndexingFilter
s@IndexingFilter' {} Maybe [Text]
a -> IndexingFilter
s {$sel:namedShadowNames:IndexingFilter' :: Maybe [Text]
namedShadowNames = Maybe [Text]
a} :: IndexingFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON IndexingFilter where
  parseJSON :: Value -> Parser IndexingFilter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IndexingFilter"
      ( \Object
x ->
          Maybe [Text] -> IndexingFilter
IndexingFilter'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"namedShadowNames"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable IndexingFilter where
  hashWithSalt :: Int -> IndexingFilter -> Int
hashWithSalt Int
_salt IndexingFilter' {Maybe [Text]
namedShadowNames :: Maybe [Text]
$sel:namedShadowNames:IndexingFilter' :: IndexingFilter -> Maybe [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
namedShadowNames

instance Prelude.NFData IndexingFilter where
  rnf :: IndexingFilter -> ()
rnf IndexingFilter' {Maybe [Text]
namedShadowNames :: Maybe [Text]
$sel:namedShadowNames:IndexingFilter' :: IndexingFilter -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
namedShadowNames

instance Data.ToJSON IndexingFilter where
  toJSON :: IndexingFilter -> Value
toJSON IndexingFilter' {Maybe [Text]
namedShadowNames :: Maybe [Text]
$sel:namedShadowNames:IndexingFilter' :: IndexingFilter -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"namedShadowNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
namedShadowNames
          ]
      )