diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6538ca91..2b28d6ec 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.8.0" + ".": "0.8.1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a0553b1e..38d124b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 21 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-a5b1d2c806c42c1534eefc8d34516f7f6e4ab68cb6a836534ee549bdbe4653f3.yml -openapi_spec_hash: 0be350cc8ddbd1fc7e058ce6c3a44ee8 -config_hash: 307153ecd5b85f77ce8e0d87f6e5dfab +configured_endpoints: 19 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-84945582139b11633f792c1052a33e6af9cafc96bbafc2902a905312d14c4cc1.yml +openapi_spec_hash: c77be216626b789a543529a6de56faed +config_hash: 65328ff206b8c0168c915914506d9dba diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee1358d..eed35acc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.8.1 (2025-07-21) + +Full Changelog: [v0.8.0...v0.8.1](https://github.com/onkernel/kernel-python-sdk/compare/v0.8.0...v0.8.1) + +### Chores + +* **api:** remove deprecated endpoints ([348e40a](https://github.com/onkernel/kernel-python-sdk/commit/348e40a5f610769a5ec59d4f4e40b79d166cdf57)) + ## 0.8.0 (2025-07-16) Full Changelog: [v0.7.1...v0.8.0](https://github.com/onkernel/kernel-python-sdk/compare/v0.7.1...v0.8.0) diff --git a/README.md b/README.md index 5041da06..884d10c2 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,10 @@ client = Kernel( environment="development", ) -deployment = client.apps.deployments.create( - entrypoint_rel_path="main.ts", - file=b"REPLACE_ME", - env_vars={"OPENAI_API_KEY": "x"}, - version="1.0.0", +browser = client.browsers.create( + persistence={"id": "browser-for-user-1234"}, ) -print(deployment.apps) +print(browser.session_id) ``` While you can provide an `api_key` keyword argument, @@ -65,13 +62,10 @@ client = AsyncKernel( async def main() -> None: - deployment = await client.apps.deployments.create( - entrypoint_rel_path="main.ts", - file=b"REPLACE_ME", - env_vars={"OPENAI_API_KEY": "x"}, - version="1.0.0", + browser = await client.browsers.create( + persistence={"id": "browser-for-user-1234"}, ) - print(deployment.apps) + print(browser.session_id) asyncio.run(main()) @@ -103,13 +97,10 @@ async def main() -> None: api_key="My API Key", http_client=DefaultAioHttpClient(), ) as client: - deployment = await client.apps.deployments.create( - entrypoint_rel_path="main.ts", - file=b"REPLACE_ME", - env_vars={"OPENAI_API_KEY": "x"}, - version="1.0.0", + browser = await client.browsers.create( + persistence={"id": "browser-for-user-1234"}, ) - print(deployment.apps) + print(browser.session_id) asyncio.run(main()) @@ -149,7 +140,7 @@ from kernel import Kernel client = Kernel() -client.apps.deployments.create( +client.deployments.create( entrypoint_rel_path="src/app.py", file=Path("/path/to/file"), ) @@ -174,7 +165,6 @@ client = Kernel() try: client.browsers.create( - invocation_id="REPLACE_ME", persistence={"id": "browser-for-user-1234"}, ) except kernel.APIConnectionError as e: @@ -220,7 +210,6 @@ client = Kernel( # Or, configure per-request: client.with_options(max_retries=5).browsers.create( - invocation_id="REPLACE_ME", persistence={"id": "browser-for-user-1234"}, ) ``` @@ -246,7 +235,6 @@ client = Kernel( # Override per-request: client.with_options(timeout=5.0).browsers.create( - invocation_id="REPLACE_ME", persistence={"id": "browser-for-user-1234"}, ) ``` @@ -290,7 +278,6 @@ from kernel import Kernel client = Kernel() response = client.browsers.with_raw_response.create( - invocation_id="REPLACE_ME", persistence={ "id": "browser-for-user-1234" }, @@ -313,7 +300,6 @@ To stream the response body, use `.with_streaming_response` instead, which requi ```python with client.browsers.with_streaming_response.create( - invocation_id="REPLACE_ME", persistence={"id": "browser-for-user-1234"}, ) as response: print(response.headers.get("X-My-Header")) diff --git a/api.md b/api.md index 58ceeacc..434ace20 100644 --- a/api.md +++ b/api.md @@ -35,20 +35,7 @@ from kernel.types import AppListResponse Methods: -- client.apps.list(\*\*params) -> AppListResponse - -## Deployments - -Types: - -```python -from kernel.types.apps import DeploymentCreateResponse, DeploymentFollowResponse -``` - -Methods: - -- client.apps.deployments.create(\*\*params) -> DeploymentCreateResponse -- client.apps.deployments.follow(id) -> DeploymentFollowResponse +- client.apps.list(\*\*params) -> AppListResponse # Invocations diff --git a/pyproject.toml b/pyproject.toml index 0eb2b247..83d7c720 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "kernel" -version = "0.8.0" +version = "0.8.1" description = "The official Python library for the kernel API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/kernel/_client.py b/src/kernel/_client.py index 00510763..a0b9ec29 100644 --- a/src/kernel/_client.py +++ b/src/kernel/_client.py @@ -21,7 +21,7 @@ ) from ._utils import is_given, get_async_library from ._version import __version__ -from .resources import deployments, invocations +from .resources import apps, deployments, invocations from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import KernelError, APIStatusError from ._base_client import ( @@ -29,7 +29,6 @@ SyncAPIClient, AsyncAPIClient, ) -from .resources.apps import apps from .resources.browsers import browsers __all__ = [ diff --git a/src/kernel/_version.py b/src/kernel/_version.py index 73e122d0..8e3e5204 100644 --- a/src/kernel/_version.py +++ b/src/kernel/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "kernel" -__version__ = "0.8.0" # x-release-please-version +__version__ = "0.8.1" # x-release-please-version diff --git a/src/kernel/resources/apps/apps.py b/src/kernel/resources/apps.py similarity index 79% rename from src/kernel/resources/apps/apps.py rename to src/kernel/resources/apps.py index 726db204..652235e2 100644 --- a/src/kernel/resources/apps/apps.py +++ b/src/kernel/resources/apps.py @@ -4,36 +4,24 @@ import httpx -from ...types import app_list_params -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import maybe_transform, async_maybe_transform -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( +from ..types import app_list_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from .deployments import ( - DeploymentsResource, - AsyncDeploymentsResource, - DeploymentsResourceWithRawResponse, - AsyncDeploymentsResourceWithRawResponse, - DeploymentsResourceWithStreamingResponse, - AsyncDeploymentsResourceWithStreamingResponse, -) -from ..._base_client import make_request_options -from ...types.app_list_response import AppListResponse +from .._base_client import make_request_options +from ..types.app_list_response import AppListResponse __all__ = ["AppsResource", "AsyncAppsResource"] class AppsResource(SyncAPIResource): - @cached_property - def deployments(self) -> DeploymentsResource: - return DeploymentsResource(self._client) - @cached_property def with_raw_response(self) -> AppsResourceWithRawResponse: """ @@ -102,10 +90,6 @@ def list( class AsyncAppsResource(AsyncAPIResource): - @cached_property - def deployments(self) -> AsyncDeploymentsResource: - return AsyncDeploymentsResource(self._client) - @cached_property def with_raw_response(self) -> AsyncAppsResourceWithRawResponse: """ @@ -181,10 +165,6 @@ def __init__(self, apps: AppsResource) -> None: apps.list, ) - @cached_property - def deployments(self) -> DeploymentsResourceWithRawResponse: - return DeploymentsResourceWithRawResponse(self._apps.deployments) - class AsyncAppsResourceWithRawResponse: def __init__(self, apps: AsyncAppsResource) -> None: @@ -194,10 +174,6 @@ def __init__(self, apps: AsyncAppsResource) -> None: apps.list, ) - @cached_property - def deployments(self) -> AsyncDeploymentsResourceWithRawResponse: - return AsyncDeploymentsResourceWithRawResponse(self._apps.deployments) - class AppsResourceWithStreamingResponse: def __init__(self, apps: AppsResource) -> None: @@ -207,10 +183,6 @@ def __init__(self, apps: AppsResource) -> None: apps.list, ) - @cached_property - def deployments(self) -> DeploymentsResourceWithStreamingResponse: - return DeploymentsResourceWithStreamingResponse(self._apps.deployments) - class AsyncAppsResourceWithStreamingResponse: def __init__(self, apps: AsyncAppsResource) -> None: @@ -219,7 +191,3 @@ def __init__(self, apps: AsyncAppsResource) -> None: self.list = async_to_streamed_response_wrapper( apps.list, ) - - @cached_property - def deployments(self) -> AsyncDeploymentsResourceWithStreamingResponse: - return AsyncDeploymentsResourceWithStreamingResponse(self._apps.deployments) diff --git a/src/kernel/resources/apps/__init__.py b/src/kernel/resources/apps/__init__.py deleted file mode 100644 index 6ce731d2..00000000 --- a/src/kernel/resources/apps/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .apps import ( - AppsResource, - AsyncAppsResource, - AppsResourceWithRawResponse, - AsyncAppsResourceWithRawResponse, - AppsResourceWithStreamingResponse, - AsyncAppsResourceWithStreamingResponse, -) -from .deployments import ( - DeploymentsResource, - AsyncDeploymentsResource, - DeploymentsResourceWithRawResponse, - AsyncDeploymentsResourceWithRawResponse, - DeploymentsResourceWithStreamingResponse, - AsyncDeploymentsResourceWithStreamingResponse, -) - -__all__ = [ - "DeploymentsResource", - "AsyncDeploymentsResource", - "DeploymentsResourceWithRawResponse", - "AsyncDeploymentsResourceWithRawResponse", - "DeploymentsResourceWithStreamingResponse", - "AsyncDeploymentsResourceWithStreamingResponse", - "AppsResource", - "AsyncAppsResource", - "AppsResourceWithRawResponse", - "AsyncAppsResourceWithRawResponse", - "AppsResourceWithStreamingResponse", - "AsyncAppsResourceWithStreamingResponse", -] diff --git a/src/kernel/resources/apps/deployments.py b/src/kernel/resources/apps/deployments.py deleted file mode 100644 index 98d1728c..00000000 --- a/src/kernel/resources/apps/deployments.py +++ /dev/null @@ -1,328 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Any, Dict, Mapping, cast -from typing_extensions import Literal - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes -from ..._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._streaming import Stream, AsyncStream -from ...types.apps import deployment_create_params -from ..._base_client import make_request_options -from ...types.apps.deployment_create_response import DeploymentCreateResponse -from ...types.apps.deployment_follow_response import DeploymentFollowResponse - -__all__ = ["DeploymentsResource", "AsyncDeploymentsResource"] - - -class DeploymentsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> DeploymentsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers - """ - return DeploymentsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> DeploymentsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response - """ - return DeploymentsResourceWithStreamingResponse(self) - - def create( - self, - *, - entrypoint_rel_path: str, - file: FileTypes, - env_vars: Dict[str, str] | NotGiven = NOT_GIVEN, - force: bool | NotGiven = NOT_GIVEN, - region: Literal["aws.us-east-1a"] | NotGiven = NOT_GIVEN, - version: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DeploymentCreateResponse: - """ - Deploy a new application and associated actions to Kernel. - - Args: - entrypoint_rel_path: Relative path to the entrypoint of the application - - file: ZIP file containing the application source directory - - env_vars: Map of environment variables to set for the deployed application. Each key-value - pair represents an environment variable. - - force: Allow overwriting an existing app version - - region: Region for deployment. Currently we only support "aws.us-east-1a" - - version: Version of the application. Can be any string. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - body = deepcopy_minimal( - { - "entrypoint_rel_path": entrypoint_rel_path, - "file": file, - "env_vars": env_vars, - "force": force, - "region": region, - "version": version, - } - ) - files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) - # It should be noted that the actual Content-Type header that will be - # sent to the server will contain a `boundary` parameter, e.g. - # multipart/form-data; boundary=---abc-- - extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( - "/deploy", - body=maybe_transform(body, deployment_create_params.DeploymentCreateParams), - files=files, - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=DeploymentCreateResponse, - ) - - def follow( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Stream[DeploymentFollowResponse]: - """ - Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and - status updates for a deployed application. The stream terminates automatically - once the application reaches a terminal state. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})} - return self._get( - f"/apps/{id}/events", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, DeploymentFollowResponse - ), # Union types cannot be passed in as arguments in the type system - stream=True, - stream_cls=Stream[DeploymentFollowResponse], - ) - - -class AsyncDeploymentsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncDeploymentsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/onkernel/kernel-python-sdk#accessing-raw-response-data-eg-headers - """ - return AsyncDeploymentsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncDeploymentsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/onkernel/kernel-python-sdk#with_streaming_response - """ - return AsyncDeploymentsResourceWithStreamingResponse(self) - - async def create( - self, - *, - entrypoint_rel_path: str, - file: FileTypes, - env_vars: Dict[str, str] | NotGiven = NOT_GIVEN, - force: bool | NotGiven = NOT_GIVEN, - region: Literal["aws.us-east-1a"] | NotGiven = NOT_GIVEN, - version: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DeploymentCreateResponse: - """ - Deploy a new application and associated actions to Kernel. - - Args: - entrypoint_rel_path: Relative path to the entrypoint of the application - - file: ZIP file containing the application source directory - - env_vars: Map of environment variables to set for the deployed application. Each key-value - pair represents an environment variable. - - force: Allow overwriting an existing app version - - region: Region for deployment. Currently we only support "aws.us-east-1a" - - version: Version of the application. Can be any string. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - body = deepcopy_minimal( - { - "entrypoint_rel_path": entrypoint_rel_path, - "file": file, - "env_vars": env_vars, - "force": force, - "region": region, - "version": version, - } - ) - files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) - # It should be noted that the actual Content-Type header that will be - # sent to the server will contain a `boundary` parameter, e.g. - # multipart/form-data; boundary=---abc-- - extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( - "/deploy", - body=await async_maybe_transform(body, deployment_create_params.DeploymentCreateParams), - files=files, - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=DeploymentCreateResponse, - ) - - async def follow( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncStream[DeploymentFollowResponse]: - """ - Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and - status updates for a deployed application. The stream terminates automatically - once the application reaches a terminal state. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})} - return await self._get( - f"/apps/{id}/events", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, DeploymentFollowResponse - ), # Union types cannot be passed in as arguments in the type system - stream=True, - stream_cls=AsyncStream[DeploymentFollowResponse], - ) - - -class DeploymentsResourceWithRawResponse: - def __init__(self, deployments: DeploymentsResource) -> None: - self._deployments = deployments - - self.create = to_raw_response_wrapper( - deployments.create, - ) - self.follow = to_raw_response_wrapper( - deployments.follow, - ) - - -class AsyncDeploymentsResourceWithRawResponse: - def __init__(self, deployments: AsyncDeploymentsResource) -> None: - self._deployments = deployments - - self.create = async_to_raw_response_wrapper( - deployments.create, - ) - self.follow = async_to_raw_response_wrapper( - deployments.follow, - ) - - -class DeploymentsResourceWithStreamingResponse: - def __init__(self, deployments: DeploymentsResource) -> None: - self._deployments = deployments - - self.create = to_streamed_response_wrapper( - deployments.create, - ) - self.follow = to_streamed_response_wrapper( - deployments.follow, - ) - - -class AsyncDeploymentsResourceWithStreamingResponse: - def __init__(self, deployments: AsyncDeploymentsResource) -> None: - self._deployments = deployments - - self.create = async_to_streamed_response_wrapper( - deployments.create, - ) - self.follow = async_to_streamed_response_wrapper( - deployments.follow, - ) diff --git a/src/kernel/types/apps/__init__.py b/src/kernel/types/apps/__init__.py deleted file mode 100644 index 93aed9dd..00000000 --- a/src/kernel/types/apps/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams -from .deployment_create_response import DeploymentCreateResponse as DeploymentCreateResponse -from .deployment_follow_response import DeploymentFollowResponse as DeploymentFollowResponse diff --git a/src/kernel/types/apps/deployment_create_params.py b/src/kernel/types/apps/deployment_create_params.py deleted file mode 100644 index cd1a7b53..00000000 --- a/src/kernel/types/apps/deployment_create_params.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict -from typing_extensions import Literal, Required, TypedDict - -from ..._types import FileTypes - -__all__ = ["DeploymentCreateParams"] - - -class DeploymentCreateParams(TypedDict, total=False): - entrypoint_rel_path: Required[str] - """Relative path to the entrypoint of the application""" - - file: Required[FileTypes] - """ZIP file containing the application source directory""" - - env_vars: Dict[str, str] - """Map of environment variables to set for the deployed application. - - Each key-value pair represents an environment variable. - """ - - force: bool - """Allow overwriting an existing app version""" - - region: Literal["aws.us-east-1a"] - """Region for deployment. Currently we only support "aws.us-east-1a" """ - - version: str - """Version of the application. Can be any string.""" diff --git a/src/kernel/types/apps/deployment_create_response.py b/src/kernel/types/apps/deployment_create_response.py deleted file mode 100644 index 8696a0f7..00000000 --- a/src/kernel/types/apps/deployment_create_response.py +++ /dev/null @@ -1,31 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.app_action import AppAction - -__all__ = ["DeploymentCreateResponse", "App"] - - -class App(BaseModel): - id: str - """ID for the app version deployed""" - - actions: List[AppAction] - """List of actions available on the app""" - - name: str - """Name of the app""" - - -class DeploymentCreateResponse(BaseModel): - apps: List[App] - """List of apps deployed""" - - status: Literal["queued", "deploying", "succeeded", "failed"] - """Current status of the deployment""" - - status_reason: Optional[str] = None - """Status reason""" diff --git a/src/kernel/types/apps/deployment_follow_response.py b/src/kernel/types/apps/deployment_follow_response.py deleted file mode 100644 index 6a196961..00000000 --- a/src/kernel/types/apps/deployment_follow_response.py +++ /dev/null @@ -1,41 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional -from datetime import datetime -from typing_extensions import Literal, Annotated, TypeAlias - -from ..._utils import PropertyInfo -from ..._models import BaseModel -from ..shared.log_event import LogEvent -from ..shared.heartbeat_event import HeartbeatEvent - -__all__ = ["DeploymentFollowResponse", "StateEvent", "StateUpdateEvent"] - - -class StateEvent(BaseModel): - event: Literal["state"] - """Event type identifier (always "state").""" - - state: str - """ - Current application state (e.g., "deploying", "running", "succeeded", "failed"). - """ - - timestamp: Optional[datetime] = None - """Time the state was reported.""" - - -class StateUpdateEvent(BaseModel): - event: Literal["state_update"] - """Event type identifier (always "state_update").""" - - state: str - """New application state (e.g., "running", "succeeded", "failed").""" - - timestamp: Optional[datetime] = None - """Time the state change occurred.""" - - -DeploymentFollowResponse: TypeAlias = Annotated[ - Union[StateEvent, StateUpdateEvent, LogEvent, HeartbeatEvent], PropertyInfo(discriminator="event") -] diff --git a/tests/api_resources/apps/__init__.py b/tests/api_resources/apps/__init__.py deleted file mode 100644 index fd8019a9..00000000 --- a/tests/api_resources/apps/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/apps/test_deployments.py b/tests/api_resources/apps/test_deployments.py deleted file mode 100644 index 7b613c85..00000000 --- a/tests/api_resources/apps/test_deployments.py +++ /dev/null @@ -1,222 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from kernel import Kernel, AsyncKernel -from tests.utils import assert_matches_type -from kernel.types.apps import DeploymentCreateResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestDeployments: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - def test_method_create(self, client: Kernel) -> None: - deployment = client.apps.deployments.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - ) - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_method_create_with_all_params(self, client: Kernel) -> None: - deployment = client.apps.deployments.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - env_vars={"foo": "string"}, - force=False, - region="aws.us-east-1a", - version="1.0.0", - ) - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_create(self, client: Kernel) -> None: - response = client.apps.deployments.with_raw_response.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - deployment = response.parse() - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_create(self, client: Kernel) -> None: - with client.apps.deployments.with_streaming_response.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - deployment = response.parse() - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - def test_method_follow(self, client: Kernel) -> None: - deployment_stream = client.apps.deployments.follow( - "id", - ) - deployment_stream.response.close() - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - def test_raw_response_follow(self, client: Kernel) -> None: - response = client.apps.deployments.with_raw_response.follow( - "id", - ) - - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = response.parse() - stream.close() - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - def test_streaming_response_follow(self, client: Kernel) -> None: - with client.apps.deployments.with_streaming_response.follow( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = response.parse() - stream.close() - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - def test_path_params_follow(self, client: Kernel) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.apps.deployments.with_raw_response.follow( - "", - ) - - -class TestAsyncDeployments: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip() - @parametrize - async def test_method_create(self, async_client: AsyncKernel) -> None: - deployment = await async_client.apps.deployments.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - ) - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncKernel) -> None: - deployment = await async_client.apps.deployments.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - env_vars={"foo": "string"}, - force=False, - region="aws.us-east-1a", - version="1.0.0", - ) - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_create(self, async_client: AsyncKernel) -> None: - response = await async_client.apps.deployments.with_raw_response.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - deployment = await response.parse() - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_create(self, async_client: AsyncKernel) -> None: - async with async_client.apps.deployments.with_streaming_response.create( - entrypoint_rel_path="src/app.py", - file=b"raw file contents", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - deployment = await response.parse() - assert_matches_type(DeploymentCreateResponse, deployment, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - async def test_method_follow(self, async_client: AsyncKernel) -> None: - deployment_stream = await async_client.apps.deployments.follow( - "id", - ) - await deployment_stream.response.aclose() - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - async def test_raw_response_follow(self, async_client: AsyncKernel) -> None: - response = await async_client.apps.deployments.with_raw_response.follow( - "id", - ) - - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = await response.parse() - await stream.close() - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - async def test_streaming_response_follow(self, async_client: AsyncKernel) -> None: - async with async_client.apps.deployments.with_streaming_response.follow( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = await response.parse() - await stream.close() - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail" - ) - @parametrize - async def test_path_params_follow(self, async_client: AsyncKernel) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.apps.deployments.with_raw_response.follow( - "", - )