Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change method response to response_data #120

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading