Skip to content

Commit 5ead241

Browse files
feat(api): update via SDK Studio (#5)
1 parent dd5a024 commit 5ead241

File tree

3 files changed

+132
-132
lines changed

3 files changed

+132
-132
lines changed

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ from replicate.types import HardwareListResponse
4444

4545
Methods:
4646

47-
- <code title="get /collections/{collection_slug}">client.hardware.<a href="./src/replicate/resources/hardware.py">retrieve</a>(collection_slug) -> None</code>
4847
- <code title="get /hardware">client.hardware.<a href="./src/replicate/resources/hardware.py">list</a>() -> <a href="./src/replicate/types/hardware_list_response.py">HardwareListResponse</a></code>
48+
- <code title="get /collections/{collection_slug}">client.hardware.<a href="./src/replicate/resources/hardware.py">retrieve_collections</a>(collection_slug) -> None</code>
4949

5050
# Accounts
5151

src/replicate/resources/hardware.py

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,45 @@ def with_streaming_response(self) -> HardwareResourceWithStreamingResponse:
3939
"""
4040
return HardwareResourceWithStreamingResponse(self)
4141

42-
def retrieve(
42+
def list(
43+
self,
44+
*,
45+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
46+
# The extra values given here take precedence over values defined on the client or passed to this method.
47+
extra_headers: Headers | None = None,
48+
extra_query: Query | None = None,
49+
extra_body: Body | None = None,
50+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
51+
) -> HardwareListResponse:
52+
"""
53+
Example cURL request:
54+
55+
```console
56+
curl -s \\
57+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
58+
https://api.replicate.com/v1/hardware
59+
```
60+
61+
The response will be a JSON array of hardware objects:
62+
63+
```json
64+
[
65+
{ "name": "CPU", "sku": "cpu" },
66+
{ "name": "Nvidia T4 GPU", "sku": "gpu-t4" },
67+
{ "name": "Nvidia A40 GPU", "sku": "gpu-a40-small" },
68+
{ "name": "Nvidia A40 (Large) GPU", "sku": "gpu-a40-large" }
69+
]
70+
```
71+
"""
72+
return self._get(
73+
"/hardware",
74+
options=make_request_options(
75+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
76+
),
77+
cast_to=HardwareListResponse,
78+
)
79+
80+
def retrieve_collections(
4381
self,
4482
collection_slug: str,
4583
*,
@@ -91,7 +129,28 @@ def retrieve(
91129
cast_to=NoneType,
92130
)
93131

94-
def list(
132+
133+
class AsyncHardwareResource(AsyncAPIResource):
134+
@cached_property
135+
def with_raw_response(self) -> AsyncHardwareResourceWithRawResponse:
136+
"""
137+
This property can be used as a prefix for any HTTP method call to return
138+
the raw response object instead of the parsed content.
139+
140+
For more information, see https://www.github.com/zeke/replicate-client-python-prod-for-fun#accessing-raw-response-data-eg-headers
141+
"""
142+
return AsyncHardwareResourceWithRawResponse(self)
143+
144+
@cached_property
145+
def with_streaming_response(self) -> AsyncHardwareResourceWithStreamingResponse:
146+
"""
147+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
148+
149+
For more information, see https://www.github.com/zeke/replicate-client-python-prod-for-fun#with_streaming_response
150+
"""
151+
return AsyncHardwareResourceWithStreamingResponse(self)
152+
153+
async def list(
95154
self,
96155
*,
97156
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -121,36 +180,15 @@ def list(
121180
]
122181
```
123182
"""
124-
return self._get(
183+
return await self._get(
125184
"/hardware",
126185
options=make_request_options(
127186
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
128187
),
129188
cast_to=HardwareListResponse,
130189
)
131190

132-
133-
class AsyncHardwareResource(AsyncAPIResource):
134-
@cached_property
135-
def with_raw_response(self) -> AsyncHardwareResourceWithRawResponse:
136-
"""
137-
This property can be used as a prefix for any HTTP method call to return
138-
the raw response object instead of the parsed content.
139-
140-
For more information, see https://www.github.com/zeke/replicate-client-python-prod-for-fun#accessing-raw-response-data-eg-headers
141-
"""
142-
return AsyncHardwareResourceWithRawResponse(self)
143-
144-
@cached_property
145-
def with_streaming_response(self) -> AsyncHardwareResourceWithStreamingResponse:
146-
"""
147-
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
148-
149-
For more information, see https://www.github.com/zeke/replicate-client-python-prod-for-fun#with_streaming_response
150-
"""
151-
return AsyncHardwareResourceWithStreamingResponse(self)
152-
153-
async def retrieve(
191+
async def retrieve_collections(
154192
self,
155193
collection_slug: str,
156194
*,
@@ -202,88 +240,50 @@ async def retrieve(
202240
cast_to=NoneType,
203241
)
204242

205-
async def list(
206-
self,
207-
*,
208-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
209-
# The extra values given here take precedence over values defined on the client or passed to this method.
210-
extra_headers: Headers | None = None,
211-
extra_query: Query | None = None,
212-
extra_body: Body | None = None,
213-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
214-
) -> HardwareListResponse:
215-
"""
216-
Example cURL request:
217-
218-
```console
219-
curl -s \\
220-
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
221-
https://api.replicate.com/v1/hardware
222-
```
223-
224-
The response will be a JSON array of hardware objects:
225-
226-
```json
227-
[
228-
{ "name": "CPU", "sku": "cpu" },
229-
{ "name": "Nvidia T4 GPU", "sku": "gpu-t4" },
230-
{ "name": "Nvidia A40 GPU", "sku": "gpu-a40-small" },
231-
{ "name": "Nvidia A40 (Large) GPU", "sku": "gpu-a40-large" }
232-
]
233-
```
234-
"""
235-
return await self._get(
236-
"/hardware",
237-
options=make_request_options(
238-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
239-
),
240-
cast_to=HardwareListResponse,
241-
)
242-
243243

244244
class HardwareResourceWithRawResponse:
245245
def __init__(self, hardware: HardwareResource) -> None:
246246
self._hardware = hardware
247247

248-
self.retrieve = to_raw_response_wrapper(
249-
hardware.retrieve,
250-
)
251248
self.list = to_raw_response_wrapper(
252249
hardware.list,
253250
)
251+
self.retrieve_collections = to_raw_response_wrapper(
252+
hardware.retrieve_collections,
253+
)
254254

255255

256256
class AsyncHardwareResourceWithRawResponse:
257257
def __init__(self, hardware: AsyncHardwareResource) -> None:
258258
self._hardware = hardware
259259

260-
self.retrieve = async_to_raw_response_wrapper(
261-
hardware.retrieve,
262-
)
263260
self.list = async_to_raw_response_wrapper(
264261
hardware.list,
265262
)
263+
self.retrieve_collections = async_to_raw_response_wrapper(
264+
hardware.retrieve_collections,
265+
)
266266

267267

268268
class HardwareResourceWithStreamingResponse:
269269
def __init__(self, hardware: HardwareResource) -> None:
270270
self._hardware = hardware
271271

272-
self.retrieve = to_streamed_response_wrapper(
273-
hardware.retrieve,
274-
)
275272
self.list = to_streamed_response_wrapper(
276273
hardware.list,
277274
)
275+
self.retrieve_collections = to_streamed_response_wrapper(
276+
hardware.retrieve_collections,
277+
)
278278

279279

280280
class AsyncHardwareResourceWithStreamingResponse:
281281
def __init__(self, hardware: AsyncHardwareResource) -> None:
282282
self._hardware = hardware
283283

284-
self.retrieve = async_to_streamed_response_wrapper(
285-
hardware.retrieve,
286-
)
287284
self.list = async_to_streamed_response_wrapper(
288285
hardware.list,
289286
)
287+
self.retrieve_collections = async_to_streamed_response_wrapper(
288+
hardware.retrieve_collections,
289+
)

tests/api_resources/test_hardware.py

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,6 @@
1717
class TestHardware:
1818
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
1919

20-
@pytest.mark.skip()
21-
@parametrize
22-
def test_method_retrieve(self, client: ReplicateClient) -> None:
23-
hardware = client.hardware.retrieve(
24-
"collection_slug",
25-
)
26-
assert hardware is None
27-
28-
@pytest.mark.skip()
29-
@parametrize
30-
def test_raw_response_retrieve(self, client: ReplicateClient) -> None:
31-
response = client.hardware.with_raw_response.retrieve(
32-
"collection_slug",
33-
)
34-
35-
assert response.is_closed is True
36-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
37-
hardware = response.parse()
38-
assert hardware is None
39-
40-
@pytest.mark.skip()
41-
@parametrize
42-
def test_streaming_response_retrieve(self, client: ReplicateClient) -> None:
43-
with client.hardware.with_streaming_response.retrieve(
44-
"collection_slug",
45-
) as response:
46-
assert not response.is_closed
47-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
48-
49-
hardware = response.parse()
50-
assert hardware is None
51-
52-
assert cast(Any, response.is_closed) is True
53-
54-
@pytest.mark.skip()
55-
@parametrize
56-
def test_path_params_retrieve(self, client: ReplicateClient) -> None:
57-
with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_slug` but received ''"):
58-
client.hardware.with_raw_response.retrieve(
59-
"",
60-
)
61-
6220
@pytest.mark.skip()
6321
@parametrize
6422
def test_method_list(self, client: ReplicateClient) -> None:
@@ -87,52 +45,52 @@ def test_streaming_response_list(self, client: ReplicateClient) -> None:
8745

8846
assert cast(Any, response.is_closed) is True
8947

90-
91-
class TestAsyncHardware:
92-
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
93-
9448
@pytest.mark.skip()
9549
@parametrize
96-
async def test_method_retrieve(self, async_client: AsyncReplicateClient) -> None:
97-
hardware = await async_client.hardware.retrieve(
50+
def test_method_retrieve_collections(self, client: ReplicateClient) -> None:
51+
hardware = client.hardware.retrieve_collections(
9852
"collection_slug",
9953
)
10054
assert hardware is None
10155

10256
@pytest.mark.skip()
10357
@parametrize
104-
async def test_raw_response_retrieve(self, async_client: AsyncReplicateClient) -> None:
105-
response = await async_client.hardware.with_raw_response.retrieve(
58+
def test_raw_response_retrieve_collections(self, client: ReplicateClient) -> None:
59+
response = client.hardware.with_raw_response.retrieve_collections(
10660
"collection_slug",
10761
)
10862

10963
assert response.is_closed is True
11064
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
111-
hardware = await response.parse()
65+
hardware = response.parse()
11266
assert hardware is None
11367

11468
@pytest.mark.skip()
11569
@parametrize
116-
async def test_streaming_response_retrieve(self, async_client: AsyncReplicateClient) -> None:
117-
async with async_client.hardware.with_streaming_response.retrieve(
70+
def test_streaming_response_retrieve_collections(self, client: ReplicateClient) -> None:
71+
with client.hardware.with_streaming_response.retrieve_collections(
11872
"collection_slug",
11973
) as response:
12074
assert not response.is_closed
12175
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
12276

123-
hardware = await response.parse()
77+
hardware = response.parse()
12478
assert hardware is None
12579

12680
assert cast(Any, response.is_closed) is True
12781

12882
@pytest.mark.skip()
12983
@parametrize
130-
async def test_path_params_retrieve(self, async_client: AsyncReplicateClient) -> None:
84+
def test_path_params_retrieve_collections(self, client: ReplicateClient) -> None:
13185
with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_slug` but received ''"):
132-
await async_client.hardware.with_raw_response.retrieve(
86+
client.hardware.with_raw_response.retrieve_collections(
13387
"",
13488
)
13589

90+
91+
class TestAsyncHardware:
92+
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
93+
13694
@pytest.mark.skip()
13795
@parametrize
13896
async def test_method_list(self, async_client: AsyncReplicateClient) -> None:
@@ -160,3 +118,45 @@ async def test_streaming_response_list(self, async_client: AsyncReplicateClient)
160118
assert_matches_type(HardwareListResponse, hardware, path=["response"])
161119

162120
assert cast(Any, response.is_closed) is True
121+
122+
@pytest.mark.skip()
123+
@parametrize
124+
async def test_method_retrieve_collections(self, async_client: AsyncReplicateClient) -> None:
125+
hardware = await async_client.hardware.retrieve_collections(
126+
"collection_slug",
127+
)
128+
assert hardware is None
129+
130+
@pytest.mark.skip()
131+
@parametrize
132+
async def test_raw_response_retrieve_collections(self, async_client: AsyncReplicateClient) -> None:
133+
response = await async_client.hardware.with_raw_response.retrieve_collections(
134+
"collection_slug",
135+
)
136+
137+
assert response.is_closed is True
138+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
139+
hardware = await response.parse()
140+
assert hardware is None
141+
142+
@pytest.mark.skip()
143+
@parametrize
144+
async def test_streaming_response_retrieve_collections(self, async_client: AsyncReplicateClient) -> None:
145+
async with async_client.hardware.with_streaming_response.retrieve_collections(
146+
"collection_slug",
147+
) as response:
148+
assert not response.is_closed
149+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
150+
151+
hardware = await response.parse()
152+
assert hardware is None
153+
154+
assert cast(Any, response.is_closed) is True
155+
156+
@pytest.mark.skip()
157+
@parametrize
158+
async def test_path_params_retrieve_collections(self, async_client: AsyncReplicateClient) -> None:
159+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_slug` but received ''"):
160+
await async_client.hardware.with_raw_response.retrieve_collections(
161+
"",
162+
)

0 commit comments

Comments
 (0)