Skip to content

Commit

Permalink
feat: add additional fields in dashboard model
Browse files Browse the repository at this point in the history
  • Loading branch information
stat-kwon committed Mar 5, 2024
1 parent dc4a808 commit 3a8d28e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/spaceone/dashboard/info/private_dashboard_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/spaceone/dashboard/info/public_dashboard_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions src/spaceone/dashboard/model/private_dashboard_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand All @@ -26,6 +30,8 @@ class PrivateDashboard(MongoModel):
meta = {
"updatable_fields": [
"name",
"template_id",
"template_type",
"layouts",
"variables",
"settings",
Expand All @@ -38,6 +44,8 @@ class PrivateDashboard(MongoModel):
"private_dashboard_id",
"name",
"version",
"template_id",
"template_type",
"display_info",
"user_id",
"workspace_id",
Expand All @@ -46,6 +54,7 @@ class PrivateDashboard(MongoModel):
"ordering": ["name"],
"indexes": [
"name",
"template_type",
"labels",
"user_id",
"workspace_id",
Expand Down
9 changes: 9 additions & 0 deletions src/spaceone/dashboard/model/public_dashboard_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand All @@ -29,6 +33,8 @@ class PublicDashboard(MongoModel):
meta = {
"updatable_fields": [
"name",
"template_id",
"template_type",
"layouts",
"variables",
"settings",
Expand All @@ -41,6 +47,8 @@ class PublicDashboard(MongoModel):
"public_dashboard_id",
"name",
"version",
"template_id",
"template_type",
"display_info",
"resource_group",
"project_id",
Expand All @@ -52,6 +60,7 @@ class PublicDashboard(MongoModel):
"indexes": [
"name",
"labels",
"template_type",
"resource_group",
"project_id",
"workspace_id",
Expand Down
6 changes: 5 additions & 1 deletion src/spaceone/dashboard/service/private_dashboard_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 7 additions & 1 deletion src/spaceone/dashboard/service/public_dashboard_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3a8d28e

Please sign in to comment.