GS2-Grade Deploy/CDK Reference

The template format used when creating stacks with GS2-Deploy, and implementation examples of template output in various languages using CDK

Entities

Resources managed by the Deploy operation

Namespace

Namespace

A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.

Therefore, you must create a namespace before you can start using each service.

Request

Resource creation and update requests

Type Condition Required Default Value Limits Description
name string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
description string ~ 1024 chars Description
transactionSetting TransactionSetting Transaction Setting
Configuration for controlling how distributed transactions are executed when processing grade operations. Supports auto-run, atomic commit, and async processing options.
changeGradeScript ScriptSetting Script setting to be executed when grade changes
Script Trigger Reference - changeGrade
logSetting LogSetting Log Output Setting
Configuration for outputting log data of grade operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for grade changes and rank cap updates can be collected.

GetAttr

Resource creation results that can be retrieved using the !GetAttr tag

Type Description
Item Namespace Namespace created

Implementation Example

Type: GS2::Grade::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  ChangeGradeScript: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/grade"
)


SampleStack := core.NewStack()
grade.NewNamespace(
    &SampleStack,
    "namespace-0001",
    grade.NamespaceOptions{
        LogSetting: &core.LogSetting{
            LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
        },
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Grade\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Grade\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.grade.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.grade.model.options.NamespaceOptions()
                        .withLogSetting(new io.gs2.cdk.core.model.LogSetting(
                            "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                        ))
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Grade.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2Grade.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
import core from "@/gs2cdk/core";
import grade from "@/gs2cdk/grade";

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

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, grade

class SampleStack(Stack):

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

print(SampleStack().yaml())  # Generate Template

TransactionSetting

Transaction Setting

Transaction Setting controls execution methods, consistency, asynchronous processing, and conflict avoidance mechanisms of transactions. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous processing of Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.

Type Condition Required Default Value Limits Description
enableAutoRun bool false Whether to automatically execute issued transactions on the server side
enableAtomicCommit bool {enableAutoRun} == true false Whether to commit the execution of transactions atomically
* Enabled only if enableAutoRun is true
transactionUseDistributor bool {enableAtomicCommit} == true false Whether to execute transactions asynchronously
* Enabled only if enableAtomicCommit is true
commitScriptResultInUseDistributor bool {transactionUseDistributor} == true false Whether to execute the commit processing of the script result asynchronously
* Enabled only if transactionUseDistributor is true
acquireActionUseJobQueue bool {enableAtomicCommit} == true false Whether to use GS2-JobQueue to execute the acquire action
* Enabled only if enableAtomicCommit is true
distributorNamespaceId string “grn:gs2:{region}:{ownerId}:distributor:default” ~ 1024 chars GS2-Distributor Namespace GRN used to execute transactions
queueNamespaceId string “grn:gs2:{region}:{ownerId}:queue:default” ~ 1024 chars GS2-JobQueue Namespace GRN used to execute transactions

ScriptSetting

Script Setting

In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.

There are two main ways to execute a script: synchronous execution and asynchronous execution. Because synchronous execution blocks processing until the script finishes executing, you can use the script result to stop the API execution or control the API response.

In contrast, asynchronous execution does not block processing until the script has finished executing. However, because the script result cannot be used to stop the API execution or modify the API response, asynchronous execution does not affect the API response flow and is generally recommended.

There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.

Type Condition Required Default Value Limits Description
triggerScriptId string ~ 1024 chars GS2-Script script GRN executed synchronously when the API is executed
Must be specified in GRN format starting with “grn:gs2:”.
doneTriggerTargetType string (enum)
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none” How to execute asynchronous scripts
Specifies the type of script to use for asynchronous execution.
You can choose from “Do not use asynchronous execution (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
DefinitionDescription
“none”None
“gs2_script”GS2-Script
“aws”Amazon EventBridge
doneTriggerScriptId string {doneTriggerTargetType} == “gs2_script” ~ 1024 chars GS2-Script script GRN for asynchronous execution
Must be specified in GRN format starting with “grn:gs2:”.
* Enabled only if doneTriggerTargetType is “gs2_script”
doneTriggerQueueNamespaceId string {doneTriggerTargetType} == “gs2_script” ~ 1024 chars GS2-JobQueue namespace GRN to execute asynchronous execution scripts
If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue namespace GRN.
There are not many cases where GS2-JobQueue is required, so you generally do not need to specify it unless you have a specific reason.
* Enabled only if doneTriggerTargetType is “gs2_script”

LogSetting

Log Output Setting

Log Output Setting defines how log data is exported. This type holds the GS2-Log namespace identifier (Namespace ID), which is used to export log data. Specify the GS2-Log Namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.

Type Condition Required Default Value Limits Description
loggingNamespaceId string
~ 1024 chars GS2-Log namespace GRN to output logs
Must be specified in GRN format starting with “grn:gs2:”.

CurrentGradeMaster

Currently active Grade Model master data

This master data defines the Grade Model currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data are updated on the server.

To create JSON files, GS2 provides a master data editor within the management console. Additionally, you can create tools better suited for game operations and export JSON files in the appropriate format.

Request

Resource creation and update requests

Type Condition Required Default Value Limits Description
namespaceName string
~ 128 chars Namespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
mode string (enum)
enum {
  “direct”,
  “preUpload”
}
“direct” Update mode
DefinitionDescription
“direct”Directly update master data
“preUpload”Upload master data and then update
settings string {mode} == “direct”
✓*
~ 5242880 chars Master Data
* Required if mode is “direct”
uploadToken string {mode} == “preUpload”
✓*
~ 1024 chars Token obtained by pre-upload
Used to apply the uploaded master data.
* Required if mode is “preUpload”

GetAttr

Resource creation results that can be retrieved using the !GetAttr tag

Type Description
Item CurrentGradeMaster Updated master data of the currently active Grade Models

Implementation Example

Type: GS2::Grade::CurrentGradeMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2023-12-25",
    "gradeModels": [
      {
        "name": "grade-0001",
        "experienceModelId": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
        "gradeEntries": [
          {
            "rankCapValue": 50,
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
            "gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
          },
          {
            "rankCapValue": 60,
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
            "gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
          },
          {
            "rankCapValue": 70,
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
            "gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
          },
          {
            "rankCapValue": 80,
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
            "gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
          }
        ],
        "metadata": "GRADE_0001",
        "defaultGrades": [
          {
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
            "defaultGradeValue": 2
          },
          {
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
            "defaultGradeValue": 3
          },
          {
            "propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
            "defaultGradeValue": 4
          }
        ]
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/grade"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
grade.NewNamespace(
    &SampleStack,
    "namespace-0001",
    grade.NamespaceOptions{},
).MasterData(
    []grade.GradeModel{
        grade.NewGradeModel(
            "grade-0001",
            "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
            []grade.GradeEntryModel{
                grade.NewGradeEntryModel(
                    50,
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
                    grade.GradeEntryModelOptions{},
                ),
                grade.NewGradeEntryModel(
                    60,
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
                    grade.GradeEntryModelOptions{},
                ),
                grade.NewGradeEntryModel(
                    70,
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
                    grade.GradeEntryModelOptions{},
                ),
                grade.NewGradeEntryModel(
                    80,
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                    "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
                    grade.GradeEntryModelOptions{},
                ),
            },
            grade.GradeModelOptions{
                Metadata: pointy.String("GRADE_0001"),
                DefaultGrades: []grade.DefaultGradeModel{
                    grade.NewDefaultGradeModel(
                        "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
                        2,
                        grade.DefaultGradeModelOptions{},
                    ),
                    grade.NewDefaultGradeModel(
                        "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
                        3,
                        grade.DefaultGradeModelOptions{},
                    ),
                    grade.NewDefaultGradeModel(
                        "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
                        4,
                        grade.DefaultGradeModelOptions{},
                    ),
                },
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Grade\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Grade\Model\GradeModel(
                    name:"grade-0001",
                    experienceModelId:"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                    gradeEntries:[
                        new \Gs2Cdk\Grade\Model\GradeEntryModel(
                            rankCapValue: 50,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
                        ),
                        new \Gs2Cdk\Grade\Model\GradeEntryModel(
                            rankCapValue: 60,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
                        ),
                        new \Gs2Cdk\Grade\Model\GradeEntryModel(
                            rankCapValue: 70,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
                        ),
                        new \Gs2Cdk\Grade\Model\GradeEntryModel(
                            rankCapValue: 80,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
                        ),
                    ],
                    options: new \Gs2Cdk\Grade\Model\Options\GradeModelOptions(
                        metadata:"GRADE_0001",
                        defaultGrades:[
                            new \Gs2Cdk\Grade\Model\DefaultGradeModel(
                                propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
                                defaultGradeValue: 2,
                            ),
                            new \Gs2Cdk\Grade\Model\DefaultGradeModel(
                                propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
                                defaultGradeValue: 3,
                            ),
                            new \Gs2Cdk\Grade\Model\DefaultGradeModel(
                                propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
                                defaultGradeValue: 4,
                            ),
                        ]
                    )
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.grade.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.grade.model.GradeModel(
                    "grade-0001",
                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                    Arrays.asList(
                        new io.gs2.cdk.grade.model.GradeEntryModel(
                            50L,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new io.gs2.cdk.grade.model.GradeEntryModel(
                            60L,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new io.gs2.cdk.grade.model.GradeEntryModel(
                            70L,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new io.gs2.cdk.grade.model.GradeEntryModel(
                            80L,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        )
                    ),
                    new io.gs2.cdk.grade.model.options.GradeModelOptions()
                        .withMetadata("GRADE_0001")
                        .withDefaultGrades(Arrays.asList(
                            new io.gs2.cdk.grade.model.DefaultGradeModel(
                                "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
                                2L
                            ),
                            new io.gs2.cdk.grade.model.DefaultGradeModel(
                                "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
                                3L
                            ),
                            new io.gs2.cdk.grade.model.DefaultGradeModel(
                                "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
                                4L
                            )
                        ))
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Grade.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Grade.Model.GradeModel[] {
                new Gs2Cdk.Gs2Grade.Model.GradeModel(
                    name: "grade-0001",
                    experienceModelId: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                    gradeEntries: new Gs2Cdk.Gs2Grade.Model.GradeEntryModel[]
                    {
                        new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
                            rankCapValue: 50L,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
                            rankCapValue: 60L,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
                            rankCapValue: 70L,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
                            rankCapValue: 80L,
                            propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        )
                    },
                    options: new Gs2Cdk.Gs2Grade.Model.Options.GradeModelOptions
                    {
                        metadata = "GRADE_0001",
                        defaultGrades = new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel[]
                        {
                            new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel(
                                propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
                                defaultGradeValue: 2L
                            ),
                            new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel(
                                propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
                                defaultGradeValue: 3L
                            ),
                            new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel(
                                propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
                                defaultGradeValue: 4L
                            )
                        }
                    }
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import grade from "@/gs2cdk/grade";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new grade.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new grade.model.GradeModel(
                    "grade-0001",
                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
                    [
                        new grade.model.GradeEntryModel(
                            50,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new grade.model.GradeEntryModel(
                            60,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new grade.model.GradeEntryModel(
                            70,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                        new grade.model.GradeEntryModel(
                            80,
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
                            "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
                        ),
                    ],
                    {
                        metadata: "GRADE_0001",
                        defaultGrades: [
                            new grade.model.DefaultGradeModel(
                                "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
                                2
                            ),
                            new grade.model.DefaultGradeModel(
                                "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
                                3
                            ),
                            new grade.model.DefaultGradeModel(
                                "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
                                4
                            ),
                        ]
                    }
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, grade

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        grade.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            grade_models=[
                grade.GradeModel(
                    name='grade-0001',
                    experience_model_id='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',
                    grade_entries=[
                        grade.GradeEntryModel(
                            rank_cap_value=50,
                            property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
                            grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',        
                        ),
                        grade.GradeEntryModel(
                            rank_cap_value=60,
                            property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
                            grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',        
                        ),
                        grade.GradeEntryModel(
                            rank_cap_value=70,
                            property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
                            grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',        
                        ),
                        grade.GradeEntryModel(
                            rank_cap_value=80,
                            property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
                            grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',        
                        ),
                    ],
                    options=grade.GradeModelOptions(
                        metadata = 'GRADE_0001',
                        default_grades = [
                            grade.DefaultGradeModel(
                                property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*',
                                default_grade_value=2,        
                            ),
                            grade.DefaultGradeModel(
                                property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*',
                                default_grade_value=3,        
                            ),
                            grade.DefaultGradeModel(
                                property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*',
                                default_grade_value=4,        
                            ),
                        ]
                    ),
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template

GradeModel

Grade Model

A Grade Model is an entity that indicates the rank of characters and equipment, and allows you to set the rank cap for GS2-Experience based on the grade.

Type Condition Required Default Value Limits Description
gradeModelId string
*
~ 1024 chars Grade Model GRN
* Set automatically by the server
name string
~ 128 chars Grade Model name
Grade Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadata string ~ 2048 chars Metadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
defaultGrades List<DefaultGradeModel> 0 ~ 100 items List of Default Grade Models
An ordered list of default grade rules evaluated when creating a new status. Each entry defines a property ID regex pattern and the grade value to assign when matched. If no pattern matches, the default grade value of 0 is used.
experienceModelId string
~ 1024 chars GS2-Experience Experience Model GRN
The GRN of the GS2-Experience experience model to link with this grade model. When a grade value changes, the corresponding rank cap in the linked experience model is automatically updated based on the grade entry mappings. This enables grade-driven progression where higher grades unlock higher rank caps.
gradeEntries List<GradeEntryModel>
1 ~ 100 items List of Grade Entry Models
The ordered list of grade entries that map each grade value to a rank cap for the linked GS2-Experience model. The index in the array corresponds to the grade value, so the first entry (index 0) defines the rank cap for grade 0, the second for grade 1, and so on.
acquireActionRates List<AcquireActionRate> 0 ~ 100 items List of Reward Addition Tables
A collection of named multiplier tables used to scale reward amounts based on grade. Multiple tables can be defined to apply different scaling rules to different types of rewards (e.g., experience points, currency, items).

DefaultGradeModel

Default Grade Model

You can set the default grade value according to the match of the property ID regular expression when creating a new grade.

Type Condition Required Default Value Limits Description
propertyIdRegex string
~ 1024 chars Property ID Regex
A regular expression pattern matched against the property ID of a newly created grade status. When the property ID matches this pattern, the specified default grade value is assigned as the initial grade instead of 0. Patterns are evaluated in order, and the first match is used.
defaultGradeValue long
0 ~ 9223372036854775805 Default Grade Value
The initial grade value assigned to a newly created status when its property ID matches the propertyIdRegex pattern. This value determines the starting rank cap for the linked GS2-Experience model, as the grade entry at this index defines the corresponding rank cap.

GradeEntryModel

Grade Entry Model

Defines the mapping between a grade value and a rank cap for the linked GS2-Experience model. Each entry also specifies regex patterns for matching property IDs, enabling the system to determine which resources can be used for grade-up operations and how their property IDs are transformed.

Type Condition Required Default Value Limits Description
metadata string ~ 2048 chars Metadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
rankCapValue long
0 ~ 9223372036854775805 Rank Cap Value
The rank cap value to set in the linked GS2-Experience model when this grade is applied. When a player’s grade changes to the value corresponding to this entry, the rank cap of the associated experience status is automatically updated to this value, controlling the maximum achievable rank.
propertyIdRegex string
~ 1024 chars Property ID Regex
A regular expression pattern applied to the grade status’s property ID to extract variables for grade-up matching. Capture groups (parenthesized parts) in this pattern become available as $1, $2, etc. in gradeUpPropertyIdRegex. For example, a pattern like “character-(.+)” extracts the character identifier for use in matching grade-up material property IDs.
gradeUpPropertyIdRegex string
~ 1024 chars Grade-Up Property ID Regex
A regular expression pattern that identifies which resource property IDs can be consumed for grade advancement. This pattern can reference capture groups from propertyIdRegex using $1, $2, etc. For example, if propertyIdRegex extracts “sword-001” as $1, this pattern might be “grade-up-material-$1” to match materials specific to that sword.

AcquireActionRate

Reward Addition Table

Defines a named multiplier table that scales reward amounts based on the current grade value. Each grade value maps to a multiplier applied to acquire actions in transactions, allowing higher-graded characters or equipment to receive proportionally more rewards. Supports both standard double-precision mode and big number mode for extremely large values.

Type Condition Required Default Value Limits Description
name string
~ 128 chars Reward Addition Table Name
A unique identifier for this multiplier table within the grade model. Referenced when applying grade-based reward scaling to specific acquire actions in transactions.
mode string (enum)
enum {
  “double”,
  “big”
}
“double” Reward Addition Table Type
Selects the numeric precision mode for multiplier values. “double” mode uses standard floating-point numbers suitable for most cases. “big” mode uses string-represented numbers supporting up to 1024 digits, for games requiring extremely large value calculations.
DefinitionDescription
“double”Floating point number less than 2^48
“big”Floating point number less than 1024 digits
rates List<double> {mode} == “double”
✓*
1 ~ 1000 items Multiplier List per Grade (double mode)
An array of reward multipliers indexed by grade value, using double-precision floating-point numbers. The entry at index 0 is the multiplier for grade 0, index 1 for grade 1, and so on. Used when mode is set to “double”.
* Required if mode is “double”
bigRates List<string> {mode} == “big”
✓*
1 ~ 1000 items Multiplier List per Grade (big mode)
An array of reward multipliers indexed by grade value, using string-represented numbers for extended precision. The entry at index 0 is the multiplier for grade 0, index 1 for grade 1, and so on. Used when mode is set to “big” for games requiring very large number calculations.
* Required if mode is “big”