|
| 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 | + ) |
0 commit comments