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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(NotebookInstanceLifecycleHook
 -> NotebookInstanceLifecycleHook -> Bool)
-> (NotebookInstanceLifecycleHook
    -> NotebookInstanceLifecycleHook -> Bool)
-> Eq NotebookInstanceLifecycleHook
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]
(Int -> ReadS NotebookInstanceLifecycleHook)
-> ReadS [NotebookInstanceLifecycleHook]
-> ReadPrec NotebookInstanceLifecycleHook
-> ReadPrec [NotebookInstanceLifecycleHook]
-> Read 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
(Int -> NotebookInstanceLifecycleHook -> ShowS)
-> (NotebookInstanceLifecycleHook -> String)
-> ([NotebookInstanceLifecycleHook] -> ShowS)
-> Show NotebookInstanceLifecycleHook
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.
 NotebookInstanceLifecycleHook
 -> Rep NotebookInstanceLifecycleHook x)
-> (forall x.
    Rep NotebookInstanceLifecycleHook x
    -> NotebookInstanceLifecycleHook)
-> Generic NotebookInstanceLifecycleHook
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' :: Maybe Text -> NotebookInstanceLifecycleHook
NotebookInstanceLifecycleHook'
    { $sel:content:NotebookInstanceLifecycleHook' :: Maybe Text
content =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> NotebookInstanceLifecycleHook -> f NotebookInstanceLifecycleHook
notebookInstanceLifecycleHook_content = (NotebookInstanceLifecycleHook -> Maybe Text)
-> (NotebookInstanceLifecycleHook
    -> Maybe Text -> NotebookInstanceLifecycleHook)
-> Lens
     NotebookInstanceLifecycleHook
     NotebookInstanceLifecycleHook
     (Maybe Text)
     (Maybe Text)
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 Core.FromJSON NotebookInstanceLifecycleHook where
  parseJSON :: Value -> Parser NotebookInstanceLifecycleHook
parseJSON =
    String
-> (Object -> Parser NotebookInstanceLifecycleHook)
-> Value
-> Parser NotebookInstanceLifecycleHook
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NotebookInstanceLifecycleHook"
      ( \Object
x ->
          Maybe Text -> NotebookInstanceLifecycleHook
NotebookInstanceLifecycleHook'
            (Maybe Text -> NotebookInstanceLifecycleHook)
-> Parser (Maybe Text) -> Parser NotebookInstanceLifecycleHook
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
"Content")
      )

instance
  Prelude.Hashable
    NotebookInstanceLifecycleHook

instance Prelude.NFData NotebookInstanceLifecycleHook

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