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

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

-- | The Amazon SageMaker model input configuration.
--
-- /See:/ 'newModelInputConfiguration' smart constructor.
data ModelInputConfiguration = ModelInputConfiguration'
  { -- | The format of the model input configuration. The format differs
    -- depending on if it is passed through to SageMaker or constructed by
    -- Amazon Fraud Detector.
    ModelInputConfiguration -> Maybe ModelInputDataFormat
format :: Prelude.Maybe ModelInputDataFormat,
    -- | The event type name.
    ModelInputConfiguration -> Maybe Text
eventTypeName :: Prelude.Maybe Prelude.Text,
    -- | Template for constructing the CSV input-data sent to SageMaker. At
    -- event-evaluation, the placeholders for variable-names in the template
    -- will be replaced with the variable values before being sent to
    -- SageMaker.
    ModelInputConfiguration -> Maybe Text
csvInputTemplate :: Prelude.Maybe Prelude.Text,
    -- | Template for constructing the JSON input-data sent to SageMaker. At
    -- event-evaluation, the placeholders for variable names in the template
    -- will be replaced with the variable values before being sent to
    -- SageMaker.
    ModelInputConfiguration -> Maybe Text
jsonInputTemplate :: Prelude.Maybe Prelude.Text,
    -- | The event variables.
    ModelInputConfiguration -> Bool
useEventVariables :: Prelude.Bool
  }
  deriving (ModelInputConfiguration -> ModelInputConfiguration -> Bool
(ModelInputConfiguration -> ModelInputConfiguration -> Bool)
-> (ModelInputConfiguration -> ModelInputConfiguration -> Bool)
-> Eq ModelInputConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelInputConfiguration -> ModelInputConfiguration -> Bool
$c/= :: ModelInputConfiguration -> ModelInputConfiguration -> Bool
== :: ModelInputConfiguration -> ModelInputConfiguration -> Bool
$c== :: ModelInputConfiguration -> ModelInputConfiguration -> Bool
Prelude.Eq, ReadPrec [ModelInputConfiguration]
ReadPrec ModelInputConfiguration
Int -> ReadS ModelInputConfiguration
ReadS [ModelInputConfiguration]
(Int -> ReadS ModelInputConfiguration)
-> ReadS [ModelInputConfiguration]
-> ReadPrec ModelInputConfiguration
-> ReadPrec [ModelInputConfiguration]
-> Read ModelInputConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModelInputConfiguration]
$creadListPrec :: ReadPrec [ModelInputConfiguration]
readPrec :: ReadPrec ModelInputConfiguration
$creadPrec :: ReadPrec ModelInputConfiguration
readList :: ReadS [ModelInputConfiguration]
$creadList :: ReadS [ModelInputConfiguration]
readsPrec :: Int -> ReadS ModelInputConfiguration
$creadsPrec :: Int -> ReadS ModelInputConfiguration
Prelude.Read, Int -> ModelInputConfiguration -> ShowS
[ModelInputConfiguration] -> ShowS
ModelInputConfiguration -> String
(Int -> ModelInputConfiguration -> ShowS)
-> (ModelInputConfiguration -> String)
-> ([ModelInputConfiguration] -> ShowS)
-> Show ModelInputConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelInputConfiguration] -> ShowS
$cshowList :: [ModelInputConfiguration] -> ShowS
show :: ModelInputConfiguration -> String
$cshow :: ModelInputConfiguration -> String
showsPrec :: Int -> ModelInputConfiguration -> ShowS
$cshowsPrec :: Int -> ModelInputConfiguration -> ShowS
Prelude.Show, (forall x.
 ModelInputConfiguration -> Rep ModelInputConfiguration x)
-> (forall x.
    Rep ModelInputConfiguration x -> ModelInputConfiguration)
-> Generic ModelInputConfiguration
forall x. Rep ModelInputConfiguration x -> ModelInputConfiguration
forall x. ModelInputConfiguration -> Rep ModelInputConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelInputConfiguration x -> ModelInputConfiguration
$cfrom :: forall x. ModelInputConfiguration -> Rep ModelInputConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ModelInputConfiguration' 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:
--
-- 'format', 'modelInputConfiguration_format' - The format of the model input configuration. The format differs
-- depending on if it is passed through to SageMaker or constructed by
-- Amazon Fraud Detector.
--
-- 'eventTypeName', 'modelInputConfiguration_eventTypeName' - The event type name.
--
-- 'csvInputTemplate', 'modelInputConfiguration_csvInputTemplate' - Template for constructing the CSV input-data sent to SageMaker. At
-- event-evaluation, the placeholders for variable-names in the template
-- will be replaced with the variable values before being sent to
-- SageMaker.
--
-- 'jsonInputTemplate', 'modelInputConfiguration_jsonInputTemplate' - Template for constructing the JSON input-data sent to SageMaker. At
-- event-evaluation, the placeholders for variable names in the template
-- will be replaced with the variable values before being sent to
-- SageMaker.
--
-- 'useEventVariables', 'modelInputConfiguration_useEventVariables' - The event variables.
newModelInputConfiguration ::
  -- | 'useEventVariables'
  Prelude.Bool ->
  ModelInputConfiguration
newModelInputConfiguration :: Bool -> ModelInputConfiguration
newModelInputConfiguration Bool
pUseEventVariables_ =
  ModelInputConfiguration' :: Maybe ModelInputDataFormat
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Bool
-> ModelInputConfiguration
ModelInputConfiguration'
    { $sel:format:ModelInputConfiguration' :: Maybe ModelInputDataFormat
format = Maybe ModelInputDataFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:eventTypeName:ModelInputConfiguration' :: Maybe Text
eventTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:csvInputTemplate:ModelInputConfiguration' :: Maybe Text
csvInputTemplate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jsonInputTemplate:ModelInputConfiguration' :: Maybe Text
jsonInputTemplate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:useEventVariables:ModelInputConfiguration' :: Bool
useEventVariables = Bool
pUseEventVariables_
    }

-- | The format of the model input configuration. The format differs
-- depending on if it is passed through to SageMaker or constructed by
-- Amazon Fraud Detector.
modelInputConfiguration_format :: Lens.Lens' ModelInputConfiguration (Prelude.Maybe ModelInputDataFormat)
modelInputConfiguration_format :: (Maybe ModelInputDataFormat -> f (Maybe ModelInputDataFormat))
-> ModelInputConfiguration -> f ModelInputConfiguration
modelInputConfiguration_format = (ModelInputConfiguration -> Maybe ModelInputDataFormat)
-> (ModelInputConfiguration
    -> Maybe ModelInputDataFormat -> ModelInputConfiguration)
-> Lens
     ModelInputConfiguration
     ModelInputConfiguration
     (Maybe ModelInputDataFormat)
     (Maybe ModelInputDataFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelInputConfiguration' {Maybe ModelInputDataFormat
format :: Maybe ModelInputDataFormat
$sel:format:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe ModelInputDataFormat
format} -> Maybe ModelInputDataFormat
format) (\s :: ModelInputConfiguration
s@ModelInputConfiguration' {} Maybe ModelInputDataFormat
a -> ModelInputConfiguration
s {$sel:format:ModelInputConfiguration' :: Maybe ModelInputDataFormat
format = Maybe ModelInputDataFormat
a} :: ModelInputConfiguration)

-- | The event type name.
modelInputConfiguration_eventTypeName :: Lens.Lens' ModelInputConfiguration (Prelude.Maybe Prelude.Text)
modelInputConfiguration_eventTypeName :: (Maybe Text -> f (Maybe Text))
-> ModelInputConfiguration -> f ModelInputConfiguration
modelInputConfiguration_eventTypeName = (ModelInputConfiguration -> Maybe Text)
-> (ModelInputConfiguration
    -> Maybe Text -> ModelInputConfiguration)
-> Lens
     ModelInputConfiguration
     ModelInputConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelInputConfiguration' {Maybe Text
eventTypeName :: Maybe Text
$sel:eventTypeName:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe Text
eventTypeName} -> Maybe Text
eventTypeName) (\s :: ModelInputConfiguration
s@ModelInputConfiguration' {} Maybe Text
a -> ModelInputConfiguration
s {$sel:eventTypeName:ModelInputConfiguration' :: Maybe Text
eventTypeName = Maybe Text
a} :: ModelInputConfiguration)

-- | Template for constructing the CSV input-data sent to SageMaker. At
-- event-evaluation, the placeholders for variable-names in the template
-- will be replaced with the variable values before being sent to
-- SageMaker.
modelInputConfiguration_csvInputTemplate :: Lens.Lens' ModelInputConfiguration (Prelude.Maybe Prelude.Text)
modelInputConfiguration_csvInputTemplate :: (Maybe Text -> f (Maybe Text))
-> ModelInputConfiguration -> f ModelInputConfiguration
modelInputConfiguration_csvInputTemplate = (ModelInputConfiguration -> Maybe Text)
-> (ModelInputConfiguration
    -> Maybe Text -> ModelInputConfiguration)
-> Lens
     ModelInputConfiguration
     ModelInputConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelInputConfiguration' {Maybe Text
csvInputTemplate :: Maybe Text
$sel:csvInputTemplate:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe Text
csvInputTemplate} -> Maybe Text
csvInputTemplate) (\s :: ModelInputConfiguration
s@ModelInputConfiguration' {} Maybe Text
a -> ModelInputConfiguration
s {$sel:csvInputTemplate:ModelInputConfiguration' :: Maybe Text
csvInputTemplate = Maybe Text
a} :: ModelInputConfiguration)

-- | Template for constructing the JSON input-data sent to SageMaker. At
-- event-evaluation, the placeholders for variable names in the template
-- will be replaced with the variable values before being sent to
-- SageMaker.
modelInputConfiguration_jsonInputTemplate :: Lens.Lens' ModelInputConfiguration (Prelude.Maybe Prelude.Text)
modelInputConfiguration_jsonInputTemplate :: (Maybe Text -> f (Maybe Text))
-> ModelInputConfiguration -> f ModelInputConfiguration
modelInputConfiguration_jsonInputTemplate = (ModelInputConfiguration -> Maybe Text)
-> (ModelInputConfiguration
    -> Maybe Text -> ModelInputConfiguration)
-> Lens
     ModelInputConfiguration
     ModelInputConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelInputConfiguration' {Maybe Text
jsonInputTemplate :: Maybe Text
$sel:jsonInputTemplate:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe Text
jsonInputTemplate} -> Maybe Text
jsonInputTemplate) (\s :: ModelInputConfiguration
s@ModelInputConfiguration' {} Maybe Text
a -> ModelInputConfiguration
s {$sel:jsonInputTemplate:ModelInputConfiguration' :: Maybe Text
jsonInputTemplate = Maybe Text
a} :: ModelInputConfiguration)

-- | The event variables.
modelInputConfiguration_useEventVariables :: Lens.Lens' ModelInputConfiguration Prelude.Bool
modelInputConfiguration_useEventVariables :: (Bool -> f Bool)
-> ModelInputConfiguration -> f ModelInputConfiguration
modelInputConfiguration_useEventVariables = (ModelInputConfiguration -> Bool)
-> (ModelInputConfiguration -> Bool -> ModelInputConfiguration)
-> Lens ModelInputConfiguration ModelInputConfiguration Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelInputConfiguration' {Bool
useEventVariables :: Bool
$sel:useEventVariables:ModelInputConfiguration' :: ModelInputConfiguration -> Bool
useEventVariables} -> Bool
useEventVariables) (\s :: ModelInputConfiguration
s@ModelInputConfiguration' {} Bool
a -> ModelInputConfiguration
s {$sel:useEventVariables:ModelInputConfiguration' :: Bool
useEventVariables = Bool
a} :: ModelInputConfiguration)

instance Core.FromJSON ModelInputConfiguration where
  parseJSON :: Value -> Parser ModelInputConfiguration
parseJSON =
    String
-> (Object -> Parser ModelInputConfiguration)
-> Value
-> Parser ModelInputConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ModelInputConfiguration"
      ( \Object
x ->
          Maybe ModelInputDataFormat
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Bool
-> ModelInputConfiguration
ModelInputConfiguration'
            (Maybe ModelInputDataFormat
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Bool
 -> ModelInputConfiguration)
-> Parser (Maybe ModelInputDataFormat)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Bool -> ModelInputConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ModelInputDataFormat)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"format")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Bool -> ModelInputConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Bool -> ModelInputConfiguration)
forall (f :: * -> *) a b. Applicative f => 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
"eventTypeName")
            Parser
  (Maybe Text -> Maybe Text -> Bool -> ModelInputConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Bool -> ModelInputConfiguration)
forall (f :: * -> *) a b. Applicative f => 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
"csvInputTemplate")
            Parser (Maybe Text -> Bool -> ModelInputConfiguration)
-> Parser (Maybe Text) -> Parser (Bool -> ModelInputConfiguration)
forall (f :: * -> *) a b. Applicative f => 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
"jsonInputTemplate")
            Parser (Bool -> ModelInputConfiguration)
-> Parser Bool -> Parser ModelInputConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"useEventVariables")
      )

instance Prelude.Hashable ModelInputConfiguration

instance Prelude.NFData ModelInputConfiguration

instance Core.ToJSON ModelInputConfiguration where
  toJSON :: ModelInputConfiguration -> Value
toJSON ModelInputConfiguration' {Bool
Maybe Text
Maybe ModelInputDataFormat
useEventVariables :: Bool
jsonInputTemplate :: Maybe Text
csvInputTemplate :: Maybe Text
eventTypeName :: Maybe Text
format :: Maybe ModelInputDataFormat
$sel:useEventVariables:ModelInputConfiguration' :: ModelInputConfiguration -> Bool
$sel:jsonInputTemplate:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe Text
$sel:csvInputTemplate:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe Text
$sel:eventTypeName:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe Text
$sel:format:ModelInputConfiguration' :: ModelInputConfiguration -> Maybe ModelInputDataFormat
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"format" Text -> ModelInputDataFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ModelInputDataFormat -> Pair)
-> Maybe ModelInputDataFormat -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ModelInputDataFormat
format,
            (Text
"eventTypeName" 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
eventTypeName,
            (Text
"csvInputTemplate" 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
csvInputTemplate,
            (Text
"jsonInputTemplate" 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
jsonInputTemplate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"useEventVariables" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
useEventVariables)
          ]
      )