{-# 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.Glue.Types.GrokClassifier
-- 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.Glue.Types.GrokClassifier where

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

-- | A classifier that uses @grok@ patterns.
--
-- /See:/ 'newGrokClassifier' smart constructor.
data GrokClassifier = GrokClassifier'
  { -- | The time that this classifier was registered.
    GrokClassifier -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The time that this classifier was last updated.
    GrokClassifier -> Maybe POSIX
lastUpdated :: Prelude.Maybe Core.POSIX,
    -- | The version of this classifier.
    GrokClassifier -> Maybe Integer
version :: Prelude.Maybe Prelude.Integer,
    -- | Optional custom grok patterns defined by this classifier. For more
    -- information, see custom patterns in
    -- <https://docs.aws.amazon.com/glue/latest/dg/custom-classifier.html Writing Custom Classifiers>.
    GrokClassifier -> Maybe Text
customPatterns :: Prelude.Maybe Prelude.Text,
    -- | The name of the classifier.
    GrokClassifier -> Text
name :: Prelude.Text,
    -- | An identifier of the data format that the classifier matches, such as
    -- Twitter, JSON, Omniture logs, and so on.
    GrokClassifier -> Text
classification :: Prelude.Text,
    -- | The grok pattern applied to a data store by this classifier. For more
    -- information, see built-in patterns in
    -- <https://docs.aws.amazon.com/glue/latest/dg/custom-classifier.html Writing Custom Classifiers>.
    GrokClassifier -> Text
grokPattern :: Prelude.Text
  }
  deriving (GrokClassifier -> GrokClassifier -> Bool
(GrokClassifier -> GrokClassifier -> Bool)
-> (GrokClassifier -> GrokClassifier -> Bool) -> Eq GrokClassifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrokClassifier -> GrokClassifier -> Bool
$c/= :: GrokClassifier -> GrokClassifier -> Bool
== :: GrokClassifier -> GrokClassifier -> Bool
$c== :: GrokClassifier -> GrokClassifier -> Bool
Prelude.Eq, ReadPrec [GrokClassifier]
ReadPrec GrokClassifier
Int -> ReadS GrokClassifier
ReadS [GrokClassifier]
(Int -> ReadS GrokClassifier)
-> ReadS [GrokClassifier]
-> ReadPrec GrokClassifier
-> ReadPrec [GrokClassifier]
-> Read GrokClassifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrokClassifier]
$creadListPrec :: ReadPrec [GrokClassifier]
readPrec :: ReadPrec GrokClassifier
$creadPrec :: ReadPrec GrokClassifier
readList :: ReadS [GrokClassifier]
$creadList :: ReadS [GrokClassifier]
readsPrec :: Int -> ReadS GrokClassifier
$creadsPrec :: Int -> ReadS GrokClassifier
Prelude.Read, Int -> GrokClassifier -> ShowS
[GrokClassifier] -> ShowS
GrokClassifier -> String
(Int -> GrokClassifier -> ShowS)
-> (GrokClassifier -> String)
-> ([GrokClassifier] -> ShowS)
-> Show GrokClassifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrokClassifier] -> ShowS
$cshowList :: [GrokClassifier] -> ShowS
show :: GrokClassifier -> String
$cshow :: GrokClassifier -> String
showsPrec :: Int -> GrokClassifier -> ShowS
$cshowsPrec :: Int -> GrokClassifier -> ShowS
Prelude.Show, (forall x. GrokClassifier -> Rep GrokClassifier x)
-> (forall x. Rep GrokClassifier x -> GrokClassifier)
-> Generic GrokClassifier
forall x. Rep GrokClassifier x -> GrokClassifier
forall x. GrokClassifier -> Rep GrokClassifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrokClassifier x -> GrokClassifier
$cfrom :: forall x. GrokClassifier -> Rep GrokClassifier x
Prelude.Generic)

-- |
-- Create a value of 'GrokClassifier' 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:
--
-- 'creationTime', 'grokClassifier_creationTime' - The time that this classifier was registered.
--
-- 'lastUpdated', 'grokClassifier_lastUpdated' - The time that this classifier was last updated.
--
-- 'version', 'grokClassifier_version' - The version of this classifier.
--
-- 'customPatterns', 'grokClassifier_customPatterns' - Optional custom grok patterns defined by this classifier. For more
-- information, see custom patterns in
-- <https://docs.aws.amazon.com/glue/latest/dg/custom-classifier.html Writing Custom Classifiers>.
--
-- 'name', 'grokClassifier_name' - The name of the classifier.
--
-- 'classification', 'grokClassifier_classification' - An identifier of the data format that the classifier matches, such as
-- Twitter, JSON, Omniture logs, and so on.
--
-- 'grokPattern', 'grokClassifier_grokPattern' - The grok pattern applied to a data store by this classifier. For more
-- information, see built-in patterns in
-- <https://docs.aws.amazon.com/glue/latest/dg/custom-classifier.html Writing Custom Classifiers>.
newGrokClassifier ::
  -- | 'name'
  Prelude.Text ->
  -- | 'classification'
  Prelude.Text ->
  -- | 'grokPattern'
  Prelude.Text ->
  GrokClassifier
newGrokClassifier :: Text -> Text -> Text -> GrokClassifier
newGrokClassifier
  Text
pName_
  Text
pClassification_
  Text
pGrokPattern_ =
    GrokClassifier' :: Maybe POSIX
-> Maybe POSIX
-> Maybe Integer
-> Maybe Text
-> Text
-> Text
-> Text
-> GrokClassifier
GrokClassifier'
      { $sel:creationTime:GrokClassifier' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:lastUpdated:GrokClassifier' :: Maybe POSIX
lastUpdated = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:version:GrokClassifier' :: Maybe Integer
version = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
        $sel:customPatterns:GrokClassifier' :: Maybe Text
customPatterns = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:GrokClassifier' :: Text
name = Text
pName_,
        $sel:classification:GrokClassifier' :: Text
classification = Text
pClassification_,
        $sel:grokPattern:GrokClassifier' :: Text
grokPattern = Text
pGrokPattern_
      }

-- | The time that this classifier was registered.
grokClassifier_creationTime :: Lens.Lens' GrokClassifier (Prelude.Maybe Prelude.UTCTime)
grokClassifier_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GrokClassifier -> f GrokClassifier
grokClassifier_creationTime = (GrokClassifier -> Maybe POSIX)
-> (GrokClassifier -> Maybe POSIX -> GrokClassifier)
-> Lens GrokClassifier GrokClassifier (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrokClassifier' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:GrokClassifier' :: GrokClassifier -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: GrokClassifier
s@GrokClassifier' {} Maybe POSIX
a -> GrokClassifier
s {$sel:creationTime:GrokClassifier' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: GrokClassifier) ((Maybe POSIX -> f (Maybe POSIX))
 -> GrokClassifier -> f GrokClassifier)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GrokClassifier
-> f GrokClassifier
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 time that this classifier was last updated.
grokClassifier_lastUpdated :: Lens.Lens' GrokClassifier (Prelude.Maybe Prelude.UTCTime)
grokClassifier_lastUpdated :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GrokClassifier -> f GrokClassifier
grokClassifier_lastUpdated = (GrokClassifier -> Maybe POSIX)
-> (GrokClassifier -> Maybe POSIX -> GrokClassifier)
-> Lens GrokClassifier GrokClassifier (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrokClassifier' {Maybe POSIX
lastUpdated :: Maybe POSIX
$sel:lastUpdated:GrokClassifier' :: GrokClassifier -> Maybe POSIX
lastUpdated} -> Maybe POSIX
lastUpdated) (\s :: GrokClassifier
s@GrokClassifier' {} Maybe POSIX
a -> GrokClassifier
s {$sel:lastUpdated:GrokClassifier' :: Maybe POSIX
lastUpdated = Maybe POSIX
a} :: GrokClassifier) ((Maybe POSIX -> f (Maybe POSIX))
 -> GrokClassifier -> f GrokClassifier)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GrokClassifier
-> f GrokClassifier
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 version of this classifier.
grokClassifier_version :: Lens.Lens' GrokClassifier (Prelude.Maybe Prelude.Integer)
grokClassifier_version :: (Maybe Integer -> f (Maybe Integer))
-> GrokClassifier -> f GrokClassifier
grokClassifier_version = (GrokClassifier -> Maybe Integer)
-> (GrokClassifier -> Maybe Integer -> GrokClassifier)
-> Lens
     GrokClassifier GrokClassifier (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrokClassifier' {Maybe Integer
version :: Maybe Integer
$sel:version:GrokClassifier' :: GrokClassifier -> Maybe Integer
version} -> Maybe Integer
version) (\s :: GrokClassifier
s@GrokClassifier' {} Maybe Integer
a -> GrokClassifier
s {$sel:version:GrokClassifier' :: Maybe Integer
version = Maybe Integer
a} :: GrokClassifier)

-- | Optional custom grok patterns defined by this classifier. For more
-- information, see custom patterns in
-- <https://docs.aws.amazon.com/glue/latest/dg/custom-classifier.html Writing Custom Classifiers>.
grokClassifier_customPatterns :: Lens.Lens' GrokClassifier (Prelude.Maybe Prelude.Text)
grokClassifier_customPatterns :: (Maybe Text -> f (Maybe Text))
-> GrokClassifier -> f GrokClassifier
grokClassifier_customPatterns = (GrokClassifier -> Maybe Text)
-> (GrokClassifier -> Maybe Text -> GrokClassifier)
-> Lens GrokClassifier GrokClassifier (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrokClassifier' {Maybe Text
customPatterns :: Maybe Text
$sel:customPatterns:GrokClassifier' :: GrokClassifier -> Maybe Text
customPatterns} -> Maybe Text
customPatterns) (\s :: GrokClassifier
s@GrokClassifier' {} Maybe Text
a -> GrokClassifier
s {$sel:customPatterns:GrokClassifier' :: Maybe Text
customPatterns = Maybe Text
a} :: GrokClassifier)

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

-- | An identifier of the data format that the classifier matches, such as
-- Twitter, JSON, Omniture logs, and so on.
grokClassifier_classification :: Lens.Lens' GrokClassifier Prelude.Text
grokClassifier_classification :: (Text -> f Text) -> GrokClassifier -> f GrokClassifier
grokClassifier_classification = (GrokClassifier -> Text)
-> (GrokClassifier -> Text -> GrokClassifier)
-> Lens GrokClassifier GrokClassifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrokClassifier' {Text
classification :: Text
$sel:classification:GrokClassifier' :: GrokClassifier -> Text
classification} -> Text
classification) (\s :: GrokClassifier
s@GrokClassifier' {} Text
a -> GrokClassifier
s {$sel:classification:GrokClassifier' :: Text
classification = Text
a} :: GrokClassifier)

-- | The grok pattern applied to a data store by this classifier. For more
-- information, see built-in patterns in
-- <https://docs.aws.amazon.com/glue/latest/dg/custom-classifier.html Writing Custom Classifiers>.
grokClassifier_grokPattern :: Lens.Lens' GrokClassifier Prelude.Text
grokClassifier_grokPattern :: (Text -> f Text) -> GrokClassifier -> f GrokClassifier
grokClassifier_grokPattern = (GrokClassifier -> Text)
-> (GrokClassifier -> Text -> GrokClassifier)
-> Lens GrokClassifier GrokClassifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrokClassifier' {Text
grokPattern :: Text
$sel:grokPattern:GrokClassifier' :: GrokClassifier -> Text
grokPattern} -> Text
grokPattern) (\s :: GrokClassifier
s@GrokClassifier' {} Text
a -> GrokClassifier
s {$sel:grokPattern:GrokClassifier' :: Text
grokPattern = Text
a} :: GrokClassifier)

instance Core.FromJSON GrokClassifier where
  parseJSON :: Value -> Parser GrokClassifier
parseJSON =
    String
-> (Object -> Parser GrokClassifier)
-> Value
-> Parser GrokClassifier
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GrokClassifier"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Integer
-> Maybe Text
-> Text
-> Text
-> Text
-> GrokClassifier
GrokClassifier'
            (Maybe POSIX
 -> Maybe POSIX
 -> Maybe Integer
 -> Maybe Text
 -> Text
 -> Text
 -> Text
 -> GrokClassifier)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe Integer
      -> Maybe Text
      -> Text
      -> Text
      -> Text
      -> GrokClassifier)
forall (f :: * -> *) a b. Functor 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
"CreationTime")
            Parser
  (Maybe POSIX
   -> Maybe Integer
   -> Maybe Text
   -> Text
   -> Text
   -> Text
   -> GrokClassifier)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Integer
      -> Maybe Text -> Text -> Text -> Text -> GrokClassifier)
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
"LastUpdated")
            Parser
  (Maybe Integer
   -> Maybe Text -> Text -> Text -> Text -> GrokClassifier)
-> Parser (Maybe Integer)
-> Parser (Maybe Text -> Text -> Text -> Text -> GrokClassifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Version")
            Parser (Maybe Text -> Text -> Text -> Text -> GrokClassifier)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> Text -> GrokClassifier)
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
"CustomPatterns")
            Parser (Text -> Text -> Text -> GrokClassifier)
-> Parser Text -> Parser (Text -> Text -> GrokClassifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (Text -> Text -> GrokClassifier)
-> Parser Text -> Parser (Text -> GrokClassifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Classification")
            Parser (Text -> GrokClassifier)
-> Parser Text -> Parser GrokClassifier
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GrokPattern")
      )

instance Prelude.Hashable GrokClassifier

instance Prelude.NFData GrokClassifier