|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing_extensions import Literal |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from .... import _legacy_response |
| 10 | +from ...._types import Body, Query, Headers, NotGiven, not_given |
| 11 | +from ...._utils import maybe_transform, async_maybe_transform |
| 12 | +from ...._compat import cached_property |
| 13 | +from ...._resource import SyncAPIResource, AsyncAPIResource |
| 14 | +from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper |
| 15 | +from ...._base_client import make_request_options |
| 16 | +from ....types.admin.organization import data_retention_update_params |
| 17 | +from ....types.admin.organization.organization_data_retention import OrganizationDataRetention |
| 18 | + |
| 19 | +__all__ = ["DataRetention", "AsyncDataRetention"] |
| 20 | + |
| 21 | + |
| 22 | +class DataRetention(SyncAPIResource): |
| 23 | + @cached_property |
| 24 | + def with_raw_response(self) -> DataRetentionWithRawResponse: |
| 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/openai/openai-python#accessing-raw-response-data-eg-headers |
| 30 | + """ |
| 31 | + return DataRetentionWithRawResponse(self) |
| 32 | + |
| 33 | + @cached_property |
| 34 | + def with_streaming_response(self) -> DataRetentionWithStreamingResponse: |
| 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/openai/openai-python#with_streaming_response |
| 39 | + """ |
| 40 | + return DataRetentionWithStreamingResponse(self) |
| 41 | + |
| 42 | + def retrieve( |
| 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 | + ) -> OrganizationDataRetention: |
| 52 | + """Retrieves organization data retention controls.""" |
| 53 | + return self._get( |
| 54 | + "/organization/data_retention", |
| 55 | + options=make_request_options( |
| 56 | + extra_headers=extra_headers, |
| 57 | + extra_query=extra_query, |
| 58 | + extra_body=extra_body, |
| 59 | + timeout=timeout, |
| 60 | + security={"admin_api_key_auth": True}, |
| 61 | + ), |
| 62 | + cast_to=OrganizationDataRetention, |
| 63 | + ) |
| 64 | + |
| 65 | + def update( |
| 66 | + self, |
| 67 | + *, |
| 68 | + retention_type: Literal[ |
| 69 | + "zero_data_retention", |
| 70 | + "modified_abuse_monitoring", |
| 71 | + "enhanced_zero_data_retention", |
| 72 | + "enhanced_modified_abuse_monitoring", |
| 73 | + ], |
| 74 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 75 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 76 | + extra_headers: Headers | None = None, |
| 77 | + extra_query: Query | None = None, |
| 78 | + extra_body: Body | None = None, |
| 79 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 80 | + ) -> OrganizationDataRetention: |
| 81 | + """ |
| 82 | + Updates organization data retention controls. |
| 83 | +
|
| 84 | + Args: |
| 85 | + retention_type: The desired organization data retention type. |
| 86 | +
|
| 87 | + extra_headers: Send extra headers |
| 88 | +
|
| 89 | + extra_query: Add additional query parameters to the request |
| 90 | +
|
| 91 | + extra_body: Add additional JSON properties to the request |
| 92 | +
|
| 93 | + timeout: Override the client-level default timeout for this request, in seconds |
| 94 | + """ |
| 95 | + return self._post( |
| 96 | + "/organization/data_retention", |
| 97 | + body=maybe_transform( |
| 98 | + {"retention_type": retention_type}, data_retention_update_params.DataRetentionUpdateParams |
| 99 | + ), |
| 100 | + options=make_request_options( |
| 101 | + extra_headers=extra_headers, |
| 102 | + extra_query=extra_query, |
| 103 | + extra_body=extra_body, |
| 104 | + timeout=timeout, |
| 105 | + security={"admin_api_key_auth": True}, |
| 106 | + ), |
| 107 | + cast_to=OrganizationDataRetention, |
| 108 | + ) |
| 109 | + |
| 110 | + |
| 111 | +class AsyncDataRetention(AsyncAPIResource): |
| 112 | + @cached_property |
| 113 | + def with_raw_response(self) -> AsyncDataRetentionWithRawResponse: |
| 114 | + """ |
| 115 | + This property can be used as a prefix for any HTTP method call to return |
| 116 | + the raw response object instead of the parsed content. |
| 117 | +
|
| 118 | + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers |
| 119 | + """ |
| 120 | + return AsyncDataRetentionWithRawResponse(self) |
| 121 | + |
| 122 | + @cached_property |
| 123 | + def with_streaming_response(self) -> AsyncDataRetentionWithStreamingResponse: |
| 124 | + """ |
| 125 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 126 | +
|
| 127 | + For more information, see https://www.github.com/openai/openai-python#with_streaming_response |
| 128 | + """ |
| 129 | + return AsyncDataRetentionWithStreamingResponse(self) |
| 130 | + |
| 131 | + async def retrieve( |
| 132 | + self, |
| 133 | + *, |
| 134 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 135 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 136 | + extra_headers: Headers | None = None, |
| 137 | + extra_query: Query | None = None, |
| 138 | + extra_body: Body | None = None, |
| 139 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 140 | + ) -> OrganizationDataRetention: |
| 141 | + """Retrieves organization data retention controls.""" |
| 142 | + return await self._get( |
| 143 | + "/organization/data_retention", |
| 144 | + options=make_request_options( |
| 145 | + extra_headers=extra_headers, |
| 146 | + extra_query=extra_query, |
| 147 | + extra_body=extra_body, |
| 148 | + timeout=timeout, |
| 149 | + security={"admin_api_key_auth": True}, |
| 150 | + ), |
| 151 | + cast_to=OrganizationDataRetention, |
| 152 | + ) |
| 153 | + |
| 154 | + async def update( |
| 155 | + self, |
| 156 | + *, |
| 157 | + retention_type: Literal[ |
| 158 | + "zero_data_retention", |
| 159 | + "modified_abuse_monitoring", |
| 160 | + "enhanced_zero_data_retention", |
| 161 | + "enhanced_modified_abuse_monitoring", |
| 162 | + ], |
| 163 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 164 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 165 | + extra_headers: Headers | None = None, |
| 166 | + extra_query: Query | None = None, |
| 167 | + extra_body: Body | None = None, |
| 168 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 169 | + ) -> OrganizationDataRetention: |
| 170 | + """ |
| 171 | + Updates organization data retention controls. |
| 172 | +
|
| 173 | + Args: |
| 174 | + retention_type: The desired organization data retention type. |
| 175 | +
|
| 176 | + extra_headers: Send extra headers |
| 177 | +
|
| 178 | + extra_query: Add additional query parameters to the request |
| 179 | +
|
| 180 | + extra_body: Add additional JSON properties to the request |
| 181 | +
|
| 182 | + timeout: Override the client-level default timeout for this request, in seconds |
| 183 | + """ |
| 184 | + return await self._post( |
| 185 | + "/organization/data_retention", |
| 186 | + body=await async_maybe_transform( |
| 187 | + {"retention_type": retention_type}, data_retention_update_params.DataRetentionUpdateParams |
| 188 | + ), |
| 189 | + options=make_request_options( |
| 190 | + extra_headers=extra_headers, |
| 191 | + extra_query=extra_query, |
| 192 | + extra_body=extra_body, |
| 193 | + timeout=timeout, |
| 194 | + security={"admin_api_key_auth": True}, |
| 195 | + ), |
| 196 | + cast_to=OrganizationDataRetention, |
| 197 | + ) |
| 198 | + |
| 199 | + |
| 200 | +class DataRetentionWithRawResponse: |
| 201 | + def __init__(self, data_retention: DataRetention) -> None: |
| 202 | + self._data_retention = data_retention |
| 203 | + |
| 204 | + self.retrieve = _legacy_response.to_raw_response_wrapper( |
| 205 | + data_retention.retrieve, |
| 206 | + ) |
| 207 | + self.update = _legacy_response.to_raw_response_wrapper( |
| 208 | + data_retention.update, |
| 209 | + ) |
| 210 | + |
| 211 | + |
| 212 | +class AsyncDataRetentionWithRawResponse: |
| 213 | + def __init__(self, data_retention: AsyncDataRetention) -> None: |
| 214 | + self._data_retention = data_retention |
| 215 | + |
| 216 | + self.retrieve = _legacy_response.async_to_raw_response_wrapper( |
| 217 | + data_retention.retrieve, |
| 218 | + ) |
| 219 | + self.update = _legacy_response.async_to_raw_response_wrapper( |
| 220 | + data_retention.update, |
| 221 | + ) |
| 222 | + |
| 223 | + |
| 224 | +class DataRetentionWithStreamingResponse: |
| 225 | + def __init__(self, data_retention: DataRetention) -> None: |
| 226 | + self._data_retention = data_retention |
| 227 | + |
| 228 | + self.retrieve = to_streamed_response_wrapper( |
| 229 | + data_retention.retrieve, |
| 230 | + ) |
| 231 | + self.update = to_streamed_response_wrapper( |
| 232 | + data_retention.update, |
| 233 | + ) |
| 234 | + |
| 235 | + |
| 236 | +class AsyncDataRetentionWithStreamingResponse: |
| 237 | + def __init__(self, data_retention: AsyncDataRetention) -> None: |
| 238 | + self._data_retention = data_retention |
| 239 | + |
| 240 | + self.retrieve = async_to_streamed_response_wrapper( |
| 241 | + data_retention.retrieve, |
| 242 | + ) |
| 243 | + self.update = async_to_streamed_response_wrapper( |
| 244 | + data_retention.update, |
| 245 | + ) |
0 commit comments