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

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

-- | Defines a mapping.
--
-- /See:/ 'newMappingEntry' smart constructor.
data MappingEntry = MappingEntry'
  { -- | The target table.
    MappingEntry -> Maybe Text
targetTable :: Prelude.Maybe Prelude.Text,
    -- | The source type.
    MappingEntry -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The name of the source table.
    MappingEntry -> Maybe Text
sourceTable :: Prelude.Maybe Prelude.Text,
    -- | The target type.
    MappingEntry -> Maybe Text
targetType :: Prelude.Maybe Prelude.Text,
    -- | The target path.
    MappingEntry -> Maybe Text
targetPath :: Prelude.Maybe Prelude.Text,
    -- | The source path.
    MappingEntry -> Maybe Text
sourcePath :: Prelude.Maybe Prelude.Text
  }
  deriving (MappingEntry -> MappingEntry -> Bool
(MappingEntry -> MappingEntry -> Bool)
-> (MappingEntry -> MappingEntry -> Bool) -> Eq MappingEntry
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]
(Int -> ReadS MappingEntry)
-> ReadS [MappingEntry]
-> ReadPrec MappingEntry
-> ReadPrec [MappingEntry]
-> Read 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
(Int -> MappingEntry -> ShowS)
-> (MappingEntry -> String)
-> ([MappingEntry] -> ShowS)
-> Show MappingEntry
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. MappingEntry -> Rep MappingEntry x)
-> (forall x. Rep MappingEntry x -> MappingEntry)
-> Generic MappingEntry
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:
--
-- 'targetTable', 'mappingEntry_targetTable' - The target table.
--
-- 'sourceType', 'mappingEntry_sourceType' - The source type.
--
-- 'sourceTable', 'mappingEntry_sourceTable' - The name of the source table.
--
-- 'targetType', 'mappingEntry_targetType' - The target type.
--
-- 'targetPath', 'mappingEntry_targetPath' - The target path.
--
-- 'sourcePath', 'mappingEntry_sourcePath' - The source path.
newMappingEntry ::
  MappingEntry
newMappingEntry :: MappingEntry
newMappingEntry =
  MappingEntry' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> MappingEntry
MappingEntry'
    { $sel:targetTable:MappingEntry' :: Maybe Text
targetTable = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceType:MappingEntry' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceTable:MappingEntry' :: Maybe Text
sourceTable = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetType:MappingEntry' :: Maybe Text
targetType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetPath:MappingEntry' :: Maybe Text
targetPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePath:MappingEntry' :: Maybe Text
sourcePath = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The target table.
mappingEntry_targetTable :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_targetTable :: (Maybe Text -> f (Maybe Text)) -> MappingEntry -> f MappingEntry
mappingEntry_targetTable = (MappingEntry -> Maybe Text)
-> (MappingEntry -> Maybe Text -> MappingEntry)
-> Lens MappingEntry MappingEntry (Maybe Text) (Maybe Text)
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 source type.
mappingEntry_sourceType :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_sourceType :: (Maybe Text -> f (Maybe Text)) -> MappingEntry -> f MappingEntry
mappingEntry_sourceType = (MappingEntry -> Maybe Text)
-> (MappingEntry -> Maybe Text -> MappingEntry)
-> Lens MappingEntry MappingEntry (Maybe Text) (Maybe Text)
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 name of the source table.
mappingEntry_sourceTable :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_sourceTable :: (Maybe Text -> f (Maybe Text)) -> MappingEntry -> f MappingEntry
mappingEntry_sourceTable = (MappingEntry -> Maybe Text)
-> (MappingEntry -> Maybe Text -> MappingEntry)
-> Lens MappingEntry MappingEntry (Maybe Text) (Maybe Text)
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 target type.
mappingEntry_targetType :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_targetType :: (Maybe Text -> f (Maybe Text)) -> MappingEntry -> f MappingEntry
mappingEntry_targetType = (MappingEntry -> Maybe Text)
-> (MappingEntry -> Maybe Text -> MappingEntry)
-> Lens MappingEntry MappingEntry (Maybe Text) (Maybe Text)
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)

-- | The target path.
mappingEntry_targetPath :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_targetPath :: (Maybe Text -> f (Maybe Text)) -> MappingEntry -> f MappingEntry
mappingEntry_targetPath = (MappingEntry -> Maybe Text)
-> (MappingEntry -> Maybe Text -> MappingEntry)
-> Lens MappingEntry MappingEntry (Maybe Text) (Maybe Text)
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 source path.
mappingEntry_sourcePath :: Lens.Lens' MappingEntry (Prelude.Maybe Prelude.Text)
mappingEntry_sourcePath :: (Maybe Text -> f (Maybe Text)) -> MappingEntry -> f MappingEntry
mappingEntry_sourcePath = (MappingEntry -> Maybe Text)
-> (MappingEntry -> Maybe Text -> MappingEntry)
-> Lens MappingEntry MappingEntry (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable MappingEntry

instance Prelude.NFData MappingEntry

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