Skip to content

Commit f66ff15

Browse files
author
stlc-bot
committed
feat(axon): add axon metadata update endpoint
Stainless-Generated-From: 1b2a3b4dd31dde4da80326d1c43c30149c4cbf90
1 parent a8dc212 commit f66ff15

7 files changed

Lines changed: 226 additions & 3 deletions

File tree

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 123
1+
configured_endpoints: 124

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ from runloop_api_client.types import (
122122
AxonCreateParams,
123123
AxonEventView,
124124
AxonListView,
125+
AxonUpdateParams,
125126
AxonView,
126127
PublishParams,
127128
PublishResultView,
@@ -132,6 +133,7 @@ Methods:
132133

133134
- <code title="post /v1/axons">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">create</a>(\*\*<a href="src/runloop_api_client/types/axon_create_params.py">params</a>) -> <a href="./src/runloop_api_client/types/axon_view.py">AxonView</a></code>
134135
- <code title="get /v1/axons/{id}">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">retrieve</a>(id) -> <a href="./src/runloop_api_client/types/axon_view.py">AxonView</a></code>
136+
- <code title="post /v1/axons/{id}">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">update</a>(id, \*\*<a href="src/runloop_api_client/types/axon_update_params.py">params</a>) -> <a href="./src/runloop_api_client/types/axon_view.py">AxonView</a></code>
135137
- <code title="get /v1/axons">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">list</a>(\*\*<a href="src/runloop_api_client/types/axon_list_params.py">params</a>) -> <a href="./src/runloop_api_client/types/axon_view.py">SyncAxonsCursorIDPage[AxonView]</a></code>
136138
- <code title="delete /v1/axons/{id}">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">delete</a>(id) -> object</code>
137139
- <code title="post /v1/axons/{id}/publish">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">publish</a>(id, \*\*<a href="src/runloop_api_client/types/axon_publish_params.py">params</a>) -> <a href="./src/runloop_api_client/types/publish_result_view.py">PublishResultView</a></code>

scripts/mock

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/runloop_api_client/resources/axons/axons.py

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
EventsResourceWithStreamingResponse,
2424
AsyncEventsResourceWithStreamingResponse,
2525
)
26-
from ...types import axon_list_params, axon_create_params, axon_publish_params, axon_subscribe_sse_params
26+
from ...types import (
27+
axon_list_params,
28+
axon_create_params,
29+
axon_update_params,
30+
axon_publish_params,
31+
axon_subscribe_sse_params,
32+
)
2733
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
2834
from ..._utils import path_template, maybe_transform, async_maybe_transform
2935
from ..._compat import cached_property
@@ -155,6 +161,53 @@ def retrieve(
155161
cast_to=AxonView,
156162
)
157163

164+
def update(
165+
self,
166+
id: str,
167+
*,
168+
metadata: Optional[Dict[str, str]] | Omit = omit,
169+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
170+
# The extra values given here take precedence over values defined on the client or passed to this method.
171+
extra_headers: Headers | None = None,
172+
extra_query: Query | None = None,
173+
extra_body: Body | None = None,
174+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
175+
idempotency_key: str | None = None,
176+
) -> AxonView:
177+
"""[Beta] Updates the specified axon fields.
178+
179+
Omitted fields are left unchanged. An
180+
empty metadata map clears the metadata.
181+
182+
Args:
183+
metadata: User defined metadata to replace the axon metadata. Omit or set to null to leave
184+
unchanged, or set to an empty map to clear it.
185+
186+
extra_headers: Send extra headers
187+
188+
extra_query: Add additional query parameters to the request
189+
190+
extra_body: Add additional JSON properties to the request
191+
192+
timeout: Override the client-level default timeout for this request, in seconds
193+
194+
idempotency_key: Specify a custom idempotency key for this request
195+
"""
196+
if not id:
197+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
198+
return self._post(
199+
path_template("/v1/axons/{id}", id=id),
200+
body=maybe_transform({"metadata": metadata}, axon_update_params.AxonUpdateParams),
201+
options=make_request_options(
202+
extra_headers=extra_headers,
203+
extra_query=extra_query,
204+
extra_body=extra_body,
205+
timeout=timeout,
206+
idempotency_key=idempotency_key,
207+
),
208+
cast_to=AxonView,
209+
)
210+
158211
def list(
159212
self,
160213
*,
@@ -488,6 +541,53 @@ async def retrieve(
488541
cast_to=AxonView,
489542
)
490543

544+
async def update(
545+
self,
546+
id: str,
547+
*,
548+
metadata: Optional[Dict[str, str]] | Omit = omit,
549+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
550+
# The extra values given here take precedence over values defined on the client or passed to this method.
551+
extra_headers: Headers | None = None,
552+
extra_query: Query | None = None,
553+
extra_body: Body | None = None,
554+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
555+
idempotency_key: str | None = None,
556+
) -> AxonView:
557+
"""[Beta] Updates the specified axon fields.
558+
559+
Omitted fields are left unchanged. An
560+
empty metadata map clears the metadata.
561+
562+
Args:
563+
metadata: User defined metadata to replace the axon metadata. Omit or set to null to leave
564+
unchanged, or set to an empty map to clear it.
565+
566+
extra_headers: Send extra headers
567+
568+
extra_query: Add additional query parameters to the request
569+
570+
extra_body: Add additional JSON properties to the request
571+
572+
timeout: Override the client-level default timeout for this request, in seconds
573+
574+
idempotency_key: Specify a custom idempotency key for this request
575+
"""
576+
if not id:
577+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
578+
return await self._post(
579+
path_template("/v1/axons/{id}", id=id),
580+
body=await async_maybe_transform({"metadata": metadata}, axon_update_params.AxonUpdateParams),
581+
options=make_request_options(
582+
extra_headers=extra_headers,
583+
extra_query=extra_query,
584+
extra_body=extra_body,
585+
timeout=timeout,
586+
idempotency_key=idempotency_key,
587+
),
588+
cast_to=AxonView,
589+
)
590+
491591
def list(
492592
self,
493593
*,
@@ -720,6 +820,9 @@ def __init__(self, axons: AxonsResource) -> None:
720820
self.retrieve = to_raw_response_wrapper(
721821
axons.retrieve,
722822
)
823+
self.update = to_raw_response_wrapper(
824+
axons.update,
825+
)
723826
self.list = to_raw_response_wrapper(
724827
axons.list,
725828
)
@@ -752,6 +855,9 @@ def __init__(self, axons: AsyncAxonsResource) -> None:
752855
self.retrieve = async_to_raw_response_wrapper(
753856
axons.retrieve,
754857
)
858+
self.update = async_to_raw_response_wrapper(
859+
axons.update,
860+
)
755861
self.list = async_to_raw_response_wrapper(
756862
axons.list,
757863
)
@@ -784,6 +890,9 @@ def __init__(self, axons: AxonsResource) -> None:
784890
self.retrieve = to_streamed_response_wrapper(
785891
axons.retrieve,
786892
)
893+
self.update = to_streamed_response_wrapper(
894+
axons.update,
895+
)
787896
self.list = to_streamed_response_wrapper(
788897
axons.list,
789898
)
@@ -816,6 +925,9 @@ def __init__(self, axons: AsyncAxonsResource) -> None:
816925
self.retrieve = async_to_streamed_response_wrapper(
817926
axons.retrieve,
818927
)
928+
self.update = async_to_streamed_response_wrapper(
929+
axons.update,
930+
)
819931
self.list = async_to_streamed_response_wrapper(
820932
axons.list,
821933
)

src/runloop_api_client/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from .scenario_run_view import ScenarioRunView as ScenarioRunView
5151
from .allowed_cidr_param import AllowedCidrParam as AllowedCidrParam
5252
from .axon_create_params import AxonCreateParams as AxonCreateParams
53+
from .axon_update_params import AxonUpdateParams as AxonUpdateParams
5354
from .benchmark_job_view import BenchmarkJobView as BenchmarkJobView
5455
from .benchmark_run_view import BenchmarkRunView as BenchmarkRunView
5556
from .devbox_list_params import DevboxListParams as DevboxListParams
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Dict, Optional
6+
from typing_extensions import TypedDict
7+
8+
__all__ = ["AxonUpdateParams"]
9+
10+
11+
class AxonUpdateParams(TypedDict, total=False):
12+
metadata: Optional[Dict[str, str]]
13+
"""User defined metadata to replace the axon metadata.
14+
15+
Omit or set to null to leave unchanged, or set to an empty map to clear it.
16+
"""

tests/api_resources/test_axons.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,52 @@ def test_path_params_retrieve(self, client: Runloop) -> None:
9292
"",
9393
)
9494

95+
@parametrize
96+
def test_method_update(self, client: Runloop) -> None:
97+
axon = client.axons.update(
98+
id="id",
99+
)
100+
assert_matches_type(AxonView, axon, path=["response"])
101+
102+
@parametrize
103+
def test_method_update_with_all_params(self, client: Runloop) -> None:
104+
axon = client.axons.update(
105+
id="id",
106+
metadata={"foo": "string"},
107+
)
108+
assert_matches_type(AxonView, axon, path=["response"])
109+
110+
@parametrize
111+
def test_raw_response_update(self, client: Runloop) -> None:
112+
response = client.axons.with_raw_response.update(
113+
id="id",
114+
)
115+
116+
assert response.is_closed is True
117+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
118+
axon = response.parse()
119+
assert_matches_type(AxonView, axon, path=["response"])
120+
121+
@parametrize
122+
def test_streaming_response_update(self, client: Runloop) -> None:
123+
with client.axons.with_streaming_response.update(
124+
id="id",
125+
) as response:
126+
assert not response.is_closed
127+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
128+
129+
axon = response.parse()
130+
assert_matches_type(AxonView, axon, path=["response"])
131+
132+
assert cast(Any, response.is_closed) is True
133+
134+
@parametrize
135+
def test_path_params_update(self, client: Runloop) -> None:
136+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
137+
client.axons.with_raw_response.update(
138+
id="",
139+
)
140+
95141
@parametrize
96142
def test_method_list(self, client: Runloop) -> None:
97143
axon = client.axons.list()
@@ -345,6 +391,52 @@ async def test_path_params_retrieve(self, async_client: AsyncRunloop) -> None:
345391
"",
346392
)
347393

394+
@parametrize
395+
async def test_method_update(self, async_client: AsyncRunloop) -> None:
396+
axon = await async_client.axons.update(
397+
id="id",
398+
)
399+
assert_matches_type(AxonView, axon, path=["response"])
400+
401+
@parametrize
402+
async def test_method_update_with_all_params(self, async_client: AsyncRunloop) -> None:
403+
axon = await async_client.axons.update(
404+
id="id",
405+
metadata={"foo": "string"},
406+
)
407+
assert_matches_type(AxonView, axon, path=["response"])
408+
409+
@parametrize
410+
async def test_raw_response_update(self, async_client: AsyncRunloop) -> None:
411+
response = await async_client.axons.with_raw_response.update(
412+
id="id",
413+
)
414+
415+
assert response.is_closed is True
416+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
417+
axon = await response.parse()
418+
assert_matches_type(AxonView, axon, path=["response"])
419+
420+
@parametrize
421+
async def test_streaming_response_update(self, async_client: AsyncRunloop) -> None:
422+
async with async_client.axons.with_streaming_response.update(
423+
id="id",
424+
) as response:
425+
assert not response.is_closed
426+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
427+
428+
axon = await response.parse()
429+
assert_matches_type(AxonView, axon, path=["response"])
430+
431+
assert cast(Any, response.is_closed) is True
432+
433+
@parametrize
434+
async def test_path_params_update(self, async_client: AsyncRunloop) -> None:
435+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
436+
await async_client.axons.with_raw_response.update(
437+
id="",
438+
)
439+
348440
@parametrize
349441
async def test_method_list(self, async_client: AsyncRunloop) -> None:
350442
axon = await async_client.axons.list()

0 commit comments

Comments
 (0)