{-# 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.LookoutEquipment.Types.IngestionS3InputConfiguration
-- 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.LookoutEquipment.Types.IngestionS3InputConfiguration 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 S3 configuration information for the input data for the data
-- ingestion job.
--
-- /See:/ 'newIngestionS3InputConfiguration' smart constructor.
data IngestionS3InputConfiguration = IngestionS3InputConfiguration'
  { -- | Pattern for matching the Amazon S3 files which will be used for
    -- ingestion. If no KeyPattern is provided, we will use the default
    -- hierarchy file structure, which is same as KeyPattern
    -- {prefix}\/{component_name}\/*
    IngestionS3InputConfiguration -> Maybe Text
keyPattern :: Prelude.Maybe Prelude.Text,
    -- | The prefix for the S3 location being used for the input data for the
    -- data ingestion.
    IngestionS3InputConfiguration -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket used for the input data for the data
    -- ingestion.
    IngestionS3InputConfiguration -> Text
bucket :: Prelude.Text
  }
  deriving (IngestionS3InputConfiguration
-> IngestionS3InputConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IngestionS3InputConfiguration
-> IngestionS3InputConfiguration -> Bool
$c/= :: IngestionS3InputConfiguration
-> IngestionS3InputConfiguration -> Bool
== :: IngestionS3InputConfiguration
-> IngestionS3InputConfiguration -> Bool
$c== :: IngestionS3InputConfiguration
-> IngestionS3InputConfiguration -> Bool
Prelude.Eq, ReadPrec [IngestionS3InputConfiguration]
ReadPrec IngestionS3InputConfiguration
Int -> ReadS IngestionS3InputConfiguration
ReadS [IngestionS3InputConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IngestionS3InputConfiguration]
$creadListPrec :: ReadPrec [IngestionS3InputConfiguration]
readPrec :: ReadPrec IngestionS3InputConfiguration
$creadPrec :: ReadPrec IngestionS3InputConfiguration
readList :: ReadS [IngestionS3InputConfiguration]
$creadList :: ReadS [IngestionS3InputConfiguration]
readsPrec :: Int -> ReadS IngestionS3InputConfiguration
$creadsPrec :: Int -> ReadS IngestionS3InputConfiguration
Prelude.Read, Int -> IngestionS3InputConfiguration -> ShowS
[IngestionS3InputConfiguration] -> ShowS
IngestionS3InputConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IngestionS3InputConfiguration] -> ShowS
$cshowList :: [IngestionS3InputConfiguration] -> ShowS
show :: IngestionS3InputConfiguration -> String
$cshow :: IngestionS3InputConfiguration -> String
showsPrec :: Int -> IngestionS3InputConfiguration -> ShowS
$cshowsPrec :: Int -> IngestionS3InputConfiguration -> ShowS
Prelude.Show, forall x.
Rep IngestionS3InputConfiguration x
-> IngestionS3InputConfiguration
forall x.
IngestionS3InputConfiguration
-> Rep IngestionS3InputConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IngestionS3InputConfiguration x
-> IngestionS3InputConfiguration
$cfrom :: forall x.
IngestionS3InputConfiguration
-> Rep IngestionS3InputConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'IngestionS3InputConfiguration' 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:
--
-- 'keyPattern', 'ingestionS3InputConfiguration_keyPattern' - Pattern for matching the Amazon S3 files which will be used for
-- ingestion. If no KeyPattern is provided, we will use the default
-- hierarchy file structure, which is same as KeyPattern
-- {prefix}\/{component_name}\/*
--
-- 'prefix', 'ingestionS3InputConfiguration_prefix' - The prefix for the S3 location being used for the input data for the
-- data ingestion.
--
-- 'bucket', 'ingestionS3InputConfiguration_bucket' - The name of the S3 bucket used for the input data for the data
-- ingestion.
newIngestionS3InputConfiguration ::
  -- | 'bucket'
  Prelude.Text ->
  IngestionS3InputConfiguration
newIngestionS3InputConfiguration :: Text -> IngestionS3InputConfiguration
newIngestionS3InputConfiguration Text
pBucket_ =
  IngestionS3InputConfiguration'
    { $sel:keyPattern:IngestionS3InputConfiguration' :: Maybe Text
keyPattern =
        forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:IngestionS3InputConfiguration' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:IngestionS3InputConfiguration' :: Text
bucket = Text
pBucket_
    }

-- | Pattern for matching the Amazon S3 files which will be used for
-- ingestion. If no KeyPattern is provided, we will use the default
-- hierarchy file structure, which is same as KeyPattern
-- {prefix}\/{component_name}\/*
ingestionS3InputConfiguration_keyPattern :: Lens.Lens' IngestionS3InputConfiguration (Prelude.Maybe Prelude.Text)
ingestionS3InputConfiguration_keyPattern :: Lens' IngestionS3InputConfiguration (Maybe Text)
ingestionS3InputConfiguration_keyPattern = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngestionS3InputConfiguration' {Maybe Text
keyPattern :: Maybe Text
$sel:keyPattern:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
keyPattern} -> Maybe Text
keyPattern) (\s :: IngestionS3InputConfiguration
s@IngestionS3InputConfiguration' {} Maybe Text
a -> IngestionS3InputConfiguration
s {$sel:keyPattern:IngestionS3InputConfiguration' :: Maybe Text
keyPattern = Maybe Text
a} :: IngestionS3InputConfiguration)

-- | The prefix for the S3 location being used for the input data for the
-- data ingestion.
ingestionS3InputConfiguration_prefix :: Lens.Lens' IngestionS3InputConfiguration (Prelude.Maybe Prelude.Text)
ingestionS3InputConfiguration_prefix :: Lens' IngestionS3InputConfiguration (Maybe Text)
ingestionS3InputConfiguration_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngestionS3InputConfiguration' {Maybe Text
prefix :: Maybe Text
$sel:prefix:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: IngestionS3InputConfiguration
s@IngestionS3InputConfiguration' {} Maybe Text
a -> IngestionS3InputConfiguration
s {$sel:prefix:IngestionS3InputConfiguration' :: Maybe Text
prefix = Maybe Text
a} :: IngestionS3InputConfiguration)

-- | The name of the S3 bucket used for the input data for the data
-- ingestion.
ingestionS3InputConfiguration_bucket :: Lens.Lens' IngestionS3InputConfiguration Prelude.Text
ingestionS3InputConfiguration_bucket :: Lens' IngestionS3InputConfiguration Text
ingestionS3InputConfiguration_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngestionS3InputConfiguration' {Text
bucket :: Text
$sel:bucket:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Text
bucket} -> Text
bucket) (\s :: IngestionS3InputConfiguration
s@IngestionS3InputConfiguration' {} Text
a -> IngestionS3InputConfiguration
s {$sel:bucket:IngestionS3InputConfiguration' :: Text
bucket = Text
a} :: IngestionS3InputConfiguration)

instance Data.FromJSON IngestionS3InputConfiguration where
  parseJSON :: Value -> Parser IngestionS3InputConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IngestionS3InputConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> IngestionS3InputConfiguration
IngestionS3InputConfiguration'
            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
"KeyPattern")
            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
"Prefix")
            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
"Bucket")
      )

instance
  Prelude.Hashable
    IngestionS3InputConfiguration
  where
  hashWithSalt :: Int -> IngestionS3InputConfiguration -> Int
hashWithSalt Int
_salt IngestionS3InputConfiguration' {Maybe Text
Text
bucket :: Text
prefix :: Maybe Text
keyPattern :: Maybe Text
$sel:bucket:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Text
$sel:prefix:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
$sel:keyPattern:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyPattern
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucket

instance Prelude.NFData IngestionS3InputConfiguration where
  rnf :: IngestionS3InputConfiguration -> ()
rnf IngestionS3InputConfiguration' {Maybe Text
Text
bucket :: Text
prefix :: Maybe Text
keyPattern :: Maybe Text
$sel:bucket:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Text
$sel:prefix:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
$sel:keyPattern:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyPattern
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucket

instance Data.ToJSON IngestionS3InputConfiguration where
  toJSON :: IngestionS3InputConfiguration -> Value
toJSON IngestionS3InputConfiguration' {Maybe Text
Text
bucket :: Text
prefix :: Maybe Text
keyPattern :: Maybe Text
$sel:bucket:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Text
$sel:prefix:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
$sel:keyPattern:IngestionS3InputConfiguration' :: IngestionS3InputConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KeyPattern" 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
keyPattern,
            (Key
"Prefix" 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
prefix,
            forall a. a -> Maybe a
Prelude.Just (Key
"Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucket)
          ]
      )