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

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

-- | Specifies a @grok@ classifier for @CreateClassifier@ to create.
--
-- /See:/ 'newCreateGrokClassifierRequest' smart constructor.
data CreateGrokClassifierRequest = CreateGrokClassifierRequest'
  { -- | Optional custom grok patterns used by this classifier.
    CreateGrokClassifierRequest -> Maybe Text
customPatterns :: Prelude.Maybe Prelude.Text,
    -- | An identifier of the data format that the classifier matches, such as
    -- Twitter, JSON, Omniture logs, Amazon CloudWatch Logs, and so on.
    CreateGrokClassifierRequest -> Text
classification :: Prelude.Text,
    -- | The name of the new classifier.
    CreateGrokClassifierRequest -> Text
name :: Prelude.Text,
    -- | The grok pattern used by this classifier.
    CreateGrokClassifierRequest -> Text
grokPattern :: Prelude.Text
  }
  deriving (CreateGrokClassifierRequest -> CreateGrokClassifierRequest -> Bool
(CreateGrokClassifierRequest
 -> CreateGrokClassifierRequest -> Bool)
-> (CreateGrokClassifierRequest
    -> CreateGrokClassifierRequest -> Bool)
-> Eq CreateGrokClassifierRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGrokClassifierRequest -> CreateGrokClassifierRequest -> Bool
$c/= :: CreateGrokClassifierRequest -> CreateGrokClassifierRequest -> Bool
== :: CreateGrokClassifierRequest -> CreateGrokClassifierRequest -> Bool
$c== :: CreateGrokClassifierRequest -> CreateGrokClassifierRequest -> Bool
Prelude.Eq, ReadPrec [CreateGrokClassifierRequest]
ReadPrec CreateGrokClassifierRequest
Int -> ReadS CreateGrokClassifierRequest
ReadS [CreateGrokClassifierRequest]
(Int -> ReadS CreateGrokClassifierRequest)
-> ReadS [CreateGrokClassifierRequest]
-> ReadPrec CreateGrokClassifierRequest
-> ReadPrec [CreateGrokClassifierRequest]
-> Read CreateGrokClassifierRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGrokClassifierRequest]
$creadListPrec :: ReadPrec [CreateGrokClassifierRequest]
readPrec :: ReadPrec CreateGrokClassifierRequest
$creadPrec :: ReadPrec CreateGrokClassifierRequest
readList :: ReadS [CreateGrokClassifierRequest]
$creadList :: ReadS [CreateGrokClassifierRequest]
readsPrec :: Int -> ReadS CreateGrokClassifierRequest
$creadsPrec :: Int -> ReadS CreateGrokClassifierRequest
Prelude.Read, Int -> CreateGrokClassifierRequest -> ShowS
[CreateGrokClassifierRequest] -> ShowS
CreateGrokClassifierRequest -> String
(Int -> CreateGrokClassifierRequest -> ShowS)
-> (CreateGrokClassifierRequest -> String)
-> ([CreateGrokClassifierRequest] -> ShowS)
-> Show CreateGrokClassifierRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGrokClassifierRequest] -> ShowS
$cshowList :: [CreateGrokClassifierRequest] -> ShowS
show :: CreateGrokClassifierRequest -> String
$cshow :: CreateGrokClassifierRequest -> String
showsPrec :: Int -> CreateGrokClassifierRequest -> ShowS
$cshowsPrec :: Int -> CreateGrokClassifierRequest -> ShowS
Prelude.Show, (forall x.
 CreateGrokClassifierRequest -> Rep CreateGrokClassifierRequest x)
-> (forall x.
    Rep CreateGrokClassifierRequest x -> CreateGrokClassifierRequest)
-> Generic CreateGrokClassifierRequest
forall x.
Rep CreateGrokClassifierRequest x -> CreateGrokClassifierRequest
forall x.
CreateGrokClassifierRequest -> Rep CreateGrokClassifierRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateGrokClassifierRequest x -> CreateGrokClassifierRequest
$cfrom :: forall x.
CreateGrokClassifierRequest -> Rep CreateGrokClassifierRequest x
Prelude.Generic)

-- |
-- Create a value of 'CreateGrokClassifierRequest' 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:
--
-- 'customPatterns', 'createGrokClassifierRequest_customPatterns' - Optional custom grok patterns used by this classifier.
--
-- 'classification', 'createGrokClassifierRequest_classification' - An identifier of the data format that the classifier matches, such as
-- Twitter, JSON, Omniture logs, Amazon CloudWatch Logs, and so on.
--
-- 'name', 'createGrokClassifierRequest_name' - The name of the new classifier.
--
-- 'grokPattern', 'createGrokClassifierRequest_grokPattern' - The grok pattern used by this classifier.
newCreateGrokClassifierRequest ::
  -- | 'classification'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'grokPattern'
  Prelude.Text ->
  CreateGrokClassifierRequest
newCreateGrokClassifierRequest :: Text -> Text -> Text -> CreateGrokClassifierRequest
newCreateGrokClassifierRequest
  Text
pClassification_
  Text
pName_
  Text
pGrokPattern_ =
    CreateGrokClassifierRequest' :: Maybe Text -> Text -> Text -> Text -> CreateGrokClassifierRequest
CreateGrokClassifierRequest'
      { $sel:customPatterns:CreateGrokClassifierRequest' :: Maybe Text
customPatterns =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:classification:CreateGrokClassifierRequest' :: Text
classification = Text
pClassification_,
        $sel:name:CreateGrokClassifierRequest' :: Text
name = Text
pName_,
        $sel:grokPattern:CreateGrokClassifierRequest' :: Text
grokPattern = Text
pGrokPattern_
      }

-- | Optional custom grok patterns used by this classifier.
createGrokClassifierRequest_customPatterns :: Lens.Lens' CreateGrokClassifierRequest (Prelude.Maybe Prelude.Text)
createGrokClassifierRequest_customPatterns :: (Maybe Text -> f (Maybe Text))
-> CreateGrokClassifierRequest -> f CreateGrokClassifierRequest
createGrokClassifierRequest_customPatterns = (CreateGrokClassifierRequest -> Maybe Text)
-> (CreateGrokClassifierRequest
    -> Maybe Text -> CreateGrokClassifierRequest)
-> Lens
     CreateGrokClassifierRequest
     CreateGrokClassifierRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGrokClassifierRequest' {Maybe Text
customPatterns :: Maybe Text
$sel:customPatterns:CreateGrokClassifierRequest' :: CreateGrokClassifierRequest -> Maybe Text
customPatterns} -> Maybe Text
customPatterns) (\s :: CreateGrokClassifierRequest
s@CreateGrokClassifierRequest' {} Maybe Text
a -> CreateGrokClassifierRequest
s {$sel:customPatterns:CreateGrokClassifierRequest' :: Maybe Text
customPatterns = Maybe Text
a} :: CreateGrokClassifierRequest)

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

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

-- | The grok pattern used by this classifier.
createGrokClassifierRequest_grokPattern :: Lens.Lens' CreateGrokClassifierRequest Prelude.Text
createGrokClassifierRequest_grokPattern :: (Text -> f Text)
-> CreateGrokClassifierRequest -> f CreateGrokClassifierRequest
createGrokClassifierRequest_grokPattern = (CreateGrokClassifierRequest -> Text)
-> (CreateGrokClassifierRequest
    -> Text -> CreateGrokClassifierRequest)
-> Lens
     CreateGrokClassifierRequest CreateGrokClassifierRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGrokClassifierRequest' {Text
grokPattern :: Text
$sel:grokPattern:CreateGrokClassifierRequest' :: CreateGrokClassifierRequest -> Text
grokPattern} -> Text
grokPattern) (\s :: CreateGrokClassifierRequest
s@CreateGrokClassifierRequest' {} Text
a -> CreateGrokClassifierRequest
s {$sel:grokPattern:CreateGrokClassifierRequest' :: Text
grokPattern = Text
a} :: CreateGrokClassifierRequest)

instance Prelude.Hashable CreateGrokClassifierRequest

instance Prelude.NFData CreateGrokClassifierRequest

instance Core.ToJSON CreateGrokClassifierRequest where
  toJSON :: CreateGrokClassifierRequest -> Value
toJSON CreateGrokClassifierRequest' {Maybe Text
Text
grokPattern :: Text
name :: Text
classification :: Text
customPatterns :: Maybe Text
$sel:grokPattern:CreateGrokClassifierRequest' :: CreateGrokClassifierRequest -> Text
$sel:name:CreateGrokClassifierRequest' :: CreateGrokClassifierRequest -> Text
$sel:classification:CreateGrokClassifierRequest' :: CreateGrokClassifierRequest -> Text
$sel:customPatterns:CreateGrokClassifierRequest' :: CreateGrokClassifierRequest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CustomPatterns" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
customPatterns,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"Classification" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
classification),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GrokPattern" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
grokPattern)
          ]
      )