GS2-Gateway SDK API Reference
Models
Namespace
Namespace
A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the Namespace differs, the data is treated as a completely independent data space.
Therefore, you must create a Namespace before you can start using each service.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceId | string | * | ~ 1024 chars | Namespace GRN
* Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSettingV2 | TransactionSettingV2 | Transaction Setting (V2) Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time. Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset. | ||||
| firebaseProjectId | string | ~ 256 chars | Firebase project ID The project ID of the Firebase project that issues the FCM device tokens registered to GS2-Gateway. Required to forward a notification as a mobile push notification via Firebase Cloud Messaging (FCM) when the target player is offline. To let GS2 send on your behalf, enable the Firebase Cloud Messaging API in that project and grant the GS2 service account for your region, api-access@gs2-<region>-<env>.iam.gserviceaccount.com (for example api-access@gs2-ap-northeast-1-live.iam.gserviceaccount.com), the “Firebase Cloud Messaging API Admin” role (roles/firebasemessaging.admin). | |||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of gateway operations to GS2-Log. By specifying a GS2-Log Namespace, API request and response logs for WebSocket session management, notification delivery, and Firebase token operations can be collected. | ||||
| createdAt | long | * | Current time | Creation Timestamp Unix time, milliseconds * Set automatically by the server | ||
| updatedAt | long | * | Current time | Last Updated Timestamp Unix time, milliseconds * Set automatically by the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
TransactionSettingV2
Transaction Setting (V2)
Transaction Setting (V2) decides how the transactions issued by a Namespace are executed.
There are only two things to set:
distributorNamespaceId: the GS2-Distributor Namespace used to execute the transactionenableParallelExecution: whether the actions in a transaction run one at a time or all at once
Whichever you choose, the transaction is executed by the server the moment it is issued, and it succeeds or fails as a whole: when an action fails, the actions that already ran are undone with it and nothing is left applied. Everything else about how a transaction runs is fixed to the recommended configuration, so there is nothing else to set.
Running the actions one at a time (the default, enableParallelExecution is false) lets each action work on top of what the actions before it wrote. The actions run in verify, consume, acquire order, and this is what lets you:
- update the same row from more than one action in a single transaction, which fails when they run all at once
- read what an earlier action wrote, including from List and Query and from inside a nested transaction
- use
%{Gs2Xxx:ActionName.path[0].field}to feed the result of an earlier verify or consume action into the parameters of a later verify, consume or acquire action
In exchange, the response time is the sum of the time taken by each action, and a transaction may contain at most 20 actions. The order within each phase is decided by the action name and then by the target resource, so you cannot choose the execution order by rearranging the actions in the request, and execution stops at the first action that fails.
Running the actions all at once (enableParallelExecution is true) executes them in parallel against a single snapshot of the data, so the response time is that of the slowest single action and there is no limit on the number of actions.
In exchange, an action cannot see what the other actions wrote, and two actions that write the same row fail the transaction with database:transaction:same.resource (400), so choose this only when you can guarantee that no two actions in the same transaction write the same data. %{...} may reference only the results of an earlier phase (verify, then consume, then acquire); a reference to an action in the same phase is left unresolved, and a phase that contains %{...} waits for the earlier phases to complete, which lengthens the response time by that amount.
Transaction Setting is the obsolete setting that Transaction Setting (V2) replaces, kept for Namespaces created before Transaction Setting (V2) existed. It applies only while Transaction Setting (V2) is unset, and setting Transaction Setting (V2) supersedes it. Three behaviours it allowed are deliberately not offered here: executing a transaction as a client-run stamp sheet, running AutoRun asynchronously via GS2-Distributor, and folding acquire actions into GS2-JobQueue.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| enableParallelExecution | bool | false | Whether to execute the actions in parallel instead of sequentially |
LogSetting
Log Output Setting
Log Output Setting defines how log data is exported. This type holds the GS2-Log Namespace identifier (Namespace ID), which is used to export log data. Specify the GS2-Log Namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified Namespace is output to the target GS2-Log Namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log Namespace GRN
to output logs Must be specified in GRN format starting with “grn:gs2:”. |
TransactionSetting
Transaction Setting
Transaction Setting is obsolete: Transaction Setting (V2) replaces it. It is kept for Namespaces created before Transaction Setting (V2) existed, applies only while Transaction Setting (V2) is unset, and should not be chosen for a new Namespace.
It exposes each part of transaction execution as a separate field – AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, asynchronous processing of acquire actions via GS2-JobQueue, and sequential execution – so combinations other than the recommended one can be built. Transaction Setting (V2) is that recommended combination expressed as a single setting. Keep using Transaction Setting only on a Namespace that already depends on a behaviour Transaction Setting (V2) does not offer: executing a transaction as a client-run stamp sheet, running AutoRun asynchronously via GS2-Distributor, or folding acquire actions into GS2-JobQueue.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | false | Whether to automatically execute issued transactions on the server side | |||
| enableAtomicCommit | bool | {enableAutoRun} == true | false | Whether to commit transactions atomically * Enabled only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Enabled only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Enabled only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Enabled only if enableAtomicCommit is true | ||
| enableSequentialExecution | bool | {enableAtomicCommit} == true | false | Whether to execute the actions of an atomic commit sequentially so that multiple actions may update the same row * Enabled only if enableAtomicCommit is true | ||
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| queueNamespaceId | string | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | GS2-JobQueue Namespace GRN used to execute transactions |
WebSocketSession
WebSocketSession
A WebSocket session is a persistent connection between a GS2 server and a client for real-time bidirectional communication. The client registers a user ID as an identifier to the server.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| webSocketSessionId | string | * | ~ 1024 chars | WebSocket Session GRN
* Set automatically by the server | ||
| connectionId | string | ✓ | ~ 128 chars | Connection ID The unique identifier assigned to this WebSocket connection. Used to identify the specific client connection when sending notifications. | ||
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| sessionId | string | ~ 128 chars | Session ID An optional session identifier that can be associated with this WebSocket connection. Used to correlate the WebSocket session with an application-level session context. | |||
| createdAt | long | * | Current time | Creation Timestamp Unix time, milliseconds * Set automatically by the server | ||
| updatedAt | long | * | Current time | Last Updated Timestamp Unix time, milliseconds * Set automatically by the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
FirebaseToken
Firebase Device Token
A Firebase Device Token is required to use mobile push notifications.
GS2-Gateway provides in-game push notification functionality, allowing you to receive push notifications when matchmaking is completed or missions are accomplished, If the target player is offline, the notification can be forwarded as a mobile push notification.
The Firebase Device Token is used to identify the device to be notified. As the name suggests, Firebase is an external service, so please refer to the Firebase documentation for detailed information on how to obtain the token.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| firebaseTokenId | string | * | ~ 1024 chars | Firebase Device Token GRN
* Set automatically by the server | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| token | string | ✓ | ~ 1024 chars | Device Token for Firebase Cloud Messaging The FCM registration token obtained from the client device. Identifies the specific device to deliver mobile push notifications to when the player is offline and cannot receive in-game WebSocket notifications. The token is device-specific and may change when the app is reinstalled or data is cleared. | ||
| locale | string | ~ 32 chars | Locale of the notification message The locale of the messages to deliver to this device. It is a free-form string such as ja or en, and is not restricted to a fixed list of values. When a notification is forwarded to a mobile push notification and its payload is a JSON that contains a mobile array of {locale, message} entries, the entry whose locale matches this value is used as the body of the push notification. If no entry matches, the entry whose locale is default is used, and if that is missing as well, the first entry of the array is used. If the payload is not in that format, the payload is used as is. This field is optional; when it is not set, only the default entry, the first entry, or the raw payload applies. | |||
| createdAt | long | * | Current time | Creation Timestamp Unix time, milliseconds * Set automatically by the server | ||
| updatedAt | long | * | Current time | Last Updated Timestamp Unix time, milliseconds * Set automatically by the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
SendNotificationEntry
Send Notification Entry
Represents a notification message to be delivered to a player. The notification is first attempted via WebSocket for online players. If the player is offline and mobile push notification forwarding is enabled, the notification is forwarded to the player’s device via Firebase Cloud Messaging.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| issuer | string | ✓ | ~ 256 chars | Notification source service The identifier of the GS2 service that originated this notification. For example, “gs2-matchmaking” for matchmaking completion notifications or “gs2-mission” for mission achievement notifications. Used by the client to determine how to handle the notification. | ||
| subject | string | ✓ | ~ 128 chars | Subject The title or summary of the notification message. When forwarded as a mobile push notification, this is displayed as the notification title on the device. | ||
| payload | string | ✓ | ~ 1024 chars | Payload The JSON data body of the notification. Contains service-specific details about the event that triggered the notification. Delivered as-is to the client via WebSocket, or included in the mobile push notification data when forwarded. | ||
| enableTransferMobileNotification | bool | false | Whether to forward the notification as a mobile push notification when the target user is offline When enabled, if the target player does not have an active WebSocket connection, the notification will be forwarded to their mobile device via Firebase Cloud Messaging. Requires that the Namespace has firebaseProjectId configured and the player has a registered device token. | |||
| sound | string | {enableTransferMobileNotification} == true | ~ 256 chars | Name of the audio file to play The name of the sound file to play when the mobile push notification is delivered. Only applicable when mobile push notification forwarding is enabled. The sound file must be included in the client application bundle. * Enabled only if enableTransferMobileNotification is true | ||
| mobileNotificationMessages | List<MobileNotificationMessage> | {enableTransferMobileNotification} == true | 0 ~ 100 items | Localized title and body used when forwarding to mobile push notifications The title and the body, per language, used when this notification is forwarded as a mobile push notification to an offline user. The entry to be used is selected in the following order: the entry whose locale matches the locale registered with the device token, then the entry whose locale is default, and finally the first entry of the list.If this is not specified, the mobile array of the payload is used instead, and if that is not present either, the payload itself is used as the body.* Enabled only if enableTransferMobileNotification is true |
MobileNotificationMessage
Localized message for mobile push notification
One entry of the per-locale message list used when a notification is forwarded as a mobile push notification. Each entry holds the title and the body for one locale.
The entry to be used is selected in the following order: the entry whose locale matches the locale registered with the Firebase device token, then the entry whose locale is default, and finally the first entry of the list.
Details
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| locale | string | ~ 32 chars | Language of the message The language this entry is for, matched against the locale registered with the Firebase device token. The value is free-form, such as ja or en. The special value default marks the fallback entry used when no entry matches the device locale. | |||
| title | string | ~ 256 chars | Title of the push notification The text displayed as the title of the mobile push notification when this entry is selected. If omitted, the subject of the notification is used. | |||
| message | string | ~ 1024 chars | Body text of the push notification The text displayed as the body of the mobile push notification when this entry is selected. |
Methods
describeNamespaces
List Namespaces
Retrieves a list of Namespaces that have been created on a per-service basis within the project. You can use the optional page token to start acquiring data from a specific location in the list. You can also limit the number of Namespaces to be acquired.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namePrefix | string | ~ 64 chars | Filter by Namespace name prefix | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<Namespace> | List of Namespaces |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DescribeNamespaces(
&gateway.DescribeNamespacesRequest {
NamePrefix: nil,
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DescribeNamespacesRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DescribeNamespacesRequest;
import io.gs2.gateway.result.DescribeNamespacesResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.describeNamespaces(
new Gs2Gateway.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 gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.describe_namespaces(
gateway.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('gateway')
api_result = client.describe_namespaces({
namePrefix=nil,
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('gateway')
api_result_handler = client.describe_namespaces_async({
namePrefix=nil,
pageToken=nil,
limit=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;createNamespace
Create Namespace
You must specify detailed information including the name, description, and various settings of the Namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSettingV2 | TransactionSettingV2 | Transaction Setting (V2) Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time. Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset. | ||||
| firebaseProjectId | string | ~ 256 chars | Firebase project ID The project ID of the Firebase project that issues the FCM device tokens registered to GS2-Gateway. Required to forward a notification as a mobile push notification via Firebase Cloud Messaging (FCM) when the target player is offline. To let GS2 send on your behalf, enable the Firebase Cloud Messaging API in that project and grant the GS2 service account for your region, api-access@gs2-<region>-<env>.iam.gserviceaccount.com (for example api-access@gs2-ap-northeast-1-live.iam.gserviceaccount.com), the “Firebase Cloud Messaging API Admin” role (roles/firebasemessaging.admin). | |||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of gateway operations to GS2-Log. By specifying a GS2-Log Namespace, API request and response logs for WebSocket session management, notification delivery, and Firebase token operations can be collected. |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace created |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.CreateNamespace(
&gateway.CreateNamespaceRequest {
Name: pointy.String("namespace-0001"),
Description: nil,
TransactionSettingV2: nil,
FirebaseProjectId: nil,
LogSetting: &gateway.LogSetting{
LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\CreateNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->createNamespace(
(new CreateNamespaceRequest())
->withName("namespace-0001")
->withDescription(null)
->withTransactionSettingV2(null)
->withFirebaseProjectId(null)
->withLogSetting((new \Gs2\Gateway\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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.CreateNamespaceRequest;
import io.gs2.gateway.result.CreateNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
CreateNamespaceResult result = client.createNamespace(
new CreateNamespaceRequest()
.withName("namespace-0001")
.withDescription(null)
.withTransactionSettingV2(null)
.withFirebaseProjectId(null)
.withLogSetting(new io.gs2.gateway.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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
new Gs2.Gs2Gateway.Request.CreateNamespaceRequest()
.WithName("namespace-0001")
.WithDescription(null)
.WithTransactionSettingV2(null)
.WithFirebaseProjectId(null)
.WithLogSetting(new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.createNamespace(
new Gs2Gateway.CreateNamespaceRequest()
.withName("namespace-0001")
.withDescription(null)
.withTransactionSettingV2(null)
.withFirebaseProjectId(null)
.withLogSetting(new Gs2Gateway.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.create_namespace(
gateway.CreateNamespaceRequest()
.with_name('namespace-0001')
.with_description(None)
.with_transaction_setting_v2(None)
.with_firebase_project_id(None)
.with_log_setting(
gateway.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('gateway')
api_result = client.create_namespace({
name="namespace-0001",
description=nil,
transactionSettingV2=nil,
firebaseProjectId=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.create_namespace_async({
name="namespace-0001",
description=nil,
transactionSettingV2=nil,
firebaseProjectId=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getNamespaceStatus
Get Namespace Status
Get the current status of the specified Namespace. This includes whether the Namespace is active, pending, or in some other state.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |||||||
|---|---|---|---|---|---|---|---|---|
| status | string | Namespace Status
|
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.GetNamespaceStatus(
&gateway.GetNamespaceStatusRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
status := result.Statususe Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetNamespaceStatusRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetNamespaceStatusRequest;
import io.gs2.gateway.result.GetNamespaceStatusResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.getNamespaceStatus(
new Gs2Gateway.GetNamespaceStatusRequest()
.withNamespaceName("namespace-0001")
);
const status = result.getStatus();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.get_namespace_status(
gateway.GetNamespaceStatusRequest()
.with_namespace_name('namespace-0001')
)
status = result.status
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.get_namespace_status({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
status = result.status;client = gs2('gateway')
api_result_handler = client.get_namespace_status_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
status = result.status;getNamespace
Get Namespace
Get detailed information about the specified Namespace. This includes the name, description, and other settings of the Namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.GetNamespace(
&gateway.GetNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetNamespaceRequest;
import io.gs2.gateway.result.GetNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.getNamespace(
new Gs2Gateway.GetNamespaceRequest()
.withNamespaceName("namespace-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.get_namespace(
gateway.GetNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.get_namespace({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.get_namespace_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;updateNamespace
Update Namespace
Update the settings of the specified Namespace. You can change the description and other settings of the Namespace.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSettingV2 | TransactionSettingV2 | Transaction Setting (V2) Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time. Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset. | ||||
| firebaseProjectId | string | ~ 256 chars | Firebase project ID The project ID of the Firebase project that issues the FCM device tokens registered to GS2-Gateway. Required to forward a notification as a mobile push notification via Firebase Cloud Messaging (FCM) when the target player is offline. To let GS2 send on your behalf, enable the Firebase Cloud Messaging API in that project and grant the GS2 service account for your region, api-access@gs2-<region>-<env>.iam.gserviceaccount.com (for example api-access@gs2-ap-northeast-1-live.iam.gserviceaccount.com), the “Firebase Cloud Messaging API Admin” role (roles/firebasemessaging.admin). | |||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of gateway operations to GS2-Log. By specifying a GS2-Log Namespace, API request and response logs for WebSocket session management, notification delivery, and Firebase token operations can be collected. |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace updated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.UpdateNamespace(
&gateway.UpdateNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
Description: pointy.String("description1"),
TransactionSettingV2: nil,
FirebaseProjectId: pointy.String("firebase-project2"),
LogSetting: &gateway.LogSetting{
LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\UpdateNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->updateNamespace(
(new UpdateNamespaceRequest())
->withNamespaceName("namespace-0001")
->withDescription("description1")
->withTransactionSettingV2(null)
->withFirebaseProjectId("firebase-project2")
->withLogSetting((new \Gs2\Gateway\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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.UpdateNamespaceRequest;
import io.gs2.gateway.result.UpdateNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
UpdateNamespaceResult result = client.updateNamespace(
new UpdateNamespaceRequest()
.withNamespaceName("namespace-0001")
.withDescription("description1")
.withTransactionSettingV2(null)
.withFirebaseProjectId("firebase-project2")
.withLogSetting(new io.gs2.gateway.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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
new Gs2.Gs2Gateway.Request.UpdateNamespaceRequest()
.WithNamespaceName("namespace-0001")
.WithDescription("description1")
.WithTransactionSettingV2(null)
.WithFirebaseProjectId("firebase-project2")
.WithLogSetting(new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.updateNamespace(
new Gs2Gateway.UpdateNamespaceRequest()
.withNamespaceName("namespace-0001")
.withDescription("description1")
.withTransactionSettingV2(null)
.withFirebaseProjectId("firebase-project2")
.withLogSetting(new Gs2Gateway.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.update_namespace(
gateway.UpdateNamespaceRequest()
.with_namespace_name('namespace-0001')
.with_description('description1')
.with_transaction_setting_v2(None)
.with_firebase_project_id('firebase-project2')
.with_log_setting(
gateway.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('gateway')
api_result = client.update_namespace({
namespaceName="namespace-0001",
description="description1",
transactionSettingV2=nil,
firebaseProjectId="firebase-project2",
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.update_namespace_async({
namespaceName="namespace-0001",
description="description1",
transactionSettingV2=nil,
firebaseProjectId="firebase-project2",
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteNamespace
Delete Namespace
Delete the specified Namespace. This operation is irreversible and all data associated with the deleted Namespace will be lost.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Deleted Namespace |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DeleteNamespace(
&gateway.DeleteNamespaceRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DeleteNamespaceRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DeleteNamespaceRequest;
import io.gs2.gateway.result.DeleteNamespaceResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.deleteNamespace(
new Gs2Gateway.DeleteNamespaceRequest()
.withNamespaceName("namespace-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.delete_namespace(
gateway.DeleteNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.delete_namespace({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.delete_namespace_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getServiceVersion
Get microservice version
Details
Request
Request parameters: None
Result
| Type | Description | |
|---|---|---|
| item | string | Version |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.GetServiceVersion(
&gateway.GetServiceVersionRequest {
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetServiceVersionRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetServiceVersionRequest;
import io.gs2.gateway.result.GetServiceVersionResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.getServiceVersion(
new Gs2Gateway.GetServiceVersionRequest()
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.get_service_version(
gateway.GetServiceVersionRequest()
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.get_service_version({
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.get_service_version_async({
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;dumpUserDataByUserId
Dump data associated with the specified user ID
Can be used to meet legal requirements for the protection of personal information, or to back up or migrate data.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
Return value: None
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DumpUserDataByUserId(
&gateway.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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DumpUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DumpUserDataByUserIdRequest;
import io.gs2.gateway.result.DumpUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DumpUserDataByUserIdResult> asyncResult = null;
yield return client.DumpUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.dumpUserDataByUserId(
new Gs2Gateway.DumpUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.dump_user_data_by_user_id(
gateway.DumpUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultclient = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultcheckDumpUserDataByUserId
Check if the dump of the data associated with the specified user ID is complete
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| url | string | URL of output data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.CheckDumpUserDataByUserId(
&gateway.CheckDumpUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
url := result.Urluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\CheckDumpUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.CheckDumpUserDataByUserIdRequest;
import io.gs2.gateway.result.CheckDumpUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.CheckDumpUserDataByUserIdResult> asyncResult = null;
yield return client.CheckDumpUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.checkDumpUserDataByUserId(
new Gs2Gateway.CheckDumpUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
const url = result.getUrl();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.check_dump_user_data_by_user_id(
gateway.CheckDumpUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
url = result.url
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
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['errorMessage'])
end
result = api_result.result
url = result.url;client = gs2('gateway')
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['errorMessage'])
end
result = api_result.result
url = result.url;cleanUserDataByUserId
Clean User Data by User ID
Execute cleaning of data associated with the specified user ID. This allows you to safely delete specific user data from the project.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
Return value: None
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.CleanUserDataByUserId(
&gateway.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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\CleanUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.CleanUserDataByUserIdRequest;
import io.gs2.gateway.result.CleanUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.CleanUserDataByUserIdResult> asyncResult = null;
yield return client.CleanUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.cleanUserDataByUserId(
new Gs2Gateway.CleanUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.clean_user_data_by_user_id(
gateway.CleanUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultclient = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultcheckCleanUserDataByUserId
Check if the cleaning of the data associated with the specified user ID is complete
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
Return value: None
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.CheckCleanUserDataByUserId(
&gateway.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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\CheckCleanUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.CheckCleanUserDataByUserIdRequest;
import io.gs2.gateway.result.CheckCleanUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.CheckCleanUserDataByUserIdResult> asyncResult = null;
yield return client.CheckCleanUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.checkCleanUserDataByUserId(
new Gs2Gateway.CheckCleanUserDataByUserIdRequest()
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.check_clean_user_data_by_user_id(
gateway.CheckCleanUserDataByUserIdRequest()
.with_user_id('user-0001')
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultclient = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultprepareImportUserDataByUserId
Prepare User Data Import by User ID
The data that can be used for import is limited to the data exported by GS2, and old data may fail to import. You can import data with a user ID different from the one you exported, but if the user ID is included in the payload of the user data, this may not be the case.
You can start the actual import process by uploading the exported zip file to the URL returned in the return value of this API and calling importUserDataByUserId.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| uploadToken | string | Token used to reflect results after upload |
| uploadUrl | string | URL used to upload user data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.PrepareImportUserDataByUserId(
&gateway.PrepareImportUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\PrepareImportUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.PrepareImportUserDataByUserIdRequest;
import io.gs2.gateway.result.PrepareImportUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.PrepareImportUserDataByUserIdResult> asyncResult = null;
yield return client.PrepareImportUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.prepareImportUserDataByUserId(
new Gs2Gateway.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 gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.prepare_import_user_data_by_user_id(
gateway.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('gateway')
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['errorMessage'])
end
result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;client = gs2('gateway')
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['errorMessage'])
end
result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;importUserDataByUserId
Execute import of data associated with the specified user ID
The data that can be used for import is limited to the data exported by GS2, and old data may fail to import. You can import data with a user ID different from the one you exported, but if the user ID is included in the payload of the user data, this may not be the case.
Before calling this API, you must call prepareImportUserDataByUserId to complete the upload preparation.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| uploadToken | string | ✓ | ~ 1024 chars | Token received in preparation for upload | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
Return value: None
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.ImportUserDataByUserId(
&gateway.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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\ImportUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.ImportUserDataByUserIdRequest;
import io.gs2.gateway.result.ImportUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.ImportUserDataByUserIdResult> asyncResult = null;
yield return client.ImportUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.importUserDataByUserId(
new Gs2Gateway.ImportUserDataByUserIdRequest()
.withUserId("user-0001")
.withUploadToken("upload-0001")
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.import_user_data_by_user_id(
gateway.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('gateway')
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['errorMessage'])
end
result = api_result.resultclient = gs2('gateway')
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['errorMessage'])
end
result = api_result.resultcheckImportUserDataByUserId
Check if the import of the data associated with the specified user ID is complete
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| userId | string | ✓ | ~ 128 chars | User ID | ||
| uploadToken | string | ✓ | ~ 1024 chars | Token received in preparation for upload | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| url | string | URL of log data |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.CheckImportUserDataByUserId(
&gateway.CheckImportUserDataByUserIdRequest {
UserId: pointy.String("user-0001"),
UploadToken: pointy.String("upload-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
url := result.Urluse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\CheckImportUserDataByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.CheckImportUserDataByUserIdRequest;
import io.gs2.gateway.result.CheckImportUserDataByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.CheckImportUserDataByUserIdResult> asyncResult = null;
yield return client.CheckImportUserDataByUserId(
new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.checkImportUserDataByUserId(
new Gs2Gateway.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 gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.check_import_user_data_by_user_id(
gateway.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('gateway')
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['errorMessage'])
end
result = api_result.result
url = result.url;client = gs2('gateway')
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['errorMessage'])
end
result = api_result.result
url = result.url;describeWebSocketSessions
List WebSocket sessions
Retrieves a paginated list of active WebSocket sessions for the requesting user. Each session represents an active WebSocket connection from a client device.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<WebSocketSession> | List of WebSocket Session |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DescribeWebSocketSessions(
&gateway.DescribeWebSocketSessionsRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DescribeWebSocketSessionsRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->describeWebSocketSessions(
(new DescribeWebSocketSessionsRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DescribeWebSocketSessionsRequest;
import io.gs2.gateway.result.DescribeWebSocketSessionsResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
DescribeWebSocketSessionsResult result = client.describeWebSocketSessions(
new DescribeWebSocketSessionsRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withPageToken(null)
.withLimit(null)
);
List<WebSocketSession> 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DescribeWebSocketSessionsResult> asyncResult = null;
yield return client.DescribeWebSocketSessions(
new Gs2.Gs2Gateway.Request.DescribeWebSocketSessionsRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.describeWebSocketSessions(
new Gs2Gateway.DescribeWebSocketSessionsRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-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 gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.describe_web_socket_sessions(
gateway.DescribeWebSocketSessionsRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-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('gateway')
api_result = client.describe_web_socket_sessions({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('gateway')
api_result_handler = client.describe_web_socket_sessions_async({
namespaceName="namespace-0001",
accessToken="accessToken-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['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;describeWebSocketSessionsByUserId
List WebSocket sessions by User ID
Retrieves a paginated list of active WebSocket sessions for the specified user (server-side operation). Each session represents an active WebSocket connection from a client device.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | 30 | 1 ~ 1000 | Number of data items to retrieve | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| items | List<WebSocketSession> | List of WebSocket Session |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DescribeWebSocketSessionsByUserId(
&gateway.DescribeWebSocketSessionsByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
PageToken: nil,
Limit: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DescribeWebSocketSessionsByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->describeWebSocketSessionsByUserId(
(new DescribeWebSocketSessionsByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DescribeWebSocketSessionsByUserIdRequest;
import io.gs2.gateway.result.DescribeWebSocketSessionsByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
DescribeWebSocketSessionsByUserIdResult result = client.describeWebSocketSessionsByUserId(
new DescribeWebSocketSessionsByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withPageToken(null)
.withLimit(null)
.withTimeOffsetToken(null)
);
List<WebSocketSession> 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DescribeWebSocketSessionsByUserIdResult> asyncResult = null;
yield return client.DescribeWebSocketSessionsByUserId(
new Gs2.Gs2Gateway.Request.DescribeWebSocketSessionsByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.describeWebSocketSessionsByUserId(
new Gs2Gateway.DescribeWebSocketSessionsByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.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 gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.describe_web_socket_sessions_by_user_id(
gateway.DescribeWebSocketSessionsByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.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('gateway')
api_result = client.describe_web_socket_sessions_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
pageToken=nil,
limit=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('gateway')
api_result_handler = client.describe_web_socket_sessions_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
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['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;setUserId
Set user ID for WebSocket session
Associates the current WebSocket connection with a user ID, creating or updating the session. When allowConcurrentAccess is false, existing sessions for the same user are handled based on the force flag:
- If force is false and another session exists, a Conflict error is returned (prevents duplicate logins).
- If force is true, the existing session is disconnected and replaced.
- If sessionId is specified, connections with the same sessionId are allowed (useful for reconnection). When allowConcurrentAccess is true, multiple concurrent connections from the same user are allowed.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| connectionId | string | ✓ | ~ 128 chars | Connection ID The unique identifier assigned to this WebSocket connection. Used to identify the specific client connection when sending notifications. | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| allowConcurrentAccess | bool | true | Whether to allow connections from different clients at the same time | |||
| sessionId | string | {allowConcurrentAccess} == false | ~ 128 chars | Specifies a session ID that allows reconnection when allowConcurrentAccess is false and the existing connection has the same session ID. * Enabled only if allowConcurrentAccess is false | ||
| force | bool? | {allowConcurrentAccess} == false | false | An existing WebSocket session will be disconnected before creating a new WebSocket session. * Enabled only if allowConcurrentAccess is false |
Result
| Type | Description | |
|---|---|---|
| item | WebSocketSession | WebSocket session updated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.SetUserId(
&gateway.SetUserIdRequest {
NamespaceName: pointy.String("$hash"),
AccessToken: pointy.String("accessToken-0001"),
AllowConcurrentAccess: pointy.Bool(true),
SessionId: nil,
Force: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->setUserId(
(new SetUserIdRequest())
->withNamespaceName("$hash")
->withAccessToken("accessToken-0001")
->withAllowConcurrentAccess(true)
->withSessionId(null)
->withForce(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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetUserIdRequest;
import io.gs2.gateway.result.SetUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
SetUserIdResult result = client.setUserId(
new SetUserIdRequest()
.withNamespaceName("$hash")
.withAccessToken("accessToken-0001")
.withAllowConcurrentAccess(true)
.withSessionId(null)
.withForce(null)
);
WebSocketSession 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.SetUserIdResult> asyncResult = null;
yield return client.SetUserId(
new Gs2.Gs2Gateway.Request.SetUserIdRequest()
.WithNamespaceName("$hash")
.WithAccessToken("accessToken-0001")
.WithAllowConcurrentAccess(true)
.WithSessionId(null)
.WithForce(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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.setUserId(
new Gs2Gateway.SetUserIdRequest()
.withNamespaceName("$hash")
.withAccessToken("accessToken-0001")
.withAllowConcurrentAccess(true)
.withSessionId(null)
.withForce(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.set_user_id(
gateway.SetUserIdRequest()
.with_namespace_name('$hash')
.with_access_token('accessToken-0001')
.with_allow_concurrent_access(True)
.with_session_id(None)
.with_force(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.set_user_id({
namespaceName="$hash",
accessToken="accessToken-0001",
allowConcurrentAccess=true,
sessionId=nil,
force=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.set_user_id_async({
namespaceName="$hash",
accessToken="accessToken-0001",
allowConcurrentAccess=true,
sessionId=nil,
force=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;setUserIdByUserId
Set user ID for WebSocket session by User ID
Associates the current WebSocket connection with the specified user ID (server-side operation). Concurrent access control and session management behavior is the same as SetUserId.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| connectionId | string | ✓ | ~ 128 chars | Connection ID The unique identifier assigned to this WebSocket connection. Used to identify the specific client connection when sending notifications. | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| allowConcurrentAccess | bool | true | Whether to allow connections from different clients at the same time | |||
| sessionId | string | {allowConcurrentAccess} == false | ~ 128 chars | Specifies a session ID that allows reconnection when allowConcurrentAccess is false and the existing connection has the same session ID. * Enabled only if allowConcurrentAccess is false | ||
| force | bool? | {allowConcurrentAccess} == false | false | An existing WebSocket session will be disconnected before creating a new WebSocket session. * Enabled only if allowConcurrentAccess is false | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | WebSocketSession | WebSocket session updated |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.SetUserIdByUserId(
&gateway.SetUserIdByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
AllowConcurrentAccess: pointy.Bool(true),
SessionId: nil,
Force: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetUserIdByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->setUserIdByUserId(
(new SetUserIdByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withAllowConcurrentAccess(true)
->withSessionId(null)
->withForce(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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetUserIdByUserIdRequest;
import io.gs2.gateway.result.SetUserIdByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
SetUserIdByUserIdResult result = client.setUserIdByUserId(
new SetUserIdByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAllowConcurrentAccess(true)
.withSessionId(null)
.withForce(null)
.withTimeOffsetToken(null)
);
WebSocketSession 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.SetUserIdByUserIdResult> asyncResult = null;
yield return client.SetUserIdByUserId(
new Gs2.Gs2Gateway.Request.SetUserIdByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithAllowConcurrentAccess(true)
.WithSessionId(null)
.WithForce(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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.setUserIdByUserId(
new Gs2Gateway.SetUserIdByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withAllowConcurrentAccess(true)
.withSessionId(null)
.withForce(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.set_user_id_by_user_id(
gateway.SetUserIdByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_allow_concurrent_access(True)
.with_session_id(None)
.with_force(None)
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.set_user_id_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
allowConcurrentAccess=true,
sessionId=nil,
force=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.set_user_id_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
allowConcurrentAccess=true,
sessionId=nil,
force=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;sendNotification
Send notification
Sends a notification message to all active WebSocket sessions of the specified user.
The notification includes a subject and payload, and optionally a sound file name.
If enableTransferMobileNotification is true and the user has no active WebSocket sessions (offline), the notification may be forwarded as a mobile push notification via Firebase.
Forwarding requires that firebaseProjectId is set on the Namespace and that a device token is registered for the user.
When mobileNotificationMessages is specified, the title and the body of the forwarded push notification are taken from the entry matching the locale registered with the device token, falling back to the default entry and then to the first entry.
Returns the protocol used and the list of connection IDs that received the notification.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| subject | string | ✓ | ~ 128 chars | Subject The title or summary of the notification message. When forwarded as a mobile push notification, this is displayed as the notification title on the device. | ||
| payload | string | ✓ | ~ 1024 chars | Payload The JSON data body of the notification. Contains service-specific details about the event that triggered the notification. Delivered as-is to the client via WebSocket, or included in the mobile push notification data when forwarded. | ||
| enableTransferMobileNotification | bool | false | Whether to forward the notification as a mobile push notification when the target user is offline When enabled, if the target player does not have an active WebSocket connection, the notification will be forwarded to their mobile device via Firebase Cloud Messaging. Requires that the Namespace has firebaseProjectId configured and the player has a registered device token. | |||
| sound | string | {enableTransferMobileNotification} == true | ~ 256 chars | Name of the audio file to play The name of the sound file to play when the mobile push notification is delivered. Only applicable when mobile push notification forwarding is enabled. The sound file must be included in the client application bundle. * Enabled only if enableTransferMobileNotification is true | ||
| mobileNotificationMessages | List<MobileNotificationMessage> | {enableTransferMobileNotification} == true | 0 ~ 100 items | Localized title and body used when forwarding to mobile push notifications The title and the body, per language, used when this notification is forwarded as a mobile push notification to an offline user. The entry to be used is selected in the following order: the entry whose locale matches the locale registered with the device token, then the entry whose locale is default, and finally the first entry of the list.If this is not specified, the mobile array of the payload is used instead, and if that is not present either, the payload itself is used as the body.* Enabled only if enableTransferMobileNotification is true | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| protocol | string | Protocol used for notification |
| sendConnectionIds | List<string> | List of connection IDs sent |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.SendNotification(
&gateway.SendNotificationRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
Subject: pointy.String("subject"),
Payload: pointy.String("payload"),
EnableTransferMobileNotification: pointy.Bool(true),
Sound: pointy.String("sound.wav"),
MobileNotificationMessages: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
protocol := result.Protocol
sendConnectionIds := result.SendConnectionIdsuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SendNotificationRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->sendNotification(
(new SendNotificationRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withSubject("subject")
->withPayload("payload")
->withEnableTransferMobileNotification(true)
->withSound("sound.wav")
->withMobileNotificationMessages(null)
->withTimeOffsetToken(null)
);
$protocol = $result->getProtocol();
$sendConnectionIds = $result->getSendConnectionIds();
} 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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SendNotificationRequest;
import io.gs2.gateway.result.SendNotificationResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
SendNotificationResult result = client.sendNotification(
new SendNotificationRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withSubject("subject")
.withPayload("payload")
.withEnableTransferMobileNotification(true)
.withSound("sound.wav")
.withMobileNotificationMessages(null)
.withTimeOffsetToken(null)
);
String protocol = result.getProtocol();
List<String> sendConnectionIds = result.getSendConnectionIds();
} 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.SendNotificationResult> asyncResult = null;
yield return client.SendNotification(
new Gs2.Gs2Gateway.Request.SendNotificationRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithSubject("subject")
.WithPayload("payload")
.WithEnableTransferMobileNotification(true)
.WithSound("sound.wav")
.WithMobileNotificationMessages(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var protocol = result.Protocol;
var sendConnectionIds = result.SendConnectionIds;import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.sendNotification(
new Gs2Gateway.SendNotificationRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withSubject("subject")
.withPayload("payload")
.withEnableTransferMobileNotification(true)
.withSound("sound.wav")
.withMobileNotificationMessages(null)
.withTimeOffsetToken(null)
);
const protocol = result.getProtocol();
const sendConnectionIds = result.getSendConnectionIds();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.send_notification(
gateway.SendNotificationRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_subject('subject')
.with_payload('payload')
.with_enable_transfer_mobile_notification(True)
.with_sound('sound.wav')
.with_mobile_notification_messages(None)
.with_time_offset_token(None)
)
protocol = result.protocol
send_connection_ids = result.send_connection_ids
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.send_notification({
namespaceName="namespace-0001",
userId="user-0001",
subject="subject",
payload="payload",
enableTransferMobileNotification=true,
sound="sound.wav",
mobileNotificationMessages=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
protocol = result.protocol;
sendConnectionIds = result.sendConnectionIds;client = gs2('gateway')
api_result_handler = client.send_notification_async({
namespaceName="namespace-0001",
userId="user-0001",
subject="subject",
payload="payload",
enableTransferMobileNotification=true,
sound="sound.wav",
mobileNotificationMessages=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
protocol = result.protocol;
sendConnectionIds = result.sendConnectionIds;disconnectByUserId
Disconnect WebSocket sessions by User ID
Disconnects and deletes all active WebSocket sessions for the specified user. Returns the list of disconnected sessions.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| items | List<WebSocketSession> | List of Disconnected WebSocket session |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DisconnectByUserId(
&gateway.DisconnectByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Itemsuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DisconnectByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->disconnectByUserId(
(new DisconnectByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withTimeOffsetToken(null)
);
$items = $result->getItems();
} 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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DisconnectByUserIdRequest;
import io.gs2.gateway.result.DisconnectByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
DisconnectByUserIdResult result = client.disconnectByUserId(
new DisconnectByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
List<WebSocketSession> items = result.getItems();
} 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DisconnectByUserIdResult> asyncResult = null;
yield return client.DisconnectByUserId(
new Gs2.Gs2Gateway.Request.DisconnectByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.disconnectByUserId(
new Gs2Gateway.DisconnectByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
const items = result.getItems();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.disconnect_by_user_id(
gateway.DisconnectByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_time_offset_token(None)
)
items = result.items
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.disconnect_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;client = gs2('gateway')
api_result_handler = client.disconnect_by_user_id_async({
namespaceName="namespace-0001",
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['errorMessage'])
end
result = api_result.result
items = result.items;disconnectAll
Disconnect all WebSocket sessions
Disconnects all WebSocket sessions in the specified Namespace. This is a Namespace-wide operation that affects all users’ sessions.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name |
Result
Return value: None
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DisconnectAll(
&gateway.DisconnectAllRequest {
NamespaceName: pointy.String("namespace-0001"),
}
)
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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DisconnectAllRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->disconnectAll(
(new DisconnectAllRequest())
->withNamespaceName("namespace-0001")
);
} 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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DisconnectAllRequest;
import io.gs2.gateway.result.DisconnectAllResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
DisconnectAllResult result = client.disconnectAll(
new DisconnectAllRequest()
.withNamespaceName("namespace-0001")
);
} 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DisconnectAllResult> asyncResult = null;
yield return client.DisconnectAll(
new Gs2.Gs2Gateway.Request.DisconnectAllRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.disconnectAll(
new Gs2Gateway.DisconnectAllRequest()
.withNamespaceName("namespace-0001")
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.disconnect_all(
gateway.DisconnectAllRequest()
.with_namespace_name('namespace-0001')
)
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.disconnect_all({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultclient = gs2('gateway')
api_result_handler = client.disconnect_all_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultsetFirebaseToken
Set Firebase device token
Registers or updates the Firebase Cloud Messaging (FCM) device token for the requesting user. If a token already exists for the user, it is updated with the new value; otherwise, a new token is created. This token is used to deliver mobile push notifications when the user is offline (no active WebSocket sessions). The optional locale selects the language of the messages that are forwarded as mobile push notifications.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| token | string | ✓ | ~ 1024 chars | Device Token for Firebase Cloud Messaging The FCM registration token obtained from the client device. Identifies the specific device to deliver mobile push notifications to when the player is offline and cannot receive in-game WebSocket notifications. The token is device-specific and may change when the app is reinstalled or data is cleared. | ||
| locale | string | ~ 32 chars | Locale of the notification message The locale of the messages to deliver to this device. It is a free-form string such as ja or en, and is not restricted to a fixed list of values. When a notification is forwarded to a mobile push notification and its payload is a JSON that contains a mobile array of {locale, message} entries, the entry whose locale matches this value is used as the body of the push notification. If no entry matches, the entry whose locale is default is used, and if that is missing as well, the first entry of the array is used. If the payload is not in that format, the payload is used as is. This field is optional; when it is not set, only the default entry, the first entry, or the raw payload applies. |
Result
| Type | Description | |
|---|---|---|
| item | FirebaseToken | Firebase Device Token created |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.SetFirebaseToken(
&gateway.SetFirebaseTokenRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
Token: pointy.String("firebase-token-0001"),
Locale: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetFirebaseTokenRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->setFirebaseToken(
(new SetFirebaseTokenRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-0001")
->withToken("firebase-token-0001")
->withLocale(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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetFirebaseTokenRequest;
import io.gs2.gateway.result.SetFirebaseTokenResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
SetFirebaseTokenResult result = client.setFirebaseToken(
new SetFirebaseTokenRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withToken("firebase-token-0001")
.withLocale(null)
);
FirebaseToken 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.SetFirebaseTokenResult> asyncResult = null;
yield return client.SetFirebaseToken(
new Gs2.Gs2Gateway.Request.SetFirebaseTokenRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-0001")
.WithToken("firebase-token-0001")
.WithLocale(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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.setFirebaseToken(
new Gs2Gateway.SetFirebaseTokenRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
.withToken("firebase-token-0001")
.withLocale(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.set_firebase_token(
gateway.SetFirebaseTokenRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
.with_token('firebase-token-0001')
.with_locale(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.set_firebase_token({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
token="firebase-token-0001",
locale=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.set_firebase_token_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
token="firebase-token-0001",
locale=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;setFirebaseTokenByUserId
Set Firebase device token by User ID
Registers or updates the Firebase Cloud Messaging (FCM) device token for the specified user (server-side operation). If a token already exists for the user, it is updated; otherwise, a new token is created. The optional locale selects the language of the messages that are forwarded as mobile push notifications.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| token | string | ✓ | ~ 1024 chars | Device Token for Firebase Cloud Messaging The FCM registration token obtained from the client device. Identifies the specific device to deliver mobile push notifications to when the player is offline and cannot receive in-game WebSocket notifications. The token is device-specific and may change when the app is reinstalled or data is cleared. | ||
| locale | string | ~ 32 chars | Locale of the notification message The locale of the messages to deliver to this device. It is a free-form string such as ja or en, and is not restricted to a fixed list of values. When a notification is forwarded to a mobile push notification and its payload is a JSON that contains a mobile array of {locale, message} entries, the entry whose locale matches this value is used as the body of the push notification. If no entry matches, the entry whose locale is default is used, and if that is missing as well, the first entry of the array is used. If the payload is not in that format, the payload is used as is. This field is optional; when it is not set, only the default entry, the first entry, or the raw payload applies. | |||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | FirebaseToken | Firebase Device Token created |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.SetFirebaseTokenByUserId(
&gateway.SetFirebaseTokenByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
Token: pointy.String("firebase-token-0001"),
Locale: nil,
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetFirebaseTokenByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->setFirebaseTokenByUserId(
(new SetFirebaseTokenByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withToken("firebase-token-0001")
->withLocale(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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetFirebaseTokenByUserIdRequest;
import io.gs2.gateway.result.SetFirebaseTokenByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
SetFirebaseTokenByUserIdResult result = client.setFirebaseTokenByUserId(
new SetFirebaseTokenByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withToken("firebase-token-0001")
.withLocale(null)
.withTimeOffsetToken(null)
);
FirebaseToken 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.SetFirebaseTokenByUserIdResult> asyncResult = null;
yield return client.SetFirebaseTokenByUserId(
new Gs2.Gs2Gateway.Request.SetFirebaseTokenByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithToken("firebase-token-0001")
.WithLocale(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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.setFirebaseTokenByUserId(
new Gs2Gateway.SetFirebaseTokenByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withToken("firebase-token-0001")
.withLocale(null)
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.set_firebase_token_by_user_id(
gateway.SetFirebaseTokenByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_token('firebase-token-0001')
.with_locale(None)
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.set_firebase_token_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
token="firebase-token-0001",
locale=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.set_firebase_token_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
token="firebase-token-0001",
locale=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getFirebaseToken
Get Firebase device token
Retrieves the Firebase Cloud Messaging (FCM) device token registered for the requesting user.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token |
Result
| Type | Description | |
|---|---|---|
| item | FirebaseToken | Firebase Device Token |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.GetFirebaseToken(
&gateway.GetFirebaseTokenRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetFirebaseTokenRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->getFirebaseToken(
(new GetFirebaseTokenRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetFirebaseTokenRequest;
import io.gs2.gateway.result.GetFirebaseTokenResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
GetFirebaseTokenResult result = client.getFirebaseToken(
new GetFirebaseTokenRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
);
FirebaseToken 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.GetFirebaseTokenResult> asyncResult = null;
yield return client.GetFirebaseToken(
new Gs2.Gs2Gateway.Request.GetFirebaseTokenRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.getFirebaseToken(
new Gs2Gateway.GetFirebaseTokenRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.get_firebase_token(
gateway.GetFirebaseTokenRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.get_firebase_token({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.get_firebase_token_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getFirebaseTokenByUserId
Get Firebase device token by User ID
Retrieves the Firebase Cloud Messaging (FCM) device token registered for the specified user (server-side operation).
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | FirebaseToken | Firebase Device Token |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.GetFirebaseTokenByUserId(
&gateway.GetFirebaseTokenByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetFirebaseTokenByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->getFirebaseTokenByUserId(
(new GetFirebaseTokenByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetFirebaseTokenByUserIdRequest;
import io.gs2.gateway.result.GetFirebaseTokenByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
GetFirebaseTokenByUserIdResult result = client.getFirebaseTokenByUserId(
new GetFirebaseTokenByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
FirebaseToken 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.GetFirebaseTokenByUserIdResult> asyncResult = null;
yield return client.GetFirebaseTokenByUserId(
new Gs2.Gs2Gateway.Request.GetFirebaseTokenByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.getFirebaseTokenByUserId(
new Gs2Gateway.GetFirebaseTokenByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.get_firebase_token_by_user_id(
gateway.GetFirebaseTokenByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.get_firebase_token_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.get_firebase_token_by_user_id_async({
namespaceName="namespace-0001",
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['errorMessage'])
end
result = api_result.result
item = result.item;deleteFirebaseToken
Delete Firebase device token
Deletes the Firebase Cloud Messaging (FCM) device token registered for the requesting user. After deletion, the user will no longer receive mobile push notifications when offline.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token |
Result
| Type | Description | |
|---|---|---|
| item | FirebaseToken | Firebase Device Token deleted |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DeleteFirebaseToken(
&gateway.DeleteFirebaseTokenRequest {
NamespaceName: pointy.String("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DeleteFirebaseTokenRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->deleteFirebaseToken(
(new DeleteFirebaseTokenRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DeleteFirebaseTokenRequest;
import io.gs2.gateway.result.DeleteFirebaseTokenResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
DeleteFirebaseTokenResult result = client.deleteFirebaseToken(
new DeleteFirebaseTokenRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
);
FirebaseToken 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DeleteFirebaseTokenResult> asyncResult = null;
yield return client.DeleteFirebaseToken(
new Gs2.Gs2Gateway.Request.DeleteFirebaseTokenRequest()
.WithNamespaceName("namespace-0001")
.WithAccessToken("accessToken-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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.deleteFirebaseToken(
new Gs2Gateway.DeleteFirebaseTokenRequest()
.withNamespaceName("namespace-0001")
.withAccessToken("accessToken-0001")
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.delete_firebase_token(
gateway.DeleteFirebaseTokenRequest()
.with_namespace_name('namespace-0001')
.with_access_token('accessToken-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.delete_firebase_token({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.delete_firebase_token_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteFirebaseTokenByUserId
Delete Firebase device token by User ID
Deletes the Firebase Cloud Messaging (FCM) device token registered for the specified user (server-side operation). After deletion, the user will no longer receive mobile push notifications when offline.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | FirebaseToken | Firebase Device Token deleted |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.DeleteFirebaseTokenByUserId(
&gateway.DeleteFirebaseTokenByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DeleteFirebaseTokenByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->deleteFirebaseTokenByUserId(
(new DeleteFirebaseTokenByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DeleteFirebaseTokenByUserIdRequest;
import io.gs2.gateway.result.DeleteFirebaseTokenByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
DeleteFirebaseTokenByUserIdResult result = client.deleteFirebaseTokenByUserId(
new DeleteFirebaseTokenByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
FirebaseToken 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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.DeleteFirebaseTokenByUserIdResult> asyncResult = null;
yield return client.DeleteFirebaseTokenByUserId(
new Gs2.Gs2Gateway.Request.DeleteFirebaseTokenByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-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 Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.deleteFirebaseTokenByUserId(
new Gs2Gateway.DeleteFirebaseTokenByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withTimeOffsetToken(null)
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.delete_firebase_token_by_user_id(
gateway.DeleteFirebaseTokenByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_time_offset_token(None)
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.delete_firebase_token_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('gateway')
api_result_handler = client.delete_firebase_token_by_user_id_async({
namespaceName="namespace-0001",
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['errorMessage'])
end
result = api_result.result
item = result.item;sendMobileNotificationByUserId
Send mobile push notification
Sends a mobile push notification to the specified user via Firebase Cloud Messaging (FCM).
The notification includes a subject (title), payload (body), and optionally a sound file name.
When mobileNotificationMessages is specified, the title and the body are taken from the entry matching the locale registered with the device token, falling back to the default entry and then to the first entry, instead of the subject and the payload.
The user must have a registered Firebase device token for the notification to be delivered.
Details
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| subject | string | ✓ | ~ 256 chars | Subject | ||
| payload | string | ✓ | ~ 1024 chars | Payload | ||
| sound | string | ~ 256 chars | Name of the audio file to play | |||
| mobileNotificationMessages | List<MobileNotificationMessage> | 0 ~ 100 items | Localized title and body used when forwarding to mobile push notifications The title and the body, per language, used when this notification is forwarded as a mobile push notification to an offline user. The entry to be used is selected in the following order: the entry whose locale matches the locale registered with the device token, then the entry whose locale is default, and finally the first entry of the list.If this is not specified, the mobile array of the payload is used instead, and if that is not present either, the payload itself is used as the body. | |||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
Return value: None
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/gateway"
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 := gateway.Gs2GatewayRestClient{
Session: &session,
}
result, err := client.SendMobileNotificationByUserId(
&gateway.SendMobileNotificationByUserIdRequest {
NamespaceName: pointy.String("namespace-0001"),
UserId: pointy.String("user-0001"),
Subject: pointy.String("subject"),
Payload: pointy.String("payload"),
Sound: pointy.String("sound.wav"),
MobileNotificationMessages: nil,
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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SendMobileNotificationByUserIdRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2GatewayRestClient(
$session
);
try {
$result = $client->sendMobileNotificationByUserId(
(new SendMobileNotificationByUserIdRequest())
->withNamespaceName("namespace-0001")
->withUserId("user-0001")
->withSubject("subject")
->withPayload("payload")
->withSound("sound.wav")
->withMobileNotificationMessages(null)
->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SendMobileNotificationByUserIdRequest;
import io.gs2.gateway.result.SendMobileNotificationByUserIdResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2GatewayRestClient client = new Gs2GatewayRestClient(session);
try {
SendMobileNotificationByUserIdResult result = client.sendMobileNotificationByUserId(
new SendMobileNotificationByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withSubject("subject")
.withPayload("payload")
.withSound("sound.wav")
.withMobileNotificationMessages(null)
.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 Gs2GatewayRestClient(session);
AsyncResult<Gs2.Gs2Gateway.Result.SendMobileNotificationByUserIdResult> asyncResult = null;
yield return client.SendMobileNotificationByUserId(
new Gs2.Gs2Gateway.Request.SendMobileNotificationByUserIdRequest()
.WithNamespaceName("namespace-0001")
.WithUserId("user-0001")
.WithSubject("subject")
.WithPayload("payload")
.WithSound("sound.wav")
.WithMobileNotificationMessages(null)
.WithTimeOffsetToken(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';
const session = new Gs2Core.Gs2RestSession(
"ap-northeast-1",
new Gs2Core.BasicGs2Credential(
'your client id',
'your client secret'
)
);
await session.connect();
const client = new Gs2Gateway.Gs2GatewayRestClient(session);
try {
const result = await client.sendMobileNotificationByUserId(
new Gs2Gateway.SendMobileNotificationByUserIdRequest()
.withNamespaceName("namespace-0001")
.withUserId("user-0001")
.withSubject("subject")
.withPayload("payload")
.withSound("sound.wav")
.withMobileNotificationMessages(null)
.withTimeOffsetToken(null)
);
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import gateway
session = core.Gs2RestSession(
core.BasicGs2Credential(
'your client id',
'your client secret'
),
"ap-northeast-1",
)
session.connect()
client = gateway.Gs2GatewayRestClient(session)
try:
result = client.send_mobile_notification_by_user_id(
gateway.SendMobileNotificationByUserIdRequest()
.with_namespace_name('namespace-0001')
.with_user_id('user-0001')
.with_subject('subject')
.with_payload('payload')
.with_sound('sound.wav')
.with_mobile_notification_messages(None)
.with_time_offset_token(None)
)
except core.Gs2Exception as e:
exit(1)client = gs2('gateway')
api_result = client.send_mobile_notification_by_user_id({
namespaceName="namespace-0001",
userId="user-0001",
subject="subject",
payload="payload",
sound="sound.wav",
mobileNotificationMessages=nil,
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.resultclient = gs2('gateway')
api_result_handler = client.send_mobile_notification_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
subject="subject",
payload="payload",
sound="sound.wav",
mobileNotificationMessages=nil,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result