NAV
go python java php typescript csharp GS2-Script

GS2-Gateway

GS2-SDK のリファレンス

モデル

Namespace

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

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

説明
namespaceId string ネームスペースGRN
name string ネームスペース名
description string 説明文
firebaseSecret string Firebase の通知送信に使用するシークレットトークン
logSetting LogSetting ログの出力設定
createdAt long 作成日時
updatedAt long 最終更新日時

WebSocketSession

説明
webSocketSessionId string WebSocketセッションGRN
connectionId string コネクションID
namespaceName string ネームスペース名
userId string ユーザーID
createdAt long 作成日時
updatedAt long 最終更新日時

FirebaseToken

Firebaseデバイストークンはモバイルプッシュ通知を利用する際に必要となります。

GS2-Gateway はゲーム内プッシュ通知機能を提供し、マッチメイキング完了時やミッション達成時にプッシュ通知を受けられますが 通知先のプレイヤーがオフラインだった場合にモバイルプッシュ通知に転送することができます。

その時に通知先のデバイスを特定し、通知するのに使用するのが Firebaseデバイストークン です。 名前の通り Firebase という外部サービスを利用するため、トークンの取得方法などの詳細情報は Firebase のドキュメントをご確認ください。

説明
firebaseTokenId string FirebaseデバイストークンGRN
userId string ユーザーID
token string Firebase Cloud Messaging のデバイストークン
createdAt long 作成日時
updatedAt long 最終更新日時

LogSetting

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

メソッド

describeNamespaces

describeNamespaces

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &gateway.DescribeNamespacesRequest {
        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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DescribeNamespacesRequest;

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

$session->open();

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

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

try {
    DescribeNamespacesResult result = client.describeNamespaces(
        new DescribeNamespacesRequest()
            .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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.DescribeNamespacesRequest;
using Gs2.Gs2Gateway.Result.DescribeNamespacesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GatewayRestClient(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 Gs2Gateway from '@/gs2/gateway';

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

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

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

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

client = gs2('gateway')

api_result = client.describe_namespaces({
    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/gateway"
import "github.com/openlyinc/pointy"

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &gateway.CreateNamespaceRequest {
        Name: pointy.String("namespace1"),
        Description: nil,
        FirebaseSecret: nil,
        LogSetting: &gateway.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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\CreateNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName(self::namespace1)
            ->withDescription(null)
            ->withFirebaseSecret(null)
            ->withLogSetting((new \Gs2\Gateway\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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.CreateNamespaceRequest;
import io.gs2.gateway.result.CreateNamespaceResult;

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

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withFirebaseSecret(null)
            .withLogSetting(new io.gs2.gateway.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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.CreateNamespaceRequest;
using Gs2.Gs2Gateway.Result.CreateNamespaceResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.createNamespace(
    new CreateNamespaceRequest()
        .withName("namespace1")
        .withDescription(null)
        .withFirebaseSecret(null)
        .withLogSetting(new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.createNamespace(
        new Gs2Gateway.CreateNamespaceRequest()
            .withName("namespace1")
            .withDescription(null)
            .withFirebaseSecret(null)
            .withLogSetting(new Gs2Gateway.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 gateway

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

try:
    result = client.create_namespace(
        gateway.CreateNamespaceRequest()
            .with_name(self.hash1)
            .with_description(None)
            .with_firebase_secret(None)
            .with_log_setting(
                gateway.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('gateway')

api_result = client.create_namespace({
    name='namespace1',
    description=nil,
    firebaseSecret=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文字 説明文
firebaseSecret string ~ 1024文字 Firebase の通知送信に使用するシークレットトークン
logSetting LogSetting ログの出力設定

Result

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

getNamespaceStatus

getNamespaceStatus

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &gateway.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetNamespaceStatusRequest;

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

$session->open();

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

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

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.GetNamespaceStatusRequest;
using Gs2.Gs2Gateway.Result.GetNamespaceStatusResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GatewayRestClient(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 Gs2Gateway from '@/gs2/gateway';

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

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

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

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

client = gs2('gateway')

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/gateway"
import "github.com/openlyinc/pointy"

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &gateway.GetNamespaceRequest {
        NamespaceName: pointy.String("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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetNamespaceRequest;

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

$session->open();

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

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

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.GetNamespaceRequest;
using Gs2.Gs2Gateway.Result.GetNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GatewayRestClient(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 Gs2Gateway from '@/gs2/gateway';

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

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

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

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

client = gs2('gateway')

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/gateway"
import "github.com/openlyinc/pointy"

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &gateway.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
        Description: pointy.String("description1"),
        FirebaseSecret: pointy.String("firebase-secret2"),
        LogSetting: &gateway.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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\UpdateNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName(self::namespace1)
            ->withDescription("description1")
            ->withFirebaseSecret("firebase-secret2")
            ->withLogSetting((new \Gs2\Gateway\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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.UpdateNamespaceRequest;
import io.gs2.gateway.result.UpdateNamespaceResult;

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

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withFirebaseSecret("firebase-secret2")
            .withLogSetting(new io.gs2.gateway.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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.UpdateNamespaceRequest;
using Gs2.Gs2Gateway.Result.UpdateNamespaceResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.updateNamespace(
    new UpdateNamespaceRequest()
        .withNamespaceName("namespace1")
        .withDescription("description1")
        .withFirebaseSecret("firebase-secret2")
        .withLogSetting(new Gs2.Gs2Gateway.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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.updateNamespace(
        new Gs2Gateway.UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withFirebaseSecret("firebase-secret2")
            .withLogSetting(new Gs2Gateway.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 gateway

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

try:
    result = client.update_namespace(
        gateway.UpdateNamespaceRequest()
            .with_namespace_name(self.hash1)
            .with_description('description1')
            .with_firebase_secret('firebase-secret2')
            .with_log_setting(
                gateway.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('gateway')

api_result = client.update_namespace({
    namespaceName='namespace1',
    description='description1',
    firebaseSecret='firebase-secret2',
    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文字 説明文
firebaseSecret string ~ 1024文字 Firebase の通知送信に使用するシークレットトークン
logSetting LogSetting ログの出力設定

Result

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

deleteNamespace

deleteNamespace

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &gateway.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\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)
    );
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DeleteNamespaceRequest;
import io.gs2.gateway.result.DeleteNamespaceResult;

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

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace1")
    );
} 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.DeleteNamespaceRequest;
using Gs2.Gs2Gateway.Result.DeleteNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GatewayRestClient(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;
import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';

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

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

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

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

client = gs2('gateway')

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

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

result = api_result.result

ネームスペースを削除

Request

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

Result

説明

describeWebSocketSessions

describeWebSocketSessions

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.DescribeWebSocketSessions(
    &gateway.DescribeWebSocketSessionsRequest {
        NamespaceName: pointy.String("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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DescribeWebSocketSessionsRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeWebSocketSessions(
        (new DescribeWebSocketSessionsRequest())
            ->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DescribeWebSocketSessionsRequest;
import io.gs2.gateway.result.DescribeWebSocketSessionsResult;

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

try {
    DescribeWebSocketSessionsResult result = client.describeWebSocketSessions(
        new DescribeWebSocketSessionsRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<WebSocketSession> 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.DescribeWebSocketSessionsRequest;
using Gs2.Gs2Gateway.Result.DescribeWebSocketSessionsResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeWebSocketSessions(
    new DescribeWebSocketSessionsRequest()
        .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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.describeWebSocketSessions(
        new Gs2Gateway.DescribeWebSocketSessionsRequest()
            .withNamespaceName("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 gateway

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

try:
    result = client.describe_web_socket_sessions(
        gateway.DescribeWebSocketSessionsRequest()
            .with_namespace_name(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('gateway')

api_result = client.describe_web_socket_sessions({
    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;

Websocketセッションの一覧を取得

Request

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

Result

説明
items WebSocketSession[] Websocketセッションのリスト
nextPageToken string リストの続きを取得するためのページトークン

describeWebSocketSessionsByUserId

describeWebSocketSessionsByUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.DescribeWebSocketSessionsByUserId(
    &gateway.DescribeWebSocketSessionsByUserIdRequest {
        NamespaceName: pointy.String("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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DescribeWebSocketSessionsByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeWebSocketSessionsByUserId(
        (new DescribeWebSocketSessionsByUserIdRequest())
            ->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DescribeWebSocketSessionsByUserIdRequest;
import io.gs2.gateway.result.DescribeWebSocketSessionsByUserIdResult;

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

try {
    DescribeWebSocketSessionsByUserIdResult result = client.describeWebSocketSessionsByUserId(
        new DescribeWebSocketSessionsByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<WebSocketSession> 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.DescribeWebSocketSessionsByUserIdRequest;
using Gs2.Gs2Gateway.Result.DescribeWebSocketSessionsByUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.describeWebSocketSessionsByUserId(
    new DescribeWebSocketSessionsByUserIdRequest()
        .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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.describeWebSocketSessionsByUserId(
        new Gs2Gateway.DescribeWebSocketSessionsByUserIdRequest()
            .withNamespaceName("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 gateway

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

try:
    result = client.describe_web_socket_sessions_by_user_id(
        gateway.DescribeWebSocketSessionsByUserIdRequest()
            .with_namespace_name(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('gateway')

api_result = client.describe_web_socket_sessions_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を指定してWebsocketセッションの一覧を取得

Request

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

Result

説明
items WebSocketSession[] Websocketセッションのリスト
nextPageToken string リストの続きを取得するためのページトークン

setUserId

setUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.SetUserId(
    &gateway.SetUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("$access_token_0001"),
        AllowConcurrentAccess: 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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->setUserId(
        (new SetUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->withAllowConcurrentAccess(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetUserIdRequest;
import io.gs2.gateway.result.SetUserIdResult;

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

try {
    SetUserIdResult result = client.setUserId(
        new SetUserIdRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withAllowConcurrentAccess(null)
    );
    WebSocketSession 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.SetUserIdRequest;
using Gs2.Gs2Gateway.Result.SetUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.setUserId(
    new SetUserIdRequest()
        .withNamespaceName("namespace1")
        .withAccessToken("$access_token_0001")
        .withAllowConcurrentAccess(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.setUserId(
        new Gs2Gateway.SetUserIdRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withAllowConcurrentAccess(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.set_user_id(
        gateway.SetUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_allow_concurrent_access(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.set_user_id({
    namespaceName='namespace1',
    accessToken='$access_token_0001',
    allowConcurrentAccess=nil,
});

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

result = api_result.result
item = result.item;

WebsocketセッションにユーザIDを設定

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 128文字 ネームスペース名
connectionId string ~ 128文字 コネクションID
accessToken string ~ 128文字 ユーザーID
allowConcurrentAccess bool true 同時に異なるクライアントからの接続を許容するか

Result

説明
item WebSocketSession 更新したWebsocketセッション

setUserIdByUserId

setUserIdByUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.SetUserIdByUserId(
    &gateway.SetUserIdByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        UserId: pointy.String("user-0001"),
        AllowConcurrentAccess: pointy.Bool(true),
    }
)
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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetUserIdByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->setUserIdByUserId(
        (new SetUserIdByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withAllowConcurrentAccess(True)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetUserIdByUserIdRequest;
import io.gs2.gateway.result.SetUserIdByUserIdResult;

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

try {
    SetUserIdByUserIdResult result = client.setUserIdByUserId(
        new SetUserIdByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withAllowConcurrentAccess(true)
    );
    WebSocketSession 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.SetUserIdByUserIdRequest;
using Gs2.Gs2Gateway.Result.SetUserIdByUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.setUserIdByUserId(
    new SetUserIdByUserIdRequest()
        .withNamespaceName("namespace1")
        .withUserId("user-0001")
        .withAllowConcurrentAccess(true),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.setUserIdByUserId(
        new Gs2Gateway.SetUserIdByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withAllowConcurrentAccess(true)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.set_user_id_by_user_id(
        gateway.SetUserIdByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_allow_concurrent_access(True)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.set_user_id_by_user_id({
    namespaceName='namespace1',
    userId='user-0001',
    allowConcurrentAccess=true,
});

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

result = api_result.result
item = result.item;

WebsocketセッションにユーザIDを設定

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 128文字 ネームスペース名
connectionId string ~ 128文字 コネクションID
userId string ~ 128文字 ユーザーID
allowConcurrentAccess bool true 同時に異なるクライアントからの接続を許容するか

Result

説明
item WebSocketSession 更新したWebsocketセッション

sendNotification

sendNotification

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.SendNotification(
    &gateway.SendNotificationRequest {
        NamespaceName: pointy.String("namespace1"),
        UserId: pointy.String("user-0001"),
        Subject: pointy.String("subject"),
        Payload: pointy.String("payload"),
        EnableTransferMobileNotification: pointy.Bool(true),
        Sound: pointy.String("sound.wav"),
    }
)
if err != nil {
    panic("error occurred")
}
protocol := result.Protocol
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SendNotificationRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->sendNotification(
        (new SendNotificationRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withSubject("subject")
            ->withPayload("payload")
            ->withEnableTransferMobileNotification(True)
            ->withSound("sound.wav")
    );
    $protocol = $result->getProtocol();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SendNotificationRequest;
import io.gs2.gateway.result.SendNotificationResult;

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

try {
    SendNotificationResult result = client.sendNotification(
        new SendNotificationRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withSubject("subject")
            .withPayload("payload")
            .withEnableTransferMobileNotification(true)
            .withSound("sound.wav")
    );
    String protocol = result.getProtocol();
} 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.SendNotificationRequest;
using Gs2.Gs2Gateway.Result.SendNotificationResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.sendNotification(
    new SendNotificationRequest()
        .withNamespaceName("namespace1")
        .withUserId("user-0001")
        .withSubject("subject")
        .withPayload("payload")
        .withEnableTransferMobileNotification(true)
        .withSound("sound.wav"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var protocol = result.Protocol;
import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.sendNotification(
        new Gs2Gateway.SendNotificationRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withSubject("subject")
            .withPayload("payload")
            .withEnableTransferMobileNotification(true)
            .withSound("sound.wav")
    );
    const protocol = result.getProtocol();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.send_notification(
        gateway.SendNotificationRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_subject('subject')
            .with_payload('payload')
            .with_enable_transfer_mobile_notification(True)
            .with_sound('sound.wav')
    )
    protocol = result.protocol
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.send_notification({
    namespaceName='namespace1',
    userId='user-0001',
    subject='subject',
    payload='payload',
    enableTransferMobileNotification=true,
    sound='sound.wav',
});

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

result = api_result.result
protocol = result.protocol;

通知を送信

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 128文字 ネームスペース名
userId string ~ 128文字 ユーザーID
issuer string ~ 256文字 通知元のサービス
subject string ~ 128文字 タイトル
payload string ~ 1024文字 ペイロード
enableTransferMobileNotification bool false 通知先のユーザがオフラインだったときにモバイルプッシュ通知に転送するか
sound string ~ 256文字 再生する音声ファイル名

Result

説明
protocol string 通知に使用したプロトコル

setFirebaseToken

setFirebaseToken

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.SetFirebaseToken(
    &gateway.SetFirebaseTokenRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("$access_token_0001"),
        Token: pointy.String("firebase-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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetFirebaseTokenRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->setFirebaseToken(
        (new SetFirebaseTokenRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->withToken("firebase-token-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetFirebaseTokenRequest;
import io.gs2.gateway.result.SetFirebaseTokenResult;

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

try {
    SetFirebaseTokenResult result = client.setFirebaseToken(
        new SetFirebaseTokenRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withToken("firebase-token-0001")
    );
    FirebaseToken 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.SetFirebaseTokenRequest;
using Gs2.Gs2Gateway.Result.SetFirebaseTokenResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.setFirebaseToken(
    new SetFirebaseTokenRequest()
        .withNamespaceName("namespace1")
        .withAccessToken("$access_token_0001")
        .withToken("firebase-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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.setFirebaseToken(
        new Gs2Gateway.SetFirebaseTokenRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
            .withToken("firebase-token-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.set_firebase_token(
        gateway.SetFirebaseTokenRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_token('firebase-token-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.set_firebase_token({
    namespaceName='namespace1',
    accessToken='$access_token_0001',
    token='firebase-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文字 ネームスペース名
accessToken string ~ 128文字 ユーザーID
token string ~ 1024文字 Firebase Cloud Messaging のデバイストークン

Result

説明
item FirebaseToken 作成したFirebaseデバイストークン

setFirebaseTokenByUserId

setFirebaseTokenByUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.SetFirebaseTokenByUserId(
    &gateway.SetFirebaseTokenByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        UserId: pointy.String("user-0001"),
        Token: pointy.String("firebase-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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SetFirebaseTokenByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->setFirebaseTokenByUserId(
        (new SetFirebaseTokenByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withToken("firebase-token-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SetFirebaseTokenByUserIdRequest;
import io.gs2.gateway.result.SetFirebaseTokenByUserIdResult;

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

try {
    SetFirebaseTokenByUserIdResult result = client.setFirebaseTokenByUserId(
        new SetFirebaseTokenByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withToken("firebase-token-0001")
    );
    FirebaseToken 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.SetFirebaseTokenByUserIdRequest;
using Gs2.Gs2Gateway.Result.SetFirebaseTokenByUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.setFirebaseTokenByUserId(
    new SetFirebaseTokenByUserIdRequest()
        .withNamespaceName("namespace1")
        .withUserId("user-0001")
        .withToken("firebase-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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.setFirebaseTokenByUserId(
        new Gs2Gateway.SetFirebaseTokenByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withToken("firebase-token-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.set_firebase_token_by_user_id(
        gateway.SetFirebaseTokenByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_token('firebase-token-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.set_firebase_token_by_user_id({
    namespaceName='namespace1',
    userId='user-0001',
    token='firebase-token-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文字 ネームスペース名
userId string ~ 128文字 ユーザーID
token string ~ 1024文字 Firebase Cloud Messaging のデバイストークン

Result

説明
item FirebaseToken 作成したFirebaseデバイストークン

getFirebaseToken

getFirebaseToken

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.GetFirebaseToken(
    &gateway.GetFirebaseTokenRequest {
        NamespaceName: pointy.String("namespace1"),
        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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetFirebaseTokenRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getFirebaseToken(
        (new GetFirebaseTokenRequest())
            ->withNamespaceName(self::namespace1)
            ->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetFirebaseTokenRequest;
import io.gs2.gateway.result.GetFirebaseTokenResult;

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

try {
    GetFirebaseTokenResult result = client.getFirebaseToken(
        new GetFirebaseTokenRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
    );
    FirebaseToken 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.GetFirebaseTokenRequest;
using Gs2.Gs2Gateway.Result.GetFirebaseTokenResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getFirebaseToken(
    new GetFirebaseTokenRequest()
        .withNamespaceName("namespace1")
        .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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.getFirebaseToken(
        new Gs2Gateway.GetFirebaseTokenRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.get_firebase_token(
        gateway.GetFirebaseTokenRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.get_firebase_token({
    namespaceName='namespace1',
    accessToken='$access_token_0001',
});

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

result = api_result.result
item = result.item;

Firebaseデバイストークンを取得

Request

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

Result

説明
item FirebaseToken 取得したFirebaseデバイストークン

getFirebaseTokenByUserId

getFirebaseTokenByUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.GetFirebaseTokenByUserId(
    &gateway.GetFirebaseTokenByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\GetFirebaseTokenByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getFirebaseTokenByUserId(
        (new GetFirebaseTokenByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.GetFirebaseTokenByUserIdRequest;
import io.gs2.gateway.result.GetFirebaseTokenByUserIdResult;

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

try {
    GetFirebaseTokenByUserIdResult result = client.getFirebaseTokenByUserId(
        new GetFirebaseTokenByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
    );
    FirebaseToken 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.GetFirebaseTokenByUserIdRequest;
using Gs2.Gs2Gateway.Result.GetFirebaseTokenByUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.getFirebaseTokenByUserId(
    new GetFirebaseTokenByUserIdRequest()
        .withNamespaceName("namespace1")
        .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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.getFirebaseTokenByUserId(
        new Gs2Gateway.GetFirebaseTokenByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.get_firebase_token_by_user_id(
        gateway.GetFirebaseTokenByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.get_firebase_token_by_user_id({
    namespaceName='namespace1',
    userId='user-0001',
});

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

result = api_result.result
item = result.item;

ユーザIDを指定してFirebaseデバイストークンを取得

Request

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

Result

説明
item FirebaseToken 取得したFirebaseデバイストークン

deleteFirebaseToken

deleteFirebaseToken

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.DeleteFirebaseToken(
    &gateway.DeleteFirebaseTokenRequest {
        NamespaceName: pointy.String("namespace1"),
        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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DeleteFirebaseTokenRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteFirebaseToken(
        (new DeleteFirebaseTokenRequest())
            ->withNamespaceName(self::namespace1)
            ->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DeleteFirebaseTokenRequest;
import io.gs2.gateway.result.DeleteFirebaseTokenResult;

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

try {
    DeleteFirebaseTokenResult result = client.deleteFirebaseToken(
        new DeleteFirebaseTokenRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
    );
    FirebaseToken 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.DeleteFirebaseTokenRequest;
using Gs2.Gs2Gateway.Result.DeleteFirebaseTokenResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.deleteFirebaseToken(
    new DeleteFirebaseTokenRequest()
        .withNamespaceName("namespace1")
        .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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.deleteFirebaseToken(
        new Gs2Gateway.DeleteFirebaseTokenRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("$access_token_0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.delete_firebase_token(
        gateway.DeleteFirebaseTokenRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.delete_firebase_token({
    namespaceName='namespace1',
    accessToken='$access_token_0001',
});

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

result = api_result.result
item = result.item;

Firebaseデバイストークンを削除

Request

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

Result

説明
item FirebaseToken 削除したFirebaseデバイストークン

deleteFirebaseTokenByUserId

deleteFirebaseTokenByUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.DeleteFirebaseTokenByUserId(
    &gateway.DeleteFirebaseTokenByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        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\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\DeleteFirebaseTokenByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteFirebaseTokenByUserId(
        (new DeleteFirebaseTokenByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->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.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.DeleteFirebaseTokenByUserIdRequest;
import io.gs2.gateway.result.DeleteFirebaseTokenByUserIdResult;

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

try {
    DeleteFirebaseTokenByUserIdResult result = client.deleteFirebaseTokenByUserId(
        new DeleteFirebaseTokenByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
    );
    FirebaseToken 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.DeleteFirebaseTokenByUserIdRequest;
using Gs2.Gs2Gateway.Result.DeleteFirebaseTokenByUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.deleteFirebaseTokenByUserId(
    new DeleteFirebaseTokenByUserIdRequest()
        .withNamespaceName("namespace1")
        .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 Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.deleteFirebaseTokenByUserId(
        new Gs2Gateway.DeleteFirebaseTokenByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.delete_firebase_token_by_user_id(
        gateway.DeleteFirebaseTokenByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.delete_firebase_token_by_user_id({
    namespaceName='namespace1',
    userId='user-0001',
});

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

result = api_result.result
item = result.item;

ユーザIDを指定してFirebaseデバイストークンを削除

Request

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

Result

説明
item FirebaseToken 削除したFirebaseデバイストークン

sendMobileNotificationByUserId

sendMobileNotificationByUserId

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

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

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

client := gateway.Gs2GatewayRestClient{
    Session: &session,
}
result, err := client.SendMobileNotificationByUserId(
    &gateway.SendMobileNotificationByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        UserId: pointy.String("user-0001"),
        Subject: pointy.String("subject"),
        Payload: pointy.String("payload"),
        Sound: pointy.String("sound.wav"),
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Gateway\Gs2GatewayRestClient;
use Gs2\Gateway\Request\SendMobileNotificationByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->sendMobileNotificationByUserId(
        (new SendMobileNotificationByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withSubject("subject")
            ->withPayload("payload")
            ->withSound("sound.wav")
    );
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.gateway.rest.Gs2GatewayRestClient;
import io.gs2.gateway.request.SendMobileNotificationByUserIdRequest;
import io.gs2.gateway.result.SendMobileNotificationByUserIdResult;

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

try {
    SendMobileNotificationByUserIdResult result = client.sendMobileNotificationByUserId(
        new SendMobileNotificationByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withSubject("subject")
            .withPayload("payload")
            .withSound("sound.wav")
    );
} 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.Gs2Gateway.Gs2GatewayRestClient;
using Gs2.Gs2Gateway.Request.SendMobileNotificationByUserIdRequest;
using Gs2.Gs2Gateway.Result.SendMobileNotificationByUserIdResult;

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

AsyncResult<Gs2.Gs2Account.Result.CreateNamespaceResult> asyncResult = null;
yield return client.sendMobileNotificationByUserId(
    new SendMobileNotificationByUserIdRequest()
        .withNamespaceName("namespace1")
        .withUserId("user-0001")
        .withSubject("subject")
        .withPayload("payload")
        .withSound("sound.wav"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2Gateway from '@/gs2/gateway';

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

try {
    const result = await client.sendMobileNotificationByUserId(
        new Gs2Gateway.SendMobileNotificationByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withSubject("subject")
            .withPayload("payload")
            .withSound("sound.wav")
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import gateway

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

try:
    result = client.send_mobile_notification_by_user_id(
        gateway.SendMobileNotificationByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_subject('subject')
            .with_payload('payload')
            .with_sound('sound.wav')
    )
except core.Gs2Exception as e:
    exit(1)

client = gs2('gateway')

api_result = client.send_mobile_notification_by_user_id({
    namespaceName='namespace1',
    userId='user-0001',
    subject='subject',
    payload='payload',
    sound='sound.wav',
});

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

result = api_result.result

モバイルプッシュ通知を送信

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
userId string ~ 128文字 ユーザーID
subject string ~ 256文字 タイトル
payload string ~ 1024文字 ペイロード
sound string ~ 256文字 再生する音声ファイル名

Result

説明