{-# 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-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.ArtifactSourceType 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.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
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]
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
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. 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'
    { $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 :: Lens' ArtifactSourceType ArtifactSourceIdType
artifactSourceType_sourceIdType = 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 :: Lens' ArtifactSourceType Text
artifactSourceType_value = 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 Data.FromJSON ArtifactSourceType where
  parseJSON :: Value -> Parser ArtifactSourceType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ArtifactSourceType"
      ( \Object
x ->
          ArtifactSourceIdType -> Text -> ArtifactSourceType
ArtifactSourceType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SourceIdType")
            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
"Value")
      )

instance Prelude.Hashable ArtifactSourceType where
  hashWithSalt :: Int -> ArtifactSourceType -> Int
hashWithSalt Int
_salt ArtifactSourceType' {Text
ArtifactSourceIdType
value :: Text
sourceIdType :: ArtifactSourceIdType
$sel:value:ArtifactSourceType' :: ArtifactSourceType -> Text
$sel:sourceIdType:ArtifactSourceType' :: ArtifactSourceType -> ArtifactSourceIdType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ArtifactSourceIdType
sourceIdType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData ArtifactSourceType where
  rnf :: ArtifactSourceType -> ()
rnf ArtifactSourceType' {Text
ArtifactSourceIdType
value :: Text
sourceIdType :: ArtifactSourceIdType
$sel:value:ArtifactSourceType' :: ArtifactSourceType -> Text
$sel:sourceIdType:ArtifactSourceType' :: ArtifactSourceType -> ArtifactSourceIdType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ArtifactSourceIdType
sourceIdType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"SourceIdType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ArtifactSourceIdType
sourceIdType),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )