| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import httpx2 |
| 4 |
|
| 5 |
from .users import ( |
| 6 |
Users, |
| 7 |
AsyncUsers, |
| 8 |
UsersWithRawResponse, |
| 9 |
AsyncUsersWithRawResponse, |
| 10 |
UsersWithStreamingResponse, |
| 11 |
AsyncUsersWithStreamingResponse, |
| 12 |
) |
| 13 |
from .invites import ( |
| 14 |
Invites, |
| 15 |
AsyncInvites, |
| 16 |
InvitesWithRawResponse, |
| 17 |
AsyncInvitesWithRawResponse, |
| 18 |
InvitesWithStreamingResponse, |
| 19 |
AsyncInvitesWithStreamingResponse, |
| 20 |
) |
| 21 |
from .api_keys import ( |
| 22 |
APIKeys, |
| 23 |
AsyncAPIKeys, |
| 24 |
APIKeysWithRawResponse, |
| 25 |
AsyncAPIKeysWithRawResponse, |
| 26 |
APIKeysWithStreamingResponse, |
| 27 |
AsyncAPIKeysWithStreamingResponse, |
| 28 |
) |
| 29 |
from ...._types import Body, Query, Headers, NotGiven, not_given |
| 30 |
from ...._compat import cached_property |
| 31 |
from .rate_limits import ( |
| 32 |
RateLimits, |
| 33 |
AsyncRateLimits, |
| 34 |
RateLimitsWithRawResponse, |
| 35 |
AsyncRateLimitsWithRawResponse, |
| 36 |
RateLimitsWithStreamingResponse, |
| 37 |
AsyncRateLimitsWithStreamingResponse, |
| 38 |
) |
| 39 |
from ...._resource import SyncAPIResource, AsyncAPIResource |
| 40 |
from ...._response import ( |
| 41 |
to_raw_response_wrapper, |
| 42 |
to_streamed_response_wrapper, |
| 43 |
async_to_raw_response_wrapper, |
| 44 |
async_to_streamed_response_wrapper, |
| 45 |
) |
| 46 |
from .external_keys import ( |
| 47 |
ExternalKeys, |
| 48 |
AsyncExternalKeys, |
| 49 |
ExternalKeysWithRawResponse, |
| 50 |
AsyncExternalKeysWithRawResponse, |
| 51 |
ExternalKeysWithStreamingResponse, |
| 52 |
AsyncExternalKeysWithStreamingResponse, |
| 53 |
) |
| 54 |
from ...._base_client import make_request_options |
| 55 |
from .compliance_settings import ( |
| 56 |
ComplianceSettings, |
| 57 |
AsyncComplianceSettings, |
| 58 |
ComplianceSettingsWithRawResponse, |
| 59 |
AsyncComplianceSettingsWithRawResponse, |
| 60 |
ComplianceSettingsWithStreamingResponse, |
| 61 |
AsyncComplianceSettingsWithStreamingResponse, |
| 62 |
) |
| 63 |
from .federation.federation import ( |
| 64 |
Federation, |
| 65 |
AsyncFederation, |
| 66 |
FederationWithRawResponse, |
| 67 |
AsyncFederationWithRawResponse, |
| 68 |
FederationWithStreamingResponse, |
| 69 |
AsyncFederationWithStreamingResponse, |
| 70 |
) |
| 71 |
from .workspaces.workspaces import ( |
| 72 |
Workspaces, |
| 73 |
AsyncWorkspaces, |
| 74 |
WorkspacesWithRawResponse, |
| 75 |
AsyncWorkspacesWithRawResponse, |
| 76 |
WorkspacesWithStreamingResponse, |
| 77 |
AsyncWorkspacesWithStreamingResponse, |
| 78 |
) |
| 79 |
from ....types.beta.beta_organization import BetaOrganization |
| 80 |
from .service_accounts.service_accounts import ( |
| 81 |
ServiceAccounts, |
| 82 |
AsyncServiceAccounts, |
| 83 |
ServiceAccountsWithRawResponse, |
| 84 |
AsyncServiceAccountsWithRawResponse, |
| 85 |
ServiceAccountsWithStreamingResponse, |
| 86 |
AsyncServiceAccountsWithStreamingResponse, |
| 87 |
) |
| 88 |
|
| 89 |
__all__ = ["Organization", "AsyncOrganization"] |
| 90 |
|
| 91 |
|
| 92 |
class Organization(SyncAPIResource): |
| 93 |
@cached_property |
| 94 |
def api_keys(self) -> APIKeys: |
| 95 |
return APIKeys(self._client) |
| 96 |
|
| 97 |
@cached_property |
| 98 |
def external_keys(self) -> ExternalKeys: |
| 99 |
return ExternalKeys(self._client) |
| 100 |
|
| 101 |
@cached_property |
| 102 |
def federation(self) -> Federation: |
| 103 |
return Federation(self._client) |
| 104 |
|
| 105 |
@cached_property |
| 106 |
def invites(self) -> Invites: |
| 107 |
return Invites(self._client) |
| 108 |
|
| 109 |
@cached_property |
| 110 |
def service_accounts(self) -> ServiceAccounts: |
| 111 |
return ServiceAccounts(self._client) |
| 112 |
|
| 113 |
@cached_property |
| 114 |
def users(self) -> Users: |
| 115 |
return Users(self._client) |
| 116 |
|
| 117 |
@cached_property |
| 118 |
def workspaces(self) -> Workspaces: |
| 119 |
return Workspaces(self._client) |
| 120 |
|
| 121 |
@cached_property |
| 122 |
def rate_limits(self) -> RateLimits: |
| 123 |
return RateLimits(self._client) |
| 124 |
|
| 125 |
@cached_property |
| 126 |
def compliance_settings(self) -> ComplianceSettings: |
| 127 |
return ComplianceSettings(self._client) |
| 128 |
|
| 129 |
@cached_property |
| 130 |
def with_raw_response(self) -> OrganizationWithRawResponse: |
| 131 |
""" |
| 132 |
This property can be used as a prefix for any HTTP method call to return |
| 133 |
the raw response object instead of the parsed content. |
| 134 |
|
| 135 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 136 |
""" |
| 137 |
return OrganizationWithRawResponse(self) |
| 138 |
|
| 139 |
@cached_property |
| 140 |
def with_streaming_response(self) -> OrganizationWithStreamingResponse: |
| 141 |
""" |
| 142 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 143 |
|
| 144 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 145 |
""" |
| 146 |
return OrganizationWithStreamingResponse(self) |
| 147 |
|
| 148 |
def retrieve( |
| 149 |
self, |
| 150 |
*, |
| 151 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 152 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 153 |
extra_headers: Headers | None = None, |
| 154 |
extra_query: Query | None = None, |
| 155 |
extra_body: Body | None = None, |
| 156 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 157 |
) -> BetaOrganization: |
| 158 |
""" |
| 159 |
Retrieve information about the organization associated with the authenticated |
| 160 |
API key. |
| 161 |
""" |
| 162 |
return self._get( |
| 163 |
"/v1/organizations/me?beta=true", |
| 164 |
options=make_request_options( |
| 165 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 166 |
), |
| 167 |
cast_to=BetaOrganization, |
| 168 |
) |
| 169 |
|
| 170 |
|
| 171 |
class AsyncOrganization(AsyncAPIResource): |
| 172 |
@cached_property |
| 173 |
def api_keys(self) -> AsyncAPIKeys: |
| 174 |
return AsyncAPIKeys(self._client) |
| 175 |
|
| 176 |
@cached_property |
| 177 |
def external_keys(self) -> AsyncExternalKeys: |
| 178 |
return AsyncExternalKeys(self._client) |
| 179 |
|
| 180 |
@cached_property |
| 181 |
def federation(self) -> AsyncFederation: |
| 182 |
return AsyncFederation(self._client) |
| 183 |
|
| 184 |
@cached_property |
| 185 |
def invites(self) -> AsyncInvites: |
| 186 |
return AsyncInvites(self._client) |
| 187 |
|
| 188 |
@cached_property |
| 189 |
def service_accounts(self) -> AsyncServiceAccounts: |
| 190 |
return AsyncServiceAccounts(self._client) |
| 191 |
|
| 192 |
@cached_property |
| 193 |
def users(self) -> AsyncUsers: |
| 194 |
return AsyncUsers(self._client) |
| 195 |
|
| 196 |
@cached_property |
| 197 |
def workspaces(self) -> AsyncWorkspaces: |
| 198 |
return AsyncWorkspaces(self._client) |
| 199 |
|
| 200 |
@cached_property |
| 201 |
def rate_limits(self) -> AsyncRateLimits: |
| 202 |
return AsyncRateLimits(self._client) |
| 203 |
|
| 204 |
@cached_property |
| 205 |
def compliance_settings(self) -> AsyncComplianceSettings: |
| 206 |
return AsyncComplianceSettings(self._client) |
| 207 |
|
| 208 |
@cached_property |
| 209 |
def with_raw_response(self) -> AsyncOrganizationWithRawResponse: |
| 210 |
""" |
| 211 |
This property can be used as a prefix for any HTTP method call to return |
| 212 |
the raw response object instead of the parsed content. |
| 213 |
|
| 214 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 215 |
""" |
| 216 |
return AsyncOrganizationWithRawResponse(self) |
| 217 |
|
| 218 |
@cached_property |
| 219 |
def with_streaming_response(self) -> AsyncOrganizationWithStreamingResponse: |
| 220 |
""" |
| 221 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 222 |
|
| 223 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 224 |
""" |
| 225 |
return AsyncOrganizationWithStreamingResponse(self) |
| 226 |
|
| 227 |
async def retrieve( |
| 228 |
self, |
| 229 |
*, |
| 230 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 231 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 232 |
extra_headers: Headers | None = None, |
| 233 |
extra_query: Query | None = None, |
| 234 |
extra_body: Body | None = None, |
| 235 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 236 |
) -> BetaOrganization: |
| 237 |
""" |
| 238 |
Retrieve information about the organization associated with the authenticated |
| 239 |
API key. |
| 240 |
""" |
| 241 |
return await self._get( |
| 242 |
"/v1/organizations/me?beta=true", |
| 243 |
options=make_request_options( |
| 244 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 245 |
), |
| 246 |
cast_to=BetaOrganization, |
| 247 |
) |
| 248 |
|
| 249 |
|
| 250 |
class OrganizationWithRawResponse: |
| 251 |
def __init__(self, organization: Organization) -> None: |
| 252 |
self._organization = organization |
| 253 |
|
| 254 |
self.retrieve = to_raw_response_wrapper( |
| 255 |
organization.retrieve, |
| 256 |
) |
| 257 |
|
| 258 |
@cached_property |
| 259 |
def api_keys(self) -> APIKeysWithRawResponse: |
| 260 |
return APIKeysWithRawResponse(self._organization.api_keys) |
| 261 |
|
| 262 |
@cached_property |
| 263 |
def external_keys(self) -> ExternalKeysWithRawResponse: |
| 264 |
return ExternalKeysWithRawResponse(self._organization.external_keys) |
| 265 |
|
| 266 |
@cached_property |
| 267 |
def federation(self) -> FederationWithRawResponse: |
| 268 |
return FederationWithRawResponse(self._organization.federation) |
| 269 |
|
| 270 |
@cached_property |
| 271 |
def invites(self) -> InvitesWithRawResponse: |
| 272 |
return InvitesWithRawResponse(self._organization.invites) |
| 273 |
|
| 274 |
@cached_property |
| 275 |
def service_accounts(self) -> ServiceAccountsWithRawResponse: |
| 276 |
return ServiceAccountsWithRawResponse(self._organization.service_accounts) |
| 277 |
|
| 278 |
@cached_property |
| 279 |
def users(self) -> UsersWithRawResponse: |
| 280 |
return UsersWithRawResponse(self._organization.users) |
| 281 |
|
| 282 |
@cached_property |
| 283 |
def workspaces(self) -> WorkspacesWithRawResponse: |
| 284 |
return WorkspacesWithRawResponse(self._organization.workspaces) |
| 285 |
|
| 286 |
@cached_property |
| 287 |
def rate_limits(self) -> RateLimitsWithRawResponse: |
| 288 |
return RateLimitsWithRawResponse(self._organization.rate_limits) |
| 289 |
|
| 290 |
@cached_property |
| 291 |
def compliance_settings(self) -> ComplianceSettingsWithRawResponse: |
| 292 |
return ComplianceSettingsWithRawResponse(self._organization.compliance_settings) |
| 293 |
|
| 294 |
|
| 295 |
class AsyncOrganizationWithRawResponse: |
| 296 |
def __init__(self, organization: AsyncOrganization) -> None: |
| 297 |
self._organization = organization |
| 298 |
|
| 299 |
self.retrieve = async_to_raw_response_wrapper( |
| 300 |
organization.retrieve, |
| 301 |
) |
| 302 |
|
| 303 |
@cached_property |
| 304 |
def api_keys(self) -> AsyncAPIKeysWithRawResponse: |
| 305 |
return AsyncAPIKeysWithRawResponse(self._organization.api_keys) |
| 306 |
|
| 307 |
@cached_property |
| 308 |
def external_keys(self) -> AsyncExternalKeysWithRawResponse: |
| 309 |
return AsyncExternalKeysWithRawResponse(self._organization.external_keys) |
| 310 |
|
| 311 |
@cached_property |
| 312 |
def federation(self) -> AsyncFederationWithRawResponse: |
| 313 |
return AsyncFederationWithRawResponse(self._organization.federation) |
| 314 |
|
| 315 |
@cached_property |
| 316 |
def invites(self) -> AsyncInvitesWithRawResponse: |
| 317 |
return AsyncInvitesWithRawResponse(self._organization.invites) |
| 318 |
|
| 319 |
@cached_property |
| 320 |
def service_accounts(self) -> AsyncServiceAccountsWithRawResponse: |
| 321 |
return AsyncServiceAccountsWithRawResponse(self._organization.service_accounts) |
| 322 |
|
| 323 |
@cached_property |
| 324 |
def users(self) -> AsyncUsersWithRawResponse: |
| 325 |
return AsyncUsersWithRawResponse(self._organization.users) |
| 326 |
|
| 327 |
@cached_property |
| 328 |
def workspaces(self) -> AsyncWorkspacesWithRawResponse: |
| 329 |
return AsyncWorkspacesWithRawResponse(self._organization.workspaces) |
| 330 |
|
| 331 |
@cached_property |
| 332 |
def rate_limits(self) -> AsyncRateLimitsWithRawResponse: |
| 333 |
return AsyncRateLimitsWithRawResponse(self._organization.rate_limits) |
| 334 |
|
| 335 |
@cached_property |
| 336 |
def compliance_settings(self) -> AsyncComplianceSettingsWithRawResponse: |
| 337 |
return AsyncComplianceSettingsWithRawResponse(self._organization.compliance_settings) |
| 338 |
|
| 339 |
|
| 340 |
class OrganizationWithStreamingResponse: |
| 341 |
def __init__(self, organization: Organization) -> None: |
| 342 |
self._organization = organization |
| 343 |
|
| 344 |
self.retrieve = to_streamed_response_wrapper( |
| 345 |
organization.retrieve, |
| 346 |
) |
| 347 |
|
| 348 |
@cached_property |
| 349 |
def api_keys(self) -> APIKeysWithStreamingResponse: |
| 350 |
return APIKeysWithStreamingResponse(self._organization.api_keys) |
| 351 |
|
| 352 |
@cached_property |
| 353 |
def external_keys(self) -> ExternalKeysWithStreamingResponse: |
| 354 |
return ExternalKeysWithStreamingResponse(self._organization.external_keys) |
| 355 |
|
| 356 |
@cached_property |
| 357 |
def federation(self) -> FederationWithStreamingResponse: |
| 358 |
return FederationWithStreamingResponse(self._organization.federation) |
| 359 |
|
| 360 |
@cached_property |
| 361 |
def invites(self) -> InvitesWithStreamingResponse: |
| 362 |
return InvitesWithStreamingResponse(self._organization.invites) |
| 363 |
|
| 364 |
@cached_property |
| 365 |
def service_accounts(self) -> ServiceAccountsWithStreamingResponse: |
| 366 |
return ServiceAccountsWithStreamingResponse(self._organization.service_accounts) |
| 367 |
|
| 368 |
@cached_property |
| 369 |
def users(self) -> UsersWithStreamingResponse: |
| 370 |
return UsersWithStreamingResponse(self._organization.users) |
| 371 |
|
| 372 |
@cached_property |
| 373 |
def workspaces(self) -> WorkspacesWithStreamingResponse: |
| 374 |
return WorkspacesWithStreamingResponse(self._organization.workspaces) |
| 375 |
|
| 376 |
@cached_property |
| 377 |
def rate_limits(self) -> RateLimitsWithStreamingResponse: |
| 378 |
return RateLimitsWithStreamingResponse(self._organization.rate_limits) |
| 379 |
|
| 380 |
@cached_property |
| 381 |
def compliance_settings(self) -> ComplianceSettingsWithStreamingResponse: |
| 382 |
return ComplianceSettingsWithStreamingResponse(self._organization.compliance_settings) |
| 383 |
|
| 384 |
|
| 385 |
class AsyncOrganizationWithStreamingResponse: |
| 386 |
def __init__(self, organization: AsyncOrganization) -> None: |
| 387 |
self._organization = organization |
| 388 |
|
| 389 |
self.retrieve = async_to_streamed_response_wrapper( |
| 390 |
organization.retrieve, |
| 391 |
) |
| 392 |
|
| 393 |
@cached_property |
| 394 |
def api_keys(self) -> AsyncAPIKeysWithStreamingResponse: |
| 395 |
return AsyncAPIKeysWithStreamingResponse(self._organization.api_keys) |
| 396 |
|
| 397 |
@cached_property |
| 398 |
def external_keys(self) -> AsyncExternalKeysWithStreamingResponse: |
| 399 |
return AsyncExternalKeysWithStreamingResponse(self._organization.external_keys) |
| 400 |
|
| 401 |
@cached_property |
| 402 |
def federation(self) -> AsyncFederationWithStreamingResponse: |
| 403 |
return AsyncFederationWithStreamingResponse(self._organization.federation) |
| 404 |
|
| 405 |
@cached_property |
| 406 |
def invites(self) -> AsyncInvitesWithStreamingResponse: |
| 407 |
return AsyncInvitesWithStreamingResponse(self._organization.invites) |
| 408 |
|
| 409 |
@cached_property |
| 410 |
def service_accounts(self) -> AsyncServiceAccountsWithStreamingResponse: |
| 411 |
return AsyncServiceAccountsWithStreamingResponse(self._organization.service_accounts) |
| 412 |
|
| 413 |
@cached_property |
| 414 |
def users(self) -> AsyncUsersWithStreamingResponse: |
| 415 |
return AsyncUsersWithStreamingResponse(self._organization.users) |
| 416 |
|
| 417 |
@cached_property |
| 418 |
def workspaces(self) -> AsyncWorkspacesWithStreamingResponse: |
| 419 |
return AsyncWorkspacesWithStreamingResponse(self._organization.workspaces) |
| 420 |
|
| 421 |
@cached_property |
| 422 |
def rate_limits(self) -> AsyncRateLimitsWithStreamingResponse: |
| 423 |
return AsyncRateLimitsWithStreamingResponse(self._organization.rate_limits) |
| 424 |
|
| 425 |
@cached_property |
| 426 |
def compliance_settings(self) -> AsyncComplianceSettingsWithStreamingResponse: |
| 427 |
return AsyncComplianceSettingsWithStreamingResponse(self._organization.compliance_settings) |