Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing parameters for API #57

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions permit/api/resource_instances.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional

from ..utils.pydantic_version import PYDANTIC_VERSION

Expand Down Expand Up @@ -32,7 +32,13 @@ def __resource_instances(self) -> SimpleHttpClient:
@required_context(ApiContextLevel.ENVIRONMENT)
@validate_arguments
async def list(
self, page: int = 1, per_page: int = 100
self,
page: int = 1,
per_page: int = 100,
tenant_key: Optional[str] = None,
resource_key: Optional[str] = None,
detailed_key: Optional[bool] = None,
search_key: Optional[str] = None,
) -> List[ResourceInstanceRead]:
"""
Retrieves a list of resource instances.
Expand All @@ -48,10 +54,20 @@ async def list(
PermitApiError: If the API returns an error HTTP status code.
PermitContextError: If the configured ApiContext does not match the required endpoint context.
"""
params = pagination_params(page, per_page)
if tenant_key is not None:
params.update(dict(tenant=tenant_key))
if resource_key is not None:
params.update(dict(resource=resource_key))
if detailed_key is not None:
params.update(dict(detailed=detailed_key))
if search_key is not None:
params.update(dict(search=search_key))

return await self.__resource_instances.get(
"",
model=List[ResourceInstanceRead],
params=pagination_params(page, per_page),
params=params,
)

async def _get(self, instance_key: str) -> ResourceInstanceRead:
Expand Down
Loading