> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Lock SDK API 레퍼런스

각종 프로그래밍 언어용 GS2-Lock SDK의 모델 사양과 API 레퍼런스



## 모델

### Namespace

네임스페이스<br>

네임스페이스는 하나의 프로젝트 내에서 동일한 서비스를 서로 다른 용도로 여러 개 이용하기 위한 엔티티입니다.<br>
GS2의 각 서비스는 네임스페이스 단위로 관리됩니다. 네임스페이스가 다르면 동일한 서비스라도 완전히 독립된 데이터 공간으로 취급됩니다.<br>

따라서 각 서비스의 이용을 시작하려면 먼저 네임스페이스를 생성해야 합니다.


|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceId | string |  | ※ |  |  ~ 1024자 | 네임스페이스 GRN<br>※ 서버가 자동으로 설정 |
| name | string |  | ✓ |  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| description | string |  |  |  |  ~ 1024자 | 설명문 |
| logSetting | [LogSetting](#logsetting) |  |  |  |  | 로그 출력 설정 |
| createdAt | long |  | ※ | 현재 시각 |  | 생성일시<br>UNIX 시간・밀리초<br>※ 서버가 자동으로 설정 |
| updatedAt | long |  | ※ | 현재 시각 |  | 최종 갱신일시<br>UNIX 시간・밀리초<br>※ 서버가 자동으로 설정 |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | 리비전 |

**관련 메서드:**
describeNamespaces - 네임스페이스 목록 조회
createNamespace - 네임스페이스 신규 생성
getNamespace - 네임스페이스 조회
updateNamespace - 네임스페이스 갱신
deleteNamespace - 네임스페이스 삭제



---

### LogSetting

로그 출력 설정<br>

로그 데이터의 출력 설정을 관리합니다. 이 타입은 로그 데이터를 출력하기 위해 사용되는 GS2-Log 네임스페이스의 식별자(Namespace ID)를 보관합니다.<br>
로그 네임스페이스ID(loggingNamespaceId)에는 로그 데이터를 수집하여 저장하는 GS2-Log의 네임스페이스를 GRN 형식으로 지정합니다.<br>
이 설정을 하면 설정된 네임스페이스 내에서 발생한 API 요청·응답 로그 데이터가 대상 GS2-Log 네임스페이스 쪽으로 출력됩니다.<br>
GS2-Log에서는 실시간으로 로그가 제공되어 시스템 모니터링, 분석, 디버깅 등에 활용할 수 있습니다.


|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| loggingNamespaceId | string |  | ✓ |  |  ~ 1024자 | 로그를 출력할 GS2-Log의 네임스페이스GRN<br>"grn:gs2:"로 시작하는 GRN 형식의 ID로 지정해야 합니다. |

**관련 메서드:**
createNamespace - 네임스페이스 신규 생성
updateNamespace - 네임스페이스 갱신


**관련 모델:**
Namespace - 네임스페이스



---

### Mutex

뮤텍스<br>

GS2가 제공하는 뮤텍스는 재진입 가능한 락의 일종입니다.<br>

잠금을 획득할 때 트랜잭션 ID를 지정하며, 동일한 트랜잭션 ID를 지정한 경우에만 다시 잠금을 획득할 수 있습니다.<br>
참조 카운터를 가지므로, 해제할 때에는 동일한 횟수만큼 잠금 해제 처리가 필요합니다.


|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| mutexId | string |  | ※ |  |  ~ 1024자 | 뮤텍스 GRN<br>※ 서버가 자동으로 설정 |
| userId | string |  | ✓ |  |  ~ 128자 | 사용자ID |
| propertyId | string |  | ✓ |  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| transactionId | string |  | ✓ |  |  ~ 256자 | 트랜잭션 ID<br>잠금을 획득하는 트랜잭션의 식별자입니다. 이 ID는 재진입 가능한 잠금을 구현하는 데 사용됩니다.<br>잠금 요청이 현재 잠금을 보유한 것과 동일한 트랜잭션 ID를 지정한 경우, 잠금은 재획득에 성공하며 참조 카운터가 증가합니다.<br>다른 트랜잭션 ID로의 잠금 요청은 잠금이 유지되는 동안 거부됩니다. |
| createdAt | long |  | ※ | 현재 시각 |  | 생성일시<br>UNIX 시간・밀리초<br>※ 서버가 자동으로 설정 |
| ttlAt | long |  |  | 현재 시각으로부터 1시간 후의 절대 시각 |  | 유효기간 일시<br>UNIX 시간・밀리초 |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | 리비전 |

**관련 메서드:**
lock - 뮤텍스 잠금
lockByUserId - 사용자 ID를 지정하여 뮤텍스 잠금
unlock - 뮤텍스 해제
unlockByUserId - 사용자 ID를 지정하여 뮤텍스 해제
getMutex - 뮤텍스 상태 조회
getMutexByUserId - 사용자 ID를 지정하여 뮤텍스 상태 조회
deleteMutexByUserId - 뮤텍스 삭제



---
## 메서드

### describeNamespaces

네임스페이스 목록 조회<br>

프로젝트 내에서 서비스 단위로 생성된 네임스페이스의 목록을 조회합니다.<br>
옵션인 페이지 토큰을 사용하여 목록의 특정 위치부터 데이터 조회를 시작할 수 있습니다.<br>
또한 조회할 네임스페이스의 수를 제한하는 것도 가능합니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namePrefix | string |  | |  |  ~ 64자 | 네임스페이스 이름의 필터 접두사 |
| pageToken | string |  | |  |  ~ 1024자 | 데이터 취득을 시작할 위치를 지정하는 토큰 |
| limit | int |  | | 30 | 1 ~ 1000 | 취득할 데이터 건수 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| items | [List&lt;Namespace&gt;](#namespace) | 네임스페이스 목록 |
| nextPageToken | string | 목록의 나머지를 취득하기 위한 페이지 토큰 |

#### 구현 예제




**Go**
```go

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.NextPageToken

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

네임스페이스 신규 생성<br>

네임스페이스의 이름, 설명 및 각종 설정을 포함한 상세 정보를 지정해야 합니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| name | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| description | string |  | |  |  ~ 1024자 | 설명문 |
| logSetting | [LogSetting](#logsetting) |  | |  |  | 로그 출력 설정 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Namespace](#namespace) | 생성한 네임스페이스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

네임스페이스의 상태 조회<br>

지정된 네임스페이스의 현재 상태를 조회합니다.<br>
상태에는 네임스페이스가 활성 상태인지, 삭제되었는지가 포함됩니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| status | string | 네임스페이스의 상태<br>ACTIVE: 유효 / DELETED: 삭제됨 /  |

#### 구현 예제




**Go**
```go

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.Status

```

**PHP**
```php

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 Gs2LockRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName("namespace-0001")
    );
    $status = $result->getStatus();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

네임스페이스 조회<br>

지정된 네임스페이스의 상세 정보를 조회합니다.<br>
여기에는 네임스페이스의 이름, 설명 및 기타 설정 정보가 포함됩니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Namespace](#namespace) | 네임스페이스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 Gs2LockRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

네임스페이스 갱신<br>

지정된 네임스페이스의 설정을 갱신합니다.<br>
네임스페이스의 설명이나 특정 설정을 변경할 수 있습니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| description | string |  | |  |  ~ 1024자 | 설명문 |
| logSetting | [LogSetting](#logsetting) |  | |  |  | 로그 출력 설정 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Namespace](#namespace) | 갱신한 네임스페이스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

네임스페이스 삭제<br>

지정된 네임스페이스를 삭제합니다.<br>
이 작업은 되돌릴 수 없으며, 삭제된 네임스페이스와 관련된 모든 데이터는 복구할 수 없게 됩니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Namespace](#namespace) | 삭제한 네임스페이스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 Gs2LockRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

마이크로서비스 버전 조회


#### Request

요청 파라미터: 없음

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | string | 버전 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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\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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

뮤텍스 잠금<br>

요청한 사용자의 지정된 프로퍼티에 대해 뮤텍스 잠금을 획득합니다.<br>
잠금은 지정된 유효기간(TTL) 초 동안 유지됩니다.<br>
동일한 transactionId로 다시 잠금을 획득하면 참조 카운트가 증가합니다(재진입 락). 다른 transactionId로 이미 잠긴 뮤텍스를 획득하려고 하면 작업은 실패합니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| accessToken | string |  | ✓|  |  ~ 128자 | 액세스 토큰 |
| transactionId | string |  | ✓|  |  ~ 256자 | 트랜잭션 ID<br>잠금을 획득하는 트랜잭션의 식별자입니다. 이 ID는 재진입 가능한 잠금을 구현하는 데 사용됩니다.<br>잠금 요청이 현재 잠금을 보유한 것과 동일한 트랜잭션 ID를 지정한 경우, 잠금은 재획득에 성공하며 참조 카운터가 증가합니다.<br>다른 트랜잭션 ID로의 잠금 요청은 잠금이 유지되는 동안 거부됩니다. |
| ttl | long |  | ✓|  | 0 ~ 9223372036854775805 | 잠금 획득 기간(초) |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

사용자 ID를 지정하여 뮤텍스 잠금<br>

지정된 사용자의 지정된 프로퍼티에 대해 뮤텍스 잠금을 획득합니다.<br>
잠금은 지정된 TTL 초 동안 유지됩니다.<br>
동일한 transactionId로 다시 잠금을 획득하면 참조 카운트가 증가합니다(재진입 락).


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| userId | string |  | ✓|  |  ~ 128자 | 사용자ID |
| transactionId | string |  | ✓|  |  ~ 256자 | 트랜잭션 ID<br>잠금을 획득하는 트랜잭션의 식별자입니다. 이 ID는 재진입 가능한 잠금을 구현하는 데 사용됩니다.<br>잠금 요청이 현재 잠금을 보유한 것과 동일한 트랜잭션 ID를 지정한 경우, 잠금은 재획득에 성공하며 참조 카운터가 증가합니다.<br>다른 트랜잭션 ID로의 잠금 요청은 잠금이 유지되는 동안 거부됩니다. |
| ttl | long |  | ✓|  | 0 ~ 9223372036854775805 | 잠금 획득 기간(초) |
| timeOffsetToken | string |  | |  |  ~ 1024자 | 타임 오프셋 토큰 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

뮤텍스 해제<br>

요청한 사용자의 지정된 프로퍼티에 대한 뮤텍스 잠금을 해제합니다.<br>
transactionId는 잠금을 획득할 때 사용한 값과 일치해야 합니다.<br>
참조 카운트가 감소하며, 0이 되면 잠금이 완전히 해제됩니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| accessToken | string |  | ✓|  |  ~ 128자 | 액세스 토큰 |
| transactionId | string |  | ✓|  |  ~ 256자 | 트랜잭션 ID<br>잠금을 획득하는 트랜잭션의 식별자입니다. 이 ID는 재진입 가능한 잠금을 구현하는 데 사용됩니다.<br>잠금 요청이 현재 잠금을 보유한 것과 동일한 트랜잭션 ID를 지정한 경우, 잠금은 재획득에 성공하며 참조 카운터가 증가합니다.<br>다른 트랜잭션 ID로의 잠금 요청은 잠금이 유지되는 동안 거부됩니다. |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

사용자 ID를 지정하여 뮤텍스 해제<br>

지정된 사용자의 지정된 프로퍼티에 대한 뮤텍스 잠금을 해제합니다.<br>
transactionId는 잠금을 획득할 때 사용한 값과 일치해야 합니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| userId | string |  | ✓|  |  ~ 128자 | 사용자ID |
| transactionId | string |  | ✓|  |  ~ 256자 | 트랜잭션 ID<br>잠금을 획득하는 트랜잭션의 식별자입니다. 이 ID는 재진입 가능한 잠금을 구현하는 데 사용됩니다.<br>잠금 요청이 현재 잠금을 보유한 것과 동일한 트랜잭션 ID를 지정한 경우, 잠금은 재획득에 성공하며 참조 카운터가 증가합니다.<br>다른 트랜잭션 ID로의 잠금 요청은 잠금이 유지되는 동안 거부됩니다. |
| timeOffsetToken | string |  | |  |  ~ 1024자 | 타임 오프셋 토큰 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

뮤텍스 상태 조회<br>

요청한 사용자의 지정된 프로퍼티에 대한 현재 뮤텍스 상태를 조회합니다.<br>
트랜잭션 ID, 유효기간(TTL)을 포함한 뮤텍스 정보를 반환합니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| accessToken | string |  | ✓|  |  ~ 128자 | 액세스 토큰 |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

사용자 ID를 지정하여 뮤텍스 상태 조회<br>

지정된 사용자의 프로퍼티에 대한 현재 뮤텍스 상태를 조회합니다.<br>
트랜잭션 ID, 유효기간(TTL)을 포함한 뮤텍스 정보를 반환합니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| userId | string |  | ✓|  |  ~ 128자 | 사용자ID |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| timeOffsetToken | string |  | |  |  ~ 1024자 | 타임 오프셋 토큰 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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

뮤텍스 삭제<br>

트랜잭션 ID나 참조 카운트에 관계없이, 지정된 프로퍼티의 뮤텍스를 강제로 삭제합니다.<br>
이는 잠금을 즉시 해제하는 관리 작업입니다.


#### Request

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| userId | string |  | ✓|  |  ~ 128자 | 사용자ID |
| propertyId | string |  | ✓|  |  ~ 1024자 | 프로퍼티 ID<br>잠금 대상 리소스를 식별하기 위한 ID로, 어떤 리소스에 대한 잠금인지를 결정합니다.<br>여러 처리가 동일한 리소스에 대한 배타적 접근을 필요로 하는 경우, 동일한 프로퍼티 ID를 지정해야 합니다. |
| timeOffsetToken | string |  | |  |  ~ 1024자 | 타임 오프셋 토큰 |

#### Result

|  | 타입 | 설명 |
| --- | --- | --- |
| item | [Mutex](#mutex) | 삭제된 뮤텍스 |

#### 구현 예제




**Go**
```go

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.Item

```

**PHP**
```php

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 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")
}

```

**Java**
```java

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);
}

```

**C#**
```csharp

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;

```

**TypeScript**
```typescript

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);
}

```

**Python**
```python

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)


```

**GS2-Script**
```lua

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;

```

**GS2-Script(Async)**
```lua

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;

```



---



