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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.CompressionType
import Amazonka.SageMaker.Types.TrainingInputMode

-- | Defines a named input source, called a channel, to be used by an
-- algorithm.
--
-- /See:/ 'newChannelSpecification' smart constructor.
data ChannelSpecification = ChannelSpecification'
  { -- | A brief description of the channel.
    ChannelSpecification -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the channel is required by the algorithm.
    ChannelSpecification -> Maybe Bool
isRequired :: Prelude.Maybe Prelude.Bool,
    -- | The allowed compression types, if data compression is used.
    ChannelSpecification -> Maybe [CompressionType]
supportedCompressionTypes :: Prelude.Maybe [CompressionType],
    -- | The name of the channel.
    ChannelSpecification -> Text
name :: Prelude.Text,
    -- | The supported MIME types for the data.
    ChannelSpecification -> [Text]
supportedContentTypes :: [Prelude.Text],
    -- | The allowed input mode, either FILE or PIPE.
    --
    -- In FILE mode, Amazon SageMaker copies the data from the input source
    -- onto the local Amazon Elastic Block Store (Amazon EBS) volumes before
    -- starting your training algorithm. This is the most commonly used input
    -- mode.
    --
    -- In PIPE mode, Amazon SageMaker streams input data from the source
    -- directly to your algorithm without using the EBS volume.
    ChannelSpecification -> NonEmpty TrainingInputMode
supportedInputModes :: Prelude.NonEmpty TrainingInputMode
  }
  deriving (ChannelSpecification -> ChannelSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelSpecification -> ChannelSpecification -> Bool
$c/= :: ChannelSpecification -> ChannelSpecification -> Bool
== :: ChannelSpecification -> ChannelSpecification -> Bool
$c== :: ChannelSpecification -> ChannelSpecification -> Bool
Prelude.Eq, ReadPrec [ChannelSpecification]
ReadPrec ChannelSpecification
Int -> ReadS ChannelSpecification
ReadS [ChannelSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelSpecification]
$creadListPrec :: ReadPrec [ChannelSpecification]
readPrec :: ReadPrec ChannelSpecification
$creadPrec :: ReadPrec ChannelSpecification
readList :: ReadS [ChannelSpecification]
$creadList :: ReadS [ChannelSpecification]
readsPrec :: Int -> ReadS ChannelSpecification
$creadsPrec :: Int -> ReadS ChannelSpecification
Prelude.Read, Int -> ChannelSpecification -> ShowS
[ChannelSpecification] -> ShowS
ChannelSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelSpecification] -> ShowS
$cshowList :: [ChannelSpecification] -> ShowS
show :: ChannelSpecification -> String
$cshow :: ChannelSpecification -> String
showsPrec :: Int -> ChannelSpecification -> ShowS
$cshowsPrec :: Int -> ChannelSpecification -> ShowS
Prelude.Show, forall x. Rep ChannelSpecification x -> ChannelSpecification
forall x. ChannelSpecification -> Rep ChannelSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelSpecification x -> ChannelSpecification
$cfrom :: forall x. ChannelSpecification -> Rep ChannelSpecification x
Prelude.Generic)

-- |
-- Create a value of 'ChannelSpecification' 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:
--
-- 'description', 'channelSpecification_description' - A brief description of the channel.
--
-- 'isRequired', 'channelSpecification_isRequired' - Indicates whether the channel is required by the algorithm.
--
-- 'supportedCompressionTypes', 'channelSpecification_supportedCompressionTypes' - The allowed compression types, if data compression is used.
--
-- 'name', 'channelSpecification_name' - The name of the channel.
--
-- 'supportedContentTypes', 'channelSpecification_supportedContentTypes' - The supported MIME types for the data.
--
-- 'supportedInputModes', 'channelSpecification_supportedInputModes' - The allowed input mode, either FILE or PIPE.
--
-- In FILE mode, Amazon SageMaker copies the data from the input source
-- onto the local Amazon Elastic Block Store (Amazon EBS) volumes before
-- starting your training algorithm. This is the most commonly used input
-- mode.
--
-- In PIPE mode, Amazon SageMaker streams input data from the source
-- directly to your algorithm without using the EBS volume.
newChannelSpecification ::
  -- | 'name'
  Prelude.Text ->
  -- | 'supportedInputModes'
  Prelude.NonEmpty TrainingInputMode ->
  ChannelSpecification
newChannelSpecification :: Text -> NonEmpty TrainingInputMode -> ChannelSpecification
newChannelSpecification Text
pName_ NonEmpty TrainingInputMode
pSupportedInputModes_ =
  ChannelSpecification'
    { $sel:description:ChannelSpecification' :: Maybe Text
description =
        forall a. Maybe a
Prelude.Nothing,
      $sel:isRequired:ChannelSpecification' :: Maybe Bool
isRequired = forall a. Maybe a
Prelude.Nothing,
      $sel:supportedCompressionTypes:ChannelSpecification' :: Maybe [CompressionType]
supportedCompressionTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ChannelSpecification' :: Text
name = Text
pName_,
      $sel:supportedContentTypes:ChannelSpecification' :: [Text]
supportedContentTypes = forall a. Monoid a => a
Prelude.mempty,
      $sel:supportedInputModes:ChannelSpecification' :: NonEmpty TrainingInputMode
supportedInputModes =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty TrainingInputMode
pSupportedInputModes_
    }

-- | A brief description of the channel.
channelSpecification_description :: Lens.Lens' ChannelSpecification (Prelude.Maybe Prelude.Text)
channelSpecification_description :: Lens' ChannelSpecification (Maybe Text)
channelSpecification_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSpecification' {Maybe Text
description :: Maybe Text
$sel:description:ChannelSpecification' :: ChannelSpecification -> Maybe Text
description} -> Maybe Text
description) (\s :: ChannelSpecification
s@ChannelSpecification' {} Maybe Text
a -> ChannelSpecification
s {$sel:description:ChannelSpecification' :: Maybe Text
description = Maybe Text
a} :: ChannelSpecification)

-- | Indicates whether the channel is required by the algorithm.
channelSpecification_isRequired :: Lens.Lens' ChannelSpecification (Prelude.Maybe Prelude.Bool)
channelSpecification_isRequired :: Lens' ChannelSpecification (Maybe Bool)
channelSpecification_isRequired = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSpecification' {Maybe Bool
isRequired :: Maybe Bool
$sel:isRequired:ChannelSpecification' :: ChannelSpecification -> Maybe Bool
isRequired} -> Maybe Bool
isRequired) (\s :: ChannelSpecification
s@ChannelSpecification' {} Maybe Bool
a -> ChannelSpecification
s {$sel:isRequired:ChannelSpecification' :: Maybe Bool
isRequired = Maybe Bool
a} :: ChannelSpecification)

-- | The allowed compression types, if data compression is used.
channelSpecification_supportedCompressionTypes :: Lens.Lens' ChannelSpecification (Prelude.Maybe [CompressionType])
channelSpecification_supportedCompressionTypes :: Lens' ChannelSpecification (Maybe [CompressionType])
channelSpecification_supportedCompressionTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSpecification' {Maybe [CompressionType]
supportedCompressionTypes :: Maybe [CompressionType]
$sel:supportedCompressionTypes:ChannelSpecification' :: ChannelSpecification -> Maybe [CompressionType]
supportedCompressionTypes} -> Maybe [CompressionType]
supportedCompressionTypes) (\s :: ChannelSpecification
s@ChannelSpecification' {} Maybe [CompressionType]
a -> ChannelSpecification
s {$sel:supportedCompressionTypes:ChannelSpecification' :: Maybe [CompressionType]
supportedCompressionTypes = Maybe [CompressionType]
a} :: ChannelSpecification) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the channel.
channelSpecification_name :: Lens.Lens' ChannelSpecification Prelude.Text
channelSpecification_name :: Lens' ChannelSpecification Text
channelSpecification_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSpecification' {Text
name :: Text
$sel:name:ChannelSpecification' :: ChannelSpecification -> Text
name} -> Text
name) (\s :: ChannelSpecification
s@ChannelSpecification' {} Text
a -> ChannelSpecification
s {$sel:name:ChannelSpecification' :: Text
name = Text
a} :: ChannelSpecification)

-- | The supported MIME types for the data.
channelSpecification_supportedContentTypes :: Lens.Lens' ChannelSpecification [Prelude.Text]
channelSpecification_supportedContentTypes :: Lens' ChannelSpecification [Text]
channelSpecification_supportedContentTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSpecification' {[Text]
supportedContentTypes :: [Text]
$sel:supportedContentTypes:ChannelSpecification' :: ChannelSpecification -> [Text]
supportedContentTypes} -> [Text]
supportedContentTypes) (\s :: ChannelSpecification
s@ChannelSpecification' {} [Text]
a -> ChannelSpecification
s {$sel:supportedContentTypes:ChannelSpecification' :: [Text]
supportedContentTypes = [Text]
a} :: ChannelSpecification) 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

-- | The allowed input mode, either FILE or PIPE.
--
-- In FILE mode, Amazon SageMaker copies the data from the input source
-- onto the local Amazon Elastic Block Store (Amazon EBS) volumes before
-- starting your training algorithm. This is the most commonly used input
-- mode.
--
-- In PIPE mode, Amazon SageMaker streams input data from the source
-- directly to your algorithm without using the EBS volume.
channelSpecification_supportedInputModes :: Lens.Lens' ChannelSpecification (Prelude.NonEmpty TrainingInputMode)
channelSpecification_supportedInputModes :: Lens' ChannelSpecification (NonEmpty TrainingInputMode)
channelSpecification_supportedInputModes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSpecification' {NonEmpty TrainingInputMode
supportedInputModes :: NonEmpty TrainingInputMode
$sel:supportedInputModes:ChannelSpecification' :: ChannelSpecification -> NonEmpty TrainingInputMode
supportedInputModes} -> NonEmpty TrainingInputMode
supportedInputModes) (\s :: ChannelSpecification
s@ChannelSpecification' {} NonEmpty TrainingInputMode
a -> ChannelSpecification
s {$sel:supportedInputModes:ChannelSpecification' :: NonEmpty TrainingInputMode
supportedInputModes = NonEmpty TrainingInputMode
a} :: ChannelSpecification) 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 ChannelSpecification where
  parseJSON :: Value -> Parser ChannelSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChannelSpecification"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe [CompressionType]
-> Text
-> [Text]
-> NonEmpty TrainingInputMode
-> ChannelSpecification
ChannelSpecification'
            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
"Description")
            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
"IsRequired")
            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
"SupportedCompressionTypes"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            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
"SupportedContentTypes"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SupportedInputModes")
      )

instance Prelude.Hashable ChannelSpecification where
  hashWithSalt :: Int -> ChannelSpecification -> Int
hashWithSalt Int
_salt ChannelSpecification' {[Text]
Maybe Bool
Maybe [CompressionType]
Maybe Text
NonEmpty TrainingInputMode
Text
supportedInputModes :: NonEmpty TrainingInputMode
supportedContentTypes :: [Text]
name :: Text
supportedCompressionTypes :: Maybe [CompressionType]
isRequired :: Maybe Bool
description :: Maybe Text
$sel:supportedInputModes:ChannelSpecification' :: ChannelSpecification -> NonEmpty TrainingInputMode
$sel:supportedContentTypes:ChannelSpecification' :: ChannelSpecification -> [Text]
$sel:name:ChannelSpecification' :: ChannelSpecification -> Text
$sel:supportedCompressionTypes:ChannelSpecification' :: ChannelSpecification -> Maybe [CompressionType]
$sel:isRequired:ChannelSpecification' :: ChannelSpecification -> Maybe Bool
$sel:description:ChannelSpecification' :: ChannelSpecification -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isRequired
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CompressionType]
supportedCompressionTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
supportedContentTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty TrainingInputMode
supportedInputModes

instance Prelude.NFData ChannelSpecification where
  rnf :: ChannelSpecification -> ()
rnf ChannelSpecification' {[Text]
Maybe Bool
Maybe [CompressionType]
Maybe Text
NonEmpty TrainingInputMode
Text
supportedInputModes :: NonEmpty TrainingInputMode
supportedContentTypes :: [Text]
name :: Text
supportedCompressionTypes :: Maybe [CompressionType]
isRequired :: Maybe Bool
description :: Maybe Text
$sel:supportedInputModes:ChannelSpecification' :: ChannelSpecification -> NonEmpty TrainingInputMode
$sel:supportedContentTypes:ChannelSpecification' :: ChannelSpecification -> [Text]
$sel:name:ChannelSpecification' :: ChannelSpecification -> Text
$sel:supportedCompressionTypes:ChannelSpecification' :: ChannelSpecification -> Maybe [CompressionType]
$sel:isRequired:ChannelSpecification' :: ChannelSpecification -> Maybe Bool
$sel:description:ChannelSpecification' :: ChannelSpecification -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isRequired
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [CompressionType]
supportedCompressionTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
supportedContentTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty TrainingInputMode
supportedInputModes

instance Data.ToJSON ChannelSpecification where
  toJSON :: ChannelSpecification -> Value
toJSON ChannelSpecification' {[Text]
Maybe Bool
Maybe [CompressionType]
Maybe Text
NonEmpty TrainingInputMode
Text
supportedInputModes :: NonEmpty TrainingInputMode
supportedContentTypes :: [Text]
name :: Text
supportedCompressionTypes :: Maybe [CompressionType]
isRequired :: Maybe Bool
description :: Maybe Text
$sel:supportedInputModes:ChannelSpecification' :: ChannelSpecification -> NonEmpty TrainingInputMode
$sel:supportedContentTypes:ChannelSpecification' :: ChannelSpecification -> [Text]
$sel:name:ChannelSpecification' :: ChannelSpecification -> Text
$sel:supportedCompressionTypes:ChannelSpecification' :: ChannelSpecification -> Maybe [CompressionType]
$sel:isRequired:ChannelSpecification' :: ChannelSpecification -> Maybe Bool
$sel:description:ChannelSpecification' :: ChannelSpecification -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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 Text
description,
            (Key
"IsRequired" 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 Bool
isRequired,
            (Key
"SupportedCompressionTypes" 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 [CompressionType]
supportedCompressionTypes,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"SupportedContentTypes"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
supportedContentTypes
              ),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SupportedInputModes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty TrainingInputMode
supportedInputModes)
          ]
      )