GS2-Script SDK API Reference

Specification of models and API references for GS2-Script SDK for various programming languages

Models

Namespace

Namespace

A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.

Therefore, you must create a namespace before you can start using each service.

Details
Type Condition Required Default Value Limits Description
namespaceId string
*
~ 1024 chars Namespace GRN
* Set automatically by the server
name string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
transactionSetting TransactionSetting Transaction Setting
Settings for distributed transactions used when scripts return transaction actions.
logSetting LogSetting Log Output Setting
Specifies the GS2-Log namespace for outputting API request and response logs. Used for tracking script invocations and their results.
createdAt long
*
Current time Creation Timestamp
Unix time, milliseconds
* Set automatically by the server
updatedAt long
*
Current time Last Updated Timestamp
Unix time, milliseconds
* Set automatically by the server
revision long 0 0 ~ 9223372036854775805 Revision

TransactionSetting

Transaction Setting

Transaction Setting controls execution methods, consistency, asynchronous processing, and conflict avoidance mechanisms of transactions. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous processing of Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.

Details
Type Condition Required Default Value Limits Description
enableAutoRun bool false Whether to automatically execute issued transactions on the server side
enableAtomicCommit bool {enableAutoRun} == true false Whether to commit the execution of transactions atomically
* Enabled only if enableAutoRun is true
transactionUseDistributor bool {enableAtomicCommit} == true false Whether to execute transactions asynchronously
* Enabled only if enableAtomicCommit is true
commitScriptResultInUseDistributor bool {transactionUseDistributor} == true false Whether to execute the commit processing of the script result asynchronously
* Enabled only if transactionUseDistributor is true
acquireActionUseJobQueue bool {enableAtomicCommit} == true false Whether to use GS2-JobQueue to execute the acquire action
* Enabled only if enableAtomicCommit is true
distributorNamespaceId string “grn:gs2:{region}:{ownerId}:distributor:default” ~ 1024 chars GS2-Distributor Namespace GRN used to execute transactions
queueNamespaceId string “grn:gs2:{region}:{ownerId}:queue:default” ~ 1024 chars GS2-JobQueue Namespace GRN used to execute transactions

LogSetting

Log Output Setting

Log Output Setting defines how log data is exported. This type holds the GS2-Log namespace identifier (Namespace ID), which is used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.

Details
Type Condition Required Default Value Limits Description
loggingNamespaceId string
~ 1024 chars GS2-Log namespace GRN to output logs
Must be specified in GRN format starting with “grn:gs2:”.

GitHubCheckoutSetting

Setup to check out script from GitHub

Details
Type Condition Required Default Value Limits Description
apiKeyId string
~ 1024 chars GitHub API Key GRN
repositoryName string
~ 1024 chars Repository Name
sourcePath string
~ 1024 chars Script file path
referenceType string (enum)
enum {
  “commit_hash”,
  “branch”,
  “tag”
}
Source of code
DefinitionDescription
“commit_hash”Commit hash
“branch”Branch
“tag”Tag
commitHash string {referenceType} == “commit_hash”
✓*
~ 1024 chars Commit hash
* Required if referenceType is “commit_hash”
branchName string {referenceType} == “branch”
✓*
~ 1024 chars Branch Name
* Required if referenceType is “branch”
tagName string {referenceType} == “tag”
✓*
~ 1024 chars Tag Name
* Required if referenceType is “tag”

Script

Script

GS2 provides scripts to extend functionality when the standard functions are not sufficient. Scripts can be written in the Lua language.

Scripts can also retrieve data from GS2 services, allowing for flexible processing. Please refer to the documentation for details.

Details
Type Condition Required Default Value Limits Description
scriptId string
*
~ 1024 chars Script GRN
* Set automatically by the server
name string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
script string
~ 5242880 chars Lua Script
The Lua script source code to execute. Scripts can access GS2 service data and return results that modify the behavior of the calling service.
disableStringNumberToNumber bool false Disable String-Number Conversion
When enabled, strings consisting only of digits (e.g., “12345”) are kept as strings instead of being automatically converted to numbers. Useful when handling IDs or codes that should remain as string type even if they look numeric.
createdAt long
*
Current time Creation Timestamp
Unix time, milliseconds
* Set automatically by the server
updatedAt long
*
Current time Last Updated Timestamp
Unix time, milliseconds
* Set automatically by the server
revision long 0 0 ~ 9223372036854775805 Revision

RandomStatus

Random Number Status

Manages the random number state available within a script execution context. Contains a seed value and a list of used random numbers per category. This state is passed to the Lua script as a table and can be read/modified by the script.

Details
Type Condition Required Default Value Limits Description
seed long
0 ~ 4294967294 Random Seed
The seed value for random number generation. Used to produce deterministic random sequences within the script execution.
used List<RandomUsed> 0 ~ 1000 items Used Random Numbers
List of random numbers already consumed, categorized by purpose. Each category can have its own usage counter.

RandomUsed

Used Random Numbers

Tracks the number of random values consumed for a specific category. Each category represents a distinct purpose for random number usage within script execution, allowing independent tracking of random consumption.

Details
Type Condition Required Default Value Limits Description
category long
0 ~ 4294967294 Category
A numeric identifier for the random number usage category. Each category tracks random consumption independently, allowing scripts to use separate random sequences for different purposes.
used long
0 ~ 4294967294 Used Count
The number of random values that have been consumed in this category. Incremented each time a random number is drawn from this category’s sequence.

AcquireAction

Acquire Action

Details
Type Condition Required Default Value Limits Description
action string (enum)
enum {
"Gs2AdReward:AcquirePointByUserId",
"Gs2Dictionary:AddEntriesByUserId",
"Gs2Enchant:ReDrawBalanceParameterStatusByUserId",
"Gs2Enchant:SetBalanceParameterStatusByUserId",
"Gs2Enchant:ReDrawRarityParameterStatusByUserId",
"Gs2Enchant:AddRarityParameterStatusByUserId",
"Gs2Enchant:SetRarityParameterStatusByUserId",
"Gs2Enhance:DirectEnhanceByUserId",
"Gs2Enhance:UnleashByUserId",
"Gs2Enhance:CreateProgressByUserId",
"Gs2Exchange:ExchangeByUserId",
"Gs2Exchange:IncrementalExchangeByUserId",
"Gs2Exchange:CreateAwaitByUserId",
"Gs2Exchange:AcquireForceByUserId",
"Gs2Exchange:SkipByUserId",
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SetExperienceByUserId",
"Gs2Experience:AddRankCapByUserId",
"Gs2Experience:SetRankCapByUserId",
"Gs2Experience:MultiplyAcquireActionsByUserId",
"Gs2Formation:AddMoldCapacityByUserId",
"Gs2Formation:SetMoldCapacityByUserId",
"Gs2Formation:AcquireActionsToFormProperties",
"Gs2Formation:SetFormByUserId",
"Gs2Formation:AcquireActionsToPropertyFormProperties",
"Gs2Friend:UpdateProfileByUserId",
"Gs2Grade:AddGradeByUserId",
"Gs2Grade:ApplyRankCapByUserId",
"Gs2Grade:MultiplyAcquireActionsByUserId",
"Gs2Guild:IncreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Guild:SetMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:IncreaseMaximumIdleMinutesByUserId",
"Gs2Idle:SetMaximumIdleMinutesByUserId",
"Gs2Idle:ReceiveByUserId",
"Gs2Inbox:SendMessageByUserId",
"Gs2Inventory:AddCapacityByUserId",
"Gs2Inventory:SetCapacityByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:AcquireItemSetWithGradeByUserId",
"Gs2Inventory:AddReferenceOfByUserId",
"Gs2Inventory:DeleteReferenceOfByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:SetSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:SetBigItemByUserId",
"Gs2JobQueue:PushByUserId",
"Gs2Limit:CountDownByUserId",
"Gs2Limit:DeleteCounterByUserId",
"Gs2LoginReward:DeleteReceiveStatusByUserId",
"Gs2LoginReward:UnmarkReceivedByUserId",
"Gs2Lottery:DrawByUserId",
"Gs2Lottery:ResetBoxByUserId",
"Gs2Mission:RevertReceiveByUserId",
"Gs2Mission:IncreaseCounterByUserId",
"Gs2Mission:SetCounterByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:RevertRecordReceipt",
"Gs2Money2:DepositByUserId",
"Gs2Quest:CreateProgressByUserId",
"Gs2Schedule:TriggerByUserId",
"Gs2Schedule:ExtendTriggerByUserId",
"Gs2Script:InvokeScript",
"Gs2SerialKey:RevertUseByUserId",
"Gs2SerialKey:IssueOnce",
"Gs2Showcase:DecrementPurchaseCountByUserId",
"Gs2Showcase:ForceReDrawByUserId",
"Gs2SkillTree:MarkReleaseByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
"Gs2Stamina:RaiseMaxValueByUserId",
"Gs2Stamina:SetMaxValueByUserId",
"Gs2Stamina:SetRecoverIntervalByUserId",
"Gs2Stamina:SetRecoverValueByUserId",
"Gs2StateMachine:StartStateMachineByUserId",
}
Type of Acquire Action
request string
~ 524288 chars JSON string of the request used when executing the action

ConsumeAction

Consume Action

Details
Type Condition Required Default Value Limits Description
action string (enum)
enum {
"Gs2AdReward:ConsumePointByUserId",
"Gs2Dictionary:DeleteEntriesByUserId",
"Gs2Enhance:DeleteProgressByUserId",
"Gs2Exchange:DeleteAwaitByUserId",
"Gs2Experience:SubExperienceByUserId",
"Gs2Experience:SubRankCapByUserId",
"Gs2Formation:SubMoldCapacityByUserId",
"Gs2Grade:SubGradeByUserId",
"Gs2Guild:DecreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:DecreaseMaximumIdleMinutesByUserId",
"Gs2Inbox:OpenMessageByUserId",
"Gs2Inbox:DeleteMessageByUserId",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2JobQueue:DeleteJobByUserId",
"Gs2Limit:CountUpByUserId",
"Gs2LoginReward:MarkReceivedByUserId",
"Gs2Mission:ReceiveByUserId",
"Gs2Mission:BatchReceiveByUserId",
"Gs2Mission:DecreaseCounterByUserId",
"Gs2Mission:ResetCounterByUserId",
"Gs2Money:WithdrawByUserId",
"Gs2Money:RecordReceipt",
"Gs2Money2:WithdrawByUserId",
"Gs2Money2:VerifyReceiptByUserId",
"Gs2Quest:DeleteProgressByUserId",
"Gs2Ranking2:CreateGlobalRankingReceivedRewardByUserId",
"Gs2Ranking2:CreateClusterRankingReceivedRewardByUserId",
"Gs2Schedule:DeleteTriggerByUserId",
"Gs2SerialKey:UseByUserId",
"Gs2Showcase:IncrementPurchaseCountByUserId",
"Gs2SkillTree:MarkRestrainByUserId",
"Gs2Stamina:DecreaseMaxValueByUserId",
"Gs2Stamina:ConsumeStaminaByUserId",
}
Type of Consume Action
request string
~ 524288 chars JSON string of the request used when executing the action

VerifyAction

Verify Action

Details
Type Condition Required Default Value Limits Description
action string (enum)
enum {
"Gs2Dictionary:VerifyEntryByUserId",
"Gs2Distributor:IfExpressionByUserId",
"Gs2Distributor:AndExpressionByUserId",
"Gs2Distributor:OrExpressionByUserId",
"Gs2Enchant:VerifyRarityParameterStatusByUserId",
"Gs2Experience:VerifyRankByUserId",
"Gs2Experience:VerifyRankCapByUserId",
"Gs2Grade:VerifyGradeByUserId",
"Gs2Grade:VerifyGradeUpMaterialByUserId",
"Gs2Guild:VerifyCurrentMaximumMemberCountByGuildName",
"Gs2Guild:VerifyIncludeMemberByUserId",
"Gs2Inventory:VerifyInventoryCurrentMaxCapacityByUserId",
"Gs2Inventory:VerifyItemSetByUserId",
"Gs2Inventory:VerifyReferenceOfByUserId",
"Gs2Inventory:VerifySimpleItemByUserId",
"Gs2Inventory:VerifyBigItemByUserId",
"Gs2Limit:VerifyCounterByUserId",
"Gs2Matchmaking:VerifyIncludeParticipantByUserId",
"Gs2Mission:VerifyCompleteByUserId",
"Gs2Mission:VerifyCounterValueByUserId",
"Gs2Ranking2:VerifyGlobalRankingScoreByUserId",
"Gs2Ranking2:VerifyClusterRankingScoreByUserId",
"Gs2Ranking2:VerifySubscribeRankingScoreByUserId",
"Gs2Schedule:VerifyTriggerByUserId",
"Gs2Schedule:VerifyEventByUserId",
"Gs2SerialKey:VerifyCodeByUserId",
"Gs2Stamina:VerifyStaminaValueByUserId",
"Gs2Stamina:VerifyStaminaMaxValueByUserId",
"Gs2Stamina:VerifyStaminaRecoverIntervalMinutesByUserId",
"Gs2Stamina:VerifyStaminaRecoverValueByUserId",
"Gs2Stamina:VerifyStaminaOverflowValueByUserId",
}
Type of Verify Action
request string
~ 524288 chars JSON string of the request used when executing the action

Transaction

Transaction

Represents a set of actions to be executed as a distributed transaction returned from a script. Contains verify actions (precondition checks), consume actions (resource consumption), and acquire actions (resource granting), which are executed as a transaction.

Details
Type Condition Required Default Value Limits Description
transactionId string ~ 128 chars Transaction ID
Optional unique identifier for this transaction. Used to track and deduplicate the execution of the acquire actions.
verifyActions List<VerifyAction> 0 ~ 100 items List of Verify Actions
List of verify actions that serve as preconditions for the transaction. All verify actions must pass before consume and acquire actions are executed.
consumeActions List<ConsumeAction> [] 0 ~ 100 items List of Acquire Actions
List of consume actions that consume resources as part of the transaction. Executed after all verify actions pass.
acquireActions List<AcquireAction> [] 0 ~ 100 items List of Acquire Actions
List of acquire actions (transactions) that grant resources as part of the transaction. Executed after all consume actions complete successfully.

VerifyActionResult

Verify Action execution result

Details
Type Condition Required Default Value Limits Description
action string (enum)
enum {
"Gs2Dictionary:VerifyEntryByUserId",
"Gs2Distributor:IfExpressionByUserId",
"Gs2Distributor:AndExpressionByUserId",
"Gs2Distributor:OrExpressionByUserId",
"Gs2Enchant:VerifyRarityParameterStatusByUserId",
"Gs2Experience:VerifyRankByUserId",
"Gs2Experience:VerifyRankCapByUserId",
"Gs2Grade:VerifyGradeByUserId",
"Gs2Grade:VerifyGradeUpMaterialByUserId",
"Gs2Guild:VerifyCurrentMaximumMemberCountByGuildName",
"Gs2Guild:VerifyIncludeMemberByUserId",
"Gs2Inventory:VerifyInventoryCurrentMaxCapacityByUserId",
"Gs2Inventory:VerifyItemSetByUserId",
"Gs2Inventory:VerifyReferenceOfByUserId",
"Gs2Inventory:VerifySimpleItemByUserId",
"Gs2Inventory:VerifyBigItemByUserId",
"Gs2Limit:VerifyCounterByUserId",
"Gs2Matchmaking:VerifyIncludeParticipantByUserId",
"Gs2Mission:VerifyCompleteByUserId",
"Gs2Mission:VerifyCounterValueByUserId",
"Gs2Ranking2:VerifyGlobalRankingScoreByUserId",
"Gs2Ranking2:VerifyClusterRankingScoreByUserId",
"Gs2Ranking2:VerifySubscribeRankingScoreByUserId",
"Gs2Schedule:VerifyTriggerByUserId",
"Gs2Schedule:VerifyEventByUserId",
"Gs2SerialKey:VerifyCodeByUserId",
"Gs2Stamina:VerifyStaminaValueByUserId",
"Gs2Stamina:VerifyStaminaMaxValueByUserId",
"Gs2Stamina:VerifyStaminaRecoverIntervalMinutesByUserId",
"Gs2Stamina:VerifyStaminaRecoverValueByUserId",
"Gs2Stamina:VerifyStaminaOverflowValueByUserId",
}
Type of Verify Action
verifyRequest string
~ 524288 chars JSON string of the request used when executing the action
statusCode int 0 ~ 999 Status code
verifyResult string ~ 1048576 chars Result content

ConsumeActionResult

Consume Action execution result

Details
Type Condition Required Default Value Limits Description
action string (enum)
enum {
"Gs2AdReward:ConsumePointByUserId",
"Gs2Dictionary:DeleteEntriesByUserId",
"Gs2Enhance:DeleteProgressByUserId",
"Gs2Exchange:DeleteAwaitByUserId",
"Gs2Experience:SubExperienceByUserId",
"Gs2Experience:SubRankCapByUserId",
"Gs2Formation:SubMoldCapacityByUserId",
"Gs2Grade:SubGradeByUserId",
"Gs2Guild:DecreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:DecreaseMaximumIdleMinutesByUserId",
"Gs2Inbox:OpenMessageByUserId",
"Gs2Inbox:DeleteMessageByUserId",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2JobQueue:DeleteJobByUserId",
"Gs2Limit:CountUpByUserId",
"Gs2LoginReward:MarkReceivedByUserId",
"Gs2Mission:ReceiveByUserId",
"Gs2Mission:BatchReceiveByUserId",
"Gs2Mission:DecreaseCounterByUserId",
"Gs2Mission:ResetCounterByUserId",
"Gs2Money:WithdrawByUserId",
"Gs2Money:RecordReceipt",
"Gs2Money2:WithdrawByUserId",
"Gs2Money2:VerifyReceiptByUserId",
"Gs2Quest:DeleteProgressByUserId",
"Gs2Ranking2:CreateGlobalRankingReceivedRewardByUserId",
"Gs2Ranking2:CreateClusterRankingReceivedRewardByUserId",
"Gs2Schedule:DeleteTriggerByUserId",
"Gs2SerialKey:UseByUserId",
"Gs2Showcase:IncrementPurchaseCountByUserId",
"Gs2SkillTree:MarkRestrainByUserId",
"Gs2Stamina:DecreaseMaxValueByUserId",
"Gs2Stamina:ConsumeStaminaByUserId",
}
Type of Consume Action
consumeRequest string
~ 524288 chars JSON string of the request used when executing the action
statusCode int 0 ~ 999 Status code
consumeResult string ~ 1048576 chars Result content

AcquireActionResult

Acquire Action execution result

Details
Type Condition Required Default Value Limits Description
action string (enum)
enum {
"Gs2AdReward:AcquirePointByUserId",
"Gs2Dictionary:AddEntriesByUserId",
"Gs2Enchant:ReDrawBalanceParameterStatusByUserId",
"Gs2Enchant:SetBalanceParameterStatusByUserId",
"Gs2Enchant:ReDrawRarityParameterStatusByUserId",
"Gs2Enchant:AddRarityParameterStatusByUserId",
"Gs2Enchant:SetRarityParameterStatusByUserId",
"Gs2Enhance:DirectEnhanceByUserId",
"Gs2Enhance:UnleashByUserId",
"Gs2Enhance:CreateProgressByUserId",
"Gs2Exchange:ExchangeByUserId",
"Gs2Exchange:IncrementalExchangeByUserId",
"Gs2Exchange:CreateAwaitByUserId",
"Gs2Exchange:AcquireForceByUserId",
"Gs2Exchange:SkipByUserId",
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SetExperienceByUserId",
"Gs2Experience:AddRankCapByUserId",
"Gs2Experience:SetRankCapByUserId",
"Gs2Experience:MultiplyAcquireActionsByUserId",
"Gs2Formation:AddMoldCapacityByUserId",
"Gs2Formation:SetMoldCapacityByUserId",
"Gs2Formation:AcquireActionsToFormProperties",
"Gs2Formation:SetFormByUserId",
"Gs2Formation:AcquireActionsToPropertyFormProperties",
"Gs2Friend:UpdateProfileByUserId",
"Gs2Grade:AddGradeByUserId",
"Gs2Grade:ApplyRankCapByUserId",
"Gs2Grade:MultiplyAcquireActionsByUserId",
"Gs2Guild:IncreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Guild:SetMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:IncreaseMaximumIdleMinutesByUserId",
"Gs2Idle:SetMaximumIdleMinutesByUserId",
"Gs2Idle:ReceiveByUserId",
"Gs2Inbox:SendMessageByUserId",
"Gs2Inventory:AddCapacityByUserId",
"Gs2Inventory:SetCapacityByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:AcquireItemSetWithGradeByUserId",
"Gs2Inventory:AddReferenceOfByUserId",
"Gs2Inventory:DeleteReferenceOfByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:SetSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:SetBigItemByUserId",
"Gs2JobQueue:PushByUserId",
"Gs2Limit:CountDownByUserId",
"Gs2Limit:DeleteCounterByUserId",
"Gs2LoginReward:DeleteReceiveStatusByUserId",
"Gs2LoginReward:UnmarkReceivedByUserId",
"Gs2Lottery:DrawByUserId",
"Gs2Lottery:ResetBoxByUserId",
"Gs2Mission:RevertReceiveByUserId",
"Gs2Mission:IncreaseCounterByUserId",
"Gs2Mission:SetCounterByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:RevertRecordReceipt",
"Gs2Money2:DepositByUserId",
"Gs2Quest:CreateProgressByUserId",
"Gs2Schedule:TriggerByUserId",
"Gs2Schedule:ExtendTriggerByUserId",
"Gs2Script:InvokeScript",
"Gs2SerialKey:RevertUseByUserId",
"Gs2SerialKey:IssueOnce",
"Gs2Showcase:DecrementPurchaseCountByUserId",
"Gs2Showcase:ForceReDrawByUserId",
"Gs2SkillTree:MarkReleaseByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
"Gs2Stamina:RaiseMaxValueByUserId",
"Gs2Stamina:SetMaxValueByUserId",
"Gs2Stamina:SetRecoverIntervalByUserId",
"Gs2Stamina:SetRecoverValueByUserId",
"Gs2StateMachine:StartStateMachineByUserId",
}
Type of Acquire Action
acquireRequest string
~ 524288 chars JSON string of the request used when executing the action
statusCode int 0 ~ 999 Status code
acquireResult string ~ 1048576 chars Result content

TransactionResult

Transaction execution result

Result of a transaction executed using the server-side automatic execution feature

Details
Type Condition Required Default Value Limits Description
transactionId string
36 ~ 36 chars Transaction ID
verifyResults List<VerifyActionResult> 0 ~ 10 items List of verify action execution results
consumeResults List<ConsumeActionResult> [] 0 ~ 10 items List of Consume Action execution results
acquireResults List<AcquireActionResult> [] 0 ~ 100 items List of Acquire Action execution results
hasError bool false Whether an error occurred during transaction execution

Methods

describeNamespaces

Get a list of Namespaces

Retrieves a list of namespaces that have been created on a per-service basis within the project. You can use the optional page token to start acquiring data from a specific location in the list. You can also limit the number of namespaces to be acquired.

Details

Request

Type Condition Required Default Value Limits Description
namePrefix string ~ 64 chars Filter by Namespace name prefix
pageToken string ~ 1024 chars Token specifying the position from which to start acquiring data
limit int 30 1 ~ 1000 Number of data items to retrieve

Result

Type Description
items List<Namespace> List of Namespaces
nextPageToken string Page token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &script.DescribeNamespacesRequest {
        NamePrefix: nil,
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\DescribeNamespacesRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->describeNamespaces(
        (new DescribeNamespacesRequest())
            ->withNamePrefix(null)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.DescribeNamespacesRequest;
import io.gs2.script.result.DescribeNamespacesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    DescribeNamespacesResult result = client.describeNamespaces(
        new DescribeNamespacesRequest()
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    List<Namespace> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Script.Request.DescribeNamespacesRequest()
        .WithNamePrefix(null)
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.describeNamespaces(
        new Gs2Script.DescribeNamespacesRequest()
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.describe_namespaces(
        script.DescribeNamespacesRequest()
            .with_name_prefix(None)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.describe_namespaces({
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;
client = gs2('script')

api_result_handler = client.describe_namespaces_async({
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

createNamespace

Create a new Namespace

You must specify detailed information including the name, description, and various settings of the namespace.

Details

Request

Type Condition Required Default Value Limits Description
name string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
transactionSetting TransactionSetting Transaction Setting
Settings for distributed transactions used when scripts return transaction actions.
logSetting LogSetting Log Output Setting
Specifies the GS2-Log namespace for outputting API request and response logs. Used for tracking script invocations and their results.

Result

Type Description
item Namespace Namespace created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &script.CreateNamespaceRequest {
        Name: pointy.String("namespace-0001"),
        Description: nil,
        TransactionSetting: nil,
        LogSetting: &script.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\CreateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName("namespace-0001")
            ->withDescription(null)
            ->withTransactionSetting(null)
            ->withLogSetting((new \Gs2\Script\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.CreateNamespaceRequest;
import io.gs2.script.result.CreateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withTransactionSetting(null)
            .withLogSetting(new io.gs2.script.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Script.Request.CreateNamespaceRequest()
        .WithName("namespace-0001")
        .WithDescription(null)
        .WithTransactionSetting(null)
        .WithLogSetting(new Gs2.Gs2Script.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.createNamespace(
        new Gs2Script.CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withTransactionSetting(null)
            .withLogSetting(new Gs2Script.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.create_namespace(
        script.CreateNamespaceRequest()
            .with_name('namespace-0001')
            .with_description(None)
            .with_transaction_setting(None)
            .with_log_setting(
                script.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.create_namespace({
    name="namespace-0001",
    description=nil,
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.create_namespace_async({
    name="namespace-0001",
    description=nil,
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

getNamespaceStatus

Get Namespace status

Get the current status of the specified namespace. This includes whether the Namespace is active, pending, or in some other state.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

Type Description
status string

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &script.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
status := result.Status
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\GetNamespaceStatusRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName("namespace-0001")
    );
    $status = $result->getStatus();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.GetNamespaceStatusRequest;
import io.gs2.script.result.GetNamespaceStatusResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Script.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.getNamespaceStatus(
        new Gs2Script.GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.get_namespace_status(
        script.GetNamespaceStatusRequest()
            .with_namespace_name('namespace-0001')
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.get_namespace_status({
    namespaceName="namespace-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
status = result.status;
client = gs2('script')

api_result_handler = client.get_namespace_status_async({
    namespaceName="namespace-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
status = result.status;

getNamespace

Get a Namespace

Get detailed information about the specified namespace. This includes the name, description, and other settings of the namespace.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

Type Description
item Namespace Namespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &script.GetNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\GetNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.GetNamespaceRequest;
import io.gs2.script.result.GetNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Script.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.getNamespace(
        new Gs2Script.GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.get_namespace(
        script.GetNamespaceRequest()
            .with_namespace_name('namespace-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.get_namespace({
    namespaceName="namespace-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.get_namespace_async({
    namespaceName="namespace-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

updateNamespace

Update Namespace

Update the settings of the specified Namespace. You can change the description and other settings of the Namespace.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
transactionSetting TransactionSetting Transaction Setting
Settings for distributed transactions used when scripts return transaction actions.
logSetting LogSetting Log Output Setting
Specifies the GS2-Log namespace for outputting API request and response logs. Used for tracking script invocations and their results.

Result

Type Description
item Namespace Namespace updated

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &script.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Description: pointy.String("description1"),
        TransactionSetting: nil,
        LogSetting: &script.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\UpdateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName("namespace-0001")
            ->withDescription("description1")
            ->withTransactionSetting(null)
            ->withLogSetting((new \Gs2\Script\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.UpdateNamespaceRequest;
import io.gs2.script.result.UpdateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withTransactionSetting(null)
            .withLogSetting(new io.gs2.script.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Script.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace-0001")
        .WithDescription("description1")
        .WithTransactionSetting(null)
        .WithLogSetting(new Gs2.Gs2Script.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.updateNamespace(
        new Gs2Script.UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withTransactionSetting(null)
            .withLogSetting(new Gs2Script.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.update_namespace(
        script.UpdateNamespaceRequest()
            .with_namespace_name('namespace-0001')
            .with_description('description1')
            .with_transaction_setting(None)
            .with_log_setting(
                script.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.update_namespace({
    namespaceName="namespace-0001",
    description="description1",
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.update_namespace_async({
    namespaceName="namespace-0001",
    description="description1",
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

deleteNamespace

Delete Namespace

Delete the specified Namespace. This operation is irreversible and all data associated with the deleted Namespace will be lost.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

Type Description
item Namespace The deleted Namespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &script.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\DeleteNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.DeleteNamespaceRequest;
import io.gs2.script.result.DeleteNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Script.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.deleteNamespace(
        new Gs2Script.DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.delete_namespace(
        script.DeleteNamespaceRequest()
            .with_namespace_name('namespace-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.delete_namespace({
    namespaceName="namespace-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.delete_namespace_async({
    namespaceName="namespace-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

getServiceVersion

Get the microservice version

Details

Request

Request parameters: None

Result

Type Description
item string Version

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.GetServiceVersion(
    &script.GetServiceVersionRequest {
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\GetServiceVersionRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->getServiceVersion(
        (new GetServiceVersionRequest())
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.GetServiceVersionRequest;
import io.gs2.script.result.GetServiceVersionResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    GetServiceVersionResult result = client.getServiceVersion(
        new GetServiceVersionRequest()
    );
    String item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
    new Gs2.Gs2Script.Request.GetServiceVersionRequest(),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.getServiceVersion(
        new Gs2Script.GetServiceVersionRequest()
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.get_service_version(
        script.GetServiceVersionRequest()
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.get_service_version({
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.get_service_version_async({
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

describeScripts

Get a list of Scripts

Retrieves a paginated list of Lua scripts registered in the namespace. Can filter by script name prefix.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
namePrefix string ~ 64 chars Filter by script name prefix
pageToken string ~ 1024 chars Token specifying the position from which to start acquiring data
limit int 30 1 ~ 1000 Number of data items to retrieve

Result

Type Description
items List<Script> List of Scripts
nextPageToken string Page token to retrieve the rest of the listing

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.DescribeScripts(
    &script.DescribeScriptsRequest {
        NamespaceName: pointy.String("namespace-0001"),
        NamePrefix: nil,
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\DescribeScriptsRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->describeScripts(
        (new DescribeScriptsRequest())
            ->withNamespaceName("namespace-0001")
            ->withNamePrefix(null)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.DescribeScriptsRequest;
import io.gs2.script.result.DescribeScriptsResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    DescribeScriptsResult result = client.describeScripts(
        new DescribeScriptsRequest()
            .withNamespaceName("namespace-0001")
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    List<Script> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.DescribeScriptsResult> asyncResult = null;
yield return client.DescribeScripts(
    new Gs2.Gs2Script.Request.DescribeScriptsRequest()
        .WithNamespaceName("namespace-0001")
        .WithNamePrefix(null)
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.describeScripts(
        new Gs2Script.DescribeScriptsRequest()
            .withNamespaceName("namespace-0001")
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.describe_scripts(
        script.DescribeScriptsRequest()
            .with_namespace_name('namespace-0001')
            .with_name_prefix(None)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.describe_scripts({
    namespaceName="namespace-0001",
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;
client = gs2('script')

api_result_handler = client.describe_scripts_async({
    namespaceName="namespace-0001",
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

createScript

Create a new script

Creates a new Lua script with the specified code. The disableStringNumberToNumber option controls whether strings consisting only of numbers are automatically converted to numbers during script execution.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
name string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
script string
~ 5242880 chars Lua Script
disableStringNumberToNumber bool false Do not convert strings consisting only of numbers to numbers

Result

Type Description
item Script Script created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.CreateScript(
    &script.CreateScriptRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Name: pointy.String("script-0001"),
        Description: nil,
        Script: pointy.String("result = {permit=true}"),
        DisableStringNumberToNumber: pointy.Bool(false),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\CreateScriptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->createScript(
        (new CreateScriptRequest())
            ->withNamespaceName("namespace-0001")
            ->withName("script-0001")
            ->withDescription(null)
            ->withScript("result = {permit=true}")
            ->withDisableStringNumberToNumber(false)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.CreateScriptRequest;
import io.gs2.script.result.CreateScriptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    CreateScriptResult result = client.createScript(
        new CreateScriptRequest()
            .withNamespaceName("namespace-0001")
            .withName("script-0001")
            .withDescription(null)
            .withScript("result = {permit=true}")
            .withDisableStringNumberToNumber(false)
    );
    Script item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.CreateScriptResult> asyncResult = null;
yield return client.CreateScript(
    new Gs2.Gs2Script.Request.CreateScriptRequest()
        .WithNamespaceName("namespace-0001")
        .WithName("script-0001")
        .WithDescription(null)
        .WithScript("result = {permit=true}")
        .WithDisableStringNumberToNumber(false),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.createScript(
        new Gs2Script.CreateScriptRequest()
            .withNamespaceName("namespace-0001")
            .withName("script-0001")
            .withDescription(null)
            .withScript("result = {permit=true}")
            .withDisableStringNumberToNumber(false)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.create_script(
        script.CreateScriptRequest()
            .with_namespace_name('namespace-0001')
            .with_name('script-0001')
            .with_description(None)
            .with_script('result = {permit=true}')
            .with_disable_string_number_to_number(False)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.create_script({
    namespaceName="namespace-0001",
    name="script-0001",
    description=nil,
    script="result = {permit=true}",
    disableStringNumberToNumber=false,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.create_script_async({
    namespaceName="namespace-0001",
    name="script-0001",
    description=nil,
    script="result = {permit=true}",
    disableStringNumberToNumber=false,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

createScriptFromGitHub

Create a new script from code in the GitHub repository

Creates a new script by checking out the source file from the specified GitHub repository.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
name string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
checkoutSetting GitHubCheckoutSetting
Setup to check out source code from GitHub
disableStringNumberToNumber bool false Do not convert strings consisting only of numbers to numbers

Result

Type Description
item Script Script created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.CreateScriptFromGitHub(
    &script.CreateScriptFromGitHubRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Name: pointy.String("script-0001"),
        Description: nil,
        CheckoutSetting: &script.GitHubCheckoutSetting{
            ApiKeyId: pointy.String("apiKeyId-0001"),
            RepositoryName: pointy.String("gs2io/script-data"),
            SourcePath: pointy.String("path/to/file.json"),
            ReferenceType: pointy.String("branch"),
            BranchName: pointy.String("develop"),
        },
        DisableStringNumberToNumber: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\CreateScriptFromGitHubRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->createScriptFromGitHub(
        (new CreateScriptFromGitHubRequest())
            ->withNamespaceName("namespace-0001")
            ->withName("script-0001")
            ->withDescription(null)
            ->withCheckoutSetting((new GitHubCheckoutSetting())
                ->withApiKeyId("apiKeyId-0001")
                ->withRepositoryName("gs2io/script-data")
                ->withSourcePath("path/to/file.json")
                ->withReferenceType("branch")
                ->withBranchName("develop")
            )
            ->withDisableStringNumberToNumber(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.CreateScriptFromGitHubRequest;
import io.gs2.script.result.CreateScriptFromGitHubResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    CreateScriptFromGitHubResult result = client.createScriptFromGitHub(
        new CreateScriptFromGitHubRequest()
            .withNamespaceName("namespace-0001")
            .withName("script-0001")
            .withDescription(null)
            .withCheckoutSetting(new GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/script-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
            .withDisableStringNumberToNumber(null)
    );
    Script item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.CreateScriptFromGitHubResult> asyncResult = null;
yield return client.CreateScriptFromGitHub(
    new Gs2.Gs2Script.Request.CreateScriptFromGitHubRequest()
        .WithNamespaceName("namespace-0001")
        .WithName("script-0001")
        .WithDescription(null)
        .WithCheckoutSetting(new Gs2.Gs2Script.Model.GitHubCheckoutSetting()
            .WithApiKeyId("apiKeyId-0001")
            .WithRepositoryName("gs2io/script-data")
            .WithSourcePath("path/to/file.json")
            .WithReferenceType("branch")
            .WithBranchName("develop")
        )
        .WithDisableStringNumberToNumber(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.createScriptFromGitHub(
        new Gs2Script.CreateScriptFromGitHubRequest()
            .withNamespaceName("namespace-0001")
            .withName("script-0001")
            .withDescription(null)
            .withCheckoutSetting(new Gs2Script.model.GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/script-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
            .withDisableStringNumberToNumber(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.create_script_from_git_hub(
        script.CreateScriptFromGitHubRequest()
            .with_namespace_name('namespace-0001')
            .with_name('script-0001')
            .with_description(None)
            .with_checkout_setting(script.GitHubCheckoutSetting()
                .with_api_key_id('apiKeyId-0001')
                .with_repository_name('gs2io/script-data')
                .with_source_path('path/to/file.json')
                .with_reference_type('branch')
                .with_branch_name('develop')
            )
            .with_disable_string_number_to_number(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.create_script_from_git_hub({
    namespaceName="namespace-0001",
    name="script-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/script-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
    disableStringNumberToNumber=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.create_script_from_git_hub_async({
    namespaceName="namespace-0001",
    name="script-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/script-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
    disableStringNumberToNumber=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

getScript

Get Script

Retrieves the specified script including its name, description, script code, and type conversion settings.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
scriptName string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

Type Description
item Script Script

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.GetScript(
    &script.GetScriptRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ScriptName: pointy.String("script-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\GetScriptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->getScript(
        (new GetScriptRequest())
            ->withNamespaceName("namespace-0001")
            ->withScriptName("script-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.GetScriptRequest;
import io.gs2.script.result.GetScriptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    GetScriptResult result = client.getScript(
        new GetScriptRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
    );
    Script item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.GetScriptResult> asyncResult = null;
yield return client.GetScript(
    new Gs2.Gs2Script.Request.GetScriptRequest()
        .WithNamespaceName("namespace-0001")
        .WithScriptName("script-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.getScript(
        new Gs2Script.GetScriptRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.get_script(
        script.GetScriptRequest()
            .with_namespace_name('namespace-0001')
            .with_script_name('script-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.get_script({
    namespaceName="namespace-0001",
    scriptName="script-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.get_script_async({
    namespaceName="namespace-0001",
    scriptName="script-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

updateScript

Update Script

Updates the specified script’s code, description, and type conversion settings. The entire script code is replaced with the new content.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
scriptName string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
script string
~ 5242880 chars Lua Script
disableStringNumberToNumber bool false Do not convert strings consisting only of numbers to numbers

Result

Type Description
item Script Script updated

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.UpdateScript(
    &script.UpdateScriptRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ScriptName: pointy.String("script-0001"),
        Description: pointy.String("description1"),
        Script: pointy.String("result = \"hogehoge\""),
        DisableStringNumberToNumber: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\UpdateScriptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->updateScript(
        (new UpdateScriptRequest())
            ->withNamespaceName("namespace-0001")
            ->withScriptName("script-0001")
            ->withDescription("description1")
            ->withScript("result = \"hogehoge\"")
            ->withDisableStringNumberToNumber(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.UpdateScriptRequest;
import io.gs2.script.result.UpdateScriptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    UpdateScriptResult result = client.updateScript(
        new UpdateScriptRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
            .withDescription("description1")
            .withScript("result = \"hogehoge\"")
            .withDisableStringNumberToNumber(null)
    );
    Script item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.UpdateScriptResult> asyncResult = null;
yield return client.UpdateScript(
    new Gs2.Gs2Script.Request.UpdateScriptRequest()
        .WithNamespaceName("namespace-0001")
        .WithScriptName("script-0001")
        .WithDescription("description1")
        .WithScript("result = \"hogehoge\"")
        .WithDisableStringNumberToNumber(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.updateScript(
        new Gs2Script.UpdateScriptRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
            .withDescription("description1")
            .withScript("result = \"hogehoge\"")
            .withDisableStringNumberToNumber(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.update_script(
        script.UpdateScriptRequest()
            .with_namespace_name('namespace-0001')
            .with_script_name('script-0001')
            .with_description('description1')
            .with_script('result = "hogehoge"')
            .with_disable_string_number_to_number(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.update_script({
    namespaceName="namespace-0001",
    scriptName="script-0001",
    description="description1",
    script="result = \"hogehoge\"",
    disableStringNumberToNumber=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.update_script_async({
    namespaceName="namespace-0001",
    scriptName="script-0001",
    description="description1",
    script="result = \"hogehoge\"",
    disableStringNumberToNumber=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

updateScriptFromGitHub

Update scripts using GitHub as a data source

Updates an existing script by fetching the latest source code from the specified GitHub repository.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
scriptName string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
checkoutSetting GitHubCheckoutSetting
Setup to check out source code from GitHub
disableStringNumberToNumber bool false Do not convert strings consisting only of numbers to numbers

Result

Type Description
item Script Script updated

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.UpdateScriptFromGitHub(
    &script.UpdateScriptFromGitHubRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ScriptName: pointy.String("script-0001"),
        Description: nil,
        CheckoutSetting: &script.GitHubCheckoutSetting{
            ApiKeyId: pointy.String("apiKeyId-0001"),
            RepositoryName: pointy.String("gs2io/script-data"),
            SourcePath: pointy.String("path/to/file.json"),
            ReferenceType: pointy.String("branch"),
            BranchName: pointy.String("develop"),
        },
        DisableStringNumberToNumber: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\UpdateScriptFromGitHubRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->updateScriptFromGitHub(
        (new UpdateScriptFromGitHubRequest())
            ->withNamespaceName("namespace-0001")
            ->withScriptName("script-0001")
            ->withDescription(null)
            ->withCheckoutSetting((new GitHubCheckoutSetting())
                ->withApiKeyId("apiKeyId-0001")
                ->withRepositoryName("gs2io/script-data")
                ->withSourcePath("path/to/file.json")
                ->withReferenceType("branch")
                ->withBranchName("develop")
            )
            ->withDisableStringNumberToNumber(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.UpdateScriptFromGitHubRequest;
import io.gs2.script.result.UpdateScriptFromGitHubResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    UpdateScriptFromGitHubResult result = client.updateScriptFromGitHub(
        new UpdateScriptFromGitHubRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
            .withDescription(null)
            .withCheckoutSetting(new GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/script-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
            .withDisableStringNumberToNumber(null)
    );
    Script item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.UpdateScriptFromGitHubResult> asyncResult = null;
yield return client.UpdateScriptFromGitHub(
    new Gs2.Gs2Script.Request.UpdateScriptFromGitHubRequest()
        .WithNamespaceName("namespace-0001")
        .WithScriptName("script-0001")
        .WithDescription(null)
        .WithCheckoutSetting(new Gs2.Gs2Script.Model.GitHubCheckoutSetting()
            .WithApiKeyId("apiKeyId-0001")
            .WithRepositoryName("gs2io/script-data")
            .WithSourcePath("path/to/file.json")
            .WithReferenceType("branch")
            .WithBranchName("develop")
        )
        .WithDisableStringNumberToNumber(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.updateScriptFromGitHub(
        new Gs2Script.UpdateScriptFromGitHubRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
            .withDescription(null)
            .withCheckoutSetting(new Gs2Script.model.GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/script-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
            .withDisableStringNumberToNumber(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.update_script_from_git_hub(
        script.UpdateScriptFromGitHubRequest()
            .with_namespace_name('namespace-0001')
            .with_script_name('script-0001')
            .with_description(None)
            .with_checkout_setting(script.GitHubCheckoutSetting()
                .with_api_key_id('apiKeyId-0001')
                .with_repository_name('gs2io/script-data')
                .with_source_path('path/to/file.json')
                .with_reference_type('branch')
                .with_branch_name('develop')
            )
            .with_disable_string_number_to_number(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.update_script_from_git_hub({
    namespaceName="namespace-0001",
    scriptName="script-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/script-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
    disableStringNumberToNumber=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.update_script_from_git_hub_async({
    namespaceName="namespace-0001",
    scriptName="script-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/script-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
    disableStringNumberToNumber=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

deleteScript

Delete script

Deletes the specified script from the namespace.

Details

Request

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
scriptName string
~ 128 chars Script name
Script-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).

Result

Type Description
item Script Script deleted

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.DeleteScript(
    &script.DeleteScriptRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ScriptName: pointy.String("script-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\DeleteScriptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->deleteScript(
        (new DeleteScriptRequest())
            ->withNamespaceName("namespace-0001")
            ->withScriptName("script-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.DeleteScriptRequest;
import io.gs2.script.result.DeleteScriptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    DeleteScriptResult result = client.deleteScript(
        new DeleteScriptRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
    );
    Script item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.DeleteScriptResult> asyncResult = null;
yield return client.DeleteScript(
    new Gs2.Gs2Script.Request.DeleteScriptRequest()
        .WithNamespaceName("namespace-0001")
        .WithScriptName("script-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.deleteScript(
        new Gs2Script.DeleteScriptRequest()
            .withNamespaceName("namespace-0001")
            .withScriptName("script-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.delete_script(
        script.DeleteScriptRequest()
            .with_namespace_name('namespace-0001')
            .with_script_name('script-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.delete_script({
    namespaceName="namespace-0001",
    scriptName="script-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;
client = gs2('script')

api_result_handler = client.delete_script_async({
    namespaceName="namespace-0001",
    scriptName="script-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

invokeScript

Execute the script

Synchronously executes the specified Lua script with the provided JSON arguments. Returns the execution result including status code, return value, transaction information, random number state, execution time, and standard output. Supports transaction handling for atomic operations across GS2 services.

Details

Request

Type Condition Required Default Value Limits Description
scriptId string
~ 1024 chars Script GRN
userId string ~ 128 chars User ID
args string “{}” ~ 5242880 chars Arguments (JSON Format)
randomStatus RandomStatus Random number status
timeOffsetToken string ~ 1024 chars Time offset token

Result

Type Description
code int Status Code
result string Result Value
transaction Transaction Transaction
randomStatus RandomStatus Random number status
atomicCommit bool? Whether to commit the transaction atomically
transactionResult TransactionResult Transaction execution result
executeTime int Script execution time (milliseconds)
charged int Time (seconds) for which costs were calculated
output List<string> List of contents of standard output

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.InvokeScript(
    &script.InvokeScriptRequest {
        ScriptId: pointy.String("script-0001"),
        UserId: nil,
        Args: pointy.String("{}"),
        RandomStatus: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
code := result.Code
result := result.Result
transaction := result.Transaction
randomStatus := result.RandomStatus
atomicCommit := result.AtomicCommit
transactionResult := result.TransactionResult
executeTime := result.ExecuteTime
charged := result.Charged
output := result.Output
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\InvokeScriptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->invokeScript(
        (new InvokeScriptRequest())
            ->withScriptId("script-0001")
            ->withUserId(null)
            ->withArgs("{}")
            ->withRandomStatus(null)
            ->withTimeOffsetToken(null)
    );
    $code = $result->getCode();
    $result = $result->getResult();
    $transaction = $result->getTransaction();
    $randomStatus = $result->getRandomStatus();
    $atomicCommit = $result->getAtomicCommit();
    $transactionResult = $result->getTransactionResult();
    $executeTime = $result->getExecuteTime();
    $charged = $result->getCharged();
    $output = $result->getOutput();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.InvokeScriptRequest;
import io.gs2.script.result.InvokeScriptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    InvokeScriptResult result = client.invokeScript(
        new InvokeScriptRequest()
            .withScriptId("script-0001")
            .withUserId(null)
            .withArgs("{}")
            .withRandomStatus(null)
            .withTimeOffsetToken(null)
    );
    int code = result.getCode();
    String result = result.getResult();
    Transaction transaction = result.getTransaction();
    RandomStatus randomStatus = result.getRandomStatus();
    boolean atomicCommit = result.getAtomicCommit();
    TransactionResult transactionResult = result.getTransactionResult();
    int executeTime = result.getExecuteTime();
    int charged = result.getCharged();
    List<String> output = result.getOutput();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.InvokeScriptResult> asyncResult = null;
yield return client.InvokeScript(
    new Gs2.Gs2Script.Request.InvokeScriptRequest()
        .WithScriptId("script-0001")
        .WithUserId(null)
        .WithArgs("{}")
        .WithRandomStatus(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var code = result.Code;
var result = result.Result;
var transaction = result.Transaction;
var randomStatus = result.RandomStatus;
var atomicCommit = result.AtomicCommit;
var transactionResult = result.TransactionResult;
var executeTime = result.ExecuteTime;
var charged = result.Charged;
var output = result.Output;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.invokeScript(
        new Gs2Script.InvokeScriptRequest()
            .withScriptId("script-0001")
            .withUserId(null)
            .withArgs("{}")
            .withRandomStatus(null)
            .withTimeOffsetToken(null)
    );
    const code = result.getCode();
    const result = result.getResult();
    const transaction = result.getTransaction();
    const randomStatus = result.getRandomStatus();
    const atomicCommit = result.getAtomicCommit();
    const transactionResult = result.getTransactionResult();
    const executeTime = result.getExecuteTime();
    const charged = result.getCharged();
    const output = result.getOutput();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.invoke_script(
        script.InvokeScriptRequest()
            .with_script_id('script-0001')
            .with_user_id(None)
            .with_args('{}')
            .with_random_status(None)
            .with_time_offset_token(None)
    )
    code = result.code
    result = result.result
    transaction = result.transaction
    random_status = result.random_status
    atomic_commit = result.atomic_commit
    transaction_result = result.transaction_result
    execute_time = result.execute_time
    charged = result.charged
    output = result.output
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.invoke_script({
    scriptId="script-0001",
    userId=nil,
    args="{}",
    randomStatus=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
code = result.code;
result = result.result;
transaction = result.transaction;
randomStatus = result.randomStatus;
atomicCommit = result.atomicCommit;
transactionResult = result.transactionResult;
executeTime = result.executeTime;
charged = result.charged;
output = result.output;
client = gs2('script')

api_result_handler = client.invoke_script_async({
    scriptId="script-0001",
    userId=nil,
    args="{}",
    randomStatus=nil,
    timeOffsetToken=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
code = result.code;
result = result.result;
transaction = result.transaction;
randomStatus = result.randomStatus;
atomicCommit = result.atomicCommit;
transactionResult = result.transactionResult;
executeTime = result.executeTime;
charged = result.charged;
output = result.output;

debugInvoke

Execute Script

Executes the provided Lua script code directly for debugging purposes without requiring prior script registration, allowing rapid testing and development of scripts.

Details

Request

Type Condition Required Default Value Limits Description
script string
~ 5242880 chars Lua Script
args string “{}” ~ 5242880 chars Arguments (JSON Format)
userId string ~ 128 chars User ID
randomStatus RandomStatus Random number status
disableStringNumberToNumber bool false Do not convert strings consisting only of numbers to numbers
timeOffsetToken string ~ 1024 chars Time offset token

Result

Type Description
code int Status Code
result string Result Value
transaction Transaction Transaction
randomStatus RandomStatus Random number status
atomicCommit bool? Whether to commit the transaction atomically
transactionResult TransactionResult Transaction execution result
executeTime int Script execution time (milliseconds)
charged int Time (seconds) for which costs were calculated
output List<string> List of contents of standard output

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/script"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := script.Gs2ScriptRestClient{
    Session: &session,
}
result, err := client.DebugInvoke(
    &script.DebugInvokeRequest {
        Script: pointy.String("result = \"hello\""),
        Args: pointy.String("{}"),
        UserId: nil,
        RandomStatus: nil,
        DisableStringNumberToNumber: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
code := result.Code
result := result.Result
transaction := result.Transaction
randomStatus := result.RandomStatus
atomicCommit := result.AtomicCommit
transactionResult := result.TransactionResult
executeTime := result.ExecuteTime
charged := result.Charged
output := result.Output
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Script\Gs2ScriptRestClient;
use Gs2\Script\Request\DebugInvokeRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2ScriptRestClient(
    $session
);

try {
    $result = $client->debugInvoke(
        (new DebugInvokeRequest())
            ->withScript("result = \"hello\"")
            ->withArgs("{}")
            ->withUserId(null)
            ->withRandomStatus(null)
            ->withDisableStringNumberToNumber(null)
            ->withTimeOffsetToken(null)
    );
    $code = $result->getCode();
    $result = $result->getResult();
    $transaction = $result->getTransaction();
    $randomStatus = $result->getRandomStatus();
    $atomicCommit = $result->getAtomicCommit();
    $transactionResult = $result->getTransactionResult();
    $executeTime = $result->getExecuteTime();
    $charged = $result->getCharged();
    $output = $result->getOutput();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.script.rest.Gs2ScriptRestClient;
import io.gs2.script.request.DebugInvokeRequest;
import io.gs2.script.result.DebugInvokeResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2ScriptRestClient client = new Gs2ScriptRestClient(session);

try {
    DebugInvokeResult result = client.debugInvoke(
        new DebugInvokeRequest()
            .withScript("result = \"hello\"")
            .withArgs("{}")
            .withUserId(null)
            .withRandomStatus(null)
            .withDisableStringNumberToNumber(null)
            .withTimeOffsetToken(null)
    );
    int code = result.getCode();
    String result = result.getResult();
    Transaction transaction = result.getTransaction();
    RandomStatus randomStatus = result.getRandomStatus();
    boolean atomicCommit = result.getAtomicCommit();
    TransactionResult transactionResult = result.getTransactionResult();
    int executeTime = result.getExecuteTime();
    int charged = result.getCharged();
    List<String> output = result.getOutput();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2ScriptRestClient(session);

AsyncResult<Gs2.Gs2Script.Result.DebugInvokeResult> asyncResult = null;
yield return client.DebugInvoke(
    new Gs2.Gs2Script.Request.DebugInvokeRequest()
        .WithScript("result = \"hello\"")
        .WithArgs("{}")
        .WithUserId(null)
        .WithRandomStatus(null)
        .WithDisableStringNumberToNumber(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var code = result.Code;
var result = result.Result;
var transaction = result.Transaction;
var randomStatus = result.RandomStatus;
var atomicCommit = result.AtomicCommit;
var transactionResult = result.TransactionResult;
var executeTime = result.ExecuteTime;
var charged = result.Charged;
var output = result.Output;
import Gs2Core from '@/gs2/core';
import * as Gs2Script from '@/gs2/script';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Script.Gs2ScriptRestClient(session);

try {
    const result = await client.debugInvoke(
        new Gs2Script.DebugInvokeRequest()
            .withScript("result = \"hello\"")
            .withArgs("{}")
            .withUserId(null)
            .withRandomStatus(null)
            .withDisableStringNumberToNumber(null)
            .withTimeOffsetToken(null)
    );
    const code = result.getCode();
    const result = result.getResult();
    const transaction = result.getTransaction();
    const randomStatus = result.getRandomStatus();
    const atomicCommit = result.getAtomicCommit();
    const transactionResult = result.getTransactionResult();
    const executeTime = result.getExecuteTime();
    const charged = result.getCharged();
    const output = result.getOutput();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import script

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = script.Gs2ScriptRestClient(session)

try:
    result = client.debug_invoke(
        script.DebugInvokeRequest()
            .with_script('result = "hello"')
            .with_args('{}')
            .with_user_id(None)
            .with_random_status(None)
            .with_disable_string_number_to_number(None)
            .with_time_offset_token(None)
    )
    code = result.code
    result = result.result
    transaction = result.transaction
    random_status = result.random_status
    atomic_commit = result.atomic_commit
    transaction_result = result.transaction_result
    execute_time = result.execute_time
    charged = result.charged
    output = result.output
except core.Gs2Exception as e:
    exit(1)
client = gs2('script')

api_result = client.debug_invoke({
    script="result = \"hello\"",
    args="{}",
    userId=nil,
    randomStatus=nil,
    disableStringNumberToNumber=nil,
    timeOffsetToken=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
code = result.code;
result = result.result;
transaction = result.transaction;
randomStatus = result.randomStatus;
atomicCommit = result.atomicCommit;
transactionResult = result.transactionResult;
executeTime = result.executeTime;
charged = result.charged;
output = result.output;
client = gs2('script')

api_result_handler = client.debug_invoke_async({
    script="result = \"hello\"",
    args="{}",
    userId=nil,
    randomStatus=nil,
    disableStringNumberToNumber=nil,
    timeOffsetToken=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
code = result.code;
result = result.result;
transaction = result.transaction;
randomStatus = result.randomStatus;
atomicCommit = result.atomicCommit;
transactionResult = result.transactionResult;
executeTime = result.executeTime;
charged = result.charged;
output = result.output;