-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the policy es_model helps to unique policy data
- Loading branch information
Showing
11 changed files
with
116 additions
and
61 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
Empty file.
49 changes: 49 additions & 0 deletions
49
cloud_governance/common/elasticsearch/modals/policy_es_data.py
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,49 @@ | ||
import datetime | ||
from dataclasses import dataclass, asdict | ||
|
||
from cloud_governance.common.utils.utils import Utils | ||
|
||
|
||
@dataclass | ||
class PolicyEsData(dict): | ||
|
||
account: str | ||
resource_id: str | ||
user: str | ||
dry_run: str | ||
name: str | ||
region_name: str | ||
public_cloud: str | ||
action_days: str | ||
skip_policy: str | ||
cost: float = '' | ||
savings: float = '' | ||
resource_type: str = '' | ||
resource_state: str = '' | ||
days_count: int = '' | ||
resource_action: str = '' | ||
IndexId: str = '' | ||
SnapshotDate: str = datetime.datetime.utcnow().date().__str__() | ||
|
||
# Specific Policy Attributes | ||
volume_size: int = '' | ||
instance_type: str = '' | ||
launch_time: str = '' | ||
running_days: int = '' | ||
|
||
def __post_init__(self): | ||
""" | ||
This method initialize the IndexId | ||
:return: | ||
:rtype: | ||
""" | ||
self.IndexId = (f'{self.SnapshotDate}-{self.public_cloud}-{self.account}-{self.region_name}-{self.resource_id}-' | ||
f'{self.resource_state}').lower() | ||
|
||
def get_as_dict_title_case(self): | ||
""" | ||
This method returns the dict object | ||
:return: | ||
:rtype: | ||
""" | ||
return {Utils.convert_to_title_case(k): v for k, v in asdict(self).items() if v != ''} |
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
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.