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

Fix Data_source_account update error #223

Merged
merged 1 commit into from
May 13, 2024
Merged
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
16 changes: 12 additions & 4 deletions src/spaceone/cost_analysis/service/data_source_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Union

from spaceone.core.service import *
from spaceone.core.error import ERROR_PERMISSION_DENIED

from spaceone.cost_analysis.manager import DataSourceManager
from spaceone.cost_analysis.manager.data_source_account_manager import (
Expand Down Expand Up @@ -39,8 +40,6 @@ def update(
params (dict): {
'data_source_id': 'str', # required
'account_id': 'str', # required
'service_account_id': 'str',
'project_id': 'str',
'workspace_id': 'str', # injected from auth
'domain_id': 'str' # injected from auth
}
Expand All @@ -54,16 +53,25 @@ def update(
workspace_id = params.workspace_id

# Check if the data source exists
data_source_vo = self.data_source_mgr.get_data_source(data_source_id, domain_id)
role_type = self.transaction.get_meta("authorization.role_type")
if role_type != "DOMAIN_ADMIN":
data_source_vo = self.data_source_mgr.get_data_source(
data_source_id, domain_id, workspace_id
)
else:
data_source_vo = self.data_source_mgr.get_data_source(
data_source_id, domain_id
)

# Check workspace
if workspace_id:
identity_mgr = self.locator.get_manager("IdentityManager")
identity_mgr.check_workspace(workspace_id, domain_id)

data_source_account_vo = self.data_source_account_mgr.get_data_source_account(
data_source_id, account_id, domain_id, workspace_id
data_source_id, account_id, domain_id
)

data_source_account_vo = (
self.data_source_account_mgr.update_data_source_account_by_vo(
params.dict(exclude_unset=True), data_source_account_vo
Expand Down
Loading