GS2-Inventory Deploy/CDK Reference
Entities
Resources targeted 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 Configures distributed transaction processing for inventory operations such as acquiring and consuming items. Supports auto-run mode for seamless execution, atomic commit for consistent multi-resource operations, and async processing for large-scale reward distribution. | ||||
| acquireScript | ScriptSetting | Script setting to be executed when an Items is acquired Script Trigger Reference - acquire | ||||
| overflowScript | ScriptSetting | Script to execute when unable to obtain due to reaching the acquisition limit Script Trigger Reference - overflowDone | ||||
| consumeScript | ScriptSetting | Script to run when consuming Items Script Trigger Reference - consume | ||||
| simpleItemAcquireScript | ScriptSetting | Script setting to be executed when acquiring Simple Items Script Trigger Reference - simpleItemAcquire | ||||
| simpleItemConsumeScript | ScriptSetting | Script to run when consuming Simple Items Script Trigger Reference - simpleItemConsume | ||||
| bigItemAcquireScript | ScriptSetting | Script setting to be executed when acquiring Big Items Script Trigger Reference - bigItemAcquire | ||||
| bigItemConsumeScript | ScriptSetting | Script to run when consuming Big Items Script Trigger Reference - bigItemConsume | ||||
| logSetting | LogSetting | Log Output Settings Specifies the GS2-Log namespace for outputting API request and response logs of inventory operations. Useful for tracking item acquisition, consumption, and capacity changes for debugging and analytics. |
GetAttr
Resource creation results that can be retrieved using the !GetAttr tag
| Type | Description | |
|---|---|---|
| Item | Namespace | Namespace created |
Implementation Example
Type: GS2::Inventory::Namespace
Properties:
Name: namespace-0001
Description: null
TransactionSetting: null
AcquireScript: null
OverflowScript: null
ConsumeScript: null
SimpleItemAcquireScript: null
SimpleItemConsumeScript: null
BigItemAcquireScript: null
BigItemConsumeScript: null
LogSetting:
LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001import (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/inventory"
)
SampleStack := core.NewStack()
inventory.NewNamespace(
&SampleStack,
"namespace-0001",
inventory.NamespaceOptions{
LogSetting: &core.LogSetting{
LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Inventory\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Inventory\Model\Options\NamespaceOptions(
logSetting: new \Gs2Cdk\Core\Model\LogSetting(
loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
)
);
}
}
print((new SampleStack())->yaml()); // Generate Templateclass SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.inventory.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.inventory.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 Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Inventory.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Inventory.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 Templateimport core from "@/gs2cdk/core";
import inventory from "@/gs2cdk/inventory";
class SampleStack extends core.Stack
{
public constructor() {
super();
new inventory.model.Namespace(
this,
"namespace-0001",
{
logSetting: new core.LogSetting(
"grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Templatefrom gs2_cdk import Stack, core, inventory
class SampleStack(Stack):
def __init__(self):
super().__init__()
inventory.Namespace(
stack=self,
name='namespace-0001',
options=inventory.NamespaceOptions(
log_setting=core.LogSetting(
logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
),
),
)
print(SampleStack().yaml()) # Generate TemplateTransactionSetting
Transaction Setting
Transaction Setting controls how transactions are executed, including their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous 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 * Applicable only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Applicable only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Applicable only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Applicable 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. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script’s execution results to halt API execution or control the API’s response content.
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)”.
| |||||||||||
| doneTriggerScriptId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-Script script GRN
for asynchronous execution Must be specified in GRN format starting with “grn:gs2:”. * Applicable 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. * Applicable only if doneTriggerTargetType is “gs2_script” |
LogSetting
Log Output Setting
Log Output Settings define how log data is exported. This type holds the GS2-Log namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, 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:”. |
CurrentItemModelMaster
Currently active Item Model master data
This master data describes the definitions of Item Models currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data settings 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.
Note
Please refer to Master Data Reference of GS2-Inventory for the JSON file 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
| |||||||||
| 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 | CurrentItemModelMaster | Updated master data of the currently active Item Models |
Implementation Example
Type: GS2::Inventory::CurrentItemModelMaster
Properties:
NamespaceName: namespace-0001
Mode: direct
Settings: {
"version": "2019-02-05",
"inventoryModels": [
{
"name": "item",
"initialCapacity": 100,
"maxCapacity": 999,
"itemModels": [
{
"name": "item-0001",
"metadata": "ITEM_0001",
"stackingLimit": 99,
"allowMultipleStacks": false,
"sortValue": 1
},
{
"name": "item-0002",
"metadata": "ITEM_0002",
"stackingLimit": 49,
"allowMultipleStacks": true,
"sortValue": 2
},
{
"name": "item-0003",
"metadata": "ITEM_0003",
"stackingLimit": 9,
"allowMultipleStacks": false,
"sortValue": 3
}
],
"metadata": "INVENTORY_ITEM"
},
{
"name": "character",
"initialCapacity": 50,
"maxCapacity": 99,
"itemModels": [
{
"name": "character-0001",
"metadata": "CHARACTER_0001",
"stackingLimit": 99,
"allowMultipleStacks": false,
"sortValue": 1
},
{
"name": "character-0002",
"metadata": "CHARACTER_0002",
"stackingLimit": 49,
"allowMultipleStacks": true,
"sortValue": 2
},
{
"name": "character-0003",
"metadata": "CHARACTER_0003",
"stackingLimit": 9,
"allowMultipleStacks": false,
"sortValue": 3
}
],
"metadata": "INVENTORY_CHARACTER"
}
],
"simpleInventoryModels": [
{
"name": "item",
"simpleItemModels": [
{
"name": "item-0001",
"metadata": "ITEM_0001"
},
{
"name": "item-0002",
"metadata": "ITEM_0002"
},
{
"name": "item-0003",
"metadata": "ITEM_0003"
}
],
"metadata": "INVENTORY_ITEM"
}
],
"bigInventoryModels": [
{
"name": "item",
"bigItemModels": [
{
"name": "item-0001",
"metadata": "ITEM_0001"
},
{
"name": "item-0002",
"metadata": "ITEM_0002"
},
{
"name": "item-0003",
"metadata": "ITEM_0003"
}
],
"metadata": "INVENTORY_ITEM"
}
]
}
UploadToken: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/inventory"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
inventory.NewNamespace(
&SampleStack,
"namespace-0001",
inventory.NamespaceOptions{},
).MasterData(
[]inventory.InventoryModel{
inventory.NewInventoryModel(
"item",
100,
999,
[]inventory.ItemModel{
inventory.NewItemModel(
"item-0001",
99,
false,
1,
inventory.ItemModelOptions{
Metadata: pointy.String("ITEM_0001"),
},
),
inventory.NewItemModel(
"item-0002",
49,
true,
2,
inventory.ItemModelOptions{
Metadata: pointy.String("ITEM_0002"),
},
),
inventory.NewItemModel(
"item-0003",
9,
false,
3,
inventory.ItemModelOptions{
Metadata: pointy.String("ITEM_0003"),
},
),
},
inventory.InventoryModelOptions{
Metadata: pointy.String("INVENTORY_ITEM"),
},
),
inventory.NewInventoryModel(
"character",
50,
99,
[]inventory.ItemModel{
inventory.NewItemModel(
"character-0001",
99,
false,
1,
inventory.ItemModelOptions{
Metadata: pointy.String("CHARACTER_0001"),
},
),
inventory.NewItemModel(
"character-0002",
49,
true,
2,
inventory.ItemModelOptions{
Metadata: pointy.String("CHARACTER_0002"),
},
),
inventory.NewItemModel(
"character-0003",
9,
false,
3,
inventory.ItemModelOptions{
Metadata: pointy.String("CHARACTER_0003"),
},
),
},
inventory.InventoryModelOptions{
Metadata: pointy.String("INVENTORY_CHARACTER"),
},
),
},
[]inventory.SimpleInventoryModel{
inventory.NewSimpleInventoryModel(
"item",
[]inventory.SimpleItemModel{
inventory.NewSimpleItemModel(
"item-0001",
inventory.SimpleItemModelOptions{
Metadata: pointy.String("ITEM_0001"),
},
),
inventory.NewSimpleItemModel(
"item-0002",
inventory.SimpleItemModelOptions{
Metadata: pointy.String("ITEM_0002"),
},
),
inventory.NewSimpleItemModel(
"item-0003",
inventory.SimpleItemModelOptions{
Metadata: pointy.String("ITEM_0003"),
},
),
},
inventory.SimpleInventoryModelOptions{
Metadata: pointy.String("INVENTORY_ITEM"),
},
),
},
[]inventory.BigInventoryModel{
inventory.NewBigInventoryModel(
"item",
[]inventory.BigItemModel{
inventory.NewBigItemModel(
"item-0001",
inventory.BigItemModelOptions{
Metadata: pointy.String("ITEM_0001"),
},
),
inventory.NewBigItemModel(
"item-0002",
inventory.BigItemModelOptions{
Metadata: pointy.String("ITEM_0002"),
},
),
inventory.NewBigItemModel(
"item-0003",
inventory.BigItemModelOptions{
Metadata: pointy.String("ITEM_0003"),
},
),
},
inventory.BigInventoryModelOptions{
Metadata: pointy.String("INVENTORY_ITEM"),
},
),
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\Inventory\Model\Namespace_(
stack: $this,
name: "namespace-0001"
))->masterData(
[
new \Gs2Cdk\Inventory\Model\InventoryModel(
name:"item",
initialCapacity:100,
maxCapacity:999,
itemModels:[
new \Gs2Cdk\Inventory\Model\ItemModel(
name: "item-0001",
stackingLimit: 99,
allowMultipleStacks: false,
sortValue: 1,
options: new \Gs2Cdk\Inventory\Model\Options\ItemModelOptions(
metadata: "ITEM_0001",
)
),
new \Gs2Cdk\Inventory\Model\ItemModel(
name: "item-0002",
stackingLimit: 49,
allowMultipleStacks: true,
sortValue: 2,
options: new \Gs2Cdk\Inventory\Model\Options\ItemModelOptions(
metadata: "ITEM_0002",
)
),
new \Gs2Cdk\Inventory\Model\ItemModel(
name: "item-0003",
stackingLimit: 9,
allowMultipleStacks: false,
sortValue: 3,
options: new \Gs2Cdk\Inventory\Model\Options\ItemModelOptions(
metadata: "ITEM_0003",
)
),
],
options: new \Gs2Cdk\Inventory\Model\Options\InventoryModelOptions(
metadata:"INVENTORY_ITEM"
)
),
new \Gs2Cdk\Inventory\Model\InventoryModel(
name:"character",
initialCapacity:50,
maxCapacity:99,
itemModels:[
new \Gs2Cdk\Inventory\Model\ItemModel(
name: "character-0001",
stackingLimit: 99,
allowMultipleStacks: false,
sortValue: 1,
options: new \Gs2Cdk\Inventory\Model\Options\ItemModelOptions(
metadata: "CHARACTER_0001",
)
),
new \Gs2Cdk\Inventory\Model\ItemModel(
name: "character-0002",
stackingLimit: 49,
allowMultipleStacks: true,
sortValue: 2,
options: new \Gs2Cdk\Inventory\Model\Options\ItemModelOptions(
metadata: "CHARACTER_0002",
)
),
new \Gs2Cdk\Inventory\Model\ItemModel(
name: "character-0003",
stackingLimit: 9,
allowMultipleStacks: false,
sortValue: 3,
options: new \Gs2Cdk\Inventory\Model\Options\ItemModelOptions(
metadata: "CHARACTER_0003",
)
),
],
options: new \Gs2Cdk\Inventory\Model\Options\InventoryModelOptions(
metadata:"INVENTORY_CHARACTER"
)
)
],
[
new \Gs2Cdk\Inventory\Model\SimpleInventoryModel(
name:"item",
simpleItemModels:[
new \Gs2Cdk\Inventory\Model\SimpleItemModel(
name: "item-0001",
options: new \Gs2Cdk\Inventory\Model\Options\SimpleItemModelOptions(
metadata: "ITEM_0001",
)
),
new \Gs2Cdk\Inventory\Model\SimpleItemModel(
name: "item-0002",
options: new \Gs2Cdk\Inventory\Model\Options\SimpleItemModelOptions(
metadata: "ITEM_0002",
)
),
new \Gs2Cdk\Inventory\Model\SimpleItemModel(
name: "item-0003",
options: new \Gs2Cdk\Inventory\Model\Options\SimpleItemModelOptions(
metadata: "ITEM_0003",
)
),
],
options: new \Gs2Cdk\Inventory\Model\Options\SimpleInventoryModelOptions(
metadata:"INVENTORY_ITEM"
)
)
],
[
new \Gs2Cdk\Inventory\Model\BigInventoryModel(
name:"item",
bigItemModels:[
new \Gs2Cdk\Inventory\Model\BigItemModel(
name: "item-0001",
options: new \Gs2Cdk\Inventory\Model\Options\BigItemModelOptions(
metadata: "ITEM_0001",
)
),
new \Gs2Cdk\Inventory\Model\BigItemModel(
name: "item-0002",
options: new \Gs2Cdk\Inventory\Model\Options\BigItemModelOptions(
metadata: "ITEM_0002",
)
),
new \Gs2Cdk\Inventory\Model\BigItemModel(
name: "item-0003",
options: new \Gs2Cdk\Inventory\Model\Options\BigItemModelOptions(
metadata: "ITEM_0003",
)
),
],
options: new \Gs2Cdk\Inventory\Model\Options\BigInventoryModelOptions(
metadata:"INVENTORY_ITEM"
)
)
]
);
}
}
print((new SampleStack())->yaml()); // Generate Templateclass SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.inventory.model.Namespace(
this,
"namespace-0001"
).masterData(
Arrays.asList(
new io.gs2.cdk.inventory.model.InventoryModel(
"item",
100,
999,
Arrays.asList(
new io.gs2.cdk.inventory.model.ItemModel(
"item-0001",
99L,
false,
1,
new io.gs2.cdk.inventory.model.options.ItemModelOptions()
.withMetadata("ITEM_0001")
),
new io.gs2.cdk.inventory.model.ItemModel(
"item-0002",
49L,
true,
2,
new io.gs2.cdk.inventory.model.options.ItemModelOptions()
.withMetadata("ITEM_0002")
),
new io.gs2.cdk.inventory.model.ItemModel(
"item-0003",
9L,
false,
3,
new io.gs2.cdk.inventory.model.options.ItemModelOptions()
.withMetadata("ITEM_0003")
)
),
new io.gs2.cdk.inventory.model.options.InventoryModelOptions()
.withMetadata("INVENTORY_ITEM")
),
new io.gs2.cdk.inventory.model.InventoryModel(
"character",
50,
99,
Arrays.asList(
new io.gs2.cdk.inventory.model.ItemModel(
"character-0001",
99L,
false,
1,
new io.gs2.cdk.inventory.model.options.ItemModelOptions()
.withMetadata("CHARACTER_0001")
),
new io.gs2.cdk.inventory.model.ItemModel(
"character-0002",
49L,
true,
2,
new io.gs2.cdk.inventory.model.options.ItemModelOptions()
.withMetadata("CHARACTER_0002")
),
new io.gs2.cdk.inventory.model.ItemModel(
"character-0003",
9L,
false,
3,
new io.gs2.cdk.inventory.model.options.ItemModelOptions()
.withMetadata("CHARACTER_0003")
)
),
new io.gs2.cdk.inventory.model.options.InventoryModelOptions()
.withMetadata("INVENTORY_CHARACTER")
)
),
Arrays.asList(
new io.gs2.cdk.inventory.model.SimpleInventoryModel(
"item",
Arrays.asList(
new io.gs2.cdk.inventory.model.SimpleItemModel(
"item-0001",
new io.gs2.cdk.inventory.model.options.SimpleItemModelOptions()
.withMetadata("ITEM_0001")
),
new io.gs2.cdk.inventory.model.SimpleItemModel(
"item-0002",
new io.gs2.cdk.inventory.model.options.SimpleItemModelOptions()
.withMetadata("ITEM_0002")
),
new io.gs2.cdk.inventory.model.SimpleItemModel(
"item-0003",
new io.gs2.cdk.inventory.model.options.SimpleItemModelOptions()
.withMetadata("ITEM_0003")
)
),
new io.gs2.cdk.inventory.model.options.SimpleInventoryModelOptions()
.withMetadata("INVENTORY_ITEM")
)
),
Arrays.asList(
new io.gs2.cdk.inventory.model.BigInventoryModel(
"item",
Arrays.asList(
new io.gs2.cdk.inventory.model.BigItemModel(
"item-0001",
new io.gs2.cdk.inventory.model.options.BigItemModelOptions()
.withMetadata("ITEM_0001")
),
new io.gs2.cdk.inventory.model.BigItemModel(
"item-0002",
new io.gs2.cdk.inventory.model.options.BigItemModelOptions()
.withMetadata("ITEM_0002")
),
new io.gs2.cdk.inventory.model.BigItemModel(
"item-0003",
new io.gs2.cdk.inventory.model.options.BigItemModelOptions()
.withMetadata("ITEM_0003")
)
),
new io.gs2.cdk.inventory.model.options.BigInventoryModelOptions()
.withMetadata("INVENTORY_ITEM")
)
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Inventory.Model.Namespace(
stack: this,
name: "namespace-0001"
).MasterData(
new Gs2Cdk.Gs2Inventory.Model.InventoryModel[] {
new Gs2Cdk.Gs2Inventory.Model.InventoryModel(
name: "item",
initialCapacity: 100,
maxCapacity: 999,
itemModels: new Gs2Cdk.Gs2Inventory.Model.ItemModel[]
{
new Gs2Cdk.Gs2Inventory.Model.ItemModel(
name: "item-0001",
stackingLimit: 99L,
allowMultipleStacks: false,
sortValue: 1,
options: new Gs2Cdk.Gs2Inventory.Model.Options.ItemModelOptions
{
metadata = "ITEM_0001"
}
),
new Gs2Cdk.Gs2Inventory.Model.ItemModel(
name: "item-0002",
stackingLimit: 49L,
allowMultipleStacks: true,
sortValue: 2,
options: new Gs2Cdk.Gs2Inventory.Model.Options.ItemModelOptions
{
metadata = "ITEM_0002"
}
),
new Gs2Cdk.Gs2Inventory.Model.ItemModel(
name: "item-0003",
stackingLimit: 9L,
allowMultipleStacks: false,
sortValue: 3,
options: new Gs2Cdk.Gs2Inventory.Model.Options.ItemModelOptions
{
metadata = "ITEM_0003"
}
)
},
options: new Gs2Cdk.Gs2Inventory.Model.Options.InventoryModelOptions
{
metadata = "INVENTORY_ITEM"
}
),
new Gs2Cdk.Gs2Inventory.Model.InventoryModel(
name: "character",
initialCapacity: 50,
maxCapacity: 99,
itemModels: new Gs2Cdk.Gs2Inventory.Model.ItemModel[]
{
new Gs2Cdk.Gs2Inventory.Model.ItemModel(
name: "character-0001",
stackingLimit: 99L,
allowMultipleStacks: false,
sortValue: 1,
options: new Gs2Cdk.Gs2Inventory.Model.Options.ItemModelOptions
{
metadata = "CHARACTER_0001"
}
),
new Gs2Cdk.Gs2Inventory.Model.ItemModel(
name: "character-0002",
stackingLimit: 49L,
allowMultipleStacks: true,
sortValue: 2,
options: new Gs2Cdk.Gs2Inventory.Model.Options.ItemModelOptions
{
metadata = "CHARACTER_0002"
}
),
new Gs2Cdk.Gs2Inventory.Model.ItemModel(
name: "character-0003",
stackingLimit: 9L,
allowMultipleStacks: false,
sortValue: 3,
options: new Gs2Cdk.Gs2Inventory.Model.Options.ItemModelOptions
{
metadata = "CHARACTER_0003"
}
)
},
options: new Gs2Cdk.Gs2Inventory.Model.Options.InventoryModelOptions
{
metadata = "INVENTORY_CHARACTER"
}
)
},
new Gs2Cdk.Gs2Inventory.Model.SimpleInventoryModel[] {
new Gs2Cdk.Gs2Inventory.Model.SimpleInventoryModel(
name: "item",
simpleItemModels: new Gs2Cdk.Gs2Inventory.Model.SimpleItemModel[]
{
new Gs2Cdk.Gs2Inventory.Model.SimpleItemModel(
name: "item-0001",
options: new Gs2Cdk.Gs2Inventory.Model.Options.SimpleItemModelOptions
{
metadata = "ITEM_0001"
}
),
new Gs2Cdk.Gs2Inventory.Model.SimpleItemModel(
name: "item-0002",
options: new Gs2Cdk.Gs2Inventory.Model.Options.SimpleItemModelOptions
{
metadata = "ITEM_0002"
}
),
new Gs2Cdk.Gs2Inventory.Model.SimpleItemModel(
name: "item-0003",
options: new Gs2Cdk.Gs2Inventory.Model.Options.SimpleItemModelOptions
{
metadata = "ITEM_0003"
}
)
},
options: new Gs2Cdk.Gs2Inventory.Model.Options.SimpleInventoryModelOptions
{
metadata = "INVENTORY_ITEM"
}
)
},
new Gs2Cdk.Gs2Inventory.Model.BigInventoryModel[] {
new Gs2Cdk.Gs2Inventory.Model.BigInventoryModel(
name: "item",
bigItemModels: new Gs2Cdk.Gs2Inventory.Model.BigItemModel[]
{
new Gs2Cdk.Gs2Inventory.Model.BigItemModel(
name: "item-0001",
options: new Gs2Cdk.Gs2Inventory.Model.Options.BigItemModelOptions
{
metadata = "ITEM_0001"
}
),
new Gs2Cdk.Gs2Inventory.Model.BigItemModel(
name: "item-0002",
options: new Gs2Cdk.Gs2Inventory.Model.Options.BigItemModelOptions
{
metadata = "ITEM_0002"
}
),
new Gs2Cdk.Gs2Inventory.Model.BigItemModel(
name: "item-0003",
options: new Gs2Cdk.Gs2Inventory.Model.Options.BigItemModelOptions
{
metadata = "ITEM_0003"
}
)
},
options: new Gs2Cdk.Gs2Inventory.Model.Options.BigInventoryModelOptions
{
metadata = "INVENTORY_ITEM"
}
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import inventory from "@/gs2cdk/inventory";
class SampleStack extends core.Stack
{
public constructor() {
super();
new inventory.model.Namespace(
this,
"namespace-0001",
).masterData(
[
new inventory.model.InventoryModel(
"item",
100,
999,
[
new inventory.model.ItemModel(
"item-0001",
99,
false,
1,
{
metadata: "ITEM_0001"
}
),
new inventory.model.ItemModel(
"item-0002",
49,
true,
2,
{
metadata: "ITEM_0002"
}
),
new inventory.model.ItemModel(
"item-0003",
9,
false,
3,
{
metadata: "ITEM_0003"
}
),
],
{
metadata: "INVENTORY_ITEM"
}
),
new inventory.model.InventoryModel(
"character",
50,
99,
[
new inventory.model.ItemModel(
"character-0001",
99,
false,
1,
{
metadata: "CHARACTER_0001"
}
),
new inventory.model.ItemModel(
"character-0002",
49,
true,
2,
{
metadata: "CHARACTER_0002"
}
),
new inventory.model.ItemModel(
"character-0003",
9,
false,
3,
{
metadata: "CHARACTER_0003"
}
),
],
{
metadata: "INVENTORY_CHARACTER"
}
)
],
[
new inventory.model.SimpleInventoryModel(
"item",
[
new inventory.model.SimpleItemModel(
"item-0001",
{
metadata: "ITEM_0001"
}
),
new inventory.model.SimpleItemModel(
"item-0002",
{
metadata: "ITEM_0002"
}
),
new inventory.model.SimpleItemModel(
"item-0003",
{
metadata: "ITEM_0003"
}
),
],
{
metadata: "INVENTORY_ITEM"
}
)
],
[
new inventory.model.BigInventoryModel(
"item",
[
new inventory.model.BigItemModel(
"item-0001",
{
metadata: "ITEM_0001"
}
),
new inventory.model.BigItemModel(
"item-0002",
{
metadata: "ITEM_0002"
}
),
new inventory.model.BigItemModel(
"item-0003",
{
metadata: "ITEM_0003"
}
),
],
{
metadata: "INVENTORY_ITEM"
}
)
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Templatefrom gs2_cdk import Stack, core, inventory
class SampleStack(Stack):
def __init__(self):
super().__init__()
inventory.Namespace(
stack=self,
name="namespace-0001",
).master_data(
inventory_models=[
inventory.InventoryModel(
name='item',
initial_capacity=100,
max_capacity=999,
item_models=[
inventory.ItemModel(
name='item-0001',
stacking_limit=99,
allow_multiple_stacks=False,
sort_value=1,
options=inventory.ItemModelOptions(
metadata='ITEM_0001',
),
),
inventory.ItemModel(
name='item-0002',
stacking_limit=49,
allow_multiple_stacks=True,
sort_value=2,
options=inventory.ItemModelOptions(
metadata='ITEM_0002',
),
),
inventory.ItemModel(
name='item-0003',
stacking_limit=9,
allow_multiple_stacks=False,
sort_value=3,
options=inventory.ItemModelOptions(
metadata='ITEM_0003',
),
),
],
options=inventory.InventoryModelOptions(
metadata = 'INVENTORY_ITEM'
),
),
inventory.InventoryModel(
name='character',
initial_capacity=50,
max_capacity=99,
item_models=[
inventory.ItemModel(
name='character-0001',
stacking_limit=99,
allow_multiple_stacks=False,
sort_value=1,
options=inventory.ItemModelOptions(
metadata='CHARACTER_0001',
),
),
inventory.ItemModel(
name='character-0002',
stacking_limit=49,
allow_multiple_stacks=True,
sort_value=2,
options=inventory.ItemModelOptions(
metadata='CHARACTER_0002',
),
),
inventory.ItemModel(
name='character-0003',
stacking_limit=9,
allow_multiple_stacks=False,
sort_value=3,
options=inventory.ItemModelOptions(
metadata='CHARACTER_0003',
),
),
],
options=inventory.InventoryModelOptions(
metadata = 'INVENTORY_CHARACTER'
),
),
],
simple_inventory_models=[
inventory.SimpleInventoryModel(
name='item',
simple_item_models=[
inventory.SimpleItemModel(
name='item-0001',
options=inventory.SimpleItemModelOptions(
metadata='ITEM_0001',
),
),
inventory.SimpleItemModel(
name='item-0002',
options=inventory.SimpleItemModelOptions(
metadata='ITEM_0002',
),
),
inventory.SimpleItemModel(
name='item-0003',
options=inventory.SimpleItemModelOptions(
metadata='ITEM_0003',
),
),
],
options=inventory.SimpleInventoryModelOptions(
metadata = 'INVENTORY_ITEM'
),
),
],
big_inventory_models=[
inventory.BigInventoryModel(
name='item',
big_item_models=[
inventory.BigItemModel(
name='item-0001',
options=inventory.BigItemModelOptions(
metadata='ITEM_0001',
),
),
inventory.BigItemModel(
name='item-0002',
options=inventory.BigItemModelOptions(
metadata='ITEM_0002',
),
),
inventory.BigItemModel(
name='item-0003',
options=inventory.BigItemModelOptions(
metadata='ITEM_0003',
),
),
],
options=inventory.BigInventoryModelOptions(
metadata = 'INVENTORY_ITEM'
),
),
],
)
print(SampleStack().yaml()) # Generate TemplateInventoryModel
Inventory Model
Inventory is like a bag that stores items owned by game players. Inventory can have a set capacity and cannot be owned beyond its capacity.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| inventoryModelId | string | * | ~ 1024 chars | Inventory Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Inventory Model name Inventory 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. | |||
| initialCapacity | int | ✓ | 0 ~ 2147483646 | Initial Capacity The number of inventory slots available to a user when the inventory is first created. Each slot can hold one item stack. Users can expand their capacity up to maxCapacity through gameplay actions. | ||
| maxCapacity | int | ✓ | 0 ~ 2147483646 | Maximum Capacity The upper limit of inventory slots that a user can expand to. Capacity cannot be increased beyond this value. When all slots are occupied and items cannot be stacked further, acquisition attempts will fail unless the overflow script handles the excess. | ||
| protectReferencedItem | bool? | false | Protect Referenced Items When enabled, item sets that have references registered (via the referenceOf mechanism) cannot be consumed or deleted. This prevents items that are in use by other systems (e.g., equipped gear, items bound to formations) from being accidentally removed. | |||
| itemModels | List<ItemModel> | [] | 1 ~ 1000 items | List of Item Models The item types that can be stored in this inventory. Each item model defines the stacking and acquisition behavior for one type of item. Up to 1000 item models per inventory model. |
ItemModel
Item Model
Items can be held in groups within a single inventory slot, such as Potion ×99. This grouping of multiple items into one slot is called “stacking,” and a maximum stack size can be set for each item.
The behavior when the stack limit is reached can also be set for each item. Specifically, you can choose one of the following:
- Add a new inventory slot to allow further acquisition
- Prevent further acquisition once the limit is reached
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| itemModelId | string | * | ~ 1024 chars | Item Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Item Model name Item Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| metadata | string | ~ 2048 chars | Metadata GS2-Enhance features a mechanism that works in conjunction with GS2-Inventory to perform enhancements. It sets the experience value when used as enhancement material in JSON format within the ItemModel metadata. Details are explained in the Microservices Introduction / GS2-Enhance section. | |||
| stackingLimit | long | ✓ | 1 ~ 9223372036854775805 | Maximum Stackable Quantity The maximum number of this item that can be held in a single inventory slot (stack). When this limit is reached, the behavior depends on the allowMultipleStacks setting: either a new slot is allocated or further acquisition is blocked. | ||
| allowMultipleStacks | bool | ✓ | Allow Multiple Stacks When enabled, if the stacking limit is reached, a new inventory slot is automatically allocated to store additional quantities of this item (consuming additional capacity). When disabled, acquisition is blocked once the stacking limit is reached in the existing slot. | |||
| sortValue | int | ✓ | 0 ~ 2147483646 | Display Order A numeric value used to sort items within the inventory for display purposes. Lower values are displayed first. This value is also copied to ItemSet records to enable consistent ordering of possessed items. |
SimpleInventoryModel
Simple Inventory Model
In a normal InventoryModel, you could limit the amount of items that could be stored in your inventory. Simple Inventory, however, has no such functionality and simply stores the number of items in the inventory.
However, the Simple Inventory provides APIs that allow increasing or decreasing multiple items in a single operation.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| inventoryModelId | string | * | ~ 1024 chars | Simple Inventory Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Simple Inventory Model name Simple Inventory 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. | |||
| simpleItemModels | List<SimpleItemModel> | [] | 1 ~ 1000 items | List of Simple Item Models The item types that can be stored in this simple inventory. Unlike standard inventory, simple items have no stacking limits or capacity constraints. Up to 1000 item models per simple inventory model. |
SimpleItemModel
Simple Item Model
ItemModel allowed setting a maximum stackable quantity, enabling implementation where items exceeding a certain number could be split into multiple stacks. SimpleItem does not have such a function and simply stores the number of items in the possession of the item.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| itemModelId | string | * | ~ 1024 chars | Simple Item Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Simple Item Model name Simple Item 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. |
BigInventoryModel
Big Inventory Model
In the normal InventoryModel and SimpleInventoryModel, the number of items that can be stored in the inventory is limited to the range of int64. In inflationary games, you may need a wider range of values.
In the Big Inventory Model, the number of items that can be stored in the inventory can have an integer value of 1024 digits.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| inventoryModelId | string | * | ~ 1024 chars | Big Inventory Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Big Inventory Model name Big Inventory 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. | |||
| bigItemModels | List<BigItemModel> | [] | 1 ~ 1000 items | List of Big Item Models The item types that can be stored in this big inventory. Each big item model can hold quantities represented as integer strings up to 1024 digits. Up to 1000 item models per big inventory model. |
BigItemModel
Big Item Model
The Big Item Model defines items stored in a Big Inventory Model. Big Items can hold quantities that exceed the range of int64.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| itemModelId | string | * | ~ 1024 chars | Big Item Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Big Item Model name Big Item 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. |