|
| 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 profile_property_params |
| 8 | +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
| 9 | +from .._utils import maybe_transform, async_maybe_transform |
| 10 | +from .._compat import cached_property |
| 11 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 12 | +from .._response import ( |
| 13 | + to_raw_response_wrapper, |
| 14 | + to_streamed_response_wrapper, |
| 15 | + async_to_raw_response_wrapper, |
| 16 | + async_to_streamed_response_wrapper, |
| 17 | +) |
| 18 | +from .._base_client import make_request_options |
| 19 | +from ..types.profile_property_response import ProfilePropertyResponse |
| 20 | + |
| 21 | +__all__ = ["ProfileResource", "AsyncProfileResource"] |
| 22 | + |
| 23 | + |
| 24 | +class ProfileResource(SyncAPIResource): |
| 25 | + @cached_property |
| 26 | + def with_raw_response(self) -> ProfileResourceWithRawResponse: |
| 27 | + """ |
| 28 | + This property can be used as a prefix for any HTTP method call to return |
| 29 | + the raw response object instead of the parsed content. |
| 30 | +
|
| 31 | + For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers |
| 32 | + """ |
| 33 | + return ProfileResourceWithRawResponse(self) |
| 34 | + |
| 35 | + @cached_property |
| 36 | + def with_streaming_response(self) -> ProfileResourceWithStreamingResponse: |
| 37 | + """ |
| 38 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 39 | +
|
| 40 | + For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response |
| 41 | + """ |
| 42 | + return ProfileResourceWithStreamingResponse(self) |
| 43 | + |
| 44 | + def property( |
| 45 | + self, |
| 46 | + *, |
| 47 | + container_tag: str, |
| 48 | + q: str | Omit = omit, |
| 49 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 50 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 51 | + extra_headers: Headers | None = None, |
| 52 | + extra_query: Query | None = None, |
| 53 | + extra_body: Body | None = None, |
| 54 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 55 | + ) -> ProfilePropertyResponse: |
| 56 | + """ |
| 57 | + Get user profile with optional search results |
| 58 | +
|
| 59 | + Args: |
| 60 | + container_tag: Tag to filter the profile by. This can be an ID for your user, a project ID, or |
| 61 | + any other identifier you wish to use to filter memories. |
| 62 | +
|
| 63 | + q: Optional search query to include search results in the response |
| 64 | +
|
| 65 | + extra_headers: Send extra headers |
| 66 | +
|
| 67 | + extra_query: Add additional query parameters to the request |
| 68 | +
|
| 69 | + extra_body: Add additional JSON properties to the request |
| 70 | +
|
| 71 | + timeout: Override the client-level default timeout for this request, in seconds |
| 72 | + """ |
| 73 | + return self._post( |
| 74 | + "/v4/profile", |
| 75 | + body=maybe_transform( |
| 76 | + { |
| 77 | + "container_tag": container_tag, |
| 78 | + "q": q, |
| 79 | + }, |
| 80 | + profile_property_params.ProfilePropertyParams, |
| 81 | + ), |
| 82 | + options=make_request_options( |
| 83 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 84 | + ), |
| 85 | + cast_to=ProfilePropertyResponse, |
| 86 | + ) |
| 87 | + |
| 88 | + |
| 89 | +class AsyncProfileResource(AsyncAPIResource): |
| 90 | + @cached_property |
| 91 | + def with_raw_response(self) -> AsyncProfileResourceWithRawResponse: |
| 92 | + """ |
| 93 | + This property can be used as a prefix for any HTTP method call to return |
| 94 | + the raw response object instead of the parsed content. |
| 95 | +
|
| 96 | + For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers |
| 97 | + """ |
| 98 | + return AsyncProfileResourceWithRawResponse(self) |
| 99 | + |
| 100 | + @cached_property |
| 101 | + def with_streaming_response(self) -> AsyncProfileResourceWithStreamingResponse: |
| 102 | + """ |
| 103 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 104 | +
|
| 105 | + For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response |
| 106 | + """ |
| 107 | + return AsyncProfileResourceWithStreamingResponse(self) |
| 108 | + |
| 109 | + async def property( |
| 110 | + self, |
| 111 | + *, |
| 112 | + container_tag: str, |
| 113 | + q: str | Omit = omit, |
| 114 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 115 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 116 | + extra_headers: Headers | None = None, |
| 117 | + extra_query: Query | None = None, |
| 118 | + extra_body: Body | None = None, |
| 119 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 120 | + ) -> ProfilePropertyResponse: |
| 121 | + """ |
| 122 | + Get user profile with optional search results |
| 123 | +
|
| 124 | + Args: |
| 125 | + container_tag: Tag to filter the profile by. This can be an ID for your user, a project ID, or |
| 126 | + any other identifier you wish to use to filter memories. |
| 127 | +
|
| 128 | + q: Optional search query to include search results in the response |
| 129 | +
|
| 130 | + extra_headers: Send extra headers |
| 131 | +
|
| 132 | + extra_query: Add additional query parameters to the request |
| 133 | +
|
| 134 | + extra_body: Add additional JSON properties to the request |
| 135 | +
|
| 136 | + timeout: Override the client-level default timeout for this request, in seconds |
| 137 | + """ |
| 138 | + return await self._post( |
| 139 | + "/v4/profile", |
| 140 | + body=await async_maybe_transform( |
| 141 | + { |
| 142 | + "container_tag": container_tag, |
| 143 | + "q": q, |
| 144 | + }, |
| 145 | + profile_property_params.ProfilePropertyParams, |
| 146 | + ), |
| 147 | + options=make_request_options( |
| 148 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 149 | + ), |
| 150 | + cast_to=ProfilePropertyResponse, |
| 151 | + ) |
| 152 | + |
| 153 | + |
| 154 | +class ProfileResourceWithRawResponse: |
| 155 | + def __init__(self, profile: ProfileResource) -> None: |
| 156 | + self._profile = profile |
| 157 | + |
| 158 | + self.property = to_raw_response_wrapper( |
| 159 | + profile.property, |
| 160 | + ) |
| 161 | + |
| 162 | + |
| 163 | +class AsyncProfileResourceWithRawResponse: |
| 164 | + def __init__(self, profile: AsyncProfileResource) -> None: |
| 165 | + self._profile = profile |
| 166 | + |
| 167 | + self.property = async_to_raw_response_wrapper( |
| 168 | + profile.property, |
| 169 | + ) |
| 170 | + |
| 171 | + |
| 172 | +class ProfileResourceWithStreamingResponse: |
| 173 | + def __init__(self, profile: ProfileResource) -> None: |
| 174 | + self._profile = profile |
| 175 | + |
| 176 | + self.property = to_streamed_response_wrapper( |
| 177 | + profile.property, |
| 178 | + ) |
| 179 | + |
| 180 | + |
| 181 | +class AsyncProfileResourceWithStreamingResponse: |
| 182 | + def __init__(self, profile: AsyncProfileResource) -> None: |
| 183 | + self._profile = profile |
| 184 | + |
| 185 | + self.property = async_to_streamed_response_wrapper( |
| 186 | + profile.property, |
| 187 | + ) |
0 commit comments