GS2-Chat SDK API リファレンス

モデル

Namespace

ネームスペース

ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。 GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。

そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。

有効化条件必須デフォルト値の制限説明
namespaceIdstring~ 1024文字ネームスペースGRN
namestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
allowCreateRoombooltrueゲームプレイヤーによるルームの作成を許可するか
postMessageScriptScriptSettingメッセージを投稿したときに実行するスクリプト
createRoomScriptScriptSettingルームを作成したときに実行するスクリプト
deleteRoomScriptScriptSettingルームを削除したときに実行するスクリプト
subscribeRoomScriptScriptSettingルームを購読したときに実行するスクリプト
unsubscribeRoomScriptScriptSettingルームの購読を解除したときに実行するスクリプト
postNotificationNotificationSetting購読しているルームに新しい投稿がきたときのプッシュ通知
logSettingLogSettingログの出力設定
createdAtlong作成日時
updatedAtlong最終更新日時
revisionlong0~ 9223372036854775805リビジョン

Room

ルーム

ルームはチャットのメッセージを届けられる範囲を表しています。 GS2-Chat のルームには参加という概念はありません。 そのため、メッセージを受信するのにルームの名前さえ知っていれば、ルームに参加する必要ありません。

ルームのメッセージを閲覧できるゲームプレイヤーを限定したい場合は2つの方法があります。 1つ目はルームにパスワードを設定することです。 2つ目はルームに設定可能なホワイトリストでゲームプレイヤーのユーザーIDを設定することで限定ができます。

パスワードを設定した場合、パスワードを知らなければゲームの管理者でもメッセージの取得が出来なくなることに注意してください。 これは日本国憲法で定められた通信の秘密に該当する可能性があるためです。

ルームを購読すると、ルームに対して新しいメッセージが送信された際に GS2-Gateway のプッシュ通知を受けることが可能です。 この通知機能を利用することで、ルームに対してポーリングすることなく新しいメッセージの有無を知ることが可能となります。

有効化条件必須デフォルト値の制限説明
roomIdstring~ 1024文字ルームGRN
namestringUUID~ 128文字ルーム名
userIdstring~ 128文字オーナーユーザーID
metadatastring~ 1024文字メタデータ
passwordstring~ 128文字ルームにアクセスするために必要となるパスワード
whiteListUserIdsList<string>[]~ 1000 itemsルームにアクセス可能なユーザIDリスト
createdAtlong作成日時
updatedAtlong最終更新日時
revisionlong0~ 9223372036854775805リビジョン

Message

メッセージ

メッセージはルームに投稿されたデータです。

カテゴリというフィールドを持ちますので、メッセージの分類が可能です。 たとえば、カテゴリが 0 の場合は通常のテキストメッセージとして解釈し、 1 の場合はスタンプ(ステッカー)として処理するようにクライアントを実行することができます。

投稿されたメッセージは投降後1時間で自動的に削除されます。 この時間は変更することができません。

有効化条件必須デフォルト値の制限説明
messageIdstring~ 1024文字メッセージGRN
roomNamestringUUID~ 128文字ルーム名
namestringUUID~ 36文字メッセージ名
userIdstring~ 128文字ユーザーID
categoryint0~ 2147483645メッセージの種類を分類したい時の種類番号
metadatastring~ 1024文字メタデータ
createdAtlong作成日時
revisionlong0~ 9223372036854775805リビジョン

Subscribe

購読

ルームを購読することで、そのルームに対する新着メッセージの存在を即座に知ることが出来るようになります。 購読する際にはメッセージのカテゴリを指定できます。 この機能をうまく利用すれば重要度の高いメッセージのみ受信するような設定も可能です。

有効化条件必須デフォルト値の制限説明
subscribeIdstring~ 1024文字購読GRN
userIdstring~ 128文字ユーザーID
roomNamestring~ 128文字購読するルーム名
notificationTypesList<NotificationType>[]~ 100 items新着メッセージ通知を受け取るカテゴリリスト
createdAtlong作成日時
revisionlong0~ 9223372036854775805リビジョン

NotificationType

通知タイプ

新着メッセージ通知を受け取るカテゴリの設定

有効化条件必須デフォルト値の制限説明
categoryint0~ 2147483646新着メッセージ通知を受け取るカテゴリ
enableTransferMobilePushNotificationboolfalseオフラインだった時にモバイルプッシュ通知に転送するか

ScriptSetting

スクリプト設定

GS2 ではマイクロサービスのイベントに関連づけて、カスタムスクリプトを実行することができます。 このモデルは、スクリプトの実行をトリガーするための設定を保持します。

スクリプトの実行方式は大きく2種類あり、それは「同期実行」と「非同期実行」です。 同期実行は、スクリプトの実行が完了するまで処理がブロックされます。 かわりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることができます。

一方、非同期実行は、スクリプトの実行が完了するまで処理がブロックされません。 かわりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることはできません。 しかし、非同期実行は、スクリプトの実行が完了するまで処理がブロックされないため、APIの応答に影響を与えないため、原則非同期実行を使用することをおすすめします。

非同期実行には実行方式が2種類あり、GS2-Script と Amazon EventBridge があります。 Amazon EventBridge を使用することで、Lua 以外の言語で処理を記述することができます。

有効化条件必須デフォルト値の制限説明
triggerScriptIdstring~ 1024文字同期実行スクリプトの GS2-Script のスクリプトGRN
doneTriggerTargetTypeenum [
“none”,
“gs2_script”,
“aws”
]
“none”~ 128文字非同期スクリプトの実行方法
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字非同期実行スクリプトの GS2-Script のスクリプトGRN
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字非同期実行スクリプトを実行する GS2-JobQueue ネームスペース

NotificationSetting

プッシュ通知に関する設定

GS2 のマイクロサービス内で何らかのイベントが発生した際に、プッシュ通知を送信するための設定です。 ここでいうプッシュ通知は GS2-Gateway の提供する WebSocket インターフェースを経由した処理であり、スマートフォンのプッシュ通知とは性質が異なります。 たとえば、マッチメイキングが完了した時やフレンドリクエストが届いた時など、ゲームクライアントの操作とは関係なく状態が変化した際に GS2-Gateway を経由してプッシュ通知をすることで、ゲームクライアントは状態の変化を検知することができます。

GS2-Gateway のプッシュ通知は通知先のデバイスがオフラインだった時に追加の処理としてモバイルプッシュ通知を送信できます。 モバイルプッシュ通知をうまく利用すれば、マッチメイキング中にゲームを終了しても、モバイルプッシュ通知を使用してプレイヤーに通知し、ゲームに戻ってくるフローを実現できる可能性があります。

有効化条件必須デフォルト値の制限説明
gatewayNamespaceIdstring“grn:gs2:{region}:{ownerId}:gateway:default”~ 1024文字プッシュ通知に使用する GS2-Gateway のネームスペース
enableTransferMobileNotificationbool?falseモバイルプッシュ通知へ転送するか
soundstring{enableTransferMobileNotification} == true~ 1024文字モバイルプッシュ通知で使用するサウンドファイル名

LogSetting

ログの書き出し設定

ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用されるログ名前空間の識別子(Namespace ID)を保持します。 ログ名前空間IDは、ログデータを集約し、保存する対象の GS2-Log の名前空間を指定します。 この設定を通じて、この名前空間以下のAPIリクエスト・レスポンスログデータが対象の GS2-Log へ出力されるようになります。 GS2-Log にはリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。

有効化条件必須デフォルト値の制限説明
loggingNamespaceIdstring~ 1024文字ネームスペースGRN

メソッド

describeNamespaces

ネームスペースの一覧を取得

プロジェクト内のすべてのネームスペースの一覧を取得します。 オプションのページトークンを使用して、リストの特定の位置からデータの取得を開始できます。 また、取得するネームスペースの数を制限することも可能です。

Request

有効化条件必須デフォルト値の制限説明
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<Namespace>ネームスペースのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &chat.DescribeNamespacesRequest {
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeNamespacesRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeNamespaces(
        (new DescribeNamespacesRequest())
            ->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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeNamespacesRequest;
import io.gs2.chat.result.DescribeNamespacesResult;

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

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

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

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

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

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

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

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

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

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

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

createNamespace

ネームスペースを新規作成

ネームスペースの名前、説明、および各種設定を含む詳細情報を指定する必要があります。

Request

有効化条件必須デフォルト値の制限説明
namestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
allowCreateRoombooltrueゲームプレイヤーによるルームの作成を許可するか
postMessageScriptScriptSettingメッセージを投稿したときに実行するスクリプト
createRoomScriptScriptSettingルームを作成したときに実行するスクリプト
deleteRoomScriptScriptSettingルームを削除したときに実行するスクリプト
subscribeRoomScriptScriptSettingルームを購読したときに実行するスクリプト
unsubscribeRoomScriptScriptSettingルームの購読を解除したときに実行するスクリプト
postNotificationNotificationSetting購読しているルームに新しい投稿がきたときのプッシュ通知
logSettingLogSettingログの出力設定

Result

説明
itemNamespace作成したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &chat.CreateNamespaceRequest {
        Name: pointy.String("namespace1"),
        Description: nil,
        AllowCreateRoom: nil,
        PostMessageScript: nil,
        CreateRoomScript: nil,
        DeleteRoomScript: nil,
        SubscribeRoomScript: nil,
        UnsubscribeRoomScript: nil,
        PostNotification: nil,
        LogSetting: &chat.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CreateNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName(self::namespace1)
            ->withDescription(null)
            ->withAllowCreateRoom(null)
            ->withPostMessageScript(null)
            ->withCreateRoomScript(null)
            ->withDeleteRoomScript(null)
            ->withSubscribeRoomScript(null)
            ->withUnsubscribeRoomScript(null)
            ->withPostNotification(null)
            ->withLogSetting((new \Gs2\Chat\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:\namespace1"))
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CreateNamespaceRequest;
import io.gs2.chat.result.CreateNamespaceResult;

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

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withAllowCreateRoom(null)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new io.gs2.chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CreateNamespaceRequest;
using Gs2.Gs2Chat.Result.CreateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Chat.Request.CreateNamespaceRequest()
        .WithName("namespace1")
        .WithDescription(null)
        .WithAllowCreateRoom(null)
        .WithPostMessageScript(null)
        .WithCreateRoomScript(null)
        .WithDeleteRoomScript(null)
        .WithSubscribeRoomScript(null)
        .WithUnsubscribeRoomScript(null)
        .WithPostNotification(null)
        .WithLogSetting(new Gs2.Gs2Chat.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1")),
    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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.createNamespace(
        new Gs2Chat.CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withAllowCreateRoom(null)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new Gs2Chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.create_namespace(
        chat.CreateNamespaceRequest()
            .with_name(self.hash1)
            .with_description(None)
            .with_allow_create_room(None)
            .with_post_message_script(None)
            .with_create_room_script(None)
            .with_delete_room_script(None)
            .with_subscribe_room_script(None)
            .with_unsubscribe_room_script(None)
            .with_post_notification(None)
            .with_log_setting(
                chat.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.create_namespace({
    name="namespace1",
    description=nil,
    allowCreateRoom=nil,
    postMessageScript=nil,
    createRoomScript=nil,
    deleteRoomScript=nil,
    subscribeRoomScript=nil,
    unsubscribeRoomScript=nil,
    postNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

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

result = api_result.result
item = result.item;

getNamespaceStatus

ネームスペースの状態を取得

指定されたネームスペースの現在の状態を取得します。 これには、ネームスペースがアクティブか、保留中か、またはその他の状態にあるかが含まれます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名

Result

説明
statusstring

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &chat.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
status := result.Status
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetNamespaceStatusRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName(self::namespace1)
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetNamespaceStatusRequest;
import io.gs2.chat.result.GetNamespaceStatusResult;

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

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("namespace1")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetNamespaceStatusRequest;
using Gs2.Gs2Chat.Result.GetNamespaceStatusResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Chat.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace1"),
    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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.getNamespaceStatus(
        new Gs2Chat.GetNamespaceStatusRequest()
            .withNamespaceName("namespace1")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.get_namespace_status(
        chat.GetNamespaceStatusRequest()
            .with_namespace_name(self.hash1)
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_namespace_status({
    namespaceName="namespace1",
})

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

result = api_result.result
status = result.status;

getNamespace

ネームスペースを取得

指定されたネームスペースの詳細情報を取得します。 これには、ネームスペースの名前、説明、およびその他の設定情報が含まれます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名

Result

説明
itemNamespaceネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &chat.GetNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetNamespaceRequest;
import io.gs2.chat.result.GetNamespaceResult;

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

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetNamespaceRequest;
using Gs2.Gs2Chat.Result.GetNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Chat.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace1"),
    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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.getNamespace(
        new Gs2Chat.GetNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.get_namespace(
        chat.GetNamespaceRequest()
            .with_namespace_name(self.hash1)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_namespace({
    namespaceName="namespace1",
})

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

result = api_result.result
item = result.item;

updateNamespace

ネームスペースを更新

指定されたネームスペースの設定を更新します。 ネームスペースの説明や、特定の設定を変更することができます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
allowCreateRoombooltrueゲームプレイヤーによるルームの作成を許可するか
postMessageScriptScriptSettingメッセージを投稿したときに実行するスクリプト
createRoomScriptScriptSettingルームを作成したときに実行するスクリプト
deleteRoomScriptScriptSettingルームを削除したときに実行するスクリプト
subscribeRoomScriptScriptSettingルームを購読したときに実行するスクリプト
unsubscribeRoomScriptScriptSettingルームの購読を解除したときに実行するスクリプト
postNotificationNotificationSetting購読しているルームに新しい投稿がきたときのプッシュ通知
logSettingLogSettingログの出力設定

Result

説明
itemNamespace更新したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &chat.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
        Description: pointy.String("description1"),
        AllowCreateRoom: pointy.Bool(false),
        PostMessageScript: nil,
        CreateRoomScript: nil,
        DeleteRoomScript: nil,
        SubscribeRoomScript: nil,
        UnsubscribeRoomScript: nil,
        PostNotification: nil,
        LogSetting: &chat.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName(self::namespace1)
            ->withDescription("description1")
            ->withAllowCreateRoom(False)
            ->withPostMessageScript(null)
            ->withCreateRoomScript(null)
            ->withDeleteRoomScript(null)
            ->withSubscribeRoomScript(null)
            ->withUnsubscribeRoomScript(null)
            ->withPostNotification(null)
            ->withLogSetting((new \Gs2\Chat\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:\namespace1"))
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateNamespaceRequest;
import io.gs2.chat.result.UpdateNamespaceResult;

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

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withAllowCreateRoom(false)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new io.gs2.chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateNamespaceRequest;
using Gs2.Gs2Chat.Result.UpdateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Chat.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace1")
        .WithDescription("description1")
        .WithAllowCreateRoom(false)
        .WithPostMessageScript(null)
        .WithCreateRoomScript(null)
        .WithDeleteRoomScript(null)
        .WithSubscribeRoomScript(null)
        .WithUnsubscribeRoomScript(null)
        .WithPostNotification(null)
        .WithLogSetting(new Gs2.Gs2Chat.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1")),
    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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.updateNamespace(
        new Gs2Chat.UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withAllowCreateRoom(false)
            .withPostMessageScript(null)
            .withCreateRoomScript(null)
            .withDeleteRoomScript(null)
            .withSubscribeRoomScript(null)
            .withUnsubscribeRoomScript(null)
            .withPostNotification(null)
            .withLogSetting(new Gs2Chat.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.update_namespace(
        chat.UpdateNamespaceRequest()
            .with_namespace_name(self.hash1)
            .with_description('description1')
            .with_allow_create_room(False)
            .with_post_message_script(None)
            .with_create_room_script(None)
            .with_delete_room_script(None)
            .with_subscribe_room_script(None)
            .with_unsubscribe_room_script(None)
            .with_post_notification(None)
            .with_log_setting(
                chat.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_namespace({
    namespaceName="namespace1",
    description="description1",
    allowCreateRoom=false,
    postMessageScript=nil,
    createRoomScript=nil,
    deleteRoomScript=nil,
    subscribeRoomScript=nil,
    unsubscribeRoomScript=nil,
    postNotification=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

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

result = api_result.result
item = result.item;

deleteNamespace

ネームスペースを削除

指定されたネームスペースを削除します。 この操作は不可逆であり、削除されたネームスペースに関連するすべてのデータは回復不能になります。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名

Result

説明
itemNamespace削除したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &chat.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteNamespaceRequest;
import io.gs2.chat.result.DeleteNamespaceResult;

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

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteNamespaceRequest;
using Gs2.Gs2Chat.Result.DeleteNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Chat.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace1"),
    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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.deleteNamespace(
        new Gs2Chat.DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.delete_namespace(
        chat.DeleteNamespaceRequest()
            .with_namespace_name(self.hash1)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_namespace({
    namespaceName="namespace1",
})

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

result = api_result.result
item = result.item;

dumpUserDataByUserId

指定したユーザーIDに紐づくデータのダンプを取得

個人情報保護の法的要件を満たすために使用したり、データのバックアップや移行に使用できます。

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DumpUserDataByUserId(
    &chat.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\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DumpUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DumpUserDataByUserIdRequest;
import io.gs2.chat.result.DumpUserDataByUserIdResult;

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

try {
    DumpUserDataByUserIdResult result = client.dumpUserDataByUserId(
        new DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DumpUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.DumpUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DumpUserDataByUserIdResult> asyncResult = null;
yield return client.DumpUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

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

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

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

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

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

result = api_result.result

checkDumpUserDataByUserId

指定したユーザーIDに紐づくデータのダンプが完了しているか確認

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
urlstring出力データのURL

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CheckDumpUserDataByUserIdRequest;
import io.gs2.chat.result.CheckDumpUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(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.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CheckDumpUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CheckDumpUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CheckDumpUserDataByUserIdResult> asyncResult = null;
yield return client.CheckDumpUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

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

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

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

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

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

result = api_result.result
url = result.url;

cleanUserDataByUserId

ユーザーデータの完全削除

指定されたユーザーIDに紐づくデータのクリーニングを実行します。 これにより、特定のユーザーデータをプロジェクトから安全に削除できます。

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CleanUserDataByUserId(
    &chat.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\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CleanUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CleanUserDataByUserIdRequest;
import io.gs2.chat.result.CleanUserDataByUserIdResult;

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

try {
    CleanUserDataByUserIdResult result = client.cleanUserDataByUserId(
        new CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CleanUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CleanUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CleanUserDataByUserIdResult> asyncResult = null;
yield return client.CleanUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

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

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

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

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

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

result = api_result.result

checkCleanUserDataByUserId

指定したユーザーIDのユーザーデータの完全削除が完了しているか確認

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CheckCleanUserDataByUserId(
    &chat.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\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CheckCleanUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CheckCleanUserDataByUserIdRequest;
import io.gs2.chat.result.CheckCleanUserDataByUserIdResult;

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

try {
    CheckCleanUserDataByUserIdResult result = client.checkCleanUserDataByUserId(
        new CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CheckCleanUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CheckCleanUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CheckCleanUserDataByUserIdResult> asyncResult = null;
yield return client.CheckCleanUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

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

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

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

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

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

result = api_result.result

prepareImportUserDataByUserId

指定したユーザーIDに紐づくデータのインポートを実行

インポートに使用できるデータは GS2 によってエクスポートして取得したデータに限定され、古いデータはインポートに失敗する可能性があります。 エクスポートしたユーザーIDと異なるユーザーIDでインポートすることができますが、ユーザーデータのペイロード内にユーザーIDが含まれる場合はその限りではありません。

このAPIの戻り値で応答されたURLにエクスポートした zip ファイルをアップロードし、importUserDataByUserId を呼び出すことで実際のインポート処理を開始できます。

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
uploadTokenstringアップロード後に結果を反映する際に使用するトークン
uploadUrlstringユーザーデータアップロード処理の実行に使用するURL

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.PrepareImportUserDataByUserIdRequest;
import io.gs2.chat.result.PrepareImportUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(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.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.PrepareImportUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.PrepareImportUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.PrepareImportUserDataByUserIdResult> asyncResult = null;
yield return client.PrepareImportUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.prepareImportUserDataByUserId(
        new Gs2Chat.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 chat

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

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

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

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

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

importUserDataByUserId

指定したユーザーIDに紐づくデータのインポートを実行

インポートに使用できるデータは GS2 によってエクスポートして取得したデータに限定され、古いデータはインポートに失敗する可能性があります。 エクスポートしたユーザーIDと異なるユーザーIDでインポートすることができますが、ユーザーデータのペイロード内にユーザーIDが含まれる場合はその限りではありません。

このAPIを呼び出す前に prepareImportUserDataByUserId を呼び出して、アップロード準備を完了させる必要があります。

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
uploadTokenstring~ 1024文字アップロード準備で受け取ったトークン
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.ImportUserDataByUserId(
    &chat.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\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\ImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.ImportUserDataByUserIdRequest;
import io.gs2.chat.result.ImportUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(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.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.ImportUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.ImportUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.ImportUserDataByUserIdResult> asyncResult = null;
yield return client.ImportUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

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

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

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

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

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

result = api_result.result

checkImportUserDataByUserId

指定したユーザーIDに紐づくデータのインポートが完了しているか確認

Request

有効化条件必須デフォルト値の制限説明
userIdstring~ 128文字ユーザーID
uploadTokenstring~ 1024文字アップロード準備で受け取ったトークン
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
urlstring出力ログのURL

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CheckImportUserDataByUserIdRequest;
import io.gs2.chat.result.CheckImportUserDataByUserIdResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2ChatRestClient client = new Gs2ChatRestClient(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.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CheckImportUserDataByUserIdRequest;
using Gs2.Gs2Chat.Result.CheckImportUserDataByUserIdResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CheckImportUserDataByUserIdResult> asyncResult = null;
yield return client.CheckImportUserDataByUserId(
    new Gs2.Gs2Chat.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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.checkImportUserDataByUserId(
        new Gs2Chat.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 chat

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

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

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

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

result = api_result.result
url = result.url;

describeRooms

ルームの一覧取得

ページトークンと取得件数の制限を指定して、ルームのリストを取得できます。 これにより、存在するルームの概要を確認することができます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<Room>ルームのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeRooms(
    &chat.DescribeRoomsRequest {
        NamespaceName: pointy.String("namespace1"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeRoomsRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeRooms(
        (new DescribeRoomsRequest())
            ->withNamespaceName(self::namespace1)
            ->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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeRoomsRequest;
import io.gs2.chat.result.DescribeRoomsResult;

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

try {
    DescribeRoomsResult result = client.describeRooms(
        new DescribeRoomsRequest()
            .withNamespaceName("namespace1")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Room> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeRoomsRequest;
using Gs2.Gs2Chat.Result.DescribeRoomsResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeRoomsResult> asyncResult = null;
yield return client.DescribeRooms(
    new Gs2.Gs2Chat.Request.DescribeRoomsRequest()
        .WithNamespaceName("namespace1")
        .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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.describeRooms(
        new Gs2Chat.DescribeRoomsRequest()
            .withNamespaceName("namespace1")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.describe_rooms(
        chat.DescribeRoomsRequest()
            .with_namespace_name(self.hash1)
            .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('chat')

api_result = client.describe_rooms({
    namespaceName="namespace1",
    pageToken=nil,
    limit=nil,
})

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

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

createRoom

ルームを作成

ルーム名、ユーザーID、メタデータ、パスワード、ホワイトリストに登録されるユーザーIDを指定して、ルームを作成することができます。 ルーム名は省略可能で、省略した場合は UUID が自動的に採番されます。 新しいコミュニケーション空間を設けるために使用されます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
accessTokenstring~ 128文字オーナーユーザーID
namestringUUID~ 128文字ルーム名
metadatastring~ 1024文字メタデータ
passwordstring~ 128文字ルームにアクセスするために必要となるパスワード
whiteListUserIdsList<string>[]~ 1000 itemsルームにアクセス可能なユーザIDリスト

Result

説明
itemRoom作成したルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CreateRoom(
    &chat.CreateRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("accessToken-0001"),
        Name: pointy.String("room-0001"),
        Metadata: nil,
        Password: nil,
        WhiteListUserIds: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CreateRoomRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createRoom(
        (new CreateRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->withName("room-0001")
            ->withMetadata(null)
            ->withPassword(null)
            ->withWhiteListUserIds(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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CreateRoomRequest;
import io.gs2.chat.result.CreateRoomResult;

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

try {
    CreateRoomResult result = client.createRoom(
        new CreateRoomRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withName("room-0001")
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CreateRoomRequest;
using Gs2.Gs2Chat.Result.CreateRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CreateRoomResult> asyncResult = null;
yield return client.CreateRoom(
    new Gs2.Gs2Chat.Request.CreateRoomRequest()
        .WithNamespaceName("namespace1")
        .WithAccessToken("accessToken-0001")
        .WithName("room-0001")
        .WithMetadata(null)
        .WithPassword(null)
        .WithWhiteListUserIds(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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.createRoom(
        new Gs2Chat.CreateRoomRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withName("room-0001")
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.create_room(
        chat.CreateRoomRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_name('room-0001')
            .with_metadata(None)
            .with_password(None)
            .with_white_list_user_ids(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.create_room({
    namespaceName="namespace1",
    accessToken="accessToken-0001",
    name="room-0001",
    metadata=nil,
    password=nil,
    whiteListUserIds=nil,
})

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

result = api_result.result
item = result.item;

createRoomFromBackend

バックエンドからルームを作成

このAPIはゲームプレイヤーから呼び出されるわけではなく、システム関連系でルームを作成する際に使用します。

ルーム名、ユーザーID、メタデータ、パスワード、ホワイトリストに登録されるユーザーIDを指定して、ルームを作成することができます。 ルーム名は省略可能で、省略した場合は UUID が自動的に採番されます。 新しいコミュニケーション空間を設けるために使用されます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
namestringUUID~ 128文字ルーム名
userIdstring~ 128文字オーナーユーザーID
metadatastring~ 1024文字メタデータ
passwordstring~ 128文字ルームにアクセスするために必要となるパスワード
whiteListUserIdsList<string>[]~ 1000 itemsルームにアクセス可能なユーザIDリスト
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
itemRoom作成したルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.CreateRoomFromBackend(
    &chat.CreateRoomFromBackendRequest {
        NamespaceName: pointy.String("namespace1"),
        Name: pointy.String("room-0001"),
        UserId: nil,
        Metadata: nil,
        Password: nil,
        WhiteListUserIds: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\CreateRoomFromBackendRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createRoomFromBackend(
        (new CreateRoomFromBackendRequest())
            ->withNamespaceName(self::namespace1)
            ->withName("room-0001")
            ->withUserId(null)
            ->withMetadata(null)
            ->withPassword(null)
            ->withWhiteListUserIds(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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.CreateRoomFromBackendRequest;
import io.gs2.chat.result.CreateRoomFromBackendResult;

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

try {
    CreateRoomFromBackendResult result = client.createRoomFromBackend(
        new CreateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withUserId(null)
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
            .withTimeOffsetToken(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.CreateRoomFromBackendRequest;
using Gs2.Gs2Chat.Result.CreateRoomFromBackendResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.CreateRoomFromBackendResult> asyncResult = null;
yield return client.CreateRoomFromBackend(
    new Gs2.Gs2Chat.Request.CreateRoomFromBackendRequest()
        .WithNamespaceName("namespace1")
        .WithName("room-0001")
        .WithUserId(null)
        .WithMetadata(null)
        .WithPassword(null)
        .WithWhiteListUserIds(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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.createRoomFromBackend(
        new Gs2Chat.CreateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withUserId(null)
            .withMetadata(null)
            .withPassword(null)
            .withWhiteListUserIds(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.create_room_from_backend(
        chat.CreateRoomFromBackendRequest()
            .with_namespace_name(self.hash1)
            .with_name('room-0001')
            .with_user_id(None)
            .with_metadata(None)
            .with_password(None)
            .with_white_list_user_ids(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.create_room_from_backend({
    namespaceName="namespace1",
    name="room-0001",
    userId=nil,
    metadata=nil,
    password=nil,
    whiteListUserIds=nil,
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;

getRoom

ルームの情報を取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestringUUID~ 128文字ルーム名

Result

説明
itemRoomルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.GetRoom(
    &chat.GetRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\GetRoomRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getRoom(
        (new GetRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.GetRoomRequest;
import io.gs2.chat.result.GetRoomResult;

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

try {
    GetRoomResult result = client.getRoom(
        new GetRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.GetRoomRequest;
using Gs2.Gs2Chat.Result.GetRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.GetRoomResult> asyncResult = null;
yield return client.GetRoom(
    new Gs2.Gs2Chat.Request.GetRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.getRoom(
        new Gs2Chat.GetRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.get_room(
        chat.GetRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.get_room({
    namespaceName="namespace1",
    roomName="room-0001",
})

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

result = api_result.result
item = result.item;

updateRoom

ルームを更新

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestringUUID~ 128文字ルーム名
metadatastring~ 1024文字メタデータ
passwordstring~ 128文字ルームにアクセスするために必要となるパスワード
whiteListUserIdsList<string>[]~ 1000 itemsルームにアクセス可能なユーザIDリスト
accessTokenstring~ 128文字オーナーユーザーID

Result

説明
itemRoom更新したルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateRoom(
    &chat.UpdateRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        Metadata: nil,
        Password: pointy.String("password-0002"),
        WhiteListUserIds: []*string{
            pointy.String("user-0001"),
            pointy.String("user-0002"),
            pointy.String("user-0003"),
        },
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateRoomRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateRoom(
        (new UpdateRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withMetadata(null)
            ->withPassword("password-0002")
            ->withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            ->withAccessToken(self::$accessToken0001)
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateRoomRequest;
import io.gs2.chat.result.UpdateRoomResult;

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

try {
    UpdateRoomResult result = client.updateRoom(
        new UpdateRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata(null)
            .withPassword("password-0002")
            .withWhiteListUserIds(Arrays.asList(
                "user-0001",
                "user-0002",
                "user-0003"
            ))
            .withAccessToken("accessToken-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateRoomRequest;
using Gs2.Gs2Chat.Result.UpdateRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateRoomResult> asyncResult = null;
yield return client.UpdateRoom(
    new Gs2.Gs2Chat.Request.UpdateRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithMetadata(null)
        .WithPassword("password-0002")
        .WithWhiteListUserIds(new string[] {
            "user-0001",
            "user-0002",
            "user-0003",
        })
        .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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.updateRoom(
        new Gs2Chat.UpdateRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata(null)
            .withPassword("password-0002")
            .withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.update_room(
        chat.UpdateRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_metadata(None)
            .with_password('password-0002')
            .with_white_list_user_ids([
                'user-0001',
                'user-0002',
                'user-0003',
            ])
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_room({
    namespaceName="namespace1",
    roomName="room-0001",
    metadata=nil,
    password="password-0002",
    whiteListUserIds={
        "user-0001",
        "user-0002",
        "user-0003"
    },
    accessToken="accessToken-0001",
})

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

result = api_result.result
item = result.item;

updateRoomFromBackend

バックエンドからルームを更新

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestringUUID~ 128文字ルーム名
metadatastring~ 1024文字メタデータ
passwordstring~ 128文字ルームにアクセスするために必要となるパスワード
whiteListUserIdsList<string>[]~ 1000 itemsルームにアクセス可能なユーザIDリスト
userIdstring~ 128文字オーナーユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
itemRoom更新したルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.UpdateRoomFromBackend(
    &chat.UpdateRoomFromBackendRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        Metadata: pointy.String("ROOM_0001"),
        Password: pointy.String("password-0003"),
        WhiteListUserIds: []*string{
            pointy.String("user-0001"),
            pointy.String("user-0002"),
            pointy.String("user-0003"),
        },
        UserId: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\UpdateRoomFromBackendRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateRoomFromBackend(
        (new UpdateRoomFromBackendRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
            ->withMetadata("ROOM_0001")
            ->withPassword("password-0003")
            ->withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            ->withUserId(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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.UpdateRoomFromBackendRequest;
import io.gs2.chat.result.UpdateRoomFromBackendResult;

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

try {
    UpdateRoomFromBackendResult result = client.updateRoomFromBackend(
        new UpdateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata("ROOM_0001")
            .withPassword("password-0003")
            .withWhiteListUserIds(Arrays.asList(
                "user-0001",
                "user-0002",
                "user-0003"
            ))
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.UpdateRoomFromBackendRequest;
using Gs2.Gs2Chat.Result.UpdateRoomFromBackendResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.UpdateRoomFromBackendResult> asyncResult = null;
yield return client.UpdateRoomFromBackend(
    new Gs2.Gs2Chat.Request.UpdateRoomFromBackendRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithMetadata("ROOM_0001")
        .WithPassword("password-0003")
        .WithWhiteListUserIds(new string[] {
            "user-0001",
            "user-0002",
            "user-0003",
        })
        .WithUserId(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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.updateRoomFromBackend(
        new Gs2Chat.UpdateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withMetadata("ROOM_0001")
            .withPassword("password-0003")
            .withWhiteListUserIds([
                "user-0001",
                "user-0002",
                "user-0003",
            ])
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.update_room_from_backend(
        chat.UpdateRoomFromBackendRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
            .with_metadata('ROOM_0001')
            .with_password('password-0003')
            .with_white_list_user_ids([
                'user-0001',
                'user-0002',
                'user-0003',
            ])
            .with_user_id(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.update_room_from_backend({
    namespaceName="namespace1",
    roomName="room-0001",
    metadata="ROOM_0001",
    password="password-0003",
    whiteListUserIds={
        "user-0001",
        "user-0002",
        "user-0003"
    },
    userId=nil,
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;

deleteRoom

ルームを削除

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestringUUID~ 128文字ルーム名
accessTokenstring~ 128文字オーナーユーザーID

Result

説明
itemRoom削除したルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteRoom(
    &chat.DeleteRoomRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        AccessToken: pointy.String("accessToken-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteRoomRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteRoom(
        (new DeleteRoomRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withAccessToken(self::$accessToken0001)
    );
    $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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteRoomRequest;
import io.gs2.chat.result.DeleteRoomResult;

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

try {
    DeleteRoomResult result = client.deleteRoom(
        new DeleteRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteRoomRequest;
using Gs2.Gs2Chat.Result.DeleteRoomResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteRoomResult> asyncResult = null;
yield return client.DeleteRoom(
    new Gs2.Gs2Chat.Request.DeleteRoomRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.deleteRoom(
        new Gs2Chat.DeleteRoomRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.delete_room(
        chat.DeleteRoomRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_room({
    namespaceName="namespace1",
    roomName="room-0001",
    accessToken="accessToken-0001",
})

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

result = api_result.result
item = result.item;

deleteRoomFromBackend

バックエンドからルームを削除

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestringUUID~ 128文字ルーム名
userIdstring~ 128文字オーナーユーザーID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
itemRoom削除したルーム

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DeleteRoomFromBackend(
    &chat.DeleteRoomFromBackendRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        UserId: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DeleteRoomFromBackendRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteRoomFromBackend(
        (new DeleteRoomFromBackendRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName("room-0001")
            ->withUserId(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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DeleteRoomFromBackendRequest;
import io.gs2.chat.result.DeleteRoomFromBackendResult;

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

try {
    DeleteRoomFromBackendResult result = client.deleteRoomFromBackend(
        new DeleteRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    Room item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DeleteRoomFromBackendRequest;
using Gs2.Gs2Chat.Result.DeleteRoomFromBackendResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DeleteRoomFromBackendResult> asyncResult = null;
yield return client.DeleteRoomFromBackend(
    new Gs2.Gs2Chat.Request.DeleteRoomFromBackendRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithUserId(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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.deleteRoomFromBackend(
        new Gs2Chat.DeleteRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withUserId(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.delete_room_from_backend(
        chat.DeleteRoomFromBackendRequest()
            .with_namespace_name(self.hash1)
            .with_room_name('room-0001')
            .with_user_id(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.delete_room_from_backend({
    namespaceName="namespace1",
    roomName="room-0001",
    userId=nil,
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;

describeMessages

メッセージの一覧取得

ルーム名、取得開始時間、および取得件数の制限を指定して、ルーム内のメッセージを取得することができます。 パスワードが設定されているルームでは、パスワードの入力が必要です。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestring~ 128文字ルーム名
passwordstring~ 128文字メッセージを受信するために必要となるパスワード
accessTokenstring~ 128文字ユーザーID
startAtlong現在時刻からの差分(-1時間)メッセージの取得を開始する時間
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<Message>メッセージのリスト

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeMessages(
    &chat.DescribeMessagesRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("room-0001"),
        Password: nil,
        AccessToken: pointy.String("accessToken-0001"),
        StartAt: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeMessagesRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeMessages(
        (new DescribeMessagesRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::room-0001)
            ->withPassword(null)
            ->withAccessToken(self::$accessToken0001)
            ->withStartAt(null)
            ->withLimit(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.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeMessagesRequest;
import io.gs2.chat.result.DescribeMessagesResult;

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

try {
    DescribeMessagesResult result = client.describeMessages(
        new DescribeMessagesRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withPassword(null)
            .withAccessToken("accessToken-0001")
            .withStartAt(null)
            .withLimit(null)
    );
    List<Message> items = result.getItems();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Chat.Gs2ChatRestClient;
using Gs2.Gs2Chat.Request.DescribeMessagesRequest;
using Gs2.Gs2Chat.Result.DescribeMessagesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2ChatRestClient(session);

AsyncResult<Gs2.Gs2Chat.Result.DescribeMessagesResult> asyncResult = null;
yield return client.DescribeMessages(
    new Gs2.Gs2Chat.Request.DescribeMessagesRequest()
        .WithNamespaceName("namespace1")
        .WithRoomName("room-0001")
        .WithPassword(null)
        .WithAccessToken("accessToken-0001")
        .WithStartAt(null)
        .WithLimit(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 Gs2Chat from '@/gs2/chat';

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

try {
    const result = await client.describeMessages(
        new Gs2Chat.DescribeMessagesRequest()
            .withNamespaceName("namespace1")
            .withRoomName("room-0001")
            .withPassword(null)
            .withAccessToken("accessToken-0001")
            .withStartAt(null)
            .withLimit(null)
    );
    const items = result.getItems();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import chat

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

try:
    result = client.describe_messages(
        chat.DescribeMessagesRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_password(None)
            .with_access_token(self.access_token_0001)
            .with_start_at(None)
            .with_limit(None)
    )
    items = result.items
except core.Gs2Exception as e:
    exit(1)
client = gs2('chat')

api_result = client.describe_messages({
    namespaceName="namespace1",
    roomName="room-0001",
    password=nil,
    accessToken="accessToken-0001",
    startAt=nil,
    limit=nil,
})

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

result = api_result.result
items = result.items;

describeMessagesByUserId

ユーザIDを指定してメッセージの一覧取得

ルーム名、取得開始時間、および取得件数の制限を指定して、ルーム内のメッセージを取得することができます。 パスワードが設定されているルームでは、パスワードの入力が必要です。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
roomNamestring~ 128文字ルーム名
passwordstring~ 128文字メッセージを受信するために必要となるパスワード
userIdstring~ 128文字ユーザーID
startAtlong現在時刻からの差分(-1時間)メッセージの取得を開始する時間
limitint301 ~ 1000データの取得件数
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
itemsList<Message>メッセージのリスト

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/chat"
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 := chat.Gs2ChatRestClient{
    Session: &session,
}
result, err := client.DescribeMessagesByUserId(
    &chat.DescribeMessagesByUserIdRequest {
        NamespaceName: pointy.String("$namespace1.name"),
        RoomName: pointy.String("room-0001"),
        Password: nil,
        UserId: pointy.String("user-0002"),
        StartAt: nil,
        Limit: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeMessagesByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeMessagesByUserId(
        (new DescribeMessagesByUserIdRequest())
            ->withNamespaceName(self::$namespace1.name)
            ->withRoomName(self::room-0001)
            ->withPassword(null)
            ->withUserId("user-0002")
            ->withStartAt(null)
            ->withLimit(null)
            ->withTimeOffsetToken