{-# 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.Glue.Types.MappingEntry
-- 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.Glue.Types.MappingEntry 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

-- | Defines a mapping.
--
-- /See:/ 'newMappingEntry' smart constructor.
data MappingEntry = MappingEntry'
  { -- | The source path.
    MappingEntry -> Maybe Text
sourcePath :: Prelude.Maybe Prelude.Text,
    -- | The name of the source table.
    MappingEntry -> Maybe Text
sourceTable :: Prelude.Maybe Prelude.Text,
    -- | The source type.
    MappingEntry -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The target path.
    MappingEntry -> Maybe Text
targetPath :: Prelude.Maybe Prelude.Text,
    -- | The target table.
    MappingEntry -> Maybe Text
targetTable :: Prelude.Maybe Prelude.Text,
    -- | The target type.
    MappingEntry -> Maybe Text
targetType :: Prelude.Maybe Prelude.Text
  }
  deriving (MappingEntry -> MappingEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MappingEntry -> MappingEntry -> Bool
$c/= :: MappingEntry -> MappingEntry -> Bool
== :: MappingEntry -> MappingEntry -> Bool
$c== :: MappingEntry -> MappingEntry -> Bool
Prelude.Eq, ReadPrec [MappingEntry]
ReadPrec MappingEntry
Int -> ReadS MappingEntry
ReadS [MappingEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MappingEntry]
$creadListPrec :: ReadPrec [MappingEntry]
readPrec :: ReadPrec MappingEntry
$creadPrec :: ReadPrec MappingEntry
readList :: ReadS [MappingEntry]
$creadList :: ReadS [MappingEntry]
readsPrec :: Int -> ReadS MappingEntry
$creadsPrec :: Int -> ReadS MappingEntry
Prelude.Read, Int -> MappingEntry -> ShowS
[MappingEntry] -> ShowS
MappingEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MappingEntry] -> ShowS
$cshowList :: [MappingEntry] -> ShowS
show :: MappingEntry -> String
$cshow :: MappingEntry -> String
showsPrec :: Int -> MappingEntry -> ShowS
$cshowsPrec :: Int -> MappingEntry -> ShowS
Prelude.Show, forall x. Rep MappingEntry x -> MappingEntry
forall x. MappingEntry -> Rep MappingEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MappingEntry x -> MappingEntry
$cfrom :: forall x. MappingEntry -> Rep MappingEntry x
Prelude.Generic)

-- |
-- Create a value of 'MappingEntry' 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:
--
-- 'sourcePath', 'mappingEntry_sourcePath' - The source path.
--
-- 'sourceTable', 'mappingEntry_sourceTable' - The name of the source table.
--
-- 'sourceType', 'mappingEntry_sourceType' - The source type.
--
-- 'targetPath', 'mappingEntry_targetPath' - The target path.
--
-- 'targetTable', 'mappingEntry_targetTable' - The target table.
--
-- 'targetType', 'mappingEntry_targetType' - The target type.
newMappingEntry ::
  MappingEntry
newMappingEntry :: MappingEntry
newMappingEntry =
  MappingEntry'
    { $sel:sourcePath:MappingEntry' :: Maybe Text
sourcePath = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceTable:MappingEntry' :: Maybe Text
sourceTable = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceType:MappingEntry' :: Maybe Text
sourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:targetPath:MappingEntry' :: Maybe Text
targetPath = forall a. Maybe a
Prelude.Nothing,
      $sel:targetTable:MappingEntry' :: Maybe Text
targetTable = forall a. Maybe a
Prelude.Nothing,
      $sel:targetType:MappingEntry' :: Maybe Text
targetType = forall a. Maybe a
Prelude.Nothing
    }

-- | The source path.
mappingEntry_sourcePath :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_sourcePath :: Lens' MappingEntry (Maybe Text)
mappingEntry_sourcePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingEntry' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:MappingEntry' :: MappingEntry -> Maybe Text
sourcePath} -> Maybe Text
sourcePath) (\s :: MappingEntry
s@MappingEntry' {} Maybe Text
a -> MappingEntry
s {$sel:sourcePath:MappingEntry' :: Maybe Text
sourcePath = Maybe Text
a} :: MappingEntry)

-- | The name of the source table.
mappingEntry_sourceTable :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_sourceTable :: Lens' MappingEntry (Maybe Text)
mappingEntry_sourceTable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingEntry' {Maybe Text
sourceTable :: Maybe Text
$sel:sourceTable:MappingEntry' :: MappingEntry -> Maybe Text
sourceTable} -> Maybe Text
sourceTable) (\s :: MappingEntry
s@MappingEntry' {} Maybe Text
a -> MappingEntry
s {$sel:sourceTable:MappingEntry' :: Maybe Text
sourceTable = Maybe Text
a} :: MappingEntry)

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

-- | The target path.
mappingEntry_targetPath :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_targetPath :: Lens' MappingEntry (Maybe Text)
mappingEntry_targetPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingEntry' {Maybe Text
targetPath :: Maybe Text
$sel:targetPath:MappingEntry' :: MappingEntry -> Maybe Text
targetPath} -> Maybe Text
targetPath) (\s :: MappingEntry
s@MappingEntry' {} Maybe Text
a -> MappingEntry
s {$sel:targetPath:MappingEntry' :: Maybe Text
targetPath = Maybe Text
a} :: MappingEntry)

-- | The target table.
mappingEntry_targetTable :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_targetTable :: Lens' MappingEntry (Maybe Text)
mappingEntry_targetTable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingEntry' {Maybe Text
targetTable :: Maybe Text
$sel:targetTable:MappingEntry' :: MappingEntry -> Maybe Text
targetTable} -> Maybe Text
targetTable) (\s :: MappingEntry
s@MappingEntry' {} Maybe Text
a -> MappingEntry
s {$sel:targetTable:MappingEntry' :: Maybe Text
targetTable = Maybe Text
a} :: MappingEntry)

-- | The target type.
mappingEntry_targetType :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_targetType :: Lens' MappingEntry (Maybe Text)
mappingEntry_targetType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingEntry' {Maybe Text
targetType :: Maybe Text
$sel:targetType:MappingEntry' :: MappingEntry -> Maybe Text
targetType} -> Maybe Text
targetType) (\s :: MappingEntry
s@MappingEntry' {} Maybe Text
a -> MappingEntry
s {$sel:targetType:MappingEntry' :: Maybe Text
targetType = Maybe Text
a} :: MappingEntry)

instance Data.FromJSON MappingEntry where
  parseJSON :: Value -> Parser MappingEntry
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MappingEntry"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> MappingEntry
MappingEntry'
            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
"SourcePath")
            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
"SourceTable")
            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 (Maybe a)
Data..:? Key
"TargetPath")
            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
"TargetTable")
            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
"TargetType")
      )

instance Prelude.Hashable MappingEntry where
  hashWithSalt :: Int -> MappingEntry -> Int
hashWithSalt Int
_salt MappingEntry' {Maybe Text
targetType :: Maybe Text
targetTable :: Maybe Text
targetPath :: Maybe Text
sourceType :: Maybe Text
sourceTable :: Maybe Text
sourcePath :: Maybe Text
$sel:targetType:MappingEntry' :: MappingEntry -> Maybe Text
$sel:targetTable:MappingEntry' :: MappingEntry -> Maybe Text
$sel:targetPath:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourceType:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourceTable:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourcePath:MappingEntry' :: MappingEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourcePath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceTable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetTable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetType

instance Prelude.NFData MappingEntry where
  rnf :: MappingEntry -> ()
rnf MappingEntry' {Maybe Text
targetType :: Maybe Text
targetTable :: Maybe Text
targetPath :: Maybe Text
sourceType :: Maybe Text
sourceTable :: Maybe Text
sourcePath :: Maybe Text
$sel:targetType:MappingEntry' :: MappingEntry -> Maybe Text
$sel:targetTable:MappingEntry' :: MappingEntry -> Maybe Text
$sel:targetPath:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourceType:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourceTable:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourcePath:MappingEntry' :: MappingEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourcePath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceTable
      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 Maybe Text
targetPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetTable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetType

instance Data.ToJSON MappingEntry where
  toJSON :: MappingEntry -> Value
toJSON MappingEntry' {Maybe Text
targetType :: Maybe Text
targetTable :: Maybe Text
targetPath :: Maybe Text
sourceType :: Maybe Text
sourceTable :: Maybe Text
sourcePath :: Maybe Text
$sel:targetType:MappingEntry' :: MappingEntry -> Maybe Text
$sel:targetTable:MappingEntry' :: MappingEntry -> Maybe Text
$sel:targetPath:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourceType:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourceTable:MappingEntry' :: MappingEntry -> Maybe Text
$sel:sourcePath:MappingEntry' :: MappingEntry -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SourcePath" 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
sourcePath,
            (Key
"SourceTable" 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
sourceTable,
            (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,
            (Key
"TargetPath" 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
targetPath,
            (Key
"TargetTable" 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
targetTable,
            (Key
"TargetType" 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
targetType
          ]
      )