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

-- |
-- Create a value of 'ActionSource' 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', 'actionSource_sourceType' - The type of the source.
--
-- 'sourceId', 'actionSource_sourceId' - The ID of the source.
--
-- 'sourceUri', 'actionSource_sourceUri' - The URI of the source.
newActionSource ::
  -- | 'sourceUri'
  Prelude.Text ->
  ActionSource
newActionSource :: Text -> ActionSource
newActionSource Text
pSourceUri_ =
  ActionSource' :: Maybe Text -> Maybe Text -> Text -> ActionSource
ActionSource'
    { $sel:sourceType:ActionSource' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceId:ActionSource' :: Maybe Text
sourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUri:ActionSource' :: Text
sourceUri = Text
pSourceUri_
    }

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

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

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

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

instance Prelude.NFData ActionSource

instance Core.ToJSON ActionSource where
  toJSON :: ActionSource -> Value
toJSON ActionSource' {Maybe Text
Text
sourceUri :: Text
sourceId :: Maybe Text
sourceType :: Maybe Text
$sel:sourceUri:ActionSource' :: ActionSource -> Text
$sel:sourceId:ActionSource' :: ActionSource -> Maybe Text
$sel:sourceType:ActionSource' :: ActionSource -> 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)
          ]
      )