Skip to content

Commit 0808bcb

Browse files
feat: Add DELETE /deployments/{id} API endpoint
1 parent 976efb5 commit 0808bcb

File tree

4 files changed

+174
-5
lines changed

4 files changed

+174
-5
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 100
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-a0f1d08e6f62a74de2aac5c25e592494abdd59f2cfca2842c5810927554faee0.yml
3-
openapi_spec_hash: ebd8bf67b7bb371cf4b4fa68b967cab5
4-
config_hash: 27c0ea01aeb797a1767af139851c5b66
1+
configured_endpoints: 101
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-bbc3dbdd0410eb315cfaeb21aad9f85e4a7f92ac55526ebb702a8bee343c2ab7.yml
3+
openapi_spec_hash: 60a5134c45a8f3a217e128d4e3335cae
4+
config_hash: 147340811dd6fbb9c2d80515a7e31f9a

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Methods:
3333
- <code title="post /deployments">client.deployments.<a href="./src/kernel/resources/deployments.py">create</a>(\*\*<a href="src/kernel/types/deployment_create_params.py">params</a>) -> <a href="./src/kernel/types/deployment_create_response.py">DeploymentCreateResponse</a></code>
3434
- <code title="get /deployments/{id}">client.deployments.<a href="./src/kernel/resources/deployments.py">retrieve</a>(id) -> <a href="./src/kernel/types/deployment_retrieve_response.py">DeploymentRetrieveResponse</a></code>
3535
- <code title="get /deployments">client.deployments.<a href="./src/kernel/resources/deployments.py">list</a>(\*\*<a href="src/kernel/types/deployment_list_params.py">params</a>) -> <a href="./src/kernel/types/deployment_list_response.py">SyncOffsetPagination[DeploymentListResponse]</a></code>
36+
- <code title="delete /deployments/{id}">client.deployments.<a href="./src/kernel/resources/deployments.py">delete</a>(id) -> None</code>
3637
- <code title="get /deployments/{id}/events">client.deployments.<a href="./src/kernel/resources/deployments.py">follow</a>(id, \*\*<a href="src/kernel/types/deployment_follow_params.py">params</a>) -> <a href="./src/kernel/types/deployment_follow_response.py">DeploymentFollowResponse</a></code>
3738

3839
# Apps

src/kernel/resources/deployments.py

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import httpx
99

1010
from ..types import deployment_list_params, deployment_create_params, deployment_follow_params
11-
from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given
11+
from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, omit, not_given
1212
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
1313
from .._compat import cached_property
1414
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -204,6 +204,42 @@ def list(
204204
model=DeploymentListResponse,
205205
)
206206

207+
def delete(
208+
self,
209+
id: str,
210+
*,
211+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
212+
# The extra values given here take precedence over values defined on the client or passed to this method.
213+
extra_headers: Headers | None = None,
214+
extra_query: Query | None = None,
215+
extra_body: Body | None = None,
216+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
217+
) -> None:
218+
"""Stops a running deployment and marks it for deletion.
219+
220+
If the deployment is
221+
already in a terminal state (stopped or failed), returns immediately.
222+
223+
Args:
224+
extra_headers: Send extra headers
225+
226+
extra_query: Add additional query parameters to the request
227+
228+
extra_body: Add additional JSON properties to the request
229+
230+
timeout: Override the client-level default timeout for this request, in seconds
231+
"""
232+
if not id:
233+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
234+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
235+
return self._delete(
236+
f"/deployments/{id}",
237+
options=make_request_options(
238+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
239+
),
240+
cast_to=NoneType,
241+
)
242+
207243
def follow(
208244
self,
209245
id: str,
@@ -427,6 +463,42 @@ def list(
427463
model=DeploymentListResponse,
428464
)
429465

466+
async def delete(
467+
self,
468+
id: str,
469+
*,
470+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
471+
# The extra values given here take precedence over values defined on the client or passed to this method.
472+
extra_headers: Headers | None = None,
473+
extra_query: Query | None = None,
474+
extra_body: Body | None = None,
475+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
476+
) -> None:
477+
"""Stops a running deployment and marks it for deletion.
478+
479+
If the deployment is
480+
already in a terminal state (stopped or failed), returns immediately.
481+
482+
Args:
483+
extra_headers: Send extra headers
484+
485+
extra_query: Add additional query parameters to the request
486+
487+
extra_body: Add additional JSON properties to the request
488+
489+
timeout: Override the client-level default timeout for this request, in seconds
490+
"""
491+
if not id:
492+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
493+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
494+
return await self._delete(
495+
f"/deployments/{id}",
496+
options=make_request_options(
497+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
498+
),
499+
cast_to=NoneType,
500+
)
501+
430502
async def follow(
431503
self,
432504
id: str,
@@ -488,6 +560,9 @@ def __init__(self, deployments: DeploymentsResource) -> None:
488560
self.list = to_raw_response_wrapper(
489561
deployments.list,
490562
)
563+
self.delete = to_raw_response_wrapper(
564+
deployments.delete,
565+
)
491566
self.follow = to_raw_response_wrapper(
492567
deployments.follow,
493568
)
@@ -506,6 +581,9 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
506581
self.list = async_to_raw_response_wrapper(
507582
deployments.list,
508583
)
584+
self.delete = async_to_raw_response_wrapper(
585+
deployments.delete,
586+
)
509587
self.follow = async_to_raw_response_wrapper(
510588
deployments.follow,
511589
)
@@ -524,6 +602,9 @@ def __init__(self, deployments: DeploymentsResource) -> None:
524602
self.list = to_streamed_response_wrapper(
525603
deployments.list,
526604
)
605+
self.delete = to_streamed_response_wrapper(
606+
deployments.delete,
607+
)
527608
self.follow = to_streamed_response_wrapper(
528609
deployments.follow,
529610
)
@@ -542,6 +623,9 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
542623
self.list = async_to_streamed_response_wrapper(
543624
deployments.list,
544625
)
626+
self.delete = async_to_streamed_response_wrapper(
627+
deployments.delete,
628+
)
545629
self.follow = async_to_streamed_response_wrapper(
546630
deployments.follow,
547631
)

tests/api_resources/test_deployments.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,48 @@ def test_streaming_response_list(self, client: Kernel) -> None:
154154

155155
assert cast(Any, response.is_closed) is True
156156

157+
@pytest.mark.skip(reason="Mock server tests are disabled")
158+
@parametrize
159+
def test_method_delete(self, client: Kernel) -> None:
160+
deployment = client.deployments.delete(
161+
"id",
162+
)
163+
assert deployment is None
164+
165+
@pytest.mark.skip(reason="Mock server tests are disabled")
166+
@parametrize
167+
def test_raw_response_delete(self, client: Kernel) -> None:
168+
response = client.deployments.with_raw_response.delete(
169+
"id",
170+
)
171+
172+
assert response.is_closed is True
173+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
174+
deployment = response.parse()
175+
assert deployment is None
176+
177+
@pytest.mark.skip(reason="Mock server tests are disabled")
178+
@parametrize
179+
def test_streaming_response_delete(self, client: Kernel) -> None:
180+
with client.deployments.with_streaming_response.delete(
181+
"id",
182+
) as response:
183+
assert not response.is_closed
184+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
185+
186+
deployment = response.parse()
187+
assert deployment is None
188+
189+
assert cast(Any, response.is_closed) is True
190+
191+
@pytest.mark.skip(reason="Mock server tests are disabled")
192+
@parametrize
193+
def test_path_params_delete(self, client: Kernel) -> None:
194+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
195+
client.deployments.with_raw_response.delete(
196+
"",
197+
)
198+
157199
@pytest.mark.skip(reason="Mock server tests are disabled")
158200
@parametrize
159201
def test_method_follow(self, client: Kernel) -> None:
@@ -342,6 +384,48 @@ async def test_streaming_response_list(self, async_client: AsyncKernel) -> None:
342384

343385
assert cast(Any, response.is_closed) is True
344386

387+
@pytest.mark.skip(reason="Mock server tests are disabled")
388+
@parametrize
389+
async def test_method_delete(self, async_client: AsyncKernel) -> None:
390+
deployment = await async_client.deployments.delete(
391+
"id",
392+
)
393+
assert deployment is None
394+
395+
@pytest.mark.skip(reason="Mock server tests are disabled")
396+
@parametrize
397+
async def test_raw_response_delete(self, async_client: AsyncKernel) -> None:
398+
response = await async_client.deployments.with_raw_response.delete(
399+
"id",
400+
)
401+
402+
assert response.is_closed is True
403+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
404+
deployment = await response.parse()
405+
assert deployment is None
406+
407+
@pytest.mark.skip(reason="Mock server tests are disabled")
408+
@parametrize
409+
async def test_streaming_response_delete(self, async_client: AsyncKernel) -> None:
410+
async with async_client.deployments.with_streaming_response.delete(
411+
"id",
412+
) as response:
413+
assert not response.is_closed
414+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
415+
416+
deployment = await response.parse()
417+
assert deployment is None
418+
419+
assert cast(Any, response.is_closed) is True
420+
421+
@pytest.mark.skip(reason="Mock server tests are disabled")
422+
@parametrize
423+
async def test_path_params_delete(self, async_client: AsyncKernel) -> None:
424+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
425+
await async_client.deployments.with_raw_response.delete(
426+
"",
427+
)
428+
345429
@pytest.mark.skip(reason="Mock server tests are disabled")
346430
@parametrize
347431
async def test_method_follow(self, async_client: AsyncKernel) -> None:

0 commit comments

Comments
 (0)