{-# 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.OnlineStoreSecurityConfig
-- 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.OnlineStoreSecurityConfig where

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

-- | The security configuration for @OnlineStore@.
--
-- /See:/ 'newOnlineStoreSecurityConfig' smart constructor.
data OnlineStoreSecurityConfig = OnlineStoreSecurityConfig'
  { -- | The ID of the Amazon Web Services Key Management Service (Amazon Web
    -- Services KMS) key that SageMaker Feature Store uses to encrypt the
    -- Amazon S3 objects at rest using Amazon S3 server-side encryption.
    --
    -- The caller (either IAM user or IAM role) of @CreateFeatureGroup@ must
    -- have below permissions to the @OnlineStore@ @KmsKeyId@:
    --
    -- -   @\"kms:Encrypt\"@
    --
    -- -   @\"kms:Decrypt\"@
    --
    -- -   @\"kms:DescribeKey\"@
    --
    -- -   @\"kms:CreateGrant\"@
    --
    -- -   @\"kms:RetireGrant\"@
    --
    -- -   @\"kms:ReEncryptFrom\"@
    --
    -- -   @\"kms:ReEncryptTo\"@
    --
    -- -   @\"kms:GenerateDataKey\"@
    --
    -- -   @\"kms:ListAliases\"@
    --
    -- -   @\"kms:ListGrants\"@
    --
    -- -   @\"kms:RevokeGrant\"@
    --
    -- The caller (either IAM user or IAM role) to all DataPlane operations
    -- (@PutRecord@, @GetRecord@, @DeleteRecord@) must have the following
    -- permissions to the @KmsKeyId@:
    --
    -- -   @\"kms:Decrypt\"@
    OnlineStoreSecurityConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool
(OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool)
-> (OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool)
-> Eq OnlineStoreSecurityConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool
$c/= :: OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool
== :: OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool
$c== :: OnlineStoreSecurityConfig -> OnlineStoreSecurityConfig -> Bool
Prelude.Eq, ReadPrec [OnlineStoreSecurityConfig]
ReadPrec OnlineStoreSecurityConfig
Int -> ReadS OnlineStoreSecurityConfig
ReadS [OnlineStoreSecurityConfig]
(Int -> ReadS OnlineStoreSecurityConfig)
-> ReadS [OnlineStoreSecurityConfig]
-> ReadPrec OnlineStoreSecurityConfig
-> ReadPrec [OnlineStoreSecurityConfig]
-> Read OnlineStoreSecurityConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OnlineStoreSecurityConfig]
$creadListPrec :: ReadPrec [OnlineStoreSecurityConfig]
readPrec :: ReadPrec OnlineStoreSecurityConfig
$creadPrec :: ReadPrec OnlineStoreSecurityConfig
readList :: ReadS [OnlineStoreSecurityConfig]
$creadList :: ReadS [OnlineStoreSecurityConfig]
readsPrec :: Int -> ReadS OnlineStoreSecurityConfig
$creadsPrec :: Int -> ReadS OnlineStoreSecurityConfig
Prelude.Read, Int -> OnlineStoreSecurityConfig -> ShowS
[OnlineStoreSecurityConfig] -> ShowS
OnlineStoreSecurityConfig -> String
(Int -> OnlineStoreSecurityConfig -> ShowS)
-> (OnlineStoreSecurityConfig -> String)
-> ([OnlineStoreSecurityConfig] -> ShowS)
-> Show OnlineStoreSecurityConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnlineStoreSecurityConfig] -> ShowS
$cshowList :: [OnlineStoreSecurityConfig] -> ShowS
show :: OnlineStoreSecurityConfig -> String
$cshow :: OnlineStoreSecurityConfig -> String
showsPrec :: Int -> OnlineStoreSecurityConfig -> ShowS
$cshowsPrec :: Int -> OnlineStoreSecurityConfig -> ShowS
Prelude.Show, (forall x.
 OnlineStoreSecurityConfig -> Rep OnlineStoreSecurityConfig x)
-> (forall x.
    Rep OnlineStoreSecurityConfig x -> OnlineStoreSecurityConfig)
-> Generic OnlineStoreSecurityConfig
forall x.
Rep OnlineStoreSecurityConfig x -> OnlineStoreSecurityConfig
forall x.
OnlineStoreSecurityConfig -> Rep OnlineStoreSecurityConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OnlineStoreSecurityConfig x -> OnlineStoreSecurityConfig
$cfrom :: forall x.
OnlineStoreSecurityConfig -> Rep OnlineStoreSecurityConfig x
Prelude.Generic)

-- |
-- Create a value of 'OnlineStoreSecurityConfig' 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', 'onlineStoreSecurityConfig_kmsKeyId' - The ID of the Amazon Web Services Key Management Service (Amazon Web
-- Services KMS) key that SageMaker Feature Store uses to encrypt the
-- Amazon S3 objects at rest using Amazon S3 server-side encryption.
--
-- The caller (either IAM user or IAM role) of @CreateFeatureGroup@ must
-- have below permissions to the @OnlineStore@ @KmsKeyId@:
--
-- -   @\"kms:Encrypt\"@
--
-- -   @\"kms:Decrypt\"@
--
-- -   @\"kms:DescribeKey\"@
--
-- -   @\"kms:CreateGrant\"@
--
-- -   @\"kms:RetireGrant\"@
--
-- -   @\"kms:ReEncryptFrom\"@
--
-- -   @\"kms:ReEncryptTo\"@
--
-- -   @\"kms:GenerateDataKey\"@
--
-- -   @\"kms:ListAliases\"@
--
-- -   @\"kms:ListGrants\"@
--
-- -   @\"kms:RevokeGrant\"@
--
-- The caller (either IAM user or IAM role) to all DataPlane operations
-- (@PutRecord@, @GetRecord@, @DeleteRecord@) must have the following
-- permissions to the @KmsKeyId@:
--
-- -   @\"kms:Decrypt\"@
newOnlineStoreSecurityConfig ::
  OnlineStoreSecurityConfig
newOnlineStoreSecurityConfig :: OnlineStoreSecurityConfig
newOnlineStoreSecurityConfig =
  OnlineStoreSecurityConfig' :: Maybe Text -> OnlineStoreSecurityConfig
OnlineStoreSecurityConfig'
    { $sel:kmsKeyId:OnlineStoreSecurityConfig' :: Maybe Text
kmsKeyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Web Services Key Management Service (Amazon Web
-- Services KMS) key that SageMaker Feature Store uses to encrypt the
-- Amazon S3 objects at rest using Amazon S3 server-side encryption.
--
-- The caller (either IAM user or IAM role) of @CreateFeatureGroup@ must
-- have below permissions to the @OnlineStore@ @KmsKeyId@:
--
-- -   @\"kms:Encrypt\"@
--
-- -   @\"kms:Decrypt\"@
--
-- -   @\"kms:DescribeKey\"@
--
-- -   @\"kms:CreateGrant\"@
--
-- -   @\"kms:RetireGrant\"@
--
-- -   @\"kms:ReEncryptFrom\"@
--
-- -   @\"kms:ReEncryptTo\"@
--
-- -   @\"kms:GenerateDataKey\"@
--
-- -   @\"kms:ListAliases\"@
--
-- -   @\"kms:ListGrants\"@
--
-- -   @\"kms:RevokeGrant\"@
--
-- The caller (either IAM user or IAM role) to all DataPlane operations
-- (@PutRecord@, @GetRecord@, @DeleteRecord@) must have the following
-- permissions to the @KmsKeyId@:
--
-- -   @\"kms:Decrypt\"@
onlineStoreSecurityConfig_kmsKeyId :: Lens.Lens' OnlineStoreSecurityConfig (Prelude.Maybe Prelude.Text)
onlineStoreSecurityConfig_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> OnlineStoreSecurityConfig -> f OnlineStoreSecurityConfig
onlineStoreSecurityConfig_kmsKeyId = (OnlineStoreSecurityConfig -> Maybe Text)
-> (OnlineStoreSecurityConfig
    -> Maybe Text -> OnlineStoreSecurityConfig)
-> Lens
     OnlineStoreSecurityConfig
     OnlineStoreSecurityConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnlineStoreSecurityConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:OnlineStoreSecurityConfig' :: OnlineStoreSecurityConfig -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: OnlineStoreSecurityConfig
s@OnlineStoreSecurityConfig' {} Maybe Text
a -> OnlineStoreSecurityConfig
s {$sel:kmsKeyId:OnlineStoreSecurityConfig' :: Maybe Text
kmsKeyId = Maybe Text
a} :: OnlineStoreSecurityConfig)

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

instance Prelude.Hashable OnlineStoreSecurityConfig

instance Prelude.NFData OnlineStoreSecurityConfig

instance Core.ToJSON OnlineStoreSecurityConfig where
  toJSON :: OnlineStoreSecurityConfig -> Value
toJSON OnlineStoreSecurityConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:OnlineStoreSecurityConfig' :: OnlineStoreSecurityConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(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]
      )