Skip to content

Commit 2420ce0

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#44)
1 parent 73fd7da commit 2420ce0

File tree

8 files changed

+255
-1
lines changed

8 files changed

+255
-1
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 6
1+
configured_endpoints: 7
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/luma-ai-karanganesan%2Fluma_ai-a9bc6643a804b0df5ccca77dbeeff12341befaefe288ac306044047ded323577.yml

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,15 @@ from lumaai.types import PingCheckResponse
3636
Methods:
3737

3838
- <code title="get /ping">client.ping.<a href="./src/lumaai/resources/ping.py">check</a>() -> <a href="./src/lumaai/types/ping_check_response.py">PingCheckResponse</a></code>
39+
40+
# Credits
41+
42+
Types:
43+
44+
```python
45+
from lumaai.types import CreditGetResponse
46+
```
47+
48+
Methods:
49+
50+
- <code title="get /credits">client.credits.<a href="./src/lumaai/resources/credits.py">get</a>() -> <a href="./src/lumaai/types/credit_get_response.py">CreditGetResponse</a></code>

src/lumaai/_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
class LumaAI(SyncAPIClient):
4949
generations: resources.GenerationsResource
5050
ping: resources.PingResource
51+
credits: resources.CreditsResource
5152
with_raw_response: LumaAIWithRawResponse
5253
with_streaming_response: LumaAIWithStreamedResponse
5354

@@ -107,6 +108,7 @@ def __init__(
107108

108109
self.generations = resources.GenerationsResource(self)
109110
self.ping = resources.PingResource(self)
111+
self.credits = resources.CreditsResource(self)
110112
self.with_raw_response = LumaAIWithRawResponse(self)
111113
self.with_streaming_response = LumaAIWithStreamedResponse(self)
112114

@@ -218,6 +220,7 @@ def _make_status_error(
218220
class AsyncLumaAI(AsyncAPIClient):
219221
generations: resources.AsyncGenerationsResource
220222
ping: resources.AsyncPingResource
223+
credits: resources.AsyncCreditsResource
221224
with_raw_response: AsyncLumaAIWithRawResponse
222225
with_streaming_response: AsyncLumaAIWithStreamedResponse
223226

@@ -277,6 +280,7 @@ def __init__(
277280

278281
self.generations = resources.AsyncGenerationsResource(self)
279282
self.ping = resources.AsyncPingResource(self)
283+
self.credits = resources.AsyncCreditsResource(self)
280284
self.with_raw_response = AsyncLumaAIWithRawResponse(self)
281285
self.with_streaming_response = AsyncLumaAIWithStreamedResponse(self)
282286

@@ -389,24 +393,28 @@ class LumaAIWithRawResponse:
389393
def __init__(self, client: LumaAI) -> None:
390394
self.generations = resources.GenerationsResourceWithRawResponse(client.generations)
391395
self.ping = resources.PingResourceWithRawResponse(client.ping)
396+
self.credits = resources.CreditsResourceWithRawResponse(client.credits)
392397

393398

394399
class AsyncLumaAIWithRawResponse:
395400
def __init__(self, client: AsyncLumaAI) -> None:
396401
self.generations = resources.AsyncGenerationsResourceWithRawResponse(client.generations)
397402
self.ping = resources.AsyncPingResourceWithRawResponse(client.ping)
403+
self.credits = resources.AsyncCreditsResourceWithRawResponse(client.credits)
398404

399405

400406
class LumaAIWithStreamedResponse:
401407
def __init__(self, client: LumaAI) -> None:
402408
self.generations = resources.GenerationsResourceWithStreamingResponse(client.generations)
403409
self.ping = resources.PingResourceWithStreamingResponse(client.ping)
410+
self.credits = resources.CreditsResourceWithStreamingResponse(client.credits)
404411

405412

406413
class AsyncLumaAIWithStreamedResponse:
407414
def __init__(self, client: AsyncLumaAI) -> None:
408415
self.generations = resources.AsyncGenerationsResourceWithStreamingResponse(client.generations)
409416
self.ping = resources.AsyncPingResourceWithStreamingResponse(client.ping)
417+
self.credits = resources.AsyncCreditsResourceWithStreamingResponse(client.credits)
410418

411419

412420
Client = LumaAI

src/lumaai/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
PingResourceWithStreamingResponse,
99
AsyncPingResourceWithStreamingResponse,
1010
)
11+
from .credits import (
12+
CreditsResource,
13+
AsyncCreditsResource,
14+
CreditsResourceWithRawResponse,
15+
AsyncCreditsResourceWithRawResponse,
16+
CreditsResourceWithStreamingResponse,
17+
AsyncCreditsResourceWithStreamingResponse,
18+
)
1119
from .generations import (
1220
GenerationsResource,
1321
AsyncGenerationsResource,
@@ -30,4 +38,10 @@
3038
"AsyncPingResourceWithRawResponse",
3139
"PingResourceWithStreamingResponse",
3240
"AsyncPingResourceWithStreamingResponse",
41+
"CreditsResource",
42+
"AsyncCreditsResource",
43+
"CreditsResourceWithRawResponse",
44+
"AsyncCreditsResourceWithRawResponse",
45+
"CreditsResourceWithStreamingResponse",
46+
"AsyncCreditsResourceWithStreamingResponse",
3347
]

src/lumaai/resources/credits.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import httpx
6+
7+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
8+
from .._compat import cached_property
9+
from .._resource import SyncAPIResource, AsyncAPIResource
10+
from .._response import (
11+
to_raw_response_wrapper,
12+
to_streamed_response_wrapper,
13+
async_to_raw_response_wrapper,
14+
async_to_streamed_response_wrapper,
15+
)
16+
from .._base_client import make_request_options
17+
from ..types.credit_get_response import CreditGetResponse
18+
19+
__all__ = ["CreditsResource", "AsyncCreditsResource"]
20+
21+
22+
class CreditsResource(SyncAPIResource):
23+
@cached_property
24+
def with_raw_response(self) -> CreditsResourceWithRawResponse:
25+
"""
26+
This property can be used as a prefix for any HTTP method call to return the
27+
the raw response object instead of the parsed content.
28+
29+
For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
30+
"""
31+
return CreditsResourceWithRawResponse(self)
32+
33+
@cached_property
34+
def with_streaming_response(self) -> CreditsResourceWithStreamingResponse:
35+
"""
36+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
37+
38+
For more information, see https://www.github.com/lumalabs/lumaai-python#with_streaming_response
39+
"""
40+
return CreditsResourceWithStreamingResponse(self)
41+
42+
def get(
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+
) -> CreditGetResponse:
52+
"""Get the credits information for the api user"""
53+
return self._get(
54+
"/credits",
55+
options=make_request_options(
56+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
57+
),
58+
cast_to=CreditGetResponse,
59+
)
60+
61+
62+
class AsyncCreditsResource(AsyncAPIResource):
63+
@cached_property
64+
def with_raw_response(self) -> AsyncCreditsResourceWithRawResponse:
65+
"""
66+
This property can be used as a prefix for any HTTP method call to return the
67+
the raw response object instead of the parsed content.
68+
69+
For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
70+
"""
71+
return AsyncCreditsResourceWithRawResponse(self)
72+
73+
@cached_property
74+
def with_streaming_response(self) -> AsyncCreditsResourceWithStreamingResponse:
75+
"""
76+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
77+
78+
For more information, see https://www.github.com/lumalabs/lumaai-python#with_streaming_response
79+
"""
80+
return AsyncCreditsResourceWithStreamingResponse(self)
81+
82+
async def get(
83+
self,
84+
*,
85+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
86+
# The extra values given here take precedence over values defined on the client or passed to this method.
87+
extra_headers: Headers | None = None,
88+
extra_query: Query | None = None,
89+
extra_body: Body | None = None,
90+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
91+
) -> CreditGetResponse:
92+
"""Get the credits information for the api user"""
93+
return await self._get(
94+
"/credits",
95+
options=make_request_options(
96+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
97+
),
98+
cast_to=CreditGetResponse,
99+
)
100+
101+
102+
class CreditsResourceWithRawResponse:
103+
def __init__(self, credits: CreditsResource) -> None:
104+
self._credits = credits
105+
106+
self.get = to_raw_response_wrapper(
107+
credits.get,
108+
)
109+
110+
111+
class AsyncCreditsResourceWithRawResponse:
112+
def __init__(self, credits: AsyncCreditsResource) -> None:
113+
self._credits = credits
114+
115+
self.get = async_to_raw_response_wrapper(
116+
credits.get,
117+
)
118+
119+
120+
class CreditsResourceWithStreamingResponse:
121+
def __init__(self, credits: CreditsResource) -> None:
122+
self._credits = credits
123+
124+
self.get = to_streamed_response_wrapper(
125+
credits.get,
126+
)
127+
128+
129+
class AsyncCreditsResourceWithStreamingResponse:
130+
def __init__(self, credits: AsyncCreditsResource) -> None:
131+
self._credits = credits
132+
133+
self.get = async_to_streamed_response_wrapper(
134+
credits.get,
135+
)

src/lumaai/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from .generation import Generation as Generation
6+
from .credit_get_response import CreditGetResponse as CreditGetResponse
67
from .ping_check_response import PingCheckResponse as PingCheckResponse
78
from .generation_list_params import GenerationListParams as GenerationListParams
89
from .generation_create_params import GenerationCreateParams as GenerationCreateParams
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
4+
5+
from .._models import BaseModel
6+
7+
__all__ = ["CreditGetResponse"]
8+
9+
10+
class CreditGetResponse(BaseModel):
11+
credit_balance: float
12+
"""Available credits balance in USD cents"""
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import os
6+
from typing import Any, cast
7+
8+
import pytest
9+
10+
from lumaai import LumaAI, AsyncLumaAI
11+
from tests.utils import assert_matches_type
12+
from lumaai.types import CreditGetResponse
13+
14+
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
15+
16+
17+
class TestCredits:
18+
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
19+
20+
@parametrize
21+
def test_method_get(self, client: LumaAI) -> None:
22+
credit = client.credits.get()
23+
assert_matches_type(CreditGetResponse, credit, path=["response"])
24+
25+
@parametrize
26+
def test_raw_response_get(self, client: LumaAI) -> None:
27+
response = client.credits.with_raw_response.get()
28+
29+
assert response.is_closed is True
30+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
31+
credit = response.parse()
32+
assert_matches_type(CreditGetResponse, credit, path=["response"])
33+
34+
@parametrize
35+
def test_streaming_response_get(self, client: LumaAI) -> None:
36+
with client.credits.with_streaming_response.get() as response:
37+
assert not response.is_closed
38+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
39+
40+
credit = response.parse()
41+
assert_matches_type(CreditGetResponse, credit, path=["response"])
42+
43+
assert cast(Any, response.is_closed) is True
44+
45+
46+
class TestAsyncCredits:
47+
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
48+
49+
@parametrize
50+
async def test_method_get(self, async_client: AsyncLumaAI) -> None:
51+
credit = await async_client.credits.get()
52+
assert_matches_type(CreditGetResponse, credit, path=["response"])
53+
54+
@parametrize
55+
async def test_raw_response_get(self, async_client: AsyncLumaAI) -> None:
56+
response = await async_client.credits.with_raw_response.get()
57+
58+
assert response.is_closed is True
59+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
60+
credit = await response.parse()
61+
assert_matches_type(CreditGetResponse, credit, path=["response"])
62+
63+
@parametrize
64+
async def test_streaming_response_get(self, async_client: AsyncLumaAI) -> None:
65+
async with async_client.credits.with_streaming_response.get() as response:
66+
assert not response.is_closed
67+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
68+
69+
credit = await response.parse()
70+
assert_matches_type(CreditGetResponse, credit, path=["response"])
71+
72+
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)