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

# GS2-Money2 Deploy/CDK 레퍼런스

GS2-Deploy의 스택을 생성할 때 사용하는 템플릿 포맷과, CDK를 이용한 각종 언어의 템플릿 출력 구현 예제




## 엔티티

Deploy 처리에서 조작 대상이 되는 리소스

### Namespace

네임스페이스<br>

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

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

#### Request

리소스 생성・갱신 요청

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| name | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| currencyUsagePriority | 문자열 열거형<br>enum {<br>"PrioritizeFree",<br>"PrioritizePaid"<br>}<br> |  | ✓|  |  | 소비 우선순위<br>지갑에서 출금할 때 유상 재화와 무상 재화 중 어느 것을 먼저 소비할지를 결정합니다. "PrioritizeFree"는 무상 재화를 우선하고, "PrioritizePaid"는 유상 재화를 우선합니다.PrioritizeFree: 무료 통화를 우선해서 사용한다 / PrioritizePaid: 유료 통화를 우선해서 사용한다 /  |
| description | string |  | |  |  ~ 1024자 | 설명문 |
| transactionSetting | [TransactionSetting](#transactionsetting) |  | |  |  | 트랜잭션 설정<br>재화의 입금·출금 시 사용되는 분산 트랜잭션의 설정입니다. |
| sharedFreeCurrency | bool |  | ✓|  |  | 무상 재화를 다른 슬롯과 공유할지 여부<br>활성화하면 무상 재화 잔액이 모든 지갑 슬롯(플랫폼) 간에 공유됩니다. 유상 재화는 슬롯별로 분리된 상태로 유지됩니다. 이 설정은 네임스페이스 생성 시에만 설정할 수 있으며, 이후에는 변경할 수 없습니다. |
| platformSetting | [PlatformSetting](#platformsetting) |  | ✓|  |  | 스토어 플랫폼 설정<br>지원되는 각 스토어 플랫폼(Apple App Store, Google Play, 테스트용 Fake)의 설정입니다. 각 플랫폼에서의 영수증 검증에 필요한 인증 정보와 키를 포함합니다. |
| depositBalanceScript | [ScriptSetting](#scriptsetting) |  | |  |  | 지갑 잔액을 가산했을 때 실행할 스크립트의 설정<br>Script 트리거 레퍼런스 - [`deposit`](../script/#deposit) |
| withdrawBalanceScript | [ScriptSetting](#scriptsetting) |  | |  |  | 지갑 잔액을 소비했을 때 실행할 스크립트의 설정<br>Script 트리거 레퍼런스 - [`withdraw`](../script/#withdraw) |
| verifyReceiptScript | [ScriptSetting](#scriptsetting) |  | |  |  | 영수증 검증을 실행했을 때 실행할 스크립트의 설정<br>Script 트리거 레퍼런스 - [`verifyReceipt`](../script/#verifyreceipt) |
| subscribeScript | string |  | |  |  ~ 1024자 | 기간 결제를 신규 계약할 때 실행할 GS2-Script 스크립트 GRN(사용자 연결 변경 시에는 호출되지 않음/한 번 계약이 실효된 후 다시 계약한 경우에도 호출됨)<br>Script 트리거 레퍼런스 - [`subscribe`](../script/#subscribe) |
| renewScript | string |  | |  |  ~ 1024자 | 기간 결제를 갱신할 때 실행할 GS2-Script 스크립트 GRN<br>Script 트리거 레퍼런스 - [`renew`](../script/#renew) |
| unsubscribeScript | string |  | |  |  ~ 1024자 | 기간 결제를 해지할 때 실행할 GS2-Script 스크립트 GRN(사용자 연결 변경 시에는 호출되지 않음)<br>Script 트리거 레퍼런스 - [`unsubscribe`](../script/#unsubscribe) |
| takeOverScript | [ScriptSetting](#scriptsetting) |  | |  |  | 기간 결제에 연결된 사용자를 변경할 때 실행할 스크립트의 설정<br>Script 트리거 레퍼런스 - [`takeOver`](../script/#takeover) |
| changeSubscriptionStatusNotification | [NotificationSetting](#notificationsetting) |  | |  |  | 기간 결제의 계약 상태가 변화했을 때의 푸시 알림<br>구독 상태가 변화했을 때(활성화, 갱신, 해지, 만료, 취소 등) GS2-Gateway를 통해 전송되는 푸시 알림 설정입니다. 게임 클라이언트가 구독 상태 변화에 실시간으로 대응할 수 있도록 합니다. |
| logSetting | [LogSetting](#logsetting) |  | |  |  | 로그 출력 설정<br>이 네임스페이스에 대한 API 요청·응답 로그의 출력 대상이 되는 GS2-Log의 네임스페이스를 지정합니다. 입금, 출금, 영수증 검증, 구독 이벤트의 추적에 유용합니다. |

#### GetAttr

[!GetAttr](/articles/tech/deploy/#getattr) 태그로 취득 가능한 리소스 생성 결과

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

#### 구현 예제




**GS2-Deploy(YAML)**
```yaml

Type: GS2::Money2::Namespace
Properties:
  Name: namespace-0001
  CurrencyUsagePriority: PrioritizeFree
  Description: null
  TransactionSetting: null
  SharedFreeCurrency: false
  PlatformSetting: {}
  DepositBalanceScript: null
  WithdrawBalanceScript: null
  VerifyReceiptScript: null
  SubscribeScript: null
  RenewScript: null
  UnsubscribeScript: null
  TakeOverScript: null
  ChangeSubscriptionStatusNotification: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001

```

**Go**
```go

import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/money2"
)


SampleStack := core.NewStack()
money2.NewNamespace(
    &SampleStack,
    "namespace-0001",
    money2.NamespaceCurrencyUsagePriorityPrioritizeFree,
    false,
    money2.PlatformSetting{
        AppleAppStore: nil,
        GooglePlay:    nil,
        Fake:          nil,
    },
    money2.NamespaceOptions{
        LogSetting: &core.LogSetting{
            LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
        },
    },
)

println(SampleStack.Yaml())  // Generate Template

```

**PHP**
```php

class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Money2\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            currencyUsagePriority: \Gs2Cdk\Money2\Model\Enums\NamespaceCurrencyUsagePriority::PRIORITIZE_FREE,
            sharedFreeCurrency: false,
            platformSetting: new \Gs2Cdk\Money2\Model\PlatformSetting(),
            options: new \Gs2Cdk\Money2\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

```

**Java**
```java

class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.money2.model.Namespace(
                this,
                "namespace-0001",
                io.gs2.cdk.money2.model.enums.NamespaceCurrencyUsagePriority.PRIORITIZE_FREE,
                false,
                new io.gs2.cdk.money2.model.PlatformSetting(),
                new io.gs2.cdk.money2.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

```

**C#**
```csharp

public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Money2.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            currencyUsagePriority: Gs2Cdk.Gs2Money2.Model.Enums.NamespaceCurrencyUsagePriority.PrioritizeFree,
            sharedFreeCurrency: false,
            platformSetting: new Gs2Cdk.Gs2Money2.Model.PlatformSetting(),
            options: new Gs2Cdk.Gs2Money2.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

```

**TypeScript**
```typescript

import core from "@/gs2cdk/core";
import money2 from "@/gs2cdk/money2";

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

console.log(new SampleStack().yaml());  // Generate Template

```

**Python**
```python

from gs2_cdk import Stack, core, money2

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        money2.Namespace(
            stack=self,
            name='namespace-0001',
            currency_usage_priority=money2.NamespaceCurrencyUsagePriority.PRIORITIZE_FREE,
            shared_free_currency=False,
            platform_setting=money2.PlatformSetting(),
            options=money2.NamespaceOptions(
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

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

```


#### TransactionSetting

트랜잭션 설정<br>

트랜잭션 설정은 트랜잭션의 실행 방법·정합성·비동기 처리·충돌 회피 메커니즘을 제어하는 설정입니다.<br>
자동 실행(AutoRun), 원자적 실행(AtomicCommit), GS2-Distributor를 이용한 비동기 실행, 스크립트 결과의 일괄 적용, GS2-JobQueue를 통한 입수 액션의 비동기화 등을 조합하여 게임 로직에 맞는 견고한 트랜잭션 관리를 가능하게 합니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| enableAutoRun | bool |  |  | false |  | 발행한 트랜잭션을 서버 사이드에서 자동으로 실행할지 여부 |
| enableAtomicCommit | bool | {enableAutoRun} == true |  | false |  | 트랜잭션의 실행을 원자적으로 커밋할지 여부<br>※ enableAutoRun이(가) true 이면 활성화 |
| transactionUseDistributor | bool | {enableAtomicCommit} == true |  | false |  | 트랜잭션을 비동기 처리로 실행할지 여부<br>※ enableAtomicCommit이(가) true 이면 활성화 |
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true |  | false |  | 스크립트의 결과 커밋 처리를 비동기 처리로 실행할지 여부<br>※ transactionUseDistributor이(가) true 이면 활성화 |
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true |  | false |  | 입수 액션을 실행할 때 GS2-JobQueue를 사용할지 여부<br>※ enableAtomicCommit이(가) true 이면 활성화 |
| distributorNamespaceId | string |  |  | "grn:gs2:{region}:{ownerId}:distributor:default" |  ~ 1024자 | 트랜잭션 실행에 사용하는 GS2-Distributor 네임스페이스GRN |
| queueNamespaceId | string |  |  | "grn:gs2:{region}:{ownerId}:queue:default" |  ~ 1024자 | 트랜잭션 실행에 사용하는 GS2-JobQueue의 네임스페이스GRN |

#### ScriptSetting

스크립트 설정<br>

GS2에서는 마이크로서비스의 이벤트에 연결하여 커스텀 스크립트를 실행할 수 있습니다.<br>
이 모델은 스크립트 실행을 트리거하기 위한 설정을 보유합니다.<br>

스크립트 실행 방식은 크게 두 가지로, 바로 "동기 실행"과 "비동기 실행"입니다.<br>
동기 실행은 스크립트 실행이 완료될 때까지 처리가 블록됩니다.<br>
대신 스크립트 실행 결과를 이용하여 API 실행을 중단시키거나 API 응답 내용을 제어할 수 있습니다.<br>

한편, 비동기 실행에서는 스크립트 완료를 기다리기 위해 처리가 블록되는 일이 없습니다.<br>
다만 스크립트 실행 결과를 이용하여 API 실행을 중단하거나 API 응답 내용을 변경할 수는 없습니다.<br>
비동기 실행은 API의 응답 흐름에 영향을 주지 않으므로 원칙적으로 비동기 실행을 권장합니다.<br>

비동기 실행에는 실행 방식이 두 가지 있으며, GS2-Script와 Amazon EventBridge가 있습니다.<br>
Amazon EventBridge를 사용함으로써 Lua 이외의 언어로 처리를 작성할 수 있습니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| triggerScriptId | string |  |  |  |  ~ 1024자 | API 실행 시 동기적으로 실행되는 GS2-Script의 스크립트GRN<br>"grn:gs2:"로 시작하는 GRN 형식의 ID로 지정해야 합니다. |
| doneTriggerTargetType | 문자열 열거형<br>enum {<br>"none",<br>"gs2_script",<br>"aws"<br>}<br> |  |  | "none" |  | 비동기 스크립트의 실행 방법<br>비동기 실행에서 사용할 스크립트의 종류를 지정합니다.<br>"비동기 실행의 스크립트를 사용하지 않음(none)", "GS2-Script를 사용함(gs2_script)", "Amazon EventBridge를 사용함(aws)" 중에서 선택할 수 있습니다.none: 없음 / gs2_script: GS2-Script / aws: Amazon EventBridge /  |
| doneTriggerScriptId | string | {doneTriggerTargetType} == "gs2_script" |  |  |  ~ 1024자 | 비동기 실행할 GS2-Script 스크립트GRN<br>"grn:gs2:"로 시작하는 GRN 형식의 ID로 지정해야 합니다.<br>※ doneTriggerTargetType이(가) "gs2_script" 이면 활성화 |
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == "gs2_script" |  |  |  ~ 1024자 | 비동기 실행 스크립트를 실행하는 GS2-JobQueue 네임스페이스GRN<br>비동기 실행 스크립트를 직접 실행하지 않고 GS2-JobQueue를 경유하는 경우 GS2-JobQueue의 네임스페이스GRN을 지정합니다.<br>GS2-JobQueue를 이용해야 할 이유는 많지 않으므로, 특별한 이유가 없다면 지정할 필요는 없습니다.<br>※ doneTriggerTargetType이(가) "gs2_script" 이면 활성화 |

#### NotificationSetting

푸시 통지에 관한 설정<br>

GS2의 마이크로서비스 내에서 어떠한 이벤트가 발생했을 때, 푸시 통지를 전송하기 위한 설정입니다.<br>
여기서 말하는 푸시 통지란 GS2-Gateway가 제공하는 WebSocket 인터페이스를 경유하는 처리이며, 스마트폰의 푸시 통지와는 성질이 다릅니다.<br>
예를 들어 매치메이킹이 완료되었을 때나 친구 요청이 도착했을 때 등, 게임 클라이언트의 조작과는 관계없이 상태가 변화했을 때 GS2-Gateway를 경유하여 푸시 통지를 함으로써, 게임 클라이언트는 상태 변화를 감지할 수 있습니다.<br>

GS2-Gateway의 푸시 통지는 통지 대상 디바이스가 오프라인이었을 때 추가 처리로 모바일 푸시 통지를 전송할 수 있습니다.<br>
모바일 푸시 통지를 잘 활용하면, 매치메이킹 중에 게임을 종료하더라도 모바일 푸시 통지를 사용하여 플레이어에게 알리고, 게임으로 복귀하도록 하는 흐름을 구현할 수 있을 가능성이 있습니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| gatewayNamespaceId | string |  |  | "grn:gs2:{region}:{ownerId}:gateway:default" |  ~ 1024자 | 푸시 통지에 사용할 GS2-Gateway의 네임스페이스<br>"grn:gs2:"로 시작하는 GRN 형식으로 GS2-Gateway의 네임스페이스 ID를 지정합니다. |
| enableTransferMobileNotification | bool? |  |  | false |  | 모바일 푸시 통지로 전달할지 여부<br>이 통지를 전송하려 할 때, 통지 대상 디바이스가 오프라인일 경우 모바일 푸시 통지로 전달할지 여부를 지정합니다. |
| sound | string | {enableTransferMobileNotification} == true |  |  |  ~ 1024자 | 모바일 푸시 통지에서 사용할 사운드 파일명<br>여기서 지정한 사운드 파일명은 모바일 푸시 통지를 전송할 때 사용되며, 특별한 사운드로 통지를 출력할 수 있습니다.<br>※ enableTransferMobileNotification이(가) true 이면 활성화 |
| enable | 문자열 열거형<br>enum {<br>"Enabled",<br>"Disabled"<br>}<br> |  |  | "Enabled" |  | 푸시 통지를 활성화할지 여부Enabled: 활성화 / Disabled: 비활성화 /  |

#### LogSetting

로그 출력 설정<br>

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

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

#### PlatformSetting

스토어 플랫폼 설정<br>

지원되는 모든 스토어 플랫폼의 설정을 통합합니다. Apple App Store, Google Play, Fake(Unity Editor에서의 테스트용) 설정을 포함합니다. 각 플랫폼 설정에는 영수증 검증에 필요한 인증 정보와 키가 포함됩니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| appleAppStore | [AppleAppStoreSetting](#appleappstoresetting) |  |  |  |  | Apple App Store 설정<br>Apple App Store 영수증 검증에 사용하는 인증 정보입니다. 번들 ID, 공유 비밀 키, Issuer ID, 키 ID, 비공개 키를 포함합니다. |
| googlePlay | [GooglePlaySetting](#googleplaysetting) |  |  |  |  | Google Play 설정<br>Google Play 영수증 검증에 사용하는 인증 정보입니다. 패키지 이름과 서명 검증용 공개 키를 포함합니다. |
| fake | [FakeSetting](#fakesetting) |  |  |  |  | Fake(Unity Editor) 설정<br>개발 및 테스트 중에 Unity Editor가 생성하는 가짜 영수증을 수용하기 위한 설정입니다. |

#### AppleAppStoreSetting

Apple App Store 설정<br>

Apple App Store 영수증 검증을 위한 설정입니다. Apple의 영수증 검증 서버와 통신하는 데 필요한 인증 정보를 포함하며, 번들 ID, 공유 비밀 키, App Store Connect의 Issuer ID, 키 ID, 비밀 키가 포함됩니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| bundleId | string |  |  |  |  ~ 1024자 | Apple App Store 번들 ID |
| sharedSecretKey | string |  |  |  |  ~ 1024자 | AppStore Connect에서 발급한 영수증의 암호화에 사용되는 공유 비밀 키 |
| issuerId | string |  |  |  |  ~ 1024자 | AppStore Connect에 등록된 인앱 결제의 Issuer ID |
| keyId | string |  |  |  |  ~ 1024자 | Apple에 등록된 키 ID |
| privateKeyPem | string |  |  |  |  ~ 10240자 | Apple로부터 받은 비밀 키 |

#### GooglePlaySetting

Google Play 설정<br>

Google Play 영수증 검증을 위한 설정입니다. Google Play의 구매 서명을 검증하는 데 필요한 패키지 이름과 공개 키를 포함합니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| packageName | string |  |  |  |  ~ 5120자 | Google Play에서 배포하는 패키지 이름 |
| publicKey | string |  |  |  |  ~ 5120자 | 서명 검증에 사용하는 공개 키 |

#### FakeSetting

디버그용 가짜 플랫폼 설정<br>

개발 중 Unity Editor가 생성하는 가짜 영수증 처리에 관한 설정입니다. 가짜 영수증을 허용할지 거부할지를 제어하여, 실제 스토어 플랫폼을 사용하지 않고도 인앱 결제 흐름을 테스트할 수 있도록 합니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| acceptFakeReceipt | 문자열 열거형<br>enum {<br>"Accept",<br>"Reject"<br>}<br> |  |  | "Reject" |  | Unity Editor가 출력하는 가짜 영수증으로 결제할 수 있도록 할지 여부<br>가짜 영수증의 허용 여부를 제어합니다. 개발·테스트 중에는 "Accept"로 설정하고, 프로덕션 환경에서는 부정한 재화 입금을 방지하기 위해 "Reject"로 설정하세요.Accept: 허용 / Reject: 거부 /  |

---

### CurrentModelMaster

현재 활성화되어 있는 모델의 마스터 데이터<br>

현재 네임스페이스 내에서 유효한 모델의 정의를 기술한 마스터 데이터입니다.<br>
GS2에서는 마스터 데이터 관리에 JSON 형식의 파일을 사용합니다.<br>
파일을 업로드함으로써 실제로 서버에 설정을 반영할 수 있습니다.<br>

JSON 파일을 작성하는 방법으로, 관리 콘솔 내에 마스터 데이터 에디터를 제공하고 있습니다.<br>
또한 게임 운영에 더 적합한 도구를 제작하여 적절한 형식의 JSON 파일을 출력하는 방식으로도 서비스를 이용할 수 있습니다.
**ℹ️ Note**

JSON 파일 형식에 대해서는 [GS2-Money2 마스터 데이터 레퍼런스](api_reference/money2/master_data/)를 참조해 주세요.

#### Request

리소스 생성・갱신 요청

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128자 | 네임스페이스 이름<br>네임스페이스 고유의 이름입니다. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다. |
| mode | 문자열 열거형<br>enum {<br>"direct",<br>"preUpload"<br>}<br> |  | | "direct" |  | 업데이트 모드direct: 마스터 데이터를 직접 업데이트 / preUpload: 마스터 데이터를 업로드한 후 업데이트 /  |
| settings | string | {mode} == "direct" | ✓※|  |  ~ 5242880 바이트 (5MB) | 마스터 데이터<br>※ mode이(가) "direct" 이면 필수 |
| uploadToken | string | {mode} == "preUpload" | ✓※|  |  ~ 1024자 | 사전 업로드로 획득한 토큰<br>업로드한 마스터 데이터를 적용하기 위해 사용됩니다.<br>※ mode이(가) "preUpload" 이면 필수 |

#### GetAttr

[!GetAttr](/articles/tech/deploy/#getattr) 태그로 취득 가능한 리소스 생성 결과

| | 타입 | 설명 |
| --- | --- | --- |
| Item | [CurrentModelMaster](../sdk#currentmodelmaster) | 갱신된 현재 활성화된 모델의 마스터 데이터

#### 구현 예제




**GS2-Deploy(YAML)**
```yaml

Type: GS2::Money2::CurrentModelMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2024-06-20",
    "storeContentModels": [
      {
        "name": "content-0001",
        "appleAppStore":
          {
            "productId": "io.gs2.sample.apple.product1"
          },
        "googlePlay":
          {
            "productId": "io.gs2.sample.google.product1"
          }
      },
      {
        "name": "content-0002",
        "appleAppStore":
          {
            "productId": "io.gs2.sample.apple.product2"
          },
        "googlePlay":
          {
            "productId": "io.gs2.sample.google.product2"
          }
      },
      {
        "name": "apple-only-0001",
        "appleAppStore":
          {
            "productId": "io.gs2.sample.apple.product3"
          }
      },
      {
        "name": "google-only-0001",
        "googlePlay":
          {
            "productId": "io.gs2.sample.google.product3"
          }
      }
    ],
    "storeSubscriptionContentModels": []
    
  }
  UploadToken: null

```

**Go**
```go

import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/money2"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
money2.NewNamespace(
    &SampleStack,
    "namespace-0001",
    money2.NamespaceCurrencyUsagePriorityPrioritizeFree,
    false,
	money2.PlatformSetting{
		AppleAppStore: nil,
		GooglePlay:    nil,
		Fake:          nil,
	},
    money2.NamespaceOptions{},
).MasterData(
    []money2.StoreContentModel{
        money2.NewStoreContentModel(
            "content-0001",
            money2.StoreContentModelOptions{
                AppleAppStore: &money2.AppleAppStoreContent{
                    ProductId: pointy.String("io.gs2.sample.apple.product1"),
                },
                GooglePlay: &money2.GooglePlayContent{
                    ProductId: pointy.String("io.gs2.sample.google.product1"),
                },
            },
        ),
        money2.NewStoreContentModel(
            "content-0002",
            money2.StoreContentModelOptions{
                AppleAppStore: &money2.AppleAppStoreContent{
                    ProductId: pointy.String("io.gs2.sample.apple.product2"),
                },
                GooglePlay: &money2.GooglePlayContent{
                    ProductId: pointy.String("io.gs2.sample.google.product2"),
                },
            },
        ),
        money2.NewStoreContentModel(
            "apple-only-0001",
            money2.StoreContentModelOptions{
                AppleAppStore: &money2.AppleAppStoreContent{
                    ProductId: pointy.String("io.gs2.sample.apple.product3"),
                },
            },
        ),
        money2.NewStoreContentModel(
            "google-only-0001",
            money2.StoreContentModelOptions{
                GooglePlay: &money2.GooglePlayContent{
                    ProductId: pointy.String("io.gs2.sample.google.product3"),
                },
            },
        ),
    },
    []money2.StoreSubscriptionContentModel{
    },
)

println(SampleStack.Yaml())  // Generate Template

```

**PHP**
```php

class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Money2\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            currencyUsagePriority: \Gs2Cdk\Money2\Model\Enums\NamespaceCurrencyUsagePriority::PRIORITIZE_FREE,
            sharedFreeCurrency: false,
            platformSetting: new \Gs2Cdk\Money2\Model\PlatformSetting(),
        ))->masterData(
            [
                new \Gs2Cdk\Money2\Model\StoreContentModel(
                    name:"content-0001",
                    options: new \Gs2Cdk\Money2\Model\Options\StoreContentModelOptions(
                        appleAppStore:new \Gs2Cdk\Money2\Model\AppleAppStoreContent(
                            options: new \Gs2Cdk\Money2\Model\Options\AppleAppStoreContentOptions(
                                productId: "io.gs2.sample.apple.product1",
                            ),
                        ),
                        googlePlay:new \Gs2Cdk\Money2\Model\GooglePlayContent(
                            options: new \Gs2Cdk\Money2\Model\Options\GooglePlayContentOptions(
                                productId: "io.gs2.sample.google.product1",
                            ),
                        )
                    )
                ),
                new \Gs2Cdk\Money2\Model\StoreContentModel(
                    name:"content-0002",
                    options: new \Gs2Cdk\Money2\Model\Options\StoreContentModelOptions(
                        appleAppStore:new \Gs2Cdk\Money2\Model\AppleAppStoreContent(
                            options: new \Gs2Cdk\Money2\Model\Options\AppleAppStoreContentOptions(
                                productId: "io.gs2.sample.apple.product2",
                            ),
                        ),
                        googlePlay:new \Gs2Cdk\Money2\Model\GooglePlayContent(
                            options: new \Gs2Cdk\Money2\Model\Options\GooglePlayContentOptions(
                                productId: "io.gs2.sample.google.product2",
                            ),
                        )
                    )
                ),
                new \Gs2Cdk\Money2\Model\StoreContentModel(
                    name:"apple-only-0001",
                    options: new \Gs2Cdk\Money2\Model\Options\StoreContentModelOptions(
                        appleAppStore:new \Gs2Cdk\Money2\Model\AppleAppStoreContent(
                            options: new \Gs2Cdk\Money2\Model\Options\AppleAppStoreContentOptions(
                                productId: "io.gs2.sample.apple.product3",
                            ),
                        )
                    )
                ),
                new \Gs2Cdk\Money2\Model\StoreContentModel(
                    name:"google-only-0001",
                    options: new \Gs2Cdk\Money2\Model\Options\StoreContentModelOptions(
                        googlePlay:new \Gs2Cdk\Money2\Model\GooglePlayContent(
                            options: new \Gs2Cdk\Money2\Model\Options\GooglePlayContentOptions(
                                productId: "io.gs2.sample.google.product3",
                            ),
                        )
                    )
                )
            ],
            [
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template

```

**Java**
```java

class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.money2.model.Namespace(
            this,
            "namespace-0001",
            io.gs2.cdk.money2.model.enums.NamespaceCurrencyUsagePriority.PRIORITIZE_FREE,
            false,
            null
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.money2.model.StoreContentModel(
                    "content-0001",
                    new io.gs2.cdk.money2.model.options.StoreContentModelOptions()
                        .withAppleAppStore(new io.gs2.cdk.money2.model.AppleAppStoreContent(
                            new io.gs2.cdk.money2.model.options.AppleAppStoreContentOptions()
                                .withProductId("io.gs2.sample.apple.product1")
                        ))
                        .withGooglePlay(new io.gs2.cdk.money2.model.GooglePlayContent(
                            new io.gs2.cdk.money2.model.options.GooglePlayContentOptions()
                                .withProductId("io.gs2.sample.google.product1")
                        ))
                ),
                new io.gs2.cdk.money2.model.StoreContentModel(
                    "content-0002",
                    new io.gs2.cdk.money2.model.options.StoreContentModelOptions()
                        .withAppleAppStore(new io.gs2.cdk.money2.model.AppleAppStoreContent(
                            new io.gs2.cdk.money2.model.options.AppleAppStoreContentOptions()
                                .withProductId("io.gs2.sample.apple.product2")
                        ))
                        .withGooglePlay(new io.gs2.cdk.money2.model.GooglePlayContent(
                            new io.gs2.cdk.money2.model.options.GooglePlayContentOptions()
                                .withProductId("io.gs2.sample.google.product2")
                        ))
                ),
                new io.gs2.cdk.money2.model.StoreContentModel(
                    "apple-only-0001",
                    new io.gs2.cdk.money2.model.options.StoreContentModelOptions()
                        .withAppleAppStore(new io.gs2.cdk.money2.model.AppleAppStoreContent(
                            new io.gs2.cdk.money2.model.options.AppleAppStoreContentOptions()
                                .withProductId("io.gs2.sample.apple.product3")
                        ))
                ),
                new io.gs2.cdk.money2.model.StoreContentModel(
                    "google-only-0001",
                    new io.gs2.cdk.money2.model.options.StoreContentModelOptions()
                        .withGooglePlay(new io.gs2.cdk.money2.model.GooglePlayContent(
                            new io.gs2.cdk.money2.model.options.GooglePlayContentOptions()
                                .withProductId("io.gs2.sample.google.product3")
                        ))
                )
            ),
            Arrays.asList(
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template

```

**C#**
```csharp

public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Money2.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            currencyUsagePriority: Gs2Cdk.Gs2Money2.Model.Enums.NamespaceCurrencyUsagePriority.PrioritizeFree,
            sharedFreeCurrency: false,
            platformSetting: null
        ).MasterData(
            new Gs2Cdk.Gs2Money2.Model.StoreContentModel[] {
                new Gs2Cdk.Gs2Money2.Model.StoreContentModel(
                    name: "content-0001",
                    options: new Gs2Cdk.Gs2Money2.Model.Options.StoreContentModelOptions
                    {
                        appleAppStore = new Gs2Cdk.Gs2Money2.Model.AppleAppStoreContent(
                            options: new Gs2Cdk.Gs2Money2.Model.Options.AppleAppStoreContentOptions
                            {
                                productId = "io.gs2.sample.apple.product1"
                            }
                        ),
                        googlePlay = new Gs2Cdk.Gs2Money2.Model.GooglePlayContent(
                            options: new Gs2Cdk.Gs2Money2.Model.Options.GooglePlayContentOptions
                            {
                                productId = "io.gs2.sample.google.product1"
                            }
                        )
                    }
                ),
                new Gs2Cdk.Gs2Money2.Model.StoreContentModel(
                    name: "content-0002",
                    options: new Gs2Cdk.Gs2Money2.Model.Options.StoreContentModelOptions
                    {
                        appleAppStore = new Gs2Cdk.Gs2Money2.Model.AppleAppStoreContent(
                            options: new Gs2Cdk.Gs2Money2.Model.Options.AppleAppStoreContentOptions
                            {
                                productId = "io.gs2.sample.apple.product2"
                            }
                        ),
                        googlePlay = new Gs2Cdk.Gs2Money2.Model.GooglePlayContent(
                            options: new Gs2Cdk.Gs2Money2.Model.Options.GooglePlayContentOptions
                            {
                                productId = "io.gs2.sample.google.product2"
                            }
                        )
                    }
                ),
                new Gs2Cdk.Gs2Money2.Model.StoreContentModel(
                    name: "apple-only-0001",
                    options: new Gs2Cdk.Gs2Money2.Model.Options.StoreContentModelOptions
                    {
                        appleAppStore = new Gs2Cdk.Gs2Money2.Model.AppleAppStoreContent(
                            options: new Gs2Cdk.Gs2Money2.Model.Options.AppleAppStoreContentOptions
                            {
                                productId = "io.gs2.sample.apple.product3"
                            }
                        )
                    }
                ),
                new Gs2Cdk.Gs2Money2.Model.StoreContentModel(
                    name: "google-only-0001",
                    options: new Gs2Cdk.Gs2Money2.Model.Options.StoreContentModelOptions
                    {
                        googlePlay = new Gs2Cdk.Gs2Money2.Model.GooglePlayContent(
                            options: new Gs2Cdk.Gs2Money2.Model.Options.GooglePlayContentOptions
                            {
                                productId = "io.gs2.sample.google.product3"
                            }
                        )
                    }
                )
            },
            new Gs2Cdk.Gs2Money2.Model.StoreSubscriptionContentModel[] {
            }
        );
    }
}

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

```

**TypeScript**
```typescript

import core from "@/gs2cdk/core";
import money2 from "@/gs2cdk/money2";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new money2.model.Namespace(
            this,
            "namespace-0001",
            money2.model.NamespaceCurrencyUsagePriority.PRIORITIZE_FREE,
            false,
            new money2.model.PlatformSetting()
        ).masterData(
            [
                new money2.model.StoreContentModel(
                    "content-0001",
                    {
                        appleAppStore: new money2.model.AppleAppStoreContent(
                            {
                                productId: "io.gs2.sample.apple.product1"
                            }
                        ),
                        googlePlay: new money2.model.GooglePlayContent(
                            {
                                productId: "io.gs2.sample.google.product1"
                            }
                        )
                    }
                ),
                new money2.model.StoreContentModel(
                    "content-0002",
                    {
                        appleAppStore: new money2.model.AppleAppStoreContent(
                            {
                                productId: "io.gs2.sample.apple.product2"
                            }
                        ),
                        googlePlay: new money2.model.GooglePlayContent(
                            {
                                productId: "io.gs2.sample.google.product2"
                            }
                        )
                    }
                ),
                new money2.model.StoreContentModel(
                    "apple-only-0001",
                    {
                        appleAppStore: new money2.model.AppleAppStoreContent(
                            {
                                productId: "io.gs2.sample.apple.product3"
                            }
                        )
                    }
                ),
                new money2.model.StoreContentModel(
                    "google-only-0001",
                    {
                        googlePlay: new money2.model.GooglePlayContent(
                            {
                                productId: "io.gs2.sample.google.product3"
                            }
                        )
                    }
                )
            ],
            [
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template

```

**Python**
```python

from gs2_cdk import Stack, core, money2

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        money2.Namespace(
            stack=self,
            name="namespace-0001",
            currency_usage_priority=money2.NamespaceCurrencyUsagePriority.PRIORITIZE_FREE,
            shared_free_currency=False,
            platform_setting=money2.PlatformSetting(),
        ).master_data(
            store_content_models=[
                money2.StoreContentModel(
                    name='content-0001',
                    options=money2.StoreContentModelOptions(
                        apple_app_store = money2.AppleAppStoreContent(
                            options=money2.AppleAppStoreContentOptions(
                                product_id='io.gs2.sample.apple.product1',
                            ),
                        ),
                        google_play = money2.GooglePlayContent(
                            options=money2.GooglePlayContentOptions(
                                product_id='io.gs2.sample.google.product1',
                            ),
                        )
                    ),
                ),
                money2.StoreContentModel(
                    name='content-0002',
                    options=money2.StoreContentModelOptions(
                        apple_app_store = money2.AppleAppStoreContent(
                            options=money2.AppleAppStoreContentOptions(
                                product_id='io.gs2.sample.apple.product2',
                            ),
                        ),
                        google_play = money2.GooglePlayContent(
                            options=money2.GooglePlayContentOptions(
                                product_id='io.gs2.sample.google.product2',
                            ),
                        )
                    ),
                ),
                money2.StoreContentModel(
                    name='apple-only-0001',
                    options=money2.StoreContentModelOptions(
                        apple_app_store = money2.AppleAppStoreContent(
                            options=money2.AppleAppStoreContentOptions(
                                product_id='io.gs2.sample.apple.product3',
                            ),
                        )
                    ),
                ),
                money2.StoreContentModel(
                    name='google-only-0001',
                    options=money2.StoreContentModelOptions(
                        google_play = money2.GooglePlayContent(
                            options=money2.GooglePlayContentOptions(
                                product_id='io.gs2.sample.google.product3',
                            ),
                        )
                    ),
                ),
            ],
            store_subscription_content_models=[
            ],
        )

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

```


#### StoreContentModel

스토어 콘텐츠 모델<br>

다양한 스토어 플랫폼의 콘텐츠를 저장하는 모델입니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| storeContentModelId | string |  | ※ |  |  ~ 1024자 | 스토어 콘텐츠 모델 GRN<br>※ 서버가 자동으로 설정 |
| name | string |  | ✓ |  |  ~ 128자 | 스토어 콘텐츠 모델 이름 |
| metadata | string |  |  |  |  ~ 1024자 | 메타데이터<br>메타데이터에는 임의의 값을 설정할 수 있습니다.<br>이 값들은 GS2의 동작에는 영향을 주지 않으므로, 게임 내에서 사용하는 정보를 저장하는 용도로 사용할 수 있습니다. |
| appleAppStore | [AppleAppStoreContent](#appleappstorecontent) |  |  |  |  | Apple App Store의 콘텐츠<br>이 스토어 콘텐츠의 Apple App Store 상품 정보(프로덕트 ID)입니다. 영수증 검증 시 구매한 상품과의 대조에 사용됩니다. |
| googlePlay | [GooglePlayContent](#googleplaycontent) |  |  |  |  | Google Play의 콘텐츠<br>이 스토어 콘텐츠의 Google Play 상품 정보(프로덕트 ID)입니다. 영수증 검증 시 구매한 상품과의 대조에 사용됩니다. |

#### AppleAppStoreContent

Apple App Store의 콘텐츠<br>

인앱 결제 상품에 대응하는 Apple App Store의 프로덕트 ID를 포함합니다. 영수증 검증 시 대조에 사용됩니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| productId | string |  |  |  |  ~ 1024자 | 프로덕트 ID<br>이 인앱 결제 아이템에 대해 App Store Connect에 등록된 Apple App Store의 프로덕트 식별자입니다. |

#### GooglePlayContent

Google Play의 콘텐츠<br>

인앱 결제 상품에 대응하는 Google Play의 프로덕트 ID를 포함합니다. 영수증 검증 시 대조에 사용됩니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| productId | string |  |  |  |  ~ 1024자 | 프로덕트 ID<br>이 인앱 결제 아이템에 대해 Google Play Console에 등록되어 있는 Google Play의 프로덕트 식별자입니다. |

#### StoreSubscriptionContentModel

스토어 구독 콘텐츠 모델<br>

다양한 스토어 플랫폼의 구독 콘텐츠를 저장하는 모델입니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| storeSubscriptionContentModelId | string |  | ※ |  |  ~ 1024자 | 구독 콘텐츠 모델 GRN<br>※ 서버가 자동으로 설정 |
| name | string |  | ✓ |  |  ~ 128자 | 스토어 구독 콘텐츠 모델 이름 |
| metadata | string |  |  |  |  ~ 1024자 | 메타데이터 |
| scheduleNamespaceId | string |  | ✓ |  |  ~ 1024자 | 구독 기간을 연동시킬 GS2-Schedule의 네임스페이스 GRN |
| triggerName | string |  | ✓ |  |  ~ 128자 | 구독 기간을 반영하는 트리거 이름<br>구독의 유효 기간을 반영하기 위해 실행되는 GS2-Schedule의 트리거 이름입니다. 트리거의 지속 시간은 구독의 유효 기한으로 설정됩니다. |
| triggerExtendMode | 문자열 열거형<br>enum {<br>"just",<br>"rollupHour"<br>}<br> |  |  | "just" |  | 구독 기간을 트리거에 반영할 때의 모드<br>구독의 유효 기한을 트리거의 지속 시간에 어떻게 매핑할지를 제어합니다. "just"는 구독 기간을 그대로 사용합니다. "rollupHour"는 지정한 시각(UTC)까지 연장하여 하루 중간에 만료되는 것을 방지합니다.just: 그대로 구독 기간을 반영 / rollupHour: 다음 날짜 변경 시각까지 연장하여 구독 기간을 반영 /  |
| rollupHour | int | {triggerExtendMode} == "rollupHour" |  | 0 | 0 ~ 23 | 날짜 변경 시각(UTC)<br>triggerExtendMode가 "rollupHour"인 경우, 구독 기간은 유효 기한일의 이 시각(0~23, UTC)까지 연장됩니다. 사용자의 플레이 세션 중에 구독이 만료되는 것을 방지합니다.<br>※ triggerExtendMode이(가) "rollupHour" 이면 활성화 |
| reallocateSpanDays | int |  |  | 30 | 0 ~ 365 | 구독 계약 정보를 다른 사용자에게 할당할 수 있게 되는 기간(일)<br>마지막 할당 이후, 구독 계약을 다른 사용자에게 재할당할 수 있게 되기까지의 일수입니다. 사용자가 계정을 변경할 때의 부정 이용을 방지하기 위해 구독 이전에 대기 기간을 둡니다. |
| appleAppStore | [AppleAppStoreSubscriptionContent](#appleappstoresubscriptioncontent) |  |  |  |  | Apple App Store 콘텐츠<br>이 구독 콘텐츠의 Apple App Store 구독 정보(구독 그룹 ID)입니다. |
| googlePlay | [GooglePlaySubscriptionContent](#googleplaysubscriptioncontent) |  |  |  |  | Google Play 콘텐츠<br>이 구독 콘텐츠의 Google Play 구독 정보(프로덕트 ID)입니다. |

#### AppleAppStoreSubscriptionContent

Apple App Store의 기간 결제 콘텐츠<br>

구독 기반 상품의 Apple App Store 구독 그룹 식별자를 포함합니다. 자동 갱신 구독의 관리와 검증에 사용됩니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| subscriptionGroupIdentifier | string |  |  |  |  ~ 64자 | 구독 그룹 ID<br>App Store Connect에 등록된 구독 그룹 식별자입니다. 동일 그룹 내의 구독은 상호 배타적이며, 사용자는 동시에 하나만 계약할 수 있습니다. |

#### GooglePlaySubscriptionContent

Google Play 구독 콘텐츠<br>

구독 기반 상품의 Google Play 프로덕트 ID를 포함합니다. Google Play에서 자동 갱신 구독을 관리하고 검증하는 데 사용됩니다.

|  | 타입 | 활성화 조건 | 필수 | 기본값 | 값 제한 | 설명 |
| --- | --- | --- | --- | --- | --- | --- |
| productId | string |  |  |  |  ~ 1024자 | 프로덕트 ID |

---



