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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents an input or output artifact of a trial component. You specify
-- @TrialComponentArtifact@ as part of the @InputArtifacts@ and
-- @OutputArtifacts@ parameters in the CreateTrialComponent request.
--
-- Examples of input artifacts are datasets, algorithms, hyperparameters,
-- source code, and instance types. Examples of output artifacts are
-- metrics, snapshots, logs, and images.
--
-- /See:/ 'newTrialComponentArtifact' smart constructor.
data TrialComponentArtifact = TrialComponentArtifact'
  { -- | The media type of the artifact, which indicates the type of data in the
    -- artifact file. The media type consists of a /type/ and a /subtype/
    -- concatenated with a slash (\/) character, for example, text\/csv,
    -- image\/jpeg, and s3\/uri. The type specifies the category of the media.
    -- The subtype specifies the kind of data.
    TrialComponentArtifact -> Maybe Text
mediaType :: Prelude.Maybe Prelude.Text,
    -- | The location of the artifact.
    TrialComponentArtifact -> Text
value :: Prelude.Text
  }
  deriving (TrialComponentArtifact -> TrialComponentArtifact -> Bool
(TrialComponentArtifact -> TrialComponentArtifact -> Bool)
-> (TrialComponentArtifact -> TrialComponentArtifact -> Bool)
-> Eq TrialComponentArtifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrialComponentArtifact -> TrialComponentArtifact -> Bool
$c/= :: TrialComponentArtifact -> TrialComponentArtifact -> Bool
== :: TrialComponentArtifact -> TrialComponentArtifact -> Bool
$c== :: TrialComponentArtifact -> TrialComponentArtifact -> Bool
Prelude.Eq, ReadPrec [TrialComponentArtifact]
ReadPrec TrialComponentArtifact
Int -> ReadS TrialComponentArtifact
ReadS [TrialComponentArtifact]
(Int -> ReadS TrialComponentArtifact)
-> ReadS [TrialComponentArtifact]
-> ReadPrec TrialComponentArtifact
-> ReadPrec [TrialComponentArtifact]
-> Read TrialComponentArtifact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrialComponentArtifact]
$creadListPrec :: ReadPrec [TrialComponentArtifact]
readPrec :: ReadPrec TrialComponentArtifact
$creadPrec :: ReadPrec TrialComponentArtifact
readList :: ReadS [TrialComponentArtifact]
$creadList :: ReadS [TrialComponentArtifact]
readsPrec :: Int -> ReadS TrialComponentArtifact
$creadsPrec :: Int -> ReadS TrialComponentArtifact
Prelude.Read, Int -> TrialComponentArtifact -> ShowS
[TrialComponentArtifact] -> ShowS
TrialComponentArtifact -> String
(Int -> TrialComponentArtifact -> ShowS)
-> (TrialComponentArtifact -> String)
-> ([TrialComponentArtifact] -> ShowS)
-> Show TrialComponentArtifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrialComponentArtifact] -> ShowS
$cshowList :: [TrialComponentArtifact] -> ShowS
show :: TrialComponentArtifact -> String
$cshow :: TrialComponentArtifact -> String
showsPrec :: Int -> TrialComponentArtifact -> ShowS
$cshowsPrec :: Int -> TrialComponentArtifact -> ShowS
Prelude.Show, (forall x. TrialComponentArtifact -> Rep TrialComponentArtifact x)
-> (forall x.
    Rep TrialComponentArtifact x -> TrialComponentArtifact)
-> Generic TrialComponentArtifact
forall x. Rep TrialComponentArtifact x -> TrialComponentArtifact
forall x. TrialComponentArtifact -> Rep TrialComponentArtifact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrialComponentArtifact x -> TrialComponentArtifact
$cfrom :: forall x. TrialComponentArtifact -> Rep TrialComponentArtifact x
Prelude.Generic)

-- |
-- Create a value of 'TrialComponentArtifact' 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:
--
-- 'mediaType', 'trialComponentArtifact_mediaType' - The media type of the artifact, which indicates the type of data in the
-- artifact file. The media type consists of a /type/ and a /subtype/
-- concatenated with a slash (\/) character, for example, text\/csv,
-- image\/jpeg, and s3\/uri. The type specifies the category of the media.
-- The subtype specifies the kind of data.
--
-- 'value', 'trialComponentArtifact_value' - The location of the artifact.
newTrialComponentArtifact ::
  -- | 'value'
  Prelude.Text ->
  TrialComponentArtifact
newTrialComponentArtifact :: Text -> TrialComponentArtifact
newTrialComponentArtifact Text
pValue_ =
  TrialComponentArtifact' :: Maybe Text -> Text -> TrialComponentArtifact
TrialComponentArtifact'
    { $sel:mediaType:TrialComponentArtifact' :: Maybe Text
mediaType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:TrialComponentArtifact' :: Text
value = Text
pValue_
    }

-- | The media type of the artifact, which indicates the type of data in the
-- artifact file. The media type consists of a /type/ and a /subtype/
-- concatenated with a slash (\/) character, for example, text\/csv,
-- image\/jpeg, and s3\/uri. The type specifies the category of the media.
-- The subtype specifies the kind of data.
trialComponentArtifact_mediaType :: Lens.Lens' TrialComponentArtifact (Prelude.Maybe Prelude.Text)
trialComponentArtifact_mediaType :: (Maybe Text -> f (Maybe Text))
-> TrialComponentArtifact -> f TrialComponentArtifact
trialComponentArtifact_mediaType = (TrialComponentArtifact -> Maybe Text)
-> (TrialComponentArtifact -> Maybe Text -> TrialComponentArtifact)
-> Lens
     TrialComponentArtifact
     TrialComponentArtifact
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrialComponentArtifact' {Maybe Text
mediaType :: Maybe Text
$sel:mediaType:TrialComponentArtifact' :: TrialComponentArtifact -> Maybe Text
mediaType} -> Maybe Text
mediaType) (\s :: TrialComponentArtifact
s@TrialComponentArtifact' {} Maybe Text
a -> TrialComponentArtifact
s {$sel:mediaType:TrialComponentArtifact' :: Maybe Text
mediaType = Maybe Text
a} :: TrialComponentArtifact)

-- | The location of the artifact.
trialComponentArtifact_value :: Lens.Lens' TrialComponentArtifact Prelude.Text
trialComponentArtifact_value :: (Text -> f Text)
-> TrialComponentArtifact -> f TrialComponentArtifact
trialComponentArtifact_value = (TrialComponentArtifact -> Text)
-> (TrialComponentArtifact -> Text -> TrialComponentArtifact)
-> Lens TrialComponentArtifact TrialComponentArtifact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrialComponentArtifact' {Text
value :: Text
$sel:value:TrialComponentArtifact' :: TrialComponentArtifact -> Text
value} -> Text
value) (\s :: TrialComponentArtifact
s@TrialComponentArtifact' {} Text
a -> TrialComponentArtifact
s {$sel:value:TrialComponentArtifact' :: Text
value = Text
a} :: TrialComponentArtifact)

instance Core.FromJSON TrialComponentArtifact where
  parseJSON :: Value -> Parser TrialComponentArtifact
parseJSON =
    String
-> (Object -> Parser TrialComponentArtifact)
-> Value
-> Parser TrialComponentArtifact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrialComponentArtifact"
      ( \Object
x ->
          Maybe Text -> Text -> TrialComponentArtifact
TrialComponentArtifact'
            (Maybe Text -> Text -> TrialComponentArtifact)
-> Parser (Maybe Text) -> Parser (Text -> TrialComponentArtifact)
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
"MediaType")
            Parser (Text -> TrialComponentArtifact)
-> Parser Text -> Parser TrialComponentArtifact
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
"Value")
      )

instance Prelude.Hashable TrialComponentArtifact

instance Prelude.NFData TrialComponentArtifact

instance Core.ToJSON TrialComponentArtifact where
  toJSON :: TrialComponentArtifact -> Value
toJSON TrialComponentArtifact' {Maybe Text
Text
value :: Text
mediaType :: Maybe Text
$sel:value:TrialComponentArtifact' :: TrialComponentArtifact -> Text
$sel:mediaType:TrialComponentArtifact' :: TrialComponentArtifact -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MediaType" 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
mediaType,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )