diff --git a/src/spaceone/dashboard/info/private_dashboard_info.py b/src/spaceone/dashboard/info/private_dashboard_info.py index fcfa92f..0d14b3d 100644 --- a/src/spaceone/dashboard/info/private_dashboard_info.py +++ b/src/spaceone/dashboard/info/private_dashboard_info.py @@ -12,6 +12,8 @@ def PrivateDashboardInfo(dashboard_vo: PrivateDashboard, minimal=False): "private_dashboard_id": dashboard_vo.private_dashboard_id, "name": dashboard_vo.name, "version": dashboard_vo.version, + "template_id": dashboard_vo.template_id, + "template_type": dashboard_vo.template_type, "display_info": change_struct_type(dashboard_vo.display_info), "labels": change_list_value_type(dashboard_vo.labels), "user_id": dashboard_vo.user_id, diff --git a/src/spaceone/dashboard/info/public_dashboard_info.py b/src/spaceone/dashboard/info/public_dashboard_info.py index 0ad5f07..aaa5f91 100644 --- a/src/spaceone/dashboard/info/public_dashboard_info.py +++ b/src/spaceone/dashboard/info/public_dashboard_info.py @@ -12,6 +12,8 @@ def PublicDashboardInfo(dashboard_vo: PublicDashboard, minimal=False): "public_dashboard_id": dashboard_vo.public_dashboard_id, "name": dashboard_vo.name, "version": dashboard_vo.version, + "template_id": dashboard_vo.template_id, + "template_type": dashboard_vo.template_type, "display_info": change_struct_type(dashboard_vo.display_info), "labels": change_list_value_type(dashboard_vo.labels), "resource_group": dashboard_vo.resource_group, diff --git a/src/spaceone/dashboard/model/private_dashboard_model.py b/src/spaceone/dashboard/model/private_dashboard_model.py index 7ed56b8..1fb6f67 100644 --- a/src/spaceone/dashboard/model/private_dashboard_model.py +++ b/src/spaceone/dashboard/model/private_dashboard_model.py @@ -9,6 +9,10 @@ class PrivateDashboard(MongoModel): max_length=40, generate_id="private-dash", unique=True ) name = StringField(max_length=100) + template_id = StringField(max_length=100, default="blank") + template_type = StringField( + max_length=40, choices=("MANAGED", "CUSTOM", "EXTENSION") + ) version = IntField(default=1) layouts = ListField(default=[]) variables = DictField(default={}) @@ -26,6 +30,8 @@ class PrivateDashboard(MongoModel): meta = { "updatable_fields": [ "name", + "template_id", + "template_type", "layouts", "variables", "settings", @@ -38,6 +44,8 @@ class PrivateDashboard(MongoModel): "private_dashboard_id", "name", "version", + "template_id", + "template_type", "display_info", "user_id", "workspace_id", @@ -46,6 +54,7 @@ class PrivateDashboard(MongoModel): "ordering": ["name"], "indexes": [ "name", + "template_type", "labels", "user_id", "workspace_id", diff --git a/src/spaceone/dashboard/model/public_dashboard_model.py b/src/spaceone/dashboard/model/public_dashboard_model.py index 5a32f3f..8f50a17 100644 --- a/src/spaceone/dashboard/model/public_dashboard_model.py +++ b/src/spaceone/dashboard/model/public_dashboard_model.py @@ -9,6 +9,10 @@ class PublicDashboard(MongoModel): max_length=40, generate_id="public-dash", unique=True ) name = StringField(max_length=100) + template_id = StringField(max_length=100, default="blank") + template_type = StringField( + max_length=40, choices=("MANAGED", "CUSTOM", "EXTENSION") + ) version = IntField(default=1) layouts = ListField(default=[]) variables = DictField(default={}) @@ -29,6 +33,8 @@ class PublicDashboard(MongoModel): meta = { "updatable_fields": [ "name", + "template_id", + "template_type", "layouts", "variables", "settings", @@ -41,6 +47,8 @@ class PublicDashboard(MongoModel): "public_dashboard_id", "name", "version", + "template_id", + "template_type", "display_info", "resource_group", "project_id", @@ -52,6 +60,7 @@ class PublicDashboard(MongoModel): "indexes": [ "name", "labels", + "template_type", "resource_group", "project_id", "workspace_id", diff --git a/src/spaceone/dashboard/service/private_dashboard_service.py b/src/spaceone/dashboard/service/private_dashboard_service.py index b759bdc..2f2de05 100644 --- a/src/spaceone/dashboard/service/private_dashboard_service.py +++ b/src/spaceone/dashboard/service/private_dashboard_service.py @@ -34,13 +34,17 @@ def __init__(self, *args, **kwargs): permission="dashboard:PrivateDashboard.write", role_types=["WORKSPACE_OWNER", "WORKSPACE_MEMBER"], ) - @check_required(["name", "workspace_id", "domain_id"]) + @check_required( + ["name", "template_id", "template_type", "workspace_id", "domain_id"] + ) def create(self, params: dict) -> PrivateDashboard: """Register private_dashboard Args: params (dict): { 'name': 'str', # required + 'template_id': 'str', # required + 'template_type': 'str', # required 'layouts': 'list', 'variables': 'dict', 'settings': 'dict', diff --git a/src/spaceone/dashboard/service/public_dashboard_service.py b/src/spaceone/dashboard/service/public_dashboard_service.py index cb97f03..0008493 100644 --- a/src/spaceone/dashboard/service/public_dashboard_service.py +++ b/src/spaceone/dashboard/service/public_dashboard_service.py @@ -34,17 +34,20 @@ def __init__(self, *args, **kwargs): permission="dashboard:PublicDashboard.write", role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER", "WORKSPACE_MEMBER"], ) - @check_required(["name", "domain_id"]) + @check_required(["name", "template_id", "template_type", "domain_id"]) def create(self, params: dict) -> PublicDashboard: """Register public_dashboard Args: params (dict): { 'name': 'str', # required + 'template_id': 'str', # required + 'template_type': 'str', # required 'layouts': 'list', 'variables': 'dict', 'settings': 'dict', 'variables_schema': 'dict', + 'display_info': 'dict', 'labels': 'list', 'tags': 'dict', 'resource_group': 'str', # required @@ -95,10 +98,13 @@ def update(self, params): params (dict): { 'public_dashboard_id': 'str', # required 'name': 'str', + 'template_id': 'str', + 'template_type': 'str', 'layouts': 'list', 'variables': 'dict', 'settings': 'dict', 'variables_schema': 'list', + 'display_info': 'dict', 'labels': 'list', 'tags': 'dict', 'domain_id': 'str' # injected from auth (required)