{-# 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.LookoutMetrics.Types.S3SourceConfig
-- 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.LookoutMetrics.Types.S3SourceConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutMetrics.Types.FileFormatDescriptor
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the configuration of the S3 bucket that
-- contains source files.
--
-- /See:/ 'newS3SourceConfig' smart constructor.
data S3SourceConfig = S3SourceConfig'
  { -- | Contains information about a source file\'s formatting.
    S3SourceConfig -> Maybe FileFormatDescriptor
fileFormatDescriptor :: Prelude.Maybe FileFormatDescriptor,
    -- | A list of paths to the historical data files.
    S3SourceConfig -> Maybe (NonEmpty Text)
historicalDataPathList :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The ARN of an IAM role that has read and write access permissions to the
    -- source S3 bucket.
    S3SourceConfig -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | A list of templated paths to the source files.
    S3SourceConfig -> Maybe (NonEmpty Text)
templatedPathList :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (S3SourceConfig -> S3SourceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3SourceConfig -> S3SourceConfig -> Bool
$c/= :: S3SourceConfig -> S3SourceConfig -> Bool
== :: S3SourceConfig -> S3SourceConfig -> Bool
$c== :: S3SourceConfig -> S3SourceConfig -> Bool
Prelude.Eq, ReadPrec [S3SourceConfig]
ReadPrec S3SourceConfig
Int -> ReadS S3SourceConfig
ReadS [S3SourceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3SourceConfig]
$creadListPrec :: ReadPrec [S3SourceConfig]
readPrec :: ReadPrec S3SourceConfig
$creadPrec :: ReadPrec S3SourceConfig
readList :: ReadS [S3SourceConfig]
$creadList :: ReadS [S3SourceConfig]
readsPrec :: Int -> ReadS S3SourceConfig
$creadsPrec :: Int -> ReadS S3SourceConfig
Prelude.Read, Int -> S3SourceConfig -> ShowS
[S3SourceConfig] -> ShowS
S3SourceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3SourceConfig] -> ShowS
$cshowList :: [S3SourceConfig] -> ShowS
show :: S3SourceConfig -> String
$cshow :: S3SourceConfig -> String
showsPrec :: Int -> S3SourceConfig -> ShowS
$cshowsPrec :: Int -> S3SourceConfig -> ShowS
Prelude.Show, forall x. Rep S3SourceConfig x -> S3SourceConfig
forall x. S3SourceConfig -> Rep S3SourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3SourceConfig x -> S3SourceConfig
$cfrom :: forall x. S3SourceConfig -> Rep S3SourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3SourceConfig' 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:
--
-- 'fileFormatDescriptor', 's3SourceConfig_fileFormatDescriptor' - Contains information about a source file\'s formatting.
--
-- 'historicalDataPathList', 's3SourceConfig_historicalDataPathList' - A list of paths to the historical data files.
--
-- 'roleArn', 's3SourceConfig_roleArn' - The ARN of an IAM role that has read and write access permissions to the
-- source S3 bucket.
--
-- 'templatedPathList', 's3SourceConfig_templatedPathList' - A list of templated paths to the source files.
newS3SourceConfig ::
  S3SourceConfig
newS3SourceConfig :: S3SourceConfig
newS3SourceConfig =
  S3SourceConfig'
    { $sel:fileFormatDescriptor:S3SourceConfig' :: Maybe FileFormatDescriptor
fileFormatDescriptor =
        forall a. Maybe a
Prelude.Nothing,
      $sel:historicalDataPathList:S3SourceConfig' :: Maybe (NonEmpty Text)
historicalDataPathList = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:S3SourceConfig' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:templatedPathList:S3SourceConfig' :: Maybe (NonEmpty Text)
templatedPathList = forall a. Maybe a
Prelude.Nothing
    }

-- | Contains information about a source file\'s formatting.
s3SourceConfig_fileFormatDescriptor :: Lens.Lens' S3SourceConfig (Prelude.Maybe FileFormatDescriptor)
s3SourceConfig_fileFormatDescriptor :: Lens' S3SourceConfig (Maybe FileFormatDescriptor)
s3SourceConfig_fileFormatDescriptor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceConfig' {Maybe FileFormatDescriptor
fileFormatDescriptor :: Maybe FileFormatDescriptor
$sel:fileFormatDescriptor:S3SourceConfig' :: S3SourceConfig -> Maybe FileFormatDescriptor
fileFormatDescriptor} -> Maybe FileFormatDescriptor
fileFormatDescriptor) (\s :: S3SourceConfig
s@S3SourceConfig' {} Maybe FileFormatDescriptor
a -> S3SourceConfig
s {$sel:fileFormatDescriptor:S3SourceConfig' :: Maybe FileFormatDescriptor
fileFormatDescriptor = Maybe FileFormatDescriptor
a} :: S3SourceConfig)

-- | A list of paths to the historical data files.
s3SourceConfig_historicalDataPathList :: Lens.Lens' S3SourceConfig (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
s3SourceConfig_historicalDataPathList :: Lens' S3SourceConfig (Maybe (NonEmpty Text))
s3SourceConfig_historicalDataPathList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceConfig' {Maybe (NonEmpty Text)
historicalDataPathList :: Maybe (NonEmpty Text)
$sel:historicalDataPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
historicalDataPathList} -> Maybe (NonEmpty Text)
historicalDataPathList) (\s :: S3SourceConfig
s@S3SourceConfig' {} Maybe (NonEmpty Text)
a -> S3SourceConfig
s {$sel:historicalDataPathList:S3SourceConfig' :: Maybe (NonEmpty Text)
historicalDataPathList = Maybe (NonEmpty Text)
a} :: S3SourceConfig) 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 ARN of an IAM role that has read and write access permissions to the
-- source S3 bucket.
s3SourceConfig_roleArn :: Lens.Lens' S3SourceConfig (Prelude.Maybe Prelude.Text)
s3SourceConfig_roleArn :: Lens' S3SourceConfig (Maybe Text)
s3SourceConfig_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceConfig' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:S3SourceConfig' :: S3SourceConfig -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: S3SourceConfig
s@S3SourceConfig' {} Maybe Text
a -> S3SourceConfig
s {$sel:roleArn:S3SourceConfig' :: Maybe Text
roleArn = Maybe Text
a} :: S3SourceConfig)

-- | A list of templated paths to the source files.
s3SourceConfig_templatedPathList :: Lens.Lens' S3SourceConfig (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
s3SourceConfig_templatedPathList :: Lens' S3SourceConfig (Maybe (NonEmpty Text))
s3SourceConfig_templatedPathList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceConfig' {Maybe (NonEmpty Text)
templatedPathList :: Maybe (NonEmpty Text)
$sel:templatedPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
templatedPathList} -> Maybe (NonEmpty Text)
templatedPathList) (\s :: S3SourceConfig
s@S3SourceConfig' {} Maybe (NonEmpty Text)
a -> S3SourceConfig
s {$sel:templatedPathList:S3SourceConfig' :: Maybe (NonEmpty Text)
templatedPathList = Maybe (NonEmpty Text)
a} :: S3SourceConfig) 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

instance Data.FromJSON S3SourceConfig where
  parseJSON :: Value -> Parser S3SourceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3SourceConfig"
      ( \Object
x ->
          Maybe FileFormatDescriptor
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe (NonEmpty Text)
-> S3SourceConfig
S3SourceConfig'
            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
"FileFormatDescriptor")
            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
"HistoricalDataPathList")
            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
"RoleArn")
            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
"TemplatedPathList")
      )

instance Prelude.Hashable S3SourceConfig where
  hashWithSalt :: Int -> S3SourceConfig -> Int
hashWithSalt Int
_salt S3SourceConfig' {Maybe (NonEmpty Text)
Maybe Text
Maybe FileFormatDescriptor
templatedPathList :: Maybe (NonEmpty Text)
roleArn :: Maybe Text
historicalDataPathList :: Maybe (NonEmpty Text)
fileFormatDescriptor :: Maybe FileFormatDescriptor
$sel:templatedPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:roleArn:S3SourceConfig' :: S3SourceConfig -> Maybe Text
$sel:historicalDataPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:fileFormatDescriptor:S3SourceConfig' :: S3SourceConfig -> Maybe FileFormatDescriptor
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FileFormatDescriptor
fileFormatDescriptor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
historicalDataPathList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
templatedPathList

instance Prelude.NFData S3SourceConfig where
  rnf :: S3SourceConfig -> ()
rnf S3SourceConfig' {Maybe (NonEmpty Text)
Maybe Text
Maybe FileFormatDescriptor
templatedPathList :: Maybe (NonEmpty Text)
roleArn :: Maybe Text
historicalDataPathList :: Maybe (NonEmpty Text)
fileFormatDescriptor :: Maybe FileFormatDescriptor
$sel:templatedPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:roleArn:S3SourceConfig' :: S3SourceConfig -> Maybe Text
$sel:historicalDataPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:fileFormatDescriptor:S3SourceConfig' :: S3SourceConfig -> Maybe FileFormatDescriptor
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FileFormatDescriptor
fileFormatDescriptor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
historicalDataPathList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
templatedPathList

instance Data.ToJSON S3SourceConfig where
  toJSON :: S3SourceConfig -> Value
toJSON S3SourceConfig' {Maybe (NonEmpty Text)
Maybe Text
Maybe FileFormatDescriptor
templatedPathList :: Maybe (NonEmpty Text)
roleArn :: Maybe Text
historicalDataPathList :: Maybe (NonEmpty Text)
fileFormatDescriptor :: Maybe FileFormatDescriptor
$sel:templatedPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:roleArn:S3SourceConfig' :: S3SourceConfig -> Maybe Text
$sel:historicalDataPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:fileFormatDescriptor:S3SourceConfig' :: S3SourceConfig -> Maybe FileFormatDescriptor
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FileFormatDescriptor" 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 FileFormatDescriptor
fileFormatDescriptor,
            (Key
"HistoricalDataPathList" 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 (NonEmpty Text)
historicalDataPathList,
            (Key
"RoleArn" 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
roleArn,
            (Key
"TemplatedPathList" 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 (NonEmpty Text)
templatedPathList
          ]
      )