{-# 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.SageMaker.Types.S3StorageConfig
-- 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.SageMaker.Types.S3StorageConfig 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

-- | The Amazon Simple Storage (Amazon S3) location and and security
-- configuration for @OfflineStore@.
--
-- /See:/ 'newS3StorageConfig' smart constructor.
data S3StorageConfig = S3StorageConfig'
  { -- | The Amazon Web Services Key Management Service (KMS) key ID of the key
    -- used to encrypt any objects written into the @OfflineStore@ S3 location.
    --
    -- The IAM @roleARN@ that is passed as a parameter to @CreateFeatureGroup@
    -- must have below permissions to the @KmsKeyId@:
    --
    -- -   @\"kms:GenerateDataKey\"@
    S3StorageConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The S3 path where offline records are written.
    S3StorageConfig -> Maybe Text
resolvedOutputS3Uri :: Prelude.Maybe Prelude.Text,
    -- | The S3 URI, or location in Amazon S3, of @OfflineStore@.
    --
    -- S3 URIs have a format similar to the following:
    -- @s3:\/\/example-bucket\/prefix\/@.
    S3StorageConfig -> Text
s3Uri :: Prelude.Text
  }
  deriving (S3StorageConfig -> S3StorageConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3StorageConfig -> S3StorageConfig -> Bool
$c/= :: S3StorageConfig -> S3StorageConfig -> Bool
== :: S3StorageConfig -> S3StorageConfig -> Bool
$c== :: S3StorageConfig -> S3StorageConfig -> Bool
Prelude.Eq, ReadPrec [S3StorageConfig]
ReadPrec S3StorageConfig
Int -> ReadS S3StorageConfig
ReadS [S3StorageConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3StorageConfig]
$creadListPrec :: ReadPrec [S3StorageConfig]
readPrec :: ReadPrec S3StorageConfig
$creadPrec :: ReadPrec S3StorageConfig
readList :: ReadS [S3StorageConfig]
$creadList :: ReadS [S3StorageConfig]
readsPrec :: Int -> ReadS S3StorageConfig
$creadsPrec :: Int -> ReadS S3StorageConfig
Prelude.Read, Int -> S3StorageConfig -> ShowS
[S3StorageConfig] -> ShowS
S3StorageConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3StorageConfig] -> ShowS
$cshowList :: [S3StorageConfig] -> ShowS
show :: S3StorageConfig -> String
$cshow :: S3StorageConfig -> String
showsPrec :: Int -> S3StorageConfig -> ShowS
$cshowsPrec :: Int -> S3StorageConfig -> ShowS
Prelude.Show, forall x. Rep S3StorageConfig x -> S3StorageConfig
forall x. S3StorageConfig -> Rep S3StorageConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3StorageConfig x -> S3StorageConfig
$cfrom :: forall x. S3StorageConfig -> Rep S3StorageConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3StorageConfig' 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:
--
-- 'kmsKeyId', 's3StorageConfig_kmsKeyId' - The Amazon Web Services Key Management Service (KMS) key ID of the key
-- used to encrypt any objects written into the @OfflineStore@ S3 location.
--
-- The IAM @roleARN@ that is passed as a parameter to @CreateFeatureGroup@
-- must have below permissions to the @KmsKeyId@:
--
-- -   @\"kms:GenerateDataKey\"@
--
-- 'resolvedOutputS3Uri', 's3StorageConfig_resolvedOutputS3Uri' - The S3 path where offline records are written.
--
-- 's3Uri', 's3StorageConfig_s3Uri' - The S3 URI, or location in Amazon S3, of @OfflineStore@.
--
-- S3 URIs have a format similar to the following:
-- @s3:\/\/example-bucket\/prefix\/@.
newS3StorageConfig ::
  -- | 's3Uri'
  Prelude.Text ->
  S3StorageConfig
newS3StorageConfig :: Text -> S3StorageConfig
newS3StorageConfig Text
pS3Uri_ =
  S3StorageConfig'
    { $sel:kmsKeyId:S3StorageConfig' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:resolvedOutputS3Uri:S3StorageConfig' :: Maybe Text
resolvedOutputS3Uri = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Uri:S3StorageConfig' :: Text
s3Uri = Text
pS3Uri_
    }

-- | The Amazon Web Services Key Management Service (KMS) key ID of the key
-- used to encrypt any objects written into the @OfflineStore@ S3 location.
--
-- The IAM @roleARN@ that is passed as a parameter to @CreateFeatureGroup@
-- must have below permissions to the @KmsKeyId@:
--
-- -   @\"kms:GenerateDataKey\"@
s3StorageConfig_kmsKeyId :: Lens.Lens' S3StorageConfig (Prelude.Maybe Prelude.Text)
s3StorageConfig_kmsKeyId :: Lens' S3StorageConfig (Maybe Text)
s3StorageConfig_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3StorageConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:S3StorageConfig' :: S3StorageConfig -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: S3StorageConfig
s@S3StorageConfig' {} Maybe Text
a -> S3StorageConfig
s {$sel:kmsKeyId:S3StorageConfig' :: Maybe Text
kmsKeyId = Maybe Text
a} :: S3StorageConfig)

-- | The S3 path where offline records are written.
s3StorageConfig_resolvedOutputS3Uri :: Lens.Lens' S3StorageConfig (Prelude.Maybe Prelude.Text)
s3StorageConfig_resolvedOutputS3Uri :: Lens' S3StorageConfig (Maybe Text)
s3StorageConfig_resolvedOutputS3Uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3StorageConfig' {Maybe Text
resolvedOutputS3Uri :: Maybe Text
$sel:resolvedOutputS3Uri:S3StorageConfig' :: S3StorageConfig -> Maybe Text
resolvedOutputS3Uri} -> Maybe Text
resolvedOutputS3Uri) (\s :: S3StorageConfig
s@S3StorageConfig' {} Maybe Text
a -> S3StorageConfig
s {$sel:resolvedOutputS3Uri:S3StorageConfig' :: Maybe Text
resolvedOutputS3Uri = Maybe Text
a} :: S3StorageConfig)

-- | The S3 URI, or location in Amazon S3, of @OfflineStore@.
--
-- S3 URIs have a format similar to the following:
-- @s3:\/\/example-bucket\/prefix\/@.
s3StorageConfig_s3Uri :: Lens.Lens' S3StorageConfig Prelude.Text
s3StorageConfig_s3Uri :: Lens' S3StorageConfig Text
s3StorageConfig_s3Uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3StorageConfig' {Text
s3Uri :: Text
$sel:s3Uri:S3StorageConfig' :: S3StorageConfig -> Text
s3Uri} -> Text
s3Uri) (\s :: S3StorageConfig
s@S3StorageConfig' {} Text
a -> S3StorageConfig
s {$sel:s3Uri:S3StorageConfig' :: Text
s3Uri = Text
a} :: S3StorageConfig)

instance Data.FromJSON S3StorageConfig where
  parseJSON :: Value -> Parser S3StorageConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3StorageConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> S3StorageConfig
S3StorageConfig'
            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
"KmsKeyId")
            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
"ResolvedOutputS3Uri")
            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
"S3Uri")
      )

instance Prelude.Hashable S3StorageConfig where
  hashWithSalt :: Int -> S3StorageConfig -> Int
hashWithSalt Int
_salt S3StorageConfig' {Maybe Text
Text
s3Uri :: Text
resolvedOutputS3Uri :: Maybe Text
kmsKeyId :: Maybe Text
$sel:s3Uri:S3StorageConfig' :: S3StorageConfig -> Text
$sel:resolvedOutputS3Uri:S3StorageConfig' :: S3StorageConfig -> Maybe Text
$sel:kmsKeyId:S3StorageConfig' :: S3StorageConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resolvedOutputS3Uri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Uri

instance Prelude.NFData S3StorageConfig where
  rnf :: S3StorageConfig -> ()
rnf S3StorageConfig' {Maybe Text
Text
s3Uri :: Text
resolvedOutputS3Uri :: Maybe Text
kmsKeyId :: Maybe Text
$sel:s3Uri:S3StorageConfig' :: S3StorageConfig -> Text
$sel:resolvedOutputS3Uri:S3StorageConfig' :: S3StorageConfig -> Maybe Text
$sel:kmsKeyId:S3StorageConfig' :: S3StorageConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resolvedOutputS3Uri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3Uri

instance Data.ToJSON S3StorageConfig where
  toJSON :: S3StorageConfig -> Value
toJSON S3StorageConfig' {Maybe Text
Text
s3Uri :: Text
resolvedOutputS3Uri :: Maybe Text
kmsKeyId :: Maybe Text
$sel:s3Uri:S3StorageConfig' :: S3StorageConfig -> Text
$sel:resolvedOutputS3Uri:S3StorageConfig' :: S3StorageConfig -> Maybe Text
$sel:kmsKeyId:S3StorageConfig' :: S3StorageConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KmsKeyId" 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
kmsKeyId,
            (Key
"ResolvedOutputS3Uri" 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
resolvedOutputS3Uri,
            forall a. a -> Maybe a
Prelude.Just (Key
"S3Uri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3Uri)
          ]
      )