{-# 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-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.SharingSettings 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
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'
  { -- | Whether to include the notebook cell output when sharing the notebook.
    -- The default is @Disabled@.
    SharingSettings -> Maybe NotebookOutputOption
notebookOutputOption :: Prelude.Maybe NotebookOutputOption,
    -- | 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
  }
  deriving (SharingSettings -> SharingSettings -> Bool
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]
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
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. 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:
--
-- 'notebookOutputOption', 'sharingSettings_notebookOutputOption' - Whether to include the notebook cell output when sharing the notebook.
-- The default is @Disabled@.
--
-- '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.
newSharingSettings ::
  SharingSettings
newSharingSettings :: SharingSettings
newSharingSettings =
  SharingSettings'
    { $sel:notebookOutputOption:SharingSettings' :: Maybe NotebookOutputOption
notebookOutputOption =
        forall a. Maybe a
Prelude.Nothing,
      $sel:s3KmsKeyId:SharingSettings' :: Maybe Text
s3KmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:SharingSettings' :: Maybe Text
s3OutputPath = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' SharingSettings (Maybe NotebookOutputOption)
sharingSettings_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)

-- | 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 :: Lens' SharingSettings (Maybe Text)
sharingSettings_s3KmsKeyId = 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 :: Lens' SharingSettings (Maybe Text)
sharingSettings_s3OutputPath = 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)

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

instance Prelude.Hashable SharingSettings where
  hashWithSalt :: Int -> SharingSettings -> Int
hashWithSalt Int
_salt SharingSettings' {Maybe Text
Maybe NotebookOutputOption
s3OutputPath :: Maybe Text
s3KmsKeyId :: Maybe Text
notebookOutputOption :: Maybe NotebookOutputOption
$sel:s3OutputPath:SharingSettings' :: SharingSettings -> Maybe Text
$sel:s3KmsKeyId:SharingSettings' :: SharingSettings -> Maybe Text
$sel:notebookOutputOption:SharingSettings' :: SharingSettings -> Maybe NotebookOutputOption
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotebookOutputOption
notebookOutputOption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3KmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3OutputPath

instance Prelude.NFData SharingSettings where
  rnf :: SharingSettings -> ()
rnf SharingSettings' {Maybe Text
Maybe NotebookOutputOption
s3OutputPath :: Maybe Text
s3KmsKeyId :: Maybe Text
notebookOutputOption :: Maybe NotebookOutputOption
$sel:s3OutputPath:SharingSettings' :: SharingSettings -> Maybe Text
$sel:s3KmsKeyId:SharingSettings' :: SharingSettings -> Maybe Text
$sel:notebookOutputOption:SharingSettings' :: SharingSettings -> Maybe NotebookOutputOption
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe NotebookOutputOption
notebookOutputOption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3KmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3OutputPath

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