API Reference of GS2-StateMachine SDK

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

Model

Namespace

Namespace

A namespace is a mechanism that allows multiple uses of the same service for different purposes within a single project. 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.

TypeConditionRequiredDefaultValue LimitsDescription
namespaceIdstring
~ 1024 charsNamespace GRN
namestring
~ 128 charsNamespace name
descriptionstring~ 1024 charsDescription
supportSpeculativeExecutionString Enum
enum {
  “enable”,
  “disable”
}
“disable”~ 128 charsWhether to support speculative execution
Enumerator String DefinitionDescription
“enable”Enable
“disable”Disable
transactionSettingTransactionSetting{supportSpeculativeExecution} == “enable”Transaction settings
* Enabled if supportSpeculativeExecution is “enable”
startScriptScriptSettingScript to execute when starting the state machine
passScriptScriptSettingScript to execute when the state machine is successfully completed
errorScriptScriptSettingScript to execute when the state machine fails
lowestStateMachineVersionlongLowest version of the state machine
logSettingLogSettingLog output settings
createdAtlong
NowDatetime of creation
Unix time, milliseconds
Automatically configured on the server
updatedAtlong
NowDatetime of last update
Unix time, milliseconds
Automatically configured on the server
revisionlong00 ~ 9223372036854775805Revision

Status

Status of state machine

TypeConditionRequiredDefaultValue LimitsDescription
statusIdstring
~ 1024 charsStatus of State Machine GRN
userIdstring
~ 128 charsUser Id
namestring
UUID~ 36 charsStatus name
Maintains a unique name for each status of state machine.
The name is automatically generated in UUID (Universally Unique Identifier) format and used to identify each status of state machine.
stateMachineVersionlong
0 ~ 32503680000000Version
enableSpeculativeExecutionString Enum
enum {
  “enable”,
  “disable”
}
“disable”~ 128 charsWhether to enable speculative execution
Enumerator String DefinitionDescription
“enable”Enable
“disable”Disable
stateMachineDefinitionstring{enableSpeculativeExecution} == “enable”~ 16777216 charsState machine definition
* Enabled if enableSpeculativeExecution is “enable”
randomStatusRandomStatus{enableSpeculativeExecution} == “enable”Random status
* Enabled if enableSpeculativeExecution is “enable”
stacksList<StackEntry>0 ~ 1024 itemsStack
variablesList<Variable>0 ~ 1000 itemsState variables for each state machine
statusString Enum
enum {
  “Running”,
  “Wait”,
  “Pass”,
  “Error”
}
“Running”~ 128 charsStatus
Enumerator String DefinitionDescription
“Running”Running
“Wait”Wait
“Pass”Pass
“Error”Error
lastErrorstring~ 1024 charsLast error
transitionCountint
00 ~ 2147483645Number of transitions
createdAtlong
NowDatetime of creation
Unix time, milliseconds
Automatically configured on the server
updatedAtlong
NowDatetime of last update
Unix time, milliseconds
Automatically configured on the server

StackEntry

Stack

TypeConditionRequiredDefaultValue LimitsDescription
stateMachineNamestring
~ 128 charsName of the state machine
taskNamestring
~ 128 charsTask name

Variable

State variables per state machine

TypeConditionRequiredDefaultValue LimitsDescription
stateMachineNamestring
~ 128 charsName of the state machine
valuestring
~ 1048576 charsValue

TransactionSetting

Transaction settings

Transaction settings control how transactions are executed, their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, Distributor, batch application of script results, and asynchronous acquisition actions via JobQueue enables robust transaction management tailored to game logic.

TypeConditionRequiredDefaultValue LimitsDescription
enableAutoRunbool
falseWhether to automatically execute issued transactions on the server side
enableAtomicCommitbool{enableAutoRun} == true
✓*
falseWhether to commit the execution of transactions atomically
* Required if enableAutoRun is true
transactionUseDistributorbool{enableAtomicCommit} == true
✓*
falseWhether to execute transactions asynchronously
* Required if enableAtomicCommit is true
commitScriptResultInUseDistributorbool{transactionUseDistributor} == true
✓*
falseWhether to execute the commit processing of the script result asynchronously
* Required if transactionUseDistributor is true
acquireActionUseJobQueuebool{enableAtomicCommit} == true
✓*
falseWhether to use GS2-JobQueue to execute the acquire action
* Required if enableAtomicCommit is true
distributorNamespaceIdstring
“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024 charsGS2-Distributor namespace used for transaction execution
queueNamespaceIdstring
“grn:gs2:{region}:{ownerId}:queue:default”~ 1024 charsNamespace in GS2-JobQueue used to run the transaction

Event

Event

TypeConditionRequiredDefaultValue LimitsDescription
eventTypeString Enum
enum {
  “change_state”,
  “emit”
}
~ 128 charsEvent type
Enumerator String DefinitionDescription
“change_state”Change state
“emit”Send a message
changeStateEventChangeStateEvent{eventType} == “change_state”
✓*
Change state
* Required if eventType is “change_state”
emitEventEmitEvent{eventType} == “emit”
✓*
Send a message
* Required if eventType is “emit”

ChangeStateEvent

Change state event

TypeConditionRequiredDefaultValue LimitsDescription
taskNamestring
~ 128 charsTask name
hashstring
~ 64 charsHash
timestamplong
Timestamp

EmitEvent

Send a message event

TypeConditionRequiredDefaultValue LimitsDescription
eventstring
~ 128 charsEvent name
parametersstring
~ 1024 charsParameters
timestamplong
Timestamp

RandomStatus

Random number status

TypeConditionRequiredDefaultValue LimitsDescription
seedlong
0 ~ 4294967294Random seed
usedList<RandomUsed>0 ~ 1000 itemsList of used random number

RandomUsed

Used random number

TypeConditionRequiredDefaultValue LimitsDescription
categorylong
0 ~ 4294967294Category
usedlong
0 ~ 4294967294Used random number

VerifyActionResult

Verify action execution result

TypeConditionRequiredDefaultValue LimitsDescription
actionString 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",
}
~ 128 charsTypes of actions to be performed in the verify task
verifyRequeststring
~ 524288 charsJSON string of the request used when executing the action
statusCodeint0 ~ 999Status code
verifyResultstring~ 1048576 charsResult payload

ConsumeActionResult

Consume action execution result

TypeConditionRequiredDefaultValue LimitsDescription
actionString 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",
}
~ 128 charsTypes of actions to be performed in the consume action
consumeRequeststring
~ 524288 charsJSON string of the request used when executing the action
statusCodeint0 ~ 999Status code
consumeResultstring~ 1048576 charsResult payload

AcquireActionResult

Acquire action execution result

TypeConditionRequiredDefaultValue LimitsDescription
actionString 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",
}
~ 128 charsTypes of actions to be performed in the acquire action
acquireRequeststring
~ 524288 charsJSON string of the request used when executing the action
statusCodeint0 ~ 999Status code
acquireResultstring~ 1048576 charsResult payload

TransactionResult

Transaction execution results

Transaction execution results executed using server-side transaction auto-execution functionality

TypeConditionRequiredDefaultValue LimitsDescription
transactionIdstring
36 ~ 36 charsTransaction ID
verifyResultsList<VerifyActionResult>0 ~ 10 itemsList of verify action execution results
consumeResultsList<ConsumeActionResult>0 ~ 10 itemsList of consume action execution results
acquireResultsList<AcquireActionResult>0 ~ 100 itemsList of acquire action execution results
hasErrorbool
falseWhether an error occurred during transaction execution

LogSetting

Log Export Settings

Manages log data export settings. This type holds the GS2-Log namespace identifier (Namespace ID) 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, and debugging.

TypeConditionRequiredDefaultValue LimitsDescription
loggingNamespaceIdstring
~ 1024 charsGS2-Log namespace GRN to output logs

ScriptSetting

Script settings

In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.

There are two main ways to execute a script: synchronous execution and asynchronous execution. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script execution result to stop the execution of the API or to tamper with the result of the API.

In contrast, asynchronous execution does not block processing until the script has finished executing. Since the script result cannot be used to stop the API execution or modify the API response, asynchronous execution does not affect the API’s response flow. For this reason, asynchronous execution is generally recommended.

There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.

TypeConditionRequiredDefaultValue LimitsDescription
triggerScriptIdstring~ 1024 charsScript GRN to be executed during processing
Must be specified in GRN format starting with “grn:gs2:”.
doneTriggerTargetTypeString Enum
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”~ 128 charsNotification of Completion
Enumerator String DefinitionDescription
“none”None
“gs2_script”GS2-Script
“aws”Amazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsScript GRN to be executed upon completion
Must be specified in GRN format starting with “grn:gs2:”.

* Enabled if doneTriggerTargetType is “gs2_script”
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-JobQueue namespace GRN to execute asynchronous execution scripts
Used when you want to know the completion of the done script.

* Enabled if doneTriggerTargetType is “gs2_script”

StateMachineMaster

State machine definition

manages state machines written in GSL.

TypeConditionRequiredDefaultValue LimitsDescription
stateMachineIdstring
~ 1024 charsState Machine Master GRN
mainStateMachineNamestring
~ 128 charsMain state machine name
payloadstring
~ 5242880 charsState machine definition
versionlong
0 ~ 32503680000000Version
createdAtlong
NowDatetime of creation
Unix time, milliseconds
Automatically configured on the server
updatedAtlong
NowDatetime of last update
Unix time, milliseconds
Automatically configured on the server
revisionlong00 ~ 9223372036854775805Revision

Methods

describeNamespaces

Get list of namespaces

Request

TypeConditionRequiredDefaultValue LimitsDescription
namePrefixstring~ 64 charsFilter by namespace name prefix
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint
301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Namespace>List of Namespace
nextPageTokenstringPage 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/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &state_machine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DescribeNamespacesRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DescribeNamespacesRequest;
import io.gs2.stateMachine.result.DescribeNamespacesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2StateMachineRestClient client = new Gs2StateMachineRestClient(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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.describeNamespaces(
        new Gs2StateMachine.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 state_machine

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

try:
    result = client.describe_namespaces(
        state_machine.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('state_machine')

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['message'])
end

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

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['message'])
end

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

createNamespace

Create a new namespace

Request

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsNamespace name
descriptionstring~ 1024 charsDescription
supportSpeculativeExecutionString Enum
enum {
  “enable”,
  “disable”
}
“disable”~ 128 charsWhether to support speculative execution
Enumerator String DefinitionDescription
“enable”Enable
“disable”Disable
transactionSettingTransactionSetting{supportSpeculativeExecution} == “enable”Transaction settings
* Enabled if supportSpeculativeExecution is “enable”
startScriptScriptSettingScript to execute when starting the state machine
passScriptScriptSettingScript to execute when the state machine is successfully completed
errorScriptScriptSettingScript to execute when the state machine fails
lowestStateMachineVersionlongLowest version of the state machine
logSettingLogSettingLog output settings

Result

TypeDescription
itemNamespaceNamespace created

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &state_machine.CreateNamespaceRequest {
        Name: pointy.String("namespace-0001"),
        Description: nil,
        SupportSpeculativeExecution: nil,
        TransactionSetting: nil,
        StartScript: nil,
        PassScript: nil,
        ErrorScript: nil,
        LowestStateMachineVersion: nil,
        LogSetting: &stateMachine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\CreateNamespaceRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName("namespace-0001")
            ->withDescription(null)
            ->withSupportSpeculativeExecution(null)
            ->withTransactionSetting(null)
            ->withStartScript(null)
            ->withPassScript(null)
            ->withErrorScript(null)
            ->withLowestStateMachineVersion(null)
            ->withLogSetting((new \Gs2\StateMachine\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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.CreateNamespaceRequest;
import io.gs2.stateMachine.result.CreateNamespaceResult;

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

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withSupportSpeculativeExecution(null)
            .withTransactionSetting(null)
            .withStartScript(null)
            .withPassScript(null)
            .withErrorScript(null)
            .withLowestStateMachineVersion(null)
            .withLogSetting(new io.gs2.stateMachine.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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2StateMachine.Request.CreateNamespaceRequest()
        .WithName("namespace-0001")
        .WithDescription(null)
        .WithSupportSpeculativeExecution(null)
        .WithTransactionSetting(null)
        .WithStartScript(null)
        .WithPassScript(null)
        .WithErrorScript(null)
        .WithLowestStateMachineVersion(null)
        .WithLogSetting(new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.createNamespace(
        new Gs2StateMachine.CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withSupportSpeculativeExecution(null)
            .withTransactionSetting(null)
            .withStartScript(null)
            .withPassScript(null)
            .withErrorScript(null)
            .withLowestStateMachineVersion(null)
            .withLogSetting(new Gs2StateMachine.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 state_machine

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

try:
    result = client.create_namespace(
        state_machine.CreateNamespaceRequest()
            .with_name('namespace-0001')
            .with_description(None)
            .with_support_speculative_execution(None)
            .with_transaction_setting(None)
            .with_start_script(None)
            .with_pass_script(None)
            .with_error_script(None)
            .with_lowest_state_machine_version(None)
            .with_log_setting(
                state_machine.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('state_machine')

api_result = client.create_namespace({
    name="namespace-0001",
    description=nil,
    supportSpeculativeExecution=nil,
    transactionSetting=nil,
    startScript=nil,
    passScript=nil,
    errorScript=nil,
    lowestStateMachineVersion=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['message'])
end

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

api_result_handler = client.create_namespace_async({
    name="namespace-0001",
    description=nil,
    supportSpeculativeExecution=nil,
    transactionSetting=nil,
    startScript=nil,
    passScript=nil,
    errorScript=nil,
    lowestStateMachineVersion=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['message'])
end

result = api_result.result
item = result.item;

getNamespaceStatus

Get namespace status

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name

Result

TypeDescription
statusstring

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &state_machine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\GetNamespaceStatusRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.GetNamespaceStatusRequest;
import io.gs2.stateMachine.result.GetNamespaceStatusResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2StateMachineRestClient client = new Gs2StateMachineRestClient(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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

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

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

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

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

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

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

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['message'])
end

result = api_result.result
status = result.status;

getNamespace

Get namespace

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name

Result

TypeDescription
itemNamespaceNamespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &state_machine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\GetNamespaceRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.GetNamespaceRequest;
import io.gs2.stateMachine.result.GetNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2StateMachineRestClient client = new Gs2StateMachineRestClient(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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

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

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

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

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

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

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

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['message'])
end

result = api_result.result
item = result.item;

updateNamespace

Update namespace

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
descriptionstring~ 1024 charsDescription
supportSpeculativeExecutionString Enum
enum {
  “enable”,
  “disable”
}
“disable”~ 128 charsWhether to support speculative execution
Enumerator String DefinitionDescription
“enable”Enable
“disable”Disable
transactionSettingTransactionSetting{supportSpeculativeExecution} == “enable”Transaction settings
* Enabled if supportSpeculativeExecution is “enable”
startScriptScriptSettingScript to execute when starting the state machine
passScriptScriptSettingScript to execute when the state machine is successfully completed
errorScriptScriptSettingScript to execute when the state machine fails
lowestStateMachineVersionlongLowest version of the state machine
logSettingLogSettingLog output settings

Result

TypeDescription
itemNamespaceUpdated namespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &state_machine.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Description: pointy.String("description1"),
        SupportSpeculativeExecution: nil,
        TransactionSetting: nil,
        StartScript: nil,
        PassScript: nil,
        ErrorScript: nil,
        LowestStateMachineVersion: nil,
        LogSetting: &stateMachine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\UpdateNamespaceRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName("namespace-0001")
            ->withDescription("description1")
            ->withSupportSpeculativeExecution(null)
            ->withTransactionSetting(null)
            ->withStartScript(null)
            ->withPassScript(null)
            ->withErrorScript(null)
            ->withLowestStateMachineVersion(null)
            ->withLogSetting((new \Gs2\StateMachine\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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.UpdateNamespaceRequest;
import io.gs2.stateMachine.result.UpdateNamespaceResult;

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

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withSupportSpeculativeExecution(null)
            .withTransactionSetting(null)
            .withStartScript(null)
            .withPassScript(null)
            .withErrorScript(null)
            .withLowestStateMachineVersion(null)
            .withLogSetting(new io.gs2.stateMachine.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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2StateMachine.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace-0001")
        .WithDescription("description1")
        .WithSupportSpeculativeExecution(null)
        .WithTransactionSetting(null)
        .WithStartScript(null)
        .WithPassScript(null)
        .WithErrorScript(null)
        .WithLowestStateMachineVersion(null)
        .WithLogSetting(new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.updateNamespace(
        new Gs2StateMachine.UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withSupportSpeculativeExecution(null)
            .withTransactionSetting(null)
            .withStartScript(null)
            .withPassScript(null)
            .withErrorScript(null)
            .withLowestStateMachineVersion(null)
            .withLogSetting(new Gs2StateMachine.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 state_machine

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

try:
    result = client.update_namespace(
        state_machine.UpdateNamespaceRequest()
            .with_namespace_name('namespace-0001')
            .with_description('description1')
            .with_support_speculative_execution(None)
            .with_transaction_setting(None)
            .with_start_script(None)
            .with_pass_script(None)
            .with_error_script(None)
            .with_lowest_state_machine_version(None)
            .with_log_setting(
                state_machine.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('state_machine')

api_result = client.update_namespace({
    namespaceName="namespace-0001",
    description="description1",
    supportSpeculativeExecution=nil,
    transactionSetting=nil,
    startScript=nil,
    passScript=nil,
    errorScript=nil,
    lowestStateMachineVersion=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['message'])
end

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

api_result_handler = client.update_namespace_async({
    namespaceName="namespace-0001",
    description="description1",
    supportSpeculativeExecution=nil,
    transactionSetting=nil,
    startScript=nil,
    passScript=nil,
    errorScript=nil,
    lowestStateMachineVersion=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['message'])
end

result = api_result.result
item = result.item;

deleteNamespace

Delete namespace

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name

Result

TypeDescription
itemNamespaceDeleted namespace

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &state_machine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DeleteNamespaceRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DeleteNamespaceRequest;
import io.gs2.stateMachine.result.DeleteNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2StateMachineRestClient client = new Gs2StateMachineRestClient(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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

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

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

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

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

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

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

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['message'])
end

result = api_result.result
item = result.item;

getServiceVersion

Get version of microservice

Request

TypeConditionRequiredDefaultValue LimitsDescription

Result

TypeDescription
itemstringVersion

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.GetServiceVersion(
    &state_machine.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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\GetServiceVersionRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.GetServiceVersionRequest;
import io.gs2.stateMachine.result.GetServiceVersionResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2StateMachineRestClient client = new Gs2StateMachineRestClient(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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
    new Gs2.Gs2StateMachine.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 Gs2StateMachine from '@/gs2/stateMachine';

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

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

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

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

api_result = client.get_service_version({
})

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

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

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['message'])
end

result = api_result.result
item = result.item;

dumpUserDataByUserId

Get dump data of the data associated with the specified user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DumpUserDataByUserId(
    &state_machine.DumpUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DumpUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->dumpUserDataByUserId(
        (new DumpUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DumpUserDataByUserIdRequest;
import io.gs2.stateMachine.result.DumpUserDataByUserIdResult;

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

try {
    DumpUserDataByUserIdResult result = client.dumpUserDataByUserId(
        new DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DumpUserDataByUserIdResult> asyncResult = null;
yield return client.DumpUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.DumpUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.dumpUserDataByUserId(
        new Gs2StateMachine.DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.dump_user_data_by_user_id(
        state_machine.DumpUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.dump_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
client = gs2('state_machine')

api_result_handler = client.dump_user_data_by_user_id_async({
    userId="user-0001",
    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['message'])
end

result = api_result.result

checkDumpUserDataByUserId

Check if the dump of the data associated with the specified user ID is complete

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
urlstringURL of output data

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.CheckDumpUserDataByUserId(
    &state_machine.CheckDumpUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
url := result.Url
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\CheckDumpUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->checkDumpUserDataByUserId(
        (new CheckDumpUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $url = $result->getUrl();
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.CheckDumpUserDataByUserIdRequest;
import io.gs2.stateMachine.result.CheckDumpUserDataByUserIdResult;

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

try {
    CheckDumpUserDataByUserIdResult result = client.checkDumpUserDataByUserId(
        new CheckDumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    String url = result.getUrl();
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.CheckDumpUserDataByUserIdResult> asyncResult = null;
yield return client.CheckDumpUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.CheckDumpUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.checkDumpUserDataByUserId(
        new Gs2StateMachine.CheckDumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const url = result.getUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.check_dump_user_data_by_user_id(
        state_machine.CheckDumpUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    url = result.url
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.check_dump_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
url = result.url;
client = gs2('state_machine')

api_result_handler = client.check_dump_user_data_by_user_id_async({
    userId="user-0001",
    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['message'])
end

result = api_result.result
url = result.url;

cleanUserDataByUserId

Get clean data of the data associated with the specified user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.CleanUserDataByUserId(
    &state_machine.CleanUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\CleanUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->cleanUserDataByUserId(
        (new CleanUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.CleanUserDataByUserIdRequest;
import io.gs2.stateMachine.result.CleanUserDataByUserIdResult;

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

try {
    CleanUserDataByUserIdResult result = client.cleanUserDataByUserId(
        new CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.CleanUserDataByUserIdResult> asyncResult = null;
yield return client.CleanUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.CleanUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.cleanUserDataByUserId(
        new Gs2StateMachine.CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.clean_user_data_by_user_id(
        state_machine.CleanUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.clean_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
client = gs2('state_machine')

api_result_handler = client.clean_user_data_by_user_id_async({
    userId="user-0001",
    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['message'])
end

result = api_result.result

checkCleanUserDataByUserId

Check if the clean of the data associated with the specified user ID is complete

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.CheckCleanUserDataByUserId(
    &state_machine.CheckCleanUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\CheckCleanUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->checkCleanUserDataByUserId(
        (new CheckCleanUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.CheckCleanUserDataByUserIdRequest;
import io.gs2.stateMachine.result.CheckCleanUserDataByUserIdResult;

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

try {
    CheckCleanUserDataByUserIdResult result = client.checkCleanUserDataByUserId(
        new CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.CheckCleanUserDataByUserIdResult> asyncResult = null;
yield return client.CheckCleanUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.CheckCleanUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.checkCleanUserDataByUserId(
        new Gs2StateMachine.CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.check_clean_user_data_by_user_id(
        state_machine.CheckCleanUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.check_clean_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
client = gs2('state_machine')

api_result_handler = client.check_clean_user_data_by_user_id_async({
    userId="user-0001",
    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['message'])
end

result = api_result.result

prepareImportUserDataByUserId

Start importing data associated with the specified user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
uploadTokenstringToken used to reflect results after upload
uploadUrlstringURL used to upload user data

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.PrepareImportUserDataByUserId(
    &state_machine.PrepareImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\PrepareImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->prepareImportUserDataByUserId(
        (new PrepareImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.PrepareImportUserDataByUserIdRequest;
import io.gs2.stateMachine.result.PrepareImportUserDataByUserIdResult;

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

try {
    PrepareImportUserDataByUserIdResult result = client.prepareImportUserDataByUserId(
        new PrepareImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.PrepareImportUserDataByUserIdResult> asyncResult = null;
yield return client.PrepareImportUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.PrepareImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.prepareImportUserDataByUserId(
        new Gs2StateMachine.PrepareImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.prepare_import_user_data_by_user_id(
        state_machine.PrepareImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.prepare_import_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;
client = gs2('state_machine')

api_result_handler = client.prepare_import_user_data_by_user_id_async({
    userId="user-0001",
    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['message'])
end

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

importUserDataByUserId

Start importing data associated with the specified user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
uploadTokenstring
~ 1024 charsToken received in preparation for upload
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.ImportUserDataByUserId(
    &state_machine.ImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        UploadToken: pointy.String("upload-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\ImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->importUserDataByUserId(
        (new ImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withUploadToken("upload-0001")
            ->withTimeOffsetToken(null)
    );
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.ImportUserDataByUserIdRequest;
import io.gs2.stateMachine.result.ImportUserDataByUserIdResult;

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

try {
    ImportUserDataByUserIdResult result = client.importUserDataByUserId(
        new ImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.ImportUserDataByUserIdResult> asyncResult = null;
yield return client.ImportUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.ImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithUploadToken("upload-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.importUserDataByUserId(
        new Gs2StateMachine.ImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.import_user_data_by_user_id(
        state_machine.ImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_upload_token('upload-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.import_user_data_by_user_id({
    userId="user-0001",
    uploadToken="upload-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
client = gs2('state_machine')

api_result_handler = client.import_user_data_by_user_id_async({
    userId="user-0001",
    uploadToken="upload-0001",
    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['message'])
end

result = api_result.result

checkImportUserDataByUserId

Check if the import of the data associated with the specified user ID is complete

Request

TypeConditionRequiredDefaultValue LimitsDescription
userIdstring
~ 128 charsUser Id
uploadTokenstring
~ 1024 charsToken received in preparation for upload
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
urlstringURL of log data

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.CheckImportUserDataByUserId(
    &state_machine.CheckImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        UploadToken: pointy.String("upload-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
url := result.Url
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\CheckImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->checkImportUserDataByUserId(
        (new CheckImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withUploadToken("upload-0001")
            ->withTimeOffsetToken(null)
    );
    $url = $result->getUrl();
} 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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.CheckImportUserDataByUserIdRequest;
import io.gs2.stateMachine.result.CheckImportUserDataByUserIdResult;

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

try {
    CheckImportUserDataByUserIdResult result = client.checkImportUserDataByUserId(
        new CheckImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
    String url = result.getUrl();
} 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.CheckImportUserDataByUserIdResult> asyncResult = null;
yield return client.CheckImportUserDataByUserId(
    new Gs2.Gs2StateMachine.Request.CheckImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithUploadToken("upload-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;
import Gs2Core from '@/gs2/core';
import * as Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.checkImportUserDataByUserId(
        new Gs2StateMachine.CheckImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
    const url = result.getUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.check_import_user_data_by_user_id(
        state_machine.CheckImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_upload_token('upload-0001')
            .with_time_offset_token(None)
    )
    url = result.url
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.check_import_user_data_by_user_id({
    userId="user-0001",
    uploadToken="upload-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
url = result.url;
client = gs2('state_machine')

api_result_handler = client.check_import_user_data_by_user_id_async({
    userId="user-0001",
    uploadToken="upload-0001",
    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['message'])
end

result = api_result.result
url = result.url;

describeStatuses

Get list of state machine statuses

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
accessTokenstring
~ 128 charsAccess token
statusString Enum
enum {
  “Running”,
  “Wait”,
  “Pass”,
  “Error”
}
~ 128 charsStatus
Enumerator String DefinitionDescription
“Running”Running
“Wait”Wait
“Pass”Pass
“Error”Error
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint
301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<Status>List of Status of State Machine
nextPageTokenstringPage 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/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DescribeStatuses(
    &state_machine.DescribeStatusesRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        Status: pointy.String("Running"),
        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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DescribeStatusesRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->describeStatuses(
        (new DescribeStatusesRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withStatus("Running")
            ->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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DescribeStatusesRequest;
import io.gs2.stateMachine.result.DescribeStatusesResult;

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

try {
    DescribeStatusesResult result = client.describeStatuses(
        new DescribeStatusesRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatus("Running")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Status> 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DescribeStatusesResult> asyncResult = null;
yield return client.DescribeStatuses(
    new Gs2.Gs2StateMachine.Request.DescribeStatusesRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithStatus("Running")
        .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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.describeStatuses(
        new Gs2StateMachine.DescribeStatusesRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatus("Running")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.describe_statuses(
        state_machine.DescribeStatusesRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_status('Running')
            .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('state_machine')

api_result = client.describe_statuses({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    status="Running",
    pageToken=nil,
    limit=nil,
})

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

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

api_result_handler = client.describe_statuses_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    status="Running",
    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['message'])
end

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

describeStatusesByUserId

Get list of state machine statuses by specifying user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
statusString Enum
enum {
  “Running”,
  “Wait”,
  “Pass”,
  “Error”
}
~ 128 charsStatus
Enumerator String DefinitionDescription
“Running”Running
“Wait”Wait
“Pass”Pass
“Error”Error
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint
301 ~ 1000Number of data acquired
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemsList<Status>List of Status of State Machine
nextPageTokenstringPage 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/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DescribeStatusesByUserId(
    &state_machine.DescribeStatusesByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        Status: nil,
        PageToken: nil,
        Limit: nil,
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DescribeStatusesByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->describeStatusesByUserId(
        (new DescribeStatusesByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatus(null)
            ->withPageToken(null)
            ->withLimit(null)
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DescribeStatusesByUserIdRequest;
import io.gs2.stateMachine.result.DescribeStatusesByUserIdResult;

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

try {
    DescribeStatusesByUserIdResult result = client.describeStatusesByUserId(
        new DescribeStatusesByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatus(null)
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    List<Status> 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DescribeStatusesByUserIdResult> asyncResult = null;
yield return client.DescribeStatusesByUserId(
    new Gs2.Gs2StateMachine.Request.DescribeStatusesByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatus(null)
        .WithPageToken(null)
        .WithLimit(null)
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.describeStatusesByUserId(
        new Gs2StateMachine.DescribeStatusesByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatus(null)
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.describe_statuses_by_user_id(
        state_machine.DescribeStatusesByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status(None)
            .with_page_token(None)
            .with_limit(None)
            .with_time_offset_token(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.describe_statuses_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    status=nil,
    pageToken=nil,
    limit=nil,
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.describe_statuses_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    status=nil,
    pageToken=nil,
    limit=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['message'])
end

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

getStatus

Get state machine

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
accessTokenstring
~ 128 charsAccess token
statusNamestring
~ 36 charsStatus name

Result

TypeDescription
itemStatusStatus of State Machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.GetStatus(
    &state_machine.GetStatusRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        StatusName: pointy.String("status-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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\GetStatusRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->getStatus(
        (new GetStatusRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withStatusName("status-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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.GetStatusRequest;
import io.gs2.stateMachine.result.GetStatusResult;

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

try {
    GetStatusResult result = client.getStatus(
        new GetStatusRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.GetStatusResult> asyncResult = null;
yield return client.GetStatus(
    new Gs2.Gs2StateMachine.Request.GetStatusRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithStatusName("status-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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.getStatus(
        new Gs2StateMachine.GetStatusRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.get_status(
        state_machine.GetStatusRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_status_name('status-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.get_status({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-0001",
})

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

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

api_result_handler = client.get_status_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-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['message'])
end

result = api_result.result
item = result.item;

getStatusByUserId

Get state machine by specifying user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
statusNamestring
~ 36 charsStatus name
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemStatusStatus of State Machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.GetStatusByUserId(
    &state_machine.GetStatusByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        StatusName: pointy.String("status-0001"),
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\GetStatusByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->getStatusByUserId(
        (new GetStatusByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatusName("status-0001")
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.GetStatusByUserIdRequest;
import io.gs2.stateMachine.result.GetStatusByUserIdResult;

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

try {
    GetStatusByUserIdResult result = client.getStatusByUserId(
        new GetStatusByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withTimeOffsetToken(null)
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.GetStatusByUserIdResult> asyncResult = null;
yield return client.GetStatusByUserId(
    new Gs2.Gs2StateMachine.Request.GetStatusByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatusName("status-0001")
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.getStatusByUserId(
        new Gs2StateMachine.GetStatusByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.get_status_by_user_id(
        state_machine.GetStatusByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status_name('status-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.get_status_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.get_status_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    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['message'])
end

result = api_result.result
item = result.item;

startStateMachineByUserId

Start state machine by specifying user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
argsstring
“{}”~ 4096 charsArguments to be passed to the state machine
ttlint1 ~ 525600Validity period (minutes)
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemStatusStarted state machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.StartStateMachineByUserId(
    &state_machine.StartStateMachineByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        Args: nil,
        Ttl: nil,
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\StartStateMachineByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->startStateMachineByUserId(
        (new StartStateMachineByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withArgs(null)
            ->withTtl(null)
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.StartStateMachineByUserIdRequest;
import io.gs2.stateMachine.result.StartStateMachineByUserIdResult;

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

try {
    StartStateMachineByUserIdResult result = client.startStateMachineByUserId(
        new StartStateMachineByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withArgs(null)
            .withTtl(null)
            .withTimeOffsetToken(null)
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.StartStateMachineByUserIdResult> asyncResult = null;
yield return client.StartStateMachineByUserId(
    new Gs2.Gs2StateMachine.Request.StartStateMachineByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithArgs(null)
        .WithTtl(null)
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.startStateMachineByUserId(
        new Gs2StateMachine.StartStateMachineByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withArgs(null)
            .withTtl(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.start_state_machine_by_user_id(
        state_machine.StartStateMachineByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_args(None)
            .with_ttl(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.start_state_machine_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    args=nil,
    ttl=nil,
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.start_state_machine_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    args=nil,
    ttl=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['message'])
end

result = api_result.result
item = result.item;

emit

Send a message to the state machine

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
accessTokenstring
~ 128 charsAccess token
statusNamestring
~ 36 charsStatus name
eventNamestring
~ 36 charsEvent name
argsstring
“{}”~ 4096 charsArguments to be passed to the state machine

Result

TypeDescription
itemStatusStatus of State Machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.Emit(
    &state_machine.EmitRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        StatusName: pointy.String("status-0001"),
        EventName: pointy.String("event-0001"),
        Args: pointy.String("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}"),
    }
)
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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\EmitRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->emit(
        (new EmitRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withStatusName("status-0001")
            ->withEventName("event-0001")
            ->withArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
    );
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.EmitRequest;
import io.gs2.stateMachine.result.EmitResult;

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

try {
    EmitResult result = client.emit(
        new EmitRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
            .withEventName("event-0001")
            .withArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.EmitResult> asyncResult = null;
yield return client.Emit(
    new Gs2.Gs2StateMachine.Request.EmitRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithStatusName("status-0001")
        .WithEventName("event-0001")
        .WithArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}"),
    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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.emit(
        new Gs2StateMachine.EmitRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
            .withEventName("event-0001")
            .withArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.emit(
        state_machine.EmitRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_status_name('status-0001')
            .with_event_name('event-0001')
            .with_args('{"value1": "value1", "value2": 2.0, "value3": 3}')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.emit({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-0001",
    eventName="event-0001",
    args="{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}",
})

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

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

api_result_handler = client.emit_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-0001",
    eventName="event-0001",
    args="{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}",
})

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['message'])
end

result = api_result.result
item = result.item;

emitByUserId

Send a message to the state machine by specifying user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
statusNamestring
~ 36 charsStatus name
eventNamestring
~ 36 charsEvent name
argsstring
“{}”~ 4096 charsArguments to be passed to the state machine
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemStatusStatus of State Machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.EmitByUserId(
    &state_machine.EmitByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        StatusName: pointy.String("status-0001"),
        EventName: pointy.String("event-0001"),
        Args: pointy.String("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}"),
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\EmitByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->emitByUserId(
        (new EmitByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatusName("status-0001")
            ->withEventName("event-0001")
            ->withArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.EmitByUserIdRequest;
import io.gs2.stateMachine.result.EmitByUserIdResult;

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

try {
    EmitByUserIdResult result = client.emitByUserId(
        new EmitByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withEventName("event-0001")
            .withArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
            .withTimeOffsetToken(null)
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.EmitByUserIdResult> asyncResult = null;
yield return client.EmitByUserId(
    new Gs2.Gs2StateMachine.Request.EmitByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatusName("status-0001")
        .WithEventName("event-0001")
        .WithArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.emitByUserId(
        new Gs2StateMachine.EmitByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withEventName("event-0001")
            .withArgs("{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.emit_by_user_id(
        state_machine.EmitByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status_name('status-0001')
            .with_event_name('event-0001')
            .with_args('{"value1": "value1", "value2": 2.0, "value3": 3}')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.emit_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    eventName="event-0001",
    args="{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}",
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.emit_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    eventName="event-0001",
    args="{\"value1\": \"value1\", \"value2\": 2.0, \"value3\": 3}",
    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['message'])
end

result = api_result.result
item = result.item;

report

Send a message to the state machine

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
accessTokenstring
~ 128 charsAccess token
statusNamestring
~ 36 charsStatus name
eventsList<Event>0 ~ 1000 itemsList of events

Result

TypeDescription
itemStatusStatus of State Machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.Report(
    &state_machine.ReportRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        StatusName: pointy.String("status-0001"),
        Events: []stateMachine.Event{
            stateMachine.Event{
                EventType: pointy.String("emit"),
                EmitEvent: &stateMachine.EmitEvent{
                    Event: pointy.String("message"),
                    Parameters: pointy.String("{\"payload\": \"Hello World\"}"),
                    Timestamp: pointy.Int64(1000),
                },
            },
        },
    }
)
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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\ReportRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->report(
        (new ReportRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withStatusName("status-0001")
            ->withEvents([
                (new Event())
                    ->withEventType("emit")
                    ->withEmitEvent(
                    (new EmitEvent())
                        ->withEvent("message")
                        ->withParameters("{\"payload\": \"Hello World\"}")
                        ->withTimestamp(1000)
                    ),
            ])
    );
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.ReportRequest;
import io.gs2.stateMachine.result.ReportResult;

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

try {
    ReportResult result = client.report(
        new ReportRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
            .withEvents(Arrays.asList(
                new Event()
                    .withEventType("emit")
                    .withEmitEvent(
                    new EmitEvent()
                        .withEvent("message")
                        .withParameters("{\"payload\": \"Hello World\"}")
                        .withTimestamp(1000L)
                    )
            ))
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.ReportResult> asyncResult = null;
yield return client.Report(
    new Gs2.Gs2StateMachine.Request.ReportRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithStatusName("status-0001")
        .WithEvents(new Gs2.Gs2StateMachine.Model.Event[] {
            new Gs2.Gs2StateMachine.Model.Event()
                .WithEventType("emit")
                .WithEmitEvent(
                new Gs2.Gs2StateMachine.Model.EmitEvent()
                    .WithEvent("message")
                    .WithParameters("{\"payload\": \"Hello World\"}")
                    .WithTimestamp(1000L)
                ),
        }),
    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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.report(
        new Gs2StateMachine.ReportRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
            .withEvents([
                new Gs2StateMachine.model.Event()
                    .withEventType("emit")
                    .withEmitEvent(
                    new Gs2StateMachine.model.EmitEvent()
                        .withEvent("message")
                        .withParameters("{\"payload\": \"Hello World\"}")
                        .withTimestamp(1000)
                    ),
            ])
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.report(
        state_machine.ReportRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_status_name('status-0001')
            .with_events([
                state_machine.Event()
                    .with_event_type('emit')
                    .with_emit_event(
                    state_machine.EmitEvent()
                        .with_event('message')
                        .with_parameters('{"payload": "Hello World"}')
                        .with_timestamp(1000)
                    ),
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.report({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-0001",
    events={
        {
            event_type="emit",
            emit_event=
            {
                event="message",
                parameters="{\"payload\": \"Hello World\"}",
                timestamp=1000,
            },
        }
    },
})

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

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

api_result_handler = client.report_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-0001",
    events={
        {
            event_type="emit",
            emit_event=
            {
                event="message",
                parameters="{\"payload\": \"Hello World\"}",
                timestamp=1000,
            },
        }
    },
})

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['message'])
end

result = api_result.result
item = result.item;

reportByUserId

Send a message to the state machine by specifying user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
statusNamestring
~ 36 charsStatus name
eventsList<Event>0 ~ 1000 itemsList of events
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemStatusStatus of State Machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.ReportByUserId(
    &state_machine.ReportByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        StatusName: pointy.String("status-0001"),
        Events: []stateMachine.Event{
            stateMachine.Event{
                EventType: pointy.String("emit"),
                EmitEvent: &stateMachine.EmitEvent{
                    Event: pointy.String("message"),
                    Parameters: pointy.String("{\"payload\": \"Hello World\"}"),
                    Timestamp: pointy.Int64(1000),
                },
            },
        },
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\ReportByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->reportByUserId(
        (new ReportByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatusName("status-0001")
            ->withEvents([
                (new Event())
                    ->withEventType("emit")
                    ->withEmitEvent(
                    (new EmitEvent())
                        ->withEvent("message")
                        ->withParameters("{\"payload\": \"Hello World\"}")
                        ->withTimestamp(1000)
                    ),
            ])
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.ReportByUserIdRequest;
import io.gs2.stateMachine.result.ReportByUserIdResult;

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

try {
    ReportByUserIdResult result = client.reportByUserId(
        new ReportByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withEvents(Arrays.asList(
                new Event()
                    .withEventType("emit")
                    .withEmitEvent(
                    new EmitEvent()
                        .withEvent("message")
                        .withParameters("{\"payload\": \"Hello World\"}")
                        .withTimestamp(1000L)
                    )
            ))
            .withTimeOffsetToken(null)
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.ReportByUserIdResult> asyncResult = null;
yield return client.ReportByUserId(
    new Gs2.Gs2StateMachine.Request.ReportByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatusName("status-0001")
        .WithEvents(new Gs2.Gs2StateMachine.Model.Event[] {
            new Gs2.Gs2StateMachine.Model.Event()
                .WithEventType("emit")
                .WithEmitEvent(
                new Gs2.Gs2StateMachine.Model.EmitEvent()
                    .WithEvent("message")
                    .WithParameters("{\"payload\": \"Hello World\"}")
                    .WithTimestamp(1000L)
                ),
        })
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.reportByUserId(
        new Gs2StateMachine.ReportByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withEvents([
                new Gs2StateMachine.model.Event()
                    .withEventType("emit")
                    .withEmitEvent(
                    new Gs2StateMachine.model.EmitEvent()
                        .withEvent("message")
                        .withParameters("{\"payload\": \"Hello World\"}")
                        .withTimestamp(1000)
                    ),
            ])
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.report_by_user_id(
        state_machine.ReportByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status_name('status-0001')
            .with_events([
                state_machine.Event()
                    .with_event_type('emit')
                    .with_emit_event(
                    state_machine.EmitEvent()
                        .with_event('message')
                        .with_parameters('{"payload": "Hello World"}')
                        .with_timestamp(1000)
                    ),
            ])
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.report_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    events={
        {
            event_type="emit",
            emit_event=
            {
                event="message",
                parameters="{\"payload\": \"Hello World\"}",
                timestamp=1000,
            },
        }
    },
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.report_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    events={
        {
            event_type="emit",
            emit_event=
            {
                event="message",
                parameters="{\"payload\": \"Hello World\"}",
                timestamp=1000,
            },
        }
    },
    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['message'])
end

result = api_result.result
item = result.item;

deleteStatusByUserId

Delete state machine by specifying user ID

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
statusNamestring
~ 36 charsStatus name
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemStatusStopped state machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DeleteStatusByUserId(
    &state_machine.DeleteStatusByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        StatusName: pointy.String("status-0001"),
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DeleteStatusByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->deleteStatusByUserId(
        (new DeleteStatusByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatusName("status-0001")
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DeleteStatusByUserIdRequest;
import io.gs2.stateMachine.result.DeleteStatusByUserIdResult;

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

try {
    DeleteStatusByUserIdResult result = client.deleteStatusByUserId(
        new DeleteStatusByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withTimeOffsetToken(null)
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DeleteStatusByUserIdResult> asyncResult = null;
yield return client.DeleteStatusByUserId(
    new Gs2.Gs2StateMachine.Request.DeleteStatusByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatusName("status-0001")
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.deleteStatusByUserId(
        new Gs2StateMachine.DeleteStatusByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.delete_status_by_user_id(
        state_machine.DeleteStatusByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status_name('status-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.delete_status_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.delete_status_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    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['message'])
end

result = api_result.result
item = result.item;

exitStateMachine

Exit and delete state machine

Can only be used when the state of the state machine is “Pass” or “Error”.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
accessTokenstring
~ 128 charsAccess token
statusNamestring
~ 36 charsStatus name

Result

TypeDescription
itemStatusExited state machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.ExitStateMachine(
    &state_machine.ExitStateMachineRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        StatusName: pointy.String("status-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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\ExitStateMachineRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->exitStateMachine(
        (new ExitStateMachineRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withStatusName("status-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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.ExitStateMachineRequest;
import io.gs2.stateMachine.result.ExitStateMachineResult;

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

try {
    ExitStateMachineResult result = client.exitStateMachine(
        new ExitStateMachineRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.ExitStateMachineResult> asyncResult = null;
yield return client.ExitStateMachine(
    new Gs2.Gs2StateMachine.Request.ExitStateMachineRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithStatusName("status-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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.exitStateMachine(
        new Gs2StateMachine.ExitStateMachineRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatusName("status-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.exit_state_machine(
        state_machine.ExitStateMachineRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_status_name('status-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.exit_state_machine({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-0001",
})

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

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

api_result_handler = client.exit_state_machine_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    statusName="status-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['message'])
end

result = api_result.result
item = result.item;

exitStateMachineByUserId

Exit and delete state machine by specifying user ID

Can only be used when the state of the state machine is “Pass” or “Error”.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
userIdstring
~ 128 charsUser Id
statusNamestring
~ 36 charsStatus name
timeOffsetTokenstring~ 1024 charsTime offset token

Result

TypeDescription
itemStatusExited state machine

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.ExitStateMachineByUserId(
    &state_machine.ExitStateMachineByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        StatusName: pointy.String("status-0001"),
        TimeOffsetToken: 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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\ExitStateMachineByUserIdRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->exitStateMachineByUserId(
        (new ExitStateMachineByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatusName("status-0001")
            ->withTimeOffsetToken(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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.ExitStateMachineByUserIdRequest;
import io.gs2.stateMachine.result.ExitStateMachineByUserIdResult;

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

try {
    ExitStateMachineByUserIdResult result = client.exitStateMachineByUserId(
        new ExitStateMachineByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withTimeOffsetToken(null)
    );
    Status 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.ExitStateMachineByUserIdResult> asyncResult = null;
yield return client.ExitStateMachineByUserId(
    new Gs2.Gs2StateMachine.Request.ExitStateMachineByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatusName("status-0001")
        .WithTimeOffsetToken(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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.exitStateMachineByUserId(
        new Gs2StateMachine.ExitStateMachineByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatusName("status-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.exit_state_machine_by_user_id(
        state_machine.ExitStateMachineByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status_name('status-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.exit_state_machine_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    timeOffsetToken=nil,
})

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

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

api_result_handler = client.exit_state_machine_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    statusName="status-0001",
    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['message'])
end

result = api_result.result
item = result.item;

describeStateMachineMasters

Get list of State Machine Masters

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
pageTokenstring~ 1024 charsToken specifying the position from which to start acquiring data
limitint
301 ~ 1000Number of data acquired

Result

TypeDescription
itemsList<StateMachineMaster>List of State Machine Masters
nextPageTokenstringPage 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/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DescribeStateMachineMasters(
    &state_machine.DescribeStateMachineMastersRequest {
        NamespaceName: pointy.String("namespace-0001"),
        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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DescribeStateMachineMastersRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->describeStateMachineMasters(
        (new DescribeStateMachineMastersRequest())
            ->withNamespaceName("namespace-0001")
            ->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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DescribeStateMachineMastersRequest;
import io.gs2.stateMachine.result.DescribeStateMachineMastersResult;

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

try {
    DescribeStateMachineMastersResult result = client.describeStateMachineMasters(
        new DescribeStateMachineMastersRequest()
            .withNamespaceName("namespace-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<StateMachineMaster> 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DescribeStateMachineMastersResult> asyncResult = null;
yield return client.DescribeStateMachineMasters(
    new Gs2.Gs2StateMachine.Request.DescribeStateMachineMastersRequest()
        .WithNamespaceName("namespace-0001")
        .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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.describeStateMachineMasters(
        new Gs2StateMachine.DescribeStateMachineMastersRequest()
            .withNamespaceName("namespace-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.describe_state_machine_masters(
        state_machine.DescribeStateMachineMastersRequest()
            .with_namespace_name('namespace-0001')
            .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('state_machine')

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

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

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

api_result_handler = client.describe_state_machine_masters_async({
    namespaceName="namespace-0001",
    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['message'])
end

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

updateStateMachineMaster

Create a new State Machine Master

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
mainStateMachineNamestring
~ 128 charsMain state machine name
payloadstring
~ 5242880 charsState machine definition

Result

TypeDescription
itemStateMachineMasterCreated State Machine Master

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.UpdateStateMachineMaster(
    &state_machine.UpdateStateMachineMasterRequest {
        NamespaceName: pointy.String("namespace-0001"),
        MainStateMachineName: pointy.String("MainStateMachine"),
        Payload: pointy.String("\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    "),
    }
)
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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\UpdateStateMachineMasterRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->updateStateMachineMaster(
        (new UpdateStateMachineMasterRequest())
            ->withNamespaceName("namespace-0001")
            ->withMainStateMachineName("MainStateMachine")
            ->withPayload("\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    ")
    );
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.UpdateStateMachineMasterRequest;
import io.gs2.stateMachine.result.UpdateStateMachineMasterResult;

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

try {
    UpdateStateMachineMasterResult result = client.updateStateMachineMaster(
        new UpdateStateMachineMasterRequest()
            .withNamespaceName("namespace-0001")
            .withMainStateMachineName("MainStateMachine")
            .withPayload("\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    ")
    );
    StateMachineMaster 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.UpdateStateMachineMasterResult> asyncResult = null;
yield return client.UpdateStateMachineMaster(
    new Gs2.Gs2StateMachine.Request.UpdateStateMachineMasterRequest()
        .WithNamespaceName("namespace-0001")
        .WithMainStateMachineName("MainStateMachine")
        .WithPayload("\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    "),
    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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.updateStateMachineMaster(
        new Gs2StateMachine.UpdateStateMachineMasterRequest()
            .withNamespaceName("namespace-0001")
            .withMainStateMachineName("MainStateMachine")
            .withPayload("\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    ")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.update_state_machine_master(
        state_machine.UpdateStateMachineMasterRequest()
            .with_namespace_name('namespace-0001')
            .with_main_state_machine_name('MainStateMachine')
            .with_payload('\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    ')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.update_state_machine_master({
    namespaceName="namespace-0001",
    mainStateMachineName="MainStateMachine",
    payload="\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    ",
})

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

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

api_result_handler = client.update_state_machine_master_async({
    namespaceName="namespace-0001",
    mainStateMachineName="MainStateMachine",
    payload="\nStateMachine MainStateMachine {\n  EntryPoint Task1;\n\n  Task Task1(int initCounter) {\n    Event Pass();\n    Event Error(string Reason);\n\n    Script grn:gs2:ap-northeast-1:YourOwnerId:script:state-machine-0001:script:Task1\n  }\n\n  PassTask Pass;\n\n  ErrorTask Error(string reason);\n\n  Transition Task1 handling Pass -> Pass;\n  Transition Task1 handling Error -> Error;\n}\n    ",
})

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['message'])
end

result = api_result.result
item = result.item;

getStateMachineMaster

Retrieve State Machine Master

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
versionlong
0 ~ 32503680000000Version

Result

TypeDescription
itemStateMachineMasterState Machine Master

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.GetStateMachineMaster(
    &state_machine.GetStateMachineMasterRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Version: pointy.Int64(1000),
    }
)
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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\GetStateMachineMasterRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->getStateMachineMaster(
        (new GetStateMachineMasterRequest())
            ->withNamespaceName("namespace-0001")
            ->withVersion(1000)
    );
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.GetStateMachineMasterRequest;
import io.gs2.stateMachine.result.GetStateMachineMasterResult;

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

try {
    GetStateMachineMasterResult result = client.getStateMachineMaster(
        new GetStateMachineMasterRequest()
            .withNamespaceName("namespace-0001")
            .withVersion(1000L)
    );
    StateMachineMaster 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.GetStateMachineMasterResult> asyncResult = null;
yield return client.GetStateMachineMaster(
    new Gs2.Gs2StateMachine.Request.GetStateMachineMasterRequest()
        .WithNamespaceName("namespace-0001")
        .WithVersion(1000L),
    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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.getStateMachineMaster(
        new Gs2StateMachine.GetStateMachineMasterRequest()
            .withNamespaceName("namespace-0001")
            .withVersion(1000)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.get_state_machine_master(
        state_machine.GetStateMachineMasterRequest()
            .with_namespace_name('namespace-0001')
            .with_version(1000)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.get_state_machine_master({
    namespaceName="namespace-0001",
    version=1000,
})

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

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

api_result_handler = client.get_state_machine_master_async({
    namespaceName="namespace-0001",
    version=1000,
})

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['message'])
end

result = api_result.result
item = result.item;

deleteStateMachineMaster

Delete State Machine Master

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
versionlong
0 ~ 32503680000000Version

Result

TypeDescription
itemStateMachineMasterDeleted State Machine Master

Implementation Example

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/state_machine"
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 := state_machine.Gs2StateMachineRestClient{
    Session: &session,
}
result, err := client.DeleteStateMachineMaster(
    &state_machine.DeleteStateMachineMasterRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Version: pointy.Int64(1000),
    }
)
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\StateMachine\Gs2StateMachineRestClient;
use Gs2\StateMachine\Request\DeleteStateMachineMasterRequest;

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

$session->open();

$client = new Gs2StateMachineRestClient(
    $session
);

try {
    $result = $client->deleteStateMachineMaster(
        (new DeleteStateMachineMasterRequest())
            ->withNamespaceName("namespace-0001")
            ->withVersion(1000)
    );
    $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.stateMachine.rest.Gs2StateMachineRestClient;
import io.gs2.stateMachine.request.DeleteStateMachineMasterRequest;
import io.gs2.stateMachine.result.DeleteStateMachineMasterResult;

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

try {
    DeleteStateMachineMasterResult result = client.deleteStateMachineMaster(
        new DeleteStateMachineMasterRequest()
            .withNamespaceName("namespace-0001")
            .withVersion(1000L)
    );
    StateMachineMaster 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 Gs2StateMachineRestClient(session);

AsyncResult<Gs2.Gs2StateMachine.Result.DeleteStateMachineMasterResult> asyncResult = null;
yield return client.DeleteStateMachineMaster(
    new Gs2.Gs2StateMachine.Request.DeleteStateMachineMasterRequest()
        .WithNamespaceName("namespace-0001")
        .WithVersion(1000L),
    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 Gs2StateMachine from '@/gs2/stateMachine';

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

try {
    const result = await client.deleteStateMachineMaster(
        new Gs2StateMachine.DeleteStateMachineMasterRequest()
            .withNamespaceName("namespace-0001")
            .withVersion(1000)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import state_machine

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

try:
    result = client.delete_state_machine_master(
        state_machine.DeleteStateMachineMasterRequest()
            .with_namespace_name('namespace-0001')
            .with_version(1000)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('state_machine')

api_result = client.delete_state_machine_master({
    namespaceName="namespace-0001",
    version=1000,
})

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

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

api_result_handler = client.delete_state_machine_master_async({
    namespaceName="namespace-0001",
    version=1000,
})

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['message'])
end

result = api_result.result
item = result.item;