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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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 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],
    -- | A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
    S3Target -> Maybe Text
eventQueueArn :: 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
  }
  deriving (S3Target -> S3Target -> Bool
(S3Target -> S3Target -> Bool)
-> (S3Target -> S3Target -> Bool) -> Eq S3Target
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]
(Int -> ReadS S3Target)
-> ReadS [S3Target]
-> ReadPrec S3Target
-> ReadPrec [S3Target]
-> Read 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
(Int -> S3Target -> ShowS)
-> (S3Target -> String) -> ([S3Target] -> ShowS) -> Show S3Target
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. S3Target -> Rep S3Target x)
-> (forall x. Rep S3Target x -> S3Target) -> Generic S3Target
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:
--
-- '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.
--
-- '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).
--
-- '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>.
--
-- 'eventQueueArn', 's3Target_eventQueueArn' - A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
--
-- 'dlqEventQueueArn', 's3Target_dlqEventQueueArn' - A valid Amazon dead-letter SQS ARN. For example,
-- @arn:aws:sqs:region:account:deadLetterQueue@.
newS3Target ::
  S3Target
newS3Target :: S3Target
newS3Target =
  S3Target' :: Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> S3Target
S3Target'
    { $sel:path:S3Target' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleSize:S3Target' :: Maybe Int
sampleSize = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionName:S3Target' :: Maybe Text
connectionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exclusions:S3Target' :: Maybe [Text]
exclusions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:eventQueueArn:S3Target' :: Maybe Text
eventQueueArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dlqEventQueueArn:S3Target' :: Maybe Text
dlqEventQueueArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The path to the Amazon S3 target.
s3Target_path :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Text)
s3Target_path :: (Maybe Text -> f (Maybe Text)) -> S3Target -> f S3Target
s3Target_path = (S3Target -> Maybe Text)
-> (S3Target -> Maybe Text -> S3Target)
-> Lens S3Target S3Target (Maybe Text) (Maybe Text)
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 :: (Maybe Int -> f (Maybe Int)) -> S3Target -> f S3Target
s3Target_sampleSize = (S3Target -> Maybe Int)
-> (S3Target -> Maybe Int -> S3Target)
-> Lens S3Target S3Target (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> S3Target -> f S3Target
s3Target_connectionName = (S3Target -> Maybe Text)
-> (S3Target -> Maybe Text -> S3Target)
-> Lens S3Target S3Target (Maybe Text) (Maybe Text)
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 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 :: (Maybe [Text] -> f (Maybe [Text])) -> S3Target -> f S3Target
s3Target_exclusions = (S3Target -> Maybe [Text])
-> (S3Target -> Maybe [Text] -> S3Target)
-> Lens S3Target S3Target (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> S3Target -> f S3Target)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> S3Target
-> f S3Target
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
s3Target_eventQueueArn :: Lens.Lens' S3Target (Prelude.Maybe Prelude.Text)
s3Target_eventQueueArn :: (Maybe Text -> f (Maybe Text)) -> S3Target -> f S3Target
s3Target_eventQueueArn = (S3Target -> Maybe Text)
-> (S3Target -> Maybe Text -> S3Target)
-> Lens S3Target S3Target (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> S3Target -> f S3Target
s3Target_dlqEventQueueArn = (S3Target -> Maybe Text)
-> (S3Target -> Maybe Text -> S3Target)
-> Lens S3Target S3Target (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON S3Target where
  parseJSON :: Value -> Parser S3Target
parseJSON =
    String -> (Object -> Parser S3Target) -> Value -> Parser S3Target
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Target"
      ( \Object
x ->
          Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> S3Target
S3Target'
            (Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> S3Target)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Text
      -> Maybe Text
      -> S3Target)
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
"Path")
            Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe Text
   -> Maybe Text
   -> S3Target)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe [Text] -> Maybe Text -> Maybe Text -> S3Target)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SampleSize")
            Parser
  (Maybe Text
   -> Maybe [Text] -> Maybe Text -> Maybe Text -> S3Target)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Maybe Text -> Maybe Text -> S3Target)
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
"ConnectionName")
            Parser (Maybe [Text] -> Maybe Text -> Maybe Text -> S3Target)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe Text -> S3Target)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Exclusions" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> S3Target)
-> Parser (Maybe Text) -> Parser (Maybe Text -> S3Target)
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
"EventQueueArn")
            Parser (Maybe Text -> S3Target)
-> Parser (Maybe Text) -> Parser S3Target
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
"DlqEventQueueArn")
      )

instance Prelude.Hashable S3Target

instance Prelude.NFData S3Target

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