Skip to content

Commit 1799732

Browse files
feat: Add project_id SDK client option mapped to X-Kernel-Project-Id
1 parent 5929332 commit 1799732

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 119
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-c6458d9c6cb5d7e3d8309c79b69eba3a22269e0ecc0bdafbaee00fde4b302e99.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-51549f813f3002e18c6ca8d850cc0c7932828d511c151e0412c73b6798d19e30.yml
33
openapi_spec_hash: ee77b293c4bda91c1a32cfdd12b8739e
4-
config_hash: 80eef1b592110714ea55cd26c470fabb
4+
config_hash: 57567e00b41af47cef1b78e51b747aa0

src/kernel/_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,16 @@ class Kernel(SyncAPIClient):
100100
api_key: str
101101
browser_route_cache: BrowserRouteCache
102102

103+
project_id: str | None
104+
103105
_environment: Literal["production", "development"] | NotGiven
104106
_browser_routing: BrowserRoutingConfig
105107

106108
def __init__(
107109
self,
108110
*,
109111
api_key: str | None = None,
112+
project_id: str | None = None,
110113
environment: Literal["production", "development"] | NotGiven = not_given,
111114
base_url: str | httpx.URL | None | NotGiven = not_given,
112115
timeout: float | Timeout | None | NotGiven = not_given,
@@ -140,6 +143,8 @@ def __init__(
140143
)
141144
self.api_key = api_key
142145

146+
self.project_id = project_id
147+
143148
self._environment = environment
144149

145150
base_url_env = os.environ.get("KERNEL_BASE_URL")
@@ -309,6 +314,7 @@ def default_headers(self) -> dict[str, str | Omit]:
309314
return {
310315
**super().default_headers,
311316
"X-Stainless-Async": "false",
317+
"X-Kernel-Project-Id": self.project_id if self.project_id is not None else Omit(),
312318
**self._custom_headers,
313319
}
314320

@@ -347,6 +353,7 @@ def copy(
347353
self,
348354
*,
349355
api_key: str | None = None,
356+
project_id: str | None = None,
350357
environment: Literal["production", "development"] | None = None,
351358
base_url: str | httpx.URL | None = None,
352359
timeout: float | Timeout | None | NotGiven = not_given,
@@ -383,6 +390,7 @@ def copy(
383390
http_client = http_client or self._client
384391
return self.__class__(
385392
api_key=api_key or self.api_key,
393+
project_id=project_id or self.project_id,
386394
base_url=base_url or self.base_url,
387395
environment=environment or self._environment,
388396
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
@@ -437,13 +445,16 @@ class AsyncKernel(AsyncAPIClient):
437445
api_key: str
438446
browser_route_cache: BrowserRouteCache
439447

448+
project_id: str | None
449+
440450
_environment: Literal["production", "development"] | NotGiven
441451
_browser_routing: BrowserRoutingConfig
442452

443453
def __init__(
444454
self,
445455
*,
446456
api_key: str | None = None,
457+
project_id: str | None = None,
447458
environment: Literal["production", "development"] | NotGiven = not_given,
448459
base_url: str | httpx.URL | None | NotGiven = not_given,
449460
timeout: float | Timeout | None | NotGiven = not_given,
@@ -477,6 +488,8 @@ def __init__(
477488
)
478489
self.api_key = api_key
479490

491+
self.project_id = project_id
492+
480493
self._environment = environment
481494

482495
base_url_env = os.environ.get("KERNEL_BASE_URL")
@@ -646,6 +659,7 @@ def default_headers(self) -> dict[str, str | Omit]:
646659
return {
647660
**super().default_headers,
648661
"X-Stainless-Async": f"async:{get_async_library()}",
662+
"X-Kernel-Project-Id": self.project_id if self.project_id is not None else Omit(),
649663
**self._custom_headers,
650664
}
651665

@@ -684,6 +698,7 @@ def copy(
684698
self,
685699
*,
686700
api_key: str | None = None,
701+
project_id: str | None = None,
687702
environment: Literal["production", "development"] | None = None,
688703
base_url: str | httpx.URL | None = None,
689704
timeout: float | Timeout | None | NotGiven = not_given,
@@ -720,6 +735,7 @@ def copy(
720735
http_client = http_client or self._client
721736
return self.__class__(
722737
api_key=api_key or self.api_key,
738+
project_id=project_id or self.project_id,
723739
base_url=base_url or self.base_url,
724740
environment=environment or self._environment,
725741
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,

0 commit comments

Comments
 (0)