{-# 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.AppStream.Types.ScriptDetails
-- 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.AppStream.Types.ScriptDetails where

import Amazonka.AppStream.Types.S3Location
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

-- | Describes the details of the script.
--
-- /See:/ 'newScriptDetails' smart constructor.
data ScriptDetails = ScriptDetails'
  { -- | The runtime parameters passed to the run path for the script.
    ScriptDetails -> Maybe Text
executableParameters :: Prelude.Maybe Prelude.Text,
    -- | The S3 object location for the script.
    ScriptDetails -> S3Location
scriptS3Location :: S3Location,
    -- | The run path for the script.
    ScriptDetails -> Text
executablePath :: Prelude.Text,
    -- | The run timeout, in seconds, for the script.
    ScriptDetails -> Int
timeoutInSeconds :: Prelude.Int
  }
  deriving (ScriptDetails -> ScriptDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScriptDetails -> ScriptDetails -> Bool
$c/= :: ScriptDetails -> ScriptDetails -> Bool
== :: ScriptDetails -> ScriptDetails -> Bool
$c== :: ScriptDetails -> ScriptDetails -> Bool
Prelude.Eq, ReadPrec [ScriptDetails]
ReadPrec ScriptDetails
Int -> ReadS ScriptDetails
ReadS [ScriptDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScriptDetails]
$creadListPrec :: ReadPrec [ScriptDetails]
readPrec :: ReadPrec ScriptDetails
$creadPrec :: ReadPrec ScriptDetails
readList :: ReadS [ScriptDetails]
$creadList :: ReadS [ScriptDetails]
readsPrec :: Int -> ReadS ScriptDetails
$creadsPrec :: Int -> ReadS ScriptDetails
Prelude.Read, Int -> ScriptDetails -> ShowS
[ScriptDetails] -> ShowS
ScriptDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScriptDetails] -> ShowS
$cshowList :: [ScriptDetails] -> ShowS
show :: ScriptDetails -> String
$cshow :: ScriptDetails -> String
showsPrec :: Int -> ScriptDetails -> ShowS
$cshowsPrec :: Int -> ScriptDetails -> ShowS
Prelude.Show, forall x. Rep ScriptDetails x -> ScriptDetails
forall x. ScriptDetails -> Rep ScriptDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScriptDetails x -> ScriptDetails
$cfrom :: forall x. ScriptDetails -> Rep ScriptDetails x
Prelude.Generic)

-- |
-- Create a value of 'ScriptDetails' 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:
--
-- 'executableParameters', 'scriptDetails_executableParameters' - The runtime parameters passed to the run path for the script.
--
-- 'scriptS3Location', 'scriptDetails_scriptS3Location' - The S3 object location for the script.
--
-- 'executablePath', 'scriptDetails_executablePath' - The run path for the script.
--
-- 'timeoutInSeconds', 'scriptDetails_timeoutInSeconds' - The run timeout, in seconds, for the script.
newScriptDetails ::
  -- | 'scriptS3Location'
  S3Location ->
  -- | 'executablePath'
  Prelude.Text ->
  -- | 'timeoutInSeconds'
  Prelude.Int ->
  ScriptDetails
newScriptDetails :: S3Location -> Text -> Int -> ScriptDetails
newScriptDetails
  S3Location
pScriptS3Location_
  Text
pExecutablePath_
  Int
pTimeoutInSeconds_ =
    ScriptDetails'
      { $sel:executableParameters:ScriptDetails' :: Maybe Text
executableParameters =
          forall a. Maybe a
Prelude.Nothing,
        $sel:scriptS3Location:ScriptDetails' :: S3Location
scriptS3Location = S3Location
pScriptS3Location_,
        $sel:executablePath:ScriptDetails' :: Text
executablePath = Text
pExecutablePath_,
        $sel:timeoutInSeconds:ScriptDetails' :: Int
timeoutInSeconds = Int
pTimeoutInSeconds_
      }

-- | The runtime parameters passed to the run path for the script.
scriptDetails_executableParameters :: Lens.Lens' ScriptDetails (Prelude.Maybe Prelude.Text)
scriptDetails_executableParameters :: Lens' ScriptDetails (Maybe Text)
scriptDetails_executableParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptDetails' {Maybe Text
executableParameters :: Maybe Text
$sel:executableParameters:ScriptDetails' :: ScriptDetails -> Maybe Text
executableParameters} -> Maybe Text
executableParameters) (\s :: ScriptDetails
s@ScriptDetails' {} Maybe Text
a -> ScriptDetails
s {$sel:executableParameters:ScriptDetails' :: Maybe Text
executableParameters = Maybe Text
a} :: ScriptDetails)

-- | The S3 object location for the script.
scriptDetails_scriptS3Location :: Lens.Lens' ScriptDetails S3Location
scriptDetails_scriptS3Location :: Lens' ScriptDetails S3Location
scriptDetails_scriptS3Location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptDetails' {S3Location
scriptS3Location :: S3Location
$sel:scriptS3Location:ScriptDetails' :: ScriptDetails -> S3Location
scriptS3Location} -> S3Location
scriptS3Location) (\s :: ScriptDetails
s@ScriptDetails' {} S3Location
a -> ScriptDetails
s {$sel:scriptS3Location:ScriptDetails' :: S3Location
scriptS3Location = S3Location
a} :: ScriptDetails)

-- | The run path for the script.
scriptDetails_executablePath :: Lens.Lens' ScriptDetails Prelude.Text
scriptDetails_executablePath :: Lens' ScriptDetails Text
scriptDetails_executablePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptDetails' {Text
executablePath :: Text
$sel:executablePath:ScriptDetails' :: ScriptDetails -> Text
executablePath} -> Text
executablePath) (\s :: ScriptDetails
s@ScriptDetails' {} Text
a -> ScriptDetails
s {$sel:executablePath:ScriptDetails' :: Text
executablePath = Text
a} :: ScriptDetails)

-- | The run timeout, in seconds, for the script.
scriptDetails_timeoutInSeconds :: Lens.Lens' ScriptDetails Prelude.Int
scriptDetails_timeoutInSeconds :: Lens' ScriptDetails Int
scriptDetails_timeoutInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptDetails' {Int
timeoutInSeconds :: Int
$sel:timeoutInSeconds:ScriptDetails' :: ScriptDetails -> Int
timeoutInSeconds} -> Int
timeoutInSeconds) (\s :: ScriptDetails
s@ScriptDetails' {} Int
a -> ScriptDetails
s {$sel:timeoutInSeconds:ScriptDetails' :: Int
timeoutInSeconds = Int
a} :: ScriptDetails)

instance Data.FromJSON ScriptDetails where
  parseJSON :: Value -> Parser ScriptDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScriptDetails"
      ( \Object
x ->
          Maybe Text -> S3Location -> Text -> Int -> ScriptDetails
ScriptDetails'
            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
"ExecutableParameters")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ScriptS3Location")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ExecutablePath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TimeoutInSeconds")
      )

instance Prelude.Hashable ScriptDetails where
  hashWithSalt :: Int -> ScriptDetails -> Int
hashWithSalt Int
_salt ScriptDetails' {Int
Maybe Text
Text
S3Location
timeoutInSeconds :: Int
executablePath :: Text
scriptS3Location :: S3Location
executableParameters :: Maybe Text
$sel:timeoutInSeconds:ScriptDetails' :: ScriptDetails -> Int
$sel:executablePath:ScriptDetails' :: ScriptDetails -> Text
$sel:scriptS3Location:ScriptDetails' :: ScriptDetails -> S3Location
$sel:executableParameters:ScriptDetails' :: ScriptDetails -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
executableParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` S3Location
scriptS3Location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
executablePath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
timeoutInSeconds

instance Prelude.NFData ScriptDetails where
  rnf :: ScriptDetails -> ()
rnf ScriptDetails' {Int
Maybe Text
Text
S3Location
timeoutInSeconds :: Int
executablePath :: Text
scriptS3Location :: S3Location
executableParameters :: Maybe Text
$sel:timeoutInSeconds:ScriptDetails' :: ScriptDetails -> Int
$sel:executablePath:ScriptDetails' :: ScriptDetails -> Text
$sel:scriptS3Location:ScriptDetails' :: ScriptDetails -> S3Location
$sel:executableParameters:ScriptDetails' :: ScriptDetails -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
executableParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf S3Location
scriptS3Location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
executablePath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
timeoutInSeconds

instance Data.ToJSON ScriptDetails where
  toJSON :: ScriptDetails -> Value
toJSON ScriptDetails' {Int
Maybe Text
Text
S3Location
timeoutInSeconds :: Int
executablePath :: Text
scriptS3Location :: S3Location
executableParameters :: Maybe Text
$sel:timeoutInSeconds:ScriptDetails' :: ScriptDetails -> Int
$sel:executablePath:ScriptDetails' :: ScriptDetails -> Text
$sel:scriptS3Location:ScriptDetails' :: ScriptDetails -> S3Location
$sel:executableParameters:ScriptDetails' :: ScriptDetails -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ExecutableParameters" 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
executableParameters,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ScriptS3Location" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= S3Location
scriptS3Location),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ExecutablePath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
executablePath),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TimeoutInSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
timeoutInSeconds)
          ]
      )