|
| 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 Body, Query, Headers, NotGiven, not_given |
| 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.account_view import AccountView |
| 18 | + |
| 19 | +__all__ = ["AccountsResource", "AsyncAccountsResource"] |
| 20 | + |
| 21 | + |
| 22 | +class AccountsResource(SyncAPIResource): |
| 23 | + @cached_property |
| 24 | + def with_raw_response(self) -> AccountsResourceWithRawResponse: |
| 25 | + """ |
| 26 | + This property can be used as a prefix for any HTTP method call to return |
| 27 | + the raw response object instead of the parsed content. |
| 28 | +
|
| 29 | + For more information, see https://www.github.com/runloopai/api-client-python#accessing-raw-response-data-eg-headers |
| 30 | + """ |
| 31 | + return AccountsResourceWithRawResponse(self) |
| 32 | + |
| 33 | + @cached_property |
| 34 | + def with_streaming_response(self) -> AccountsResourceWithStreamingResponse: |
| 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/runloopai/api-client-python#with_streaming_response |
| 39 | + """ |
| 40 | + return AccountsResourceWithStreamingResponse(self) |
| 41 | + |
| 42 | + def me( |
| 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 | + ) -> AccountView: |
| 52 | + """ |
| 53 | + Returns the account the API key or session is authenticated against, including |
| 54 | + id, name, tier, and billing summary. |
| 55 | + """ |
| 56 | + return self._get( |
| 57 | + "/v1/accounts/me", |
| 58 | + options=make_request_options( |
| 59 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 60 | + ), |
| 61 | + cast_to=AccountView, |
| 62 | + ) |
| 63 | + |
| 64 | + |
| 65 | +class AsyncAccountsResource(AsyncAPIResource): |
| 66 | + @cached_property |
| 67 | + def with_raw_response(self) -> AsyncAccountsResourceWithRawResponse: |
| 68 | + """ |
| 69 | + This property can be used as a prefix for any HTTP method call to return |
| 70 | + the raw response object instead of the parsed content. |
| 71 | +
|
| 72 | + For more information, see https://www.github.com/runloopai/api-client-python#accessing-raw-response-data-eg-headers |
| 73 | + """ |
| 74 | + return AsyncAccountsResourceWithRawResponse(self) |
| 75 | + |
| 76 | + @cached_property |
| 77 | + def with_streaming_response(self) -> AsyncAccountsResourceWithStreamingResponse: |
| 78 | + """ |
| 79 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 80 | +
|
| 81 | + For more information, see https://www.github.com/runloopai/api-client-python#with_streaming_response |
| 82 | + """ |
| 83 | + return AsyncAccountsResourceWithStreamingResponse(self) |
| 84 | + |
| 85 | + async def me( |
| 86 | + self, |
| 87 | + *, |
| 88 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 89 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 90 | + extra_headers: Headers | None = None, |
| 91 | + extra_query: Query | None = None, |
| 92 | + extra_body: Body | None = None, |
| 93 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 94 | + ) -> AccountView: |
| 95 | + """ |
| 96 | + Returns the account the API key or session is authenticated against, including |
| 97 | + id, name, tier, and billing summary. |
| 98 | + """ |
| 99 | + return await self._get( |
| 100 | + "/v1/accounts/me", |
| 101 | + options=make_request_options( |
| 102 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 103 | + ), |
| 104 | + cast_to=AccountView, |
| 105 | + ) |
| 106 | + |
| 107 | + |
| 108 | +class AccountsResourceWithRawResponse: |
| 109 | + def __init__(self, accounts: AccountsResource) -> None: |
| 110 | + self._accounts = accounts |
| 111 | + |
| 112 | + self.me = to_raw_response_wrapper( |
| 113 | + accounts.me, |
| 114 | + ) |
| 115 | + |
| 116 | + |
| 117 | +class AsyncAccountsResourceWithRawResponse: |
| 118 | + def __init__(self, accounts: AsyncAccountsResource) -> None: |
| 119 | + self._accounts = accounts |
| 120 | + |
| 121 | + self.me = async_to_raw_response_wrapper( |
| 122 | + accounts.me, |
| 123 | + ) |
| 124 | + |
| 125 | + |
| 126 | +class AccountsResourceWithStreamingResponse: |
| 127 | + def __init__(self, accounts: AccountsResource) -> None: |
| 128 | + self._accounts = accounts |
| 129 | + |
| 130 | + self.me = to_streamed_response_wrapper( |
| 131 | + accounts.me, |
| 132 | + ) |
| 133 | + |
| 134 | + |
| 135 | +class AsyncAccountsResourceWithStreamingResponse: |
| 136 | + def __init__(self, accounts: AsyncAccountsResource) -> None: |
| 137 | + self._accounts = accounts |
| 138 | + |
| 139 | + self.me = async_to_streamed_response_wrapper( |
| 140 | + accounts.me, |
| 141 | + ) |
0 commit comments