Skip to content

Commit 2b3f9ca

Browse files
committed
feat: integration workspace support added
1 parent 3419dcd commit 2b3f9ca

4 files changed

Lines changed: 113 additions & 2 deletions

File tree

portkey_ai/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
AsyncContent,
126126
Integrations,
127127
AsyncIntegrations,
128+
IntegrationsWorkspaces,
129+
AsyncIntegrationsWorkspaces,
128130
)
129131

130132
from portkey_ai.version import VERSION
@@ -269,4 +271,6 @@
269271
"AsyncContent",
270272
"Integrations",
271273
"AsyncIntegrations",
274+
"IntegrationsWorkspaces",
275+
"AsyncIntegrationsWorkspaces",
272276
]

portkey_ai/api_resources/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@
113113
AsyncContent,
114114
Integrations,
115115
AsyncIntegrations,
116+
IntegrationsWorkspaces,
117+
AsyncIntegrationsWorkspaces,
116118
)
117119
from .utils import (
118120
Modes,
@@ -261,4 +263,6 @@
261263
"AsyncContent",
262264
"Integrations",
263265
"AsyncIntegrations",
266+
"IntegrationsWorkspaces",
267+
"AsyncIntegrationsWorkspaces",
264268
]

portkey_ai/api_resources/apis/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@
139139

140140
from .collections import Collections, AsyncCollections
141141

142-
from .integrations import Integrations, AsyncIntegrations
142+
from .integrations import (
143+
Integrations,
144+
AsyncIntegrations,
145+
IntegrationsWorkspaces,
146+
AsyncIntegrationsWorkspaces,
147+
)
143148

144149
sys.modules["openai"] = vendored_openai # For pydantic v1 and v2 compatibility
145150

@@ -267,4 +272,6 @@
267272
"AsyncContent",
268273
"Integrations",
269274
"AsyncIntegrations",
275+
"IntegrationsWorkspaces",
276+
"AsyncIntegrationsWorkspaces",
270277
]

portkey_ai/api_resources/apis/integrations.py

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, Optional
1+
from typing import Any, Dict, List, Optional
22
from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient
33
from urllib.parse import urlencode
44
from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource
@@ -9,6 +9,7 @@
99
class Integrations(APIResource):
1010
def __init__(self, client: APIClient) -> None:
1111
super().__init__(client)
12+
self.workspaces = IntegrationsWorkspaces(client)
1213

1314
def create(
1415
self,
@@ -126,9 +127,57 @@ def delete(
126127
)
127128

128129

130+
class IntegrationsWorkspaces(APIResource):
131+
def __init__(self, client: APIClient) -> None:
132+
super().__init__(client)
133+
134+
def list(
135+
self,
136+
*,
137+
provider_integration_id: Optional[str] = None,
138+
) -> GenericResponse:
139+
return self._get(
140+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/workspaces",
141+
params=None,
142+
body=None,
143+
cast_to=GenericResponse,
144+
stream=False,
145+
stream_cls=None,
146+
headers={},
147+
)
148+
149+
def update(
150+
self,
151+
*,
152+
provider_integration_id: Optional[str] = None,
153+
global_workspace_access: Optional[Dict[str, Any]] = None,
154+
workspace_ids: Optional[List[str]] = None,
155+
override_existing_workspaces_access: Optional[bool] = None,
156+
workspaces: Optional[List[Dict[str, Any]]] = None,
157+
**kwargs: Any,
158+
) -> GenericResponse:
159+
body = {
160+
"global_workspace_access": global_workspace_access,
161+
"workspace_ids": workspace_ids,
162+
"override_existing_workspaces_access": override_existing_workspaces_access,
163+
"workspaces": workspaces,
164+
**kwargs,
165+
}
166+
return self._put(
167+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/workspaces",
168+
body=body,
169+
params=None,
170+
cast_to=GenericResponse,
171+
stream=False,
172+
stream_cls=None,
173+
headers={},
174+
)
175+
176+
129177
class AsyncIntegrations(AsyncAPIResource):
130178
def __init__(self, client: AsyncAPIClient) -> None:
131179
super().__init__(client)
180+
self.workspaces = AsyncIntegrationsWorkspaces(client)
132181

133182
async def create(
134183
self,
@@ -244,3 +293,50 @@ async def delete(
244293
stream_cls=None,
245294
headers={},
246295
)
296+
297+
298+
class AsyncIntegrationsWorkspaces(AsyncAPIResource):
299+
def __init__(self, client: AsyncAPIClient) -> None:
300+
super().__init__(client)
301+
302+
async def list(
303+
self,
304+
*,
305+
provider_integration_id: Optional[str] = None,
306+
) -> GenericResponse:
307+
return await self._get(
308+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/workspaces",
309+
params=None,
310+
body=None,
311+
cast_to=GenericResponse,
312+
stream=False,
313+
stream_cls=None,
314+
headers={},
315+
)
316+
317+
async def update(
318+
self,
319+
*,
320+
provider_integration_id: Optional[str] = None,
321+
global_workspace_access: Optional[Dict[str, Any]] = None,
322+
workspace_ids: Optional[List[str]] = None,
323+
override_existing_workspaces_access: Optional[bool] = None,
324+
workspaces: Optional[List[Dict[str, Any]]] = None,
325+
**kwargs: Any,
326+
) -> GenericResponse:
327+
body = {
328+
"global_workspace_access": global_workspace_access,
329+
"workspace_ids": workspace_ids,
330+
"override_existing_workspaces_access": override_existing_workspaces_access,
331+
"workspaces": workspaces,
332+
**kwargs,
333+
}
334+
return await self._put(
335+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/workspaces",
336+
body=body,
337+
params=None,
338+
cast_to=GenericResponse,
339+
stream=False,
340+
stream_cls=None,
341+
headers={},
342+
)

0 commit comments

Comments
 (0)