88from .base import (
99 BasePermitApi ,
1010 SimpleHttpClient ,
11+ pagination_params ,
1112)
1213from .context import ApiContextLevel , ApiKeyAccessLevel
1314from .models import (
1415 ElementsUserInviteApprove ,
16+ ElementsUserInviteCreate ,
17+ ElementsUserInviteRead ,
18+ PaginatedResultElementsUserInviteRead ,
1519 UserRead ,
1620)
1721
@@ -23,6 +27,87 @@ def __user_invites(self) -> SimpleHttpClient:
2327 f"/v2/facts/{ self .config .api_context .project } /{ self .config .api_context .environment } /user_invites"
2428 )
2529
30+ @validate_arguments # type: ignore[operator]
31+ async def list (self , page : int = 1 , per_page : int = 100 ) -> PaginatedResultElementsUserInviteRead :
32+ """
33+ Retrieves a list of user invites.
34+
35+ Args:
36+ page: The page number to retrieve (default: 1).
37+ per_page: The number of invites per page (default: 100).
38+
39+ Returns:
40+ A paginated list of user invites.
41+
42+ Raises:
43+ PermitApiError: If the API returns an error HTTP status code.
44+ PermitContextError: If the configured ApiContext does not match the required endpoint context.
45+ """
46+ await self ._ensure_access_level (ApiKeyAccessLevel .ENVIRONMENT_LEVEL_API_KEY )
47+ await self ._ensure_context (ApiContextLevel .ENVIRONMENT )
48+ return await self .__user_invites .get (
49+ "" ,
50+ model = PaginatedResultElementsUserInviteRead ,
51+ params = pagination_params (page , per_page ),
52+ )
53+
54+ @validate_arguments # type: ignore[operator]
55+ async def get (self , user_invite_id : str ) -> ElementsUserInviteRead :
56+ """
57+ Retrieves a single user invite by ID.
58+
59+ Args:
60+ user_invite_id: The ID of the user invite to retrieve.
61+
62+ Returns:
63+ The user invite details.
64+
65+ Raises:
66+ PermitApiError: If the API returns an error HTTP status code.
67+ PermitContextError: If the configured ApiContext does not match the required endpoint context.
68+ """
69+ await self ._ensure_access_level (ApiKeyAccessLevel .ENVIRONMENT_LEVEL_API_KEY )
70+ await self ._ensure_context (ApiContextLevel .ENVIRONMENT )
71+ return await self .__user_invites .get (f"/{ user_invite_id } " , model = ElementsUserInviteRead )
72+
73+ @validate_arguments # type: ignore[operator]
74+ async def create (self , user_invite_data : ElementsUserInviteCreate ) -> ElementsUserInviteRead :
75+ """
76+ Creates a new user invite.
77+
78+ Args:
79+ user_invite_data: The user invite data to create.
80+
81+ Returns:
82+ The created user invite.
83+
84+ Raises:
85+ PermitApiError: If the API returns an error HTTP status code.
86+ PermitContextError: If the configured ApiContext does not match the required endpoint context.
87+ """
88+ await self ._ensure_access_level (ApiKeyAccessLevel .ENVIRONMENT_LEVEL_API_KEY )
89+ await self ._ensure_context (ApiContextLevel .ENVIRONMENT )
90+ return await self .__user_invites .post ("" , model = ElementsUserInviteRead , json = user_invite_data )
91+
92+ @validate_arguments # type: ignore[operator]
93+ async def delete (self , user_invite_id : str ) -> None :
94+ """
95+ Deletes a user invite.
96+
97+ Args:
98+ user_invite_id: The ID of the user invite to delete.
99+
100+ Returns:
101+ None
102+
103+ Raises:
104+ PermitApiError: If the API returns an error HTTP status code.
105+ PermitContextError: If the configured ApiContext does not match the required endpoint context.
106+ """
107+ await self ._ensure_access_level (ApiKeyAccessLevel .ENVIRONMENT_LEVEL_API_KEY )
108+ await self ._ensure_context (ApiContextLevel .ENVIRONMENT )
109+ await self .__user_invites .delete (f"/{ user_invite_id } " )
110+
26111 @validate_arguments # type: ignore[operator]
27112 async def approve (self , user_invite_id : str , approve_data : ElementsUserInviteApprove ) -> UserRead :
28113 """
0 commit comments