-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from ImMin5/master
Add new feature 'update_permissions' for DataSource
- Loading branch information
Showing
19 changed files
with
324 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,46 @@ | ||
from spaceone.api.cost_analysis.v1 import cost_pb2, cost_pb2_grpc | ||
from spaceone.core.pygrpc import BaseAPI | ||
|
||
from spaceone.cost_analysis.service import CostService | ||
|
||
class Cost(BaseAPI, cost_pb2_grpc.CostServicer): | ||
|
||
class Cost(BaseAPI, cost_pb2_grpc.CostServicer): | ||
pb2 = cost_pb2 | ||
pb2_grpc = cost_pb2_grpc | ||
|
||
def create(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
|
||
with self.locator.get_service('CostService', metadata) as cost_service: | ||
return self.locator.get_info('CostInfo', cost_service.create(params)) | ||
with self.locator.get_service("CostService", metadata) as cost_service: | ||
return self.locator.get_info("CostInfo", cost_service.create(params)) | ||
|
||
def delete(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
|
||
with self.locator.get_service('CostService', metadata) as cost_service: | ||
with self.locator.get_service("CostService", metadata) as cost_service: | ||
cost_service.delete(params) | ||
return self.locator.get_info('EmptyInfo') | ||
return self.locator.get_info("EmptyInfo") | ||
|
||
def get(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
|
||
with self.locator.get_service('CostService', metadata) as cost_service: | ||
return self.locator.get_info('CostInfo', cost_service.get(params)) | ||
cost_svc = CostService(metadata) | ||
response: dict = cost_svc.get(params) | ||
return self.dict_to_message(response) | ||
|
||
def list(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
|
||
with self.locator.get_service('CostService', metadata) as cost_service: | ||
cost_vos, total_count = cost_service.list(params) | ||
return self.locator.get_info('CostsInfo', | ||
cost_vos, | ||
total_count, | ||
minimal=self.get_minimal(params)) | ||
cost_svc = CostService(metadata) | ||
response: dict = cost_svc.list(params) | ||
return self.dict_to_message(response) | ||
|
||
def analyze(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
|
||
with self.locator.get_service('CostService', metadata) as cost_service: | ||
return self.locator.get_info('StatisticsInfo', cost_service.analyze(params)) | ||
with self.locator.get_service("CostService", metadata) as cost_service: | ||
return self.locator.get_info("StatisticsInfo", cost_service.analyze(params)) | ||
|
||
def stat(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
|
||
with self.locator.get_service('CostService', metadata) as cost_service: | ||
return self.locator.get_info('StatisticsInfo', cost_service.stat(params)) | ||
with self.locator.get_service("CostService", metadata) as cost_service: | ||
return self.locator.get_info("StatisticsInfo", cost_service.stat(params)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Union, List | ||
from pydantic import BaseModel | ||
|
||
__all__ = ["CostResponse", "CostsResponse"] | ||
|
||
|
||
class CostResponse(BaseModel): | ||
cost_id: Union[str, None] = None | ||
cost: Union[float, None] = None | ||
usage_quantity: Union[float, None] = None | ||
usage_unit: Union[str, None] = None | ||
provider: Union[str, None] = None | ||
region_code: Union[str, None] = None | ||
region_key: Union[str, None] = None | ||
product: Union[str, None] = None | ||
usage_type: Union[str, None] = None | ||
resource: Union[str, None] = None | ||
tags: Union[dict, None] = None | ||
additional_info: Union[dict, None] = None | ||
data: Union[dict, None] = None | ||
account_id: Union[str, None] = None | ||
service_account_id: Union[str, None] = None | ||
project_id: Union[str, None] = None | ||
data_source_id: Union[str, None] = None | ||
workspace_id: Union[str, None] = None | ||
domain_id: Union[str, None] = None | ||
billed_year: Union[str, None] = None | ||
billed_month: Union[str, None] = None | ||
billed_date: Union[str, None] = None | ||
|
||
|
||
class CostsResponse(BaseModel): | ||
results: List[CostResponse] | ||
total_count: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import Union, Literal | ||
from pydantic import BaseModel | ||
|
||
__all__ = [ | ||
"DataSourceUpdatePermissionsRequest", | ||
] | ||
State = Literal["ENABLED", "DISABLED"] | ||
DataSourceType = Literal["LOCAL", "EXTERNAL"] | ||
SecretType = Literal["MANUAL", "USE_SERVICE_ACCOUNT_SECRET"] | ||
ResourceGroup = Literal["DOMAIN", "WORKSPACE"] | ||
|
||
|
||
class DataSourceUpdatePermissionsRequest(BaseModel): | ||
data_source_id: str | ||
permissions: dict | ||
domain_id: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from datetime import datetime | ||
from typing import Union, Literal | ||
from pydantic import BaseModel | ||
|
||
from spaceone.core import utils | ||
|
||
from spaceone.cost_analysis.model.data_source.request import ( | ||
State, | ||
DataSourceType, | ||
SecretType, | ||
ResourceGroup, | ||
) | ||
|
||
__all__ = [ | ||
"DataSourceResponse", | ||
] | ||
|
||
|
||
class DataSourceResponse(BaseModel): | ||
data_source_id: Union[str, None] = None | ||
name: Union[str, None] = None | ||
state: Union[State, None] = None | ||
data_source_type: Union[DataSourceType, None] = None | ||
permissions: Union[dict, None] = None | ||
provider: Union[str, None] = None | ||
secret_type: Union[SecretType, None] = None | ||
secret_filter: Union[dict, None] = None | ||
plugin_info: Union[dict, None] = None | ||
template: Union[dict, None] = None | ||
tags: Union[dict, None] = None | ||
cost_tag_keys: Union[list, None] = None | ||
cost_additional_info_keys: Union[list, None] = None | ||
cost_data_keys: Union[list, None] = None | ||
data_source_account_count: Union[int, None] = None | ||
connected_workspace_count: Union[int, None] = None | ||
resource_group: Union[ResourceGroup, None] = None | ||
workspace_id: Union[str, None] = None | ||
domain_id: Union[str, None] = None | ||
created_at: Union[datetime, None] = None | ||
updated_at: Union[datetime, None] = None | ||
last_synchronized_at: Union[datetime, None] = None | ||
|
||
def dict(self, *args, **kwargs): | ||
data = super().dict(*args, **kwargs) | ||
data["created_at"] = utils.datetime_to_iso8601(data["created_at"]) | ||
data["updated_at"] = utils.datetime_to_iso8601(data.get("updated_at")) | ||
data["last_synchronized_at"] = utils.datetime_to_iso8601( | ||
data.get("last_synchronized_at") | ||
) | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.