NAV
go python java php typescript csharp GS2-Script

GS2-Chat

GS2-SDK のリファレンス

モデル

Namespace

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

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

説明
namespaceId string ネームスペースGRN
name string ネームスペース名
description string 説明文
allowCreateRoom bool ゲームプレイヤーによるルームの作成を許可するか
postMessageScript ScriptSetting メッセージを投稿したときに実行するスクリプト
createRoomScript ScriptSetting ルームを作成したときに実行するスクリプト
deleteRoomScript ScriptSetting ルームを削除したときに実行するスクリプト
subscribeRoomScript ScriptSetting ルームを購読したときに実行するスクリプト
unsubscribeRoomScript ScriptSetting ルームの購読を解除したときに実行するスクリプト
postNotification NotificationSetting 購読しているルームに新しい投稿がきたときのプッシュ通知
logSetting LogSetting ログの出力設定
createdAt long 作成日時
updatedAt long 最終更新日時

Room

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

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

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

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

説明
roomId string ルームGRN
name string ルーム名
userId string 管理者ユーザーID
metadata string メタデータ
password string ルームにアクセスするために必要となるパスワード
whiteListUserIds string[] ルームにアクセス可能なユーザIDリスト
createdAt long 作成日時
updatedAt long 最終更新日時

Message

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

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

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

説明
messageId string メッセージGRN
roomName string ルーム名
name string メッセージ名
userId string ユーザーID
category int メッセージの種類を分類したい時の種類番号
metadata string メタデータ
createdAt long 作成日時

Subscribe

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

説明
subscribeId string 購読GRN
userId string ユーザーID
roomName string 購読するルーム名
notificationTypes NotificationType[] 新着メッセージ通知を受け取るカテゴリリスト
createdAt long 作成日時

NotificationType

説明
category int 新着メッセージ通知を受け取るカテゴリ
enableTransferMobilePushNotification bool オフラインだった時にモバイルプッシュ通知に転送するか

ScriptSetting

説明
triggerScriptId string スクリプトGRN
doneTriggerTargetType string 完了通知の通知先
doneTriggerScriptId string スクリプトGRN
doneTriggerQueueNamespaceId string ネームスペースGRN

NotificationSetting

説明
gatewayNamespaceId string ネームスペースGRN
enableTransferMobileNotification bool モバイルプッシュ通知へ転送するか
sound string モバイルプッシュ通知で使用するサウンドファイル名

LogSetting

説明
loggingNamespaceId string ネームスペースGRN

メソッド

describeNamespaces

describeNamespaces

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeNamespaces(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

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

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

Request

必須 デフォルト 値の制限 説明
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items Namespace[] ネームスペースのリスト
nextPageToken string リストの続きを取得するためのページトークン

createNamespace

createNamespace

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.createNamespace(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

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

Request

必須 デフォルト 値の制限 説明
name string ~ 32文字 ネームスペース名
description string ~ 1024文字 説明文
allowCreateRoom bool true ゲームプレイヤーによるルームの作成を許可するか
postMessageScript ScriptSetting メッセージを投稿したときに実行するスクリプト
createRoomScript ScriptSetting ルームを作成したときに実行するスクリプト
deleteRoomScript ScriptSetting ルームを削除したときに実行するスクリプト
subscribeRoomScript ScriptSetting ルームを購読したときに実行するスクリプト
unsubscribeRoomScript ScriptSetting ルームの購読を解除したときに実行するスクリプト
postNotification NotificationSetting 購読しているルームに新しい投稿がきたときのプッシュ通知
logSetting LogSetting ログの出力設定

Result

説明
item Namespace 作成したネームスペース

getNamespaceStatus

getNamespaceStatus

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getNamespaceStatus(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
status = result.status;

ネームスペースを取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名

Result

説明
status string

getNamespace

getNamespace

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getNamespace(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ネームスペースを取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名

Result

説明
item Namespace ネームスペース

updateNamespace

updateNamespace

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.updateNamespace(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ネームスペースを更新

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
description string ~ 1024文字 説明文
allowCreateRoom bool true ゲームプレイヤーによるルームの作成を許可するか
postMessageScript ScriptSetting メッセージを投稿したときに実行するスクリプト
createRoomScript ScriptSetting ルームを作成したときに実行するスクリプト
deleteRoomScript ScriptSetting ルームを削除したときに実行するスクリプト
subscribeRoomScript ScriptSetting ルームを購読したときに実行するスクリプト
unsubscribeRoomScript ScriptSetting ルームの購読を解除したときに実行するスクリプト
postNotification NotificationSetting 購読しているルームに新しい投稿がきたときのプッシュ通知
logSetting LogSetting ログの出力設定

Result

説明
item Namespace 更新したネームスペース

deleteNamespace

deleteNamespace

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.deleteNamespace(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ネームスペースを削除

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名

Result

説明
item Namespace 削除したネームスペース

describeRooms

describeRooms

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeRooms(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

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

ルームの一覧取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items Room[] ルームのリスト
nextPageToken string リストの続きを取得するためのページトークン

createRoom

createRoom

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("$access_token_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("$access_token_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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.createRoom(
    new CreateRoomRequest()
        .withNamespaceName("namespace1")
        .withAccessToken("$access_token_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("$access_token_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='$access_token_0001',
    name='room-0001',
    metadata=nil,
    password=nil,
    whiteListUserIds=nil,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを作成

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
accessToken string ~ 128文字 管理者ユーザーID
name string ~ 128文字 ルーム名
metadata string ~ 1024文字 メタデータ
password string ~ 128文字 ルームにアクセスするために必要となるパスワード
whiteListUserIds string[] [] ルームにアクセス可能なユーザIDリスト

Result

説明
item Room 作成したルーム

createRoomFromBackend

createRoomFromBackend

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,
    }
)
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)
    );
    $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)
    );
    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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.createRoomFromBackend(
    new CreateRoomFromBackendRequest()
        .withNamespaceName("namespace1")
        .withName("room-0001")
        .withUserId(null)
        .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.createRoomFromBackend(
        new Gs2Chat.CreateRoomFromBackendRequest()
            .withNamespaceName("namespace1")
            .withName("room-0001")
            .withUserId(null)
            .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_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)
    )
    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,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを作成

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
name string ~ 128文字 ルーム名
userId string ~ 128文字 管理者ユーザーID
metadata string ~ 1024文字 メタデータ
password string ~ 128文字 ルームにアクセスするために必要となるパスワード
whiteListUserIds string[] [] ルームにアクセス可能なユーザIDリスト

Result

説明
item Room 作成したルーム

getRoom

getRoom

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getRoom(
    new 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
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名

Result

説明
item Room ルーム

updateRoom

updateRoom

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: pointy.String("ROOM_0001"),
        Password: pointy.String("password-0003"),
        WhiteListUserIds: []string{
            "user-0001",
        "user-0002",
        "user-0003",
        },
    }
)
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("room-0001")
            ->withMetadata("ROOM_0001")
            ->withPassword("password-0003")
            ->withWhiteListUserIds([    "user-0001",
            "user-0002",
            "user-0003",
            ])
    );
    $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("ROOM_0001")
            .withPassword("password-0003")
            .withWhiteListUserIds(Arrays.asList(
                "user-0001",
            "user-0002",
            "user-0003"
            ))
    );
    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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.updateRoom(
    new UpdateRoomRequest()
        .withNamespaceName("namespace1")
        .withRoomName("room-0001")
        .withMetadata("ROOM_0001")
        .withPassword("password-0003")
        .withWhiteListUserIds(new string[] {
            "user-0001",
        "user-0002",
        "user-0003"
        }),
    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("ROOM_0001")
            .withPassword("password-0003")
            .withWhiteListUserIds([
                "user-0001",
            "user-0002",
            "user-0003"
            ])
    );
    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('room-0001')
            .with_metadata('ROOM_0001')
            .with_password('password-0003')
            .with_white_list_user_ids([    'user-0001',
            'user-0002',
            'user-0003',
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.update_room({
    namespaceName='namespace1',
    roomName='room-0001',
    metadata='ROOM_0001',
    password='password-0003',
    whiteListUserIds={
        'user-0001',
    'user-0002',
    'user-0003'
    },
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを更新

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
metadata string ~ 1024文字 メタデータ
password string ~ 128文字 ルームにアクセスするために必要となるパスワード
whiteListUserIds string[] [] ルームにアクセス可能なユーザIDリスト

Result

説明
item Room 更新したルーム

deleteRoom

deleteRoom

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("$room1.name"),
        AccessToken: pointy.String("$access_token_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::$room1.name)
            ->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("$room1.name")
            .withAccessToken("$access_token_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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.deleteRoom(
    new DeleteRoomRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withAccessToken("$access_token_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("$room1.name")
            .withAccessToken("$access_token_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='$room1.name',
    accessToken='$access_token_0001',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを削除

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
accessToken string ~ 128文字 管理者ユーザーID

Result

説明
item Room 削除したルーム

deleteRoomFromBackend

deleteRoomFromBackend

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,
    }
)
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)
    );
    $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)
    );
    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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.deleteRoomFromBackend(
    new DeleteRoomFromBackendRequest()
        .withNamespaceName("namespace1")
        .withRoomName("room-0001")
        .withUserId(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)
    );
    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)
    )
    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,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを削除

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
userId string ~ 128文字 管理者ユーザーID

Result

説明
item Room 削除したルーム

describeMessages

describeMessages

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("$room1.name"),
        Password: nil,
        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::$room1.name)
            ->withPassword(null)
            ->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("$room1.name")
            .withPassword(null)
            .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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeMessages(
    new DescribeMessagesRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withPassword(null)
        .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("$room1.name")
            .withPassword(null)
            .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_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='$room1.name',
    password=nil,
    startAt=nil,
    limit=nil,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
items = result.items;

メッセージの一覧取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
password string ~ 128文字 メッセージを受信するために必要となるパスワード
startAt long 現在時刻からのオフセット(-1時間) メッセージの取得を開始する時間
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items Message[] メッセージのリスト

post

post

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.Post(
    &chat.PostRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        AccessToken: pointy.String("$access_token_0001"),
        Category: nil,
        Metadata: pointy.String("MESSAGE_0001"),
        Password: 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\PostRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->post(
        (new PostRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withAccessToken(self::$accessToken0001)
            ->withCategory(null)
            ->withMetadata("MESSAGE_0001")
            ->withPassword(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.PostRequest;
import io.gs2.chat.result.PostResult;

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

try {
    PostResult result = client.post(
        new PostRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
            .withCategory(null)
            .withMetadata("MESSAGE_0001")
            .withPassword(null)
    );
    Message 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.PostRequest;
using Gs2.Gs2Chat.Result.PostResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.post(
    new PostRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withAccessToken("$access_token_0001")
        .withCategory(null)
        .withMetadata("MESSAGE_0001")
        .withPassword(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.post(
        new Gs2Chat.PostRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
            .withCategory(null)
            .withMetadata("MESSAGE_0001")
            .withPassword(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.post(
        chat.PostRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
            .with_category(None)
            .with_metadata('MESSAGE_0001')
            .with_password(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.post({
    namespaceName='namespace1',
    roomName='$room1.name',
    accessToken='$access_token_0001',
    category=nil,
    metadata='MESSAGE_0001',
    password=nil,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

メッセージを投稿

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
accessToken string ~ 128文字 ユーザーID
category int 0 ~ 9223372036854775807 メッセージの種類を分類したい時の種類番号
metadata string ~ 1024文字 メタデータ
password string ~ 128文字 パスワード

Result

説明
item Message 投稿したメッセージ

postByUserId

postByUserId

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.PostByUserId(
    &chat.PostByUserIdRequest {
        NamespaceName: nil,
        RoomName: pointy.String("$room2.name"),
        UserId: pointy.String("user-0002"),
        Category: nil,
        Metadata: pointy.String("MESSAGE_0003"),
        Password: pointy.String("password-0002"),
    }
)
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\PostByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->postByUserId(
        (new PostByUserIdRequest())
            ->withNamespaceName(null)
            ->withRoomName(self::$room2.name)
            ->withUserId("user-0002")
            ->withCategory(null)
            ->withMetadata("MESSAGE_0003")
            ->withPassword("password-0002")
    );
    $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.PostByUserIdRequest;
import io.gs2.chat.result.PostByUserIdResult;

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

try {
    PostByUserIdResult result = client.postByUserId(
        new PostByUserIdRequest()
            .withNamespaceName(null)
            .withRoomName("$room2.name")
            .withUserId("user-0002")
            .withCategory(null)
            .withMetadata("MESSAGE_0003")
            .withPassword("password-0002")
    );
    Message 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.PostByUserIdRequest;
using Gs2.Gs2Chat.Result.PostByUserIdResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.postByUserId(
    new PostByUserIdRequest()
        .withNamespaceName(null)
        .withRoomName("$room2.name")
        .withUserId("user-0002")
        .withCategory(null)
        .withMetadata("MESSAGE_0003")
        .withPassword("password-0002"),
    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.postByUserId(
        new Gs2Chat.PostByUserIdRequest()
            .withNamespaceName(null)
            .withRoomName("$room2.name")
            .withUserId("user-0002")
            .withCategory(null)
            .withMetadata("MESSAGE_0003")
            .withPassword("password-0002")
    );
    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.post_by_user_id(
        chat.PostByUserIdRequest()
            .with_namespace_name(None)
            .with_room_name(self.room2.name)
            .with_user_id('user-0002')
            .with_category(None)
            .with_metadata('MESSAGE_0003')
            .with_password('password-0002')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.post_by_user_id({
    namespaceName=nil,
    roomName='$room2.name',
    userId='user-0002',
    category=nil,
    metadata='MESSAGE_0003',
    password='password-0002',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ユーザIDを指定してメッセージを投稿

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
userId string ~ 128文字 ユーザーID
category int 0 ~ 9223372036854775807 メッセージの種類を分類したい時の種類番号
metadata string ~ 1024文字 メタデータ
password string ~ 128文字 パスワード

Result

説明
item Message 投稿したメッセージ

getMessage

getMessage

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.GetMessage(
    &chat.GetMessageRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        MessageName: pointy.String("$message1.name"),
    }
)
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\GetMessageRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getMessage(
        (new GetMessageRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withMessageName(self::$message1.name)
    );
    $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.GetMessageRequest;
import io.gs2.chat.result.GetMessageResult;

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

try {
    GetMessageResult result = client.getMessage(
        new GetMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withMessageName("$message1.name")
    );
    Message 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.GetMessageRequest;
using Gs2.Gs2Chat.Result.GetMessageResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getMessage(
    new GetMessageRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withMessageName("$message1.name"),
    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.getMessage(
        new Gs2Chat.GetMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withMessageName("$message1.name")
    );
    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_message(
        chat.GetMessageRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_message_name(self.message1.name)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.get_message({
    namespaceName='namespace1',
    roomName='$room1.name',
    messageName='$message1.name',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

メッセージを取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
messageName string UUID ~ 36文字 メッセージ名

Result

説明
item Message メッセージ

deleteMessage

deleteMessage

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.DeleteMessage(
    &chat.DeleteMessageRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        MessageName: pointy.String("$message1.name"),
    }
)
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\DeleteMessageRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteMessage(
        (new DeleteMessageRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withMessageName(self::$message1.name)
    );
    $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.DeleteMessageRequest;
import io.gs2.chat.result.DeleteMessageResult;

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

try {
    DeleteMessageResult result = client.deleteMessage(
        new DeleteMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withMessageName("$message1.name")
    );
    Message 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.DeleteMessageRequest;
using Gs2.Gs2Chat.Result.DeleteMessageResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.deleteMessage(
    new DeleteMessageRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withMessageName("$message1.name"),
    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.deleteMessage(
        new Gs2Chat.DeleteMessageRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withMessageName("$message1.name")
    );
    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_message(
        chat.DeleteMessageRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_message_name(self.message1.name)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.delete_message({
    namespaceName='namespace1',
    roomName='$room1.name',
    messageName='$message1.name',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

メッセージを削除

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 ルーム名
messageName string UUID ~ 36文字 メッセージ名

Result

説明
item Message 削除したメッセージ

describeSubscribes

describeSubscribes

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.DescribeSubscribes(
    &chat.DescribeSubscribesRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("$access_token_0001"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeSubscribesRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeSubscribes(
        (new DescribeSubscribesRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->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.DescribeSubscribesRequest;
import io.gs2.chat.result.DescribeSubscribesResult;

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

try {
    DescribeSubscribesResult result = client.describeSubscribes(
        new DescribeSubscribesRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Subscribe> 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.DescribeSubscribesRequest;
using Gs2.Gs2Chat.Result.DescribeSubscribesResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeSubscribes(
    new DescribeSubscribesRequest()
        .withNamespaceName("namespace1")
        .withAccessToken("$access_token_0001")
        .withPageToken(null)
        .withLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as 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.describeSubscribes(
        new Gs2Chat.DescribeSubscribesRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import 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_subscribes(
        chat.DescribeSubscribesRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.describe_subscribes({
    namespaceName='namespace1',
    accessToken='$access_token_0001',
    pageToken=nil,
    limit=nil,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

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

購読しているルームの一覧取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
accessToken string ~ 128文字 ユーザーID
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items Subscribe[] 購読のリスト
nextPageToken string リストの続きを取得するためのページトークン

describeSubscribesByUserId

describeSubscribesByUserId

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.DescribeSubscribesByUserId(
    &chat.DescribeSubscribesByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        UserId: pointy.String("user-0001"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Chat\Gs2ChatRestClient;
use Gs2\Chat\Request\DescribeSubscribesByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeSubscribesByUserId(
        (new DescribeSubscribesByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.chat.rest.Gs2ChatRestClient;
import io.gs2.chat.request.DescribeSubscribesByUserIdRequest;
import io.gs2.chat.result.DescribeSubscribesByUserIdResult;

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

try {
    DescribeSubscribesByUserIdResult result = client.describeSubscribesByUserId(
        new DescribeSubscribesByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Subscribe> 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.DescribeSubscribesByUserIdRequest;
using Gs2.Gs2Chat.Result.DescribeSubscribesByUserIdResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeSubscribesByUserId(
    new DescribeSubscribesByUserIdRequest()
        .withNamespaceName("namespace1")
        .withUserId("user-0001")
        .withPageToken(null)
        .withLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as 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.describeSubscribesByUserId(
        new Gs2Chat.DescribeSubscribesByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import 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_subscribes_by_user_id(
        chat.DescribeSubscribesByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.describe_subscribes_by_user_id({
    namespaceName='namespace1',
    userId='user-0001',
    pageToken=nil,
    limit=nil,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

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

ユーザIDを指定して購読しているルームの一覧取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
userId string ~ 128文字 ユーザーID
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items Subscribe[] 購読のリスト
nextPageToken string リストの続きを取得するためのページトークン

describeSubscribesByRoomName

describeSubscribesByRoomName

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.DescribeSubscribesByRoomName(
    &chat.DescribeSubscribesByRoomNameRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        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\DescribeSubscribesByRoomNameRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeSubscribesByRoomName(
        (new DescribeSubscribesByRoomNameRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->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.DescribeSubscribesByRoomNameRequest;
import io.gs2.chat.result.DescribeSubscribesByRoomNameResult;

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

try {
    DescribeSubscribesByRoomNameResult result = client.describeSubscribesByRoomName(
        new DescribeSubscribesByRoomNameRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Subscribe> 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.DescribeSubscribesByRoomNameRequest;
using Gs2.Gs2Chat.Result.DescribeSubscribesByRoomNameResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeSubscribesByRoomName(
    new DescribeSubscribesByRoomNameRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .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.describeSubscribesByRoomName(
        new Gs2Chat.DescribeSubscribesByRoomNameRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .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_subscribes_by_room_name(
        chat.DescribeSubscribesByRoomNameRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .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_subscribes_by_room_name({
    namespaceName='namespace1',
    roomName='$room1.name',
    pageToken=nil,
    limit=nil,
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

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

ルーム名を指定して購読しているユーザの一覧取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン
limit int 30 1 ~ 1000 データの取得件数

Result

説明
items Subscribe[] 購読のリスト
nextPageToken string リストの続きを取得するためのページトークン

subscribe

subscribe

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.Subscribe(
    &chat.SubscribeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        AccessToken: pointy.String("$access_token_0001"),
        NotificationTypes: []chat.NotificationType{
            chat.NotificationType{
            },
        },
    }
)
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\SubscribeRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->subscribe(
        (new SubscribeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withAccessToken(self::$accessToken0001)
            ->withNotificationTypes([    (new \Gs2\Chat\Model\NotificationType()),
            ])
    );
    $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.SubscribeRequest;
import io.gs2.chat.result.SubscribeResult;

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

try {
    SubscribeResult result = client.subscribe(
        new SubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
            .withNotificationTypes(Arrays.asList(
                new io.gs2.chat.model.NotificationType()
            ))
    );
    Subscribe 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.SubscribeRequest;
using Gs2.Gs2Chat.Result.SubscribeResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.subscribe(
    new SubscribeRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withAccessToken("$access_token_0001")
        .withNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            new Gs2.Gs2Chat.Model.NotificationType()
        }),
    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.subscribe(
        new Gs2Chat.SubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
            .withNotificationTypes([
                new Gs2Chat.Model.NotificationType()
            ])
    );
    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.subscribe(
        chat.SubscribeRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
            .with_notification_types([    chat.NotificationType(),
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.subscribe({
    namespaceName='namespace1',
    roomName='$room1.name',
    accessToken='$access_token_0001',
    notificationTypes={
        {
        }
    },
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ルームを購読

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
accessToken string ~ 128文字 ユーザーID
notificationTypes NotificationType[] [] 新着メッセージ通知を受け取るカテゴリリスト

Result

説明
item Subscribe 購読した購読

subscribeByUserId

subscribeByUserId

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.SubscribeByUserId(
    &chat.SubscribeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        UserId: pointy.String("user-0001"),
        NotificationTypes: []chat.NotificationType{
            {},
        },
    }
)
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\SubscribeByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->subscribeByUserId(
        (new SubscribeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withUserId("user-0001")
            ->withNotificationTypes([    {},
            ])
    );
    $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.SubscribeByUserIdRequest;
import io.gs2.chat.result.SubscribeByUserIdResult;

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

try {
    SubscribeByUserIdResult result = client.subscribeByUserId(
        new SubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-0001")
            .withNotificationTypes(Arrays.asList(
                {}
            ))
    );
    Subscribe 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.SubscribeByUserIdRequest;
using Gs2.Gs2Chat.Result.SubscribeByUserIdResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.subscribeByUserId(
    new SubscribeByUserIdRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withUserId("user-0001")
        .withNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            {}
        }),
    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.subscribeByUserId(
        new Gs2Chat.SubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-0001")
            .withNotificationTypes([
                {}
            ])
    );
    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.subscribe_by_user_id(
        chat.SubscribeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_notification_types([    {},
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.subscribe_by_user_id({
    namespaceName='namespace1',
    roomName='$room1.name',
    userId='user-0001',
    notificationTypes={
        {}
    },
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ユーザIDを指定してルームを購読

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
userId string ~ 128文字 ユーザーID
notificationTypes NotificationType[] [] 新着メッセージ通知を受け取るカテゴリリスト

Result

説明
item Subscribe 購読した購読

getSubscribe

getSubscribe

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.GetSubscribe(
    &chat.GetSubscribeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        AccessToken: pointy.String("$access_token_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\GetSubscribeRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getSubscribe(
        (new GetSubscribeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->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.GetSubscribeRequest;
import io.gs2.chat.result.GetSubscribeResult;

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

try {
    GetSubscribeResult result = client.getSubscribe(
        new GetSubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
    );
    Subscribe 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.GetSubscribeRequest;
using Gs2.Gs2Chat.Result.GetSubscribeResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getSubscribe(
    new GetSubscribeRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withAccessToken("$access_token_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.getSubscribe(
        new Gs2Chat.GetSubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_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_subscribe(
        chat.GetSubscribeRequest()
            .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.get_subscribe({
    namespaceName='namespace1',
    roomName='$room1.name',
    accessToken='$access_token_0001',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

購読を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
accessToken string ~ 128文字 ユーザーID

Result

説明
item Subscribe 購読

getSubscribeByUserId

getSubscribeByUserId

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.GetSubscribeByUserId(
    &chat.GetSubscribeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        UserId: pointy.String("user-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\GetSubscribeByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getSubscribeByUserId(
        (new GetSubscribeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withUserId("user-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.GetSubscribeByUserIdRequest;
import io.gs2.chat.result.GetSubscribeByUserIdResult;

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

try {
    GetSubscribeByUserIdResult result = client.getSubscribeByUserId(
        new GetSubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-0001")
    );
    Subscribe 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.GetSubscribeByUserIdRequest;
using Gs2.Gs2Chat.Result.GetSubscribeByUserIdResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getSubscribeByUserId(
    new GetSubscribeByUserIdRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withUserId("user-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.getSubscribeByUserId(
        new Gs2Chat.GetSubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-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_subscribe_by_user_id(
        chat.GetSubscribeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.get_subscribe_by_user_id({
    namespaceName='namespace1',
    roomName='$room1.name',
    userId='user-0001',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ユーザIDを指定して購読を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
userId string ~ 128文字 ユーザーID

Result

説明
item Subscribe 購読

updateNotificationType

updateNotificationType

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.UpdateNotificationType(
    &chat.UpdateNotificationTypeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        AccessToken: pointy.String("$access_token_0001"),
        NotificationTypes: []chat.NotificationType{
            {},
        },
    }
)
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\UpdateNotificationTypeRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNotificationType(
        (new UpdateNotificationTypeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withAccessToken(self::$accessToken0001)
            ->withNotificationTypes([    {},
            ])
    );
    $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.UpdateNotificationTypeRequest;
import io.gs2.chat.result.UpdateNotificationTypeResult;

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

try {
    UpdateNotificationTypeResult result = client.updateNotificationType(
        new UpdateNotificationTypeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
            .withNotificationTypes(Arrays.asList(
                {}
            ))
    );
    Subscribe 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.UpdateNotificationTypeRequest;
using Gs2.Gs2Chat.Result.UpdateNotificationTypeResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.updateNotificationType(
    new UpdateNotificationTypeRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withAccessToken("$access_token_0001")
        .withNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            {}
        }),
    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.updateNotificationType(
        new Gs2Chat.UpdateNotificationTypeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
            .withNotificationTypes([
                {}
            ])
    );
    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_notification_type(
        chat.UpdateNotificationTypeRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_access_token(self.access_token_0001)
            .with_notification_types([    {},
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.update_notification_type({
    namespaceName='namespace1',
    roomName='$room1.name',
    accessToken='$access_token_0001',
    notificationTypes={
        {}
    },
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

通知方法を更新

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
accessToken string ~ 128文字 ユーザーID
notificationTypes NotificationType[] [] 新着メッセージ通知を受け取るカテゴリリスト

Result

説明
item Subscribe 更新した購読

updateNotificationTypeByUserId

updateNotificationTypeByUserId

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.UpdateNotificationTypeByUserId(
    &chat.UpdateNotificationTypeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        UserId: pointy.String("user-0001"),
        NotificationTypes: []chat.NotificationType{
            {},
        },
    }
)
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\UpdateNotificationTypeByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNotificationTypeByUserId(
        (new UpdateNotificationTypeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withUserId("user-0001")
            ->withNotificationTypes([    {},
            ])
    );
    $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.UpdateNotificationTypeByUserIdRequest;
import io.gs2.chat.result.UpdateNotificationTypeByUserIdResult;

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

try {
    UpdateNotificationTypeByUserIdResult result = client.updateNotificationTypeByUserId(
        new UpdateNotificationTypeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-0001")
            .withNotificationTypes(Arrays.asList(
                {}
            ))
    );
    Subscribe 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.UpdateNotificationTypeByUserIdRequest;
using Gs2.Gs2Chat.Result.UpdateNotificationTypeByUserIdResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.updateNotificationTypeByUserId(
    new UpdateNotificationTypeByUserIdRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withUserId("user-0001")
        .withNotificationTypes(new Gs2.Gs2Chat.Model.NotificationType[] {
            {}
        }),
    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.updateNotificationTypeByUserId(
        new Gs2Chat.UpdateNotificationTypeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-0001")
            .withNotificationTypes([
                {}
            ])
    );
    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_notification_type_by_user_id(
        chat.UpdateNotificationTypeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
            .with_notification_types([    {},
            ])
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.update_notification_type_by_user_id({
    namespaceName='namespace1',
    roomName='$room1.name',
    userId='user-0001',
    notificationTypes={
        {}
    },
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ユーザIDを指定して通知方法を更新

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
userId string ~ 128文字 ユーザーID
notificationTypes NotificationType[] [] 新着メッセージ通知を受け取るカテゴリリスト

Result

説明
item Subscribe 更新した購読

unsubscribe

unsubscribe

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.Unsubscribe(
    &chat.UnsubscribeRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        AccessToken: pointy.String("$access_token_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\UnsubscribeRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->unsubscribe(
        (new UnsubscribeRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->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.UnsubscribeRequest;
import io.gs2.chat.result.UnsubscribeResult;

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

try {
    UnsubscribeResult result = client.unsubscribe(
        new UnsubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_0001")
    );
    Subscribe 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.UnsubscribeRequest;
using Gs2.Gs2Chat.Result.UnsubscribeResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.unsubscribe(
    new UnsubscribeRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withAccessToken("$access_token_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.unsubscribe(
        new Gs2Chat.UnsubscribeRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withAccessToken("$access_token_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.unsubscribe(
        chat.UnsubscribeRequest()
            .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.unsubscribe({
    namespaceName='namespace1',
    roomName='$room1.name',
    accessToken='$access_token_0001',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

購読の購読を解除

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
accessToken string ~ 128文字 ユーザーID

Result

説明
item Subscribe 解除した購読

unsubscribeByUserId

unsubscribeByUserId

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.UnsubscribeByUserId(
    &chat.UnsubscribeByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        RoomName: pointy.String("$room1.name"),
        UserId: pointy.String("user-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\UnsubscribeByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->unsubscribeByUserId(
        (new UnsubscribeByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withRoomName(self::$room1.name)
            ->withUserId("user-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.UnsubscribeByUserIdRequest;
import io.gs2.chat.result.UnsubscribeByUserIdResult;

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

try {
    UnsubscribeByUserIdResult result = client.unsubscribeByUserId(
        new UnsubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-0001")
    );
    Subscribe 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.UnsubscribeByUserIdRequest;
using Gs2.Gs2Chat.Result.UnsubscribeByUserIdResult;

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.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.unsubscribeByUserId(
    new UnsubscribeByUserIdRequest()
        .withNamespaceName("namespace1")
        .withRoomName("$room1.name")
        .withUserId("user-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.unsubscribeByUserId(
        new Gs2Chat.UnsubscribeByUserIdRequest()
            .withNamespaceName("namespace1")
            .withRoomName("$room1.name")
            .withUserId("user-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.unsubscribe_by_user_id(
        chat.UnsubscribeByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_room_name(self.room1.name)
            .with_user_id('user-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('chat')

api_result = client.unsubscribe_by_user_id({
    namespaceName='namespace1',
    roomName='$room1.name',
    userId='user-0001',
});

if(api_result.isError) then
    # エラー発生時
    fail(api_result['statusCode'], api_result['message'])
end

result = api_result.result
item = result.item;

ユーザIDを指定して購読の購読を解除

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
roomName string ~ 128文字 購読するルーム名
userId string ~ 128文字 ユーザーID

Result

説明
item Subscribe 解除した購読