Skip to content

Commit 59fdd82

Browse files
committed
feat: changes in configs
1 parent c015dda commit 59fdd82

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

portkey_ai/api_resources/apis/configs.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Dict, Optional
1+
from typing import Any, Dict, Optional, Union
2+
from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven
23
from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient
34
from urllib.parse import urlencode
45
from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource
@@ -19,10 +20,10 @@ def __init__(self, client: APIClient) -> None:
1920
def create(
2021
self,
2122
*,
22-
name: Optional[str] = None,
23-
config: Optional[Dict[str, Any]] = None,
24-
is_default: Optional[int] = None,
25-
workspace_id: Optional[str] = None,
23+
name: Union[str, NotGiven] = NOT_GIVEN,
24+
config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN,
25+
is_default: Union[int, NotGiven] = NOT_GIVEN,
26+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
2627
) -> ConfigAddResponse:
2728
body = {
2829
"name": name,
@@ -54,12 +55,12 @@ def retrieve(self, *, slug: Optional[str]) -> ConfigGetResponse:
5455
def list(
5556
self,
5657
*,
57-
workspace_id: Optional[str] = None,
58+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
5859
) -> ConfigListResponse:
5960
query = {
6061
"workspace_id": workspace_id,
6162
}
62-
filtered_query = {k: v for k, v in query.items() if v is not None}
63+
filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN}
6364
query_string = urlencode(filtered_query)
6465
return self._get(
6566
f"{PortkeyApiPaths.CONFIG_API}?{query_string}",
@@ -74,10 +75,10 @@ def list(
7475
def update(
7576
self,
7677
*,
77-
slug: Optional[str] = None,
78-
name: Optional[str] = None,
79-
config: Optional[Dict[str, Any]] = None,
80-
status: Optional[str] = None,
78+
slug: Union[str, NotGiven] = NOT_GIVEN,
79+
name: Union[str, NotGiven] = NOT_GIVEN,
80+
config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN,
81+
status: Union[str, NotGiven] = NOT_GIVEN,
8182
) -> ConfigUpdateResponse:
8283
body = {
8384
"slug": slug,
@@ -95,7 +96,12 @@ def update(
9596
headers={},
9697
)
9798

98-
def delete(self, *, id: Optional[str] = None, slug: Optional[str] = None) -> Any:
99+
def delete(
100+
self,
101+
*,
102+
id: Union[str, NotGiven] = NOT_GIVEN,
103+
slug: Union[str, NotGiven] = NOT_GIVEN,
104+
) -> Any:
99105
config_slug = None
100106
if id:
101107
import warnings
@@ -128,10 +134,10 @@ def __init__(self, client: AsyncAPIClient) -> None:
128134
async def create(
129135
self,
130136
*,
131-
name: Optional[str] = None,
132-
config: Optional[Dict[str, Any]] = None,
133-
is_default: Optional[int] = None,
134-
workspace_id: Optional[str] = None,
137+
name: Union[str, NotGiven] = NOT_GIVEN,
138+
config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN,
139+
is_default: Union[int, NotGiven] = NOT_GIVEN,
140+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
135141
) -> ConfigAddResponse:
136142
body = {
137143
"name": name,
@@ -163,12 +169,12 @@ async def retrieve(self, *, slug: Optional[str]) -> ConfigGetResponse:
163169
async def list(
164170
self,
165171
*,
166-
workspace_id: Optional[str] = None,
172+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
167173
) -> ConfigListResponse:
168174
query = {
169175
"workspace_id": workspace_id,
170176
}
171-
filtered_query = {k: v for k, v in query.items() if v is not None}
177+
filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN}
172178
query_string = urlencode(filtered_query)
173179
return await self._get(
174180
f"{PortkeyApiPaths.CONFIG_API}?{query_string}",
@@ -183,10 +189,10 @@ async def list(
183189
async def update(
184190
self,
185191
*,
186-
slug: Optional[str] = None,
187-
name: Optional[str] = None,
188-
config: Optional[Dict[str, Any]] = None,
189-
status: Optional[str] = None,
192+
slug: Union[str, NotGiven] = NOT_GIVEN,
193+
name: Union[str, NotGiven] = NOT_GIVEN,
194+
config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN,
195+
status: Union[str, NotGiven] = NOT_GIVEN,
190196
) -> ConfigUpdateResponse:
191197
body = {
192198
"slug": slug,
@@ -207,8 +213,8 @@ async def update(
207213
async def delete(
208214
self,
209215
*,
210-
id: Optional[str] = None,
211-
slug: Optional[str] = None,
216+
id: Union[str, NotGiven] = NOT_GIVEN,
217+
slug: Union[str, NotGiven] = NOT_GIVEN,
212218
) -> Any:
213219
config_slug = None
214220
if id:

0 commit comments

Comments
 (0)