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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | A list of templated paths to the source files.
    S3SourceConfig -> Maybe (NonEmpty Text)
templatedPathList :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | A list of paths to the historical data files.
    S3SourceConfig -> Maybe (NonEmpty Text)
historicalDataPathList :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | Contains information about a source file\'s formatting.
    S3SourceConfig -> Maybe FileFormatDescriptor
fileFormatDescriptor :: Prelude.Maybe FileFormatDescriptor,
    -- | The ARN of an IAM role that has read and write access permissions to the
    -- source S3 bucket.
    S3SourceConfig -> Text
roleArn :: Prelude.Text
  }
  deriving (S3SourceConfig -> S3SourceConfig -> Bool
(S3SourceConfig -> S3SourceConfig -> Bool)
-> (S3SourceConfig -> S3SourceConfig -> Bool) -> Eq S3SourceConfig
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]
(Int -> ReadS S3SourceConfig)
-> ReadS [S3SourceConfig]
-> ReadPrec S3SourceConfig
-> ReadPrec [S3SourceConfig]
-> Read 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
(Int -> S3SourceConfig -> ShowS)
-> (S3SourceConfig -> String)
-> ([S3SourceConfig] -> ShowS)
-> Show S3SourceConfig
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. S3SourceConfig -> Rep S3SourceConfig x)
-> (forall x. Rep S3SourceConfig x -> S3SourceConfig)
-> Generic S3SourceConfig
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:
--
-- 'templatedPathList', 's3SourceConfig_templatedPathList' - A list of templated paths to the source files.
--
-- 'historicalDataPathList', 's3SourceConfig_historicalDataPathList' - A list of paths to the historical data files.
--
-- 'fileFormatDescriptor', 's3SourceConfig_fileFormatDescriptor' - Contains information about a source file\'s formatting.
--
-- 'roleArn', 's3SourceConfig_roleArn' - The ARN of an IAM role that has read and write access permissions to the
-- source S3 bucket.
newS3SourceConfig ::
  -- | 'roleArn'
  Prelude.Text ->
  S3SourceConfig
newS3SourceConfig :: Text -> S3SourceConfig
newS3SourceConfig Text
pRoleArn_ =
  S3SourceConfig' :: Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text)
-> Maybe FileFormatDescriptor
-> Text
-> S3SourceConfig
S3SourceConfig'
    { $sel:templatedPathList:S3SourceConfig' :: Maybe (NonEmpty Text)
templatedPathList =
        Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:historicalDataPathList:S3SourceConfig' :: Maybe (NonEmpty Text)
historicalDataPathList = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:fileFormatDescriptor:S3SourceConfig' :: Maybe FileFormatDescriptor
fileFormatDescriptor = Maybe FileFormatDescriptor
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:S3SourceConfig' :: Text
roleArn = Text
pRoleArn_
    }

-- | A list of templated paths to the source files.
s3SourceConfig_templatedPathList :: Lens.Lens' S3SourceConfig (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
s3SourceConfig_templatedPathList :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> S3SourceConfig -> f S3SourceConfig
s3SourceConfig_templatedPathList = (S3SourceConfig -> Maybe (NonEmpty Text))
-> (S3SourceConfig -> Maybe (NonEmpty Text) -> S3SourceConfig)
-> Lens
     S3SourceConfig
     S3SourceConfig
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> S3SourceConfig -> f S3SourceConfig)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> S3SourceConfig
-> f S3SourceConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of paths to the historical data files.
s3SourceConfig_historicalDataPathList :: Lens.Lens' S3SourceConfig (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
s3SourceConfig_historicalDataPathList :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> S3SourceConfig -> f S3SourceConfig
s3SourceConfig_historicalDataPathList = (S3SourceConfig -> Maybe (NonEmpty Text))
-> (S3SourceConfig -> Maybe (NonEmpty Text) -> S3SourceConfig)
-> Lens
     S3SourceConfig
     S3SourceConfig
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> S3SourceConfig -> f S3SourceConfig)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> S3SourceConfig
-> f S3SourceConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains information about a source file\'s formatting.
s3SourceConfig_fileFormatDescriptor :: Lens.Lens' S3SourceConfig (Prelude.Maybe FileFormatDescriptor)
s3SourceConfig_fileFormatDescriptor :: (Maybe FileFormatDescriptor -> f (Maybe FileFormatDescriptor))
-> S3SourceConfig -> f S3SourceConfig
s3SourceConfig_fileFormatDescriptor = (S3SourceConfig -> Maybe FileFormatDescriptor)
-> (S3SourceConfig -> Maybe FileFormatDescriptor -> S3SourceConfig)
-> Lens
     S3SourceConfig
     S3SourceConfig
     (Maybe FileFormatDescriptor)
     (Maybe 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)

-- | The ARN of an IAM role that has read and write access permissions to the
-- source S3 bucket.
s3SourceConfig_roleArn :: Lens.Lens' S3SourceConfig Prelude.Text
s3SourceConfig_roleArn :: (Text -> f Text) -> S3SourceConfig -> f S3SourceConfig
s3SourceConfig_roleArn = (S3SourceConfig -> Text)
-> (S3SourceConfig -> Text -> S3SourceConfig)
-> Lens S3SourceConfig S3SourceConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3SourceConfig' {Text
roleArn :: Text
$sel:roleArn:S3SourceConfig' :: S3SourceConfig -> Text
roleArn} -> Text
roleArn) (\s :: S3SourceConfig
s@S3SourceConfig' {} Text
a -> S3SourceConfig
s {$sel:roleArn:S3SourceConfig' :: Text
roleArn = Text
a} :: S3SourceConfig)

instance Core.FromJSON S3SourceConfig where
  parseJSON :: Value -> Parser S3SourceConfig
parseJSON =
    String
-> (Object -> Parser S3SourceConfig)
-> Value
-> Parser S3SourceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3SourceConfig"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text)
-> Maybe FileFormatDescriptor
-> Text
-> S3SourceConfig
S3SourceConfig'
            (Maybe (NonEmpty Text)
 -> Maybe (NonEmpty Text)
 -> Maybe FileFormatDescriptor
 -> Text
 -> S3SourceConfig)
-> Parser (Maybe (NonEmpty Text))
-> Parser
     (Maybe (NonEmpty Text)
      -> Maybe FileFormatDescriptor -> Text -> S3SourceConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TemplatedPathList")
            Parser
  (Maybe (NonEmpty Text)
   -> Maybe FileFormatDescriptor -> Text -> S3SourceConfig)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Maybe FileFormatDescriptor -> Text -> S3SourceConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HistoricalDataPathList")
            Parser (Maybe FileFormatDescriptor -> Text -> S3SourceConfig)
-> Parser (Maybe FileFormatDescriptor)
-> Parser (Text -> S3SourceConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FileFormatDescriptor)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FileFormatDescriptor")
            Parser (Text -> S3SourceConfig)
-> Parser Text -> Parser S3SourceConfig
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
"RoleArn")
      )

instance Prelude.Hashable S3SourceConfig

instance Prelude.NFData S3SourceConfig

instance Core.ToJSON S3SourceConfig where
  toJSON :: S3SourceConfig -> Value
toJSON S3SourceConfig' {Maybe (NonEmpty Text)
Maybe FileFormatDescriptor
Text
roleArn :: Text
fileFormatDescriptor :: Maybe FileFormatDescriptor
historicalDataPathList :: Maybe (NonEmpty Text)
templatedPathList :: Maybe (NonEmpty Text)
$sel:roleArn:S3SourceConfig' :: S3SourceConfig -> Text
$sel:fileFormatDescriptor:S3SourceConfig' :: S3SourceConfig -> Maybe FileFormatDescriptor
$sel:historicalDataPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
$sel:templatedPathList:S3SourceConfig' :: S3SourceConfig -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TemplatedPathList" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
templatedPathList,
            (Text
"HistoricalDataPathList" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
historicalDataPathList,
            (Text
"FileFormatDescriptor" Text -> FileFormatDescriptor -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FileFormatDescriptor -> Pair)
-> Maybe FileFormatDescriptor -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileFormatDescriptor
fileFormatDescriptor,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
          ]
      )