{-# 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.SageMaker.Types.AutoMLChannel
-- 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.SageMaker.Types.AutoMLChannel where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.AutoMLDataSource
import Amazonka.SageMaker.Types.CompressionType

-- | A channel is a named input source that training algorithms can consume.
-- For more information, see .
--
-- /See:/ 'newAutoMLChannel' smart constructor.
data AutoMLChannel = AutoMLChannel'
  { -- | You can use @Gzip@ or @None@. The default value is @None@.
    AutoMLChannel -> Maybe CompressionType
compressionType :: Prelude.Maybe CompressionType,
    -- | The data source for an AutoML channel.
    AutoMLChannel -> AutoMLDataSource
dataSource :: AutoMLDataSource,
    -- | The name of the target variable in supervised learning, usually
    -- represented by \'y\'.
    AutoMLChannel -> Text
targetAttributeName :: Prelude.Text
  }
  deriving (AutoMLChannel -> AutoMLChannel -> Bool
(AutoMLChannel -> AutoMLChannel -> Bool)
-> (AutoMLChannel -> AutoMLChannel -> Bool) -> Eq AutoMLChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoMLChannel -> AutoMLChannel -> Bool
$c/= :: AutoMLChannel -> AutoMLChannel -> Bool
== :: AutoMLChannel -> AutoMLChannel -> Bool
$c== :: AutoMLChannel -> AutoMLChannel -> Bool
Prelude.Eq, ReadPrec [AutoMLChannel]
ReadPrec AutoMLChannel
Int -> ReadS AutoMLChannel
ReadS [AutoMLChannel]
(Int -> ReadS AutoMLChannel)
-> ReadS [AutoMLChannel]
-> ReadPrec AutoMLChannel
-> ReadPrec [AutoMLChannel]
-> Read AutoMLChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoMLChannel]
$creadListPrec :: ReadPrec [AutoMLChannel]
readPrec :: ReadPrec AutoMLChannel
$creadPrec :: ReadPrec AutoMLChannel
readList :: ReadS [AutoMLChannel]
$creadList :: ReadS [AutoMLChannel]
readsPrec :: Int -> ReadS AutoMLChannel
$creadsPrec :: Int -> ReadS AutoMLChannel
Prelude.Read, Int -> AutoMLChannel -> ShowS
[AutoMLChannel] -> ShowS
AutoMLChannel -> String
(Int -> AutoMLChannel -> ShowS)
-> (AutoMLChannel -> String)
-> ([AutoMLChannel] -> ShowS)
-> Show AutoMLChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoMLChannel] -> ShowS
$cshowList :: [AutoMLChannel] -> ShowS
show :: AutoMLChannel -> String
$cshow :: AutoMLChannel -> String
showsPrec :: Int -> AutoMLChannel -> ShowS
$cshowsPrec :: Int -> AutoMLChannel -> ShowS
Prelude.Show, (forall x. AutoMLChannel -> Rep AutoMLChannel x)
-> (forall x. Rep AutoMLChannel x -> AutoMLChannel)
-> Generic AutoMLChannel
forall x. Rep AutoMLChannel x -> AutoMLChannel
forall x. AutoMLChannel -> Rep AutoMLChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoMLChannel x -> AutoMLChannel
$cfrom :: forall x. AutoMLChannel -> Rep AutoMLChannel x
Prelude.Generic)

-- |
-- Create a value of 'AutoMLChannel' 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:
--
-- 'compressionType', 'autoMLChannel_compressionType' - You can use @Gzip@ or @None@. The default value is @None@.
--
-- 'dataSource', 'autoMLChannel_dataSource' - The data source for an AutoML channel.
--
-- 'targetAttributeName', 'autoMLChannel_targetAttributeName' - The name of the target variable in supervised learning, usually
-- represented by \'y\'.
newAutoMLChannel ::
  -- | 'dataSource'
  AutoMLDataSource ->
  -- | 'targetAttributeName'
  Prelude.Text ->
  AutoMLChannel
newAutoMLChannel :: AutoMLDataSource -> Text -> AutoMLChannel
newAutoMLChannel AutoMLDataSource
pDataSource_ Text
pTargetAttributeName_ =
  AutoMLChannel' :: Maybe CompressionType -> AutoMLDataSource -> Text -> AutoMLChannel
AutoMLChannel'
    { $sel:compressionType:AutoMLChannel' :: Maybe CompressionType
compressionType = Maybe CompressionType
forall a. Maybe a
Prelude.Nothing,
      $sel:dataSource:AutoMLChannel' :: AutoMLDataSource
dataSource = AutoMLDataSource
pDataSource_,
      $sel:targetAttributeName:AutoMLChannel' :: Text
targetAttributeName = Text
pTargetAttributeName_
    }

-- | You can use @Gzip@ or @None@. The default value is @None@.
autoMLChannel_compressionType :: Lens.Lens' AutoMLChannel (Prelude.Maybe CompressionType)
autoMLChannel_compressionType :: (Maybe CompressionType -> f (Maybe CompressionType))
-> AutoMLChannel -> f AutoMLChannel
autoMLChannel_compressionType = (AutoMLChannel -> Maybe CompressionType)
-> (AutoMLChannel -> Maybe CompressionType -> AutoMLChannel)
-> Lens
     AutoMLChannel
     AutoMLChannel
     (Maybe CompressionType)
     (Maybe CompressionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMLChannel' {Maybe CompressionType
compressionType :: Maybe CompressionType
$sel:compressionType:AutoMLChannel' :: AutoMLChannel -> Maybe CompressionType
compressionType} -> Maybe CompressionType
compressionType) (\s :: AutoMLChannel
s@AutoMLChannel' {} Maybe CompressionType
a -> AutoMLChannel
s {$sel:compressionType:AutoMLChannel' :: Maybe CompressionType
compressionType = Maybe CompressionType
a} :: AutoMLChannel)

-- | The data source for an AutoML channel.
autoMLChannel_dataSource :: Lens.Lens' AutoMLChannel AutoMLDataSource
autoMLChannel_dataSource :: (AutoMLDataSource -> f AutoMLDataSource)
-> AutoMLChannel -> f AutoMLChannel
autoMLChannel_dataSource = (AutoMLChannel -> AutoMLDataSource)
-> (AutoMLChannel -> AutoMLDataSource -> AutoMLChannel)
-> Lens
     AutoMLChannel AutoMLChannel AutoMLDataSource AutoMLDataSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMLChannel' {AutoMLDataSource
dataSource :: AutoMLDataSource
$sel:dataSource:AutoMLChannel' :: AutoMLChannel -> AutoMLDataSource
dataSource} -> AutoMLDataSource
dataSource) (\s :: AutoMLChannel
s@AutoMLChannel' {} AutoMLDataSource
a -> AutoMLChannel
s {$sel:dataSource:AutoMLChannel' :: AutoMLDataSource
dataSource = AutoMLDataSource
a} :: AutoMLChannel)

-- | The name of the target variable in supervised learning, usually
-- represented by \'y\'.
autoMLChannel_targetAttributeName :: Lens.Lens' AutoMLChannel Prelude.Text
autoMLChannel_targetAttributeName :: (Text -> f Text) -> AutoMLChannel -> f AutoMLChannel
autoMLChannel_targetAttributeName = (AutoMLChannel -> Text)
-> (AutoMLChannel -> Text -> AutoMLChannel)
-> Lens AutoMLChannel AutoMLChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMLChannel' {Text
targetAttributeName :: Text
$sel:targetAttributeName:AutoMLChannel' :: AutoMLChannel -> Text
targetAttributeName} -> Text
targetAttributeName) (\s :: AutoMLChannel
s@AutoMLChannel' {} Text
a -> AutoMLChannel
s {$sel:targetAttributeName:AutoMLChannel' :: Text
targetAttributeName = Text
a} :: AutoMLChannel)

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

instance Prelude.Hashable AutoMLChannel

instance Prelude.NFData AutoMLChannel

instance Core.ToJSON AutoMLChannel where
  toJSON :: AutoMLChannel -> Value
toJSON AutoMLChannel' {Maybe CompressionType
Text
AutoMLDataSource
targetAttributeName :: Text
dataSource :: AutoMLDataSource
compressionType :: Maybe CompressionType
$sel:targetAttributeName:AutoMLChannel' :: AutoMLChannel -> Text
$sel:dataSource:AutoMLChannel' :: AutoMLChannel -> AutoMLDataSource
$sel:compressionType:AutoMLChannel' :: AutoMLChannel -> Maybe CompressionType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CompressionType" Text -> CompressionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CompressionType -> Pair) -> Maybe CompressionType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CompressionType
compressionType,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DataSource" Text -> AutoMLDataSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AutoMLDataSource
dataSource),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TargetAttributeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
targetAttributeName)
          ]
      )