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

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

-- | Specifies options for sharing SageMaker Studio notebooks. These settings
-- are specified as part of @DefaultUserSettings@ when the @CreateDomain@
-- API is called, and as part of @UserSettings@ when the
-- @CreateUserProfile@ API is called. When @SharingSettings@ is not
-- specified, notebook sharing isn\'t allowed.
--
-- /See:/ 'newSharingSettings' smart constructor.
data SharingSettings = SharingSettings'
  { -- | When @NotebookOutputOption@ is @Allowed@, the Amazon Web Services Key
    -- Management Service (KMS) encryption key ID used to encrypt the notebook
    -- cell output in the Amazon S3 bucket.
    SharingSettings -> Maybe Text
s3KmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | When @NotebookOutputOption@ is @Allowed@, the Amazon S3 bucket used to
    -- store the shared notebook snapshots.
    SharingSettings -> Maybe Text
s3OutputPath :: Prelude.Maybe Prelude.Text,
    -- | Whether to include the notebook cell output when sharing the notebook.
    -- The default is @Disabled@.
    SharingSettings -> Maybe NotebookOutputOption
notebookOutputOption :: Prelude.Maybe NotebookOutputOption
  }
  deriving (SharingSettings -> SharingSettings -> Bool
(SharingSettings -> SharingSettings -> Bool)
-> (SharingSettings -> SharingSettings -> Bool)
-> Eq SharingSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SharingSettings -> SharingSettings -> Bool
$c/= :: SharingSettings -> SharingSettings -> Bool
== :: SharingSettings -> SharingSettings -> Bool
$c== :: SharingSettings -> SharingSettings -> Bool
Prelude.Eq, ReadPrec [SharingSettings]
ReadPrec SharingSettings
Int -> ReadS SharingSettings
ReadS [SharingSettings]
(Int -> ReadS SharingSettings)
-> ReadS [SharingSettings]
-> ReadPrec SharingSettings
-> ReadPrec [SharingSettings]
-> Read SharingSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SharingSettings]
$creadListPrec :: ReadPrec [SharingSettings]
readPrec :: ReadPrec SharingSettings
$creadPrec :: ReadPrec SharingSettings
readList :: ReadS [SharingSettings]
$creadList :: ReadS [SharingSettings]
readsPrec :: Int -> ReadS SharingSettings
$creadsPrec :: Int -> ReadS SharingSettings
Prelude.Read, Int -> SharingSettings -> ShowS
[SharingSettings] -> ShowS
SharingSettings -> String
(Int -> SharingSettings -> ShowS)
-> (SharingSettings -> String)
-> ([SharingSettings] -> ShowS)
-> Show SharingSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SharingSettings] -> ShowS
$cshowList :: [SharingSettings] -> ShowS
show :: SharingSettings -> String
$cshow :: SharingSettings -> String
showsPrec :: Int -> SharingSettings -> ShowS
$cshowsPrec :: Int -> SharingSettings -> ShowS
Prelude.Show, (forall x. SharingSettings -> Rep SharingSettings x)
-> (forall x. Rep SharingSettings x -> SharingSettings)
-> Generic SharingSettings
forall x. Rep SharingSettings x -> SharingSettings
forall x. SharingSettings -> Rep SharingSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SharingSettings x -> SharingSettings
$cfrom :: forall x. SharingSettings -> Rep SharingSettings x
Prelude.Generic)

-- |
-- Create a value of 'SharingSettings' 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:
--
-- 's3KmsKeyId', 'sharingSettings_s3KmsKeyId' - When @NotebookOutputOption@ is @Allowed@, the Amazon Web Services Key
-- Management Service (KMS) encryption key ID used to encrypt the notebook
-- cell output in the Amazon S3 bucket.
--
-- 's3OutputPath', 'sharingSettings_s3OutputPath' - When @NotebookOutputOption@ is @Allowed@, the Amazon S3 bucket used to
-- store the shared notebook snapshots.
--
-- 'notebookOutputOption', 'sharingSettings_notebookOutputOption' - Whether to include the notebook cell output when sharing the notebook.
-- The default is @Disabled@.
newSharingSettings ::
  SharingSettings
newSharingSettings :: SharingSettings
newSharingSettings =
  SharingSettings' :: Maybe Text
-> Maybe Text -> Maybe NotebookOutputOption -> SharingSettings
SharingSettings'
    { $sel:s3KmsKeyId:SharingSettings' :: Maybe Text
s3KmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:SharingSettings' :: Maybe Text
s3OutputPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notebookOutputOption:SharingSettings' :: Maybe NotebookOutputOption
notebookOutputOption = Maybe NotebookOutputOption
forall a. Maybe a
Prelude.Nothing
    }

-- | When @NotebookOutputOption@ is @Allowed@, the Amazon Web Services Key
-- Management Service (KMS) encryption key ID used to encrypt the notebook
-- cell output in the Amazon S3 bucket.
sharingSettings_s3KmsKeyId :: Lens.Lens' SharingSettings (Prelude.Maybe Prelude.Text)
sharingSettings_s3KmsKeyId :: (Maybe Text -> f (Maybe Text))
-> SharingSettings -> f SharingSettings
sharingSettings_s3KmsKeyId = (SharingSettings -> Maybe Text)
-> (SharingSettings -> Maybe Text -> SharingSettings)
-> Lens SharingSettings SharingSettings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SharingSettings' {Maybe Text
s3KmsKeyId :: Maybe Text
$sel:s3KmsKeyId:SharingSettings' :: SharingSettings -> Maybe Text
s3KmsKeyId} -> Maybe Text
s3KmsKeyId) (\s :: SharingSettings
s@SharingSettings' {} Maybe Text
a -> SharingSettings
s {$sel:s3KmsKeyId:SharingSettings' :: Maybe Text
s3KmsKeyId = Maybe Text
a} :: SharingSettings)

-- | When @NotebookOutputOption@ is @Allowed@, the Amazon S3 bucket used to
-- store the shared notebook snapshots.
sharingSettings_s3OutputPath :: Lens.Lens' SharingSettings (Prelude.Maybe Prelude.Text)
sharingSettings_s3OutputPath :: (Maybe Text -> f (Maybe Text))
-> SharingSettings -> f SharingSettings
sharingSettings_s3OutputPath = (SharingSettings -> Maybe Text)
-> (SharingSettings -> Maybe Text -> SharingSettings)
-> Lens SharingSettings SharingSettings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SharingSettings' {Maybe Text
s3OutputPath :: Maybe Text
$sel:s3OutputPath:SharingSettings' :: SharingSettings -> Maybe Text
s3OutputPath} -> Maybe Text
s3OutputPath) (\s :: SharingSettings
s@SharingSettings' {} Maybe Text
a -> SharingSettings
s {$sel:s3OutputPath:SharingSettings' :: Maybe Text
s3OutputPath = Maybe Text
a} :: SharingSettings)

-- | Whether to include the notebook cell output when sharing the notebook.
-- The default is @Disabled@.
sharingSettings_notebookOutputOption :: Lens.Lens' SharingSettings (Prelude.Maybe NotebookOutputOption)
sharingSettings_notebookOutputOption :: (Maybe NotebookOutputOption -> f (Maybe NotebookOutputOption))
-> SharingSettings -> f SharingSettings
sharingSettings_notebookOutputOption = (SharingSettings -> Maybe NotebookOutputOption)
-> (SharingSettings
    -> Maybe NotebookOutputOption -> SharingSettings)
-> Lens
     SharingSettings
     SharingSettings
     (Maybe NotebookOutputOption)
     (Maybe NotebookOutputOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SharingSettings' {Maybe NotebookOutputOption
notebookOutputOption :: Maybe NotebookOutputOption
$sel:notebookOutputOption:SharingSettings' :: SharingSettings -> Maybe NotebookOutputOption
notebookOutputOption} -> Maybe NotebookOutputOption
notebookOutputOption) (\s :: SharingSettings
s@SharingSettings' {} Maybe NotebookOutputOption
a -> SharingSettings
s {$sel:notebookOutputOption:SharingSettings' :: Maybe NotebookOutputOption
notebookOutputOption = Maybe NotebookOutputOption
a} :: SharingSettings)

instance Core.FromJSON SharingSettings where
  parseJSON :: Value -> Parser SharingSettings
parseJSON =
    String
-> (Object -> Parser SharingSettings)
-> Value
-> Parser SharingSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SharingSettings"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe NotebookOutputOption -> SharingSettings
SharingSettings'
            (Maybe Text
 -> Maybe Text -> Maybe NotebookOutputOption -> SharingSettings)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe NotebookOutputOption -> SharingSettings)
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
"S3KmsKeyId")
            Parser
  (Maybe Text -> Maybe NotebookOutputOption -> SharingSettings)
-> Parser (Maybe Text)
-> Parser (Maybe NotebookOutputOption -> SharingSettings)
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
"S3OutputPath")
            Parser (Maybe NotebookOutputOption -> SharingSettings)
-> Parser (Maybe NotebookOutputOption) -> Parser SharingSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NotebookOutputOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NotebookOutputOption")
      )

instance Prelude.Hashable SharingSettings

instance Prelude.NFData SharingSettings

instance Core.ToJSON SharingSettings where
  toJSON :: SharingSettings -> Value
toJSON SharingSettings' {Maybe Text
Maybe NotebookOutputOption
notebookOutputOption :: Maybe NotebookOutputOption
s3OutputPath :: Maybe Text
s3KmsKeyId :: Maybe Text
$sel:notebookOutputOption:SharingSettings' :: SharingSettings -> Maybe NotebookOutputOption
$sel:s3OutputPath:SharingSettings' :: SharingSettings -> Maybe Text
$sel:s3KmsKeyId:SharingSettings' :: SharingSettings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3KmsKeyId" 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
s3KmsKeyId,
            (Text
"S3OutputPath" 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
s3OutputPath,
            (Text
"NotebookOutputOption" Text -> NotebookOutputOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NotebookOutputOption -> Pair)
-> Maybe NotebookOutputOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotebookOutputOption
notebookOutputOption
          ]
      )