{-# 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-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.ActionSource 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 an action.
--
-- /See:/ 'newActionSource' smart constructor.
data ActionSource = ActionSource'
  { -- | The ID of the source.
    ActionSource -> Maybe Text
sourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of the source.
    ActionSource -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The URI of the source.
    ActionSource -> Text
sourceUri :: Prelude.Text
  }
  deriving (ActionSource -> ActionSource -> Bool
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]
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
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. 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:
--
-- 'sourceId', 'actionSource_sourceId' - The ID of the source.
--
-- 'sourceType', 'actionSource_sourceType' - The type of the source.
--
-- 'sourceUri', 'actionSource_sourceUri' - The URI of the source.
newActionSource ::
  -- | 'sourceUri'
  Prelude.Text ->
  ActionSource
newActionSource :: Text -> ActionSource
newActionSource Text
pSourceUri_ =
  ActionSource'
    { $sel:sourceId:ActionSource' :: Maybe Text
sourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceType:ActionSource' :: Maybe Text
sourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUri:ActionSource' :: Text
sourceUri = Text
pSourceUri_
    }

-- | The ID of the source.
actionSource_sourceId :: Lens.Lens' ActionSource (Prelude.Maybe Prelude.Text)
actionSource_sourceId :: Lens' ActionSource (Maybe Text)
actionSource_sourceId = 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 type of the source.
actionSource_sourceType :: Lens.Lens' ActionSource (Prelude.Maybe Prelude.Text)
actionSource_sourceType :: Lens' ActionSource (Maybe Text)
actionSource_sourceType = 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 URI of the source.
actionSource_sourceUri :: Lens.Lens' ActionSource Prelude.Text
actionSource_sourceUri :: Lens' ActionSource Text
actionSource_sourceUri = 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 Data.FromJSON ActionSource where
  parseJSON :: Value -> Parser ActionSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ActionSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> ActionSource
ActionSource'
            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 ActionSource where
  hashWithSalt :: Int -> ActionSource -> Int
hashWithSalt Int
_salt ActionSource' {Maybe Text
Text
sourceUri :: Text
sourceType :: Maybe Text
sourceId :: Maybe Text
$sel:sourceUri:ActionSource' :: ActionSource -> Text
$sel:sourceType:ActionSource' :: ActionSource -> Maybe Text
$sel:sourceId:ActionSource' :: ActionSource -> 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 ActionSource where
  rnf :: ActionSource -> ()
rnf ActionSource' {Maybe Text
Text
sourceUri :: Text
sourceType :: Maybe Text
sourceId :: Maybe Text
$sel:sourceUri:ActionSource' :: ActionSource -> Text
$sel:sourceType:ActionSource' :: ActionSource -> Maybe Text
$sel:sourceId:ActionSource' :: ActionSource -> 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 ActionSource where
  toJSON :: ActionSource -> Value
toJSON ActionSource' {Maybe Text
Text
sourceUri :: Text
sourceType :: Maybe Text
sourceId :: Maybe Text
$sel:sourceUri:ActionSource' :: ActionSource -> Text
$sel:sourceType:ActionSource' :: ActionSource -> Maybe Text
$sel:sourceId:ActionSource' :: ActionSource -> 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)
          ]
      )