{-# 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.GameLift.Types.Script
-- 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.GameLift.Types.Script where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.S3Location
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Properties describing a Realtime script.
--
-- __Related actions__
--
-- CreateScript | ListScripts | DescribeScript | UpdateScript |
-- DeleteScript |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
--
-- /See:/ 'newScript' smart constructor.
data Script = Script'
  { -- | A time stamp indicating when this data object was created. Format is a
    -- number expressed in Unix time as milliseconds (for example
    -- @\"1469498468.057\"@).
    Script -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    Script -> Maybe S3Location
storageLocation :: Prelude.Maybe S3Location,
    -- | A descriptive label that is associated with a script. Script names do
    -- not need to be unique.
    Script -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the Realtime script
    Script -> Maybe Text
scriptId :: Prelude.Maybe Prelude.Text,
    -- | Version information that is associated with a build or script. Version
    -- strings do not need to be unique.
    Script -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
    -- that is assigned to a GameLift script resource and uniquely identifies
    -- it. ARNs are unique across all Regions. In a GameLift script ARN, the
    -- resource ID matches the /ScriptId/ value.
    Script -> Maybe Text
scriptArn :: Prelude.Maybe Prelude.Text,
    -- | The file size of the uploaded Realtime script, expressed in bytes. When
    -- files are uploaded from an S3 location, this value remains at \"0\".
    Script -> Maybe Natural
sizeOnDisk :: Prelude.Maybe Prelude.Natural
  }
  deriving (Script -> Script -> Bool
(Script -> Script -> Bool)
-> (Script -> Script -> Bool) -> Eq Script
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Script -> Script -> Bool
$c/= :: Script -> Script -> Bool
== :: Script -> Script -> Bool
$c== :: Script -> Script -> Bool
Prelude.Eq, ReadPrec [Script]
ReadPrec Script
Int -> ReadS Script
ReadS [Script]
(Int -> ReadS Script)
-> ReadS [Script]
-> ReadPrec Script
-> ReadPrec [Script]
-> Read Script
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Script]
$creadListPrec :: ReadPrec [Script]
readPrec :: ReadPrec Script
$creadPrec :: ReadPrec Script
readList :: ReadS [Script]
$creadList :: ReadS [Script]
readsPrec :: Int -> ReadS Script
$creadsPrec :: Int -> ReadS Script
Prelude.Read, Int -> Script -> ShowS
[Script] -> ShowS
Script -> String
(Int -> Script -> ShowS)
-> (Script -> String) -> ([Script] -> ShowS) -> Show Script
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Script] -> ShowS
$cshowList :: [Script] -> ShowS
show :: Script -> String
$cshow :: Script -> String
showsPrec :: Int -> Script -> ShowS
$cshowsPrec :: Int -> Script -> ShowS
Prelude.Show, (forall x. Script -> Rep Script x)
-> (forall x. Rep Script x -> Script) -> Generic Script
forall x. Rep Script x -> Script
forall x. Script -> Rep Script x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Script x -> Script
$cfrom :: forall x. Script -> Rep Script x
Prelude.Generic)

-- |
-- Create a value of 'Script' 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:
--
-- 'creationTime', 'script_creationTime' - A time stamp indicating when this data object was created. Format is a
-- number expressed in Unix time as milliseconds (for example
-- @\"1469498468.057\"@).
--
-- 'storageLocation', 'script_storageLocation' - Undocumented member.
--
-- 'name', 'script_name' - A descriptive label that is associated with a script. Script names do
-- not need to be unique.
--
-- 'scriptId', 'script_scriptId' - A unique identifier for the Realtime script
--
-- 'version', 'script_version' - Version information that is associated with a build or script. Version
-- strings do not need to be unique.
--
-- 'scriptArn', 'script_scriptArn' - The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- that is assigned to a GameLift script resource and uniquely identifies
-- it. ARNs are unique across all Regions. In a GameLift script ARN, the
-- resource ID matches the /ScriptId/ value.
--
-- 'sizeOnDisk', 'script_sizeOnDisk' - The file size of the uploaded Realtime script, expressed in bytes. When
-- files are uploaded from an S3 location, this value remains at \"0\".
newScript ::
  Script
newScript :: Script
newScript =
  Script' :: Maybe POSIX
-> Maybe S3Location
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Script
Script'
    { $sel:creationTime:Script' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:storageLocation:Script' :: Maybe S3Location
storageLocation = Maybe S3Location
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Script' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scriptId:Script' :: Maybe Text
scriptId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:Script' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scriptArn:Script' :: Maybe Text
scriptArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sizeOnDisk:Script' :: Maybe Natural
sizeOnDisk = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | A time stamp indicating when this data object was created. Format is a
-- number expressed in Unix time as milliseconds (for example
-- @\"1469498468.057\"@).
script_creationTime :: Lens.Lens' Script (Prelude.Maybe Prelude.UTCTime)
script_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Script -> f Script
script_creationTime = (Script -> Maybe POSIX)
-> (Script -> Maybe POSIX -> Script)
-> Lens Script Script (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Script' :: Script -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Script
s@Script' {} Maybe POSIX
a -> Script
s {$sel:creationTime:Script' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Script) ((Maybe POSIX -> f (Maybe POSIX)) -> Script -> f Script)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Script
-> f Script
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Undocumented member.
script_storageLocation :: Lens.Lens' Script (Prelude.Maybe S3Location)
script_storageLocation :: (Maybe S3Location -> f (Maybe S3Location)) -> Script -> f Script
script_storageLocation = (Script -> Maybe S3Location)
-> (Script -> Maybe S3Location -> Script)
-> Lens Script Script (Maybe S3Location) (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe S3Location
storageLocation :: Maybe S3Location
$sel:storageLocation:Script' :: Script -> Maybe S3Location
storageLocation} -> Maybe S3Location
storageLocation) (\s :: Script
s@Script' {} Maybe S3Location
a -> Script
s {$sel:storageLocation:Script' :: Maybe S3Location
storageLocation = Maybe S3Location
a} :: Script)

-- | A descriptive label that is associated with a script. Script names do
-- not need to be unique.
script_name :: Lens.Lens' Script (Prelude.Maybe Prelude.Text)
script_name :: (Maybe Text -> f (Maybe Text)) -> Script -> f Script
script_name = (Script -> Maybe Text)
-> (Script -> Maybe Text -> Script)
-> Lens Script Script (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe Text
name :: Maybe Text
$sel:name:Script' :: Script -> Maybe Text
name} -> Maybe Text
name) (\s :: Script
s@Script' {} Maybe Text
a -> Script
s {$sel:name:Script' :: Maybe Text
name = Maybe Text
a} :: Script)

-- | A unique identifier for the Realtime script
script_scriptId :: Lens.Lens' Script (Prelude.Maybe Prelude.Text)
script_scriptId :: (Maybe Text -> f (Maybe Text)) -> Script -> f Script
script_scriptId = (Script -> Maybe Text)
-> (Script -> Maybe Text -> Script)
-> Lens Script Script (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe Text
scriptId :: Maybe Text
$sel:scriptId:Script' :: Script -> Maybe Text
scriptId} -> Maybe Text
scriptId) (\s :: Script
s@Script' {} Maybe Text
a -> Script
s {$sel:scriptId:Script' :: Maybe Text
scriptId = Maybe Text
a} :: Script)

-- | Version information that is associated with a build or script. Version
-- strings do not need to be unique.
script_version :: Lens.Lens' Script (Prelude.Maybe Prelude.Text)
script_version :: (Maybe Text -> f (Maybe Text)) -> Script -> f Script
script_version = (Script -> Maybe Text)
-> (Script -> Maybe Text -> Script)
-> Lens Script Script (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe Text
version :: Maybe Text
$sel:version:Script' :: Script -> Maybe Text
version} -> Maybe Text
version) (\s :: Script
s@Script' {} Maybe Text
a -> Script
s {$sel:version:Script' :: Maybe Text
version = Maybe Text
a} :: Script)

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- that is assigned to a GameLift script resource and uniquely identifies
-- it. ARNs are unique across all Regions. In a GameLift script ARN, the
-- resource ID matches the /ScriptId/ value.
script_scriptArn :: Lens.Lens' Script (Prelude.Maybe Prelude.Text)
script_scriptArn :: (Maybe Text -> f (Maybe Text)) -> Script -> f Script
script_scriptArn = (Script -> Maybe Text)
-> (Script -> Maybe Text -> Script)
-> Lens Script Script (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe Text
scriptArn :: Maybe Text
$sel:scriptArn:Script' :: Script -> Maybe Text
scriptArn} -> Maybe Text
scriptArn) (\s :: Script
s@Script' {} Maybe Text
a -> Script
s {$sel:scriptArn:Script' :: Maybe Text
scriptArn = Maybe Text
a} :: Script)

-- | The file size of the uploaded Realtime script, expressed in bytes. When
-- files are uploaded from an S3 location, this value remains at \"0\".
script_sizeOnDisk :: Lens.Lens' Script (Prelude.Maybe Prelude.Natural)
script_sizeOnDisk :: (Maybe Natural -> f (Maybe Natural)) -> Script -> f Script
script_sizeOnDisk = (Script -> Maybe Natural)
-> (Script -> Maybe Natural -> Script)
-> Lens Script Script (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Script' {Maybe Natural
sizeOnDisk :: Maybe Natural
$sel:sizeOnDisk:Script' :: Script -> Maybe Natural
sizeOnDisk} -> Maybe Natural
sizeOnDisk) (\s :: Script
s@Script' {} Maybe Natural
a -> Script
s {$sel:sizeOnDisk:Script' :: Maybe Natural
sizeOnDisk = Maybe Natural
a} :: Script)

instance Core.FromJSON Script where
  parseJSON :: Value -> Parser Script
parseJSON =
    String -> (Object -> Parser Script) -> Value -> Parser Script
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Script"
      ( \Object
x ->
          Maybe POSIX
-> Maybe S3Location
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Script
Script'
            (Maybe POSIX
 -> Maybe S3Location
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Natural
 -> Script)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe S3Location
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Natural
      -> Script)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationTime")
            Parser
  (Maybe S3Location
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Natural
   -> Script)
-> Parser (Maybe S3Location)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Natural
      -> Script)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StorageLocation")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Natural
   -> Script)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Natural -> Script)
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
"Name")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Natural -> Script)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Natural -> Script)
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
"ScriptId")
            Parser (Maybe Text -> Maybe Text -> Maybe Natural -> Script)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Natural -> Script)
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
"Version")
            Parser (Maybe Text -> Maybe Natural -> Script)
-> Parser (Maybe Text) -> Parser (Maybe Natural -> Script)
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
"ScriptArn")
            Parser (Maybe Natural -> Script)
-> Parser (Maybe Natural) -> Parser Script
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SizeOnDisk")
      )

instance Prelude.Hashable Script

instance Prelude.NFData Script