Skip to content

Commit

Permalink
fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
omer9564 committed Oct 27, 2024
1 parent 5ac58b1 commit 666b0da
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
12 changes: 7 additions & 5 deletions horizon/data_manager/policy_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ async def list_facts_by_type(
per_page: int = 30,
filters: dict[str, Any] | None = None,
) -> aiohttp.ClientResponse:
logger.info("Performing list facts for '{fact_type}' fact type from the External Data Manager",
fact_type=fact_type)
logger.info(
"Performing list facts for '{fact_type}' fact type from the External Data Manager",
fact_type=fact_type,
)
query_params = {
"page": page,
"per_page": per_page,
} | (filters or {})
"page": page,
"per_page": per_page,
} | (filters or {})
res = await self.client.get(
f"/v1/facts/{fact_type}",
params=query_params,
Expand Down
16 changes: 9 additions & 7 deletions horizon/local/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
RoleAssignment,
ListRoleAssignmentsFilters,
ListRoleAssignmentsPDPBody,
WrappedResponse, ListRoleAssignmentsPagination,
WrappedResponse,
ListRoleAssignmentsPagination,
)


Expand Down Expand Up @@ -92,27 +93,27 @@ async def list_role_assignments(
user: Optional[str] = Query(
None,
description="optional user filter, "
"will only return role assignments granted to this user.",
"will only return role assignments granted to this user.",
),
role: Optional[str] = Query(
None,
description="optional role filter, "
"will only return role assignments granting this role.",
"will only return role assignments granting this role.",
),
tenant: Optional[str] = Query(
None,
description="optional tenant filter, "
"will only return role assignments granted in that tenant.",
"will only return role assignments granted in that tenant.",
),
resource: Optional[str] = Query(
None,
description="optional resource **type** filter, "
"will only return role assignments granted on that resource type.",
"will only return role assignments granted on that resource type.",
),
resource_instance: Optional[str] = Query(
None,
description="optional resource instance filter, "
"will only return role assignments granted on that resource instance.",
"will only return role assignments granted on that resource instance.",
),
page: int = Query(
default=1,
Expand Down Expand Up @@ -164,12 +165,13 @@ async def legacy_list_role_assignments() -> list[RoleAssignment]:
if not isinstance(policy_store, DataManagerPolicyStoreClient):
logger.warning(
"External Data Manager is enabled by policy store is not set to {store_type}",
store_type=DataManagerPolicyStoreClient.__name__
store_type=DataManagerPolicyStoreClient.__name__,
)
return await legacy_list_role_assignments()
else:
res = await policy_store.list_facts_by_type("role_assignments")
return parse_obj_as(list[RoleAssignment], await res.json())
else:
return await legacy_list_role_assignments()

return router
10 changes: 6 additions & 4 deletions horizon/tests/test_local_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ def __init__(self, opal: OpalClient | None = None):

class MockDataManagerPermitPDP(MockPermitPDP):
def __init__(self):
super().__init__(opal=DataManagerClient(
shard_id=sidecar_config.SHARD_ID, data_topics=self._fix_data_topics()
))
super().__init__(
opal=DataManagerClient(
shard_id=sidecar_config.SHARD_ID, data_topics=self._fix_data_topics()
)
)


sidecar = MockPermitPDP()
Expand Down Expand Up @@ -145,7 +147,7 @@ async def test_list_role_assignments_external_data_store() -> None:
"tenant": "tenant1",
"resource_instance": "resource_instance1",
}
]
],
)

response = _client.get(
Expand Down

0 comments on commit 666b0da

Please sign in to comment.