{-# 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.S3DirectTarget
-- 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.S3DirectTarget 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.TargetFormat
import qualified Amazonka.Prelude as Prelude

-- | Specifies a data target that writes to Amazon S3.
--
-- /See:/ 'newS3DirectTarget' smart constructor.
data S3DirectTarget = S3DirectTarget'
  { -- | 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\"@).
    S3DirectTarget -> Maybe Text
compression :: Prelude.Maybe Prelude.Text,
    -- | Specifies native partitioning using a sequence of keys.
    S3DirectTarget -> Maybe [[Text]]
partitionKeys :: Prelude.Maybe [[Prelude.Text]],
    -- | A policy that specifies update behavior for the crawler.
    S3DirectTarget -> Maybe DirectSchemaChangePolicy
schemaChangePolicy :: Prelude.Maybe DirectSchemaChangePolicy,
    -- | The name of the data target.
    S3DirectTarget -> Text
name :: Prelude.Text,
    -- | The nodes that are inputs to the data target.
    S3DirectTarget -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text,
    -- | A single Amazon S3 path to write to.
    S3DirectTarget -> Text
path :: Prelude.Text,
    -- | Specifies the data output format for the target.
    S3DirectTarget -> TargetFormat
format :: TargetFormat
  }
  deriving (S3DirectTarget -> S3DirectTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3DirectTarget -> S3DirectTarget -> Bool
$c/= :: S3DirectTarget -> S3DirectTarget -> Bool
== :: S3DirectTarget -> S3DirectTarget -> Bool
$c== :: S3DirectTarget -> S3DirectTarget -> Bool
Prelude.Eq, ReadPrec [S3DirectTarget]
ReadPrec S3DirectTarget
Int -> ReadS S3DirectTarget
ReadS [S3DirectTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3DirectTarget]
$creadListPrec :: ReadPrec [S3DirectTarget]
readPrec :: ReadPrec S3DirectTarget
$creadPrec :: ReadPrec S3DirectTarget
readList :: ReadS [S3DirectTarget]
$creadList :: ReadS [S3DirectTarget]
readsPrec :: Int -> ReadS S3DirectTarget
$creadsPrec :: Int -> ReadS S3DirectTarget
Prelude.Read, Int -> S3DirectTarget -> ShowS
[S3DirectTarget] -> ShowS
S3DirectTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3DirectTarget] -> ShowS
$cshowList :: [S3DirectTarget] -> ShowS
show :: S3DirectTarget -> String
$cshow :: S3DirectTarget -> String
showsPrec :: Int -> S3DirectTarget -> ShowS
$cshowsPrec :: Int -> S3DirectTarget -> ShowS
Prelude.Show, forall x. Rep S3DirectTarget x -> S3DirectTarget
forall x. S3DirectTarget -> Rep S3DirectTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3DirectTarget x -> S3DirectTarget
$cfrom :: forall x. S3DirectTarget -> Rep S3DirectTarget x
Prelude.Generic)

-- |
-- Create a value of 'S3DirectTarget' 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', 's3DirectTarget_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', 's3DirectTarget_partitionKeys' - Specifies native partitioning using a sequence of keys.
--
-- 'schemaChangePolicy', 's3DirectTarget_schemaChangePolicy' - A policy that specifies update behavior for the crawler.
--
-- 'name', 's3DirectTarget_name' - The name of the data target.
--
-- 'inputs', 's3DirectTarget_inputs' - The nodes that are inputs to the data target.
--
-- 'path', 's3DirectTarget_path' - A single Amazon S3 path to write to.
--
-- 'format', 's3DirectTarget_format' - Specifies the data output format for the target.
newS3DirectTarget ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'path'
  Prelude.Text ->
  -- | 'format'
  TargetFormat ->
  S3DirectTarget
newS3DirectTarget :: Text -> NonEmpty Text -> Text -> TargetFormat -> S3DirectTarget
newS3DirectTarget Text
pName_ NonEmpty Text
pInputs_ Text
pPath_ TargetFormat
pFormat_ =
  S3DirectTarget'
    { $sel:compression:S3DirectTarget' :: Maybe Text
compression = forall a. Maybe a
Prelude.Nothing,
      $sel:partitionKeys:S3DirectTarget' :: Maybe [[Text]]
partitionKeys = forall a. Maybe a
Prelude.Nothing,
      $sel:schemaChangePolicy:S3DirectTarget' :: Maybe DirectSchemaChangePolicy
schemaChangePolicy = forall a. Maybe a
Prelude.Nothing,
      $sel:name:S3DirectTarget' :: Text
name = Text
pName_,
      $sel:inputs:S3DirectTarget' :: 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:S3DirectTarget' :: Text
path = Text
pPath_,
      $sel:format:S3DirectTarget' :: TargetFormat
format = TargetFormat
pFormat_
    }

-- | 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\"@).
s3DirectTarget_compression :: Lens.Lens' S3DirectTarget (Prelude.Maybe Prelude.Text)
s3DirectTarget_compression :: Lens' S3DirectTarget (Maybe Text)
s3DirectTarget_compression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DirectTarget' {Maybe Text
compression :: Maybe Text
$sel:compression:S3DirectTarget' :: S3DirectTarget -> Maybe Text
compression} -> Maybe Text
compression) (\s :: S3DirectTarget
s@S3DirectTarget' {} Maybe Text
a -> S3DirectTarget
s {$sel:compression:S3DirectTarget' :: Maybe Text
compression = Maybe Text
a} :: S3DirectTarget)

-- | Specifies native partitioning using a sequence of keys.
s3DirectTarget_partitionKeys :: Lens.Lens' S3DirectTarget (Prelude.Maybe [[Prelude.Text]])
s3DirectTarget_partitionKeys :: Lens' S3DirectTarget (Maybe [[Text]])
s3DirectTarget_partitionKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DirectTarget' {Maybe [[Text]]
partitionKeys :: Maybe [[Text]]
$sel:partitionKeys:S3DirectTarget' :: S3DirectTarget -> Maybe [[Text]]
partitionKeys} -> Maybe [[Text]]
partitionKeys) (\s :: S3DirectTarget
s@S3DirectTarget' {} Maybe [[Text]]
a -> S3DirectTarget
s {$sel:partitionKeys:S3DirectTarget' :: Maybe [[Text]]
partitionKeys = Maybe [[Text]]
a} :: S3DirectTarget) 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.
s3DirectTarget_schemaChangePolicy :: Lens.Lens' S3DirectTarget (Prelude.Maybe DirectSchemaChangePolicy)
s3DirectTarget_schemaChangePolicy :: Lens' S3DirectTarget (Maybe DirectSchemaChangePolicy)
s3DirectTarget_schemaChangePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DirectTarget' {Maybe DirectSchemaChangePolicy
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
$sel:schemaChangePolicy:S3DirectTarget' :: S3DirectTarget -> Maybe DirectSchemaChangePolicy
schemaChangePolicy} -> Maybe DirectSchemaChangePolicy
schemaChangePolicy) (\s :: S3DirectTarget
s@S3DirectTarget' {} Maybe DirectSchemaChangePolicy
a -> S3DirectTarget
s {$sel:schemaChangePolicy:S3DirectTarget' :: Maybe DirectSchemaChangePolicy
schemaChangePolicy = Maybe DirectSchemaChangePolicy
a} :: S3DirectTarget)

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

-- | The nodes that are inputs to the data target.
s3DirectTarget_inputs :: Lens.Lens' S3DirectTarget (Prelude.NonEmpty Prelude.Text)
s3DirectTarget_inputs :: Lens' S3DirectTarget (NonEmpty Text)
s3DirectTarget_inputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DirectTarget' {NonEmpty Text
inputs :: NonEmpty Text
$sel:inputs:S3DirectTarget' :: S3DirectTarget -> NonEmpty Text
inputs} -> NonEmpty Text
inputs) (\s :: S3DirectTarget
s@S3DirectTarget' {} NonEmpty Text
a -> S3DirectTarget
s {$sel:inputs:S3DirectTarget' :: NonEmpty Text
inputs = NonEmpty Text
a} :: S3DirectTarget) 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.
s3DirectTarget_path :: Lens.Lens' S3DirectTarget Prelude.Text
s3DirectTarget_path :: Lens' S3DirectTarget Text
s3DirectTarget_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DirectTarget' {Text
path :: Text
$sel:path:S3DirectTarget' :: S3DirectTarget -> Text
path} -> Text
path) (\s :: S3DirectTarget
s@S3DirectTarget' {} Text
a -> S3DirectTarget
s {$sel:path:S3DirectTarget' :: Text
path = Text
a} :: S3DirectTarget)

-- | Specifies the data output format for the target.
s3DirectTarget_format :: Lens.Lens' S3DirectTarget TargetFormat
s3DirectTarget_format :: Lens' S3DirectTarget TargetFormat
s3DirectTarget_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DirectTarget' {TargetFormat
format :: TargetFormat
$sel:format:S3DirectTarget' :: S3DirectTarget -> TargetFormat
format} -> TargetFormat
format) (\s :: S3DirectTarget
s@S3DirectTarget' {} TargetFormat
a -> S3DirectTarget
s {$sel:format:S3DirectTarget' :: TargetFormat
format = TargetFormat
a} :: S3DirectTarget)

instance Data.FromJSON S3DirectTarget where
  parseJSON :: Value -> Parser S3DirectTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3DirectTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe [[Text]]
-> Maybe DirectSchemaChangePolicy
-> Text
-> NonEmpty Text
-> Text
-> TargetFormat
-> S3DirectTarget
S3DirectTarget'
            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")
            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
"Format")
      )

instance Prelude.Hashable S3DirectTarget where
  hashWithSalt :: Int -> S3DirectTarget -> Int
hashWithSalt Int
_salt S3DirectTarget' {Maybe [[Text]]
Maybe Text
Maybe DirectSchemaChangePolicy
NonEmpty Text
Text
TargetFormat
format :: TargetFormat
path :: Text
inputs :: NonEmpty Text
name :: Text
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
partitionKeys :: Maybe [[Text]]
compression :: Maybe Text
$sel:format:S3DirectTarget' :: S3DirectTarget -> TargetFormat
$sel:path:S3DirectTarget' :: S3DirectTarget -> Text
$sel:inputs:S3DirectTarget' :: S3DirectTarget -> NonEmpty Text
$sel:name:S3DirectTarget' :: S3DirectTarget -> Text
$sel:schemaChangePolicy:S3DirectTarget' :: S3DirectTarget -> Maybe DirectSchemaChangePolicy
$sel:partitionKeys:S3DirectTarget' :: S3DirectTarget -> Maybe [[Text]]
$sel:compression:S3DirectTarget' :: S3DirectTarget -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TargetFormat
format

instance Prelude.NFData S3DirectTarget where
  rnf :: S3DirectTarget -> ()
rnf S3DirectTarget' {Maybe [[Text]]
Maybe Text
Maybe DirectSchemaChangePolicy
NonEmpty Text
Text
TargetFormat
format :: TargetFormat
path :: Text
inputs :: NonEmpty Text
name :: Text
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
partitionKeys :: Maybe [[Text]]
compression :: Maybe Text
$sel:format:S3DirectTarget' :: S3DirectTarget -> TargetFormat
$sel:path:S3DirectTarget' :: S3DirectTarget -> Text
$sel:inputs:S3DirectTarget' :: S3DirectTarget -> NonEmpty Text
$sel:name:S3DirectTarget' :: S3DirectTarget -> Text
$sel:schemaChangePolicy:S3DirectTarget' :: S3DirectTarget -> Maybe DirectSchemaChangePolicy
$sel:partitionKeys:S3DirectTarget' :: S3DirectTarget -> Maybe [[Text]]
$sel:compression:S3DirectTarget' :: S3DirectTarget -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TargetFormat
format

instance Data.ToJSON S3DirectTarget where
  toJSON :: S3DirectTarget -> Value
toJSON S3DirectTarget' {Maybe [[Text]]
Maybe Text
Maybe DirectSchemaChangePolicy
NonEmpty Text
Text
TargetFormat
format :: TargetFormat
path :: Text
inputs :: NonEmpty Text
name :: Text
schemaChangePolicy :: Maybe DirectSchemaChangePolicy
partitionKeys :: Maybe [[Text]]
compression :: Maybe Text
$sel:format:S3DirectTarget' :: S3DirectTarget -> TargetFormat
$sel:path:S3DirectTarget' :: S3DirectTarget -> Text
$sel:inputs:S3DirectTarget' :: S3DirectTarget -> NonEmpty Text
$sel:name:S3DirectTarget' :: S3DirectTarget -> Text
$sel:schemaChangePolicy:S3DirectTarget' :: S3DirectTarget -> Maybe DirectSchemaChangePolicy
$sel:partitionKeys:S3DirectTarget' :: S3DirectTarget -> Maybe [[Text]]
$sel:compression:S3DirectTarget' :: S3DirectTarget -> Maybe Text
..} =
    [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 Text
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),
            forall a. a -> Maybe a
Prelude.Just (Key
"Format" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TargetFormat
format)
          ]
      )