Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 14, 2023
1 parent cb9dbea commit bfafd67
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions wrapanapi/systems/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,12 @@ def cleanup(self):
"""
return self.delete()

class Resource():

class Resource:
"""
This class represents a resource returned by Resource Explorer.
"""

def __init__(self, arn, region, resource_type, service, properties=[]):
self.arn = arn
self.region = region
Expand All @@ -505,7 +507,7 @@ def get_tag_value(self, key) -> str | None:
if len(tags) > 0:
return tags[0].get("Value")
return None

def get_tags(self, regex="") -> typing.List[dict]:
"""
Returns a list of tags (a dict with keys 'Key' and 'Value').
Expand All @@ -522,14 +524,14 @@ def get_tags(self, regex="") -> typing.List[dict]:
if re.match(regex, key):
list.append(tag)
return list

def get_id(self) -> str:
"""
Returns the last part part of the arn.
This is part is used as id in aws cli.
"""
return self.arn.split(":")[-1]

def get_name(self) -> str:
"""
Returns a name for the resource derived from the associated tag with key 'Name'.
Expand All @@ -540,6 +542,7 @@ def get_name(self) -> str:
name = self.get_id()
return name


class EC2System(System, VmMixin, TemplateMixin, StackMixin, NetworkMixin):
"""EC2 Management System, powered by boto
Expand Down Expand Up @@ -1817,9 +1820,7 @@ def list_resources(self, query="", view="") -> typing.List[Resource]:
Examples:
Use query "tag.key:kubernetes.io/cluster/*" to list OCP resources
"""
args = {
"QueryString":query
}
args = {"QueryString": query}
if view:
args["ViewArn"] = view
list = []
Expand All @@ -1833,7 +1834,7 @@ def list_resources(self, query="", view="") -> typing.List[Resource]:
region=r.get("Region"),
service=r.get("Service"),
properties=r.get("Properties"),
resource_type=r.get("ResourceType")
resource_type=r.get("ResourceType"),
)
list.append(resource)
return list

0 comments on commit bfafd67

Please sign in to comment.