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

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

-- | The training data schema.
--
-- /See:/ 'newTrainingDataSchema' smart constructor.
data TrainingDataSchema = TrainingDataSchema'
  { -- | The training data schema variables.
    TrainingDataSchema -> [Text]
modelVariables :: [Prelude.Text],
    TrainingDataSchema -> LabelSchema
labelSchema :: LabelSchema
  }
  deriving (TrainingDataSchema -> TrainingDataSchema -> Bool
(TrainingDataSchema -> TrainingDataSchema -> Bool)
-> (TrainingDataSchema -> TrainingDataSchema -> Bool)
-> Eq TrainingDataSchema
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]
(Int -> ReadS TrainingDataSchema)
-> ReadS [TrainingDataSchema]
-> ReadPrec TrainingDataSchema
-> ReadPrec [TrainingDataSchema]
-> Read 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
(Int -> TrainingDataSchema -> ShowS)
-> (TrainingDataSchema -> String)
-> ([TrainingDataSchema] -> ShowS)
-> Show TrainingDataSchema
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. TrainingDataSchema -> Rep TrainingDataSchema x)
-> (forall x. Rep TrainingDataSchema x -> TrainingDataSchema)
-> Generic TrainingDataSchema
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:
--
-- 'modelVariables', 'trainingDataSchema_modelVariables' - The training data schema variables.
--
-- 'labelSchema', 'trainingDataSchema_labelSchema' - Undocumented member.
newTrainingDataSchema ::
  -- | 'labelSchema'
  LabelSchema ->
  TrainingDataSchema
newTrainingDataSchema :: LabelSchema -> TrainingDataSchema
newTrainingDataSchema LabelSchema
pLabelSchema_ =
  TrainingDataSchema' :: [Text] -> LabelSchema -> TrainingDataSchema
TrainingDataSchema'
    { $sel:modelVariables:TrainingDataSchema' :: [Text]
modelVariables =
        [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:labelSchema:TrainingDataSchema' :: LabelSchema
labelSchema = LabelSchema
pLabelSchema_
    }

-- | The training data schema variables.
trainingDataSchema_modelVariables :: Lens.Lens' TrainingDataSchema [Prelude.Text]
trainingDataSchema_modelVariables :: ([Text] -> f [Text]) -> TrainingDataSchema -> f TrainingDataSchema
trainingDataSchema_modelVariables = (TrainingDataSchema -> [Text])
-> (TrainingDataSchema -> [Text] -> TrainingDataSchema)
-> Lens TrainingDataSchema TrainingDataSchema [Text] [Text]
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) (([Text] -> f [Text])
 -> TrainingDataSchema -> f TrainingDataSchema)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> TrainingDataSchema
-> f TrainingDataSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.Hashable TrainingDataSchema

instance Prelude.NFData TrainingDataSchema

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