Skip to content

Commit

Permalink
chore: 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 Aug 23, 2024
1 parent b86c869 commit 847d470
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions plugins/module_utils/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,29 @@ def get_name_field_from_endpoint(endpoint: str) -> str:
def get_endpoint(self, endpoint: str, **kwargs: Any) -> Response:
return self.client.get(endpoint, **kwargs)

def post_endpoint(self, endpoint: str, **kwargs: Any) -> Union[dict[str, bool], Response]:
def post_endpoint(
self, endpoint: str, **kwargs: Any
) -> Union[dict[str, bool], Response]:
# Handle check mode
if self.module.check_mode:
self.result["changed"] = True
return self.result

return self.client.post(endpoint, **kwargs)

def patch_endpoint(self, endpoint: str, **kwargs: Any) -> Union[dict[str, bool], Response]:
def patch_endpoint(
self, endpoint: str, **kwargs: Any
) -> Union[dict[str, bool], Response]:
# Handle check mode
if self.module.check_mode:
self.result["changed"] = True
return self.result

return self.client.patch(endpoint, **kwargs)

def delete_endpoint(self, endpoint: str, **kwargs: Any) -> Union[dict[str, bool], Response]:
def delete_endpoint(
self, endpoint: str, **kwargs: Any
) -> Union[dict[str, bool], Response]:
# Handle check mode
if self.module.check_mode:
self.result["changed"] = True
Expand All @@ -75,7 +81,9 @@ def get_item_name(self, item: Any) -> Any:
msg = "Cant determine identity field for Undefined object."
raise EDAError(msg)

def fail_wanted_one(self, response: list[Any], endpoint: str, query_params: Any) -> NoReturn:
def fail_wanted_one(
self, response: list[Any], endpoint: str, query_params: Any
) -> NoReturn:
url = self.client.build_url(endpoint, query_params)
host_length = len(self.client.host)
display_endpoint = url.geturl()[
Expand All @@ -86,7 +94,9 @@ def fail_wanted_one(self, response: list[Any], endpoint: str, query_params: Any)
)
raise EDAError(msg)

def get_exactly_one(self, endpoint:str, name: Optional[str]=None, **kwargs: Any) -> dict[str, Any]:
def get_exactly_one(
self, endpoint: str, name: Optional[str] = None, **kwargs: Any
) -> dict[str, Any]:
new_kwargs = kwargs.copy()

result = self.get_one_or_many(endpoint, name=name, **kwargs)
Expand Down Expand Up @@ -250,7 +260,13 @@ def fields_could_be_same(old_field: Any, new_field: Any) -> bool:
return True
return bool(new_field == old_field)

def objects_could_be_different(self, old: dict[str, Any], new: dict[str, Any], field_set:Optional[set]=None, warning:bool=False) -> bool:
def objects_could_be_different(
self,
old: dict[str, Any],
new: dict[str, Any],
field_set: Optional[set] = None,
warning: bool = False,
) -> bool:
if field_set is None:
field_set = set(fd for fd in new.keys())
for field in field_set:
Expand Down

0 comments on commit 847d470

Please sign in to comment.