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

# GS2-Datastore SDK API リファレンス

各種プログラミング言語向け GS2-Datastore SDK の モデルの仕様 と API のリファレンス



## モデル

### Namespace

ネームスペース<br>

ネームスペースは、一つのプロジェクト内で同じサービスを異なる用途で複数利用するためのエンティティです。<br>
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。<br>

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



|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceId | string |  | ※ |  |  ~ 1024文字 | ネームスペースGRN<br>※ サーバーが自動で設定 |
| name | string |  | ✓ |  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| description | string |  |  |  |  ~ 1024文字 | 説明文 |
| transactionSetting | [TransactionSetting](#transactionsetting) |  |  |  |  | トランザクション設定<br>データストア操作時の分散トランザクションの実行方法を制御する設定です。自動実行、アトミックコミット、非同期処理などのオプションをサポートします。 |
| doneUploadScript | [ScriptSetting](#scriptsetting) |  |  |  |  | アップロード完了報告時に実行するスクリプトの設定<br>Script トリガーリファレンス - [`doneUpload`](../script/#doneupload) |
| logSetting | [LogSetting](#logsetting) |  |  |  |  | ログの出力設定<br>データストア操作のログデータを GS2-Log に出力するための設定です。GS2-Log のネームスペースを指定することで、データオブジェクトのアップロード・ダウンロード・アクセス権変更などの API リクエスト・レスポンスログを収集できます。 |
| createdAt | long |  | ※ | 現在時刻 |  | 作成日時<br>UNIX 時間・ミリ秒<br>※ サーバーが自動で設定 |
| updatedAt | long |  | ※ | 現在時刻 |  | 最終更新日時<br>UNIX 時間・ミリ秒<br>※ サーバーが自動で設定 |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | リビジョン |

**関連するメソッド:**
describeNamespaces - ネームスペースの一覧を取得
createNamespace - ネームスペースを新規作成
getNamespace - ネームスペースを取得
updateNamespace - ネームスペースを更新
deleteNamespace - ネームスペースを削除




---

### TransactionSetting

トランザクション設定<br>

トランザクション設定は、トランザクションの実行方法・整合性・非同期処理・競合回避の仕組みを制御する設定です。<br>
自動実行（AutoRun）、アトミック実行（AtomicCommit）、GS2-Distributor を利用した非同期実行、スクリプト結果の一括適用、GS2-JobQueue による入手アクションの非同期化などを組み合わせ、ゲームロジックに応じた堅牢なトランザクション管理を可能にします。



|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| enableAutoRun | bool |  |  | false |  | 発行したトランザクションをサーバーサイドで自動的に実行するか |
| enableAtomicCommit | bool | {enableAutoRun} == true |  | false |  | トランザクションの実行をアトミックにコミットするか<br>※ enableAutoRun が true であれば 有効 |
| transactionUseDistributor | bool | {enableAtomicCommit} == true |  | false |  | トランザクションを非同期処理で実行する<br>※ enableAtomicCommit が true であれば 有効 |
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true |  | false |  | スクリプトの結果コミット処理を非同期処理で実行するか<br>※ transactionUseDistributor が true であれば 有効 |
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true |  | false |  | 入手アクションを実行する際に GS2-JobQueue を使用するか<br>※ enableAtomicCommit が true であれば 有効 |
| distributorNamespaceId | string |  |  | "grn:gs2:{region}:{ownerId}:distributor:default" |  ~ 1024文字 | トランザクションの実行に使用する GS2-Distributor ネームスペースGRN |
| queueNamespaceId | string |  |  | "grn:gs2:{region}:{ownerId}:queue:default" |  ~ 1024文字 | トランザクションの実行に使用する GS2-JobQueue のネームスペースGRN |

**関連するメソッド:**
createNamespace - ネームスペースを新規作成
updateNamespace - ネームスペースを更新


**関連するモデル:**
Namespace - ネームスペース




---

### ScriptSetting

スクリプト設定<br>

GS2 ではマイクロサービスのイベントに関連づけて、カスタムスクリプトを実行することができます。<br>
このモデルは、スクリプトの実行をトリガーするための設定を保持します。<br>

スクリプトの実行方式は大きく2種類あり、それは「同期実行」と「非同期実行」です。<br>
同期実行は、スクリプトの実行が完了するまで処理がブロックされます。<br>
代わりに、スクリプトの実行結果を使って API の実行を止めたり、API のレスポンス内容を制御することができます。<br>

一方、非同期実行ではスクリプトの完了を待つために処理がブロックされることはありません。<br>
ただし、スクリプトの実行結果を利用して API の実行を停止したり、API の応答内容を変更することはできません。<br>
非同期実行は API の応答フローに影響を与えないため、原則として非同期実行を推奨します。<br>

非同期実行には実行方式が2種類あり、GS2-Script と Amazon EventBridge があります。<br>
Amazon EventBridge を使用することで、Lua 以外の言語で処理を記述することができます。



|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| triggerScriptId | string |  |  |  |  ~ 1024文字 | API 実行時に同期的に実行される GS2-Script のスクリプトGRN<br>「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |
| doneTriggerTargetType | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"none",<br>&nbsp;&nbsp;"gs2_script",<br>&nbsp;&nbsp;"aws"<br>}<br> |  |  | "none" |  | 非同期スクリプトの実行方法<br>非同期実行で使用するスクリプトの種類を指定します。<br>「非同期実行のスクリプトを使用しない(none)」「GS2-Scriptを使用する(gs2_script)」「Amazon EventBridgeを使用する(aws)」が選択できます。"none": なし / "gs2_script": GS2-Script / "aws": Amazon EventBridge /  |
| doneTriggerScriptId | string | {doneTriggerTargetType} == "gs2_script" |  |  |  ~ 1024文字 | 非同期実行する GS2-Script スクリプトGRN<br>「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。<br>※ doneTriggerTargetType が "gs2_script" であれば 有効 |
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == "gs2_script" |  |  |  ~ 1024文字 | 非同期実行スクリプトを実行する GS2-JobQueue ネームスペースGRN<br>非同期実行スクリプトを直接実行するのではなく、GS2-JobQueue を経由する場合は GS2-JobQueue のネームスペースGRN を指定します。<br>GS2-JobQueue を利用する理由は多くはありませんので、特に理由がなければ指定する必要はありません。<br>※ doneTriggerTargetType が "gs2_script" であれば 有効 |

**関連するメソッド:**
createNamespace - ネームスペースを新規作成
updateNamespace - ネームスペースを更新


**関連するモデル:**
Namespace - ネームスペース




---

### LogSetting

ログの出力設定<br>

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



|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| loggingNamespaceId | string |  | ✓ |  |  ~ 1024文字 | ログを出力する GS2-Log のネームスペースGRN<br>「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。 |

**関連するメソッド:**
createNamespace - ネームスペースを新規作成
updateNamespace - ネームスペースを更新


**関連するモデル:**
Namespace - ネームスペース




---

### DataObject

データオブジェクト<br>

データオブジェクトはゲームプレイヤーがアップロードしたデータです。<br>
データは世代管理され、30日分の過去のデータも保管されます。<br>

データにはアクセス権限を設定できます。<br>
スコープには3種類あり、<br>
- だれでもアクセスできる `public`<br>
- 指定したユーザーIDのゲームプレイヤーのみがアクセスできる `protected`<br>
- 自身のみがアクセスできる `private`<br>

があります。



|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| dataObjectId | string |  | ※ |  |  ~ 1024文字 | データオブジェクトGRN<br>※ サーバーが自動で設定 |
| name | string |  | ✓ | UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| userId | string |  | ✓ |  |  ~ 128文字 | ユーザーID |
| scope | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"public",<br>&nbsp;&nbsp;"protected",<br>&nbsp;&nbsp;"private"<br>}<br> |  |  | "private" |  | ファイルのアクセス権<br>このデータオブジェクトにアクセスできるユーザーを制御します。`public` は誰でもアクセス可能、`protected` は allowUserIds に指定されたユーザーIDのみアクセス可能、`private` はオーナー本人のみアクセス可能です。"public": 公開 / "protected": 指定したユーザーにのみ公開 / "private": 非公開 /  |
| allowUserIds | List&lt;string&gt; | {scope} == "protected" |  | [] | 0 ~ 100 items | 公開するユーザーIDリスト<br>スコープが `protected` に設定されている場合に、このデータオブジェクトにアクセスできるユーザーを指定します。このリストに含まれるユーザーIDのユーザーのみが読み取りアクセスを許可されます。<br>※ scope が "protected" であれば 有効 |
| status | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"ACTIVE",<br>&nbsp;&nbsp;"UPLOADING",<br>&nbsp;&nbsp;"DELETED"<br>}<br> |  | ✓ |  |  | 状態<br>データオブジェクトの現在のライフサイクル状態です。`ACTIVE` はデータがアクセス可能であることを示し、`UPLOADING` は新しいバージョンがアップロード中であることを示し、`DELETED` は削除済みであることを示します（実際の削除は30日後に行われます）。"ACTIVE": 有効 / "UPLOADING": アップロード中 / "DELETED": 削除済み(削除処理から30日後に実際に削除) /  |
| generation | string |  |  |  |  ~ 128文字 | データの世代<br>アップロードされたデータの現在のバージョンを表す識別子です。データが再アップロードされるたびに新しい世代IDが割り当てられます。 |
| previousGeneration | string |  |  |  |  ~ 128文字 | 以前有効だったデータの世代<br>現在のアップロード前にアクティブだったデータバージョンの世代IDです。アップロード中（UPLOADING 状態）は、新しいアップロードが完了するまでデータの継続的なアクセスを保証するために、以前の世代が引き続きアクセス可能です。 |
| createdAt | long |  | ※ | 現在時刻 |  | 作成日時<br>UNIX 時間・ミリ秒<br>※ サーバーが自動で設定 |
| updatedAt | long |  | ※ | 現在時刻 |  | 最終更新日時<br>UNIX 時間・ミリ秒<br>※ サーバーが自動で設定 |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | リビジョン |

**関連するメソッド:**
describeDataObjects - データオブジェクトの一覧を取得
describeDataObjectsByUserId - ユーザーIDを指定してデータオブジェクトの一覧を取得
prepareUpload - データオブジェクトのアップロードを準備する
prepareUploadByUserId - ユーザーIDを指定してデータオブジェクトのアップロードを準備する
updateDataObject - データオブジェクトを更新
updateDataObjectByUserId - ユーザーIDを指定してデータオブジェクトを更新
prepareReUpload - データオブジェクトの再アップロードを準備する
prepareReUploadByUserId - ユーザーIDを指定してデータオブジェクトの再アップロードを準備する
doneUpload - データオブジェクトのアップロード完了を報告
doneUploadByUserId - ユーザーIDを指定してデータオブジェクトのアップロード完了を報告
deleteDataObject - データオブジェクトの削除
deleteDataObjectByUserId - ユーザーIDを指定してデータオブジェクトの削除
prepareDownload - データオブジェクトのダウンロード準備
prepareDownloadByUserId - ユーザーIDを指定してデータオブジェクトのダウンロード準備
prepareDownloadByGeneration - データオブジェクトを世代を指定してダウンロード準備
prepareDownloadByGenerationAndUserId - ユーザーIDを指定してデータオブジェクトの世代を指定してダウンロード準備
prepareDownloadOwnData - 名前を指定して自分のデータオブジェクトのダウンロード準備
prepareDownloadByUserIdAndDataObjectName - ユーザーIDとオブジェクト名を指定してデータオブジェクトをダウンロード準備する
prepareDownloadOwnDataByGeneration - 自分のデータオブジェクトの世代を指定してダウンロード準備
prepareDownloadByUserIdAndDataObjectNameAndGeneration - ユーザーID・オブジェクト名・世代を指定してデータオブジェクトのダウンロード準備
restoreDataObject - データオブジェクトの管理情報を修復




---

### DataObjectHistory

データオブジェクト履歴<br>

データオブジェクトの更新履歴が確認できます。<br>
データオブジェクトが再アップロードされるたびに、世代IDとファイルサイズを含む履歴レコードが作成されます。履歴データは30日間保持され、以前のバージョンへのロールバックや監査が可能です。



|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| dataObjectHistoryId | string |  | ※ |  |  ~ 1024文字 | データオブジェクト履歴GRN<br>※ サーバーが自動で設定 |
| dataObjectName | string |  | ✓ | UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| generation | string |  | ✓ |  |  ~ 128文字 | 世代ID<br>アップロード時点のデータオブジェクトの特定バージョンを示す一意な識別子です。DataObject の generation フィールドに対応し、PrepareDownloadByGeneration でこの特定バージョンをダウンロードする際に使用できます。 |
| contentLength | long |  | ✓ |  | 0 ~ 10485760 | データサイズ<br>この世代のアップロードデータのサイズ（バイト単位）です。最大ファイルサイズは 10 MB（10,485,760 バイト）です。 |
| createdAt | long |  | ※ | 現在時刻 |  | 作成日時<br>UNIX 時間・ミリ秒<br>※ サーバーが自動で設定 |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | リビジョン |

**関連するメソッド:**
describeDataObjectHistories - データオブジェクト履歴の一覧を取得
describeDataObjectHistoriesByUserId - ユーザーIDを指定してデータオブジェクト履歴の一覧を取得
getDataObjectHistory - データオブジェクト履歴を取得
getDataObjectHistoryByUserId - ユーザーIDを指定してデータオブジェクト履歴を取得




---
## メソッド

### 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/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &datastore.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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DescribeNamespacesRequest;

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

$session->open();

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

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2DatastoreRestClient client = new Gs2DatastoreRestClient(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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Datastore.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 Gs2Datastore from '@/gs2/datastore';

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

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

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

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

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('datastore')

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文字 | 説明文 |
| transactionSetting | [TransactionSetting](#transactionsetting) |  | |  |  | トランザクション設定<br>データストア操作時の分散トランザクションの実行方法を制御する設定です。自動実行、アトミックコミット、非同期処理などのオプションをサポートします。 |
| logSetting | [LogSetting](#logsetting) |  | |  |  | ログの出力設定<br>データストア操作のログデータを GS2-Log に出力するための設定です。GS2-Log のネームスペースを指定することで、データオブジェクトのアップロード・ダウンロード・アクセス権変更などの API リクエスト・レスポンスログを収集できます。 |
| doneUploadScript | [ScriptSetting](#scriptsetting) |  | |  |  | アップロード完了報告時に実行するスクリプトの設定<br>Script トリガーリファレンス - [`doneUpload`](../script/#doneupload) |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [Namespace](#namespace) | 作成したネームスペース |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &datastore.CreateNamespaceRequest {
        Name: pointy.String("namespace-0001"),
        Description: nil,
        TransactionSetting: nil,
        LogSetting: &datastore.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
        },
        DoneUploadScript: 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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\CreateNamespaceRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName("namespace-0001")
            ->withDescription(null)
            ->withTransactionSetting(null)
            ->withLogSetting((new \Gs2\Datastore\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
            ->withDoneUploadScript(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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.CreateNamespaceRequest;
import io.gs2.datastore.result.CreateNamespaceResult;

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

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withTransactionSetting(null)
            .withLogSetting(new io.gs2.datastore.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
            .withDoneUploadScript(null)
    );
    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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Datastore.Request.CreateNamespaceRequest()
        .WithName("namespace-0001")
        .WithDescription(null)
        .WithTransactionSetting(null)
        .WithLogSetting(new Gs2.Gs2Datastore.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
        .WithDoneUploadScript(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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.createNamespace(
        new Gs2Datastore.CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withTransactionSetting(null)
            .withLogSetting(new Gs2Datastore.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
            .withDoneUploadScript(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.create_namespace(
        datastore.CreateNamespaceRequest()
            .with_name('namespace-0001')
            .with_description(None)
            .with_transaction_setting(None)
            .with_log_setting(
                datastore.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
            .with_done_upload_script(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.create_namespace({
    name="namespace-0001",
    description=nil,
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
    doneUploadScript=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('datastore')

api_result_handler = client.create_namespace_async({
    name="namespace-0001",
    description=nil,
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
    doneUploadScript=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;

```




---

### getNamespaceStatus

ネームスペースの状態を取得<br>

指定されたネームスペースの現在の状態を取得します。<br>
これには、ネームスペースがアクティブか、保留中か、またはその他の状態にあるかが含まれます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| status | string |  |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &datastore.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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\GetNamespaceStatusRequest;

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

$session->open();

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

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2DatastoreRestClient client = new Gs2DatastoreRestClient(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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Datastore.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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.getNamespaceStatus(
        new Gs2Datastore.GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.get_namespace_status(
        datastore.GetNamespaceStatusRequest()
            .with_namespace_name('namespace-0001')
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

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('datastore')

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/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &datastore.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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\GetNamespaceRequest;

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

$session->open();

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

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2DatastoreRestClient client = new Gs2DatastoreRestClient(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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Datastore.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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.getNamespace(
        new Gs2Datastore.GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.get_namespace(
        datastore.GetNamespaceRequest()
            .with_namespace_name('namespace-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

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('datastore')

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文字 | 説明文 |
| transactionSetting | [TransactionSetting](#transactionsetting) |  | |  |  | トランザクション設定<br>データストア操作時の分散トランザクションの実行方法を制御する設定です。自動実行、アトミックコミット、非同期処理などのオプションをサポートします。 |
| logSetting | [LogSetting](#logsetting) |  | |  |  | ログの出力設定<br>データストア操作のログデータを GS2-Log に出力するための設定です。GS2-Log のネームスペースを指定することで、データオブジェクトのアップロード・ダウンロード・アクセス権変更などの API リクエスト・レスポンスログを収集できます。 |
| doneUploadScript | [ScriptSetting](#scriptsetting) |  | |  |  | アップロード完了報告時に実行するスクリプトの設定<br>Script トリガーリファレンス - [`doneUpload`](../script/#doneupload) |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [Namespace](#namespace) | 更新したネームスペース |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &datastore.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Description: pointy.String("description1"),
        TransactionSetting: nil,
        LogSetting: &datastore.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
        },
        DoneUploadScript: 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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\UpdateNamespaceRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName("namespace-0001")
            ->withDescription("description1")
            ->withTransactionSetting(null)
            ->withLogSetting((new \Gs2\Datastore\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
            ->withDoneUploadScript(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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.UpdateNamespaceRequest;
import io.gs2.datastore.result.UpdateNamespaceResult;

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

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withTransactionSetting(null)
            .withLogSetting(new io.gs2.datastore.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
            .withDoneUploadScript(null)
    );
    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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Datastore.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace-0001")
        .WithDescription("description1")
        .WithTransactionSetting(null)
        .WithLogSetting(new Gs2.Gs2Datastore.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
        .WithDoneUploadScript(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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.updateNamespace(
        new Gs2Datastore.UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withTransactionSetting(null)
            .withLogSetting(new Gs2Datastore.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
            .withDoneUploadScript(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.update_namespace(
        datastore.UpdateNamespaceRequest()
            .with_namespace_name('namespace-0001')
            .with_description('description1')
            .with_transaction_setting(None)
            .with_log_setting(
                datastore.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
            .with_done_upload_script(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.update_namespace({
    namespaceName="namespace-0001",
    description="description1",
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
    doneUploadScript=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('datastore')

api_result_handler = client.update_namespace_async({
    namespaceName="namespace-0001",
    description="description1",
    transactionSetting=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
    doneUploadScript=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;

```




---

### 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/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &datastore.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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DeleteNamespaceRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DeleteNamespaceRequest;
import io.gs2.datastore.result.DeleteNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2DatastoreRestClient client = new Gs2DatastoreRestClient(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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Datastore.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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.deleteNamespace(
        new Gs2Datastore.DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.delete_namespace(
        datastore.DeleteNamespaceRequest()
            .with_namespace_name('namespace-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

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('datastore')

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/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.GetServiceVersion(
    &datastore.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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\GetServiceVersionRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.GetServiceVersionRequest;
import io.gs2.datastore.result.GetServiceVersionResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2DatastoreRestClient client = new Gs2DatastoreRestClient(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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
    new Gs2.Gs2Datastore.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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.getServiceVersion(
        new Gs2Datastore.GetServiceVersionRequest()
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.get_service_version(
        datastore.GetServiceVersionRequest()
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

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('datastore')

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;

```




---

### dumpUserDataByUserId

指定したユーザーIDに紐づくデータのダンプを取得<br>

個人情報保護の法的要件を満たすために使用したり、データのバックアップや移行に使用できます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DumpUserDataByUserId(
    &datastore.DumpUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DumpUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->dumpUserDataByUserId(
        (new DumpUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DumpUserDataByUserIdRequest;
import io.gs2.datastore.result.DumpUserDataByUserIdResult;

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

try {
    DumpUserDataByUserIdResult result = client.dumpUserDataByUserId(
        new DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DumpUserDataByUserIdResult> asyncResult = null;
yield return client.DumpUserDataByUserId(
    new Gs2.Gs2Datastore.Request.DumpUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.dumpUserDataByUserId(
        new Gs2Datastore.DumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.dump_user_data_by_user_id(
        datastore.DumpUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.dump_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result

```

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

client = gs2('datastore')

api_result_handler = client.dump_user_data_by_user_id_async({
    userId="user-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

```




---

### checkDumpUserDataByUserId

指定したユーザーIDに紐づくデータのダンプが完了しているか確認



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| url | string | 出力データのURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.CheckDumpUserDataByUserId(
    &datastore.CheckDumpUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
url := result.Url

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\CheckDumpUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->checkDumpUserDataByUserId(
        (new CheckDumpUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $url = $result->getUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.CheckDumpUserDataByUserIdRequest;
import io.gs2.datastore.result.CheckDumpUserDataByUserIdResult;

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

try {
    CheckDumpUserDataByUserIdResult result = client.checkDumpUserDataByUserId(
        new CheckDumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    String url = result.getUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.CheckDumpUserDataByUserIdResult> asyncResult = null;
yield return client.CheckDumpUserDataByUserId(
    new Gs2.Gs2Datastore.Request.CheckDumpUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.checkDumpUserDataByUserId(
        new Gs2Datastore.CheckDumpUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const url = result.getUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.check_dump_user_data_by_user_id(
        datastore.CheckDumpUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    url = result.url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.check_dump_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
url = result.url;

```

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

client = gs2('datastore')

api_result_handler = client.check_dump_user_data_by_user_id_async({
    userId="user-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
url = result.url;

```




---

### cleanUserDataByUserId

ユーザーデータの完全削除<br>

指定されたユーザーIDに紐づくデータのクリーニングを実行します。<br>
これにより、特定のユーザーデータをプロジェクトから安全に削除できます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.CleanUserDataByUserId(
    &datastore.CleanUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\CleanUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->cleanUserDataByUserId(
        (new CleanUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.CleanUserDataByUserIdRequest;
import io.gs2.datastore.result.CleanUserDataByUserIdResult;

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

try {
    CleanUserDataByUserIdResult result = client.cleanUserDataByUserId(
        new CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.CleanUserDataByUserIdResult> asyncResult = null;
yield return client.CleanUserDataByUserId(
    new Gs2.Gs2Datastore.Request.CleanUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.cleanUserDataByUserId(
        new Gs2Datastore.CleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.clean_user_data_by_user_id(
        datastore.CleanUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.clean_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result

```

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

client = gs2('datastore')

api_result_handler = client.clean_user_data_by_user_id_async({
    userId="user-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

```




---

### checkCleanUserDataByUserId

指定したユーザーIDのユーザーデータの完全削除が完了しているか確認



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.CheckCleanUserDataByUserId(
    &datastore.CheckCleanUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\CheckCleanUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->checkCleanUserDataByUserId(
        (new CheckCleanUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.CheckCleanUserDataByUserIdRequest;
import io.gs2.datastore.result.CheckCleanUserDataByUserIdResult;

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

try {
    CheckCleanUserDataByUserIdResult result = client.checkCleanUserDataByUserId(
        new CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.CheckCleanUserDataByUserIdResult> asyncResult = null;
yield return client.CheckCleanUserDataByUserId(
    new Gs2.Gs2Datastore.Request.CheckCleanUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.checkCleanUserDataByUserId(
        new Gs2Datastore.CheckCleanUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.check_clean_user_data_by_user_id(
        datastore.CheckCleanUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.check_clean_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result

```

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

client = gs2('datastore')

api_result_handler = client.check_clean_user_data_by_user_id_async({
    userId="user-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

```




---

### prepareImportUserDataByUserId

指定したユーザーIDに紐づくデータのインポートを準備<br>

インポートに使用できるデータは GS2 によってエクスポートして取得したデータに限定され、古いデータはインポートに失敗する可能性があります。<br>
エクスポートしたユーザーIDと異なるユーザーIDでインポートすることができますが、ユーザーデータのペイロード内にユーザーIDが含まれる場合はその限りではありません。<br>

このAPIの戻り値で応答されたURLにエクスポートした zip ファイルをアップロードし、importUserDataByUserId を呼び出すことで実際のインポート処理を開始できます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| uploadToken | string | アップロード後に結果を反映する際に使用するトークン |
| uploadUrl | string | ユーザーデータアップロード処理の実行に使用するURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareImportUserDataByUserId(
    &datastore.PrepareImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareImportUserDataByUserId(
        (new PrepareImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withTimeOffsetToken(null)
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareImportUserDataByUserIdRequest;
import io.gs2.datastore.result.PrepareImportUserDataByUserIdResult;

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

try {
    PrepareImportUserDataByUserIdResult result = client.prepareImportUserDataByUserId(
        new PrepareImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareImportUserDataByUserIdResult> asyncResult = null;
yield return client.PrepareImportUserDataByUserId(
    new Gs2.Gs2Datastore.Request.PrepareImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareImportUserDataByUserId(
        new Gs2Datastore.PrepareImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_import_user_data_by_user_id(
        datastore.PrepareImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_import_user_data_by_user_id({
    userId="user-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_import_user_data_by_user_id_async({
    userId="user-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
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

```




---

### importUserDataByUserId

指定したユーザーIDに紐づくデータのインポートを実行<br>

インポートに使用できるデータは GS2 によってエクスポートして取得したデータに限定され、古いデータはインポートに失敗する可能性があります。<br>
エクスポートしたユーザーIDと異なるユーザーIDでインポートすることができますが、ユーザーデータのペイロード内にユーザーIDが含まれる場合はその限りではありません。<br>

このAPIを呼び出す前に prepareImportUserDataByUserId を呼び出して、アップロード準備を完了させる必要があります。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| uploadToken | string |  | ✓|  |  ~ 1024文字 | アップロード準備で受け取ったトークン |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.ImportUserDataByUserId(
    &datastore.ImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        UploadToken: pointy.String("upload-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\ImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->importUserDataByUserId(
        (new ImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withUploadToken("upload-0001")
            ->withTimeOffsetToken(null)
    );
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.ImportUserDataByUserIdRequest;
import io.gs2.datastore.result.ImportUserDataByUserIdResult;

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

try {
    ImportUserDataByUserIdResult result = client.importUserDataByUserId(
        new ImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.ImportUserDataByUserIdResult> asyncResult = null;
yield return client.ImportUserDataByUserId(
    new Gs2.Gs2Datastore.Request.ImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithUploadToken("upload-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.importUserDataByUserId(
        new Gs2Datastore.ImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.import_user_data_by_user_id(
        datastore.ImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_upload_token('upload-0001')
            .with_time_offset_token(None)
    )
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.import_user_data_by_user_id({
    userId="user-0001",
    uploadToken="upload-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result

```

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

client = gs2('datastore')

api_result_handler = client.import_user_data_by_user_id_async({
    userId="user-0001",
    uploadToken="upload-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

```




---

### checkImportUserDataByUserId

指定したユーザーIDに紐づくデータのインポートが完了しているか確認



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| uploadToken | string |  | ✓|  |  ~ 1024文字 | アップロード準備で受け取ったトークン |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| url | string | 出力ログのURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.CheckImportUserDataByUserId(
    &datastore.CheckImportUserDataByUserIdRequest {
        UserId: pointy.String("user-0001"),
        UploadToken: pointy.String("upload-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
url := result.Url

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\CheckImportUserDataByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->checkImportUserDataByUserId(
        (new CheckImportUserDataByUserIdRequest())
            ->withUserId("user-0001")
            ->withUploadToken("upload-0001")
            ->withTimeOffsetToken(null)
    );
    $url = $result->getUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.CheckImportUserDataByUserIdRequest;
import io.gs2.datastore.result.CheckImportUserDataByUserIdResult;

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

try {
    CheckImportUserDataByUserIdResult result = client.checkImportUserDataByUserId(
        new CheckImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
    String url = result.getUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.CheckImportUserDataByUserIdResult> asyncResult = null;
yield return client.CheckImportUserDataByUserId(
    new Gs2.Gs2Datastore.Request.CheckImportUserDataByUserIdRequest()
        .WithUserId("user-0001")
        .WithUploadToken("upload-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var url = result.Url;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.checkImportUserDataByUserId(
        new Gs2Datastore.CheckImportUserDataByUserIdRequest()
            .withUserId("user-0001")
            .withUploadToken("upload-0001")
            .withTimeOffsetToken(null)
    );
    const url = result.getUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.check_import_user_data_by_user_id(
        datastore.CheckImportUserDataByUserIdRequest()
            .with_user_id('user-0001')
            .with_upload_token('upload-0001')
            .with_time_offset_token(None)
    )
    url = result.url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.check_import_user_data_by_user_id({
    userId="user-0001",
    uploadToken="upload-0001",
    timeOffsetToken=nil,
})

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

result = api_result.result
url = result.url;

```

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

client = gs2('datastore')

api_result_handler = client.check_import_user_data_by_user_id_async({
    userId="user-0001",
    uploadToken="upload-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
url = result.url;

```




---

### describeDataObjects

データオブジェクトの一覧を取得<br>

指定されたネームスペースで現在ログインしているユーザーが所有するデータオブジェクトのページネーション付きリストを取得します。<br>
オプションでステータス（ACTIVE、UPLOADING、DELETED）を指定して、特定の状態のオブジェクトのみを取得できます。<br>
ステータスフィルターを指定しない場合、ステータスに関係なくすべてのデータオブジェクトが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| status | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"ACTIVE",<br>&nbsp;&nbsp;"UPLOADING",<br>&nbsp;&nbsp;"DELETED"<br>}<br> |  | |  |  | 状態"ACTIVE": 有効 / "UPLOADING": アップロード中 / "DELETED": 削除済み(削除処理から30日後に実際に削除) /  |
| pageToken | string |  | |  |  ~ 1024文字 | データの取得を開始する位置を指定するトークン |
| limit | int |  | | 30 | 1 ~ 1000 | データの取得件数 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| items | [List&lt;DataObject&gt;](#dataobject) | データオブジェクトのリスト |
| nextPageToken | string | リストの続きを取得するためのページトークン |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DescribeDataObjects(
    &datastore.DescribeDataObjectsRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        Status: pointy.String("ACTIVE"),
        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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DescribeDataObjectsRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->describeDataObjects(
        (new DescribeDataObjectsRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withStatus("ACTIVE")
            ->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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DescribeDataObjectsRequest;
import io.gs2.datastore.result.DescribeDataObjectsResult;

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

try {
    DescribeDataObjectsResult result = client.describeDataObjects(
        new DescribeDataObjectsRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatus("ACTIVE")
            .withPageToken(null)
            .withLimit(null)
    );
    List<DataObject> 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DescribeDataObjectsResult> asyncResult = null;
yield return client.DescribeDataObjects(
    new Gs2.Gs2Datastore.Request.DescribeDataObjectsRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithStatus("ACTIVE")
        .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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.describeDataObjects(
        new Gs2Datastore.DescribeDataObjectsRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withStatus("ACTIVE")
            .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 datastore

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

try:
    result = client.describe_data_objects(
        datastore.DescribeDataObjectsRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_status('ACTIVE')
            .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('datastore')

api_result = client.describe_data_objects({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    status="ACTIVE",
    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('datastore')

api_result_handler = client.describe_data_objects_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    status="ACTIVE",
    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;

```




---

### describeDataObjectsByUserId

ユーザーIDを指定してデータオブジェクトの一覧を取得<br>

指定されたネームスペースで指定されたユーザーが所有するデータオブジェクトのページネーション付きリストを取得します。<br>
オプションでステータス（ACTIVE、UPLOADING、DELETED）を指定して、特定の状態のオブジェクトのみを取得できます。<br>
ステータスフィルターを指定しない場合、ステータスに関係なくすべてのデータオブジェクトが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| status | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"ACTIVE",<br>&nbsp;&nbsp;"UPLOADING",<br>&nbsp;&nbsp;"DELETED"<br>}<br> |  | |  |  | 状態"ACTIVE": 有効 / "UPLOADING": アップロード中 / "DELETED": 削除済み(削除処理から30日後に実際に削除) /  |
| pageToken | string |  | |  |  ~ 1024文字 | データの取得を開始する位置を指定するトークン |
| limit | int |  | | 30 | 1 ~ 1000 | データの取得件数 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| items | [List&lt;DataObject&gt;](#dataobject) | データオブジェクトのリスト |
| nextPageToken | string | リストの続きを取得するためのページトークン |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DescribeDataObjectsByUserId(
    &datastore.DescribeDataObjectsByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        Status: pointy.String("ACTIVE"),
        PageToken: nil,
        Limit: nil,
        TimeOffsetToken: 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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DescribeDataObjectsByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->describeDataObjectsByUserId(
        (new DescribeDataObjectsByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withStatus("ACTIVE")
            ->withPageToken(null)
            ->withLimit(null)
            ->withTimeOffsetToken(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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DescribeDataObjectsByUserIdRequest;
import io.gs2.datastore.result.DescribeDataObjectsByUserIdResult;

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

try {
    DescribeDataObjectsByUserIdResult result = client.describeDataObjectsByUserId(
        new DescribeDataObjectsByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatus("ACTIVE")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    List<DataObject> 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DescribeDataObjectsByUserIdResult> asyncResult = null;
yield return client.DescribeDataObjectsByUserId(
    new Gs2.Gs2Datastore.Request.DescribeDataObjectsByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithStatus("ACTIVE")
        .WithPageToken(null)
        .WithLimit(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.describeDataObjectsByUserId(
        new Gs2Datastore.DescribeDataObjectsByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withStatus("ACTIVE")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.describe_data_objects_by_user_id(
        datastore.DescribeDataObjectsByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_status('ACTIVE')
            .with_page_token(None)
            .with_limit(None)
            .with_time_offset_token(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.describe_data_objects_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    status="ACTIVE",
    pageToken=nil,
    limit=nil,
    timeOffsetToken=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('datastore')

api_result_handler = client.describe_data_objects_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    status="ACTIVE",
    pageToken=nil,
    limit=nil,
    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
items = result.items;
nextPageToken = result.nextPageToken;

```




---

### prepareUpload

データオブジェクトのアップロードを準備する<br>

新しいデータオブジェクトを作成し、ファイルアップロード用の署名付きクラウドストレージ URL を生成します。<br>
データオブジェクト名は省略可能で、省略した場合は UUID が自動的に割り当てられます。<br>
アクセススコープ（public / protected / private）の設定と、オブジェクトへのアクセスを許可するユーザーIDのリストを指定できます。<br>
updateIfExists が true で同名のオブジェクトが既に存在する場合、既存オブジェクトのスコープと権限が更新され、エラーの代わりに再アップロード用の URL が生成されます。<br>
返された署名付き URL を使用してファイルデータを直接 PUT してください。アップロード後、DoneUpload を呼び出してデータオブジェクトを確定します。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| name | string |  | |  |  ~ 128文字 | データオブジェクトの名前<br>指定しなかった場合、自動的にUUIDが割り当てられます。 |
| contentType | string |  | | "application/octet-stream" |  ~ 256文字 | アップロードするデータの MIME-Type |
| scope | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"public",<br>&nbsp;&nbsp;"protected",<br>&nbsp;&nbsp;"private"<br>}<br> |  | | "private" |  | ファイルのアクセス権<br>このデータオブジェクトにアクセスできるユーザーを制御します。`public` は誰でもアクセス可能、`protected` は allowUserIds に指定されたユーザーIDのみアクセス可能、`private` はオーナー本人のみアクセス可能です。"public": 公開 / "protected": 指定したユーザーにのみ公開 / "private": 非公開 /  |
| allowUserIds | List&lt;string&gt; | {scope} == "protected" | | [] | 0 ~ 100 items | 公開するユーザーIDリスト<br>スコープが `protected` に設定されている場合に、このデータオブジェクトにアクセスできるユーザーを指定します。このリストに含まれるユーザーIDのユーザーのみが読み取りアクセスを許可されます。<br>※ scope が "protected" であれば有効 |
| updateIfExists | bool |  | | false |  | 既にデータが存在する場合にエラーとするか、データを更新するか |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| uploadUrl | string | アップロード処理の実行に使用するURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareUpload(
    &datastore.PrepareUploadRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        Name: pointy.String("dataObject-0001"),
        ContentType: pointy.String("application/octet-stream"),
        Scope: pointy.String("public"),
        AllowUserIds: nil,
        UpdateIfExists: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
uploadUrl := result.UploadUrl

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareUploadRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareUpload(
        (new PrepareUploadRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withName("dataObject-0001")
            ->withContentType("application/octet-stream")
            ->withScope("public")
            ->withAllowUserIds(null)
            ->withUpdateIfExists(null)
    );
    $item = $result->getItem();
    $uploadUrl = $result->getUploadUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareUploadRequest;
import io.gs2.datastore.result.PrepareUploadResult;

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

try {
    PrepareUploadResult result = client.prepareUpload(
        new PrepareUploadRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withName("dataObject-0001")
            .withContentType("application/octet-stream")
            .withScope("public")
            .withAllowUserIds(null)
            .withUpdateIfExists(null)
    );
    DataObject item = result.getItem();
    String uploadUrl = result.getUploadUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareUploadResult> asyncResult = null;
yield return client.PrepareUpload(
    new Gs2.Gs2Datastore.Request.PrepareUploadRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithName("dataObject-0001")
        .WithContentType("application/octet-stream")
        .WithScope("public")
        .WithAllowUserIds(null)
        .WithUpdateIfExists(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var uploadUrl = result.UploadUrl;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareUpload(
        new Gs2Datastore.PrepareUploadRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withName("dataObject-0001")
            .withContentType("application/octet-stream")
            .withScope("public")
            .withAllowUserIds(null)
            .withUpdateIfExists(null)
    );
    const item = result.getItem();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_upload(
        datastore.PrepareUploadRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_name('dataObject-0001')
            .with_content_type('application/octet-stream')
            .with_scope('public')
            .with_allow_user_ids(None)
            .with_update_if_exists(None)
    )
    item = result.item
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_upload({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    name="dataObject-0001",
    contentType="application/octet-stream",
    scope="public",
    allowUserIds=nil,
    updateIfExists=nil,
})

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

result = api_result.result
item = result.item;
uploadUrl = result.uploadUrl;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_upload_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    name="dataObject-0001",
    contentType="application/octet-stream",
    scope="public",
    allowUserIds=nil,
    updateIfExists=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;
uploadUrl = result.uploadUrl;

```




---

### prepareUploadByUserId

ユーザーIDを指定してデータオブジェクトのアップロードを準備する<br>

指定されたユーザーの新しいデータオブジェクトを作成し、ファイルアップロード用の署名付きクラウドストレージ URL を生成します。<br>
データオブジェクト名は省略可能で、省略した場合は UUID が自動的に割り当てられます。<br>
アクセススコープ（public / protected / private）の設定と、オブジェクトへのアクセスを許可するユーザーIDのリストを指定できます。<br>
updateIfExists が true で同名のオブジェクトが既に存在する場合、既存オブジェクトのスコープと権限が更新され、エラーの代わりに再アップロード用の URL が生成されます。<br>
返された署名付き URL を使用してファイルデータを直接 PUT してください。アップロード後、DoneUpload を呼び出してデータオブジェクトを確定します。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| name | string |  | |  |  ~ 128文字 | データオブジェクトの名前<br>指定しなかった場合、自動的にUUIDが割り当てられます。 |
| contentType | string |  | | "application/octet-stream" |  ~ 256文字 | アップロードするデータの MIME-Type |
| scope | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"public",<br>&nbsp;&nbsp;"protected",<br>&nbsp;&nbsp;"private"<br>}<br> |  | | "private" |  | ファイルのアクセス権<br>このデータオブジェクトにアクセスできるユーザーを制御します。`public` は誰でもアクセス可能、`protected` は allowUserIds に指定されたユーザーIDのみアクセス可能、`private` はオーナー本人のみアクセス可能です。"public": 公開 / "protected": 指定したユーザーにのみ公開 / "private": 非公開 /  |
| allowUserIds | List&lt;string&gt; | {scope} == "protected" | | [] | 0 ~ 100 items | 公開するユーザーIDリスト<br>スコープが `protected` に設定されている場合に、このデータオブジェクトにアクセスできるユーザーを指定します。このリストに含まれるユーザーIDのユーザーのみが読み取りアクセスを許可されます。<br>※ scope が "protected" であれば有効 |
| updateIfExists | bool |  | | false |  | 既にデータが存在する場合にエラーとするか、データを更新するか |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| uploadUrl | string | アップロード処理の実行に使用するURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareUploadByUserId(
    &datastore.PrepareUploadByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        Name: pointy.String("dataObject-0001"),
        ContentType: pointy.String("application/octet-stream"),
        Scope: pointy.String("public"),
        AllowUserIds: nil,
        UpdateIfExists: nil,
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
uploadUrl := result.UploadUrl

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareUploadByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareUploadByUserId(
        (new PrepareUploadByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withName("dataObject-0001")
            ->withContentType("application/octet-stream")
            ->withScope("public")
            ->withAllowUserIds(null)
            ->withUpdateIfExists(null)
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
    $uploadUrl = $result->getUploadUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareUploadByUserIdRequest;
import io.gs2.datastore.result.PrepareUploadByUserIdResult;

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

try {
    PrepareUploadByUserIdResult result = client.prepareUploadByUserId(
        new PrepareUploadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withName("dataObject-0001")
            .withContentType("application/octet-stream")
            .withScope("public")
            .withAllowUserIds(null)
            .withUpdateIfExists(null)
            .withTimeOffsetToken(null)
    );
    DataObject item = result.getItem();
    String uploadUrl = result.getUploadUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareUploadByUserIdResult> asyncResult = null;
yield return client.PrepareUploadByUserId(
    new Gs2.Gs2Datastore.Request.PrepareUploadByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithName("dataObject-0001")
        .WithContentType("application/octet-stream")
        .WithScope("public")
        .WithAllowUserIds(null)
        .WithUpdateIfExists(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var uploadUrl = result.UploadUrl;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareUploadByUserId(
        new Gs2Datastore.PrepareUploadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withName("dataObject-0001")
            .withContentType("application/octet-stream")
            .withScope("public")
            .withAllowUserIds(null)
            .withUpdateIfExists(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_upload_by_user_id(
        datastore.PrepareUploadByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_name('dataObject-0001')
            .with_content_type('application/octet-stream')
            .with_scope('public')
            .with_allow_user_ids(None)
            .with_update_if_exists(None)
            .with_time_offset_token(None)
    )
    item = result.item
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_upload_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    name="dataObject-0001",
    contentType="application/octet-stream",
    scope="public",
    allowUserIds=nil,
    updateIfExists=nil,
    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;
uploadUrl = result.uploadUrl;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_upload_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    name="dataObject-0001",
    contentType="application/octet-stream",
    scope="public",
    allowUserIds=nil,
    updateIfExists=nil,
    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;
uploadUrl = result.uploadUrl;

```




---

### updateDataObject

データオブジェクトを更新<br>

現在ログインしているユーザーが所有する既存のデータオブジェクトのメタデータを更新します。<br>
アクセススコープ（public / protected / private）とオブジェクトへのアクセスを許可するユーザーIDのリストを変更できます。<br>
この操作はアクセス制御設定のみを更新し、ファイルの内容自体は変更されません。ファイルの内容を更新するには、代わりに PrepareReUpload を使用してください。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| scope | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"public",<br>&nbsp;&nbsp;"protected",<br>&nbsp;&nbsp;"private"<br>}<br> |  | | "private" |  | ファイルのアクセス権<br>このデータオブジェクトにアクセスできるユーザーを制御します。`public` は誰でもアクセス可能、`protected` は allowUserIds に指定されたユーザーIDのみアクセス可能、`private` はオーナー本人のみアクセス可能です。"public": 公開 / "protected": 指定したユーザーにのみ公開 / "private": 非公開 /  |
| allowUserIds | List&lt;string&gt; | {scope} == "protected" | | [] | 0 ~ 100 items | 公開するユーザーIDリスト<br>スコープが `protected` に設定されている場合に、このデータオブジェクトにアクセスできるユーザーを指定します。このリストに含まれるユーザーIDのユーザーのみが読み取りアクセスを許可されます。<br>※ scope が "protected" であれば有効 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.UpdateDataObject(
    &datastore.UpdateDataObjectRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        Scope: pointy.String("public"),
        AllowUserIds: 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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\UpdateDataObjectRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->updateDataObject(
        (new UpdateDataObjectRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectName("dataObject-0001")
            ->withAccessToken("accessToken-0001")
            ->withScope("public")
            ->withAllowUserIds(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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.UpdateDataObjectRequest;
import io.gs2.datastore.result.UpdateDataObjectResult;

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

try {
    UpdateDataObjectResult result = client.updateDataObject(
        new UpdateDataObjectRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withAccessToken("accessToken-0001")
            .withScope("public")
            .withAllowUserIds(null)
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.UpdateDataObjectResult> asyncResult = null;
yield return client.UpdateDataObject(
    new Gs2.Gs2Datastore.Request.UpdateDataObjectRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectName("dataObject-0001")
        .WithAccessToken("accessToken-0001")
        .WithScope("public")
        .WithAllowUserIds(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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.updateDataObject(
        new Gs2Datastore.UpdateDataObjectRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withAccessToken("accessToken-0001")
            .withScope("public")
            .withAllowUserIds(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.update_data_object(
        datastore.UpdateDataObjectRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_name('dataObject-0001')
            .with_access_token('accessToken-0001')
            .with_scope('public')
            .with_allow_user_ids(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.update_data_object({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    accessToken="accessToken-0001",
    scope="public",
    allowUserIds=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('datastore')

api_result_handler = client.update_data_object_async({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    accessToken="accessToken-0001",
    scope="public",
    allowUserIds=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;

```




---

### updateDataObjectByUserId

ユーザーIDを指定してデータオブジェクトを更新<br>

指定されたユーザーが所有する既存のデータオブジェクトのメタデータを更新します。<br>
アクセススコープ（public / protected / private）とオブジェクトへのアクセスを許可するユーザーIDのリストを変更できます。<br>
この操作はアクセス制御設定のみを更新し、ファイルの内容自体は変更されません。ファイルの内容を更新するには、代わりに PrepareReUpload を使用してください。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| scope | 文字列列挙型<br>enum {<br>&nbsp;&nbsp;"public",<br>&nbsp;&nbsp;"protected",<br>&nbsp;&nbsp;"private"<br>}<br> |  | | "private" |  | ファイルのアクセス権<br>このデータオブジェクトにアクセスできるユーザーを制御します。`public` は誰でもアクセス可能、`protected` は allowUserIds に指定されたユーザーIDのみアクセス可能、`private` はオーナー本人のみアクセス可能です。"public": 公開 / "protected": 指定したユーザーにのみ公開 / "private": 非公開 /  |
| allowUserIds | List&lt;string&gt; | {scope} == "protected" | | [] | 0 ~ 100 items | 公開するユーザーIDリスト<br>スコープが `protected` に設定されている場合に、このデータオブジェクトにアクセスできるユーザーを指定します。このリストに含まれるユーザーIDのユーザーのみが読み取りアクセスを許可されます。<br>※ scope が "protected" であれば有効 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.UpdateDataObjectByUserId(
    &datastore.UpdateDataObjectByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        UserId: pointy.String("user-0001"),
        Scope: pointy.String("public"),
        AllowUserIds: nil,
        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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\UpdateDataObjectByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->updateDataObjectByUserId(
        (new UpdateDataObjectByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectName("dataObject-0001")
            ->withUserId("user-0001")
            ->withScope("public")
            ->withAllowUserIds(null)
            ->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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.UpdateDataObjectByUserIdRequest;
import io.gs2.datastore.result.UpdateDataObjectByUserIdResult;

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

try {
    UpdateDataObjectByUserIdResult result = client.updateDataObjectByUserId(
        new UpdateDataObjectByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withUserId("user-0001")
            .withScope("public")
            .withAllowUserIds(null)
            .withTimeOffsetToken(null)
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.UpdateDataObjectByUserIdResult> asyncResult = null;
yield return client.UpdateDataObjectByUserId(
    new Gs2.Gs2Datastore.Request.UpdateDataObjectByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectName("dataObject-0001")
        .WithUserId("user-0001")
        .WithScope("public")
        .WithAllowUserIds(null)
        .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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.updateDataObjectByUserId(
        new Gs2Datastore.UpdateDataObjectByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withUserId("user-0001")
            .withScope("public")
            .withAllowUserIds(null)
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.update_data_object_by_user_id(
        datastore.UpdateDataObjectByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_name('dataObject-0001')
            .with_user_id('user-0001')
            .with_scope('public')
            .with_allow_user_ids(None)
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.update_data_object_by_user_id({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    userId="user-0001",
    scope="public",
    allowUserIds=nil,
    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('datastore')

api_result_handler = client.update_data_object_by_user_id_async({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    userId="user-0001",
    scope="public",
    allowUserIds=nil,
    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;

```




---

### prepareReUpload

データオブジェクトの再アップロードを準備する<br>

既存のデータオブジェクトのファイル内容を再アップロードするための新しい署名付きクラウドストレージ URL を生成します。<br>
データオブジェクトのステータスは UPLOADING に変更され、新しい世代番号が割り当てられます。<br>
以前のバージョンのファイルはデータオブジェクト履歴に保持され、世代番号を指定して古いバージョンをダウンロードできます。<br>
返された URL に新しいファイルをアップロードした後、DoneUpload を呼び出して更新を確定します。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| contentType | string |  | | "application/octet-stream" |  ~ 256文字 | アップロードするデータオブジェクトの MIME-Type |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| uploadUrl | string | アップロード処理の実行に使用するURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareReUpload(
    &datastore.PrepareReUploadRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        ContentType: pointy.String("application/octet-stream"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
uploadUrl := result.UploadUrl

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareReUploadRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareReUpload(
        (new PrepareReUploadRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectName("dataObject-0001")
            ->withAccessToken("accessToken-0001")
            ->withContentType("application/octet-stream")
    );
    $item = $result->getItem();
    $uploadUrl = $result->getUploadUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareReUploadRequest;
import io.gs2.datastore.result.PrepareReUploadResult;

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

try {
    PrepareReUploadResult result = client.prepareReUpload(
        new PrepareReUploadRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withAccessToken("accessToken-0001")
            .withContentType("application/octet-stream")
    );
    DataObject item = result.getItem();
    String uploadUrl = result.getUploadUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareReUploadResult> asyncResult = null;
yield return client.PrepareReUpload(
    new Gs2.Gs2Datastore.Request.PrepareReUploadRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectName("dataObject-0001")
        .WithAccessToken("accessToken-0001")
        .WithContentType("application/octet-stream"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var uploadUrl = result.UploadUrl;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareReUpload(
        new Gs2Datastore.PrepareReUploadRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withAccessToken("accessToken-0001")
            .withContentType("application/octet-stream")
    );
    const item = result.getItem();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_re_upload(
        datastore.PrepareReUploadRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_name('dataObject-0001')
            .with_access_token('accessToken-0001')
            .with_content_type('application/octet-stream')
    )
    item = result.item
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_re_upload({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    accessToken="accessToken-0001",
    contentType="application/octet-stream",
})

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

result = api_result.result
item = result.item;
uploadUrl = result.uploadUrl;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_re_upload_async({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    accessToken="accessToken-0001",
    contentType="application/octet-stream",
})

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;
uploadUrl = result.uploadUrl;

```




---

### prepareReUploadByUserId

ユーザーIDを指定してデータオブジェクトの再アップロードを準備する<br>

指定されたユーザーが所有する既存のデータオブジェクトのファイル内容を再アップロードするための新しい署名付きクラウドストレージ URL を生成します。<br>
データオブジェクトのステータスは UPLOADING に変更され、新しい世代番号が割り当てられます。<br>
以前のバージョンのファイルはデータオブジェクト履歴に保持されます。<br>
返された URL に新しいファイルをアップロードした後、DoneUpload を呼び出して更新を確定します。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| contentType | string |  | | "application/octet-stream" |  ~ 256文字 | アップロードするデータオブジェクトの MIME-Type |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| uploadUrl | string | アップロード処理の実行に使用するURL |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareReUploadByUserId(
    &datastore.PrepareReUploadByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        UserId: pointy.String("user-0001"),
        ContentType: pointy.String("application/octet-stream"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
uploadUrl := result.UploadUrl

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareReUploadByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareReUploadByUserId(
        (new PrepareReUploadByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectName("dataObject-0001")
            ->withUserId("user-0001")
            ->withContentType("application/octet-stream")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
    $uploadUrl = $result->getUploadUrl();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareReUploadByUserIdRequest;
import io.gs2.datastore.result.PrepareReUploadByUserIdResult;

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

try {
    PrepareReUploadByUserIdResult result = client.prepareReUploadByUserId(
        new PrepareReUploadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withUserId("user-0001")
            .withContentType("application/octet-stream")
            .withTimeOffsetToken(null)
    );
    DataObject item = result.getItem();
    String uploadUrl = result.getUploadUrl();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareReUploadByUserIdResult> asyncResult = null;
yield return client.PrepareReUploadByUserId(
    new Gs2.Gs2Datastore.Request.PrepareReUploadByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectName("dataObject-0001")
        .WithUserId("user-0001")
        .WithContentType("application/octet-stream")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var uploadUrl = result.UploadUrl;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareReUploadByUserId(
        new Gs2Datastore.PrepareReUploadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withUserId("user-0001")
            .withContentType("application/octet-stream")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_re_upload_by_user_id(
        datastore.PrepareReUploadByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_name('dataObject-0001')
            .with_user_id('user-0001')
            .with_content_type('application/octet-stream')
            .with_time_offset_token(None)
    )
    item = result.item
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_re_upload_by_user_id({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    userId="user-0001",
    contentType="application/octet-stream",
    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;
uploadUrl = result.uploadUrl;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_re_upload_by_user_id_async({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    userId="user-0001",
    contentType="application/octet-stream",
    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;
uploadUrl = result.uploadUrl;

```




---

### doneUpload

データオブジェクトのアップロード完了を報告<br>

PrepareUpload または PrepareReUpload で取得した署名付き URL にファイルがアップロードされた後、データオブジェクトを確定します。<br>
データオブジェクトのステータスが UPLOADING から ACTIVE に変更され、ファイルメタデータ（サイズ、世代）が記録されます。<br>
ネームスペース設定で doneUploadScript が設定されている場合、アップロード確認後にフックとしてスクリプトが実行されます。<br>
データオブジェクトが UPLOADING 状態でない場合、またはアップロードされたファイルが見つからない場合はエラーが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DoneUpload(
    &datastore.DoneUploadRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        AccessToken: pointy.String("accessToken-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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DoneUploadRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->doneUpload(
        (new DoneUploadRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectName("dataObject-0001")
            ->withAccessToken("accessToken-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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DoneUploadRequest;
import io.gs2.datastore.result.DoneUploadResult;

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

try {
    DoneUploadResult result = client.doneUpload(
        new DoneUploadRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withAccessToken("accessToken-0001")
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DoneUploadResult> asyncResult = null;
yield return client.DoneUpload(
    new Gs2.Gs2Datastore.Request.DoneUploadRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectName("dataObject-0001")
        .WithAccessToken("accessToken-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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.doneUpload(
        new Gs2Datastore.DoneUploadRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withAccessToken("accessToken-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.done_upload(
        datastore.DoneUploadRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_name('dataObject-0001')
            .with_access_token('accessToken-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.done_upload({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    accessToken="accessToken-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('datastore')

api_result_handler = client.done_upload_async({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    accessToken="accessToken-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;

```




---

### doneUploadByUserId

ユーザーIDを指定してデータオブジェクトのアップロード完了を報告<br>

PrepareUpload または PrepareReUpload で取得した署名付き URL にファイルがアップロードされた後、データオブジェクトを確定します。<br>
データオブジェクトのステータスが UPLOADING から ACTIVE に変更され、ファイルメタデータ（サイズ、世代）が記録されます。<br>
ネームスペース設定で doneUploadScript が設定されている場合、アップロード確認後にフックとしてスクリプトが実行されます。<br>
データオブジェクトが UPLOADING 状態でない場合、またはアップロードされたファイルが見つからない場合はエラーが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DoneUploadByUserId(
    &datastore.DoneUploadByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        UserId: pointy.String("user-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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DoneUploadByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->doneUploadByUserId(
        (new DoneUploadByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectName("dataObject-0001")
            ->withUserId("user-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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DoneUploadByUserIdRequest;
import io.gs2.datastore.result.DoneUploadByUserIdResult;

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

try {
    DoneUploadByUserIdResult result = client.doneUploadByUserId(
        new DoneUploadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DoneUploadByUserIdResult> asyncResult = null;
yield return client.DoneUploadByUserId(
    new Gs2.Gs2Datastore.Request.DoneUploadByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectName("dataObject-0001")
        .WithUserId("user-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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.doneUploadByUserId(
        new Gs2Datastore.DoneUploadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectName("dataObject-0001")
            .withUserId("user-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.done_upload_by_user_id(
        datastore.DoneUploadByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_name('dataObject-0001')
            .with_user_id('user-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.done_upload_by_user_id({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    userId="user-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('datastore')

api_result_handler = client.done_upload_by_user_id_async({
    namespaceName="namespace-0001",
    dataObjectName="dataObject-0001",
    userId="user-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;

```




---

### deleteDataObject

データオブジェクトの削除<br>

指定されたデータオブジェクトを削除対象としてマークします。<br>
現在ログインしているユーザーが所有するデータオブジェクトが対象です。実際のファイルデータは30日後に削除されます。<br>
データオブジェクトが削除可能な状態にない場合（例：アップロード中）はエラーが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DeleteDataObject(
    &datastore.DeleteDataObjectRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectName: pointy.String("dataObject-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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DeleteDataObjectRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->deleteDataObject(
        (new DeleteDataObjectRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectName("dataObject-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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DeleteDataObjectRequest;
import io.gs2.datastore.result.DeleteDataObjectResult;

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

try {
    DeleteDataObjectResult result = client.deleteDataObject(
        new DeleteDataObjectRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DeleteDataObjectResult> asyncResult = null;
yield return client.DeleteDataObject(
    new Gs2.Gs2Datastore.Request.DeleteDataObjectRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectName("dataObject-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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.deleteDataObject(
        new Gs2Datastore.DeleteDataObjectRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.delete_data_object(
        datastore.DeleteDataObjectRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_name('dataObject-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.delete_data_object({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-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('datastore')

api_result_handler = client.delete_data_object_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-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;

```




---

### deleteDataObjectByUserId

ユーザーIDを指定してデータオブジェクトの削除<br>

指定されたユーザーが所有する指定されたデータオブジェクトを削除対象としてマークします。<br>
実際のファイルデータは30日後に削除されます。<br>
データオブジェクトが削除可能な状態にない場合（例：アップロード中）はエラーが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DeleteDataObjectByUserId(
    &datastore.DeleteDataObjectByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectName: pointy.String("dataObject-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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DeleteDataObjectByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->deleteDataObjectByUserId(
        (new DeleteDataObjectByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectName("dataObject-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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DeleteDataObjectByUserIdRequest;
import io.gs2.datastore.result.DeleteDataObjectByUserIdResult;

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

try {
    DeleteDataObjectByUserIdResult result = client.deleteDataObjectByUserId(
        new DeleteDataObjectByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withTimeOffsetToken(null)
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DeleteDataObjectByUserIdResult> asyncResult = null;
yield return client.DeleteDataObjectByUserId(
    new Gs2.Gs2Datastore.Request.DeleteDataObjectByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectName("dataObject-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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.deleteDataObjectByUserId(
        new Gs2Datastore.DeleteDataObjectByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.delete_data_object_by_user_id(
        datastore.DeleteDataObjectByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_name('dataObject-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.delete_data_object_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-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('datastore')

api_result_handler = client.delete_data_object_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-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;

```




---

### prepareDownload

データオブジェクトのダウンロード準備<br>

指定されたデータオブジェクトの最新バージョンをダウンロードするための署名付きクラウドストレージ URL を生成します。<br>
データオブジェクトは GRN（dataObjectId）で指定します。アクセス制御が適用され、データの所有者または allowUserIds に登録されたユーザーのみがダウンロードできます。<br>
署名付きダウンロード URL とファイルサイズ（コンテンツ長）が返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectId | string |  | ✓|  |  ~ 1024文字 | データオブジェクトGRN |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownload(
    &datastore.PrepareDownloadRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownload(
        (new PrepareDownloadRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadRequest;
import io.gs2.datastore.result.PrepareDownloadResult;

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

try {
    PrepareDownloadResult result = client.prepareDownload(
        new PrepareDownloadRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadResult> asyncResult = null;
yield return client.PrepareDownload(
    new Gs2.Gs2Datastore.Request.PrepareDownloadRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownload(
        new Gs2Datastore.PrepareDownloadRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download(
        datastore.PrepareDownloadRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_id('grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001')
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001",
})

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

result = api_result.result
item = result.item;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadByUserId

ユーザーIDを指定してデータオブジェクトのダウンロード準備<br>

指定されたデータオブジェクトの最新バージョンをダウンロードするための署名付きクラウドストレージ URL を生成します。<br>
データオブジェクトは GRN（dataObjectId）で指定します。アクセス制御が適用され、データの所有者または allowUserIds に登録されたユーザーのみがダウンロードできます。<br>
署名付きダウンロード URL とファイルサイズ（コンテンツ長）が返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectId | string |  | ✓|  |  ~ 1024文字 | データオブジェクトGRN |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadByUserId(
    &datastore.PrepareDownloadByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadByUserId(
        (new PrepareDownloadByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadByUserIdRequest;
import io.gs2.datastore.result.PrepareDownloadByUserIdResult;

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

try {
    PrepareDownloadByUserIdResult result = client.prepareDownloadByUserId(
        new PrepareDownloadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            .withTimeOffsetToken(null)
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadByUserIdResult> asyncResult = null;
yield return client.PrepareDownloadByUserId(
    new Gs2.Gs2Datastore.Request.PrepareDownloadByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadByUserId(
        new Gs2Datastore.PrepareDownloadByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_by_user_id(
        datastore.PrepareDownloadByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_id('grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001')
            .with_time_offset_token(None)
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadByGeneration

データオブジェクトを世代を指定してダウンロード準備<br>

データオブジェクトの特定のバージョン（世代）をダウンロードするための署名付きクラウドストレージ URL を生成します。<br>
データの再アップロード時に保持された以前のバージョンのファイルにアクセスできます。<br>
アクセス制御が適用され、データの所有者または allowUserIds に登録されたユーザーのみがダウンロードできます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectId | string |  | ✓|  |  ~ 1024文字 | データオブジェクトGRN |
| generation | string |  | ✓|  |  ~ 128文字 | データの世代 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadByGeneration(
    &datastore.PrepareDownloadByGenerationRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001"),
        Generation: pointy.String("generation-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadByGenerationRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadByGeneration(
        (new PrepareDownloadByGenerationRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            ->withGeneration("generation-0001")
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadByGenerationRequest;
import io.gs2.datastore.result.PrepareDownloadByGenerationResult;

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

try {
    PrepareDownloadByGenerationResult result = client.prepareDownloadByGeneration(
        new PrepareDownloadByGenerationRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            .withGeneration("generation-0001")
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadByGenerationResult> asyncResult = null;
yield return client.PrepareDownloadByGeneration(
    new Gs2.Gs2Datastore.Request.PrepareDownloadByGenerationRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
        .WithGeneration("generation-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadByGeneration(
        new Gs2Datastore.PrepareDownloadByGenerationRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            .withGeneration("generation-0001")
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_by_generation(
        datastore.PrepareDownloadByGenerationRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_id('grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001')
            .with_generation('generation-0001')
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_by_generation({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001",
    generation="generation-0001",
})

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

result = api_result.result
item = result.item;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_by_generation_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001",
    generation="generation-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadByGenerationAndUserId

ユーザーIDを指定してデータオブジェクトの世代を指定してダウンロード準備<br>

データオブジェクトの特定のバージョン（世代）をダウンロードするための署名付きクラウドストレージ URL を生成します。<br>
データの再アップロード時に保持された以前のバージョンのファイルにアクセスできます。<br>
アクセス制御が適用され、データの所有者または allowUserIds に登録されたユーザーのみがダウンロードできます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectId | string |  | ✓|  |  ~ 1024文字 | データオブジェクトGRN |
| generation | string |  | ✓|  |  ~ 128文字 | データの世代 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadByGenerationAndUserId(
    &datastore.PrepareDownloadByGenerationAndUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001"),
        Generation: pointy.String("generation-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadByGenerationAndUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadByGenerationAndUserId(
        (new PrepareDownloadByGenerationAndUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            ->withGeneration("generation-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadByGenerationAndUserIdRequest;
import io.gs2.datastore.result.PrepareDownloadByGenerationAndUserIdResult;

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

try {
    PrepareDownloadByGenerationAndUserIdResult result = client.prepareDownloadByGenerationAndUserId(
        new PrepareDownloadByGenerationAndUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            .withGeneration("generation-0001")
            .withTimeOffsetToken(null)
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadByGenerationAndUserIdResult> asyncResult = null;
yield return client.PrepareDownloadByGenerationAndUserId(
    new Gs2.Gs2Datastore.Request.PrepareDownloadByGenerationAndUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
        .WithGeneration("generation-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadByGenerationAndUserId(
        new Gs2Datastore.PrepareDownloadByGenerationAndUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
            .withGeneration("generation-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_by_generation_and_user_id(
        datastore.PrepareDownloadByGenerationAndUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_id('grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001')
            .with_generation('generation-0001')
            .with_time_offset_token(None)
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_by_generation_and_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001",
    generation="generation-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_by_generation_and_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001",
    generation="generation-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadOwnData

名前を指定して自分のデータオブジェクトのダウンロード準備<br>

GRN（dataObjectId）の代わりに名前を指定して、現在ログインしているユーザー自身のデータオブジェクトをダウンロードするための簡易APIです。<br>
署名付きダウンロード URL とファイルサイズ（コンテンツ長）が返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadOwnData(
    &datastore.PrepareDownloadOwnDataRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadOwnDataRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadOwnData(
        (new PrepareDownloadOwnDataRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectName("dataObject-0001")
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadOwnDataRequest;
import io.gs2.datastore.result.PrepareDownloadOwnDataResult;

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

try {
    PrepareDownloadOwnDataResult result = client.prepareDownloadOwnData(
        new PrepareDownloadOwnDataRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadOwnDataResult> asyncResult = null;
yield return client.PrepareDownloadOwnData(
    new Gs2.Gs2Datastore.Request.PrepareDownloadOwnDataRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectName("dataObject-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadOwnData(
        new Gs2Datastore.PrepareDownloadOwnDataRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_own_data(
        datastore.PrepareDownloadOwnDataRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_name('dataObject-0001')
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_own_data({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
})

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

result = api_result.result
item = result.item;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_own_data_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadByUserIdAndDataObjectName

ユーザーIDとオブジェクト名を指定してデータオブジェクトをダウンロード準備する<br>

GRN（dataObjectId）の代わりにユーザーIDとオブジェクト名を指定して、ユーザーのデータオブジェクトをダウンロードするための簡易APIです。<br>
アクセス制御が適用され、データの所有者または allowUserIds に登録されたユーザーのみがダウンロードできます。<br>
署名付きダウンロード URL とファイルサイズ（コンテンツ長）が返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadByUserIdAndDataObjectName(
    &datastore.PrepareDownloadByUserIdAndDataObjectNameRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadByUserIdAndDataObjectNameRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadByUserIdAndDataObjectName(
        (new PrepareDownloadByUserIdAndDataObjectNameRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectName("dataObject-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadByUserIdAndDataObjectNameRequest;
import io.gs2.datastore.result.PrepareDownloadByUserIdAndDataObjectNameResult;

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

try {
    PrepareDownloadByUserIdAndDataObjectNameResult result = client.prepareDownloadByUserIdAndDataObjectName(
        new PrepareDownloadByUserIdAndDataObjectNameRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withTimeOffsetToken(null)
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadByUserIdAndDataObjectNameResult> asyncResult = null;
yield return client.PrepareDownloadByUserIdAndDataObjectName(
    new Gs2.Gs2Datastore.Request.PrepareDownloadByUserIdAndDataObjectNameRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectName("dataObject-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadByUserIdAndDataObjectName(
        new Gs2Datastore.PrepareDownloadByUserIdAndDataObjectNameRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_by_user_id_and_data_object_name(
        datastore.PrepareDownloadByUserIdAndDataObjectNameRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_name('dataObject-0001')
            .with_time_offset_token(None)
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_by_user_id_and_data_object_name({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_by_user_id_and_data_object_name_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadOwnDataByGeneration

自分のデータオブジェクトの世代を指定してダウンロード準備<br>

GRN の代わりに名前を指定して、現在ログインしているユーザー自身のデータオブジェクトの特定のバージョン（世代）をダウンロードするための簡易APIです。<br>
データの再アップロード時に保持された以前のバージョンのファイルにアクセスできます。<br>
署名付きダウンロード URL とファイルサイズ（コンテンツ長）が返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| generation | string |  | ✓|  |  ~ 128文字 | データの世代 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadOwnDataByGeneration(
    &datastore.PrepareDownloadOwnDataByGenerationRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        Generation: pointy.String("generation-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadOwnDataByGenerationRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadOwnDataByGeneration(
        (new PrepareDownloadOwnDataByGenerationRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectName("dataObject-0001")
            ->withGeneration("generation-0001")
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadOwnDataByGenerationRequest;
import io.gs2.datastore.result.PrepareDownloadOwnDataByGenerationResult;

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

try {
    PrepareDownloadOwnDataByGenerationResult result = client.prepareDownloadOwnDataByGeneration(
        new PrepareDownloadOwnDataByGenerationRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("generation-0001")
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadOwnDataByGenerationResult> asyncResult = null;
yield return client.PrepareDownloadOwnDataByGeneration(
    new Gs2.Gs2Datastore.Request.PrepareDownloadOwnDataByGenerationRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectName("dataObject-0001")
        .WithGeneration("generation-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadOwnDataByGeneration(
        new Gs2Datastore.PrepareDownloadOwnDataByGenerationRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("generation-0001")
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_own_data_by_generation(
        datastore.PrepareDownloadOwnDataByGenerationRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_name('dataObject-0001')
            .with_generation('generation-0001')
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_own_data_by_generation({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
    generation="generation-0001",
})

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

result = api_result.result
item = result.item;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_own_data_by_generation_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
    generation="generation-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### prepareDownloadByUserIdAndDataObjectNameAndGeneration

ユーザーID・オブジェクト名・世代を指定してデータオブジェクトのダウンロード準備<br>

GRN の代わりにユーザーIDとオブジェクト名を指定して、ユーザーのデータオブジェクトの特定のバージョン（世代）をダウンロードするための簡易APIです。<br>
データの再アップロード時に保持された以前のバージョンのファイルにアクセスできます。<br>
アクセス制御が適用され、データの所有者または allowUserIds に登録されたユーザーのみがダウンロードできます。<br>
署名付きダウンロード URL とファイルサイズ（コンテンツ長）が返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| generation | string |  | ✓|  |  ~ 128文字 | データの世代 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |
| fileUrl | string | ファイルをダウンロードするためのURL |
| contentLength | long | ファイルの容量 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.PrepareDownloadByUserIdAndDataObjectNameAndGeneration(
    &datastore.PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        Generation: pointy.String("generation-0001"),
        TimeOffsetToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
fileUrl := result.FileUrl
contentLength := result.ContentLength

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->prepareDownloadByUserIdAndDataObjectNameAndGeneration(
        (new PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectName("dataObject-0001")
            ->withGeneration("generation-0001")
            ->withTimeOffsetToken(null)
    );
    $item = $result->getItem();
    $fileUrl = $result->getFileUrl();
    $contentLength = $result->getContentLength();
} 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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest;
import io.gs2.datastore.result.PrepareDownloadByUserIdAndDataObjectNameAndGenerationResult;

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

try {
    PrepareDownloadByUserIdAndDataObjectNameAndGenerationResult result = client.prepareDownloadByUserIdAndDataObjectNameAndGeneration(
        new PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("generation-0001")
            .withTimeOffsetToken(null)
    );
    DataObject item = result.getItem();
    String fileUrl = result.getFileUrl();
    long contentLength = result.getContentLength();
} 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.PrepareDownloadByUserIdAndDataObjectNameAndGenerationResult> asyncResult = null;
yield return client.PrepareDownloadByUserIdAndDataObjectNameAndGeneration(
    new Gs2.Gs2Datastore.Request.PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectName("dataObject-0001")
        .WithGeneration("generation-0001")
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
var fileUrl = result.FileUrl;
var contentLength = result.ContentLength;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.prepareDownloadByUserIdAndDataObjectNameAndGeneration(
        new Gs2Datastore.PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("generation-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
    const fileUrl = result.getFileUrl();
    const contentLength = result.getContentLength();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.prepare_download_by_user_id_and_data_object_name_and_generation(
        datastore.PrepareDownloadByUserIdAndDataObjectNameAndGenerationRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_name('dataObject-0001')
            .with_generation('generation-0001')
            .with_time_offset_token(None)
    )
    item = result.item
    file_url = result.file_url
    content_length = result.content_length
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.prepare_download_by_user_id_and_data_object_name_and_generation({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-0001",
    generation="generation-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```

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

client = gs2('datastore')

api_result_handler = client.prepare_download_by_user_id_and_data_object_name_and_generation_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-0001",
    generation="generation-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;
fileUrl = result.fileUrl;
contentLength = result.contentLength;

```




---

### restoreDataObject

データオブジェクトの管理情報を修復<br>

データオブジェクトの保存されたメタデータを実際のファイル状態と照合します。<br>
記録されている世代番号やコンテンツ長が実際のファイルと異なる場合、メタデータが一致するように更新されます。<br>
アップロード中の部分的な障害により発生する可能性のある不整合から回復する場合に役立ちます。<br>
ACTIVE ステータスのデータオブジェクトのみ修復可能で、他のステータスの場合はエラーが返されます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| dataObjectId | string |  | ✓|  |  ~ 1024文字 | データオブジェクトGRN |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObject](#dataobject) | データオブジェクト |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.RestoreDataObject(
    &datastore.RestoreDataObjectRequest {
        NamespaceName: pointy.String("namespace-0001"),
        DataObjectId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\RestoreDataObjectRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->restoreDataObject(
        (new RestoreDataObjectRequest())
            ->withNamespaceName("namespace-0001")
            ->withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.RestoreDataObjectRequest;
import io.gs2.datastore.result.RestoreDataObjectResult;

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

try {
    RestoreDataObjectResult result = client.restoreDataObject(
        new RestoreDataObjectRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
    );
    DataObject 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.RestoreDataObjectResult> asyncResult = null;
yield return client.RestoreDataObject(
    new Gs2.Gs2Datastore.Request.RestoreDataObjectRequest()
        .WithNamespaceName("namespace-0001")
        .WithDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.restoreDataObject(
        new Gs2Datastore.RestoreDataObjectRequest()
            .withNamespaceName("namespace-0001")
            .withDataObjectId("grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.restore_data_object(
        datastore.RestoreDataObjectRequest()
            .with_namespace_name('namespace-0001')
            .with_data_object_id('grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.restore_data_object({
    namespaceName="namespace-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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('datastore')

api_result_handler = client.restore_data_object_async({
    namespaceName="namespace-0001",
    dataObjectId="grn:gs2:ap-northeast-1:YourOwnerId:datastore:namespace-0001:user:user-0001:data:dataObject-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;

```




---

### describeDataObjectHistories

データオブジェクト履歴の一覧を取得<br>

現在ログインしているユーザーが所有する特定のデータオブジェクトの全バージョン履歴（世代）を一覧取得します。<br>
PrepareReUpload と DoneUpload を通じてデータオブジェクトのファイル内容が再アップロードされるたびに新しい世代が作成され、以前のバージョンが履歴に記録されます。<br>
履歴エントリには、各世代のコンテンツサイズや作成タイムスタンプなどのメタデータが含まれます。<br>
ページトークンと取得件数の制限を使用して結果をページネーションできます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| pageToken | string |  | |  |  ~ 1024文字 | データの取得を開始する位置を指定するトークン |
| limit | int |  | | 30 | 1 ~ 1000 | データの取得件数 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| items | [List&lt;DataObjectHistory&gt;](#dataobjecthistory) | データオブジェクト履歴のリスト |
| nextPageToken | string | リストの続きを取得するためのページトークン |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DescribeDataObjectHistories(
    &datastore.DescribeDataObjectHistoriesRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DescribeDataObjectHistoriesRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->describeDataObjectHistories(
        (new DescribeDataObjectHistoriesRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectName("dataObject-0001")
            ->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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DescribeDataObjectHistoriesRequest;
import io.gs2.datastore.result.DescribeDataObjectHistoriesResult;

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

try {
    DescribeDataObjectHistoriesResult result = client.describeDataObjectHistories(
        new DescribeDataObjectHistoriesRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<DataObjectHistory> 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DescribeDataObjectHistoriesResult> asyncResult = null;
yield return client.DescribeDataObjectHistories(
    new Gs2.Gs2Datastore.Request.DescribeDataObjectHistoriesRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectName("dataObject-0001")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.describeDataObjectHistories(
        new Gs2Datastore.DescribeDataObjectHistoriesRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
            .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 datastore

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

try:
    result = client.describe_data_object_histories(
        datastore.DescribeDataObjectHistoriesRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_name('dataObject-0001')
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.describe_data_object_histories({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
    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('datastore')

api_result_handler = client.describe_data_object_histories_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
    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;

```




---

### describeDataObjectHistoriesByUserId

ユーザーIDを指定してデータオブジェクト履歴の一覧を取得<br>

指定されたユーザーが所有する特定のデータオブジェクトの全バージョン履歴（世代）を一覧取得します。<br>
PrepareReUpload と DoneUpload を通じてデータオブジェクトのファイル内容が再アップロードされるたびに新しい世代が作成され、以前のバージョンが履歴に記録されます。<br>
履歴エントリには、各世代のコンテンツサイズや作成タイムスタンプなどのメタデータが含まれます。<br>
ページトークンと取得件数の制限を使用して結果をページネーションできます。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| pageToken | string |  | |  |  ~ 1024文字 | データの取得を開始する位置を指定するトークン |
| limit | int |  | | 30 | 1 ~ 1000 | データの取得件数 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| items | [List&lt;DataObjectHistory&gt;](#dataobjecthistory) | データオブジェクト履歴のリスト |
| nextPageToken | string | リストの続きを取得するためのページトークン |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.DescribeDataObjectHistoriesByUserId(
    &datastore.DescribeDataObjectHistoriesByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        PageToken: nil,
        Limit: nil,
        TimeOffsetToken: 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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\DescribeDataObjectHistoriesByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->describeDataObjectHistoriesByUserId(
        (new DescribeDataObjectHistoriesByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectName("dataObject-0001")
            ->withPageToken(null)
            ->withLimit(null)
            ->withTimeOffsetToken(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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.DescribeDataObjectHistoriesByUserIdRequest;
import io.gs2.datastore.result.DescribeDataObjectHistoriesByUserIdResult;

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

try {
    DescribeDataObjectHistoriesByUserIdResult result = client.describeDataObjectHistoriesByUserId(
        new DescribeDataObjectHistoriesByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    List<DataObjectHistory> 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.DescribeDataObjectHistoriesByUserIdResult> asyncResult = null;
yield return client.DescribeDataObjectHistoriesByUserId(
    new Gs2.Gs2Datastore.Request.DescribeDataObjectHistoriesByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectName("dataObject-0001")
        .WithPageToken(null)
        .WithLimit(null)
        .WithTimeOffsetToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.describeDataObjectHistoriesByUserId(
        new Gs2Datastore.DescribeDataObjectHistoriesByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withPageToken(null)
            .withLimit(null)
            .withTimeOffsetToken(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.describe_data_object_histories_by_user_id(
        datastore.DescribeDataObjectHistoriesByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_name('dataObject-0001')
            .with_page_token(None)
            .with_limit(None)
            .with_time_offset_token(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.describe_data_object_histories_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-0001",
    pageToken=nil,
    limit=nil,
    timeOffsetToken=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('datastore')

api_result_handler = client.describe_data_object_histories_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-0001",
    pageToken=nil,
    limit=nil,
    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
items = result.items;
nextPageToken = result.nextPageToken;

```




---

### getDataObjectHistory

データオブジェクト履歴を取得<br>

現在ログインしているユーザーが所有するデータオブジェクトの特定の世代の履歴エントリを取得します。<br>
世代番号を指定することで、データオブジェクトの特定バージョンに関するメタデータ（コンテンツサイズや作成タイムスタンプなど）にアクセスできます。<br>
PrepareDownloadByGeneration で過去のバージョンをダウンロードする前に、そのバージョンの情報を確認するのに便利です。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| accessToken | string |  | ✓|  |  ~ 128文字 | アクセストークン |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| generation | string |  | ✓|  |  ~ 128文字 | 世代ID<br>アップロード時点のデータオブジェクトの特定バージョンを示す一意な識別子です。DataObject の generation フィールドに対応し、PrepareDownloadByGeneration でこの特定バージョンをダウンロードする際に使用できます。 |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObjectHistory](#dataobjecthistory) | データオブジェクト履歴 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.GetDataObjectHistory(
    &datastore.GetDataObjectHistoryRequest {
        NamespaceName: pointy.String("namespace-0001"),
        AccessToken: pointy.String("accessToken-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        Generation: pointy.String("1"),
    }
)
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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\GetDataObjectHistoryRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->getDataObjectHistory(
        (new GetDataObjectHistoryRequest())
            ->withNamespaceName("namespace-0001")
            ->withAccessToken("accessToken-0001")
            ->withDataObjectName("dataObject-0001")
            ->withGeneration("1")
    );
    $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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.GetDataObjectHistoryRequest;
import io.gs2.datastore.result.GetDataObjectHistoryResult;

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

try {
    GetDataObjectHistoryResult result = client.getDataObjectHistory(
        new GetDataObjectHistoryRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("1")
    );
    DataObjectHistory 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.GetDataObjectHistoryResult> asyncResult = null;
yield return client.GetDataObjectHistory(
    new Gs2.Gs2Datastore.Request.GetDataObjectHistoryRequest()
        .WithNamespaceName("namespace-0001")
        .WithAccessToken("accessToken-0001")
        .WithDataObjectName("dataObject-0001")
        .WithGeneration("1"),
    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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.getDataObjectHistory(
        new Gs2Datastore.GetDataObjectHistoryRequest()
            .withNamespaceName("namespace-0001")
            .withAccessToken("accessToken-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.get_data_object_history(
        datastore.GetDataObjectHistoryRequest()
            .with_namespace_name('namespace-0001')
            .with_access_token('accessToken-0001')
            .with_data_object_name('dataObject-0001')
            .with_generation('1')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.get_data_object_history({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
    generation="1",
})

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('datastore')

api_result_handler = client.get_data_object_history_async({
    namespaceName="namespace-0001",
    accessToken="accessToken-0001",
    dataObjectName="dataObject-0001",
    generation="1",
})

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;

```




---

### getDataObjectHistoryByUserId

ユーザーIDを指定してデータオブジェクト履歴を取得<br>

指定されたユーザーが所有するデータオブジェクトの特定の世代の履歴エントリを取得します。<br>
世代番号を指定することで、データオブジェクトの特定バージョンに関するメタデータ（コンテンツサイズや作成タイムスタンプなど）にアクセスできます。<br>
PrepareDownloadByGeneration で過去のバージョンをダウンロードする前に、そのバージョンの情報を確認するのに便利です。



#### Request

|  | 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128文字 | ネームスペース名<br>ネームスペース固有の名前。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。 |
| userId | string |  | ✓|  |  ~ 128文字 | ユーザーID |
| dataObjectName | string |  | ✓| UUID |  ~ 128文字 | データオブジェクトの名前<br>データオブジェクトを識別する一意な名前です。デフォルトでは UUID 形式で自動生成されます。ネームスペース内でアップロードされたデータの参照・管理に使用されます。 |
| generation | string |  | ✓|  |  ~ 128文字 | 世代ID<br>アップロード時点のデータオブジェクトの特定バージョンを示す一意な識別子です。DataObject の generation フィールドに対応し、PrepareDownloadByGeneration でこの特定バージョンをダウンロードする際に使用できます。 |
| timeOffsetToken | string |  | |  |  ~ 1024文字 | タイムオフセットトークン |

#### Result

|  | 型 | 説明 |
| --- | --- | --- |
| item | [DataObjectHistory](#dataobjecthistory) | データオブジェクト履歴 |

#### 実装例




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/datastore"
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 := datastore.Gs2DatastoreRestClient{
    Session: &session,
}
result, err := client.GetDataObjectHistoryByUserId(
    &datastore.GetDataObjectHistoryByUserIdRequest {
        NamespaceName: pointy.String("namespace-0001"),
        UserId: pointy.String("user-0001"),
        DataObjectName: pointy.String("dataObject-0001"),
        Generation: pointy.String("generation-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\Datastore\Gs2DatastoreRestClient;
use Gs2\Datastore\Request\GetDataObjectHistoryByUserIdRequest;

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

$session->open();

$client = new Gs2DatastoreRestClient(
    $session
);

try {
    $result = $client->getDataObjectHistoryByUserId(
        (new GetDataObjectHistoryByUserIdRequest())
            ->withNamespaceName("namespace-0001")
            ->withUserId("user-0001")
            ->withDataObjectName("dataObject-0001")
            ->withGeneration("generation-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.datastore.rest.Gs2DatastoreRestClient;
import io.gs2.datastore.request.GetDataObjectHistoryByUserIdRequest;
import io.gs2.datastore.result.GetDataObjectHistoryByUserIdResult;

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

try {
    GetDataObjectHistoryByUserIdResult result = client.getDataObjectHistoryByUserId(
        new GetDataObjectHistoryByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("generation-0001")
            .withTimeOffsetToken(null)
    );
    DataObjectHistory 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 Gs2DatastoreRestClient(session);

AsyncResult<Gs2.Gs2Datastore.Result.GetDataObjectHistoryByUserIdResult> asyncResult = null;
yield return client.GetDataObjectHistoryByUserId(
    new Gs2.Gs2Datastore.Request.GetDataObjectHistoryByUserIdRequest()
        .WithNamespaceName("namespace-0001")
        .WithUserId("user-0001")
        .WithDataObjectName("dataObject-0001")
        .WithGeneration("generation-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 Gs2Datastore from '@/gs2/datastore';

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

try {
    const result = await client.getDataObjectHistoryByUserId(
        new Gs2Datastore.GetDataObjectHistoryByUserIdRequest()
            .withNamespaceName("namespace-0001")
            .withUserId("user-0001")
            .withDataObjectName("dataObject-0001")
            .withGeneration("generation-0001")
            .withTimeOffsetToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import datastore

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

try:
    result = client.get_data_object_history_by_user_id(
        datastore.GetDataObjectHistoryByUserIdRequest()
            .with_namespace_name('namespace-0001')
            .with_user_id('user-0001')
            .with_data_object_name('dataObject-0001')
            .with_generation('generation-0001')
            .with_time_offset_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('datastore')

api_result = client.get_data_object_history_by_user_id({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-0001",
    generation="generation-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('datastore')

api_result_handler = client.get_data_object_history_by_user_id_async({
    namespaceName="namespace-0001",
    userId="user-0001",
    dataObjectName="dataObject-0001",
    generation="generation-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;

```




---



