|
| 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 admin_create_organization_params |
| 8 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 9 | +from .._utils import ( |
| 10 | + maybe_transform, |
| 11 | + async_maybe_transform, |
| 12 | +) |
| 13 | +from .._compat import cached_property |
| 14 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 15 | +from .._response import ( |
| 16 | + to_raw_response_wrapper, |
| 17 | + to_streamed_response_wrapper, |
| 18 | + async_to_raw_response_wrapper, |
| 19 | + async_to_streamed_response_wrapper, |
| 20 | +) |
| 21 | +from .._base_client import make_request_options |
| 22 | +from ..types.admin_create_organization_response import AdminCreateOrganizationResponse |
| 23 | + |
| 24 | +__all__ = ["AdminResource", "AsyncAdminResource"] |
| 25 | + |
| 26 | + |
| 27 | +class AdminResource(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> AdminResourceWithRawResponse: |
| 30 | + """ |
| 31 | + This property can be used as a prefix for any HTTP method call to return |
| 32 | + the raw response object instead of the parsed content. |
| 33 | +
|
| 34 | + For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers |
| 35 | + """ |
| 36 | + return AdminResourceWithRawResponse(self) |
| 37 | + |
| 38 | + @cached_property |
| 39 | + def with_streaming_response(self) -> AdminResourceWithStreamingResponse: |
| 40 | + """ |
| 41 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 42 | +
|
| 43 | + For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#with_streaming_response |
| 44 | + """ |
| 45 | + return AdminResourceWithStreamingResponse(self) |
| 46 | + |
| 47 | + def create_organization( |
| 48 | + self, |
| 49 | + *, |
| 50 | + organization_name: str, |
| 51 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 52 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 53 | + extra_headers: Headers | None = None, |
| 54 | + extra_query: Query | None = None, |
| 55 | + extra_body: Body | None = None, |
| 56 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 57 | + ) -> AdminCreateOrganizationResponse: |
| 58 | + """Creates or updates an organization with the provided organization name. |
| 59 | +
|
| 60 | + An API |
| 61 | + Key will be returned. |
| 62 | +
|
| 63 | + Returns 201 if a new organization was created, 200 if an existing organization |
| 64 | + was found. |
| 65 | +
|
| 66 | + Args: |
| 67 | + organization_name: The orgniazation name to create. Must be unique. |
| 68 | +
|
| 69 | + extra_headers: Send extra headers |
| 70 | +
|
| 71 | + extra_query: Add additional query parameters to the request |
| 72 | +
|
| 73 | + extra_body: Add additional JSON properties to the request |
| 74 | +
|
| 75 | + timeout: Override the client-level default timeout for this request, in seconds |
| 76 | + """ |
| 77 | + return self._post( |
| 78 | + "/admin/create-organization", |
| 79 | + body=maybe_transform( |
| 80 | + {"organization_name": organization_name}, admin_create_organization_params.AdminCreateOrganizationParams |
| 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=AdminCreateOrganizationResponse, |
| 86 | + ) |
| 87 | + |
| 88 | + |
| 89 | +class AsyncAdminResource(AsyncAPIResource): |
| 90 | + @cached_property |
| 91 | + def with_raw_response(self) -> AsyncAdminResourceWithRawResponse: |
| 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/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers |
| 97 | + """ |
| 98 | + return AsyncAdminResourceWithRawResponse(self) |
| 99 | + |
| 100 | + @cached_property |
| 101 | + def with_streaming_response(self) -> AsyncAdminResourceWithStreamingResponse: |
| 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/zeroentropy-ai/zeroentropy-python#with_streaming_response |
| 106 | + """ |
| 107 | + return AsyncAdminResourceWithStreamingResponse(self) |
| 108 | + |
| 109 | + async def create_organization( |
| 110 | + self, |
| 111 | + *, |
| 112 | + organization_name: str, |
| 113 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 114 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 115 | + extra_headers: Headers | None = None, |
| 116 | + extra_query: Query | None = None, |
| 117 | + extra_body: Body | None = None, |
| 118 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 119 | + ) -> AdminCreateOrganizationResponse: |
| 120 | + """Creates or updates an organization with the provided organization name. |
| 121 | +
|
| 122 | + An API |
| 123 | + Key will be returned. |
| 124 | +
|
| 125 | + Returns 201 if a new organization was created, 200 if an existing organization |
| 126 | + was found. |
| 127 | +
|
| 128 | + Args: |
| 129 | + organization_name: The orgniazation name to create. Must be unique. |
| 130 | +
|
| 131 | + extra_headers: Send extra headers |
| 132 | +
|
| 133 | + extra_query: Add additional query parameters to the request |
| 134 | +
|
| 135 | + extra_body: Add additional JSON properties to the request |
| 136 | +
|
| 137 | + timeout: Override the client-level default timeout for this request, in seconds |
| 138 | + """ |
| 139 | + return await self._post( |
| 140 | + "/admin/create-organization", |
| 141 | + body=await async_maybe_transform( |
| 142 | + {"organization_name": organization_name}, admin_create_organization_params.AdminCreateOrganizationParams |
| 143 | + ), |
| 144 | + options=make_request_options( |
| 145 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 146 | + ), |
| 147 | + cast_to=AdminCreateOrganizationResponse, |
| 148 | + ) |
| 149 | + |
| 150 | + |
| 151 | +class AdminResourceWithRawResponse: |
| 152 | + def __init__(self, admin: AdminResource) -> None: |
| 153 | + self._admin = admin |
| 154 | + |
| 155 | + self.create_organization = to_raw_response_wrapper( |
| 156 | + admin.create_organization, |
| 157 | + ) |
| 158 | + |
| 159 | + |
| 160 | +class AsyncAdminResourceWithRawResponse: |
| 161 | + def __init__(self, admin: AsyncAdminResource) -> None: |
| 162 | + self._admin = admin |
| 163 | + |
| 164 | + self.create_organization = async_to_raw_response_wrapper( |
| 165 | + admin.create_organization, |
| 166 | + ) |
| 167 | + |
| 168 | + |
| 169 | +class AdminResourceWithStreamingResponse: |
| 170 | + def __init__(self, admin: AdminResource) -> None: |
| 171 | + self._admin = admin |
| 172 | + |
| 173 | + self.create_organization = to_streamed_response_wrapper( |
| 174 | + admin.create_organization, |
| 175 | + ) |
| 176 | + |
| 177 | + |
| 178 | +class AsyncAdminResourceWithStreamingResponse: |
| 179 | + def __init__(self, admin: AsyncAdminResource) -> None: |
| 180 | + self._admin = admin |
| 181 | + |
| 182 | + self.create_organization = async_to_streamed_response_wrapper( |
| 183 | + admin.create_organization, |
| 184 | + ) |
0 commit comments