GS2-Version GS2-Deploy/CDK リファレンス

エンティティ

Namespace

ネームスペース

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

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

必須デフォルト値の制限説明
namestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
assumeUserIdstring~ 1024文字バージョンチェックを通過した場合に昇格する GS2-Identifier ユーザーGRN
acceptVersionScriptScriptSettingバージョンを承認したときに実行するスクリプト
checkVersionTriggerScriptIdstring~ 1024文字バージョンチェック処理を実行する GS2-Script のスクリプト
logSettingLogSettingログの出力設定

GetAttr

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

実装例

Type: GS2::Version::Namespace
Properties:
  Name: namespace1
  Description: null
  AssumeUserId: grn:gs2::YourOwnerId:identifier:user:user-0001
  AcceptVersionScript: null
  CheckVersionTriggerScriptId: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1
from gs2_cdk import Stack, core, version

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        version.Namespace(
            stack=self,
            name="namespace-0001",
            assume_user_id='grn:gs2::YourOwnerId:identifier:user:user-0001',
            options=version.NamespaceOptions(
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

print(SampleStack().yaml())  # Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Version\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            assumeUserId: "grn:gs2::YourOwnerId:identifier:user:user-0001",
            options: new \Gs2Cdk\Version\Model\Options\NamespaceOptions(
                logSetting: new \Gs2Cdk\Core\Model\LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            )
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.version.model.Namespace(
            this,
            "namespace-0001",
            "grn:gs2::YourOwnerId:identifier:user:user-0001",
            new io.gs2.cdk.version.model.options.NamespaceOptions() {
                {
                    logSetting = new io.gs2.cdk.core.model.LogSetting(
                        loggingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                    );
                }
            }
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
import core from "@/gs2cdk/core";
import version from "@/gs2cdk/version";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new version.model.Namespace(
            this,
            "namespace-0001",
            "grn:gs2::YourOwnerId:identifier:user:user-0001",
            {
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Version.Model.Namespace(
            this,
            "namespace-0001",
            "grn:gs2::YourOwnerId:identifier:user:user-0001",
            new Gs2Cdk.Gs2Version.Model.Options.NamespaceOptions {
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    LoggingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template

CurrentVersionMaster

現在有効なマスターデータ

GS2ではマスターデータの管理にJSON形式のファイルを使用します。 ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。

JSONファイルを作成する方法として、マネージメントコンソール上でのマスターデータエディタを提供していますが よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。

JSONファイルの形式についてはドキュメントを参照ください。

必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
settingsstring~ 5242880文字マスターデータ

GetAttr

説明
ItemCurrentVersionMaster更新した現在有効なバージョン

実装例

Type: GS2::Version::CurrentVersionMaster
Properties:
  NamespaceName: namespace1
  Settings: {
    "version": "2019-10-09",
    "versionModels": [
      {
        "name": "app",
        "scope": "passive",
        "type": "simple",
        "metadata": "APP",
        "warningVersion":
          {
            "major": 2,
            "minor": 2,
            "micro": 2
          },
        "errorVersion":
          {
            "major": 1,
            "minor": 1,
            "micro": 1
          }
      },
      {
        "name": "asset",
        "scope": "passive",
        "type": "simple",
        "metadata": "ASSET",
        "warningVersion":
          {
            "major": 3,
            "minor": 3,
            "micro": 3
          },
        "errorVersion":
          {
            "major": 2,
            "minor": 2,
            "micro": 2
          },
        "needSignature": true,
        "signatureKeyId": "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
      },
      {
        "name": "eula",
        "scope": "active",
        "type": "simple",
        "metadata": "EULA",
        "currentVersion":
          {
            "major": 2,
            "minor": 2,
            "micro": 2
          },
        "warningVersion":
          {
            "major": 4,
            "minor": 4,
            "micro": 4
          },
        "errorVersion":
          {
            "major": 3,
            "minor": 3,
            "micro": 3
          }
      }
    ]
  }
from gs2_cdk import Stack, core, version

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        version.Namespace(
            stack=self,
            # 省略
        ).master_data(
            version_models=[
                version.VersionModel(
                    name='app',
                    scope='passive',
                    type='simple',
                    options=version.VersionModelOptions(
                        metadata='APP',
                        warning_version=version.Version(
                            major=2,
                            minor=2,
                            micro=2
                        ),
                        error_version=version.Version(
                            major=1,
                            minor=1,
                            micro=1
                        ),
                    ),
                ),
                version.VersionModel(
                    name='asset',
                    scope='passive',
                    type='simple',
                    options=version.VersionModelOptions(
                        metadata='ASSET',
                        warning_version=version.Version(
                            major=3,
                            minor=3,
                            micro=3
                        ),
                        error_version=version.Version(
                            major=2,
                            minor=2,
                            micro=2
                        ),
                        need_signature=True,
                        signature_key_id='grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001',
                    ),
                ),
                version.VersionModel(
                    name='eula',
                    scope='active',
                    type='simple',
                    options=version.VersionModelOptions(
                        metadata='EULA',
                        current_version=version.Version(
                            major=2,
                            minor=2,
                            micro=2
                        ),
                        warning_version=version.Version(
                            major=4,
                            minor=4,
                            micro=4
                        ),
                        error_version=version.Version(
                            major=3,
                            minor=3,
                            micro=3
                        ),
                    ),
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Version\Model\Namespace_(
            stack: $this,
            // 省略
        ))->masterData(
            [
                new \Gs2Cdk\Version\Model\VersionModel(
                    name:"app",
                    scope: \Gs2Cdk\Version\Model\Enums\VersionModelScope::PASSIVE,
                    type: \Gs2Cdk\Version\Model\Enums\VersionModelType::SIMPLE,
                    options: new \Gs2Cdk\Version\Model\Options\VersionModelOptions(
                        metadata:"APP",
                        warningVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 2,
                            minor: 2,
                            micro: 2
                        ),
                        errorVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 1,
                            minor: 1,
                            micro: 1
                        )
                    )
                ),
                new \Gs2Cdk\Version\Model\VersionModel(
                    name:"asset",
                    scope: \Gs2Cdk\Version\Model\Enums\VersionModelScope::PASSIVE,
                    type: \Gs2Cdk\Version\Model\Enums\VersionModelType::SIMPLE,
                    options: new \Gs2Cdk\Version\Model\Options\VersionModelOptions(
                        metadata:"ASSET",
                        warningVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 3,
                            minor: 3,
                            micro: 3
                        ),
                        errorVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 2,
                            minor: 2,
                            micro: 2
                        ),
                        needSignature:True,
                        signatureKeyId:"grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
                    )
                ),
                new \Gs2Cdk\Version\Model\VersionModel(
                    name:"eula",
                    scope: \Gs2Cdk\Version\Model\Enums\VersionModelScope::ACTIVE,
                    type: \Gs2Cdk\Version\Model\Enums\VersionModelType::SIMPLE,
                    options: new \Gs2Cdk\Version\Model\Options\VersionModelOptions(
                        metadata:"EULA",
                        currentVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 2,
                            minor: 2,
                            micro: 2
                        ),
                        warningVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 4,
                            minor: 4,
                            micro: 4
                        ),
                        errorVersion:new \Gs2Cdk\Version\Model\Version(
                            major: 3,
                            minor: 3,
                            micro: 3
                        )
                    )
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.version.model.Namespace(
            this,
            // 省略
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.version.model.VersionModel(
                    "app",
                    Passive,
                    Simple,
                    new io.gs2.cdk.version.model.options.VersionModelOptions() {
                        {
                            metadata: "APP";
                            warningVersion: new io.gs2.cdk.version.model.Version(
                                2,
                                2,
                                2
                            );
                            errorVersion: new io.gs2.cdk.version.model.Version(
                                1,
                                1,
                                1
                            );
                        }
                    }
                ),
                new io.gs2.cdk.version.model.VersionModel(
                    "asset",
                    Passive,
                    Simple,
                    new io.gs2.cdk.version.model.options.VersionModelOptions() {
                        {
                            metadata: "ASSET";
                            warningVersion: new io.gs2.cdk.version.model.Version(
                                3,
                                3,
                                3
                            );
                            errorVersion: new io.gs2.cdk.version.model.Version(
                                2,
                                2,
                                2
                            );
                            needSignature: true;
                            signatureKeyId: "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001";
                        }
                    }
                ),
                new io.gs2.cdk.version.model.VersionModel(
                    "eula",
                    Active,
                    Simple,
                    new io.gs2.cdk.version.model.options.VersionModelOptions() {
                        {
                            metadata: "EULA";
                            currentVersion: new io.gs2.cdk.version.model.Version(
                                2,
                                2,
                                2
                            );
                            warningVersion: new io.gs2.cdk.version.model.Version(
                                4,
                                4,
                                4
                            );
                            errorVersion: new io.gs2.cdk.version.model.Version(
                                3,
                                3,
                                3
                            );
                        }
                    }
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
import core from "@/gs2cdk/core";
import version from "@/gs2cdk/version";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new version.model.Namespace(
            this,
            // 省略
        ).masterData(
            [
                new version.model.VersionModel(
                    "app",
                    version.model.VersionModelScope.PASSIVE,
                    version.model.VersionModelType.SIMPLE,
                    {
                        metadata: "APP",
                        warningVersion: new version.model.Version(
                            2,
                            2,
                            2
                        ),
                        errorVersion: new version.model.Version(
                            1,
                            1,
                            1
                        )
                    }
                ),
                new version.model.VersionModel(
                    "asset",
                    version.model.VersionModelScope.PASSIVE,
                    version.model.VersionModelType.SIMPLE,
                    {
                        metadata: "ASSET",
                        warningVersion: new version.model.Version(
                            3,
                            3,
                            3
                        ),
                        errorVersion: new version.model.Version(
                            2,
                            2,
                            2
                        ),
                        needSignature: true,
                        signatureKeyId: "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
                    }
                ),
                new version.model.VersionModel(
                    "eula",
                    version.model.VersionModelScope.ACTIVE,
                    version.model.VersionModelType.SIMPLE,
                    {
                        metadata: "EULA",
                        currentVersion: new version.model.Version(
                            2,
                            2,
                            2
                        ),
                        warningVersion: new version.model.Version(
                            4,
                            4,
                            4
                        ),
                        errorVersion: new version.model.Version(
                            3,
                            3,
                            3
                        )
                    }
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Version.Model.Namespace(
            this,
            // 省略
        ).MasterData(
            new [] {
                new Gs2Cdk.Gs2Version.Model.VersionModel(
                    "app",
                    Gs2Cdk.Gs2Version.Model.Enums.VersionModelScope.Passive,
                    Gs2Cdk.Gs2Version.Model.Enums.VersionModelType.Simple,
                    new Gs2Cdk.Gs2Version.Model.Options.VersionModelOptions {
                        metadata = "APP",
                        warningVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 2,
                            minor: 2,
                            micro: 2
                        ),
                        errorVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 1,
                            minor: 1,
                            micro: 1
                        )
                    }
                ),
                new Gs2Cdk.Gs2Version.Model.VersionModel(
                    "asset",
                    Gs2Cdk.Gs2Version.Model.Enums.VersionModelScope.Passive,
                    Gs2Cdk.Gs2Version.Model.Enums.VersionModelType.Simple,
                    new Gs2Cdk.Gs2Version.Model.Options.VersionModelOptions {
                        metadata = "ASSET",
                        warningVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 3,
                            minor: 3,
                            micro: 3
                        ),
                        errorVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 2,
                            minor: 2,
                            micro: 2
                        ),
                        needSignature = true,
                        signatureKeyId = "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
                    }
                ),
                new Gs2Cdk.Gs2Version.Model.VersionModel(
                    "eula",
                    Gs2Cdk.Gs2Version.Model.Enums.VersionModelScope.Active,
                    Gs2Cdk.Gs2Version.Model.Enums.VersionModelType.Simple,
                    new Gs2Cdk.Gs2Version.Model.Options.VersionModelOptions {
                        metadata = "EULA",
                        currentVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 2,
                            minor: 2,
                            micro: 2
                        ),
                        warningVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 4,
                            minor: 4,
                            micro: 4
                        ),
                        errorVersion = new Gs2Cdk.Gs2Version.Model.Version_(
                            major: 3,
                            minor: 3,
                            micro: 3
                        )
                    }
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template

ScriptSetting

スクリプト設定

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

スクリプトの実行方式は大きく2種類あり、それは「同期実行」と「非同期実行」です。 同期実行は、スクリプトの実行が完了するまで処理がブロックされます。 かわりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることができます。

一方、非同期実行は、スクリプトの実行が完了するまで処理がブロックされません。 かわりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることはできません。 しかし、非同期実行は、スクリプトの実行が完了するまで処理がブロックされないため、APIの応答に影響を与えないため、原則非同期実行を使用することをおすすめします。

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

必須デフォルト値の制限説明
triggerScriptIdstring~ 1024文字スクリプトGRN
doneTriggerTargetTypeenum [
“none”,
“gs2_script”,
“aws”
]
“none”~ 128文字完了通知の通知先
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字スクリプトGRN
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字ネームスペースGRN

GitHubCheckoutSetting

GitHubからマスターデータをチェックアウトする設定

必須デフォルト値の制限説明
apiKeyIdstring~ 1024文字GitHub のAPIキーGRN
repositoryNamestring~ 1024文字リポジトリ名
sourcePathstring~ 1024文字ソースコードのファイルパス
referenceTypeenum [
“commit_hash”,
“branch”,
“tag”
]
~ 128文字コードの取得元
commitHashstring{referenceType} == “commit_hash”~ 1024文字コミットハッシュ
branchNamestring{referenceType} == “branch”~ 1024文字ブランチ名
tagNamestring{referenceType} == “tag”~ 1024文字タグ名

LogSetting

ログの書き出し設定

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

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

Version

バージョン

必須デフォルト値の制限説明
majorint~ 2147483646メジャーバージョン
minorint~ 2147483646マイナーバージョン
microint~ 2147483646マイクロバージョン

ScheduleVersion

時系列で切り替わるバージョン

必須デフォルト値の制限説明
currentVersionVersion現在のバージョン
warningVersionVersionバージョンアップを促すバージョン
errorVersionVersionバージョンチェックでエラーになるバージョン
scheduleEventIdstring~ 1024文字バージョンチェックを有効化する期間を設定した GS2-Schedule のイベントGRN