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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.ArtifactSourceIdType

-- | The ID and ID type of an artifact source.
--
-- /See:/ 'newArtifactSourceType' smart constructor.
data ArtifactSourceType = ArtifactSourceType'
  { -- | The type of ID.
    ArtifactSourceType -> ArtifactSourceIdType
sourceIdType :: ArtifactSourceIdType,
    -- | The ID.
    ArtifactSourceType -> Text
value :: Prelude.Text
  }
  deriving (ArtifactSourceType -> ArtifactSourceType -> Bool
(ArtifactSourceType -> ArtifactSourceType -> Bool)
-> (ArtifactSourceType -> ArtifactSourceType -> Bool)
-> Eq ArtifactSourceType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArtifactSourceType -> ArtifactSourceType -> Bool
$c/= :: ArtifactSourceType -> ArtifactSourceType -> Bool
== :: ArtifactSourceType -> ArtifactSourceType -> Bool
$c== :: ArtifactSourceType -> ArtifactSourceType -> Bool
Prelude.Eq, ReadPrec [ArtifactSourceType]
ReadPrec ArtifactSourceType
Int -> ReadS ArtifactSourceType
ReadS [ArtifactSourceType]
(Int -> ReadS ArtifactSourceType)
-> ReadS [ArtifactSourceType]
-> ReadPrec ArtifactSourceType
-> ReadPrec [ArtifactSourceType]
-> Read ArtifactSourceType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArtifactSourceType]
$creadListPrec :: ReadPrec [ArtifactSourceType]
readPrec :: ReadPrec ArtifactSourceType
$creadPrec :: ReadPrec ArtifactSourceType
readList :: ReadS [ArtifactSourceType]
$creadList :: ReadS [ArtifactSourceType]
readsPrec :: Int -> ReadS ArtifactSourceType
$creadsPrec :: Int -> ReadS ArtifactSourceType
Prelude.Read, Int -> ArtifactSourceType -> ShowS
[ArtifactSourceType] -> ShowS
ArtifactSourceType -> String
(Int -> ArtifactSourceType -> ShowS)
-> (ArtifactSourceType -> String)
-> ([ArtifactSourceType] -> ShowS)
-> Show ArtifactSourceType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArtifactSourceType] -> ShowS
$cshowList :: [ArtifactSourceType] -> ShowS
show :: ArtifactSourceType -> String
$cshow :: ArtifactSourceType -> String
showsPrec :: Int -> ArtifactSourceType -> ShowS
$cshowsPrec :: Int -> ArtifactSourceType -> ShowS
Prelude.Show, (forall x. ArtifactSourceType -> Rep ArtifactSourceType x)
-> (forall x. Rep ArtifactSourceType x -> ArtifactSourceType)
-> Generic ArtifactSourceType
forall x. Rep ArtifactSourceType x -> ArtifactSourceType
forall x. ArtifactSourceType -> Rep ArtifactSourceType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArtifactSourceType x -> ArtifactSourceType
$cfrom :: forall x. ArtifactSourceType -> Rep ArtifactSourceType x
Prelude.Generic)

-- |
-- Create a value of 'ArtifactSourceType' 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:
--
-- 'sourceIdType', 'artifactSourceType_sourceIdType' - The type of ID.
--
-- 'value', 'artifactSourceType_value' - The ID.
newArtifactSourceType ::
  -- | 'sourceIdType'
  ArtifactSourceIdType ->
  -- | 'value'
  Prelude.Text ->
  ArtifactSourceType
newArtifactSourceType :: ArtifactSourceIdType -> Text -> ArtifactSourceType
newArtifactSourceType ArtifactSourceIdType
pSourceIdType_ Text
pValue_ =
  ArtifactSourceType' :: ArtifactSourceIdType -> Text -> ArtifactSourceType
ArtifactSourceType'
    { $sel:sourceIdType:ArtifactSourceType' :: ArtifactSourceIdType
sourceIdType = ArtifactSourceIdType
pSourceIdType_,
      $sel:value:ArtifactSourceType' :: Text
value = Text
pValue_
    }

-- | The type of ID.
artifactSourceType_sourceIdType :: Lens.Lens' ArtifactSourceType ArtifactSourceIdType
artifactSourceType_sourceIdType :: (ArtifactSourceIdType -> f ArtifactSourceIdType)
-> ArtifactSourceType -> f ArtifactSourceType
artifactSourceType_sourceIdType = (ArtifactSourceType -> ArtifactSourceIdType)
-> (ArtifactSourceType
    -> ArtifactSourceIdType -> ArtifactSourceType)
-> Lens
     ArtifactSourceType
     ArtifactSourceType
     ArtifactSourceIdType
     ArtifactSourceIdType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactSourceType' {ArtifactSourceIdType
sourceIdType :: ArtifactSourceIdType
$sel:sourceIdType:ArtifactSourceType' :: ArtifactSourceType -> ArtifactSourceIdType
sourceIdType} -> ArtifactSourceIdType
sourceIdType) (\s :: ArtifactSourceType
s@ArtifactSourceType' {} ArtifactSourceIdType
a -> ArtifactSourceType
s {$sel:sourceIdType:ArtifactSourceType' :: ArtifactSourceIdType
sourceIdType = ArtifactSourceIdType
a} :: ArtifactSourceType)

-- | The ID.
artifactSourceType_value :: Lens.Lens' ArtifactSourceType Prelude.Text
artifactSourceType_value :: (Text -> f Text) -> ArtifactSourceType -> f ArtifactSourceType
artifactSourceType_value = (ArtifactSourceType -> Text)
-> (ArtifactSourceType -> Text -> ArtifactSourceType)
-> Lens ArtifactSourceType ArtifactSourceType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactSourceType' {Text
value :: Text
$sel:value:ArtifactSourceType' :: ArtifactSourceType -> Text
value} -> Text
value) (\s :: ArtifactSourceType
s@ArtifactSourceType' {} Text
a -> ArtifactSourceType
s {$sel:value:ArtifactSourceType' :: Text
value = Text
a} :: ArtifactSourceType)

instance Core.FromJSON ArtifactSourceType where
  parseJSON :: Value -> Parser ArtifactSourceType
parseJSON =
    String
-> (Object -> Parser ArtifactSourceType)
-> Value
-> Parser ArtifactSourceType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArtifactSourceType"
      ( \Object
x ->
          ArtifactSourceIdType -> Text -> ArtifactSourceType
ArtifactSourceType'
            (ArtifactSourceIdType -> Text -> ArtifactSourceType)
-> Parser ArtifactSourceIdType
-> Parser (Text -> ArtifactSourceType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ArtifactSourceIdType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourceIdType")
            Parser (Text -> ArtifactSourceType)
-> Parser Text -> Parser ArtifactSourceType
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 ArtifactSourceType

instance Prelude.NFData ArtifactSourceType

instance Core.ToJSON ArtifactSourceType where
  toJSON :: ArtifactSourceType -> Value
toJSON ArtifactSourceType' {Text
ArtifactSourceIdType
value :: Text
sourceIdType :: ArtifactSourceIdType
$sel:value:ArtifactSourceType' :: ArtifactSourceType -> Text
$sel:sourceIdType:ArtifactSourceType' :: ArtifactSourceType -> ArtifactSourceIdType
..} =
    [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
"SourceIdType" Text -> ArtifactSourceIdType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ArtifactSourceIdType
sourceIdType),
            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)
          ]
      )