{-# 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.Connect.Types.Filters
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Connect.Types.Filters where

import Amazonka.Connect.Types.Channel
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the filter to apply when retrieving metrics.
--
-- /See:/ 'newFilters' smart constructor.
data Filters = Filters'
  { -- | The queues to use to filter the metrics. You can specify up to 100
    -- queues per request.
    Filters -> Maybe (NonEmpty Text)
queues :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The channel to use to filter the metrics.
    Filters -> Maybe [Channel]
channels :: Prelude.Maybe [Channel]
  }
  deriving (Filters -> Filters -> Bool
(Filters -> Filters -> Bool)
-> (Filters -> Filters -> Bool) -> Eq Filters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filters -> Filters -> Bool
$c/= :: Filters -> Filters -> Bool
== :: Filters -> Filters -> Bool
$c== :: Filters -> Filters -> Bool
Prelude.Eq, ReadPrec [Filters]
ReadPrec Filters
Int -> ReadS Filters
ReadS [Filters]
(Int -> ReadS Filters)
-> ReadS [Filters]
-> ReadPrec Filters
-> ReadPrec [Filters]
-> Read Filters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Filters]
$creadListPrec :: ReadPrec [Filters]
readPrec :: ReadPrec Filters
$creadPrec :: ReadPrec Filters
readList :: ReadS [Filters]
$creadList :: ReadS [Filters]
readsPrec :: Int -> ReadS Filters
$creadsPrec :: Int -> ReadS Filters
Prelude.Read, Int -> Filters -> ShowS
[Filters] -> ShowS
Filters -> String
(Int -> Filters -> ShowS)
-> (Filters -> String) -> ([Filters] -> ShowS) -> Show Filters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filters] -> ShowS
$cshowList :: [Filters] -> ShowS
show :: Filters -> String
$cshow :: Filters -> String
showsPrec :: Int -> Filters -> ShowS
$cshowsPrec :: Int -> Filters -> ShowS
Prelude.Show, (forall x. Filters -> Rep Filters x)
-> (forall x. Rep Filters x -> Filters) -> Generic Filters
forall x. Rep Filters x -> Filters
forall x. Filters -> Rep Filters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filters x -> Filters
$cfrom :: forall x. Filters -> Rep Filters x
Prelude.Generic)

-- |
-- Create a value of 'Filters' 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:
--
-- 'queues', 'filters_queues' - The queues to use to filter the metrics. You can specify up to 100
-- queues per request.
--
-- 'channels', 'filters_channels' - The channel to use to filter the metrics.
newFilters ::
  Filters
newFilters :: Filters
newFilters =
  Filters' :: Maybe (NonEmpty Text) -> Maybe [Channel] -> Filters
Filters'
    { $sel:queues:Filters' :: Maybe (NonEmpty Text)
queues = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:channels:Filters' :: Maybe [Channel]
channels = Maybe [Channel]
forall a. Maybe a
Prelude.Nothing
    }

-- | The queues to use to filter the metrics. You can specify up to 100
-- queues per request.
filters_queues :: Lens.Lens' Filters (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
filters_queues :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Filters -> f Filters
filters_queues = (Filters -> Maybe (NonEmpty Text))
-> (Filters -> Maybe (NonEmpty Text) -> Filters)
-> Lens
     Filters Filters (Maybe (NonEmpty Text)) (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filters' {Maybe (NonEmpty Text)
queues :: Maybe (NonEmpty Text)
$sel:queues:Filters' :: Filters -> Maybe (NonEmpty Text)
queues} -> Maybe (NonEmpty Text)
queues) (\s :: Filters
s@Filters' {} Maybe (NonEmpty Text)
a -> Filters
s {$sel:queues:Filters' :: Maybe (NonEmpty Text)
queues = Maybe (NonEmpty Text)
a} :: Filters) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> Filters -> f Filters)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Filters
-> f Filters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The channel to use to filter the metrics.
filters_channels :: Lens.Lens' Filters (Prelude.Maybe [Channel])
filters_channels :: (Maybe [Channel] -> f (Maybe [Channel])) -> Filters -> f Filters
filters_channels = (Filters -> Maybe [Channel])
-> (Filters -> Maybe [Channel] -> Filters)
-> Lens Filters Filters (Maybe [Channel]) (Maybe [Channel])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filters' {Maybe [Channel]
channels :: Maybe [Channel]
$sel:channels:Filters' :: Filters -> Maybe [Channel]
channels} -> Maybe [Channel]
channels) (\s :: Filters
s@Filters' {} Maybe [Channel]
a -> Filters
s {$sel:channels:Filters' :: Maybe [Channel]
channels = Maybe [Channel]
a} :: Filters) ((Maybe [Channel] -> f (Maybe [Channel])) -> Filters -> f Filters)
-> ((Maybe [Channel] -> f (Maybe [Channel]))
    -> Maybe [Channel] -> f (Maybe [Channel]))
-> (Maybe [Channel] -> f (Maybe [Channel]))
-> Filters
-> f Filters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Channel] [Channel] [Channel] [Channel]
-> Iso
     (Maybe [Channel])
     (Maybe [Channel])
     (Maybe [Channel])
     (Maybe [Channel])
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 AnIso [Channel] [Channel] [Channel] [Channel]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable Filters

instance Prelude.NFData Filters

instance Core.ToJSON Filters where
  toJSON :: Filters -> Value
toJSON Filters' {Maybe [Channel]
Maybe (NonEmpty Text)
channels :: Maybe [Channel]
queues :: Maybe (NonEmpty Text)
$sel:channels:Filters' :: Filters -> Maybe [Channel]
$sel:queues:Filters' :: Filters -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Queues" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
queues,
            (Text
"Channels" Text -> [Channel] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Channel] -> Pair) -> Maybe [Channel] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Channel]
channels
          ]
      )