{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.Script where

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

-- | Properties describing a Realtime script.
--
-- __Related actions__
--
-- <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 Data.POSIX,
    -- | 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,
    -- | 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,
    -- | A unique identifier for the Realtime script
    Script -> Maybe Text
scriptId :: 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,
    -- | The location of the Amazon S3 bucket where a zipped file containing your
    -- Realtime scripts is stored. The storage location must specify the Amazon
    -- S3 bucket name, the zip file name (the \"key\"), and a role ARN that
    -- allows Amazon GameLift to access the Amazon S3 storage location. The S3
    -- bucket must be in the same Region where you want to create a new script.
    -- By default, Amazon GameLift uploads the latest version of the zip file;
    -- if you have S3 object versioning turned on, you can use the
    -- @ObjectVersion@ parameter to specify an earlier version.
    Script -> Maybe S3Location
storageLocation :: Prelude.Maybe S3Location,
    -- | Version information associated with a build or script. Version strings
    -- do not need to be unique.
    Script -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (Script -> Script -> Bool
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]
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
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. 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\"@).
--
-- 'name', 'script_name' - A descriptive label that is associated with a script. Script names 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.
--
-- 'scriptId', 'script_scriptId' - A unique identifier for the Realtime script
--
-- '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\".
--
-- 'storageLocation', 'script_storageLocation' - The location of the Amazon S3 bucket where a zipped file containing your
-- Realtime scripts is stored. The storage location must specify the Amazon
-- S3 bucket name, the zip file name (the \"key\"), and a role ARN that
-- allows Amazon GameLift to access the Amazon S3 storage location. The S3
-- bucket must be in the same Region where you want to create a new script.
-- By default, Amazon GameLift uploads the latest version of the zip file;
-- if you have S3 object versioning turned on, you can use the
-- @ObjectVersion@ parameter to specify an earlier version.
--
-- 'version', 'script_version' - Version information associated with a build or script. Version strings
-- do not need to be unique.
newScript ::
  Script
newScript :: Script
newScript =
  Script'
    { $sel:creationTime:Script' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Script' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:scriptArn:Script' :: Maybe Text
scriptArn = forall a. Maybe a
Prelude.Nothing,
      $sel:scriptId:Script' :: Maybe Text
scriptId = forall a. Maybe a
Prelude.Nothing,
      $sel:sizeOnDisk:Script' :: Maybe Natural
sizeOnDisk = forall a. Maybe a
Prelude.Nothing,
      $sel:storageLocation:Script' :: Maybe S3Location
storageLocation = forall a. Maybe a
Prelude.Nothing,
      $sel:version:Script' :: Maybe Text
version = 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 :: Lens' Script (Maybe UTCTime)
script_creationTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | 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 :: Lens' Script (Maybe Text)
script_name = 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)

-- | 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 :: Lens' Script (Maybe Text)
script_scriptArn = 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)

-- | A unique identifier for the Realtime script
script_scriptId :: Lens.Lens' Script (Prelude.Maybe Prelude.Text)
script_scriptId :: Lens' Script (Maybe Text)
script_scriptId = 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)

-- | 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 :: Lens' Script (Maybe Natural)
script_sizeOnDisk = 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)

-- | The location of the Amazon S3 bucket where a zipped file containing your
-- Realtime scripts is stored. The storage location must specify the Amazon
-- S3 bucket name, the zip file name (the \"key\"), and a role ARN that
-- allows Amazon GameLift to access the Amazon S3 storage location. The S3
-- bucket must be in the same Region where you want to create a new script.
-- By default, Amazon GameLift uploads the latest version of the zip file;
-- if you have S3 object versioning turned on, you can use the
-- @ObjectVersion@ parameter to specify an earlier version.
script_storageLocation :: Lens.Lens' Script (Prelude.Maybe S3Location)
script_storageLocation :: Lens' Script (Maybe S3Location)
script_storageLocation = 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)

-- | Version information 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 :: Lens' Script (Maybe Text)
script_version = 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)

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

instance Prelude.Hashable Script where
  hashWithSalt :: Int -> Script -> Int
hashWithSalt Int
_salt Script' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe S3Location
version :: Maybe Text
storageLocation :: Maybe S3Location
sizeOnDisk :: Maybe Natural
scriptId :: Maybe Text
scriptArn :: Maybe Text
name :: Maybe Text
creationTime :: Maybe POSIX
$sel:version:Script' :: Script -> Maybe Text
$sel:storageLocation:Script' :: Script -> Maybe S3Location
$sel:sizeOnDisk:Script' :: Script -> Maybe Natural
$sel:scriptId:Script' :: Script -> Maybe Text
$sel:scriptArn:Script' :: Script -> Maybe Text
$sel:name:Script' :: Script -> Maybe Text
$sel:creationTime:Script' :: Script -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
scriptArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
scriptId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sizeOnDisk
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3Location
storageLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version

instance Prelude.NFData Script where
  rnf :: Script -> ()
rnf Script' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe S3Location
version :: Maybe Text
storageLocation :: Maybe S3Location
sizeOnDisk :: Maybe Natural
scriptId :: Maybe Text
scriptArn :: Maybe Text
name :: Maybe Text
creationTime :: Maybe POSIX
$sel:version:Script' :: Script -> Maybe Text
$sel:storageLocation:Script' :: Script -> Maybe S3Location
$sel:sizeOnDisk:Script' :: Script -> Maybe Natural
$sel:scriptId:Script' :: Script -> Maybe Text
$sel:scriptArn:Script' :: Script -> Maybe Text
$sel:name:Script' :: Script -> Maybe Text
$sel:creationTime:Script' :: Script -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
scriptArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
scriptId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
sizeOnDisk
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3Location
storageLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version