From 8e01babc4afcf92d3a4ffe79fa8480efb1f5b875 Mon Sep 17 00:00:00 2001 From: Jongmin Kim Date: Mon, 4 Sep 2023 20:44:04 +0900 Subject: [PATCH] feat: change grpc_method of analyze API --- .../interface/rest/cost_analysis/cost.py | 39 +------------------ .../model/cost_analysis/cost.py | 18 +++------ 2 files changed, 7 insertions(+), 50 deletions(-) diff --git a/src/cloudforet/console_api_v2/interface/rest/cost_analysis/cost.py b/src/cloudforet/console_api_v2/interface/rest/cost_analysis/cost.py index cf2e6b8..815b829 100644 --- a/src/cloudforet/console_api_v2/interface/rest/cost_analysis/cost.py +++ b/src/cloudforet/console_api_v2/interface/rest/cost_analysis/cost.py @@ -48,54 +48,19 @@ async def get(self, request: Request): @router.post('/list', openapi_extra=CostQuery.meta(), response_model=CostsInfo) @exception_handler async def list(self, request: Request): - """ - ## Description - Gets a list of all Costs. You can use a query to get a filtered list of Costs. - -
- | Key | Description | Type | Required | - |------------------------|---------------------------------------------------------------|--------|----------| - | **cost_id** | Cost id | string | | - | **original_currency** | Original currency like USD | string | | - | **provider** | CSP code like aws, azure and google_cloud | string | | - | **region_code** | Unique region code by each CSP | string | | - | **region_key** | {provider}.{region_code} format value | string | | - | **category** | Category value | string | | - | **product** | Product value | string | | - | **account** | Unique ID to identify your account from CSP | string | | - | **usage_type** | Usage type | string | | - | **resource_group** | Resource group value | string | | - | **resource** | Resource value | string | | - | **service_account_id** | Service account id | string | | - | **project_id** | Project id | string | | - | **project_group_id** | Project group id | string | | - | **data_source_id** | Data source id | string | | - | **query** | Query option for detail search | object | | - | **domain_id** | Unique id by each domain (extracted automatically from token) | string | | - """ params, metadata = await self.parse_request(request, self.token.credentials) with self.locator.get_service(ProxyService, metadata) as proxy_service: params['grpc_method'] = 'cost_analysis.Cost.list' return proxy_service.dispatch_api(params) - @router.post('/analyze', openapi_extra=CostAnalyzeV2Query.meta(), response_model=CostAnalyzeInfo) + @router.post('/analyze', openapi_extra=CostAnalyzeQuery.meta(), response_model=CostAnalyzeInfo) @exception_handler async def analyze(self, request: Request): - """ - ## Description - Gets the Cost information of specific products. - -
- | Key | Description | Type | Required | - |---------------|---------------------------------------------------------------|--------|----------| - | **query** | Query option for detail search | object |*True* | - | **domain_id** | Unique id by each domain (extracted automatically from token) | string | | - """ params, metadata = await self.parse_request(request, self.token.credentials) with self.locator.get_service(ProxyService, metadata) as proxy_service: - params['grpc_method'] = 'cost_analysis.Cost.analyze_v2' + params['grpc_method'] = 'cost_analysis.Cost.analyze' return proxy_service.dispatch_api(params) @router.post('/stat', openapi_extra=CostStatQuery.meta()) diff --git a/src/cloudforet/console_api_v2/model/cost_analysis/cost.py b/src/cloudforet/console_api_v2/model/cost_analysis/cost.py index 60229cc..4a3fab0 100644 --- a/src/cloudforet/console_api_v2/model/cost_analysis/cost.py +++ b/src/cloudforet/console_api_v2/model/cost_analysis/cost.py @@ -18,15 +18,11 @@ class GetCostRequest(BaseAPIModel): class CostQuery(BaseAPIModel): cost_id: Union[str, None] = Field(None) - original_currency: Union[str, None] = Field(None) provider: Union[str, None] = Field(None) region_code: Union[str, None] = Field(None) region_key: Union[str, None] = Field(None) - category: Union[str, None] = Field(None) product: Union[str, None] = Field(None) - account: Union[str, None] = Field(None) usage_type: Union[str, None] = Field(None) - resource_group: Union[str, None] = Field(None) resource: Union[str, None] = Field(None) service_account_id: Union[str, None] = Field(None) project_id: Union[str, None] = Field(None) @@ -38,18 +34,14 @@ class CostQuery(BaseAPIModel): class CostInfo(BaseAPIModel): cost_id: Union[str, None] = Field(None) - usd_cost: Union[str, None] = Field(None) - original_currency: Union[str, None] = Field(None) - original_cost: Union[float, None] = Field(None) + cost: Union[float, None] = Field(None) usage_quantity: Union[float, None] = Field(None) + usage_unit: Union[str, None] = Field(None) provider: Union[str, None] = Field(None) region_code: Union[str, None] = Field(None) region_key: Union[str, None] = Field(None) - category: Union[str, None] = Field(None) product: Union[str, None] = Field(None) - account: Union[str, None] = Field(None) usage_type: Union[str, None] = Field(None) - resource_group: Union[str, None] = Field(None) resource: Union[str, None] = Field(None) tags: Union[dict, None] = Field(None) additional_info: Union[dict, None] = Field(None) @@ -57,8 +49,7 @@ class CostInfo(BaseAPIModel): project_id: Union[str, None] = Field(None) data_source_id: Union[str, None] = Field(None) domain_id: Union[str, None] = Field(None) - billed_at: Union[datetime, None] = Field(None) - created_at: Union[datetime, None] = Field(None) + billed_date: Union[str, None] = Field(None) class CostsInfo(BaseAPIModel): @@ -66,7 +57,8 @@ class CostsInfo(BaseAPIModel): total_count: Union[int, None] = Field(None) -class CostAnalyzeV2Query(BaseAPIModel): +class CostAnalyzeQuery(BaseAPIModel): + data_source_id: Union[str, None] = Field(None) query: dict = Field(None) domain_id: Union[str, None] = Field(None)