GS2-Lock SDK API リファレンス

モデル

Namespace

ネームスペース

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

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

有効化条件必須デフォルト値の制限説明
namespaceIdstring~ 1024文字ネームスペースGRN
namestring~ 32文字ネームスペース名
descriptionstring~ 1024文字説明文
logSettingLogSettingログの出力設定
createdAtlong作成日時
updatedAtlong最終更新日時
revisionlong0~ 9223372036854775805リビジョン

Mutex

ミューテックス GS2 の提供するミューテックスは再入可能ロックの一種です。

ロックを取得する際にはトランザクションIDを指定し、同一トランザクションIDを指定した場合にのみ再度ロックを取得できます。 参照カウンタを持つため、解放するときには同回数のアンロック処理が必要です。

有効化条件必須デフォルト値の制限説明
mutexIdstring~ 1024文字ミューテックスGRN
userIdstring~ 128文字ユーザーID
propertyIdstring~ 1024文字プロパティID
transactionIdstring~ 256文字ロックを取得したトランザクションID
createdAtlong作成日時
revisionlong0~ 9223372036854775805リビジョン

LogSetting

ログの書き出し設定

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

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

メソッド

describeNamespaces

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

Request

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

Result

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

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &lock.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\Lock\Gs2LockRestClient;
use Gs2\Lock\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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.DescribeNamespacesRequest;
import io.gs2.lock.result.DescribeNamespacesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2LockRestClient client = new Gs2LockRestClient(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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.DescribeNamespacesRequest;
using Gs2.Gs2Lock.Result.DescribeNamespacesResult;

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

AsyncResult<Gs2.Gs2Lock.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Lock.Request.DescribeNamespacesRequest()
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

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

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

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

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

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

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

createNamespace

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

Request

有効化条件必須デフォルト値の制限説明
namestring~ 32文字ネームスペース名
descriptionstring~ 1024文字説明文
logSettingLogSettingログの出力設定

Result

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

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &lock.CreateNamespaceRequest {
        Name: pointy.String("namespace1"),
        Description: nil,
        LogSetting: &lock.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\Lock\Gs2LockRestClient;
use Gs2\Lock\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)
            ->withLogSetting((new \Gs2\Lock\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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.CreateNamespaceRequest;
import io.gs2.lock.result.CreateNamespaceResult;

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

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

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

AsyncResult<Gs2.Gs2Lock.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Lock.Request.CreateNamespaceRequest()
        .WithName("namespace1")
        .WithDescription(null)
        .WithLogSetting(new Gs2.Gs2Lock.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 Gs2Lock from '@/gs2/lock';

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

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

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

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

api_result = client.create_namespace({
    name="namespace1",
    description=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

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

result = api_result.result
item = result.item;

getNamespaceStatus

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

Request

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

Result

説明
statusstring

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &lock.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\Lock\Gs2LockRestClient;
use Gs2\Lock\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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.GetNamespaceStatusRequest;
import io.gs2.lock.result.GetNamespaceStatusResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2LockRestClient client = new Gs2LockRestClient(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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.GetNamespaceStatusRequest;
using Gs2.Gs2Lock.Result.GetNamespaceStatusResult;

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

AsyncResult<Gs2.Gs2Lock.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Lock.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

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

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

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

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

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

result = api_result.result
status = result.status;

getNamespace

ネームスペースを取得

Request

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

Result

説明
itemNamespaceネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &lock.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\Lock\Gs2LockRestClient;
use Gs2\Lock\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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.GetNamespaceRequest;
import io.gs2.lock.result.GetNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
session.connect();
Gs2LockRestClient client = new Gs2LockRestClient(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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.GetNamespaceRequest;
using Gs2.Gs2Lock.Result.GetNamespaceResult;

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

AsyncResult<Gs2.Gs2Lock.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Lock.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

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

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

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

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

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

result = api_result.result
item = result.item;

updateNamespace

ネームスペースを更新

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
descriptionstring~ 1024文字説明文
logSettingLogSettingログの出力設定

Result

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

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &lock.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace1"),
        Description: pointy.String("description1"),
        LogSetting: &lock.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\Lock\Gs2LockRestClient;
use Gs2\Lock\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")
            ->withLogSetting((new \Gs2\Lock\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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.UpdateNamespaceRequest;
import io.gs2.lock.result.UpdateNamespaceResult;

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

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withLogSetting(new io.gs2.lock.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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.UpdateNamespaceRequest;
using Gs2.Gs2Lock.Result.UpdateNamespaceResult;

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

AsyncResult<Gs2.Gs2Lock.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Lock.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace1")
        .WithDescription("description1")
        .WithLogSetting(new Gs2.Gs2Lock.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 Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.updateNamespace(
        new Gs2Lock.UpdateNamespaceRequest()
            .withNamespaceName("namespace1")
            .withDescription("description1")
            .withLogSetting(new Gs2Lock.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 lock

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

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

api_result = client.update_namespace({
    namespaceName="namespace1",
    description="description1",
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1",
    },
})

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

result = api_result.result
item = result.item;

deleteNamespace

ネームスペースを削除

Request

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

Result

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

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName(self::namespace1)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.DeleteNamespaceRequest;
import io.gs2.lock.result.DeleteNamespaceResult;

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

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

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

AsyncResult<Gs2.Gs2Lock.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Lock.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

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

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

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

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

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

result = api_result.result
item = result.item;

describeMutexes

ミューテックスの一覧を取得

Request

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

Result

説明
itemsList<Mutex>ミューテックスのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.DescribeMutexes(
    &lock.DescribeMutexesRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("accessToken-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\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\DescribeMutexesRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeMutexes(
        (new DescribeMutexesRequest())
            ->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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.DescribeMutexesRequest;
import io.gs2.lock.result.DescribeMutexesResult;

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

try {
    DescribeMutexesResult result = client.describeMutexes(
        new DescribeMutexesRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Mutex> 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.DescribeMutexesRequest;
using Gs2.Gs2Lock.Result.DescribeMutexesResult;

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

AsyncResult<Gs2.Gs2Lock.Result.DescribeMutexesResult> asyncResult = null;
yield return client.DescribeMutexes(
    new Gs2.Gs2Lock.Request.DescribeMutexesRequest()
        .WithNamespaceName("namespace1")
        .WithAccessToken("accessToken-0001")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.describeMutexes(
        new Gs2Lock.DescribeMutexesRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.describe_mutexes(
        lock.DescribeMutexesRequest()
            .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('lock')

api_result = client.describe_mutexes({
    namespaceName="namespace1",
    accessToken="accessToken-0001",
    pageToken=nil,
    limit=nil,
})

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

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

describeMutexesByUserId

ユーザーIDを指定してミューテックスの一覧を取得

Request

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

Result

説明
itemsList<Mutex>ミューテックスのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

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

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

try {
    DescribeMutexesByUserIdResult result = client.describeMutexesByUserId(
        new DescribeMutexesByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    List<Mutex> 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.DescribeMutexesByUserIdRequest;
using Gs2.Gs2Lock.Result.DescribeMutexesByUserIdResult;

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

AsyncResult<Gs2.Gs2Lock.Result.DescribeMutexesByUserIdResult> asyncResult = null;
yield return client.DescribeMutexesByUserId(
    new Gs2.Gs2Lock.Request.DescribeMutexesByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithUserId("user-0001")
        .WithPageToken(null)
        .WithLimit(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.describeMutexesByUserId(
        new Gs2Lock.DescribeMutexesByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.describe_mutexes_by_user_id(
        lock.DescribeMutexesByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_page_token(None)
            .with_limit(None)
            .with_time_offset_token(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.describe_mutexes_by_user_id({
    namespaceName="namespace1",
    userId="user-0001",
    pageToken=nil,
    limit=nil,
    timeOffsetToken=nil,
})

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

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

lock

ミューテックスを取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
propertyIdstring~ 1024文字プロパティID
accessTokenstring~ 128文字ユーザーID
transactionIdstring~ 256文字ロックを取得したトランザクションID
ttllong~ 9223372036854775805ロックを取得する期間(秒)

Result

説明
itemMutexミューテックス

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.Lock(
    &lock.LockRequest {
        NamespaceName: pointy.String("namespace1"),
        PropertyId: pointy.String("property-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        TransactionId: pointy.String("transaction-0001"),
        Ttl: pointy.Int64(100000),
    }
)
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\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\LockRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->lock(
        (new LockRequest())
            ->withNamespaceName(self::namespace1)
            ->withPropertyId("property-0001")
            ->withAccessToken(self::$accessToken0001)
            ->withTransactionId("transaction-0001")
            ->withTtl(100000)
    );
    $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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.LockRequest;
import io.gs2.lock.result.LockResult;

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

try {
    LockResult result = client.lock(
        new LockRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withAccessToken("accessToken-0001")
            .withTransactionId("transaction-0001")
            .withTtl(100000L)
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.LockRequest;
using Gs2.Gs2Lock.Result.LockResult;

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

AsyncResult<Gs2.Gs2Lock.Result.LockResult> asyncResult = null;
yield return client.Lock(
    new Gs2.Gs2Lock.Request.LockRequest()
        .WithNamespaceName("namespace1")
        .WithPropertyId("property-0001")
        .WithAccessToken("accessToken-0001")
        .WithTransactionId("transaction-0001")
        .WithTtl(100000L),
    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 Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.lock(
        new Gs2Lock.LockRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withAccessToken("accessToken-0001")
            .withTransactionId("transaction-0001")
            .withTtl(100000)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.lock(
        lock.LockRequest()
            .with_namespace_name(self.hash1)
            .with_property_id('property-0001')
            .with_access_token(self.access_token_0001)
            .with_transaction_id('transaction-0001')
            .with_ttl(100000)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.lock({
    namespaceName="namespace1",
    propertyId="property-0001",
    accessToken="accessToken-0001",
    transactionId="transaction-0001",
    ttl=100000,
})

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

result = api_result.result
item = result.item;

lockByUserId

ユーザIDを指定してミューテックスを取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
propertyIdstring~ 1024文字プロパティID
userIdstring~ 128文字ユーザーID
transactionIdstring~ 256文字ロックを取得したトランザクションID
ttllong~ 9223372036854775805ロックを取得する期間(秒)
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
itemMutexミューテックス

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.LockByUserId(
    &lock.LockByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        PropertyId: pointy.String("property-0001"),
        UserId: pointy.String("user-0001"),
        TransactionId: pointy.String("transaction-0001"),
        Ttl: pointy.Int64(10),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\LockByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->lockByUserId(
        (new LockByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withPropertyId("property-0001")
            ->withUserId("user-0001")
            ->withTransactionId("transaction-0001")
            ->withTtl(10)
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.LockByUserIdRequest;
import io.gs2.lock.result.LockByUserIdResult;

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

try {
    LockByUserIdResult result = client.lockByUserId(
        new LockByUserIdRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withUserId("user-0001")
            .withTransactionId("transaction-0001")
            .withTtl(10L)
            .withTimeOffsetToken(null)
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.LockByUserIdRequest;
using Gs2.Gs2Lock.Result.LockByUserIdResult;

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

AsyncResult<Gs2.Gs2Lock.Result.LockByUserIdResult> asyncResult = null;
yield return client.LockByUserId(
    new Gs2.Gs2Lock.Request.LockByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithPropertyId("property-0001")
        .WithUserId("user-0001")
        .WithTransactionId("transaction-0001")
        .WithTtl(10L)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.lockByUserId(
        new Gs2Lock.LockByUserIdRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withUserId("user-0001")
            .withTransactionId("transaction-0001")
            .withTtl(10)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.lock_by_user_id(
        lock.LockByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_property_id('property-0001')
            .with_user_id('user-0001')
            .with_transaction_id('transaction-0001')
            .with_ttl(10)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.lock_by_user_id({
    namespaceName="namespace1",
    propertyId="property-0001",
    userId="user-0001",
    transactionId="transaction-0001",
    ttl=10,
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;

unlock

ミューテックスを解放

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
propertyIdstring~ 1024文字プロパティID
accessTokenstring~ 128文字ユーザーID
transactionIdstring~ 256文字ロックを取得したトランザクションID

Result

説明
itemMutexミューテックス

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.Unlock(
    &lock.UnlockRequest {
        NamespaceName: pointy.String("namespace1"),
        PropertyId: pointy.String("property-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        TransactionId: pointy.String("transaction-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\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\UnlockRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->unlock(
        (new UnlockRequest())
            ->withNamespaceName(self::namespace1)
            ->withPropertyId("property-0001")
            ->withAccessToken(self::$accessToken0001)
            ->withTransactionId("transaction-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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.UnlockRequest;
import io.gs2.lock.result.UnlockResult;

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

try {
    UnlockResult result = client.unlock(
        new UnlockRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withAccessToken("accessToken-0001")
            .withTransactionId("transaction-0001")
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.UnlockRequest;
using Gs2.Gs2Lock.Result.UnlockResult;

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

AsyncResult<Gs2.Gs2Lock.Result.UnlockResult> asyncResult = null;
yield return client.Unlock(
    new Gs2.Gs2Lock.Request.UnlockRequest()
        .WithNamespaceName("namespace1")
        .WithPropertyId("property-0001")
        .WithAccessToken("accessToken-0001")
        .WithTransactionId("transaction-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 Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.unlock(
        new Gs2Lock.UnlockRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withAccessToken("accessToken-0001")
            .withTransactionId("transaction-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.unlock(
        lock.UnlockRequest()
            .with_namespace_name(self.hash1)
            .with_property_id('property-0001')
            .with_access_token(self.access_token_0001)
            .with_transaction_id('transaction-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.unlock({
    namespaceName="namespace1",
    propertyId="property-0001",
    accessToken="accessToken-0001",
    transactionId="transaction-0001",
})

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

result = api_result.result
item = result.item;

unlockByUserId

ユーザIDを指定してミューテックスを解放

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
propertyIdstring~ 1024文字プロパティID
userIdstring~ 128文字ユーザーID
transactionIdstring~ 256文字ロックを取得したトランザクションID
timeOffsetTokenstring~ 1024文字タイムオフセットトークン

Result

説明
itemMutexミューテックス

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.UnlockByUserId(
    &lock.UnlockByUserIdRequest {
        NamespaceName: pointy.String("namespace1"),
        PropertyId: pointy.String("property-0001"),
        UserId: pointy.String("user-0001"),
        TransactionId: pointy.String("transaction-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\UnlockByUserIdRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->unlockByUserId(
        (new UnlockByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withPropertyId("property-0001")
            ->withUserId("user-0001")
            ->withTransactionId("transaction-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.UnlockByUserIdRequest;
import io.gs2.lock.result.UnlockByUserIdResult;

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

try {
    UnlockByUserIdResult result = client.unlockByUserId(
        new UnlockByUserIdRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withUserId("user-0001")
            .withTransactionId("transaction-0001")
            .withTimeOffsetToken(null)
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.UnlockByUserIdRequest;
using Gs2.Gs2Lock.Result.UnlockByUserIdResult;

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

AsyncResult<Gs2.Gs2Lock.Result.UnlockByUserIdResult> asyncResult = null;
yield return client.UnlockByUserId(
    new Gs2.Gs2Lock.Request.UnlockByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithPropertyId("property-0001")
        .WithUserId("user-0001")
        .WithTransactionId("transaction-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.unlockByUserId(
        new Gs2Lock.UnlockByUserIdRequest()
            .withNamespaceName("namespace1")
            .withPropertyId("property-0001")
            .withUserId("user-0001")
            .withTransactionId("transaction-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.unlock_by_user_id(
        lock.UnlockByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_property_id('property-0001')
            .with_user_id('user-0001')
            .with_transaction_id('transaction-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.unlock_by_user_id({
    namespaceName="namespace1",
    propertyId="property-0001",
    userId="user-0001",
    transactionId="transaction-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;

getMutex

ミューテックスの状態を取得

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring~ 32文字ネームスペース名
accessTokenstring~ 128文字ユーザーID
propertyIdstring~ 1024文字プロパティID

Result

説明
itemMutexミューテックス

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/lock"
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 := lock.Gs2LockRestClient{
    Session: &session,
}
result, err := client.GetMutex(
    &lock.GetMutexRequest {
        NamespaceName: pointy.String("namespace1"),
        AccessToken: pointy.String("accessToken-0001"),
        PropertyId: pointy.String("property-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\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\GetMutexRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getMutex(
        (new GetMutexRequest())
            ->withNamespaceName(self::namespace1)
            ->withAccessToken(self::$accessToken0001)
            ->withPropertyId("property-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.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.GetMutexRequest;
import io.gs2.lock.result.GetMutexResult;

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

try {
    GetMutexResult result = client.getMutex(
        new GetMutexRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withPropertyId("property-0001")
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.GetMutexRequest;
using Gs2.Gs2Lock.Result.GetMutexResult;

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

AsyncResult<Gs2.Gs2Lock.Result.GetMutexResult> asyncResult = null;
yield return client.GetMutex(
    new Gs2.Gs2Lock.Request.GetMutexRequest()
        .WithNamespaceName("namespace1")
        .WithAccessToken("accessToken-0001")
        .WithPropertyId("property-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 Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.getMutex(
        new Gs2Lock.GetMutexRequest()
            .withNamespaceName("namespace1")
            .withAccessToken("accessToken-0001")
            .withPropertyId("property-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.get_mutex(
        lock.GetMutexRequest()
            .with_namespace_name(self.hash1)
            .with_access_token(self.access_token_0001)
            .with_property_id('property-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.get_mutex({
    namespaceName="namespace1",
    accessToken="accessToken-0001",
    propertyId="property-0001",
})

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

result = api_result.result
item = result.item;

getMutexByUserId

ユーザIDを指定してミューテックスの状態を取得

Request

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

Result

説明
itemMutexミューテックス

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getMutexByUserId(
        (new GetMutexByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withPropertyId("property-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.GetMutexByUserIdRequest;
import io.gs2.lock.result.GetMutexByUserIdResult;

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

try {
    GetMutexByUserIdResult result = client.getMutexByUserId(
        new GetMutexByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPropertyId("property-0001")
            .withTimeOffsetToken(null)
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.GetMutexByUserIdRequest;
using Gs2.Gs2Lock.Result.GetMutexByUserIdResult;

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

AsyncResult<Gs2.Gs2Lock.Result.GetMutexByUserIdResult> asyncResult = null;
yield return client.GetMutexByUserId(
    new Gs2.Gs2Lock.Request.GetMutexByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithUserId("user-0001")
        .WithPropertyId("property-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.getMutexByUserId(
        new Gs2Lock.GetMutexByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPropertyId("property-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.get_mutex_by_user_id(
        lock.GetMutexByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_property_id('property-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.get_mutex_by_user_id({
    namespaceName="namespace1",
    userId="user-0001",
    propertyId="property-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;

deleteMutexByUserId

ミューテックスを削除

Request

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

Result

説明
itemMutex削除したミューテックス

実装例

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

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteMutexByUserId(
        (new DeleteMutexByUserIdRequest())
            ->withNamespaceName(self::namespace1)
            ->withUserId("user-0001")
            ->withPropertyId("property-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.DeleteMutexByUserIdRequest;
import io.gs2.lock.result.DeleteMutexByUserIdResult;

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

try {
    DeleteMutexByUserIdResult result = client.deleteMutexByUserId(
        new DeleteMutexByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPropertyId("property-0001")
            .withTimeOffsetToken(null)
    );
    Mutex 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.Gs2Lock.Gs2LockRestClient;
using Gs2.Gs2Lock.Request.DeleteMutexByUserIdRequest;
using Gs2.Gs2Lock.Result.DeleteMutexByUserIdResult;

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

AsyncResult<Gs2.Gs2Lock.Result.DeleteMutexByUserIdResult> asyncResult = null;
yield return client.DeleteMutexByUserId(
    new Gs2.Gs2Lock.Request.DeleteMutexByUserIdRequest()
        .WithNamespaceName("namespace1")
        .WithUserId("user-0001")
        .WithPropertyId("property-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Lock from '@/gs2/lock';

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

try {
    const result = await client.deleteMutexByUserId(
        new Gs2Lock.DeleteMutexByUserIdRequest()
            .withNamespaceName("namespace1")
            .withUserId("user-0001")
            .withPropertyId("property-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import lock

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

try:
    result = client.delete_mutex_by_user_id(
        lock.DeleteMutexByUserIdRequest()
            .with_namespace_name(self.hash1)
            .with_user_id('user-0001')
            .with_property_id('property-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('lock')

api_result = client.delete_mutex_by_user_id({
    namespaceName="namespace1",
    userId="user-0001",
    propertyId="property-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
item = result.item;