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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.DirectSchemaChangePolicy
import Amazonka.Glue.Types.ParquetCompressionType
import qualified Amazonka.Prelude as Prelude

-- | Specifies a data target that writes to Amazon S3 in Apache Parquet
-- columnar storage.
--
-- /See:/ 'newS3GlueParquetTarget' smart constructor.
data S3GlueParquetTarget = S3GlueParquetTarget'
  { -- | Specifies how the data is compressed. This is generally not necessary if
    -- the data has a standard file extension. Possible values are @\"gzip\"@
    -- and @\"bzip\"@).
    S3GlueParquetTarget -> Maybe ParquetCompressionType
compression :: Prelude.Maybe ParquetCompressionType,
    -- | Specifies native partitioning using a sequence of keys.
    S3GlueParquetTarget -> Maybe [[Text]]
partitionKeys :: Prelude.Maybe [[Prelude.Text]],
    -- | A policy that specifies update behavior for the crawler.
    S3GlueParquetTarget -> Maybe DirectSchemaChangePolicy
schemaChangePolicy :: Prelude.Maybe DirectSchemaChangePolicy,
    -- | The name of the data target.
    S3GlueParquetTarget -> Text
name :: Prelude.Text,
    -- | The nodes that are inputs to the data target.
    S3GlueParquetTarget -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text,
    -- | A single Amazon S3 path to write to.
    S3GlueParquetTarget -> Text
path :: Prelude.Text
  }
  deriving (S3GlueParquetTarget -> S3GlueParquetTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3GlueParquetTarget -> S3GlueParquetTarget -> Bool
$c/= :: S3GlueParquetTarget -> S3GlueParquetTarget -> Bool
== :: S3GlueParquetTarget -> S3GlueParquetTarget -> Bool
$c== :: S3GlueParquetTarget -> S3GlueParquetTarget -> Bool
Prelude.Eq, ReadPrec [S3GlueParquetTarget]
ReadPrec S3GlueParquetTarget
Int -> ReadS S3GlueParquetTarget
ReadS [S3GlueParquetTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3GlueParquetTarget]
$creadListPrec :: ReadPrec [S3GlueParquetTarget]
readPrec :: ReadPrec S3GlueParquetTarget
$creadPrec :: ReadPrec S3GlueParquetTarget
readList :: ReadS [S3GlueParquetTarget]
$creadList :: ReadS [S3GlueParquetTarget]
readsPrec :: Int -> ReadS S3GlueParquetTarget
$creadsPrec :: Int -> ReadS S3GlueParquetTarget
Prelude.Read, Int -> S3GlueParquetTarget -> ShowS
[S3GlueParquetTarget] -> ShowS
S3GlueParquetTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3GlueParquetTarget] -> ShowS
$cshowList :: [S3GlueParquetTarget] -> ShowS
show :: S3GlueParquetTarget -> String
$cshow :: S3GlueParquetTarget -> String
showsPrec :: Int -> S3GlueParquetTarget -> ShowS
$cshowsPrec :: Int -> S3GlueParquetTarget -> ShowS
Prelude.Show, forall x. Rep S3GlueParquetTarget x -> S3GlueParquetTarget
forall x. S3GlueParquetTarget -> Rep S3GlueParquetTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3GlueParquetTarget x -> S3GlueParquetTarget
$cfrom :: forall x. S3GlueParquetTarget -> Rep S3GlueParquetTarget x
Prelude.Generic)

-- |
-- Create a value of 'S3GlueParquetTarget' 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:
--
-- 'compression', 's3GlueParquetTarget_compression' - Specifies how the data is compressed. This is generally not necessary if
-- the data has a standard file extension. Possible values are @\"gzip\"@
-- and @\"bzip\"@).
--
-- 'partitionKeys', 's3GlueParquetTarget_partitionKeys' - Specifies native partitioning using a sequence of keys.
--
-- 'schemaChangePolicy', 's3GlueParquetTarget_schemaChangePolicy' - A policy that specifies update behavior for the crawler.
--
-- 'name', 's3GlueParquetTarget_name' - The name of the data target.
--
-- 'inputs', 's3GlueParquetTarget_inputs' - The nodes that are inputs to the data target.
--
-- 'path', 's3GlueParquetTarget_path' - A single Amazon S3 path to write to.
newS3GlueParquetTarget ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'path'
  Prelude.Text ->
  S3GlueParquetTarget
newS3GlueParquetTarget :: Text -> NonEmpty Text -> Text -> S3GlueParquetTarget
newS3GlueParquetTarget Text
pName_ NonEmpty Text
pInputs_ Text
pPath_ =
  S3GlueParquetTarget'
    { $sel:compression:S3GlueParquetTarget' :: Maybe ParquetCompressionType
compression = forall a. Maybe a
Prelude.Nothing,
      $sel:partitionKeys:S3GlueParquetTarget' :: Maybe [[Text]]
partitionKeys = forall a. Maybe a
Prelude.Nothing,
      $sel:schemaChangePolicy:S3GlueParquetTarget' :: Maybe DirectSchemaChangePolicy
schemaChangePolicy = forall a. Maybe a
Prelude.Nothing,
      $sel:name:S3GlueParquetTarget' :: Text
name = Text
pName_,
      $sel:inputs:S3GlueParquetTarget' :: NonEmpty Text
inputs = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pInputs_,
      $sel:path:S3GlueParquetTarget' :: Text
path = Text
pPath_
    }

-- | Specifies how the data is compressed. This is generally not necessary if
-- the data has a standard file extension. Possible values are @\"gzip\"@
-- and @\"bzip\"@).
s3GlueParquetTarget_compression :: Lens.Lens' S3GlueParquetTarget (Prelude.Maybe ParquetCompressionType)
s3GlueParquetTarget_compression :: Lens' S3GlueParquetTarget (Maybe ParquetCompressionType)
s3GlueParquetTarget_compression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3GlueParquetTarget' {Maybe ParquetCompressionType
compression :: Maybe ParquetCompressionType
$sel:compression:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe ParquetCompressionType
compression} -> Maybe ParquetCompressionType
compression) (\s :: S3GlueParquetTarget
s@S3GlueParquetTarget' {} Maybe ParquetCompressionType
a -> S3GlueParquetTarget
s {$sel:compression:S3GlueParquetTarget' :: Maybe ParquetCompressionType
compression = Maybe ParquetCompressionType
a} :: S3GlueParquetTarget)

-- | Specifies native partitioning using a sequence of keys.
s3GlueParquetTarget_partitionKeys :: Lens.Lens' S3GlueParquetTarget (Prelude.Maybe [[Prelude.Text]])
s3GlueParquetTarget_partitionKeys :: Lens' S3GlueParquetTarget (Maybe [[Text]])
s3GlueParquetTarget_partitionKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3GlueParquetTarget' {Maybe [[Text]]
partitionKeys :: Maybe [[Text]]
$sel:partitionKeys:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe [[Text]]
partitionKeys} -> Maybe [[Text]]
partitionKeys) (\s :: S3GlueParquetTarget
s@S3GlueParquetTarget' {} Maybe [[Text]]
a -> S3GlueParquetTarget
s {$sel:partitionKeys:S3GlueParquetTarget' :: Maybe [[Text]]
partitionKeys = Maybe [[Text]]
a} :: S3GlueParquetTarget) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A policy that specifies update behavior for the crawler.
s3GlueParquetTarget_schemaChangePolicy :: Lens.Lens' S3GlueParquetTarget (Prelude.Maybe DirectSchemaChangePolicy)
s3GlueParquetTarget_schemaChangePolicy :: Lens' S3GlueParquetTarget (Maybe DirectSchemaChangePolicy)
s3GlueParquetTarget_schemaChangePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3GlueParquetTarget' {Maybe DirectSchemaChangePolicy
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
$sel:schemaChangePolicy:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe DirectSchemaChangePolicy
schemaChangePolicy} -> Maybe DirectSchemaChangePolicy
schemaChangePolicy) (\s :: S3GlueParquetTarget
s@S3GlueParquetTarget' {} Maybe DirectSchemaChangePolicy
a -> S3GlueParquetTarget
s {$sel:schemaChangePolicy:S3GlueParquetTarget' :: Maybe DirectSchemaChangePolicy
schemaChangePolicy = Maybe DirectSchemaChangePolicy
a} :: S3GlueParquetTarget)

-- | The name of the data target.
s3GlueParquetTarget_name :: Lens.Lens' S3GlueParquetTarget Prelude.Text
s3GlueParquetTarget_name :: Lens' S3GlueParquetTarget Text
s3GlueParquetTarget_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3GlueParquetTarget' {Text
name :: Text
$sel:name:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
name} -> Text
name) (\s :: S3GlueParquetTarget
s@S3GlueParquetTarget' {} Text
a -> S3GlueParquetTarget
s {$sel:name:S3GlueParquetTarget' :: Text
name = Text
a} :: S3GlueParquetTarget)

-- | The nodes that are inputs to the data target.
s3GlueParquetTarget_inputs :: Lens.Lens' S3GlueParquetTarget (Prelude.NonEmpty Prelude.Text)
s3GlueParquetTarget_inputs :: Lens' S3GlueParquetTarget (NonEmpty Text)
s3GlueParquetTarget_inputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3GlueParquetTarget' {NonEmpty Text
inputs :: NonEmpty Text
$sel:inputs:S3GlueParquetTarget' :: S3GlueParquetTarget -> NonEmpty Text
inputs} -> NonEmpty Text
inputs) (\s :: S3GlueParquetTarget
s@S3GlueParquetTarget' {} NonEmpty Text
a -> S3GlueParquetTarget
s {$sel:inputs:S3GlueParquetTarget' :: NonEmpty Text
inputs = NonEmpty Text
a} :: S3GlueParquetTarget) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A single Amazon S3 path to write to.
s3GlueParquetTarget_path :: Lens.Lens' S3GlueParquetTarget Prelude.Text
s3GlueParquetTarget_path :: Lens' S3GlueParquetTarget Text
s3GlueParquetTarget_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3GlueParquetTarget' {Text
path :: Text
$sel:path:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
path} -> Text
path) (\s :: S3GlueParquetTarget
s@S3GlueParquetTarget' {} Text
a -> S3GlueParquetTarget
s {$sel:path:S3GlueParquetTarget' :: Text
path = Text
a} :: S3GlueParquetTarget)

instance Data.FromJSON S3GlueParquetTarget where
  parseJSON :: Value -> Parser S3GlueParquetTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3GlueParquetTarget"
      ( \Object
x ->
          Maybe ParquetCompressionType
-> Maybe [[Text]]
-> Maybe DirectSchemaChangePolicy
-> Text
-> NonEmpty Text
-> Text
-> S3GlueParquetTarget
S3GlueParquetTarget'
            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
"Compression")
            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
"PartitionKeys" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"SchemaChangePolicy")
            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
"Name")
            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
"Inputs")
            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
"Path")
      )

instance Prelude.Hashable S3GlueParquetTarget where
  hashWithSalt :: Int -> S3GlueParquetTarget -> Int
hashWithSalt Int
_salt S3GlueParquetTarget' {Maybe [[Text]]
Maybe ParquetCompressionType
Maybe DirectSchemaChangePolicy
NonEmpty Text
Text
path :: Text
inputs :: NonEmpty Text
name :: Text
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
partitionKeys :: Maybe [[Text]]
compression :: Maybe ParquetCompressionType
$sel:path:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
$sel:inputs:S3GlueParquetTarget' :: S3GlueParquetTarget -> NonEmpty Text
$sel:name:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
$sel:schemaChangePolicy:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe DirectSchemaChangePolicy
$sel:partitionKeys:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe [[Text]]
$sel:compression:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe ParquetCompressionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ParquetCompressionType
compression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [[Text]]
partitionKeys
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DirectSchemaChangePolicy
schemaChangePolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
inputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path

instance Prelude.NFData S3GlueParquetTarget where
  rnf :: S3GlueParquetTarget -> ()
rnf S3GlueParquetTarget' {Maybe [[Text]]
Maybe ParquetCompressionType
Maybe DirectSchemaChangePolicy
NonEmpty Text
Text
path :: Text
inputs :: NonEmpty Text
name :: Text
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
partitionKeys :: Maybe [[Text]]
compression :: Maybe ParquetCompressionType
$sel:path:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
$sel:inputs:S3GlueParquetTarget' :: S3GlueParquetTarget -> NonEmpty Text
$sel:name:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
$sel:schemaChangePolicy:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe DirectSchemaChangePolicy
$sel:partitionKeys:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe [[Text]]
$sel:compression:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe ParquetCompressionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ParquetCompressionType
compression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [[Text]]
partitionKeys
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DirectSchemaChangePolicy
schemaChangePolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
inputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
path

instance Data.ToJSON S3GlueParquetTarget where
  toJSON :: S3GlueParquetTarget -> Value
toJSON S3GlueParquetTarget' {Maybe [[Text]]
Maybe ParquetCompressionType
Maybe DirectSchemaChangePolicy
NonEmpty Text
Text
path :: Text
inputs :: NonEmpty Text
name :: Text
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
partitionKeys :: Maybe [[Text]]
compression :: Maybe ParquetCompressionType
$sel:path:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
$sel:inputs:S3GlueParquetTarget' :: S3GlueParquetTarget -> NonEmpty Text
$sel:name:S3GlueParquetTarget' :: S3GlueParquetTarget -> Text
$sel:schemaChangePolicy:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe DirectSchemaChangePolicy
$sel:partitionKeys:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe [[Text]]
$sel:compression:S3GlueParquetTarget' :: S3GlueParquetTarget -> Maybe ParquetCompressionType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Compression" 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 ParquetCompressionType
compression,
            (Key
"PartitionKeys" 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]]
partitionKeys,
            (Key
"SchemaChangePolicy" 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 DirectSchemaChangePolicy
schemaChangePolicy,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Inputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
inputs),
            forall a. a -> Maybe a
Prelude.Just (Key
"Path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
path)
          ]
      )