Skip to content

Commit

Permalink
Merge pull request #120 from stat-kwon/master
Browse files Browse the repository at this point in the history
Change method response to response_data
  • Loading branch information
stat-kwon authored Dec 13, 2024
2 parents 0fde102 + 67677ed commit e1d46df
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/spaceone/dashboard/service/private_data_table_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def load(self, params: PrivateDataTableLoadRequest) -> dict:
params.end,
params.vars,
)
return ds_mgr.response(params.sort, params.page)
return ds_mgr.response_data(params.sort, params.page)

else:
operator = pri_data_table_vo.operator
Expand All @@ -404,7 +404,7 @@ def load(self, params: PrivateDataTableLoadRequest) -> dict:
params.end,
params.vars,
)
return dt_mgr.response(params.sort, params.page)
return dt_mgr.response_data(params.sort, params.page)

@transaction(
permission="dashboard:PrivateDataTable.read",
Expand Down
71 changes: 71 additions & 0 deletions src/spaceone/dashboard/service/private_widget_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,77 @@ def load(self, params: PrivateWidgetLoadRequest) -> dict:
params.vars,
)

@transaction(
permission="dashboard:PrivateWidget.read",
role_types=["USER"],
)
@change_value_by_rule("APPEND", "workspace_id", "*")
@change_value_by_rule("APPEND", "project_id", "*")
@convert_model
def load_sum(self, params: PrivateWidgetLoadRequest) -> dict:
"""Load private widget
Args:
params (dict): {
'widget_id': 'str', # required
'query': 'dict (spaceone.api.core.v1.AnalyzeQuery)', # required
'vars': 'dict',
'user_id': 'str', # injected from auth (required)
'domain_id': 'str' # injected from auth (required)
}
Returns:
None
"""

pri_widget_vo = self.pri_widget_mgr.get_private_widget(
params.widget_id,
params.domain_id,
params.user_id,
)

if pri_widget_vo.data_table_id is None:
raise ERROR_INVALID_PARAMETER(
key="widget_id", reason="Data table is not set."
)

pri_data_table_mgr = PrivateDataTableManager()
pri_data_table_vo = pri_data_table_mgr.get_private_data_table(
pri_widget_vo.data_table_id,
params.domain_id,
params.user_id,
)

if pri_data_table_vo.data_type == "ADDED":
ds_mgr = DataSourceManager(
"PRIVATE",
pri_data_table_vo.source_type,
pri_data_table_vo.options,
pri_data_table_vo.widget_id,
pri_data_table_vo.domain_id,
)
return ds_mgr.load_from_widget(
params.query,
params.vars,
column_sum=True,
)
else:
operator = pri_data_table_vo.operator
options = pri_data_table_vo.options.get(operator, {})

dt_mgr = DataTransformationManager(
"PRIVATE",
pri_data_table_vo.operator,
options,
pri_data_table_vo.widget_id,
pri_data_table_vo.domain_id,
)
return dt_mgr.load_from_widget(
params.query,
params.vars,
column_sum=True,
)

@transaction(
permission="dashboard:PrivateWidget.read",
role_types=["USER"],
Expand Down
4 changes: 2 additions & 2 deletions src/spaceone/dashboard/service/public_data_table_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def load(self, params: PublicDataTableLoadRequest) -> dict:
params.end,
params.vars,
)
return ds_mgr.response(params.sort, params.page)
return ds_mgr.response_data(params.sort, params.page)

else:
operator = pub_data_table_vo.operator
Expand All @@ -428,7 +428,7 @@ def load(self, params: PublicDataTableLoadRequest) -> dict:
params.end,
params.vars,
)
return dt_mgr.response(params.sort, params.page)
return dt_mgr.response_data(params.sort, params.page)

@transaction(
permission="dashboard:PublicDataTable.read",
Expand Down

0 comments on commit e1d46df

Please sign in to comment.