{-# 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-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.LookoutEquipment.Types.IngestionS3InputConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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
(IngestionS3InputConfiguration
 -> IngestionS3InputConfiguration -> Bool)
-> (IngestionS3InputConfiguration
    -> IngestionS3InputConfiguration -> Bool)
-> Eq IngestionS3InputConfiguration
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]
(Int -> ReadS IngestionS3InputConfiguration)
-> ReadS [IngestionS3InputConfiguration]
-> ReadPrec IngestionS3InputConfiguration
-> ReadPrec [IngestionS3InputConfiguration]
-> Read 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
(Int -> IngestionS3InputConfiguration -> ShowS)
-> (IngestionS3InputConfiguration -> String)
-> ([IngestionS3InputConfiguration] -> ShowS)
-> Show IngestionS3InputConfiguration
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.
 IngestionS3InputConfiguration
 -> Rep IngestionS3InputConfiguration x)
-> (forall x.
    Rep IngestionS3InputConfiguration x
    -> IngestionS3InputConfiguration)
-> Generic IngestionS3InputConfiguration
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:
--
-- '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' :: Maybe Text -> Text -> IngestionS3InputConfiguration
IngestionS3InputConfiguration'
    { $sel:prefix:IngestionS3InputConfiguration' :: Maybe Text
prefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:IngestionS3InputConfiguration' :: Text
bucket = Text
pBucket_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> IngestionS3InputConfiguration -> f IngestionS3InputConfiguration
ingestionS3InputConfiguration_prefix = (IngestionS3InputConfiguration -> Maybe Text)
-> (IngestionS3InputConfiguration
    -> Maybe Text -> IngestionS3InputConfiguration)
-> Lens
     IngestionS3InputConfiguration
     IngestionS3InputConfiguration
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> IngestionS3InputConfiguration -> f IngestionS3InputConfiguration
ingestionS3InputConfiguration_bucket = (IngestionS3InputConfiguration -> Text)
-> (IngestionS3InputConfiguration
    -> Text -> IngestionS3InputConfiguration)
-> Lens
     IngestionS3InputConfiguration
     IngestionS3InputConfiguration
     Text
     Text
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 Core.FromJSON IngestionS3InputConfiguration where
  parseJSON :: Value -> Parser IngestionS3InputConfiguration
parseJSON =
    String
-> (Object -> Parser IngestionS3InputConfiguration)
-> Value
-> Parser IngestionS3InputConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IngestionS3InputConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> IngestionS3InputConfiguration
IngestionS3InputConfiguration'
            (Maybe Text -> Text -> IngestionS3InputConfiguration)
-> Parser (Maybe Text)
-> Parser (Text -> IngestionS3InputConfiguration)
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
"Prefix")
            Parser (Text -> IngestionS3InputConfiguration)
-> Parser Text -> Parser IngestionS3InputConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Bucket")
      )

instance
  Prelude.Hashable
    IngestionS3InputConfiguration

instance Prelude.NFData IngestionS3InputConfiguration

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