{-# 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.Personalize.Types.Filter
-- 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.Personalize.Types.Filter where

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

-- | Contains information on a recommendation filter, including its ARN,
-- status, and filter expression.
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | If the filter failed, the reason for its failure.
    Filter -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | The status of the filter.
    Filter -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | Specifies the type of item interactions to filter out of recommendation
    -- results. The filter expression must follow specific format rules. For
    -- information about filter expression structure and syntax, see
    -- filter-expressions.
    Filter -> Maybe (Sensitive Text)
filterExpression :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The time at which the filter was last updated.
    Filter -> Maybe POSIX
lastUpdatedDateTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the filter.
    Filter -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the filter.
    Filter -> Maybe Text
filterArn :: Prelude.Maybe Prelude.Text,
    -- | The time at which the filter was created.
    Filter -> Maybe POSIX
creationDateTime :: Prelude.Maybe Core.POSIX,
    -- | The ARN of the dataset group to which the filter belongs.
    Filter -> Maybe Text
datasetGroupArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Filter -> Filter -> Bool
(Filter -> Filter -> Bool)
-> (Filter -> Filter -> Bool) -> Eq Filter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filter -> Filter -> Bool
$c/= :: Filter -> Filter -> Bool
== :: Filter -> Filter -> Bool
$c== :: Filter -> Filter -> Bool
Prelude.Eq, Int -> Filter -> ShowS
[Filter] -> ShowS
Filter -> String
(Int -> Filter -> ShowS)
-> (Filter -> String) -> ([Filter] -> ShowS) -> Show Filter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filter] -> ShowS
$cshowList :: [Filter] -> ShowS
show :: Filter -> String
$cshow :: Filter -> String
showsPrec :: Int -> Filter -> ShowS
$cshowsPrec :: Int -> Filter -> ShowS
Prelude.Show, (forall x. Filter -> Rep Filter x)
-> (forall x. Rep Filter x -> Filter) -> Generic Filter
forall x. Rep Filter x -> Filter
forall x. Filter -> Rep Filter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filter x -> Filter
$cfrom :: forall x. Filter -> Rep Filter x
Prelude.Generic)

-- |
-- Create a value of 'Filter' 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:
--
-- 'failureReason', 'filter_failureReason' - If the filter failed, the reason for its failure.
--
-- 'status', 'filter_status' - The status of the filter.
--
-- 'filterExpression', 'filter_filterExpression' - Specifies the type of item interactions to filter out of recommendation
-- results. The filter expression must follow specific format rules. For
-- information about filter expression structure and syntax, see
-- filter-expressions.
--
-- 'lastUpdatedDateTime', 'filter_lastUpdatedDateTime' - The time at which the filter was last updated.
--
-- 'name', 'filter_name' - The name of the filter.
--
-- 'filterArn', 'filter_filterArn' - The ARN of the filter.
--
-- 'creationDateTime', 'filter_creationDateTime' - The time at which the filter was created.
--
-- 'datasetGroupArn', 'filter_datasetGroupArn' - The ARN of the dataset group to which the filter belongs.
newFilter ::
  Filter
newFilter :: Filter
newFilter =
  Filter' :: Maybe Text
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Filter
Filter'
    { $sel:failureReason:Filter' :: Maybe Text
failureReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:Filter' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filterExpression:Filter' :: Maybe (Sensitive Text)
filterExpression = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedDateTime:Filter' :: Maybe POSIX
lastUpdatedDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Filter' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filterArn:Filter' :: Maybe Text
filterArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDateTime:Filter' :: Maybe POSIX
creationDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:datasetGroupArn:Filter' :: Maybe Text
datasetGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | If the filter failed, the reason for its failure.
filter_failureReason :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_failureReason :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_failureReason = (Filter -> Maybe Text)
-> (Filter -> Maybe Text -> Filter)
-> Lens Filter Filter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:Filter' :: Filter -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:failureReason:Filter' :: Maybe Text
failureReason = Maybe Text
a} :: Filter)

-- | The status of the filter.
filter_status :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_status :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_status = (Filter -> Maybe Text)
-> (Filter -> Maybe Text -> Filter)
-> Lens Filter Filter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
status :: Maybe Text
$sel:status:Filter' :: Filter -> Maybe Text
status} -> Maybe Text
status) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:status:Filter' :: Maybe Text
status = Maybe Text
a} :: Filter)

-- | Specifies the type of item interactions to filter out of recommendation
-- results. The filter expression must follow specific format rules. For
-- information about filter expression structure and syntax, see
-- filter-expressions.
filter_filterExpression :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_filterExpression :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_filterExpression = (Filter -> Maybe (Sensitive Text))
-> (Filter -> Maybe (Sensitive Text) -> Filter)
-> Lens
     Filter Filter (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe (Sensitive Text)
filterExpression :: Maybe (Sensitive Text)
$sel:filterExpression:Filter' :: Filter -> Maybe (Sensitive Text)
filterExpression} -> Maybe (Sensitive Text)
filterExpression) (\s :: Filter
s@Filter' {} Maybe (Sensitive Text)
a -> Filter
s {$sel:filterExpression:Filter' :: Maybe (Sensitive Text)
filterExpression = Maybe (Sensitive Text)
a} :: Filter) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Filter -> f Filter)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Filter
-> f Filter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The time at which the filter was last updated.
filter_lastUpdatedDateTime :: Lens.Lens' Filter (Prelude.Maybe Prelude.UTCTime)
filter_lastUpdatedDateTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Filter -> f Filter
filter_lastUpdatedDateTime = (Filter -> Maybe POSIX)
-> (Filter -> Maybe POSIX -> Filter)
-> Lens Filter Filter (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe POSIX
lastUpdatedDateTime :: Maybe POSIX
$sel:lastUpdatedDateTime:Filter' :: Filter -> Maybe POSIX
lastUpdatedDateTime} -> Maybe POSIX
lastUpdatedDateTime) (\s :: Filter
s@Filter' {} Maybe POSIX
a -> Filter
s {$sel:lastUpdatedDateTime:Filter' :: Maybe POSIX
lastUpdatedDateTime = Maybe POSIX
a} :: Filter) ((Maybe POSIX -> f (Maybe POSIX)) -> Filter -> f Filter)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Filter
-> f Filter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the filter.
filter_name :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_name :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_name = (Filter -> Maybe Text)
-> (Filter -> Maybe Text -> Filter)
-> Lens Filter Filter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
name :: Maybe Text
$sel:name:Filter' :: Filter -> Maybe Text
name} -> Maybe Text
name) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:name:Filter' :: Maybe Text
name = Maybe Text
a} :: Filter)

-- | The ARN of the filter.
filter_filterArn :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_filterArn :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_filterArn = (Filter -> Maybe Text)
-> (Filter -> Maybe Text -> Filter)
-> Lens Filter Filter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
filterArn :: Maybe Text
$sel:filterArn:Filter' :: Filter -> Maybe Text
filterArn} -> Maybe Text
filterArn) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:filterArn:Filter' :: Maybe Text
filterArn = Maybe Text
a} :: Filter)

-- | The time at which the filter was created.
filter_creationDateTime :: Lens.Lens' Filter (Prelude.Maybe Prelude.UTCTime)
filter_creationDateTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Filter -> f Filter
filter_creationDateTime = (Filter -> Maybe POSIX)
-> (Filter -> Maybe POSIX -> Filter)
-> Lens Filter Filter (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:creationDateTime:Filter' :: Filter -> Maybe POSIX
creationDateTime} -> Maybe POSIX
creationDateTime) (\s :: Filter
s@Filter' {} Maybe POSIX
a -> Filter
s {$sel:creationDateTime:Filter' :: Maybe POSIX
creationDateTime = Maybe POSIX
a} :: Filter) ((Maybe POSIX -> f (Maybe POSIX)) -> Filter -> f Filter)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Filter
-> f Filter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ARN of the dataset group to which the filter belongs.
filter_datasetGroupArn :: Lens.Lens' Filter (Prelude.Maybe Prelude.Text)
filter_datasetGroupArn :: (Maybe Text -> f (Maybe Text)) -> Filter -> f Filter
filter_datasetGroupArn = (Filter -> Maybe Text)
-> (Filter -> Maybe Text -> Filter)
-> Lens Filter Filter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe Text
datasetGroupArn :: Maybe Text
$sel:datasetGroupArn:Filter' :: Filter -> Maybe Text
datasetGroupArn} -> Maybe Text
datasetGroupArn) (\s :: Filter
s@Filter' {} Maybe Text
a -> Filter
s {$sel:datasetGroupArn:Filter' :: Maybe Text
datasetGroupArn = Maybe Text
a} :: Filter)

instance Core.FromJSON Filter where
  parseJSON :: Value -> Parser Filter
parseJSON =
    String -> (Object -> Parser Filter) -> Value -> Parser Filter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Filter"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Filter
Filter'
            (Maybe Text
 -> Maybe Text
 -> Maybe (Sensitive Text)
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Filter)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (Sensitive Text)
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Filter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failureReason")
            Parser
  (Maybe Text
   -> Maybe (Sensitive Text)
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Filter)
-> Parser (Maybe Text)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Filter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Filter)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe Text -> Maybe POSIX -> Maybe Text -> Filter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"filterExpression")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe Text -> Maybe POSIX -> Maybe Text -> Filter)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe POSIX -> Maybe Text -> Filter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdatedDateTime")
            Parser
  (Maybe Text -> Maybe Text -> Maybe POSIX -> Maybe Text -> Filter)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> Filter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
            Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> Filter)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> Filter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"filterArn")
            Parser (Maybe POSIX -> Maybe Text -> Filter)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> Filter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationDateTime")
            Parser (Maybe Text -> Filter)
-> Parser (Maybe Text) -> Parser Filter
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"datasetGroupArn")
      )

instance Prelude.Hashable Filter

instance Prelude.NFData Filter