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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 S3 path where offline records are written.
    S3StorageConfig -> Maybe Text
resolvedOutputS3Uri :: Prelude.Maybe Prelude.Text,
    -- | 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 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
(S3StorageConfig -> S3StorageConfig -> Bool)
-> (S3StorageConfig -> S3StorageConfig -> Bool)
-> Eq S3StorageConfig
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]
(Int -> ReadS S3StorageConfig)
-> ReadS [S3StorageConfig]
-> ReadPrec S3StorageConfig
-> ReadPrec [S3StorageConfig]
-> Read 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
(Int -> S3StorageConfig -> ShowS)
-> (S3StorageConfig -> String)
-> ([S3StorageConfig] -> ShowS)
-> Show S3StorageConfig
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. S3StorageConfig -> Rep S3StorageConfig x)
-> (forall x. Rep S3StorageConfig x -> S3StorageConfig)
-> Generic S3StorageConfig
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:
--
-- 'resolvedOutputS3Uri', 's3StorageConfig_resolvedOutputS3Uri' - The S3 path where offline records are written.
--
-- '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\"@
--
-- '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' :: Maybe Text -> Maybe Text -> Text -> S3StorageConfig
S3StorageConfig'
    { $sel:resolvedOutputS3Uri:S3StorageConfig' :: Maybe Text
resolvedOutputS3Uri =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:S3StorageConfig' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Uri:S3StorageConfig' :: Text
s3Uri = Text
pS3Uri_
    }

-- | The S3 path where offline records are written.
s3StorageConfig_resolvedOutputS3Uri :: Lens.Lens' S3StorageConfig (Prelude.Maybe Prelude.Text)
s3StorageConfig_resolvedOutputS3Uri :: (Maybe Text -> f (Maybe Text))
-> S3StorageConfig -> f S3StorageConfig
s3StorageConfig_resolvedOutputS3Uri = (S3StorageConfig -> Maybe Text)
-> (S3StorageConfig -> Maybe Text -> S3StorageConfig)
-> Lens S3StorageConfig S3StorageConfig (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> S3StorageConfig -> f S3StorageConfig
s3StorageConfig_kmsKeyId = (S3StorageConfig -> Maybe Text)
-> (S3StorageConfig -> Maybe Text -> S3StorageConfig)
-> Lens S3StorageConfig S3StorageConfig (Maybe Text) (Maybe Text)
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 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 :: (Text -> f Text) -> S3StorageConfig -> f S3StorageConfig
s3StorageConfig_s3Uri = (S3StorageConfig -> Text)
-> (S3StorageConfig -> Text -> S3StorageConfig)
-> Lens S3StorageConfig S3StorageConfig Text Text
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 Core.FromJSON S3StorageConfig where
  parseJSON :: Value -> Parser S3StorageConfig
parseJSON =
    String
-> (Object -> Parser S3StorageConfig)
-> Value
-> Parser S3StorageConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3StorageConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> S3StorageConfig
S3StorageConfig'
            (Maybe Text -> Maybe Text -> Text -> S3StorageConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> S3StorageConfig)
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
"ResolvedOutputS3Uri")
            Parser (Maybe Text -> Text -> S3StorageConfig)
-> Parser (Maybe Text) -> Parser (Text -> S3StorageConfig)
forall (f :: * -> *) a b. Applicative f => 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
"KmsKeyId")
            Parser (Text -> S3StorageConfig)
-> Parser Text -> Parser S3StorageConfig
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
"S3Uri")
      )

instance Prelude.Hashable S3StorageConfig

instance Prelude.NFData S3StorageConfig

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