{-# 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.Classifier
-- 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.Classifier where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.CsvClassifier
import Amazonka.Glue.Types.GrokClassifier
import Amazonka.Glue.Types.JsonClassifier
import Amazonka.Glue.Types.XMLClassifier
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Classifiers are triggered during a crawl task. A classifier checks
-- whether a given file is in a format it can handle. If it is, the
-- classifier creates a schema in the form of a @StructType@ object that
-- matches that data format.
--
-- You can use the standard classifiers that Glue provides, or you can
-- write your own classifiers to best categorize your data sources and
-- specify the appropriate schemas to use for them. A classifier can be a
-- @grok@ classifier, an @XML@ classifier, a @JSON@ classifier, or a custom
-- @CSV@ classifier, as specified in one of the fields in the @Classifier@
-- object.
--
-- /See:/ 'newClassifier' smart constructor.
data Classifier = Classifier'
  { -- | A classifier that uses @grok@.
    Classifier -> Maybe GrokClassifier
grokClassifier :: Prelude.Maybe GrokClassifier,
    -- | A classifier for XML content.
    Classifier -> Maybe XMLClassifier
xMLClassifier :: Prelude.Maybe XMLClassifier,
    -- | A classifier for comma-separated values (CSV).
    Classifier -> Maybe CsvClassifier
csvClassifier :: Prelude.Maybe CsvClassifier,
    -- | A classifier for JSON content.
    Classifier -> Maybe JsonClassifier
jsonClassifier :: Prelude.Maybe JsonClassifier
  }
  deriving (Classifier -> Classifier -> Bool
(Classifier -> Classifier -> Bool)
-> (Classifier -> Classifier -> Bool) -> Eq Classifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Classifier -> Classifier -> Bool
$c/= :: Classifier -> Classifier -> Bool
== :: Classifier -> Classifier -> Bool
$c== :: Classifier -> Classifier -> Bool
Prelude.Eq, ReadPrec [Classifier]
ReadPrec Classifier
Int -> ReadS Classifier
ReadS [Classifier]
(Int -> ReadS Classifier)
-> ReadS [Classifier]
-> ReadPrec Classifier
-> ReadPrec [Classifier]
-> Read Classifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Classifier]
$creadListPrec :: ReadPrec [Classifier]
readPrec :: ReadPrec Classifier
$creadPrec :: ReadPrec Classifier
readList :: ReadS [Classifier]
$creadList :: ReadS [Classifier]
readsPrec :: Int -> ReadS Classifier
$creadsPrec :: Int -> ReadS Classifier
Prelude.Read, Int -> Classifier -> ShowS
[Classifier] -> ShowS
Classifier -> String
(Int -> Classifier -> ShowS)
-> (Classifier -> String)
-> ([Classifier] -> ShowS)
-> Show Classifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Classifier] -> ShowS
$cshowList :: [Classifier] -> ShowS
show :: Classifier -> String
$cshow :: Classifier -> String
showsPrec :: Int -> Classifier -> ShowS
$cshowsPrec :: Int -> Classifier -> ShowS
Prelude.Show, (forall x. Classifier -> Rep Classifier x)
-> (forall x. Rep Classifier x -> Classifier) -> Generic Classifier
forall x. Rep Classifier x -> Classifier
forall x. Classifier -> Rep Classifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Classifier x -> Classifier
$cfrom :: forall x. Classifier -> Rep Classifier x
Prelude.Generic)

-- |
-- Create a value of 'Classifier' 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:
--
-- 'grokClassifier', 'classifier_grokClassifier' - A classifier that uses @grok@.
--
-- 'xMLClassifier', 'classifier_xMLClassifier' - A classifier for XML content.
--
-- 'csvClassifier', 'classifier_csvClassifier' - A classifier for comma-separated values (CSV).
--
-- 'jsonClassifier', 'classifier_jsonClassifier' - A classifier for JSON content.
newClassifier ::
  Classifier
newClassifier :: Classifier
newClassifier =
  Classifier' :: Maybe GrokClassifier
-> Maybe XMLClassifier
-> Maybe CsvClassifier
-> Maybe JsonClassifier
-> Classifier
Classifier'
    { $sel:grokClassifier:Classifier' :: Maybe GrokClassifier
grokClassifier = Maybe GrokClassifier
forall a. Maybe a
Prelude.Nothing,
      $sel:xMLClassifier:Classifier' :: Maybe XMLClassifier
xMLClassifier = Maybe XMLClassifier
forall a. Maybe a
Prelude.Nothing,
      $sel:csvClassifier:Classifier' :: Maybe CsvClassifier
csvClassifier = Maybe CsvClassifier
forall a. Maybe a
Prelude.Nothing,
      $sel:jsonClassifier:Classifier' :: Maybe JsonClassifier
jsonClassifier = Maybe JsonClassifier
forall a. Maybe a
Prelude.Nothing
    }

-- | A classifier that uses @grok@.
classifier_grokClassifier :: Lens.Lens' Classifier (Prelude.Maybe GrokClassifier)
classifier_grokClassifier :: (Maybe GrokClassifier -> f (Maybe GrokClassifier))
-> Classifier -> f Classifier
classifier_grokClassifier = (Classifier -> Maybe GrokClassifier)
-> (Classifier -> Maybe GrokClassifier -> Classifier)
-> Lens
     Classifier Classifier (Maybe GrokClassifier) (Maybe GrokClassifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Classifier' {Maybe GrokClassifier
grokClassifier :: Maybe GrokClassifier
$sel:grokClassifier:Classifier' :: Classifier -> Maybe GrokClassifier
grokClassifier} -> Maybe GrokClassifier
grokClassifier) (\s :: Classifier
s@Classifier' {} Maybe GrokClassifier
a -> Classifier
s {$sel:grokClassifier:Classifier' :: Maybe GrokClassifier
grokClassifier = Maybe GrokClassifier
a} :: Classifier)

-- | A classifier for XML content.
classifier_xMLClassifier :: Lens.Lens' Classifier (Prelude.Maybe XMLClassifier)
classifier_xMLClassifier :: (Maybe XMLClassifier -> f (Maybe XMLClassifier))
-> Classifier -> f Classifier
classifier_xMLClassifier = (Classifier -> Maybe XMLClassifier)
-> (Classifier -> Maybe XMLClassifier -> Classifier)
-> Lens
     Classifier Classifier (Maybe XMLClassifier) (Maybe XMLClassifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Classifier' {Maybe XMLClassifier
xMLClassifier :: Maybe XMLClassifier
$sel:xMLClassifier:Classifier' :: Classifier -> Maybe XMLClassifier
xMLClassifier} -> Maybe XMLClassifier
xMLClassifier) (\s :: Classifier
s@Classifier' {} Maybe XMLClassifier
a -> Classifier
s {$sel:xMLClassifier:Classifier' :: Maybe XMLClassifier
xMLClassifier = Maybe XMLClassifier
a} :: Classifier)

-- | A classifier for comma-separated values (CSV).
classifier_csvClassifier :: Lens.Lens' Classifier (Prelude.Maybe CsvClassifier)
classifier_csvClassifier :: (Maybe CsvClassifier -> f (Maybe CsvClassifier))
-> Classifier -> f Classifier
classifier_csvClassifier = (Classifier -> Maybe CsvClassifier)
-> (Classifier -> Maybe CsvClassifier -> Classifier)
-> Lens
     Classifier Classifier (Maybe CsvClassifier) (Maybe CsvClassifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Classifier' {Maybe CsvClassifier
csvClassifier :: Maybe CsvClassifier
$sel:csvClassifier:Classifier' :: Classifier -> Maybe CsvClassifier
csvClassifier} -> Maybe CsvClassifier
csvClassifier) (\s :: Classifier
s@Classifier' {} Maybe CsvClassifier
a -> Classifier
s {$sel:csvClassifier:Classifier' :: Maybe CsvClassifier
csvClassifier = Maybe CsvClassifier
a} :: Classifier)

-- | A classifier for JSON content.
classifier_jsonClassifier :: Lens.Lens' Classifier (Prelude.Maybe JsonClassifier)
classifier_jsonClassifier :: (Maybe JsonClassifier -> f (Maybe JsonClassifier))
-> Classifier -> f Classifier
classifier_jsonClassifier = (Classifier -> Maybe JsonClassifier)
-> (Classifier -> Maybe JsonClassifier -> Classifier)
-> Lens
     Classifier Classifier (Maybe JsonClassifier) (Maybe JsonClassifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Classifier' {Maybe JsonClassifier
jsonClassifier :: Maybe JsonClassifier
$sel:jsonClassifier:Classifier' :: Classifier -> Maybe JsonClassifier
jsonClassifier} -> Maybe JsonClassifier
jsonClassifier) (\s :: Classifier
s@Classifier' {} Maybe JsonClassifier
a -> Classifier
s {$sel:jsonClassifier:Classifier' :: Maybe JsonClassifier
jsonClassifier = Maybe JsonClassifier
a} :: Classifier)

instance Core.FromJSON Classifier where
  parseJSON :: Value -> Parser Classifier
parseJSON =
    String
-> (Object -> Parser Classifier) -> Value -> Parser Classifier
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Classifier"
      ( \Object
x ->
          Maybe GrokClassifier
-> Maybe XMLClassifier
-> Maybe CsvClassifier
-> Maybe JsonClassifier
-> Classifier
Classifier'
            (Maybe GrokClassifier
 -> Maybe XMLClassifier
 -> Maybe CsvClassifier
 -> Maybe JsonClassifier
 -> Classifier)
-> Parser (Maybe GrokClassifier)
-> Parser
     (Maybe XMLClassifier
      -> Maybe CsvClassifier -> Maybe JsonClassifier -> Classifier)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GrokClassifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GrokClassifier")
            Parser
  (Maybe XMLClassifier
   -> Maybe CsvClassifier -> Maybe JsonClassifier -> Classifier)
-> Parser (Maybe XMLClassifier)
-> Parser
     (Maybe CsvClassifier -> Maybe JsonClassifier -> Classifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe XMLClassifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"XMLClassifier")
            Parser (Maybe CsvClassifier -> Maybe JsonClassifier -> Classifier)
-> Parser (Maybe CsvClassifier)
-> Parser (Maybe JsonClassifier -> Classifier)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CsvClassifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CsvClassifier")
            Parser (Maybe JsonClassifier -> Classifier)
-> Parser (Maybe JsonClassifier) -> Parser Classifier
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JsonClassifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JsonClassifier")
      )

instance Prelude.Hashable Classifier

instance Prelude.NFData Classifier