Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RazcoDev committed Apr 11, 2024
1 parent 88f13ec commit c6748fa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
10 changes: 1 addition & 9 deletions permit/pdp_api/base.py
Original file line number Diff line number Diff line change
@@ -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}

Expand All @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions permit/pdp_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from typing import Optional
from typing import Optional

from ..utils.pydantic_version import PYDANTIC_VERSION

Expand All @@ -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",
)

10 changes: 2 additions & 8 deletions permit/pdp_api/role_assignments.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions permit/permit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})),
Expand Down Expand Up @@ -77,7 +77,6 @@ def pdp_api(self) -> PermitPdpApiClient:
"""
return self._pdp_api


async def bulk_check(
self,
checks: list[CheckQuery],
Expand Down

0 comments on commit c6748fa

Please sign in to comment.