{-# 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.FraudDetector.Types.TrainingDataSchema
-- 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.FraudDetector.Types.TrainingDataSchema where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FraudDetector.Types.LabelSchema
import qualified Amazonka.Prelude as Prelude

-- | The training data schema.
--
-- /See:/ 'newTrainingDataSchema' smart constructor.
data TrainingDataSchema = TrainingDataSchema'
  { TrainingDataSchema -> Maybe LabelSchema
labelSchema :: Prelude.Maybe LabelSchema,
    -- | The training data schema variables.
    TrainingDataSchema -> [Text]
modelVariables :: [Prelude.Text]
  }
  deriving (TrainingDataSchema -> TrainingDataSchema -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrainingDataSchema -> TrainingDataSchema -> Bool
$c/= :: TrainingDataSchema -> TrainingDataSchema -> Bool
== :: TrainingDataSchema -> TrainingDataSchema -> Bool
$c== :: TrainingDataSchema -> TrainingDataSchema -> Bool
Prelude.Eq, ReadPrec [TrainingDataSchema]
ReadPrec TrainingDataSchema
Int -> ReadS TrainingDataSchema
ReadS [TrainingDataSchema]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrainingDataSchema]
$creadListPrec :: ReadPrec [TrainingDataSchema]
readPrec :: ReadPrec TrainingDataSchema
$creadPrec :: ReadPrec TrainingDataSchema
readList :: ReadS [TrainingDataSchema]
$creadList :: ReadS [TrainingDataSchema]
readsPrec :: Int -> ReadS TrainingDataSchema
$creadsPrec :: Int -> ReadS TrainingDataSchema
Prelude.Read, Int -> TrainingDataSchema -> ShowS
[TrainingDataSchema] -> ShowS
TrainingDataSchema -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrainingDataSchema] -> ShowS
$cshowList :: [TrainingDataSchema] -> ShowS
show :: TrainingDataSchema -> String
$cshow :: TrainingDataSchema -> String
showsPrec :: Int -> TrainingDataSchema -> ShowS
$cshowsPrec :: Int -> TrainingDataSchema -> ShowS
Prelude.Show, forall x. Rep TrainingDataSchema x -> TrainingDataSchema
forall x. TrainingDataSchema -> Rep TrainingDataSchema x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrainingDataSchema x -> TrainingDataSchema
$cfrom :: forall x. TrainingDataSchema -> Rep TrainingDataSchema x
Prelude.Generic)

-- |
-- Create a value of 'TrainingDataSchema' 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:
--
-- 'labelSchema', 'trainingDataSchema_labelSchema' - Undocumented member.
--
-- 'modelVariables', 'trainingDataSchema_modelVariables' - The training data schema variables.
newTrainingDataSchema ::
  TrainingDataSchema
newTrainingDataSchema :: TrainingDataSchema
newTrainingDataSchema =
  TrainingDataSchema'
    { $sel:labelSchema:TrainingDataSchema' :: Maybe LabelSchema
labelSchema = forall a. Maybe a
Prelude.Nothing,
      $sel:modelVariables:TrainingDataSchema' :: [Text]
modelVariables = forall a. Monoid a => a
Prelude.mempty
    }

-- | Undocumented member.
trainingDataSchema_labelSchema :: Lens.Lens' TrainingDataSchema (Prelude.Maybe LabelSchema)
trainingDataSchema_labelSchema :: Lens' TrainingDataSchema (Maybe LabelSchema)
trainingDataSchema_labelSchema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrainingDataSchema' {Maybe LabelSchema
labelSchema :: Maybe LabelSchema
$sel:labelSchema:TrainingDataSchema' :: TrainingDataSchema -> Maybe LabelSchema
labelSchema} -> Maybe LabelSchema
labelSchema) (\s :: TrainingDataSchema
s@TrainingDataSchema' {} Maybe LabelSchema
a -> TrainingDataSchema
s {$sel:labelSchema:TrainingDataSchema' :: Maybe LabelSchema
labelSchema = Maybe LabelSchema
a} :: TrainingDataSchema)

-- | The training data schema variables.
trainingDataSchema_modelVariables :: Lens.Lens' TrainingDataSchema [Prelude.Text]
trainingDataSchema_modelVariables :: Lens' TrainingDataSchema [Text]
trainingDataSchema_modelVariables = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrainingDataSchema' {[Text]
modelVariables :: [Text]
$sel:modelVariables:TrainingDataSchema' :: TrainingDataSchema -> [Text]
modelVariables} -> [Text]
modelVariables) (\s :: TrainingDataSchema
s@TrainingDataSchema' {} [Text]
a -> TrainingDataSchema
s {$sel:modelVariables:TrainingDataSchema' :: [Text]
modelVariables = [Text]
a} :: TrainingDataSchema) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON TrainingDataSchema where
  parseJSON :: Value -> Parser TrainingDataSchema
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TrainingDataSchema"
      ( \Object
x ->
          Maybe LabelSchema -> [Text] -> TrainingDataSchema
TrainingDataSchema'
            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
"labelSchema")
            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
"modelVariables"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable TrainingDataSchema where
  hashWithSalt :: Int -> TrainingDataSchema -> Int
hashWithSalt Int
_salt TrainingDataSchema' {[Text]
Maybe LabelSchema
modelVariables :: [Text]
labelSchema :: Maybe LabelSchema
$sel:modelVariables:TrainingDataSchema' :: TrainingDataSchema -> [Text]
$sel:labelSchema:TrainingDataSchema' :: TrainingDataSchema -> Maybe LabelSchema
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LabelSchema
labelSchema
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
modelVariables

instance Prelude.NFData TrainingDataSchema where
  rnf :: TrainingDataSchema -> ()
rnf TrainingDataSchema' {[Text]
Maybe LabelSchema
modelVariables :: [Text]
labelSchema :: Maybe LabelSchema
$sel:modelVariables:TrainingDataSchema' :: TrainingDataSchema -> [Text]
$sel:labelSchema:TrainingDataSchema' :: TrainingDataSchema -> Maybe LabelSchema
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LabelSchema
labelSchema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
modelVariables

instance Data.ToJSON TrainingDataSchema where
  toJSON :: TrainingDataSchema -> Value
toJSON TrainingDataSchema' {[Text]
Maybe LabelSchema
modelVariables :: [Text]
labelSchema :: Maybe LabelSchema
$sel:modelVariables:TrainingDataSchema' :: TrainingDataSchema -> [Text]
$sel:labelSchema:TrainingDataSchema' :: TrainingDataSchema -> Maybe LabelSchema
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"labelSchema" 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 LabelSchema
labelSchema,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"modelVariables" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
modelVariables)
          ]
      )