{-# 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.ContextSource
-- 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.ContextSource 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

-- | A structure describing the source of a context.
--
-- /See:/ 'newContextSource' smart constructor.
data ContextSource = ContextSource'
  { -- | The ID of the source.
    ContextSource -> Maybe Text
sourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of the source.
    ContextSource -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The URI of the source.
    ContextSource -> Text
sourceUri :: Prelude.Text
  }
  deriving (ContextSource -> ContextSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContextSource -> ContextSource -> Bool
$c/= :: ContextSource -> ContextSource -> Bool
== :: ContextSource -> ContextSource -> Bool
$c== :: ContextSource -> ContextSource -> Bool
Prelude.Eq, ReadPrec [ContextSource]
ReadPrec ContextSource
Int -> ReadS ContextSource
ReadS [ContextSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContextSource]
$creadListPrec :: ReadPrec [ContextSource]
readPrec :: ReadPrec ContextSource
$creadPrec :: ReadPrec ContextSource
readList :: ReadS [ContextSource]
$creadList :: ReadS [ContextSource]
readsPrec :: Int -> ReadS ContextSource
$creadsPrec :: Int -> ReadS ContextSource
Prelude.Read, Int -> ContextSource -> ShowS
[ContextSource] -> ShowS
ContextSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContextSource] -> ShowS
$cshowList :: [ContextSource] -> ShowS
show :: ContextSource -> String
$cshow :: ContextSource -> String
showsPrec :: Int -> ContextSource -> ShowS
$cshowsPrec :: Int -> ContextSource -> ShowS
Prelude.Show, forall x. Rep ContextSource x -> ContextSource
forall x. ContextSource -> Rep ContextSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContextSource x -> ContextSource
$cfrom :: forall x. ContextSource -> Rep ContextSource x
Prelude.Generic)

-- |
-- Create a value of 'ContextSource' 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:
--
-- 'sourceId', 'contextSource_sourceId' - The ID of the source.
--
-- 'sourceType', 'contextSource_sourceType' - The type of the source.
--
-- 'sourceUri', 'contextSource_sourceUri' - The URI of the source.
newContextSource ::
  -- | 'sourceUri'
  Prelude.Text ->
  ContextSource
newContextSource :: Text -> ContextSource
newContextSource Text
pSourceUri_ =
  ContextSource'
    { $sel:sourceId:ContextSource' :: Maybe Text
sourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceType:ContextSource' :: Maybe Text
sourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUri:ContextSource' :: Text
sourceUri = Text
pSourceUri_
    }

-- | The ID of the source.
contextSource_sourceId :: Lens.Lens' ContextSource (Prelude.Maybe Prelude.Text)
contextSource_sourceId :: Lens' ContextSource (Maybe Text)
contextSource_sourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContextSource' {Maybe Text
sourceId :: Maybe Text
$sel:sourceId:ContextSource' :: ContextSource -> Maybe Text
sourceId} -> Maybe Text
sourceId) (\s :: ContextSource
s@ContextSource' {} Maybe Text
a -> ContextSource
s {$sel:sourceId:ContextSource' :: Maybe Text
sourceId = Maybe Text
a} :: ContextSource)

-- | The type of the source.
contextSource_sourceType :: Lens.Lens' ContextSource (Prelude.Maybe Prelude.Text)
contextSource_sourceType :: Lens' ContextSource (Maybe Text)
contextSource_sourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContextSource' {Maybe Text
sourceType :: Maybe Text
$sel:sourceType:ContextSource' :: ContextSource -> Maybe Text
sourceType} -> Maybe Text
sourceType) (\s :: ContextSource
s@ContextSource' {} Maybe Text
a -> ContextSource
s {$sel:sourceType:ContextSource' :: Maybe Text
sourceType = Maybe Text
a} :: ContextSource)

-- | The URI of the source.
contextSource_sourceUri :: Lens.Lens' ContextSource Prelude.Text
contextSource_sourceUri :: Lens' ContextSource Text
contextSource_sourceUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContextSource' {Text
sourceUri :: Text
$sel:sourceUri:ContextSource' :: ContextSource -> Text
sourceUri} -> Text
sourceUri) (\s :: ContextSource
s@ContextSource' {} Text
a -> ContextSource
s {$sel:sourceUri:ContextSource' :: Text
sourceUri = Text
a} :: ContextSource)

instance Data.FromJSON ContextSource where
  parseJSON :: Value -> Parser ContextSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContextSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> ContextSource
ContextSource'
            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
"SourceId")
            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
"SourceType")
            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
"SourceUri")
      )

instance Prelude.Hashable ContextSource where
  hashWithSalt :: Int -> ContextSource -> Int
hashWithSalt Int
_salt ContextSource' {Maybe Text
Text
sourceUri :: Text
sourceType :: Maybe Text
sourceId :: Maybe Text
$sel:sourceUri:ContextSource' :: ContextSource -> Text
$sel:sourceType:ContextSource' :: ContextSource -> Maybe Text
$sel:sourceId:ContextSource' :: ContextSource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceUri

instance Prelude.NFData ContextSource where
  rnf :: ContextSource -> ()
rnf ContextSource' {Maybe Text
Text
sourceUri :: Text
sourceType :: Maybe Text
sourceId :: Maybe Text
$sel:sourceUri:ContextSource' :: ContextSource -> Text
$sel:sourceType:ContextSource' :: ContextSource -> Maybe Text
$sel:sourceId:ContextSource' :: ContextSource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceUri

instance Data.ToJSON ContextSource where
  toJSON :: ContextSource -> Value
toJSON ContextSource' {Maybe Text
Text
sourceUri :: Text
sourceType :: Maybe Text
sourceId :: Maybe Text
$sel:sourceUri:ContextSource' :: ContextSource -> Text
$sel:sourceType:ContextSource' :: ContextSource -> Maybe Text
$sel:sourceId:ContextSource' :: ContextSource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SourceId" 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
sourceId,
            (Key
"SourceType" 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
sourceType,
            forall a. a -> Maybe a
Prelude.Just (Key
"SourceUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceUri)
          ]
      )