Skip to content

Commit 2958b00

Browse files
Merge pull request #23 from jinyoungmoonDEV/master
fix: 비용 정보에서 Credit 정보 포함 여부를 optional로 처리하도록 변경
2 parents 7fcb829 + 4c15c6f commit 2958b00

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/plugin/manager/cost_manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def get_data(
7777

7878
date_ranges = self._get_date_range(start)
7979

80+
include_credit = options.get("include_credit", True)
81+
8082
for date in date_ranges:
8183
year, month = date.split("-")
8284
path = f"SPACE_ONE/billing/database={database}/account_id={account_id}/year={year}/month={month}"
@@ -85,7 +87,7 @@ def get_data(
8587
for content in contents:
8688
response_stream = self.aws_s3_connector.get_cost_data(content["Key"])
8789
for results in response_stream:
88-
yield self._make_cost_data(results, account_id)
90+
yield self._make_cost_data(results, account_id, include_credit)
8991

9092
yield {"results": []}
9193

@@ -98,7 +100,7 @@ def _update_sync_state(self, options, secret_data, schema, service_account_id):
98100
tags["is_sync"] = "true"
99101
self.space_connector.update_service_account(service_account_id, tags)
100102

101-
def _make_cost_data(self, results, account_id):
103+
def _make_cost_data(self, results, account_id, include_credit):
102104
costs_data = []
103105

104106
""" Source Data Model
@@ -123,6 +125,10 @@ class CostSummaryItem(BaseModel):
123125
region = result["region"] or "USE1"
124126
service_code = result["service_code"]
125127
usage_type = result["usage_type"]
128+
129+
if not include_credit and service_code == "Credit":
130+
continue
131+
126132
data = {
127133
"cost": result.get("usage_cost", 0.0) or 0.0,
128134
"usage_quantity": result["usage_quantity"],

0 commit comments

Comments
 (0)