Debian Codegraph @

src/anthropic/resources/beta/organization/compliance_settings.py

raw
1 from __future__ import annotations
2
3 import httpx2
4
5 from ...._types import Body, Query, Headers, NotGiven, not_given
6 from ...._compat import cached_property
7 from ...._resource import SyncAPIResource, AsyncAPIResource
8 from ...._response import (
9 to_raw_response_wrapper,
10 to_streamed_response_wrapper,
11 async_to_raw_response_wrapper,
12 async_to_streamed_response_wrapper,
13 )
14 from ...._base_client import make_request_options
15 from ....types.beta.organization import BetaComplianceSettingsStateParam
16 from ....types.beta.organization.beta_compliance_settings import BetaComplianceSettings
17 from ....types.beta.organization.beta_compliance_settings_state_param import BetaComplianceSettingsStateParam
18
19 __all__ = ["ComplianceSettings", "AsyncComplianceSettings"]
20
21
22 class ComplianceSettings(SyncAPIResource):
23 @cached_property
24 def with_raw_response(self) -> ComplianceSettingsWithRawResponse:
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/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
30 """
31 return ComplianceSettingsWithRawResponse(self)
32
33 @cached_property
34 def with_streaming_response(self) -> ComplianceSettingsWithStreamingResponse:
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/anthropics/anthropic-sdk-python#with_streaming_response
39 """
40 return ComplianceSettingsWithStreamingResponse(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 | httpx2.Timeout | None | NotGiven = not_given,
51 ) -> BetaComplianceSettings:
52 """
53 Retrieve your organization's Compliance Settings.
54
55 Compliance Settings is a singleton resource: there is exactly one per
56 organization, addressed without an identifier. The `state` field reflects
57 whether the Compliance API is enabled. An organization with a parent
58 organization reads the state inherited from the parent's configuration.
59 """
60 return self._get(
61 "/v1/organizations/compliance_settings?beta=true",
62 options=make_request_options(
63 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
64 ),
65 cast_to=BetaComplianceSettings,
66 )
67
68 def update(
69 self,
70 *,
71 state: BetaComplianceSettingsStateParam,
72 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
73 # The extra values given here take precedence over values defined on the client or passed to this method.
74 extra_headers: Headers | None = None,
75 extra_query: Query | None = None,
76 extra_body: Body | None = None,
77 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
78 ) -> BetaComplianceSettings:
79 """
80 Update your organization's Compliance Settings.
81
82 Setting `state` to `enabled` turns on the Compliance API and begins capturing
83 organization activity events. Setting it to `disabled` turns both off. `state`
84 reflects whether the Compliance API is enabled.
85
86 A request that sets `state` to its current value succeeds and leaves the
87 resource unchanged. A `disabled` request stays in effect until a later `enabled`
88 request or the organization's next provisioning action that enables Access
89 Transparency: enabling Access Transparency also enables the Compliance API,
90 which serves its activity events, so such provisioning (including re-runs)
91 re-enables the Compliance API even after a `disabled` request. Automated
92 provisioning never disables compliance settings.
93
94 Args:
95 state: Desired state. Accepts the string shorthand "enabled" or "disabled" in place of
96 the object form; the response always returns the canonical object form.
97
98 extra_headers: Send extra headers
99
100 extra_query: Add additional query parameters to the request
101
102 extra_body: Add additional JSON properties to the request
103
104 timeout: Override the client-level default timeout for this request, in seconds
105 """
106 return self._post(
107 "/v1/organizations/compliance_settings?beta=true",
108 body={"state": state},
109 options=make_request_options(
110 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
111 ),
112 cast_to=BetaComplianceSettings,
113 )
114
115
116 class AsyncComplianceSettings(AsyncAPIResource):
117 @cached_property
118 def with_raw_response(self) -> AsyncComplianceSettingsWithRawResponse:
119 """
120 This property can be used as a prefix for any HTTP method call to return
121 the raw response object instead of the parsed content.
122
123 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
124 """
125 return AsyncComplianceSettingsWithRawResponse(self)
126
127 @cached_property
128 def with_streaming_response(self) -> AsyncComplianceSettingsWithStreamingResponse:
129 """
130 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
131
132 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
133 """
134 return AsyncComplianceSettingsWithStreamingResponse(self)
135
136 async def retrieve(
137 self,
138 *,
139 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
140 # The extra values given here take precedence over values defined on the client or passed to this method.
141 extra_headers: Headers | None = None,
142 extra_query: Query | None = None,
143 extra_body: Body | None = None,
144 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
145 ) -> BetaComplianceSettings:
146 """
147 Retrieve your organization's Compliance Settings.
148
149 Compliance Settings is a singleton resource: there is exactly one per
150 organization, addressed without an identifier. The `state` field reflects
151 whether the Compliance API is enabled. An organization with a parent
152 organization reads the state inherited from the parent's configuration.
153 """
154 return await self._get(
155 "/v1/organizations/compliance_settings?beta=true",
156 options=make_request_options(
157 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
158 ),
159 cast_to=BetaComplianceSettings,
160 )
161
162 async def update(
163 self,
164 *,
165 state: BetaComplianceSettingsStateParam,
166 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
167 # The extra values given here take precedence over values defined on the client or passed to this method.
168 extra_headers: Headers | None = None,
169 extra_query: Query | None = None,
170 extra_body: Body | None = None,
171 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
172 ) -> BetaComplianceSettings:
173 """
174 Update your organization's Compliance Settings.
175
176 Setting `state` to `enabled` turns on the Compliance API and begins capturing
177 organization activity events. Setting it to `disabled` turns both off. `state`
178 reflects whether the Compliance API is enabled.
179
180 A request that sets `state` to its current value succeeds and leaves the
181 resource unchanged. A `disabled` request stays in effect until a later `enabled`
182 request or the organization's next provisioning action that enables Access
183 Transparency: enabling Access Transparency also enables the Compliance API,
184 which serves its activity events, so such provisioning (including re-runs)
185 re-enables the Compliance API even after a `disabled` request. Automated
186 provisioning never disables compliance settings.
187
188 Args:
189 state: Desired state. Accepts the string shorthand "enabled" or "disabled" in place of
190 the object form; the response always returns the canonical object form.
191
192 extra_headers: Send extra headers
193
194 extra_query: Add additional query parameters to the request
195
196 extra_body: Add additional JSON properties to the request
197
198 timeout: Override the client-level default timeout for this request, in seconds
199 """
200 return await self._post(
201 "/v1/organizations/compliance_settings?beta=true",
202 body={"state": state},
203 options=make_request_options(
204 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
205 ),
206 cast_to=BetaComplianceSettings,
207 )
208
209
210 class ComplianceSettingsWithRawResponse:
211 def __init__(self, compliance_settings: ComplianceSettings) -> None:
212 self._compliance_settings = compliance_settings
213
214 self.retrieve = to_raw_response_wrapper(
215 compliance_settings.retrieve,
216 )
217 self.update = to_raw_response_wrapper(
218 compliance_settings.update,
219 )
220
221
222 class AsyncComplianceSettingsWithRawResponse:
223 def __init__(self, compliance_settings: AsyncComplianceSettings) -> None:
224 self._compliance_settings = compliance_settings
225
226 self.retrieve = async_to_raw_response_wrapper(
227 compliance_settings.retrieve,
228 )
229 self.update = async_to_raw_response_wrapper(
230 compliance_settings.update,
231 )
232
233
234 class ComplianceSettingsWithStreamingResponse:
235 def __init__(self, compliance_settings: ComplianceSettings) -> None:
236 self._compliance_settings = compliance_settings
237
238 self.retrieve = to_streamed_response_wrapper(
239 compliance_settings.retrieve,
240 )
241 self.update = to_streamed_response_wrapper(
242 compliance_settings.update,
243 )
244
245
246 class AsyncComplianceSettingsWithStreamingResponse:
247 def __init__(self, compliance_settings: AsyncComplianceSettings) -> None:
248 self._compliance_settings = compliance_settings
249
250 self.retrieve = async_to_streamed_response_wrapper(
251 compliance_settings.retrieve,
252 )
253 self.update = async_to_streamed_response_wrapper(
254 compliance_settings.update,
255 )