{-# 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.S3Target
-- 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.S3Target 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

-- | Specifies a data store in Amazon Simple Storage Service (Amazon S3).
--
-- /See:/ 'newS3Target' smart constructor.
data S3Target = S3Target'
  { -- | The name of a connection which allows a job or crawler to access data in
    -- Amazon S3 within an Amazon Virtual Private Cloud environment (Amazon
    -- VPC).
    S3Target -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | A valid Amazon dead-letter SQS ARN. For example,
    -- @arn:aws:sqs:region:account:deadLetterQueue@.
    S3Target -> Maybe Text
dlqEventQueueArn :: Prelude.Maybe Prelude.Text,
    -- | A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
    S3Target -> Maybe Text
eventQueueArn :: Prelude.Maybe Prelude.Text,
    -- | A list of glob patterns used to exclude from the crawl. For more
    -- information, see
    -- <https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html Catalog Tables with a Crawler>.
    S3Target -> Maybe [Text]
exclusions :: Prelude.Maybe [Prelude.Text],
    -- | The path to the Amazon S3 target.
    S3Target -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | Sets the number of files in each leaf folder to be crawled when crawling
    -- sample files in a dataset. If not set, all the files are crawled. A
    -- valid value is an integer between 1 and 249.
    S3Target -> Maybe Int
sampleSize :: Prelude.Maybe Prelude.Int
  }
  deriving (S3Target -> S3Target -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Target -> S3Target -> Bool
$c/= :: S3Target -> S3Target -> Bool
== :: S3Target -> S3Target -> Bool
$c== :: S3Target -> S3Target -> Bool
Prelude.Eq, ReadPrec [S3Target]
ReadPrec S3Target
Int -> ReadS S3Target
ReadS [S3Target]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Target]
$creadListPrec :: ReadPrec [S3Target]
readPrec :: ReadPrec S3Target
$creadPrec :: ReadPrec S3Target
readList :: ReadS [S3Target]
$creadList :: ReadS [S3Target]
readsPrec :: Int -> ReadS S3Target
$creadsPrec :: Int -> ReadS S3Target
Prelude.Read, Int -> S3Target -> ShowS
[S3Target] -> ShowS
S3Target -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Target] -> ShowS
$cshowList :: [S3Target] -> ShowS
show :: S3Target -> String
$cshow :: S3Target -> String
showsPrec :: Int -> S3Target -> ShowS
$cshowsPrec :: Int -> S3Target -> ShowS
Prelude.Show, forall x. Rep S3Target x -> S3Target
forall x. S3Target -> Rep S3Target x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Target x -> S3Target
$cfrom :: forall x. S3Target -> Rep S3Target x
Prelude.Generic)

-- |
-- Create a value of 'S3Target' 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:
--
-- 'connectionName', 's3Target_connectionName' - The name of a connection which allows a job or crawler to access data in
-- Amazon S3 within an Amazon Virtual Private Cloud environment (Amazon
-- VPC).
--
-- 'dlqEventQueueArn', 's3Target_dlqEventQueueArn' - A valid Amazon dead-letter SQS ARN. For example,
-- @arn:aws:sqs:region:account:deadLetterQueue@.
--
-- 'eventQueueArn', 's3Target_eventQueueArn' - A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
--
-- 'exclusions', 's3Target_exclusions' - A list of glob patterns used to exclude from the crawl. For more
-- information, see
-- <https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html Catalog Tables with a Crawler>.
--
-- 'path', 's3Target_path' - The path to the Amazon S3 target.
--
-- 'sampleSize', 's3Target_sampleSize' - Sets the number of files in each leaf folder to be crawled when crawling
-- sample files in a dataset. If not set, all the files are crawled. A
-- valid value is an integer between 1 and 249.
newS3Target ::
  S3Target
newS3Target :: S3Target
newS3Target =
  S3Target'
    { $sel:connectionName:S3Target' :: Maybe Text
connectionName = forall a. Maybe a
Prelude.Nothing,
      $sel:dlqEventQueueArn:S3Target' :: Maybe Text
dlqEventQueueArn = forall a. Maybe a
Prelude.Nothing,
      $sel:eventQueueArn:S3Target' :: Maybe Text
eventQueueArn = forall a. Maybe a
Prelude.Nothing,
      $sel:exclusions:S3Target' :: Maybe [Text]
exclusions = forall a. Maybe a
Prelude.Nothing,
      $sel:path:S3Target' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleSize:S3Target' :: Maybe Int
sampleSize = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a connection which allows a job or crawler to access data in
-- Amazon S3 within an Amazon Virtual Private Cloud environment (Amazon
-- VPC).
s3Target_connectionName :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Text)
s3Target_connectionName :: Lens' S3Target (Maybe Text)
s3Target_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Target' {Maybe Text
connectionName :: Maybe Text
$sel:connectionName:S3Target' :: S3Target -> Maybe Text
connectionName} -> Maybe Text
connectionName) (\s :: S3Target
s@S3Target' {} Maybe Text
a -> S3Target
s {$sel:connectionName:S3Target' :: Maybe Text
connectionName = Maybe Text
a} :: S3Target)

-- | A valid Amazon dead-letter SQS ARN. For example,
-- @arn:aws:sqs:region:account:deadLetterQueue@.
s3Target_dlqEventQueueArn :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Text)
s3Target_dlqEventQueueArn :: Lens' S3Target (Maybe Text)
s3Target_dlqEventQueueArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Target' {Maybe Text
dlqEventQueueArn :: Maybe Text
$sel:dlqEventQueueArn:S3Target' :: S3Target -> Maybe Text
dlqEventQueueArn} -> Maybe Text
dlqEventQueueArn) (\s :: S3Target
s@S3Target' {} Maybe Text
a -> S3Target
s {$sel:dlqEventQueueArn:S3Target' :: Maybe Text
dlqEventQueueArn = Maybe Text
a} :: S3Target)

-- | A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
s3Target_eventQueueArn :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Text)
s3Target_eventQueueArn :: Lens' S3Target (Maybe Text)
s3Target_eventQueueArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Target' {Maybe Text
eventQueueArn :: Maybe Text
$sel:eventQueueArn:S3Target' :: S3Target -> Maybe Text
eventQueueArn} -> Maybe Text
eventQueueArn) (\s :: S3Target
s@S3Target' {} Maybe Text
a -> S3Target
s {$sel:eventQueueArn:S3Target' :: Maybe Text
eventQueueArn = Maybe Text
a} :: S3Target)

-- | A list of glob patterns used to exclude from the crawl. For more
-- information, see
-- <https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html Catalog Tables with a Crawler>.
s3Target_exclusions :: Lens.Lens' S3Target (Prelude.Maybe [Prelude.Text])
s3Target_exclusions :: Lens' S3Target (Maybe [Text])
s3Target_exclusions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Target' {Maybe [Text]
exclusions :: Maybe [Text]
$sel:exclusions:S3Target' :: S3Target -> Maybe [Text]
exclusions} -> Maybe [Text]
exclusions) (\s :: S3Target
s@S3Target' {} Maybe [Text]
a -> S3Target
s {$sel:exclusions:S3Target' :: Maybe [Text]
exclusions = Maybe [Text]
a} :: S3Target) 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

-- | The path to the Amazon S3 target.
s3Target_path :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Text)
s3Target_path :: Lens' S3Target (Maybe Text)
s3Target_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Target' {Maybe Text
path :: Maybe Text
$sel:path:S3Target' :: S3Target -> Maybe Text
path} -> Maybe Text
path) (\s :: S3Target
s@S3Target' {} Maybe Text
a -> S3Target
s {$sel:path:S3Target' :: Maybe Text
path = Maybe Text
a} :: S3Target)

-- | Sets the number of files in each leaf folder to be crawled when crawling
-- sample files in a dataset. If not set, all the files are crawled. A
-- valid value is an integer between 1 and 249.
s3Target_sampleSize :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Int)
s3Target_sampleSize :: Lens' S3Target (Maybe Int)
s3Target_sampleSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Target' {Maybe Int
sampleSize :: Maybe Int
$sel:sampleSize:S3Target' :: S3Target -> Maybe Int
sampleSize} -> Maybe Int
sampleSize) (\s :: S3Target
s@S3Target' {} Maybe Int
a -> S3Target
s {$sel:sampleSize:S3Target' :: Maybe Int
sampleSize = Maybe Int
a} :: S3Target)

instance Data.FromJSON S3Target where
  parseJSON :: Value -> Parser S3Target
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Target"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Int
-> S3Target
S3Target'
            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
"ConnectionName")
            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
"DlqEventQueueArn")
            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
"EventQueueArn")
            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
"Exclusions" 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
"Path")
            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
"SampleSize")
      )

instance Prelude.Hashable S3Target where
  hashWithSalt :: Int -> S3Target -> Int
hashWithSalt Int
_salt S3Target' {Maybe Int
Maybe [Text]
Maybe Text
sampleSize :: Maybe Int
path :: Maybe Text
exclusions :: Maybe [Text]
eventQueueArn :: Maybe Text
dlqEventQueueArn :: Maybe Text
connectionName :: Maybe Text
$sel:sampleSize:S3Target' :: S3Target -> Maybe Int
$sel:path:S3Target' :: S3Target -> Maybe Text
$sel:exclusions:S3Target' :: S3Target -> Maybe [Text]
$sel:eventQueueArn:S3Target' :: S3Target -> Maybe Text
$sel:dlqEventQueueArn:S3Target' :: S3Target -> Maybe Text
$sel:connectionName:S3Target' :: S3Target -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dlqEventQueueArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventQueueArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
exclusions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
sampleSize

instance Prelude.NFData S3Target where
  rnf :: S3Target -> ()
rnf S3Target' {Maybe Int
Maybe [Text]
Maybe Text
sampleSize :: Maybe Int
path :: Maybe Text
exclusions :: Maybe [Text]
eventQueueArn :: Maybe Text
dlqEventQueueArn :: Maybe Text
connectionName :: Maybe Text
$sel:sampleSize:S3Target' :: S3Target -> Maybe Int
$sel:path:S3Target' :: S3Target -> Maybe Text
$sel:exclusions:S3Target' :: S3Target -> Maybe [Text]
$sel:eventQueueArn:S3Target' :: S3Target -> Maybe Text
$sel:dlqEventQueueArn:S3Target' :: S3Target -> Maybe Text
$sel:connectionName:S3Target' :: S3Target -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dlqEventQueueArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventQueueArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
exclusions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
sampleSize

instance Data.ToJSON S3Target where
  toJSON :: S3Target -> Value
toJSON S3Target' {Maybe Int
Maybe [Text]
Maybe Text
sampleSize :: Maybe Int
path :: Maybe Text
exclusions :: Maybe [Text]
eventQueueArn :: Maybe Text
dlqEventQueueArn :: Maybe Text
connectionName :: Maybe Text
$sel:sampleSize:S3Target' :: S3Target -> Maybe Int
$sel:path:S3Target' :: S3Target -> Maybe Text
$sel:exclusions:S3Target' :: S3Target -> Maybe [Text]
$sel:eventQueueArn:S3Target' :: S3Target -> Maybe Text
$sel:dlqEventQueueArn:S3Target' :: S3Target -> Maybe Text
$sel:connectionName:S3Target' :: S3Target -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ConnectionName" 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
connectionName,
            (Key
"DlqEventQueueArn" 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
dlqEventQueueArn,
            (Key
"EventQueueArn" 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
eventQueueArn,
            (Key
"Exclusions" 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]
exclusions,
            (Key
"Path" 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
path,
            (Key
"SampleSize" 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 Int
sampleSize
          ]
      )