{-# 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.Transcribe.Types.Rule
-- 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.Transcribe.Types.Rule 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
import Amazonka.Transcribe.Types.InterruptionFilter
import Amazonka.Transcribe.Types.NonTalkTimeFilter
import Amazonka.Transcribe.Types.SentimentFilter
import Amazonka.Transcribe.Types.TranscriptFilter

-- | A rule is a set of criteria that you can specify to flag an attribute in
-- your Call Analytics output. Rules define a Call Analytics category.
--
-- Rules can include these parameters: , , , and .
--
-- To learn more about Call Analytics rules and categories, see
-- <https://docs.aws.amazon.com/transcribe/latest/dg/tca-categories-batch.html Creating categories for batch transcriptions>
-- and
-- <https://docs.aws.amazon.com/transcribe/latest/dg/tca-categories-stream.html Creating categories for streaming transcriptions>.
--
-- To learn more about Call Analytics, see
-- <https://docs.aws.amazon.com/transcribe/latest/dg/call-analytics.html Analyzing call center audio with Call Analytics>.
--
-- /See:/ 'newRule' smart constructor.
data Rule = Rule'
  { -- | Flag the presence or absence of interruptions in your Call Analytics
    -- transcription output. Refer to for more detail.
    Rule -> Maybe InterruptionFilter
interruptionFilter :: Prelude.Maybe InterruptionFilter,
    -- | Flag the presence or absence of periods of silence in your Call
    -- Analytics transcription output. Refer to for more detail.
    Rule -> Maybe NonTalkTimeFilter
nonTalkTimeFilter :: Prelude.Maybe NonTalkTimeFilter,
    -- | Flag the presence or absence of specific sentiments in your Call
    -- Analytics transcription output. Refer to for more detail.
    Rule -> Maybe SentimentFilter
sentimentFilter :: Prelude.Maybe SentimentFilter,
    -- | Flag the presence or absence of specific words or phrases in your Call
    -- Analytics transcription output. Refer to for more detail.
    Rule -> Maybe TranscriptFilter
transcriptFilter :: Prelude.Maybe TranscriptFilter
  }
  deriving (Rule -> Rule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c== :: Rule -> Rule -> Bool
Prelude.Eq, ReadPrec [Rule]
ReadPrec Rule
Int -> ReadS Rule
ReadS [Rule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rule]
$creadListPrec :: ReadPrec [Rule]
readPrec :: ReadPrec Rule
$creadPrec :: ReadPrec Rule
readList :: ReadS [Rule]
$creadList :: ReadS [Rule]
readsPrec :: Int -> ReadS Rule
$creadsPrec :: Int -> ReadS Rule
Prelude.Read, Int -> Rule -> ShowS
[Rule] -> ShowS
Rule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rule] -> ShowS
$cshowList :: [Rule] -> ShowS
show :: Rule -> String
$cshow :: Rule -> String
showsPrec :: Int -> Rule -> ShowS
$cshowsPrec :: Int -> Rule -> ShowS
Prelude.Show, forall x. Rep Rule x -> Rule
forall x. Rule -> Rep Rule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rule x -> Rule
$cfrom :: forall x. Rule -> Rep Rule x
Prelude.Generic)

-- |
-- Create a value of 'Rule' 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:
--
-- 'interruptionFilter', 'rule_interruptionFilter' - Flag the presence or absence of interruptions in your Call Analytics
-- transcription output. Refer to for more detail.
--
-- 'nonTalkTimeFilter', 'rule_nonTalkTimeFilter' - Flag the presence or absence of periods of silence in your Call
-- Analytics transcription output. Refer to for more detail.
--
-- 'sentimentFilter', 'rule_sentimentFilter' - Flag the presence or absence of specific sentiments in your Call
-- Analytics transcription output. Refer to for more detail.
--
-- 'transcriptFilter', 'rule_transcriptFilter' - Flag the presence or absence of specific words or phrases in your Call
-- Analytics transcription output. Refer to for more detail.
newRule ::
  Rule
newRule :: Rule
newRule =
  Rule'
    { $sel:interruptionFilter:Rule' :: Maybe InterruptionFilter
interruptionFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:nonTalkTimeFilter:Rule' :: Maybe NonTalkTimeFilter
nonTalkTimeFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:sentimentFilter:Rule' :: Maybe SentimentFilter
sentimentFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:transcriptFilter:Rule' :: Maybe TranscriptFilter
transcriptFilter = forall a. Maybe a
Prelude.Nothing
    }

-- | Flag the presence or absence of interruptions in your Call Analytics
-- transcription output. Refer to for more detail.
rule_interruptionFilter :: Lens.Lens' Rule (Prelude.Maybe InterruptionFilter)
rule_interruptionFilter :: Lens' Rule (Maybe InterruptionFilter)
rule_interruptionFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe InterruptionFilter
interruptionFilter :: Maybe InterruptionFilter
$sel:interruptionFilter:Rule' :: Rule -> Maybe InterruptionFilter
interruptionFilter} -> Maybe InterruptionFilter
interruptionFilter) (\s :: Rule
s@Rule' {} Maybe InterruptionFilter
a -> Rule
s {$sel:interruptionFilter:Rule' :: Maybe InterruptionFilter
interruptionFilter = Maybe InterruptionFilter
a} :: Rule)

-- | Flag the presence or absence of periods of silence in your Call
-- Analytics transcription output. Refer to for more detail.
rule_nonTalkTimeFilter :: Lens.Lens' Rule (Prelude.Maybe NonTalkTimeFilter)
rule_nonTalkTimeFilter :: Lens' Rule (Maybe NonTalkTimeFilter)
rule_nonTalkTimeFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe NonTalkTimeFilter
nonTalkTimeFilter :: Maybe NonTalkTimeFilter
$sel:nonTalkTimeFilter:Rule' :: Rule -> Maybe NonTalkTimeFilter
nonTalkTimeFilter} -> Maybe NonTalkTimeFilter
nonTalkTimeFilter) (\s :: Rule
s@Rule' {} Maybe NonTalkTimeFilter
a -> Rule
s {$sel:nonTalkTimeFilter:Rule' :: Maybe NonTalkTimeFilter
nonTalkTimeFilter = Maybe NonTalkTimeFilter
a} :: Rule)

-- | Flag the presence or absence of specific sentiments in your Call
-- Analytics transcription output. Refer to for more detail.
rule_sentimentFilter :: Lens.Lens' Rule (Prelude.Maybe SentimentFilter)
rule_sentimentFilter :: Lens' Rule (Maybe SentimentFilter)
rule_sentimentFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe SentimentFilter
sentimentFilter :: Maybe SentimentFilter
$sel:sentimentFilter:Rule' :: Rule -> Maybe SentimentFilter
sentimentFilter} -> Maybe SentimentFilter
sentimentFilter) (\s :: Rule
s@Rule' {} Maybe SentimentFilter
a -> Rule
s {$sel:sentimentFilter:Rule' :: Maybe SentimentFilter
sentimentFilter = Maybe SentimentFilter
a} :: Rule)

-- | Flag the presence or absence of specific words or phrases in your Call
-- Analytics transcription output. Refer to for more detail.
rule_transcriptFilter :: Lens.Lens' Rule (Prelude.Maybe TranscriptFilter)
rule_transcriptFilter :: Lens' Rule (Maybe TranscriptFilter)
rule_transcriptFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe TranscriptFilter
transcriptFilter :: Maybe TranscriptFilter
$sel:transcriptFilter:Rule' :: Rule -> Maybe TranscriptFilter
transcriptFilter} -> Maybe TranscriptFilter
transcriptFilter) (\s :: Rule
s@Rule' {} Maybe TranscriptFilter
a -> Rule
s {$sel:transcriptFilter:Rule' :: Maybe TranscriptFilter
transcriptFilter = Maybe TranscriptFilter
a} :: Rule)

instance Data.FromJSON Rule where
  parseJSON :: Value -> Parser Rule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Rule"
      ( \Object
x ->
          Maybe InterruptionFilter
-> Maybe NonTalkTimeFilter
-> Maybe SentimentFilter
-> Maybe TranscriptFilter
-> Rule
Rule'
            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
"InterruptionFilter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NonTalkTimeFilter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SentimentFilter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TranscriptFilter")
      )

instance Prelude.Hashable Rule where
  hashWithSalt :: Int -> Rule -> Int
hashWithSalt Int
_salt Rule' {Maybe NonTalkTimeFilter
Maybe InterruptionFilter
Maybe SentimentFilter
Maybe TranscriptFilter
transcriptFilter :: Maybe TranscriptFilter
sentimentFilter :: Maybe SentimentFilter
nonTalkTimeFilter :: Maybe NonTalkTimeFilter
interruptionFilter :: Maybe InterruptionFilter
$sel:transcriptFilter:Rule' :: Rule -> Maybe TranscriptFilter
$sel:sentimentFilter:Rule' :: Rule -> Maybe SentimentFilter
$sel:nonTalkTimeFilter:Rule' :: Rule -> Maybe NonTalkTimeFilter
$sel:interruptionFilter:Rule' :: Rule -> Maybe InterruptionFilter
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InterruptionFilter
interruptionFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NonTalkTimeFilter
nonTalkTimeFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SentimentFilter
sentimentFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TranscriptFilter
transcriptFilter

instance Prelude.NFData Rule where
  rnf :: Rule -> ()
rnf Rule' {Maybe NonTalkTimeFilter
Maybe InterruptionFilter
Maybe SentimentFilter
Maybe TranscriptFilter
transcriptFilter :: Maybe TranscriptFilter
sentimentFilter :: Maybe SentimentFilter
nonTalkTimeFilter :: Maybe NonTalkTimeFilter
interruptionFilter :: Maybe InterruptionFilter
$sel:transcriptFilter:Rule' :: Rule -> Maybe TranscriptFilter
$sel:sentimentFilter:Rule' :: Rule -> Maybe SentimentFilter
$sel:nonTalkTimeFilter:Rule' :: Rule -> Maybe NonTalkTimeFilter
$sel:interruptionFilter:Rule' :: Rule -> Maybe InterruptionFilter
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InterruptionFilter
interruptionFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NonTalkTimeFilter
nonTalkTimeFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SentimentFilter
sentimentFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TranscriptFilter
transcriptFilter

instance Data.ToJSON Rule where
  toJSON :: Rule -> Value
toJSON Rule' {Maybe NonTalkTimeFilter
Maybe InterruptionFilter
Maybe SentimentFilter
Maybe TranscriptFilter
transcriptFilter :: Maybe TranscriptFilter
sentimentFilter :: Maybe SentimentFilter
nonTalkTimeFilter :: Maybe NonTalkTimeFilter
interruptionFilter :: Maybe InterruptionFilter
$sel:transcriptFilter:Rule' :: Rule -> Maybe TranscriptFilter
$sel:sentimentFilter:Rule' :: Rule -> Maybe SentimentFilter
$sel:nonTalkTimeFilter:Rule' :: Rule -> Maybe NonTalkTimeFilter
$sel:interruptionFilter:Rule' :: Rule -> Maybe InterruptionFilter
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"InterruptionFilter" 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 InterruptionFilter
interruptionFilter,
            (Key
"NonTalkTimeFilter" 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 NonTalkTimeFilter
nonTalkTimeFilter,
            (Key
"SentimentFilter" 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 SentimentFilter
sentimentFilter,
            (Key
"TranscriptFilter" 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 TranscriptFilter
transcriptFilter
          ]
      )