{-# 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.Personalize.Types.S3DataConfig
-- 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.Personalize.Types.S3DataConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration details of an Amazon S3 input or output bucket.
--
-- /See:/ 'newS3DataConfig' smart constructor.
data S3DataConfig = S3DataConfig'
  { -- | The Amazon Resource Name (ARN) of the Key Management Service (KMS) key
    -- that Amazon Personalize uses to encrypt or decrypt the input and output
    -- files of a batch inference job.
    S3DataConfig -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The file path of the Amazon S3 bucket.
    S3DataConfig -> Text
path :: Prelude.Text
  }
  deriving (S3DataConfig -> S3DataConfig -> Bool
(S3DataConfig -> S3DataConfig -> Bool)
-> (S3DataConfig -> S3DataConfig -> Bool) -> Eq S3DataConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3DataConfig -> S3DataConfig -> Bool
$c/= :: S3DataConfig -> S3DataConfig -> Bool
== :: S3DataConfig -> S3DataConfig -> Bool
$c== :: S3DataConfig -> S3DataConfig -> Bool
Prelude.Eq, ReadPrec [S3DataConfig]
ReadPrec S3DataConfig
Int -> ReadS S3DataConfig
ReadS [S3DataConfig]
(Int -> ReadS S3DataConfig)
-> ReadS [S3DataConfig]
-> ReadPrec S3DataConfig
-> ReadPrec [S3DataConfig]
-> Read S3DataConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3DataConfig]
$creadListPrec :: ReadPrec [S3DataConfig]
readPrec :: ReadPrec S3DataConfig
$creadPrec :: ReadPrec S3DataConfig
readList :: ReadS [S3DataConfig]
$creadList :: ReadS [S3DataConfig]
readsPrec :: Int -> ReadS S3DataConfig
$creadsPrec :: Int -> ReadS S3DataConfig
Prelude.Read, Int -> S3DataConfig -> ShowS
[S3DataConfig] -> ShowS
S3DataConfig -> String
(Int -> S3DataConfig -> ShowS)
-> (S3DataConfig -> String)
-> ([S3DataConfig] -> ShowS)
-> Show S3DataConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3DataConfig] -> ShowS
$cshowList :: [S3DataConfig] -> ShowS
show :: S3DataConfig -> String
$cshow :: S3DataConfig -> String
showsPrec :: Int -> S3DataConfig -> ShowS
$cshowsPrec :: Int -> S3DataConfig -> ShowS
Prelude.Show, (forall x. S3DataConfig -> Rep S3DataConfig x)
-> (forall x. Rep S3DataConfig x -> S3DataConfig)
-> Generic S3DataConfig
forall x. Rep S3DataConfig x -> S3DataConfig
forall x. S3DataConfig -> Rep S3DataConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3DataConfig x -> S3DataConfig
$cfrom :: forall x. S3DataConfig -> Rep S3DataConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3DataConfig' 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:
--
-- 'kmsKeyArn', 's3DataConfig_kmsKeyArn' - The Amazon Resource Name (ARN) of the Key Management Service (KMS) key
-- that Amazon Personalize uses to encrypt or decrypt the input and output
-- files of a batch inference job.
--
-- 'path', 's3DataConfig_path' - The file path of the Amazon S3 bucket.
newS3DataConfig ::
  -- | 'path'
  Prelude.Text ->
  S3DataConfig
newS3DataConfig :: Text -> S3DataConfig
newS3DataConfig Text
pPath_ =
  S3DataConfig' :: Maybe Text -> Text -> S3DataConfig
S3DataConfig'
    { $sel:kmsKeyArn:S3DataConfig' :: Maybe Text
kmsKeyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:path:S3DataConfig' :: Text
path = Text
pPath_
    }

-- | The Amazon Resource Name (ARN) of the Key Management Service (KMS) key
-- that Amazon Personalize uses to encrypt or decrypt the input and output
-- files of a batch inference job.
s3DataConfig_kmsKeyArn :: Lens.Lens' S3DataConfig (Prelude.Maybe Prelude.Text)
s3DataConfig_kmsKeyArn :: (Maybe Text -> f (Maybe Text)) -> S3DataConfig -> f S3DataConfig
s3DataConfig_kmsKeyArn = (S3DataConfig -> Maybe Text)
-> (S3DataConfig -> Maybe Text -> S3DataConfig)
-> Lens S3DataConfig S3DataConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DataConfig' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:S3DataConfig' :: S3DataConfig -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: S3DataConfig
s@S3DataConfig' {} Maybe Text
a -> S3DataConfig
s {$sel:kmsKeyArn:S3DataConfig' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: S3DataConfig)

-- | The file path of the Amazon S3 bucket.
s3DataConfig_path :: Lens.Lens' S3DataConfig Prelude.Text
s3DataConfig_path :: (Text -> f Text) -> S3DataConfig -> f S3DataConfig
s3DataConfig_path = (S3DataConfig -> Text)
-> (S3DataConfig -> Text -> S3DataConfig)
-> Lens S3DataConfig S3DataConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DataConfig' {Text
path :: Text
$sel:path:S3DataConfig' :: S3DataConfig -> Text
path} -> Text
path) (\s :: S3DataConfig
s@S3DataConfig' {} Text
a -> S3DataConfig
s {$sel:path:S3DataConfig' :: Text
path = Text
a} :: S3DataConfig)

instance Core.FromJSON S3DataConfig where
  parseJSON :: Value -> Parser S3DataConfig
parseJSON =
    String
-> (Object -> Parser S3DataConfig) -> Value -> Parser S3DataConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3DataConfig"
      ( \Object
x ->
          Maybe Text -> Text -> S3DataConfig
S3DataConfig'
            (Maybe Text -> Text -> S3DataConfig)
-> Parser (Maybe Text) -> Parser (Text -> S3DataConfig)
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
"kmsKeyArn")
            Parser (Text -> S3DataConfig) -> Parser Text -> Parser S3DataConfig
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
"path")
      )

instance Prelude.Hashable S3DataConfig

instance Prelude.NFData S3DataConfig

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