API Reference of GS2-Lock SDK
Model
Namespace
Namespace
A namespace is a mechanism that allows multiple uses of the same service for different purposes within a single project. Each GS2 service is managed on a per namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.
Therefore, you must create a namespace before you can start using each service.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceId | string | ✓* | ~ 1024 chars | Namespace GRN * Automatically configured on the server | ||
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| logSetting | LogSetting | Log output settings | ||||
| createdAt | long | ✓* | Now | Datetime of creation Unix time, milliseconds * Automatically configured on the server | ||
| updatedAt | long | ✓* | Now | Datetime of last update Unix time, milliseconds * Automatically configured on the server | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
LogSetting
Log Export Settings
Manages log data export settings. This type holds the GS2-Log namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, and debugging.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log namespace GRN
to output logs Must be specified in GRN format starting with “grn:gs2:”. |
Mutex
Mutex The mutex provided by GS2 is a type of re-entrant lock.
When acquiring a lock, a transaction ID is specified, and the lock can be acquired again only if the same transaction ID is specified. Since it has a reference counter, the same number of unlock operations are required when releasing it.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| mutexId | string | ✓* | ~ 1024 chars | Mutex GRN * Automatically configured on the server | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| transactionId | string | ✓ | ~ 256 chars | Transaction ID used for lock acquisition | ||
| createdAt | long | ✓* | Now | Datetime of creation Unix time, milliseconds * Automatically configured on the server | ||
| ttlAt | long | ✓* | Absolute time 1 hour from the current time | Datetime of ttl Unix time, milliseconds | ||
| revision | long | 0 | 0 ~ 9223372036854775805 | Revision |
Methods
describeNamespaces
Get list of namespaces
Get a list of all namespaces in the project. You can use the optional page token to start acquiring data from a specific location in the list. You can also limit the number of namespaces to be acquired.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namePrefix | string | ~ 64 chars | Filter by namespace name prefix | |||
| pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | |||
| limit | int | ✓ | 30 | 1 ~ 1000 | Number of data items to retrieve |
Result
| Type | Description | |
|---|---|---|
| items | List<Namespace> | List of Namespace |
| nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/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 {
NamePrefix: nil,
PageToken: nil,
Limit: nil,
}
)
if err != nil {
panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageTokenuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->describeNamespaces(
(new DescribeNamespacesRequest())
->withNamePrefix(null)
->withPageToken(null)
->withLimit(null)
);
$items = $result->getItems();
$nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.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()
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
List<Namespace> items = result.getItems();
String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
new Gs2.Gs2Lock.Request.DescribeNamespacesRequest()
.WithNamePrefix(null)
.WithPageToken(null)
.WithLimit(null),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;import Gs2Core from '@/gs2/core';
import * as 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()
.withNamePrefix(null)
.withPageToken(null)
.withLimit(null)
);
const items = result.getItems();
const nextPageToken = result.getNextPageToken();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import 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_name_prefix(None)
.with_page_token(None)
.with_limit(None)
)
items = result.items
next_page_token = result.next_page_token
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.describe_namespaces({
namePrefix=nil,
pageToken=nil,
limit=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;client = gs2('lock')
api_result_handler = client.describe_namespaces_async({
namePrefix=nil,
pageToken=nil,
limit=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;createNamespace
Create new namespace
You must specify detailed information including the name, description, and various settings of the namespace.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| logSetting | LogSetting | Log output settings |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | The created Namespace |
Implementation Example
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("namespace-0001"),
Description: nil,
LogSetting: &lock.LogSetting{
LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->createNamespace(
(new CreateNamespaceRequest())
->withName("namespace-0001")
->withDescription(null)
->withLogSetting((new \Gs2\Lock\Model\LogSetting())
->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.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("namespace-0001")
.withDescription(null)
.withLogSetting(new io.gs2.lock.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
new Gs2.Gs2Lock.Request.CreateNamespaceRequest()
.WithName("namespace-0001")
.WithDescription(null)
.WithLogSetting(new Gs2.Gs2Lock.Model.LogSetting()
.WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as 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("namespace-0001")
.withDescription(null)
.withLogSetting(new Gs2Lock.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import 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('namespace-0001')
.with_description(None)
.with_log_setting(
lock.LogSetting()
.with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.create_namespace({
name="namespace-0001",
description=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.create_namespace_async({
name="namespace-0001",
description=nil,
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getNamespaceStatus
Get namespace status
Get the current status of the specified namespace. This includes whether the namespace is active, pending, or in some other state.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| status | string |
Implementation Example
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("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
status := result.Statususe Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->getNamespaceStatus(
(new GetNamespaceStatusRequest())
->withNamespaceName("namespace-0001")
);
$status = $result->getStatus();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.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("namespace-0001")
);
String status = result.getStatus();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
new Gs2.Gs2Lock.Request.GetNamespaceStatusRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;import Gs2Core from '@/gs2/core';
import * as 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("namespace-0001")
);
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('namespace-0001')
)
status = result.status
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.get_namespace_status({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
status = result.status;client = gs2('lock')
api_result_handler = client.get_namespace_status_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
status = result.status;getNamespace
Get namespace
Get detailed information about the specified namespace. This includes the name, description, and other settings of the namespace.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | Namespace |
Implementation Example
import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/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("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->getNamespace(
(new GetNamespaceRequest())
->withNamespaceName("namespace-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.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("namespace-0001")
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
new Gs2.Gs2Lock.Request.GetNamespaceRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as 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("namespace-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_namespace(
lock.GetNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.get_namespace({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.get_namespace_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;updateNamespace
Update namespace
Update the settings of the specified namespace. You can change the description of the namespace and specific settings.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| logSetting | LogSetting | Log output settings |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | The updated namespace |
Implementation Example
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("namespace-0001"),
Description: pointy.String("description1"),
LogSetting: &lock.LogSetting{
LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
},
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->updateNamespace(
(new UpdateNamespaceRequest())
->withNamespaceName("namespace-0001")
->withDescription("description1")
->withLogSetting((new \Gs2\Lock\Model\LogSetting())
->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.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("namespace-0001")
.withDescription("description1")
.withLogSetting(new io.gs2.lock.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
new Gs2.Gs2Lock.Request.UpdateNamespaceRequest()
.WithNamespaceName("namespace-0001")
.WithDescription("description1")
.WithLogSetting(new Gs2.Gs2Lock.Model.LogSetting()
.WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as 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("namespace-0001")
.withDescription("description1")
.withLogSetting(new Gs2Lock.model.LogSetting()
.withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
);
const item = result.getItem();
} catch (e) {
process.exit(1);
}from gs2 import core
from gs2 import 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('namespace-0001')
.with_description('description1')
.with_log_setting(
lock.LogSetting()
.with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.update_namespace({
namespaceName="namespace-0001",
description="description1",
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.update_namespace_async({
namespaceName="namespace-0001",
description="description1",
logSetting={
loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteNamespace
Delete namespace
Delete the specified namespace. This operation is irreversible and all data associated with the deleted namespace will be lost.
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
Result
| Type | Description | |
|---|---|---|
| item | Namespace | The deleted Namespace |
Implementation Example
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("namespace-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->deleteNamespace(
(new DeleteNamespaceRequest())
->withNamespaceName("namespace-0001")
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.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("namespace-0001")
);
Namespace item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
new Gs2.Gs2Lock.Request.DeleteNamespaceRequest()
.WithNamespaceName("namespace-0001"),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as 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("namespace-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.delete_namespace(
lock.DeleteNamespaceRequest()
.with_namespace_name('namespace-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.delete_namespace({
namespaceName="namespace-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.delete_namespace_async({
namespaceName="namespace-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getServiceVersion
Get version of microservice
Request
| Type | Condition | Required | Default | Value Limits | Description |
|---|
Result
| Type | Description | |
|---|---|---|
| item | string | Version |
Implementation Example
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.GetServiceVersion(
&lock.GetServiceVersionRequest {
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Lock\Gs2LockRestClient;
use Gs2\Lock\Request\GetServiceVersionRequest;
$session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region::AP_NORTHEAST_1
);
$session->open();
$client = new Gs2LockRestClient(
$session
);
try {
$result = $client->getServiceVersion(
(new GetServiceVersionRequest())
);
$item = $result->getItem();
} catch (Gs2Exception $e) {
exit("error occurred")
}import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.lock.rest.Gs2LockRestClient;
import io.gs2.lock.request.GetServiceVersionRequest;
import io.gs2.lock.result.GetServiceVersionResult;
Gs2RestSession session = new Gs2RestSession(
Region.AP_NORTHEAST_1,
new BasicGs2Credential(
"your client id",
"your client secret"
)
);
session.connect();
Gs2LockRestClient client = new Gs2LockRestClient(session);
try {
GetServiceVersionResult result = client.getServiceVersion(
new GetServiceVersionRequest()
);
String item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
new Gs2.Gs2Lock.Request.GetServiceVersionRequest(),
r => asyncResult = r
);
if (asyncResult.Error != null) {
throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;import Gs2Core from '@/gs2/core';
import * as 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.getServiceVersion(
new Gs2Lock.GetServiceVersionRequest()
);
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_service_version(
lock.GetServiceVersionRequest()
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.get_service_version({
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.get_service_version_async({
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;lock
Get mutex
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| transactionId | string | ✓ | ~ 256 chars | Transaction ID used for lock acquisition | ||
| ttl | long | ✓ | 0 ~ 9223372036854775805 | Duration of lock acquisition (seconds) |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Mutex |
Implementation Example
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("namespace-0001"),
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.Itemuse 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 Gs2LockRestClient(
$session
);
try {
$result = $client->lock(
(new LockRequest())
->withNamespaceName("namespace-0001")
->withPropertyId("property-0001")
->withAccessToken("accessToken-0001")
->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("namespace-0001")
.withPropertyId("property-0001")
.withAccessToken("accessToken-0001")
.withTransactionId("transaction-0001")
.withTtl(100000L)
);
Mutex item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.LockResult> asyncResult = null;
yield return client.Lock(
new Gs2.Gs2Lock.Request.LockRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.with_property_id('property-0001')
.with_access_token('accessToken-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="namespace-0001",
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['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.lock_async({
namespaceName="namespace-0001",
propertyId="property-0001",
accessToken="accessToken-0001",
transactionId="transaction-0001",
ttl=100000,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;lockByUserId
Get mutex by specifying user ID
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| transactionId | string | ✓ | ~ 256 chars | Transaction ID used for lock acquisition | ||
| ttl | long | ✓ | 0 ~ 9223372036854775805 | Duration of lock acquisition (seconds) | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Mutex |
Implementation Example
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("namespace-0001"),
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.Itemuse 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 Gs2LockRestClient(
$session
);
try {
$result = $client->lockByUserId(
(new LockByUserIdRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.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;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.LockByUserIdResult> asyncResult = null;
yield return client.LockByUserId(
new Gs2.Gs2Lock.Request.LockByUserIdRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.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="namespace-0001",
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['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.lock_by_user_id_async({
namespaceName="namespace-0001",
propertyId="property-0001",
userId="user-0001",
transactionId="transaction-0001",
ttl=10,
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;unlock
Release Mutex
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| transactionId | string | ✓ | ~ 256 chars | Transaction ID used for lock acquisition |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Mutex |
Implementation Example
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("namespace-0001"),
PropertyId: pointy.String("property-0001"),
AccessToken: pointy.String("accessToken-0001"),
TransactionId: pointy.String("transaction-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->unlock(
(new UnlockRequest())
->withNamespaceName("namespace-0001")
->withPropertyId("property-0001")
->withAccessToken("accessToken-0001")
->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("namespace-0001")
.withPropertyId("property-0001")
.withAccessToken("accessToken-0001")
.withTransactionId("transaction-0001")
);
Mutex item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.UnlockResult> asyncResult = null;
yield return client.Unlock(
new Gs2.Gs2Lock.Request.UnlockRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.with_property_id('property-0001')
.with_access_token('accessToken-0001')
.with_transaction_id('transaction-0001')
)
item = result.item
except core.Gs2Exception as e:
exit(1)client = gs2('lock')
api_result = client.unlock({
namespaceName="namespace-0001",
propertyId="property-0001",
accessToken="accessToken-0001",
transactionId="transaction-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.unlock_async({
namespaceName="namespace-0001",
propertyId="property-0001",
accessToken="accessToken-0001",
transactionId="transaction-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;unlockByUserId
Release mutex with user ID
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| transactionId | string | ✓ | ~ 256 chars | Transaction ID used for lock acquisition | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Mutex |
Implementation Example
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("namespace-0001"),
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.Itemuse 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 Gs2LockRestClient(
$session
);
try {
$result = $client->unlockByUserId(
(new UnlockByUserIdRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withPropertyId("property-0001")
.withUserId("user-0001")
.withTransactionId("transaction-0001")
.withTimeOffsetToken(null)
);
Mutex item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.UnlockByUserIdResult> asyncResult = null;
yield return client.UnlockByUserId(
new Gs2.Gs2Lock.Request.UnlockByUserIdRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.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="namespace-0001",
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['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.unlock_by_user_id_async({
namespaceName="namespace-0001",
propertyId="property-0001",
userId="user-0001",
transactionId="transaction-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getMutex
Get mutex status
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| accessToken | string | ✓ | ~ 128 chars | Access token | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Mutex |
Implementation Example
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("namespace-0001"),
AccessToken: pointy.String("accessToken-0001"),
PropertyId: pointy.String("property-0001"),
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->getMutex(
(new GetMutexRequest())
->withNamespaceName("namespace-0001")
->withAccessToken("accessToken-0001")
->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("namespace-0001")
.withAccessToken("accessToken-0001")
.withPropertyId("property-0001")
);
Mutex item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.GetMutexResult> asyncResult = null;
yield return client.GetMutex(
new Gs2.Gs2Lock.Request.GetMutexRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.with_access_token('accessToken-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="namespace-0001",
accessToken="accessToken-0001",
propertyId="property-0001",
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.get_mutex_async({
namespaceName="namespace-0001",
accessToken="accessToken-0001",
propertyId="property-0001",
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;getMutexByUserId
Get mutex status by specifying user ID
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Mutex |
Implementation Example
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("namespace-0001"),
UserId: pointy.String("user-0001"),
PropertyId: pointy.String("property-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->getMutexByUserId(
(new GetMutexByUserIdRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withUserId("user-0001")
.withPropertyId("property-0001")
.withTimeOffsetToken(null)
);
Mutex item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.GetMutexByUserIdResult> asyncResult = null;
yield return client.GetMutexByUserId(
new Gs2.Gs2Lock.Request.GetMutexByUserIdRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.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="namespace-0001",
userId="user-0001",
propertyId="property-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.get_mutex_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
propertyId="property-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;deleteMutexByUserId
Delete mutex
Request
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| userId | string | ✓ | ~ 128 chars | User ID | ||
| propertyId | string | ✓ | ~ 1024 chars | Property ID | ||
| timeOffsetToken | string | ~ 1024 chars | Time offset token |
Result
| Type | Description | |
|---|---|---|
| item | Mutex | Deleted mutex |
Implementation Example
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("namespace-0001"),
UserId: pointy.String("user-0001"),
PropertyId: pointy.String("property-0001"),
TimeOffsetToken: nil,
}
)
if err != nil {
panic("error occurred")
}
item := result.Itemuse Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\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 Gs2LockRestClient(
$session
);
try {
$result = $client->deleteMutexByUserId(
(new DeleteMutexByUserIdRequest())
->withNamespaceName("namespace-0001")
->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("namespace-0001")
.withUserId("user-0001")
.withPropertyId("property-0001")
.withTimeOffsetToken(null)
);
Mutex item = result.getItem();
} catch (Gs2Exception e) {
System.exit(1);
}using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;
var session = new Gs2RestSession(
new BasicGs2Credential(
"your client id",
"your client secret"
),
Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2LockRestClient(session);
AsyncResult<Gs2.Gs2Lock.Result.DeleteMutexByUserIdResult> asyncResult = null;
yield return client.DeleteMutexByUserId(
new Gs2.Gs2Lock.Request.DeleteMutexByUserIdRequest()
.WithNamespaceName("namespace-0001")
.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("namespace-0001")
.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('namespace-0001')
.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="namespace-0001",
userId="user-0001",
propertyId="property-0001",
timeOffsetToken=nil,
})
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;client = gs2('lock')
api_result_handler = client.delete_mutex_by_user_id_async({
namespaceName="namespace-0001",
userId="user-0001",
propertyId="property-0001",
timeOffsetToken=nil,
})
api_result = api_result_handler() -- Call the handler to get the result
if(api_result.isError) then
-- When error occurs
fail(api_result['statusCode'], api_result['errorMessage'])
end
result = api_result.result
item = result.item;