diff --git a/permit/pdp_api/base.py b/permit/pdp_api/base.py index 6cfe529..5f28ba9 100644 --- a/permit/pdp_api/base.py +++ b/permit/pdp_api/base.py @@ -1,25 +1,19 @@ from typing import Callable, TypeVar -from permit import PermitConfig, PYDANTIC_VERSION - +from permit import PYDANTIC_VERSION, PermitConfig from permit.api.base import SimpleHttpClient - if PYDANTIC_VERSION < (2, 0): from pydantic import BaseModel, Extra, Field, parse_obj_as else: from pydantic.v1 import BaseModel, Extra, Field, parse_obj_as # type: ignore - - T = TypeVar("T", bound=Callable) TModel = TypeVar("TModel", bound=BaseModel) TData = TypeVar("TData", bound=BaseModel) - - def pagination_params(page: int, per_page: int) -> dict: return {"page": page, "per_page": per_page} @@ -35,8 +29,6 @@ class Config: headers: dict = Field(..., description="http headers sent to the API server") - - class BasePdpPermitApi: """ The base class for Permit APIs. diff --git a/permit/pdp_api/models.py b/permit/pdp_api/models.py index 1674236..fc4e737 100644 --- a/permit/pdp_api/models.py +++ b/permit/pdp_api/models.py @@ -4,7 +4,7 @@ from __future__ import annotations -from typing import Optional +from typing import Optional from ..utils.pydantic_version import PYDANTIC_VERSION @@ -14,16 +14,14 @@ from pydantic.v1 import BaseModel, Field # type: ignore - class RoleAssignment(BaseModel): - user: str = Field(..., description='the user the role is assigned to', title='User') - role: str = Field(..., description='the role that is assigned', title='Role') + user: str = Field(..., description="the user the role is assigned to", title="User") + role: str = Field(..., description="the role that is assigned", title="Role") tenant: str = Field( - ..., description='the tenant the role is associated with', title='Tenant' + ..., description="the tenant the role is associated with", title="Tenant" ) resource_instance: Optional[str] = Field( None, - description='the resource instance the role is associated with', - title='Resource Instance', + description="the resource instance the role is associated with", + title="Resource Instance", ) - diff --git a/permit/pdp_api/role_assignments.py b/permit/pdp_api/role_assignments.py index e1584fb..7519287 100644 --- a/permit/pdp_api/role_assignments.py +++ b/permit/pdp_api/role_assignments.py @@ -1,8 +1,7 @@ from typing import List, Optional -from permit.api.base import SimpleHttpClient - from permit import PYDANTIC_VERSION +from permit.api.base import SimpleHttpClient from permit.pdp_api.base import BasePdpPermitApi, pagination_params from permit.pdp_api.models import RoleAssignment @@ -12,15 +11,10 @@ from pydantic.v1 import validate_arguments # type: ignore - - class RoleAssignmentsApi(BasePdpPermitApi): @property def __role_assignments(self) -> SimpleHttpClient: - return self._build_http_client( - "/local/role_assignments" - ) - + return self._build_http_client("/local/role_assignments") @validate_arguments async def list( diff --git a/permit/permit.py b/permit/permit.py index 86c5eab..0a1c0a6 100644 --- a/permit/permit.py +++ b/permit/permit.py @@ -22,7 +22,7 @@ def __init__(self, config: Optional[PermitConfig] = None, **options): self._enforcer = Enforcer(self._config) self._api = PermitApiClient(self._config) self._elements = ElementsApi(self._config) - self. _pdp_api = PermitPdpApiClient(self._config) + self._pdp_api = PermitPdpApiClient(self._config) logger.debug( "Permit SDK initialized with config:\n${}", json.dumps(self._config.dict(exclude={"api_context"})), @@ -77,7 +77,6 @@ def pdp_api(self) -> PermitPdpApiClient: """ return self._pdp_api - async def bulk_check( self, checks: list[CheckQuery],