Skip to content

Commit

Permalink
Merge pull request #66 from ImMin5/master
Browse files Browse the repository at this point in the history
Modify metadata info for cost and data
  • Loading branch information
ImMin5 authored Jul 1, 2024
2 parents dddeddc + c947029 commit 5d06e70
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/cloudforet/cost_analysis/manager/data_source_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@ def init_response(options):
plugin_metadata.currency = currency

if options.get("pay_as_you_go"):
plugin_metadata.alias.update({"cost": "PayAsYouGo"})
plugin_metadata.cost_info = {
"name": "PayAsYouGo",
"unit": options.get("currency", "KRW"),
}
elif options.get("cost_metric") == "AmortizedCost":
plugin_metadata.alias.update({"cost": "Amortized Cost"})
plugin_metadata.cost_info = {
"name": "Amortized Cost",
"unit": options.get("currency", "KRW"),
}
else:
plugin_metadata.alias.update({"cost": "Actual Cost"})
plugin_metadata.cost_info = {
"name": "Actual Cost",
"unit": options.get("currency", "KRW"),
}
plugin_metadata.data_info["PayAsYouGo"] = {
"name": "PayAsYouGo",
"unit": options.get("currency", "KRW"),
}

if options.get("use_account_routing"):
plugin_metadata.use_account_routing = True
Expand Down
7 changes: 7 additions & 0 deletions src/cloudforet/cost_analysis/model/data_source_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class DataSourceRule(Model):
tags = DictType(StringType, default={})


class MetadataDataInfo(Model):
name = StringType(required=True)
unit = StringType(required=True)


class PluginMetadata(Model):
data_source_rules = ListType(
ModelType(DataSourceRule), default=_DEFAULT_DATA_SOURCE_RULES
Expand All @@ -64,3 +69,5 @@ class PluginMetadata(Model):
alias = DictType(StringType, default={})
account_match_key = StringType(default=None)
exclude_license_cost = BooleanType(default=False)
cost_info = DictType(StringType, default={})
data_info = DictType(ModelType(MetadataDataInfo), default={})

0 comments on commit 5d06e70

Please sign in to comment.