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

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

-- | A structure describing the source of a context.
--
-- /See:/ 'newContextSource' smart constructor.
data ContextSource = ContextSource'
  { -- | The type of the source.
    ContextSource -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The ID of the source.
    ContextSource -> Maybe Text
sourceId :: Prelude.Maybe Prelude.Text,
    -- | The URI of the source.
    ContextSource -> Text
sourceUri :: Prelude.Text
  }
  deriving (ContextSource -> ContextSource -> Bool
(ContextSource -> ContextSource -> Bool)
-> (ContextSource -> ContextSource -> Bool) -> Eq ContextSource
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]
(Int -> ReadS ContextSource)
-> ReadS [ContextSource]
-> ReadPrec ContextSource
-> ReadPrec [ContextSource]
-> Read 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
(Int -> ContextSource -> ShowS)
-> (ContextSource -> String)
-> ([ContextSource] -> ShowS)
-> Show ContextSource
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. ContextSource -> Rep ContextSource x)
-> (forall x. Rep ContextSource x -> ContextSource)
-> Generic ContextSource
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:
--
-- 'sourceType', 'contextSource_sourceType' - The type of the source.
--
-- 'sourceId', 'contextSource_sourceId' - The ID of the source.
--
-- 'sourceUri', 'contextSource_sourceUri' - The URI of the source.
newContextSource ::
  -- | 'sourceUri'
  Prelude.Text ->
  ContextSource
newContextSource :: Text -> ContextSource
newContextSource Text
pSourceUri_ =
  ContextSource' :: Maybe Text -> Maybe Text -> Text -> ContextSource
ContextSource'
    { $sel:sourceType:ContextSource' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceId:ContextSource' :: Maybe Text
sourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUri:ContextSource' :: Text
sourceUri = Text
pSourceUri_
    }

-- | The type of the source.
contextSource_sourceType :: Lens.Lens' ContextSource (Prelude.Maybe Prelude.Text)
contextSource_sourceType :: (Maybe Text -> f (Maybe Text)) -> ContextSource -> f ContextSource
contextSource_sourceType = (ContextSource -> Maybe Text)
-> (ContextSource -> Maybe Text -> ContextSource)
-> Lens ContextSource ContextSource (Maybe Text) (Maybe Text)
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 ID of the source.
contextSource_sourceId :: Lens.Lens' ContextSource (Prelude.Maybe Prelude.Text)
contextSource_sourceId :: (Maybe Text -> f (Maybe Text)) -> ContextSource -> f ContextSource
contextSource_sourceId = (ContextSource -> Maybe Text)
-> (ContextSource -> Maybe Text -> ContextSource)
-> Lens ContextSource ContextSource (Maybe Text) (Maybe Text)
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 URI of the source.
contextSource_sourceUri :: Lens.Lens' ContextSource Prelude.Text
contextSource_sourceUri :: (Text -> f Text) -> ContextSource -> f ContextSource
contextSource_sourceUri = (ContextSource -> Text)
-> (ContextSource -> Text -> ContextSource)
-> Lens ContextSource ContextSource Text Text
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 Core.FromJSON ContextSource where
  parseJSON :: Value -> Parser ContextSource
parseJSON =
    String
-> (Object -> Parser ContextSource)
-> Value
-> Parser ContextSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContextSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> ContextSource
ContextSource'
            (Maybe Text -> Maybe Text -> Text -> ContextSource)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> ContextSource)
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
"SourceType")
            Parser (Maybe Text -> Text -> ContextSource)
-> Parser (Maybe Text) -> Parser (Text -> ContextSource)
forall (f :: * -> *) a b. Applicative f => 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
"SourceId")
            Parser (Text -> ContextSource)
-> Parser Text -> Parser ContextSource
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
"SourceUri")
      )

instance Prelude.Hashable ContextSource

instance Prelude.NFData ContextSource

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