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

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

-- | Information about a serialization\/deserialization program (SerDe) that
-- serves as an extractor and loader.
--
-- /See:/ 'newSerDeInfo' smart constructor.
data SerDeInfo = SerDeInfo'
  { -- | Usually the class that implements the SerDe. An example is
    -- @org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe@.
    SerDeInfo -> Maybe Text
serializationLibrary :: Prelude.Maybe Prelude.Text,
    -- | Name of the SerDe.
    SerDeInfo -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | These key-value pairs define initialization parameters for the SerDe.
    SerDeInfo -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (SerDeInfo -> SerDeInfo -> Bool
(SerDeInfo -> SerDeInfo -> Bool)
-> (SerDeInfo -> SerDeInfo -> Bool) -> Eq SerDeInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SerDeInfo -> SerDeInfo -> Bool
$c/= :: SerDeInfo -> SerDeInfo -> Bool
== :: SerDeInfo -> SerDeInfo -> Bool
$c== :: SerDeInfo -> SerDeInfo -> Bool
Prelude.Eq, ReadPrec [SerDeInfo]
ReadPrec SerDeInfo
Int -> ReadS SerDeInfo
ReadS [SerDeInfo]
(Int -> ReadS SerDeInfo)
-> ReadS [SerDeInfo]
-> ReadPrec SerDeInfo
-> ReadPrec [SerDeInfo]
-> Read SerDeInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SerDeInfo]
$creadListPrec :: ReadPrec [SerDeInfo]
readPrec :: ReadPrec SerDeInfo
$creadPrec :: ReadPrec SerDeInfo
readList :: ReadS [SerDeInfo]
$creadList :: ReadS [SerDeInfo]
readsPrec :: Int -> ReadS SerDeInfo
$creadsPrec :: Int -> ReadS SerDeInfo
Prelude.Read, Int -> SerDeInfo -> ShowS
[SerDeInfo] -> ShowS
SerDeInfo -> String
(Int -> SerDeInfo -> ShowS)
-> (SerDeInfo -> String)
-> ([SerDeInfo] -> ShowS)
-> Show SerDeInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SerDeInfo] -> ShowS
$cshowList :: [SerDeInfo] -> ShowS
show :: SerDeInfo -> String
$cshow :: SerDeInfo -> String
showsPrec :: Int -> SerDeInfo -> ShowS
$cshowsPrec :: Int -> SerDeInfo -> ShowS
Prelude.Show, (forall x. SerDeInfo -> Rep SerDeInfo x)
-> (forall x. Rep SerDeInfo x -> SerDeInfo) -> Generic SerDeInfo
forall x. Rep SerDeInfo x -> SerDeInfo
forall x. SerDeInfo -> Rep SerDeInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SerDeInfo x -> SerDeInfo
$cfrom :: forall x. SerDeInfo -> Rep SerDeInfo x
Prelude.Generic)

-- |
-- Create a value of 'SerDeInfo' 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:
--
-- 'serializationLibrary', 'serDeInfo_serializationLibrary' - Usually the class that implements the SerDe. An example is
-- @org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe@.
--
-- 'name', 'serDeInfo_name' - Name of the SerDe.
--
-- 'parameters', 'serDeInfo_parameters' - These key-value pairs define initialization parameters for the SerDe.
newSerDeInfo ::
  SerDeInfo
newSerDeInfo :: SerDeInfo
newSerDeInfo =
  SerDeInfo' :: Maybe Text -> Maybe Text -> Maybe (HashMap Text Text) -> SerDeInfo
SerDeInfo'
    { $sel:serializationLibrary:SerDeInfo' :: Maybe Text
serializationLibrary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:SerDeInfo' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:SerDeInfo' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Usually the class that implements the SerDe. An example is
-- @org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe@.
serDeInfo_serializationLibrary :: Lens.Lens' SerDeInfo (Prelude.Maybe Prelude.Text)
serDeInfo_serializationLibrary :: (Maybe Text -> f (Maybe Text)) -> SerDeInfo -> f SerDeInfo
serDeInfo_serializationLibrary = (SerDeInfo -> Maybe Text)
-> (SerDeInfo -> Maybe Text -> SerDeInfo)
-> Lens SerDeInfo SerDeInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SerDeInfo' {Maybe Text
serializationLibrary :: Maybe Text
$sel:serializationLibrary:SerDeInfo' :: SerDeInfo -> Maybe Text
serializationLibrary} -> Maybe Text
serializationLibrary) (\s :: SerDeInfo
s@SerDeInfo' {} Maybe Text
a -> SerDeInfo
s {$sel:serializationLibrary:SerDeInfo' :: Maybe Text
serializationLibrary = Maybe Text
a} :: SerDeInfo)

-- | Name of the SerDe.
serDeInfo_name :: Lens.Lens' SerDeInfo (Prelude.Maybe Prelude.Text)
serDeInfo_name :: (Maybe Text -> f (Maybe Text)) -> SerDeInfo -> f SerDeInfo
serDeInfo_name = (SerDeInfo -> Maybe Text)
-> (SerDeInfo -> Maybe Text -> SerDeInfo)
-> Lens SerDeInfo SerDeInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SerDeInfo' {Maybe Text
name :: Maybe Text
$sel:name:SerDeInfo' :: SerDeInfo -> Maybe Text
name} -> Maybe Text
name) (\s :: SerDeInfo
s@SerDeInfo' {} Maybe Text
a -> SerDeInfo
s {$sel:name:SerDeInfo' :: Maybe Text
name = Maybe Text
a} :: SerDeInfo)

-- | These key-value pairs define initialization parameters for the SerDe.
serDeInfo_parameters :: Lens.Lens' SerDeInfo (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
serDeInfo_parameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SerDeInfo -> f SerDeInfo
serDeInfo_parameters = (SerDeInfo -> Maybe (HashMap Text Text))
-> (SerDeInfo -> Maybe (HashMap Text Text) -> SerDeInfo)
-> Lens
     SerDeInfo
     SerDeInfo
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SerDeInfo' {Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
$sel:parameters:SerDeInfo' :: SerDeInfo -> Maybe (HashMap Text Text)
parameters} -> Maybe (HashMap Text Text)
parameters) (\s :: SerDeInfo
s@SerDeInfo' {} Maybe (HashMap Text Text)
a -> SerDeInfo
s {$sel:parameters:SerDeInfo' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
a} :: SerDeInfo) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> SerDeInfo -> f SerDeInfo)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SerDeInfo
-> f SerDeInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SerDeInfo where
  parseJSON :: Value -> Parser SerDeInfo
parseJSON =
    String -> (Object -> Parser SerDeInfo) -> Value -> Parser SerDeInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SerDeInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe (HashMap Text Text) -> SerDeInfo
SerDeInfo'
            (Maybe Text
 -> Maybe Text -> Maybe (HashMap Text Text) -> SerDeInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe (HashMap Text Text) -> SerDeInfo)
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
"SerializationLibrary")
            Parser (Maybe Text -> Maybe (HashMap Text Text) -> SerDeInfo)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> SerDeInfo)
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
"Name")
            Parser (Maybe (HashMap Text Text) -> SerDeInfo)
-> Parser (Maybe (HashMap Text Text)) -> Parser SerDeInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SerDeInfo

instance Prelude.NFData SerDeInfo

instance Core.ToJSON SerDeInfo where
  toJSON :: SerDeInfo -> Value
toJSON SerDeInfo' {Maybe Text
Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
name :: Maybe Text
serializationLibrary :: Maybe Text
$sel:parameters:SerDeInfo' :: SerDeInfo -> Maybe (HashMap Text Text)
$sel:name:SerDeInfo' :: SerDeInfo -> Maybe Text
$sel:serializationLibrary:SerDeInfo' :: SerDeInfo -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SerializationLibrary" 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
serializationLibrary,
            (Text
"Name" 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
name,
            (Text
"Parameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
parameters
          ]
      )