Skip to content

Commit

Permalink
remove redundant checks and methods in api helper class
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorency committed Sep 3, 2024
1 parent d871593 commit 32834c5
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions plugins/plugin_utils/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,9 @@ def __init__(self, hostname, session):
self.hostname = hostname
self.session = session

async def fetch(self, url):
async with self.session.get(url) as response:
result = await response.json()
return result

def build_url(self, object_type, filters):
corrected_filters_for_query = self.correct_filter_names(filters, object_type)
if object_type == "resource_pool":
object_type = object_type.replace("_", "-")
object_type = object_type.replace("_", "-")

return (f"https://{self.hostname}/api/vcenter/{object_type}") + gen_args(
corrected_filters_for_query, corrected_filters_for_query.keys()
Expand Down Expand Up @@ -86,8 +80,8 @@ def correct_filter_names(self, filters, object_type):

async def fetch_object_with_filters(self, object_type, filters):
_url = self.build_url(object_type, filters)
res = await self.fetch(_url)
return await self.fetch(_url)
async with self.session.get(_url) as response:
return await response.json()


class Lookup:
Expand Down

0 comments on commit 32834c5

Please sign in to comment.