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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.FindMatchesParameters
import Amazonka.Glue.Types.TransformType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The algorithm-specific parameters that are associated with the machine
-- learning transform.
--
-- /See:/ 'newTransformParameters' smart constructor.
data TransformParameters = TransformParameters'
  { -- | The parameters for the find matches algorithm.
    TransformParameters -> Maybe FindMatchesParameters
findMatchesParameters :: Prelude.Maybe FindMatchesParameters,
    -- | The type of machine learning transform.
    --
    -- For information about the types of machine learning transforms, see
    -- <https://docs.aws.amazon.com/glue/latest/dg/add-job-machine-learning-transform.html Creating Machine Learning Transforms>.
    TransformParameters -> TransformType
transformType :: TransformType
  }
  deriving (TransformParameters -> TransformParameters -> Bool
(TransformParameters -> TransformParameters -> Bool)
-> (TransformParameters -> TransformParameters -> Bool)
-> Eq TransformParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransformParameters -> TransformParameters -> Bool
$c/= :: TransformParameters -> TransformParameters -> Bool
== :: TransformParameters -> TransformParameters -> Bool
$c== :: TransformParameters -> TransformParameters -> Bool
Prelude.Eq, ReadPrec [TransformParameters]
ReadPrec TransformParameters
Int -> ReadS TransformParameters
ReadS [TransformParameters]
(Int -> ReadS TransformParameters)
-> ReadS [TransformParameters]
-> ReadPrec TransformParameters
-> ReadPrec [TransformParameters]
-> Read TransformParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransformParameters]
$creadListPrec :: ReadPrec [TransformParameters]
readPrec :: ReadPrec TransformParameters
$creadPrec :: ReadPrec TransformParameters
readList :: ReadS [TransformParameters]
$creadList :: ReadS [TransformParameters]
readsPrec :: Int -> ReadS TransformParameters
$creadsPrec :: Int -> ReadS TransformParameters
Prelude.Read, Int -> TransformParameters -> ShowS
[TransformParameters] -> ShowS
TransformParameters -> String
(Int -> TransformParameters -> ShowS)
-> (TransformParameters -> String)
-> ([TransformParameters] -> ShowS)
-> Show TransformParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransformParameters] -> ShowS
$cshowList :: [TransformParameters] -> ShowS
show :: TransformParameters -> String
$cshow :: TransformParameters -> String
showsPrec :: Int -> TransformParameters -> ShowS
$cshowsPrec :: Int -> TransformParameters -> ShowS
Prelude.Show, (forall x. TransformParameters -> Rep TransformParameters x)
-> (forall x. Rep TransformParameters x -> TransformParameters)
-> Generic TransformParameters
forall x. Rep TransformParameters x -> TransformParameters
forall x. TransformParameters -> Rep TransformParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransformParameters x -> TransformParameters
$cfrom :: forall x. TransformParameters -> Rep TransformParameters x
Prelude.Generic)

-- |
-- Create a value of 'TransformParameters' 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:
--
-- 'findMatchesParameters', 'transformParameters_findMatchesParameters' - The parameters for the find matches algorithm.
--
-- 'transformType', 'transformParameters_transformType' - The type of machine learning transform.
--
-- For information about the types of machine learning transforms, see
-- <https://docs.aws.amazon.com/glue/latest/dg/add-job-machine-learning-transform.html Creating Machine Learning Transforms>.
newTransformParameters ::
  -- | 'transformType'
  TransformType ->
  TransformParameters
newTransformParameters :: TransformType -> TransformParameters
newTransformParameters TransformType
pTransformType_ =
  TransformParameters' :: Maybe FindMatchesParameters -> TransformType -> TransformParameters
TransformParameters'
    { $sel:findMatchesParameters:TransformParameters' :: Maybe FindMatchesParameters
findMatchesParameters =
        Maybe FindMatchesParameters
forall a. Maybe a
Prelude.Nothing,
      $sel:transformType:TransformParameters' :: TransformType
transformType = TransformType
pTransformType_
    }

-- | The parameters for the find matches algorithm.
transformParameters_findMatchesParameters :: Lens.Lens' TransformParameters (Prelude.Maybe FindMatchesParameters)
transformParameters_findMatchesParameters :: (Maybe FindMatchesParameters -> f (Maybe FindMatchesParameters))
-> TransformParameters -> f TransformParameters
transformParameters_findMatchesParameters = (TransformParameters -> Maybe FindMatchesParameters)
-> (TransformParameters
    -> Maybe FindMatchesParameters -> TransformParameters)
-> Lens
     TransformParameters
     TransformParameters
     (Maybe FindMatchesParameters)
     (Maybe FindMatchesParameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformParameters' {Maybe FindMatchesParameters
findMatchesParameters :: Maybe FindMatchesParameters
$sel:findMatchesParameters:TransformParameters' :: TransformParameters -> Maybe FindMatchesParameters
findMatchesParameters} -> Maybe FindMatchesParameters
findMatchesParameters) (\s :: TransformParameters
s@TransformParameters' {} Maybe FindMatchesParameters
a -> TransformParameters
s {$sel:findMatchesParameters:TransformParameters' :: Maybe FindMatchesParameters
findMatchesParameters = Maybe FindMatchesParameters
a} :: TransformParameters)

-- | The type of machine learning transform.
--
-- For information about the types of machine learning transforms, see
-- <https://docs.aws.amazon.com/glue/latest/dg/add-job-machine-learning-transform.html Creating Machine Learning Transforms>.
transformParameters_transformType :: Lens.Lens' TransformParameters TransformType
transformParameters_transformType :: (TransformType -> f TransformType)
-> TransformParameters -> f TransformParameters
transformParameters_transformType = (TransformParameters -> TransformType)
-> (TransformParameters -> TransformType -> TransformParameters)
-> Lens
     TransformParameters TransformParameters TransformType TransformType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformParameters' {TransformType
transformType :: TransformType
$sel:transformType:TransformParameters' :: TransformParameters -> TransformType
transformType} -> TransformType
transformType) (\s :: TransformParameters
s@TransformParameters' {} TransformType
a -> TransformParameters
s {$sel:transformType:TransformParameters' :: TransformType
transformType = TransformType
a} :: TransformParameters)

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

instance Prelude.Hashable TransformParameters

instance Prelude.NFData TransformParameters

instance Core.ToJSON TransformParameters where
  toJSON :: TransformParameters -> Value
toJSON TransformParameters' {Maybe FindMatchesParameters
TransformType
transformType :: TransformType
findMatchesParameters :: Maybe FindMatchesParameters
$sel:transformType:TransformParameters' :: TransformParameters -> TransformType
$sel:findMatchesParameters:TransformParameters' :: TransformParameters -> Maybe FindMatchesParameters
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FindMatchesParameters" Text -> FindMatchesParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FindMatchesParameters -> Pair)
-> Maybe FindMatchesParameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FindMatchesParameters
findMatchesParameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TransformType" Text -> TransformType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TransformType
transformType)
          ]
      )