|
| 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.account_list_response import AccountListResponse |
| 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/stainless-sdks/replicate-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/stainless-sdks/replicate-client-python#with_streaming_response |
| 39 | + """ |
| 40 | + return AccountsResourceWithStreamingResponse(self) |
| 41 | + |
| 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 | + ) -> AccountListResponse: |
| 52 | + """ |
| 53 | + Returns information about the user or organization associated with the provided |
| 54 | + API token. |
| 55 | +
|
| 56 | + Example cURL request: |
| 57 | +
|
| 58 | + ```console |
| 59 | + curl -s \\ |
| 60 | + -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\ |
| 61 | + https://api.replicate.com/v1/account |
| 62 | + ``` |
| 63 | +
|
| 64 | + The response will be a JSON object describing the account: |
| 65 | +
|
| 66 | + ```json |
| 67 | + { |
| 68 | + "type": "organization", |
| 69 | + "username": "acme", |
| 70 | + "name": "Acme Corp, Inc.", |
| 71 | + "github_url": "https://github.com/acme" |
| 72 | + } |
| 73 | + ``` |
| 74 | + """ |
| 75 | + return self._get( |
| 76 | + "/account", |
| 77 | + options=make_request_options( |
| 78 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 79 | + ), |
| 80 | + cast_to=AccountListResponse, |
| 81 | + ) |
| 82 | + |
| 83 | + |
| 84 | +class AsyncAccountsResource(AsyncAPIResource): |
| 85 | + @cached_property |
| 86 | + def with_raw_response(self) -> AsyncAccountsResourceWithRawResponse: |
| 87 | + """ |
| 88 | + This property can be used as a prefix for any HTTP method call to return |
| 89 | + the raw response object instead of the parsed content. |
| 90 | +
|
| 91 | + For more information, see https://www.github.com/stainless-sdks/replicate-client-python#accessing-raw-response-data-eg-headers |
| 92 | + """ |
| 93 | + return AsyncAccountsResourceWithRawResponse(self) |
| 94 | + |
| 95 | + @cached_property |
| 96 | + def with_streaming_response(self) -> AsyncAccountsResourceWithStreamingResponse: |
| 97 | + """ |
| 98 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 99 | +
|
| 100 | + For more information, see https://www.github.com/stainless-sdks/replicate-client-python#with_streaming_response |
| 101 | + """ |
| 102 | + return AsyncAccountsResourceWithStreamingResponse(self) |
| 103 | + |
| 104 | + async def list( |
| 105 | + self, |
| 106 | + *, |
| 107 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 108 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 109 | + extra_headers: Headers | None = None, |
| 110 | + extra_query: Query | None = None, |
| 111 | + extra_body: Body | None = None, |
| 112 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 113 | + ) -> AccountListResponse: |
| 114 | + """ |
| 115 | + Returns information about the user or organization associated with the provided |
| 116 | + API token. |
| 117 | +
|
| 118 | + Example cURL request: |
| 119 | +
|
| 120 | + ```console |
| 121 | + curl -s \\ |
| 122 | + -H "Authorization: Bearer $REPLICATE_API_TOKEN" \\ |
| 123 | + https://api.replicate.com/v1/account |
| 124 | + ``` |
| 125 | +
|
| 126 | + The response will be a JSON object describing the account: |
| 127 | +
|
| 128 | + ```json |
| 129 | + { |
| 130 | + "type": "organization", |
| 131 | + "username": "acme", |
| 132 | + "name": "Acme Corp, Inc.", |
| 133 | + "github_url": "https://github.com/acme" |
| 134 | + } |
| 135 | + ``` |
| 136 | + """ |
| 137 | + return await self._get( |
| 138 | + "/account", |
| 139 | + options=make_request_options( |
| 140 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 141 | + ), |
| 142 | + cast_to=AccountListResponse, |
| 143 | + ) |
| 144 | + |
| 145 | + |
| 146 | +class AccountsResourceWithRawResponse: |
| 147 | + def __init__(self, accounts: AccountsResource) -> None: |
| 148 | + self._accounts = accounts |
| 149 | + |
| 150 | + self.list = to_raw_response_wrapper( |
| 151 | + accounts.list, |
| 152 | + ) |
| 153 | + |
| 154 | + |
| 155 | +class AsyncAccountsResourceWithRawResponse: |
| 156 | + def __init__(self, accounts: AsyncAccountsResource) -> None: |
| 157 | + self._accounts = accounts |
| 158 | + |
| 159 | + self.list = async_to_raw_response_wrapper( |
| 160 | + accounts.list, |
| 161 | + ) |
| 162 | + |
| 163 | + |
| 164 | +class AccountsResourceWithStreamingResponse: |
| 165 | + def __init__(self, accounts: AccountsResource) -> None: |
| 166 | + self._accounts = accounts |
| 167 | + |
| 168 | + self.list = to_streamed_response_wrapper( |
| 169 | + accounts.list, |
| 170 | + ) |
| 171 | + |
| 172 | + |
| 173 | +class AsyncAccountsResourceWithStreamingResponse: |
| 174 | + def __init__(self, accounts: AsyncAccountsResource) -> None: |
| 175 | + self._accounts = accounts |
| 176 | + |
| 177 | + self.list = async_to_streamed_response_wrapper( |
| 178 | + accounts.list, |
| 179 | + ) |
0 commit comments