Skip to content

Commit

Permalink
fix: data_source_account update error (cloudforet-io#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed May 13, 2024
1 parent ecd8c5c commit bcc98a9
Showing 1 changed file with 12 additions and 4 deletions.
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

0 comments on commit bcc98a9

Please sign in to comment.