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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.OnlineStoreSecurityConfig

-- | Use this to specify the Amazon Web Services Key Management Service (KMS)
-- Key ID, or @KMSKeyId@, for at rest data encryption. You can turn
-- @OnlineStore@ on or off by specifying the @EnableOnlineStore@ flag at
-- General Assembly; the default value is @False@.
--
-- /See:/ 'newOnlineStoreConfig' smart constructor.
data OnlineStoreConfig = OnlineStoreConfig'
  { -- | Use to specify KMS Key ID (@KMSKeyId@) for at-rest encryption of your
    -- @OnlineStore@.
    OnlineStoreConfig -> Maybe OnlineStoreSecurityConfig
securityConfig :: Prelude.Maybe OnlineStoreSecurityConfig,
    -- | Turn @OnlineStore@ off by specifying @False@ for the @EnableOnlineStore@
    -- flag. Turn @OnlineStore@ on by specifying @True@ for the
    -- @EnableOnlineStore@ flag.
    --
    -- The default value is @False@.
    OnlineStoreConfig -> Maybe Bool
enableOnlineStore :: Prelude.Maybe Prelude.Bool
  }
  deriving (OnlineStoreConfig -> OnlineStoreConfig -> Bool
(OnlineStoreConfig -> OnlineStoreConfig -> Bool)
-> (OnlineStoreConfig -> OnlineStoreConfig -> Bool)
-> Eq OnlineStoreConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnlineStoreConfig -> OnlineStoreConfig -> Bool
$c/= :: OnlineStoreConfig -> OnlineStoreConfig -> Bool
== :: OnlineStoreConfig -> OnlineStoreConfig -> Bool
$c== :: OnlineStoreConfig -> OnlineStoreConfig -> Bool
Prelude.Eq, ReadPrec [OnlineStoreConfig]
ReadPrec OnlineStoreConfig
Int -> ReadS OnlineStoreConfig
ReadS [OnlineStoreConfig]
(Int -> ReadS OnlineStoreConfig)
-> ReadS [OnlineStoreConfig]
-> ReadPrec OnlineStoreConfig
-> ReadPrec [OnlineStoreConfig]
-> Read OnlineStoreConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OnlineStoreConfig]
$creadListPrec :: ReadPrec [OnlineStoreConfig]
readPrec :: ReadPrec OnlineStoreConfig
$creadPrec :: ReadPrec OnlineStoreConfig
readList :: ReadS [OnlineStoreConfig]
$creadList :: ReadS [OnlineStoreConfig]
readsPrec :: Int -> ReadS OnlineStoreConfig
$creadsPrec :: Int -> ReadS OnlineStoreConfig
Prelude.Read, Int -> OnlineStoreConfig -> ShowS
[OnlineStoreConfig] -> ShowS
OnlineStoreConfig -> String
(Int -> OnlineStoreConfig -> ShowS)
-> (OnlineStoreConfig -> String)
-> ([OnlineStoreConfig] -> ShowS)
-> Show OnlineStoreConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnlineStoreConfig] -> ShowS
$cshowList :: [OnlineStoreConfig] -> ShowS
show :: OnlineStoreConfig -> String
$cshow :: OnlineStoreConfig -> String
showsPrec :: Int -> OnlineStoreConfig -> ShowS
$cshowsPrec :: Int -> OnlineStoreConfig -> ShowS
Prelude.Show, (forall x. OnlineStoreConfig -> Rep OnlineStoreConfig x)
-> (forall x. Rep OnlineStoreConfig x -> OnlineStoreConfig)
-> Generic OnlineStoreConfig
forall x. Rep OnlineStoreConfig x -> OnlineStoreConfig
forall x. OnlineStoreConfig -> Rep OnlineStoreConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnlineStoreConfig x -> OnlineStoreConfig
$cfrom :: forall x. OnlineStoreConfig -> Rep OnlineStoreConfig x
Prelude.Generic)

-- |
-- Create a value of 'OnlineStoreConfig' 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:
--
-- 'securityConfig', 'onlineStoreConfig_securityConfig' - Use to specify KMS Key ID (@KMSKeyId@) for at-rest encryption of your
-- @OnlineStore@.
--
-- 'enableOnlineStore', 'onlineStoreConfig_enableOnlineStore' - Turn @OnlineStore@ off by specifying @False@ for the @EnableOnlineStore@
-- flag. Turn @OnlineStore@ on by specifying @True@ for the
-- @EnableOnlineStore@ flag.
--
-- The default value is @False@.
newOnlineStoreConfig ::
  OnlineStoreConfig
newOnlineStoreConfig :: OnlineStoreConfig
newOnlineStoreConfig =
  OnlineStoreConfig' :: Maybe OnlineStoreSecurityConfig -> Maybe Bool -> OnlineStoreConfig
OnlineStoreConfig'
    { $sel:securityConfig:OnlineStoreConfig' :: Maybe OnlineStoreSecurityConfig
securityConfig =
        Maybe OnlineStoreSecurityConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:enableOnlineStore:OnlineStoreConfig' :: Maybe Bool
enableOnlineStore = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Use to specify KMS Key ID (@KMSKeyId@) for at-rest encryption of your
-- @OnlineStore@.
onlineStoreConfig_securityConfig :: Lens.Lens' OnlineStoreConfig (Prelude.Maybe OnlineStoreSecurityConfig)
onlineStoreConfig_securityConfig :: (Maybe OnlineStoreSecurityConfig
 -> f (Maybe OnlineStoreSecurityConfig))
-> OnlineStoreConfig -> f OnlineStoreConfig
onlineStoreConfig_securityConfig = (OnlineStoreConfig -> Maybe OnlineStoreSecurityConfig)
-> (OnlineStoreConfig
    -> Maybe OnlineStoreSecurityConfig -> OnlineStoreConfig)
-> Lens
     OnlineStoreConfig
     OnlineStoreConfig
     (Maybe OnlineStoreSecurityConfig)
     (Maybe OnlineStoreSecurityConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnlineStoreConfig' {Maybe OnlineStoreSecurityConfig
securityConfig :: Maybe OnlineStoreSecurityConfig
$sel:securityConfig:OnlineStoreConfig' :: OnlineStoreConfig -> Maybe OnlineStoreSecurityConfig
securityConfig} -> Maybe OnlineStoreSecurityConfig
securityConfig) (\s :: OnlineStoreConfig
s@OnlineStoreConfig' {} Maybe OnlineStoreSecurityConfig
a -> OnlineStoreConfig
s {$sel:securityConfig:OnlineStoreConfig' :: Maybe OnlineStoreSecurityConfig
securityConfig = Maybe OnlineStoreSecurityConfig
a} :: OnlineStoreConfig)

-- | Turn @OnlineStore@ off by specifying @False@ for the @EnableOnlineStore@
-- flag. Turn @OnlineStore@ on by specifying @True@ for the
-- @EnableOnlineStore@ flag.
--
-- The default value is @False@.
onlineStoreConfig_enableOnlineStore :: Lens.Lens' OnlineStoreConfig (Prelude.Maybe Prelude.Bool)
onlineStoreConfig_enableOnlineStore :: (Maybe Bool -> f (Maybe Bool))
-> OnlineStoreConfig -> f OnlineStoreConfig
onlineStoreConfig_enableOnlineStore = (OnlineStoreConfig -> Maybe Bool)
-> (OnlineStoreConfig -> Maybe Bool -> OnlineStoreConfig)
-> Lens
     OnlineStoreConfig OnlineStoreConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnlineStoreConfig' {Maybe Bool
enableOnlineStore :: Maybe Bool
$sel:enableOnlineStore:OnlineStoreConfig' :: OnlineStoreConfig -> Maybe Bool
enableOnlineStore} -> Maybe Bool
enableOnlineStore) (\s :: OnlineStoreConfig
s@OnlineStoreConfig' {} Maybe Bool
a -> OnlineStoreConfig
s {$sel:enableOnlineStore:OnlineStoreConfig' :: Maybe Bool
enableOnlineStore = Maybe Bool
a} :: OnlineStoreConfig)

instance Core.FromJSON OnlineStoreConfig where
  parseJSON :: Value -> Parser OnlineStoreConfig
parseJSON =
    String
-> (Object -> Parser OnlineStoreConfig)
-> Value
-> Parser OnlineStoreConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OnlineStoreConfig"
      ( \Object
x ->
          Maybe OnlineStoreSecurityConfig -> Maybe Bool -> OnlineStoreConfig
OnlineStoreConfig'
            (Maybe OnlineStoreSecurityConfig
 -> Maybe Bool -> OnlineStoreConfig)
-> Parser (Maybe OnlineStoreSecurityConfig)
-> Parser (Maybe Bool -> OnlineStoreConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OnlineStoreSecurityConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SecurityConfig")
            Parser (Maybe Bool -> OnlineStoreConfig)
-> Parser (Maybe Bool) -> Parser OnlineStoreConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EnableOnlineStore")
      )

instance Prelude.Hashable OnlineStoreConfig

instance Prelude.NFData OnlineStoreConfig

instance Core.ToJSON OnlineStoreConfig where
  toJSON :: OnlineStoreConfig -> Value
toJSON OnlineStoreConfig' {Maybe Bool
Maybe OnlineStoreSecurityConfig
enableOnlineStore :: Maybe Bool
securityConfig :: Maybe OnlineStoreSecurityConfig
$sel:enableOnlineStore:OnlineStoreConfig' :: OnlineStoreConfig -> Maybe Bool
$sel:securityConfig:OnlineStoreConfig' :: OnlineStoreConfig -> Maybe OnlineStoreSecurityConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SecurityConfig" Text -> OnlineStoreSecurityConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OnlineStoreSecurityConfig -> Pair)
-> Maybe OnlineStoreSecurityConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OnlineStoreSecurityConfig
securityConfig,
            (Text
"EnableOnlineStore" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enableOnlineStore
          ]
      )