{-# 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.NotebookInstanceLifecycleHook
-- 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.NotebookInstanceLifecycleHook 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

-- | Contains the notebook instance lifecycle configuration script.
--
-- Each lifecycle configuration script has a limit of 16384 characters.
--
-- The value of the @$PATH@ environment variable that is available to both
-- scripts is @\/sbin:bin:\/usr\/sbin:\/usr\/bin@.
--
-- View CloudWatch Logs for notebook instance lifecycle configurations in
-- log group @\/aws\/sagemaker\/NotebookInstances@ in log stream
-- @[notebook-instance-name]\/[LifecycleConfigHook]@.
--
-- Lifecycle configuration scripts cannot run for longer than 5 minutes. If
-- a script runs for longer than 5 minutes, it fails and the notebook
-- instance is not created or started.
--
-- For information about notebook instance lifestyle configurations, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html Step 2.1: (Optional) Customize a Notebook Instance>.
--
-- /See:/ 'newNotebookInstanceLifecycleHook' smart constructor.
data NotebookInstanceLifecycleHook = NotebookInstanceLifecycleHook'
  { -- | A base64-encoded string that contains a shell script for a notebook
    -- instance lifecycle configuration.
    NotebookInstanceLifecycleHook -> Maybe Text
content :: Prelude.Maybe Prelude.Text
  }
  deriving (NotebookInstanceLifecycleHook
-> NotebookInstanceLifecycleHook -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotebookInstanceLifecycleHook
-> NotebookInstanceLifecycleHook -> Bool
$c/= :: NotebookInstanceLifecycleHook
-> NotebookInstanceLifecycleHook -> Bool
== :: NotebookInstanceLifecycleHook
-> NotebookInstanceLifecycleHook -> Bool
$c== :: NotebookInstanceLifecycleHook
-> NotebookInstanceLifecycleHook -> Bool
Prelude.Eq, ReadPrec [NotebookInstanceLifecycleHook]
ReadPrec NotebookInstanceLifecycleHook
Int -> ReadS NotebookInstanceLifecycleHook
ReadS [NotebookInstanceLifecycleHook]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotebookInstanceLifecycleHook]
$creadListPrec :: ReadPrec [NotebookInstanceLifecycleHook]
readPrec :: ReadPrec NotebookInstanceLifecycleHook
$creadPrec :: ReadPrec NotebookInstanceLifecycleHook
readList :: ReadS [NotebookInstanceLifecycleHook]
$creadList :: ReadS [NotebookInstanceLifecycleHook]
readsPrec :: Int -> ReadS NotebookInstanceLifecycleHook
$creadsPrec :: Int -> ReadS NotebookInstanceLifecycleHook
Prelude.Read, Int -> NotebookInstanceLifecycleHook -> ShowS
[NotebookInstanceLifecycleHook] -> ShowS
NotebookInstanceLifecycleHook -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotebookInstanceLifecycleHook] -> ShowS
$cshowList :: [NotebookInstanceLifecycleHook] -> ShowS
show :: NotebookInstanceLifecycleHook -> String
$cshow :: NotebookInstanceLifecycleHook -> String
showsPrec :: Int -> NotebookInstanceLifecycleHook -> ShowS
$cshowsPrec :: Int -> NotebookInstanceLifecycleHook -> ShowS
Prelude.Show, forall x.
Rep NotebookInstanceLifecycleHook x
-> NotebookInstanceLifecycleHook
forall x.
NotebookInstanceLifecycleHook
-> Rep NotebookInstanceLifecycleHook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotebookInstanceLifecycleHook x
-> NotebookInstanceLifecycleHook
$cfrom :: forall x.
NotebookInstanceLifecycleHook
-> Rep NotebookInstanceLifecycleHook x
Prelude.Generic)

-- |
-- Create a value of 'NotebookInstanceLifecycleHook' 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:
--
-- 'content', 'notebookInstanceLifecycleHook_content' - A base64-encoded string that contains a shell script for a notebook
-- instance lifecycle configuration.
newNotebookInstanceLifecycleHook ::
  NotebookInstanceLifecycleHook
newNotebookInstanceLifecycleHook :: NotebookInstanceLifecycleHook
newNotebookInstanceLifecycleHook =
  NotebookInstanceLifecycleHook'
    { $sel:content:NotebookInstanceLifecycleHook' :: Maybe Text
content =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A base64-encoded string that contains a shell script for a notebook
-- instance lifecycle configuration.
notebookInstanceLifecycleHook_content :: Lens.Lens' NotebookInstanceLifecycleHook (Prelude.Maybe Prelude.Text)
notebookInstanceLifecycleHook_content :: Lens' NotebookInstanceLifecycleHook (Maybe Text)
notebookInstanceLifecycleHook_content = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotebookInstanceLifecycleHook' {Maybe Text
content :: Maybe Text
$sel:content:NotebookInstanceLifecycleHook' :: NotebookInstanceLifecycleHook -> Maybe Text
content} -> Maybe Text
content) (\s :: NotebookInstanceLifecycleHook
s@NotebookInstanceLifecycleHook' {} Maybe Text
a -> NotebookInstanceLifecycleHook
s {$sel:content:NotebookInstanceLifecycleHook' :: Maybe Text
content = Maybe Text
a} :: NotebookInstanceLifecycleHook)

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

instance
  Prelude.Hashable
    NotebookInstanceLifecycleHook
  where
  hashWithSalt :: Int -> NotebookInstanceLifecycleHook -> Int
hashWithSalt Int
_salt NotebookInstanceLifecycleHook' {Maybe Text
content :: Maybe Text
$sel:content:NotebookInstanceLifecycleHook' :: NotebookInstanceLifecycleHook -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
content

instance Prelude.NFData NotebookInstanceLifecycleHook where
  rnf :: NotebookInstanceLifecycleHook -> ()
rnf NotebookInstanceLifecycleHook' {Maybe Text
content :: Maybe Text
$sel:content:NotebookInstanceLifecycleHook' :: NotebookInstanceLifecycleHook -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
content

instance Data.ToJSON NotebookInstanceLifecycleHook where
  toJSON :: NotebookInstanceLifecycleHook -> Value
toJSON NotebookInstanceLifecycleHook' {Maybe Text
content :: Maybe Text
$sel:content:NotebookInstanceLifecycleHook' :: NotebookInstanceLifecycleHook -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Content" 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
content]
      )