feat: CV Application - AI-powered CV management, parsing, matching, and generation

This commit is contained in:
root
2026-07-15 14:23:23 +00:00
commit 76f0d9efba
5691 changed files with 699219 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .admin import (
Admin,
AsyncAdmin,
AdminWithRawResponse,
AsyncAdminWithRawResponse,
AdminWithStreamingResponse,
AsyncAdminWithStreamingResponse,
)
from .organization import (
Organization,
AsyncOrganization,
OrganizationWithRawResponse,
AsyncOrganizationWithRawResponse,
OrganizationWithStreamingResponse,
AsyncOrganizationWithStreamingResponse,
)
__all__ = [
"Organization",
"AsyncOrganization",
"OrganizationWithRawResponse",
"AsyncOrganizationWithRawResponse",
"OrganizationWithStreamingResponse",
"AsyncOrganizationWithStreamingResponse",
"Admin",
"AsyncAdmin",
"AdminWithRawResponse",
"AsyncAdminWithRawResponse",
"AdminWithStreamingResponse",
"AsyncAdminWithStreamingResponse",
]

View File

@@ -0,0 +1,102 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from .organization.organization import (
Organization,
AsyncOrganization,
OrganizationWithRawResponse,
AsyncOrganizationWithRawResponse,
OrganizationWithStreamingResponse,
AsyncOrganizationWithStreamingResponse,
)
__all__ = ["Admin", "AsyncAdmin"]
class Admin(SyncAPIResource):
@cached_property
def organization(self) -> Organization:
return Organization(self._client)
@cached_property
def with_raw_response(self) -> AdminWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AdminWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AdminWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AdminWithStreamingResponse(self)
class AsyncAdmin(AsyncAPIResource):
@cached_property
def organization(self) -> AsyncOrganization:
return AsyncOrganization(self._client)
@cached_property
def with_raw_response(self) -> AsyncAdminWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncAdminWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncAdminWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncAdminWithStreamingResponse(self)
class AdminWithRawResponse:
def __init__(self, admin: Admin) -> None:
self._admin = admin
@cached_property
def organization(self) -> OrganizationWithRawResponse:
return OrganizationWithRawResponse(self._admin.organization)
class AsyncAdminWithRawResponse:
def __init__(self, admin: AsyncAdmin) -> None:
self._admin = admin
@cached_property
def organization(self) -> AsyncOrganizationWithRawResponse:
return AsyncOrganizationWithRawResponse(self._admin.organization)
class AdminWithStreamingResponse:
def __init__(self, admin: Admin) -> None:
self._admin = admin
@cached_property
def organization(self) -> OrganizationWithStreamingResponse:
return OrganizationWithStreamingResponse(self._admin.organization)
class AsyncAdminWithStreamingResponse:
def __init__(self, admin: AsyncAdmin) -> None:
self._admin = admin
@cached_property
def organization(self) -> AsyncOrganizationWithStreamingResponse:
return AsyncOrganizationWithStreamingResponse(self._admin.organization)

View File

@@ -0,0 +1,173 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .usage import (
Usage,
AsyncUsage,
UsageWithRawResponse,
AsyncUsageWithRawResponse,
UsageWithStreamingResponse,
AsyncUsageWithStreamingResponse,
)
from .users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
from .groups import (
Groups,
AsyncGroups,
GroupsWithRawResponse,
AsyncGroupsWithRawResponse,
GroupsWithStreamingResponse,
AsyncGroupsWithStreamingResponse,
)
from .invites import (
Invites,
AsyncInvites,
InvitesWithRawResponse,
AsyncInvitesWithRawResponse,
InvitesWithStreamingResponse,
AsyncInvitesWithStreamingResponse,
)
from .projects import (
Projects,
AsyncProjects,
ProjectsWithRawResponse,
AsyncProjectsWithRawResponse,
ProjectsWithStreamingResponse,
AsyncProjectsWithStreamingResponse,
)
from .audit_logs import (
AuditLogs,
AsyncAuditLogs,
AuditLogsWithRawResponse,
AsyncAuditLogsWithRawResponse,
AuditLogsWithStreamingResponse,
AsyncAuditLogsWithStreamingResponse,
)
from .certificates import (
Certificates,
AsyncCertificates,
CertificatesWithRawResponse,
AsyncCertificatesWithRawResponse,
CertificatesWithStreamingResponse,
AsyncCertificatesWithStreamingResponse,
)
from .organization import (
Organization,
AsyncOrganization,
OrganizationWithRawResponse,
AsyncOrganizationWithRawResponse,
OrganizationWithStreamingResponse,
AsyncOrganizationWithStreamingResponse,
)
from .spend_alerts import (
SpendAlerts,
AsyncSpendAlerts,
SpendAlertsWithRawResponse,
AsyncSpendAlertsWithRawResponse,
SpendAlertsWithStreamingResponse,
AsyncSpendAlertsWithStreamingResponse,
)
from .admin_api_keys import (
AdminAPIKeys,
AsyncAdminAPIKeys,
AdminAPIKeysWithRawResponse,
AsyncAdminAPIKeysWithRawResponse,
AdminAPIKeysWithStreamingResponse,
AsyncAdminAPIKeysWithStreamingResponse,
)
from .data_retention import (
DataRetention,
AsyncDataRetention,
DataRetentionWithRawResponse,
AsyncDataRetentionWithRawResponse,
DataRetentionWithStreamingResponse,
AsyncDataRetentionWithStreamingResponse,
)
__all__ = [
"AuditLogs",
"AsyncAuditLogs",
"AuditLogsWithRawResponse",
"AsyncAuditLogsWithRawResponse",
"AuditLogsWithStreamingResponse",
"AsyncAuditLogsWithStreamingResponse",
"AdminAPIKeys",
"AsyncAdminAPIKeys",
"AdminAPIKeysWithRawResponse",
"AsyncAdminAPIKeysWithRawResponse",
"AdminAPIKeysWithStreamingResponse",
"AsyncAdminAPIKeysWithStreamingResponse",
"Usage",
"AsyncUsage",
"UsageWithRawResponse",
"AsyncUsageWithRawResponse",
"UsageWithStreamingResponse",
"AsyncUsageWithStreamingResponse",
"Invites",
"AsyncInvites",
"InvitesWithRawResponse",
"AsyncInvitesWithRawResponse",
"InvitesWithStreamingResponse",
"AsyncInvitesWithStreamingResponse",
"Users",
"AsyncUsers",
"UsersWithRawResponse",
"AsyncUsersWithRawResponse",
"UsersWithStreamingResponse",
"AsyncUsersWithStreamingResponse",
"Groups",
"AsyncGroups",
"GroupsWithRawResponse",
"AsyncGroupsWithRawResponse",
"GroupsWithStreamingResponse",
"AsyncGroupsWithStreamingResponse",
"Roles",
"AsyncRoles",
"RolesWithRawResponse",
"AsyncRolesWithRawResponse",
"RolesWithStreamingResponse",
"AsyncRolesWithStreamingResponse",
"DataRetention",
"AsyncDataRetention",
"DataRetentionWithRawResponse",
"AsyncDataRetentionWithRawResponse",
"DataRetentionWithStreamingResponse",
"AsyncDataRetentionWithStreamingResponse",
"SpendAlerts",
"AsyncSpendAlerts",
"SpendAlertsWithRawResponse",
"AsyncSpendAlertsWithRawResponse",
"SpendAlertsWithStreamingResponse",
"AsyncSpendAlertsWithStreamingResponse",
"Certificates",
"AsyncCertificates",
"CertificatesWithRawResponse",
"AsyncCertificatesWithRawResponse",
"CertificatesWithStreamingResponse",
"AsyncCertificatesWithStreamingResponse",
"Projects",
"AsyncProjects",
"ProjectsWithRawResponse",
"AsyncProjectsWithRawResponse",
"ProjectsWithStreamingResponse",
"AsyncProjectsWithStreamingResponse",
"Organization",
"AsyncOrganization",
"OrganizationWithRawResponse",
"AsyncOrganizationWithRawResponse",
"OrganizationWithStreamingResponse",
"AsyncOrganizationWithStreamingResponse",
]

View File

@@ -0,0 +1,489 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ...._utils import path_template, maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....pagination import SyncCursorPage, AsyncCursorPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.admin.organization import admin_api_key_list_params, admin_api_key_create_params
from ....types.admin.organization.admin_api_key import AdminAPIKey
from ....types.admin.organization.admin_api_key_create_response import AdminAPIKeyCreateResponse
from ....types.admin.organization.admin_api_key_delete_response import AdminAPIKeyDeleteResponse
__all__ = ["AdminAPIKeys", "AsyncAdminAPIKeys"]
class AdminAPIKeys(SyncAPIResource):
@cached_property
def with_raw_response(self) -> AdminAPIKeysWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AdminAPIKeysWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AdminAPIKeysWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AdminAPIKeysWithStreamingResponse(self)
def create(
self,
*,
name: str,
expires_in_seconds: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AdminAPIKeyCreateResponse:
"""
Create an organization admin API key
Args:
expires_in_seconds: The number of seconds until the API key expires. Omit this field for a key that
does not expire.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/admin_api_keys",
body=maybe_transform(
{
"name": name,
"expires_in_seconds": expires_in_seconds,
},
admin_api_key_create_params.AdminAPIKeyCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=AdminAPIKeyCreateResponse,
)
def retrieve(
self,
key_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AdminAPIKey:
"""
Retrieve a single organization API key
Args:
key_id: The ID of the API key.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not key_id:
raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}")
return self._get(
path_template("/organization/admin_api_keys/{key_id}", key_id=key_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=AdminAPIKey,
)
def list(
self,
*,
after: Optional[str] | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncCursorPage[AdminAPIKey]:
"""
List organization API keys
Args:
after: Return keys with IDs that come after this ID in the pagination order.
limit: Maximum number of keys to return.
order: Order results by creation time, ascending or descending.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/admin_api_keys",
page=SyncCursorPage[AdminAPIKey],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
admin_api_key_list_params.AdminAPIKeyListParams,
),
security={"admin_api_key_auth": True},
),
model=AdminAPIKey,
)
def delete(
self,
key_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AdminAPIKeyDeleteResponse:
"""
Delete an organization admin API key
Args:
key_id: The ID of the API key to be deleted.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not key_id:
raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}")
return self._delete(
path_template("/organization/admin_api_keys/{key_id}", key_id=key_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=AdminAPIKeyDeleteResponse,
)
class AsyncAdminAPIKeys(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncAdminAPIKeysWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncAdminAPIKeysWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncAdminAPIKeysWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncAdminAPIKeysWithStreamingResponse(self)
async def create(
self,
*,
name: str,
expires_in_seconds: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AdminAPIKeyCreateResponse:
"""
Create an organization admin API key
Args:
expires_in_seconds: The number of seconds until the API key expires. Omit this field for a key that
does not expire.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/admin_api_keys",
body=await async_maybe_transform(
{
"name": name,
"expires_in_seconds": expires_in_seconds,
},
admin_api_key_create_params.AdminAPIKeyCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=AdminAPIKeyCreateResponse,
)
async def retrieve(
self,
key_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AdminAPIKey:
"""
Retrieve a single organization API key
Args:
key_id: The ID of the API key.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not key_id:
raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}")
return await self._get(
path_template("/organization/admin_api_keys/{key_id}", key_id=key_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=AdminAPIKey,
)
def list(
self,
*,
after: Optional[str] | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[AdminAPIKey, AsyncCursorPage[AdminAPIKey]]:
"""
List organization API keys
Args:
after: Return keys with IDs that come after this ID in the pagination order.
limit: Maximum number of keys to return.
order: Order results by creation time, ascending or descending.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/admin_api_keys",
page=AsyncCursorPage[AdminAPIKey],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
admin_api_key_list_params.AdminAPIKeyListParams,
),
security={"admin_api_key_auth": True},
),
model=AdminAPIKey,
)
async def delete(
self,
key_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AdminAPIKeyDeleteResponse:
"""
Delete an organization admin API key
Args:
key_id: The ID of the API key to be deleted.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not key_id:
raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}")
return await self._delete(
path_template("/organization/admin_api_keys/{key_id}", key_id=key_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=AdminAPIKeyDeleteResponse,
)
class AdminAPIKeysWithRawResponse:
def __init__(self, admin_api_keys: AdminAPIKeys) -> None:
self._admin_api_keys = admin_api_keys
self.create = _legacy_response.to_raw_response_wrapper(
admin_api_keys.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
admin_api_keys.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
admin_api_keys.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
admin_api_keys.delete,
)
class AsyncAdminAPIKeysWithRawResponse:
def __init__(self, admin_api_keys: AsyncAdminAPIKeys) -> None:
self._admin_api_keys = admin_api_keys
self.create = _legacy_response.async_to_raw_response_wrapper(
admin_api_keys.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
admin_api_keys.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
admin_api_keys.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
admin_api_keys.delete,
)
class AdminAPIKeysWithStreamingResponse:
def __init__(self, admin_api_keys: AdminAPIKeys) -> None:
self._admin_api_keys = admin_api_keys
self.create = to_streamed_response_wrapper(
admin_api_keys.create,
)
self.retrieve = to_streamed_response_wrapper(
admin_api_keys.retrieve,
)
self.list = to_streamed_response_wrapper(
admin_api_keys.list,
)
self.delete = to_streamed_response_wrapper(
admin_api_keys.delete,
)
class AsyncAdminAPIKeysWithStreamingResponse:
def __init__(self, admin_api_keys: AsyncAdminAPIKeys) -> None:
self._admin_api_keys = admin_api_keys
self.create = async_to_streamed_response_wrapper(
admin_api_keys.create,
)
self.retrieve = async_to_streamed_response_wrapper(
admin_api_keys.retrieve,
)
self.list = async_to_streamed_response_wrapper(
admin_api_keys.list,
)
self.delete = async_to_streamed_response_wrapper(
admin_api_keys.delete,
)

View File

@@ -0,0 +1,419 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import List
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from ...._utils import maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.admin.organization import audit_log_list_params
from ....types.admin.organization.audit_log_list_response import AuditLogListResponse
__all__ = ["AuditLogs", "AsyncAuditLogs"]
class AuditLogs(SyncAPIResource):
"""List user actions and configuration changes within this organization."""
@cached_property
def with_raw_response(self) -> AuditLogsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AuditLogsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AuditLogsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AuditLogsWithStreamingResponse(self)
def list(
self,
*,
actor_emails: SequenceNotStr[str] | Omit = omit,
actor_ids: SequenceNotStr[str] | Omit = omit,
after: str | Omit = omit,
before: str | Omit = omit,
effective_at: audit_log_list_params.EffectiveAt | Omit = omit,
event_types: List[
Literal[
"api_key.created",
"api_key.updated",
"api_key.deleted",
"certificate.created",
"certificate.updated",
"certificate.deleted",
"certificates.activated",
"certificates.deactivated",
"checkpoint.permission.created",
"checkpoint.permission.deleted",
"external_key.registered",
"external_key.removed",
"group.created",
"group.updated",
"group.deleted",
"invite.sent",
"invite.accepted",
"invite.deleted",
"ip_allowlist.created",
"ip_allowlist.updated",
"ip_allowlist.deleted",
"ip_allowlist.config.activated",
"ip_allowlist.config.deactivated",
"login.succeeded",
"login.failed",
"logout.succeeded",
"logout.failed",
"organization.updated",
"project.created",
"project.updated",
"project.archived",
"project.deleted",
"rate_limit.updated",
"rate_limit.deleted",
"resource.deleted",
"tunnel.created",
"tunnel.updated",
"tunnel.deleted",
"workload_identity_provider.created",
"workload_identity_provider.updated",
"workload_identity_provider.deleted",
"workload_identity_provider_mapping.created",
"workload_identity_provider_mapping.updated",
"workload_identity_provider_mapping.deleted",
"role.created",
"role.updated",
"role.deleted",
"role.assignment.created",
"role.assignment.deleted",
"role.bound_to_resource",
"role.unbound_from_resource",
"scim.enabled",
"scim.disabled",
"service_account.created",
"service_account.updated",
"service_account.deleted",
"user.added",
"user.updated",
"user.deleted",
]
]
| Omit = omit,
limit: int | Omit = omit,
project_ids: SequenceNotStr[str] | Omit = omit,
resource_ids: SequenceNotStr[str] | Omit = omit,
tenant_only: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[AuditLogListResponse]:
"""
List user actions and configuration changes within this organization.
Args:
actor_emails: Return only events performed by users with these emails.
actor_ids: Return only events performed by these actors. Can be a user ID, a service
account ID, or an api key tracking ID.
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
before: A cursor for use in pagination. `before` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
starting with obj_foo, your subsequent call can include before=obj_foo in order
to fetch the previous page of the list.
effective_at: Return only events whose `effective_at` (Unix seconds) is in this range.
event_types: Return only events with a `type` in one of these values. For example,
`project.created`. For all options, see the documentation for the
[audit log object](https://platform.openai.com/docs/api-reference/audit-logs/object).
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
project_ids: Return only events for these projects.
resource_ids: Return only events performed on these targets. For example, a project ID
updated. For ChatGPT connector role events, use the workspace connector resource
ID shown in `details.id`, such as `<workspace_id>__<connector_id>`.
tenant_only: Return only tenant-scoped events associated with this organization. Required for
tenant-scoped events such as `role.bound_to_resource` and
`role.unbound_from_resource`. When `true`, all supplied event types must be
tenant-scoped.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/audit_logs",
page=SyncConversationCursorPage[AuditLogListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"actor_emails": actor_emails,
"actor_ids": actor_ids,
"after": after,
"before": before,
"effective_at": effective_at,
"event_types": event_types,
"limit": limit,
"project_ids": project_ids,
"resource_ids": resource_ids,
"tenant_only": tenant_only,
},
audit_log_list_params.AuditLogListParams,
),
security={"admin_api_key_auth": True},
),
model=AuditLogListResponse,
)
class AsyncAuditLogs(AsyncAPIResource):
"""List user actions and configuration changes within this organization."""
@cached_property
def with_raw_response(self) -> AsyncAuditLogsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncAuditLogsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncAuditLogsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncAuditLogsWithStreamingResponse(self)
def list(
self,
*,
actor_emails: SequenceNotStr[str] | Omit = omit,
actor_ids: SequenceNotStr[str] | Omit = omit,
after: str | Omit = omit,
before: str | Omit = omit,
effective_at: audit_log_list_params.EffectiveAt | Omit = omit,
event_types: List[
Literal[
"api_key.created",
"api_key.updated",
"api_key.deleted",
"certificate.created",
"certificate.updated",
"certificate.deleted",
"certificates.activated",
"certificates.deactivated",
"checkpoint.permission.created",
"checkpoint.permission.deleted",
"external_key.registered",
"external_key.removed",
"group.created",
"group.updated",
"group.deleted",
"invite.sent",
"invite.accepted",
"invite.deleted",
"ip_allowlist.created",
"ip_allowlist.updated",
"ip_allowlist.deleted",
"ip_allowlist.config.activated",
"ip_allowlist.config.deactivated",
"login.succeeded",
"login.failed",
"logout.succeeded",
"logout.failed",
"organization.updated",
"project.created",
"project.updated",
"project.archived",
"project.deleted",
"rate_limit.updated",
"rate_limit.deleted",
"resource.deleted",
"tunnel.created",
"tunnel.updated",
"tunnel.deleted",
"workload_identity_provider.created",
"workload_identity_provider.updated",
"workload_identity_provider.deleted",
"workload_identity_provider_mapping.created",
"workload_identity_provider_mapping.updated",
"workload_identity_provider_mapping.deleted",
"role.created",
"role.updated",
"role.deleted",
"role.assignment.created",
"role.assignment.deleted",
"role.bound_to_resource",
"role.unbound_from_resource",
"scim.enabled",
"scim.disabled",
"service_account.created",
"service_account.updated",
"service_account.deleted",
"user.added",
"user.updated",
"user.deleted",
]
]
| Omit = omit,
limit: int | Omit = omit,
project_ids: SequenceNotStr[str] | Omit = omit,
resource_ids: SequenceNotStr[str] | Omit = omit,
tenant_only: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[AuditLogListResponse, AsyncConversationCursorPage[AuditLogListResponse]]:
"""
List user actions and configuration changes within this organization.
Args:
actor_emails: Return only events performed by users with these emails.
actor_ids: Return only events performed by these actors. Can be a user ID, a service
account ID, or an api key tracking ID.
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
before: A cursor for use in pagination. `before` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
starting with obj_foo, your subsequent call can include before=obj_foo in order
to fetch the previous page of the list.
effective_at: Return only events whose `effective_at` (Unix seconds) is in this range.
event_types: Return only events with a `type` in one of these values. For example,
`project.created`. For all options, see the documentation for the
[audit log object](https://platform.openai.com/docs/api-reference/audit-logs/object).
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
project_ids: Return only events for these projects.
resource_ids: Return only events performed on these targets. For example, a project ID
updated. For ChatGPT connector role events, use the workspace connector resource
ID shown in `details.id`, such as `<workspace_id>__<connector_id>`.
tenant_only: Return only tenant-scoped events associated with this organization. Required for
tenant-scoped events such as `role.bound_to_resource` and
`role.unbound_from_resource`. When `true`, all supplied event types must be
tenant-scoped.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/audit_logs",
page=AsyncConversationCursorPage[AuditLogListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"actor_emails": actor_emails,
"actor_ids": actor_ids,
"after": after,
"before": before,
"effective_at": effective_at,
"event_types": event_types,
"limit": limit,
"project_ids": project_ids,
"resource_ids": resource_ids,
"tenant_only": tenant_only,
},
audit_log_list_params.AuditLogListParams,
),
security={"admin_api_key_auth": True},
),
model=AuditLogListResponse,
)
class AuditLogsWithRawResponse:
def __init__(self, audit_logs: AuditLogs) -> None:
self._audit_logs = audit_logs
self.list = _legacy_response.to_raw_response_wrapper(
audit_logs.list,
)
class AsyncAuditLogsWithRawResponse:
def __init__(self, audit_logs: AsyncAuditLogs) -> None:
self._audit_logs = audit_logs
self.list = _legacy_response.async_to_raw_response_wrapper(
audit_logs.list,
)
class AuditLogsWithStreamingResponse:
def __init__(self, audit_logs: AuditLogs) -> None:
self._audit_logs = audit_logs
self.list = to_streamed_response_wrapper(
audit_logs.list,
)
class AsyncAuditLogsWithStreamingResponse:
def __init__(self, audit_logs: AsyncAuditLogs) -> None:
self._audit_logs = audit_logs
self.list = async_to_streamed_response_wrapper(
audit_logs.list,
)

View File

@@ -0,0 +1,818 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import List
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from ...._utils import path_template, maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....pagination import SyncPage, AsyncPage, SyncConversationCursorPage, AsyncConversationCursorPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.admin.organization import (
certificate_list_params,
certificate_create_params,
certificate_update_params,
certificate_activate_params,
certificate_retrieve_params,
certificate_deactivate_params,
)
from ....types.admin.organization.certificate import Certificate
from ....types.admin.organization.certificate_list_response import CertificateListResponse
from ....types.admin.organization.certificate_delete_response import CertificateDeleteResponse
from ....types.admin.organization.certificate_activate_response import CertificateActivateResponse
from ....types.admin.organization.certificate_deactivate_response import CertificateDeactivateResponse
__all__ = ["Certificates", "AsyncCertificates"]
class Certificates(SyncAPIResource):
@cached_property
def with_raw_response(self) -> CertificatesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return CertificatesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> CertificatesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return CertificatesWithStreamingResponse(self)
def create(
self,
*,
certificate: str,
name: str | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Certificate:
"""Upload a certificate to the organization.
This does **not** automatically
activate the certificate.
Organizations can upload up to 50 certificates.
Args:
certificate: The certificate content in PEM format
name: An optional name for the certificate
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/certificates",
body=maybe_transform(
{
"certificate": certificate,
"name": name,
},
certificate_create_params.CertificateCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
def retrieve(
self,
certificate_id: str,
*,
include: List[Literal["content"]] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Certificate:
"""
Get a certificate that has been uploaded to the organization.
You can get a certificate regardless of whether it is active or not.
Args:
include: A list of additional fields to include in the response. Currently the only
supported value is `content` to fetch the PEM content of the certificate.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return self._get(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"include": include}, certificate_retrieve_params.CertificateRetrieveParams),
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
def update(
self,
certificate_id: str,
*,
name: str | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Certificate:
"""Modify a certificate.
Note that only the name can be modified.
Args:
name: The updated name for the certificate
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return self._post(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
body=maybe_transform({"name": name}, certificate_update_params.CertificateUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[CertificateListResponse]:
"""
List uploaded certificates for this organization.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
order and `desc` for descending order.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/certificates",
page=SyncConversationCursorPage[CertificateListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
certificate_list_params.CertificateListParams,
),
security={"admin_api_key_auth": True},
),
model=CertificateListResponse,
)
def delete(
self,
certificate_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> CertificateDeleteResponse:
"""
Delete a certificate from the organization.
The certificate must be inactive for the organization and all projects.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return self._delete(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=CertificateDeleteResponse,
)
def activate(
self,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncPage[CertificateActivateResponse]:
"""
Activate certificates at the organization level.
You can atomically and idempotently activate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/certificates/activate",
page=SyncPage[CertificateActivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_activate_params.CertificateActivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateActivateResponse,
method="post",
)
def deactivate(
self,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncPage[CertificateDeactivateResponse]:
"""
Deactivate certificates at the organization level.
You can atomically and idempotently deactivate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/certificates/deactivate",
page=SyncPage[CertificateDeactivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_deactivate_params.CertificateDeactivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateDeactivateResponse,
method="post",
)
class AsyncCertificates(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncCertificatesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncCertificatesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncCertificatesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncCertificatesWithStreamingResponse(self)
async def create(
self,
*,
certificate: str,
name: str | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Certificate:
"""Upload a certificate to the organization.
This does **not** automatically
activate the certificate.
Organizations can upload up to 50 certificates.
Args:
certificate: The certificate content in PEM format
name: An optional name for the certificate
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/certificates",
body=await async_maybe_transform(
{
"certificate": certificate,
"name": name,
},
certificate_create_params.CertificateCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
async def retrieve(
self,
certificate_id: str,
*,
include: List[Literal["content"]] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Certificate:
"""
Get a certificate that has been uploaded to the organization.
You can get a certificate regardless of whether it is active or not.
Args:
include: A list of additional fields to include in the response. Currently the only
supported value is `content` to fetch the PEM content of the certificate.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return await self._get(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{"include": include}, certificate_retrieve_params.CertificateRetrieveParams
),
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
async def update(
self,
certificate_id: str,
*,
name: str | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Certificate:
"""Modify a certificate.
Note that only the name can be modified.
Args:
name: The updated name for the certificate
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return await self._post(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
body=await async_maybe_transform({"name": name}, certificate_update_params.CertificateUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[CertificateListResponse, AsyncConversationCursorPage[CertificateListResponse]]:
"""
List uploaded certificates for this organization.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
order and `desc` for descending order.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/certificates",
page=AsyncConversationCursorPage[CertificateListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
certificate_list_params.CertificateListParams,
),
security={"admin_api_key_auth": True},
),
model=CertificateListResponse,
)
async def delete(
self,
certificate_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> CertificateDeleteResponse:
"""
Delete a certificate from the organization.
The certificate must be inactive for the organization and all projects.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return await self._delete(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=CertificateDeleteResponse,
)
def activate(
self,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[CertificateActivateResponse, AsyncPage[CertificateActivateResponse]]:
"""
Activate certificates at the organization level.
You can atomically and idempotently activate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/certificates/activate",
page=AsyncPage[CertificateActivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_activate_params.CertificateActivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateActivateResponse,
method="post",
)
def deactivate(
self,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[CertificateDeactivateResponse, AsyncPage[CertificateDeactivateResponse]]:
"""
Deactivate certificates at the organization level.
You can atomically and idempotently deactivate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/certificates/deactivate",
page=AsyncPage[CertificateDeactivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_deactivate_params.CertificateDeactivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateDeactivateResponse,
method="post",
)
class CertificatesWithRawResponse:
def __init__(self, certificates: Certificates) -> None:
self._certificates = certificates
self.create = _legacy_response.to_raw_response_wrapper(
certificates.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
certificates.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
certificates.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
certificates.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
certificates.delete,
)
self.activate = _legacy_response.to_raw_response_wrapper(
certificates.activate,
)
self.deactivate = _legacy_response.to_raw_response_wrapper(
certificates.deactivate,
)
class AsyncCertificatesWithRawResponse:
def __init__(self, certificates: AsyncCertificates) -> None:
self._certificates = certificates
self.create = _legacy_response.async_to_raw_response_wrapper(
certificates.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
certificates.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
certificates.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
certificates.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
certificates.delete,
)
self.activate = _legacy_response.async_to_raw_response_wrapper(
certificates.activate,
)
self.deactivate = _legacy_response.async_to_raw_response_wrapper(
certificates.deactivate,
)
class CertificatesWithStreamingResponse:
def __init__(self, certificates: Certificates) -> None:
self._certificates = certificates
self.create = to_streamed_response_wrapper(
certificates.create,
)
self.retrieve = to_streamed_response_wrapper(
certificates.retrieve,
)
self.update = to_streamed_response_wrapper(
certificates.update,
)
self.list = to_streamed_response_wrapper(
certificates.list,
)
self.delete = to_streamed_response_wrapper(
certificates.delete,
)
self.activate = to_streamed_response_wrapper(
certificates.activate,
)
self.deactivate = to_streamed_response_wrapper(
certificates.deactivate,
)
class AsyncCertificatesWithStreamingResponse:
def __init__(self, certificates: AsyncCertificates) -> None:
self._certificates = certificates
self.create = async_to_streamed_response_wrapper(
certificates.create,
)
self.retrieve = async_to_streamed_response_wrapper(
certificates.retrieve,
)
self.update = async_to_streamed_response_wrapper(
certificates.update,
)
self.list = async_to_streamed_response_wrapper(
certificates.list,
)
self.delete = async_to_streamed_response_wrapper(
certificates.delete,
)
self.activate = async_to_streamed_response_wrapper(
certificates.activate,
)
self.deactivate = async_to_streamed_response_wrapper(
certificates.deactivate,
)

View File

@@ -0,0 +1,245 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Query, Headers, NotGiven, not_given
from ...._utils import maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ...._base_client import make_request_options
from ....types.admin.organization import data_retention_update_params
from ....types.admin.organization.organization_data_retention import OrganizationDataRetention
__all__ = ["DataRetention", "AsyncDataRetention"]
class DataRetention(SyncAPIResource):
@cached_property
def with_raw_response(self) -> DataRetentionWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return DataRetentionWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> DataRetentionWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return DataRetentionWithStreamingResponse(self)
def retrieve(
self,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationDataRetention:
"""Retrieves organization data retention controls."""
return self._get(
"/organization/data_retention",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationDataRetention,
)
def update(
self,
*,
retention_type: Literal[
"zero_data_retention",
"modified_abuse_monitoring",
"enhanced_zero_data_retention",
"enhanced_modified_abuse_monitoring",
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationDataRetention:
"""
Updates organization data retention controls.
Args:
retention_type: The desired organization data retention type.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/data_retention",
body=maybe_transform(
{"retention_type": retention_type}, data_retention_update_params.DataRetentionUpdateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationDataRetention,
)
class AsyncDataRetention(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncDataRetentionWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncDataRetentionWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncDataRetentionWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncDataRetentionWithStreamingResponse(self)
async def retrieve(
self,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationDataRetention:
"""Retrieves organization data retention controls."""
return await self._get(
"/organization/data_retention",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationDataRetention,
)
async def update(
self,
*,
retention_type: Literal[
"zero_data_retention",
"modified_abuse_monitoring",
"enhanced_zero_data_retention",
"enhanced_modified_abuse_monitoring",
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationDataRetention:
"""
Updates organization data retention controls.
Args:
retention_type: The desired organization data retention type.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/data_retention",
body=await async_maybe_transform(
{"retention_type": retention_type}, data_retention_update_params.DataRetentionUpdateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationDataRetention,
)
class DataRetentionWithRawResponse:
def __init__(self, data_retention: DataRetention) -> None:
self._data_retention = data_retention
self.retrieve = _legacy_response.to_raw_response_wrapper(
data_retention.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
data_retention.update,
)
class AsyncDataRetentionWithRawResponse:
def __init__(self, data_retention: AsyncDataRetention) -> None:
self._data_retention = data_retention
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
data_retention.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
data_retention.update,
)
class DataRetentionWithStreamingResponse:
def __init__(self, data_retention: DataRetention) -> None:
self._data_retention = data_retention
self.retrieve = to_streamed_response_wrapper(
data_retention.retrieve,
)
self.update = to_streamed_response_wrapper(
data_retention.update,
)
class AsyncDataRetentionWithStreamingResponse:
def __init__(self, data_retention: AsyncDataRetention) -> None:
self._data_retention = data_retention
self.retrieve = async_to_streamed_response_wrapper(
data_retention.retrieve,
)
self.update = async_to_streamed_response_wrapper(
data_retention.update,
)

View File

@@ -0,0 +1,47 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
from .groups import (
Groups,
AsyncGroups,
GroupsWithRawResponse,
AsyncGroupsWithRawResponse,
GroupsWithStreamingResponse,
AsyncGroupsWithStreamingResponse,
)
__all__ = [
"Users",
"AsyncUsers",
"UsersWithRawResponse",
"AsyncUsersWithRawResponse",
"UsersWithStreamingResponse",
"AsyncUsersWithStreamingResponse",
"Roles",
"AsyncRoles",
"RolesWithRawResponse",
"AsyncRolesWithRawResponse",
"RolesWithStreamingResponse",
"AsyncRolesWithStreamingResponse",
"Groups",
"AsyncGroups",
"GroupsWithRawResponse",
"AsyncGroupsWithRawResponse",
"GroupsWithStreamingResponse",
"AsyncGroupsWithStreamingResponse",
]

View File

@@ -0,0 +1,630 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncNextCursorPage, AsyncNextCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization import group_list_params, group_create_params, group_update_params
from .....types.admin.organization.group import Group
from .....types.admin.organization.group_delete_response import GroupDeleteResponse
from .....types.admin.organization.group_update_response import GroupUpdateResponse
__all__ = ["Groups", "AsyncGroups"]
class Groups(SyncAPIResource):
@cached_property
def users(self) -> Users:
return Users(self._client)
@cached_property
def roles(self) -> Roles:
return Roles(self._client)
@cached_property
def with_raw_response(self) -> GroupsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return GroupsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> GroupsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return GroupsWithStreamingResponse(self)
def create(
self,
*,
name: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Group:
"""
Creates a new group in the organization.
Args:
name: Human readable name for the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/groups",
body=maybe_transform({"name": name}, group_create_params.GroupCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Group,
)
def retrieve(
self,
group_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Group:
"""
Retrieves a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get(
path_template("/organization/groups/{group_id}", group_id=group_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Group,
)
def update(
self,
group_id: str,
*,
name: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> GroupUpdateResponse:
"""
Updates a group's information.
Args:
name: New display name for the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._post(
path_template("/organization/groups/{group_id}", group_id=group_id),
body=maybe_transform({"name": name}, group_update_params.GroupUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=GroupUpdateResponse,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[Group]:
"""
Lists all groups in the organization.
Args:
after: A cursor for use in pagination. `after` is a group ID that defines your place in
the list. For instance, if you make a list request and receive 100 objects,
ending with group_abc, your subsequent call can include `after=group_abc` in
order to fetch the next page of the list.
limit: A limit on the number of groups to be returned. Limit can range between 0 and
1000, and the default is 100.
order: Specifies the sort order of the returned groups.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/groups",
page=SyncNextCursorPage[Group],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
group_list_params.GroupListParams,
),
security={"admin_api_key_auth": True},
),
model=Group,
)
def delete(
self,
group_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> GroupDeleteResponse:
"""
Deletes a group from the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._delete(
path_template("/organization/groups/{group_id}", group_id=group_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=GroupDeleteResponse,
)
class AsyncGroups(AsyncAPIResource):
@cached_property
def users(self) -> AsyncUsers:
return AsyncUsers(self._client)
@cached_property
def roles(self) -> AsyncRoles:
return AsyncRoles(self._client)
@cached_property
def with_raw_response(self) -> AsyncGroupsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncGroupsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncGroupsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncGroupsWithStreamingResponse(self)
async def create(
self,
*,
name: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Group:
"""
Creates a new group in the organization.
Args:
name: Human readable name for the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/groups",
body=await async_maybe_transform({"name": name}, group_create_params.GroupCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Group,
)
async def retrieve(
self,
group_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Group:
"""
Retrieves a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._get(
path_template("/organization/groups/{group_id}", group_id=group_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Group,
)
async def update(
self,
group_id: str,
*,
name: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> GroupUpdateResponse:
"""
Updates a group's information.
Args:
name: New display name for the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._post(
path_template("/organization/groups/{group_id}", group_id=group_id),
body=await async_maybe_transform({"name": name}, group_update_params.GroupUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=GroupUpdateResponse,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[Group, AsyncNextCursorPage[Group]]:
"""
Lists all groups in the organization.
Args:
after: A cursor for use in pagination. `after` is a group ID that defines your place in
the list. For instance, if you make a list request and receive 100 objects,
ending with group_abc, your subsequent call can include `after=group_abc` in
order to fetch the next page of the list.
limit: A limit on the number of groups to be returned. Limit can range between 0 and
1000, and the default is 100.
order: Specifies the sort order of the returned groups.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/groups",
page=AsyncNextCursorPage[Group],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
group_list_params.GroupListParams,
),
security={"admin_api_key_auth": True},
),
model=Group,
)
async def delete(
self,
group_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> GroupDeleteResponse:
"""
Deletes a group from the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._delete(
path_template("/organization/groups/{group_id}", group_id=group_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=GroupDeleteResponse,
)
class GroupsWithRawResponse:
def __init__(self, groups: Groups) -> None:
self._groups = groups
self.create = _legacy_response.to_raw_response_wrapper(
groups.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
groups.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
groups.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
groups.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
groups.delete,
)
@cached_property
def users(self) -> UsersWithRawResponse:
return UsersWithRawResponse(self._groups.users)
@cached_property
def roles(self) -> RolesWithRawResponse:
return RolesWithRawResponse(self._groups.roles)
class AsyncGroupsWithRawResponse:
def __init__(self, groups: AsyncGroups) -> None:
self._groups = groups
self.create = _legacy_response.async_to_raw_response_wrapper(
groups.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
groups.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
groups.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
groups.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
groups.delete,
)
@cached_property
def users(self) -> AsyncUsersWithRawResponse:
return AsyncUsersWithRawResponse(self._groups.users)
@cached_property
def roles(self) -> AsyncRolesWithRawResponse:
return AsyncRolesWithRawResponse(self._groups.roles)
class GroupsWithStreamingResponse:
def __init__(self, groups: Groups) -> None:
self._groups = groups
self.create = to_streamed_response_wrapper(
groups.create,
)
self.retrieve = to_streamed_response_wrapper(
groups.retrieve,
)
self.update = to_streamed_response_wrapper(
groups.update,
)
self.list = to_streamed_response_wrapper(
groups.list,
)
self.delete = to_streamed_response_wrapper(
groups.delete,
)
@cached_property
def users(self) -> UsersWithStreamingResponse:
return UsersWithStreamingResponse(self._groups.users)
@cached_property
def roles(self) -> RolesWithStreamingResponse:
return RolesWithStreamingResponse(self._groups.roles)
class AsyncGroupsWithStreamingResponse:
def __init__(self, groups: AsyncGroups) -> None:
self._groups = groups
self.create = async_to_streamed_response_wrapper(
groups.create,
)
self.retrieve = async_to_streamed_response_wrapper(
groups.retrieve,
)
self.update = async_to_streamed_response_wrapper(
groups.update,
)
self.list = async_to_streamed_response_wrapper(
groups.list,
)
self.delete = async_to_streamed_response_wrapper(
groups.delete,
)
@cached_property
def users(self) -> AsyncUsersWithStreamingResponse:
return AsyncUsersWithStreamingResponse(self._groups.users)
@cached_property
def roles(self) -> AsyncRolesWithStreamingResponse:
return AsyncRolesWithStreamingResponse(self._groups.roles)

View File

@@ -0,0 +1,491 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncNextCursorPage, AsyncNextCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.groups import role_list_params, role_create_params
from .....types.admin.organization.groups.role_list_response import RoleListResponse
from .....types.admin.organization.groups.role_create_response import RoleCreateResponse
from .....types.admin.organization.groups.role_delete_response import RoleDeleteResponse
from .....types.admin.organization.groups.role_retrieve_response import RoleRetrieveResponse
__all__ = ["Roles", "AsyncRoles"]
class Roles(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RolesWithStreamingResponse(self)
def create(
self,
group_id: str,
*,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns an organization role to a group within the organization.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._post(
path_template("/organization/groups/{group_id}/roles", group_id=group_id),
body=maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
def retrieve(
self,
role_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves an organization role assigned to a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._get(
path_template("/organization/groups/{group_id}/roles/{role_id}", group_id=group_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
group_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[RoleListResponse]:
"""
Lists the organization roles assigned to a group within the organization.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing organization roles.
limit: A limit on the number of organization role assignments to return.
order: Sort order for the returned organization roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get_api_list(
path_template("/organization/groups/{group_id}/roles", group_id=group_id),
page=SyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
def delete(
self,
role_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns an organization role from a group within the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._delete(
path_template("/organization/groups/{group_id}/roles/{role_id}", group_id=group_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class AsyncRoles(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRolesWithStreamingResponse(self)
async def create(
self,
group_id: str,
*,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns an organization role to a group within the organization.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._post(
path_template("/organization/groups/{group_id}/roles", group_id=group_id),
body=await async_maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
async def retrieve(
self,
role_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves an organization role assigned to a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._get(
path_template("/organization/groups/{group_id}/roles/{role_id}", group_id=group_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
group_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[RoleListResponse, AsyncNextCursorPage[RoleListResponse]]:
"""
Lists the organization roles assigned to a group within the organization.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing organization roles.
limit: A limit on the number of organization role assignments to return.
order: Sort order for the returned organization roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get_api_list(
path_template("/organization/groups/{group_id}/roles", group_id=group_id),
page=AsyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
async def delete(
self,
role_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns an organization role from a group within the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._delete(
path_template("/organization/groups/{group_id}/roles/{role_id}", group_id=group_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class RolesWithRawResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = _legacy_response.to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
roles.delete,
)
class AsyncRolesWithRawResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = _legacy_response.async_to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
roles.delete,
)
class RolesWithStreamingResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = to_streamed_response_wrapper(
roles.create,
)
self.retrieve = to_streamed_response_wrapper(
roles.retrieve,
)
self.list = to_streamed_response_wrapper(
roles.list,
)
self.delete = to_streamed_response_wrapper(
roles.delete,
)
class AsyncRolesWithStreamingResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = async_to_streamed_response_wrapper(
roles.create,
)
self.retrieve = async_to_streamed_response_wrapper(
roles.retrieve,
)
self.list = async_to_streamed_response_wrapper(
roles.list,
)
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)

View File

@@ -0,0 +1,493 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncNextCursorPage, AsyncNextCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.groups import user_list_params, user_create_params
from .....types.admin.organization.groups.user_create_response import UserCreateResponse
from .....types.admin.organization.groups.user_delete_response import UserDeleteResponse
from .....types.admin.organization.groups.user_retrieve_response import UserRetrieveResponse
from .....types.admin.organization.groups.organization_group_user import OrganizationGroupUser
__all__ = ["Users", "AsyncUsers"]
class Users(SyncAPIResource):
@cached_property
def with_raw_response(self) -> UsersWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return UsersWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> UsersWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return UsersWithStreamingResponse(self)
def create(
self,
group_id: str,
*,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserCreateResponse:
"""
Adds a user to a group.
Args:
user_id: Identifier of the user to add to the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._post(
path_template("/organization/groups/{group_id}/users", group_id=group_id),
body=maybe_transform({"user_id": user_id}, user_create_params.UserCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserCreateResponse,
)
def retrieve(
self,
user_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserRetrieveResponse:
"""
Retrieves a user in a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get(
path_template("/organization/groups/{group_id}/users/{user_id}", group_id=group_id, user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserRetrieveResponse,
)
def list(
self,
group_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[OrganizationGroupUser]:
"""
Lists the users assigned to a group.
Args:
after: A cursor for use in pagination. Provide the ID of the last user from the
previous list response to retrieve the next page.
limit: A limit on the number of users to be returned. Limit can range between 0 and
1000, and the default is 100.
order: Specifies the sort order of users in the list.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get_api_list(
path_template("/organization/groups/{group_id}/users", group_id=group_id),
page=SyncNextCursorPage[OrganizationGroupUser],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
user_list_params.UserListParams,
),
security={"admin_api_key_auth": True},
),
model=OrganizationGroupUser,
)
def delete(
self,
user_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserDeleteResponse:
"""
Removes a user from a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._delete(
path_template("/organization/groups/{group_id}/users/{user_id}", group_id=group_id, user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserDeleteResponse,
)
class AsyncUsers(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncUsersWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncUsersWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncUsersWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncUsersWithStreamingResponse(self)
async def create(
self,
group_id: str,
*,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserCreateResponse:
"""
Adds a user to a group.
Args:
user_id: Identifier of the user to add to the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._post(
path_template("/organization/groups/{group_id}/users", group_id=group_id),
body=await async_maybe_transform({"user_id": user_id}, user_create_params.UserCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserCreateResponse,
)
async def retrieve(
self,
user_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserRetrieveResponse:
"""
Retrieves a user in a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._get(
path_template("/organization/groups/{group_id}/users/{user_id}", group_id=group_id, user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserRetrieveResponse,
)
def list(
self,
group_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[OrganizationGroupUser, AsyncNextCursorPage[OrganizationGroupUser]]:
"""
Lists the users assigned to a group.
Args:
after: A cursor for use in pagination. Provide the ID of the last user from the
previous list response to retrieve the next page.
limit: A limit on the number of users to be returned. Limit can range between 0 and
1000, and the default is 100.
order: Specifies the sort order of users in the list.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get_api_list(
path_template("/organization/groups/{group_id}/users", group_id=group_id),
page=AsyncNextCursorPage[OrganizationGroupUser],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
user_list_params.UserListParams,
),
security={"admin_api_key_auth": True},
),
model=OrganizationGroupUser,
)
async def delete(
self,
user_id: str,
*,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserDeleteResponse:
"""
Removes a user from a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._delete(
path_template("/organization/groups/{group_id}/users/{user_id}", group_id=group_id, user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserDeleteResponse,
)
class UsersWithRawResponse:
def __init__(self, users: Users) -> None:
self._users = users
self.create = _legacy_response.to_raw_response_wrapper(
users.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
users.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
users.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
users.delete,
)
class AsyncUsersWithRawResponse:
def __init__(self, users: AsyncUsers) -> None:
self._users = users
self.create = _legacy_response.async_to_raw_response_wrapper(
users.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
users.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
users.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
users.delete,
)
class UsersWithStreamingResponse:
def __init__(self, users: Users) -> None:
self._users = users
self.create = to_streamed_response_wrapper(
users.create,
)
self.retrieve = to_streamed_response_wrapper(
users.retrieve,
)
self.list = to_streamed_response_wrapper(
users.list,
)
self.delete = to_streamed_response_wrapper(
users.delete,
)
class AsyncUsersWithStreamingResponse:
def __init__(self, users: AsyncUsers) -> None:
self._users = users
self.create = async_to_streamed_response_wrapper(
users.create,
)
self.retrieve = async_to_streamed_response_wrapper(
users.retrieve,
)
self.list = async_to_streamed_response_wrapper(
users.list,
)
self.delete = async_to_streamed_response_wrapper(
users.delete,
)

View File

@@ -0,0 +1,502 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Iterable
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ...._utils import path_template, maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.admin.organization import invite_list_params, invite_create_params
from ....types.admin.organization.invite import Invite
from ....types.admin.organization.invite_delete_response import InviteDeleteResponse
__all__ = ["Invites", "AsyncInvites"]
class Invites(SyncAPIResource):
@cached_property
def with_raw_response(self) -> InvitesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return InvitesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> InvitesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return InvitesWithStreamingResponse(self)
def create(
self,
*,
email: str,
role: Literal["reader", "owner"],
projects: Iterable[invite_create_params.Project] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Invite:
"""Create an invite for a user to the organization.
The invite must be accepted by
the user before they have access to the organization.
Args:
email: Send an email to this address
role: `owner` or `reader`
projects: An array of projects to which membership is granted at the same time the org
invite is accepted. If omitted, the user will be invited to the default project
for compatibility with legacy behavior. If empty list is passed, the user will
not be invited to any projects, including the default one.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/invites",
body=maybe_transform(
{
"email": email,
"role": role,
"projects": projects,
},
invite_create_params.InviteCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Invite,
)
def retrieve(
self,
invite_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Invite:
"""
Retrieves an invite.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not invite_id:
raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}")
return self._get(
path_template("/organization/invites/{invite_id}", invite_id=invite_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Invite,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[Invite]:
"""
Returns a list of invites in the organization.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/invites",
page=SyncConversationCursorPage[Invite],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
invite_list_params.InviteListParams,
),
security={"admin_api_key_auth": True},
),
model=Invite,
)
def delete(
self,
invite_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> InviteDeleteResponse:
"""Delete an invite.
If the invite has already been accepted, it cannot be deleted.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not invite_id:
raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}")
return self._delete(
path_template("/organization/invites/{invite_id}", invite_id=invite_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=InviteDeleteResponse,
)
class AsyncInvites(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncInvitesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncInvitesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncInvitesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncInvitesWithStreamingResponse(self)
async def create(
self,
*,
email: str,
role: Literal["reader", "owner"],
projects: Iterable[invite_create_params.Project] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Invite:
"""Create an invite for a user to the organization.
The invite must be accepted by
the user before they have access to the organization.
Args:
email: Send an email to this address
role: `owner` or `reader`
projects: An array of projects to which membership is granted at the same time the org
invite is accepted. If omitted, the user will be invited to the default project
for compatibility with legacy behavior. If empty list is passed, the user will
not be invited to any projects, including the default one.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/invites",
body=await async_maybe_transform(
{
"email": email,
"role": role,
"projects": projects,
},
invite_create_params.InviteCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Invite,
)
async def retrieve(
self,
invite_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Invite:
"""
Retrieves an invite.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not invite_id:
raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}")
return await self._get(
path_template("/organization/invites/{invite_id}", invite_id=invite_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Invite,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[Invite, AsyncConversationCursorPage[Invite]]:
"""
Returns a list of invites in the organization.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/invites",
page=AsyncConversationCursorPage[Invite],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
invite_list_params.InviteListParams,
),
security={"admin_api_key_auth": True},
),
model=Invite,
)
async def delete(
self,
invite_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> InviteDeleteResponse:
"""Delete an invite.
If the invite has already been accepted, it cannot be deleted.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not invite_id:
raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}")
return await self._delete(
path_template("/organization/invites/{invite_id}", invite_id=invite_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=InviteDeleteResponse,
)
class InvitesWithRawResponse:
def __init__(self, invites: Invites) -> None:
self._invites = invites
self.create = _legacy_response.to_raw_response_wrapper(
invites.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
invites.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
invites.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
invites.delete,
)
class AsyncInvitesWithRawResponse:
def __init__(self, invites: AsyncInvites) -> None:
self._invites = invites
self.create = _legacy_response.async_to_raw_response_wrapper(
invites.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
invites.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
invites.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
invites.delete,
)
class InvitesWithStreamingResponse:
def __init__(self, invites: Invites) -> None:
self._invites = invites
self.create = to_streamed_response_wrapper(
invites.create,
)
self.retrieve = to_streamed_response_wrapper(
invites.retrieve,
)
self.list = to_streamed_response_wrapper(
invites.list,
)
self.delete = to_streamed_response_wrapper(
invites.delete,
)
class AsyncInvitesWithStreamingResponse:
def __init__(self, invites: AsyncInvites) -> None:
self._invites = invites
self.create = async_to_streamed_response_wrapper(
invites.create,
)
self.retrieve = async_to_streamed_response_wrapper(
invites.retrieve,
)
self.list = async_to_streamed_response_wrapper(
invites.list,
)
self.delete = async_to_streamed_response_wrapper(
invites.delete,
)

View File

@@ -0,0 +1,428 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .usage import (
Usage,
AsyncUsage,
UsageWithRawResponse,
AsyncUsageWithRawResponse,
UsageWithStreamingResponse,
AsyncUsageWithStreamingResponse,
)
from .invites import (
Invites,
AsyncInvites,
InvitesWithRawResponse,
AsyncInvitesWithRawResponse,
InvitesWithStreamingResponse,
AsyncInvitesWithStreamingResponse,
)
from ...._compat import cached_property
from .audit_logs import (
AuditLogs,
AsyncAuditLogs,
AuditLogsWithRawResponse,
AsyncAuditLogsWithRawResponse,
AuditLogsWithStreamingResponse,
AsyncAuditLogsWithStreamingResponse,
)
from .users.users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
from ...._resource import SyncAPIResource, AsyncAPIResource
from .certificates import (
Certificates,
AsyncCertificates,
CertificatesWithRawResponse,
AsyncCertificatesWithRawResponse,
CertificatesWithStreamingResponse,
AsyncCertificatesWithStreamingResponse,
)
from .spend_alerts import (
SpendAlerts,
AsyncSpendAlerts,
SpendAlertsWithRawResponse,
AsyncSpendAlertsWithRawResponse,
SpendAlertsWithStreamingResponse,
AsyncSpendAlertsWithStreamingResponse,
)
from .groups.groups import (
Groups,
AsyncGroups,
GroupsWithRawResponse,
AsyncGroupsWithRawResponse,
GroupsWithStreamingResponse,
AsyncGroupsWithStreamingResponse,
)
from .admin_api_keys import (
AdminAPIKeys,
AsyncAdminAPIKeys,
AdminAPIKeysWithRawResponse,
AsyncAdminAPIKeysWithRawResponse,
AdminAPIKeysWithStreamingResponse,
AsyncAdminAPIKeysWithStreamingResponse,
)
from .data_retention import (
DataRetention,
AsyncDataRetention,
DataRetentionWithRawResponse,
AsyncDataRetentionWithRawResponse,
DataRetentionWithStreamingResponse,
AsyncDataRetentionWithStreamingResponse,
)
from .projects.projects import (
Projects,
AsyncProjects,
ProjectsWithRawResponse,
AsyncProjectsWithRawResponse,
ProjectsWithStreamingResponse,
AsyncProjectsWithStreamingResponse,
)
__all__ = ["Organization", "AsyncOrganization"]
class Organization(SyncAPIResource):
@cached_property
def audit_logs(self) -> AuditLogs:
"""List user actions and configuration changes within this organization."""
return AuditLogs(self._client)
@cached_property
def admin_api_keys(self) -> AdminAPIKeys:
return AdminAPIKeys(self._client)
@cached_property
def usage(self) -> Usage:
return Usage(self._client)
@cached_property
def invites(self) -> Invites:
return Invites(self._client)
@cached_property
def users(self) -> Users:
return Users(self._client)
@cached_property
def groups(self) -> Groups:
return Groups(self._client)
@cached_property
def roles(self) -> Roles:
return Roles(self._client)
@cached_property
def data_retention(self) -> DataRetention:
return DataRetention(self._client)
@cached_property
def spend_alerts(self) -> SpendAlerts:
return SpendAlerts(self._client)
@cached_property
def certificates(self) -> Certificates:
return Certificates(self._client)
@cached_property
def projects(self) -> Projects:
return Projects(self._client)
@cached_property
def with_raw_response(self) -> OrganizationWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return OrganizationWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> OrganizationWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return OrganizationWithStreamingResponse(self)
class AsyncOrganization(AsyncAPIResource):
@cached_property
def audit_logs(self) -> AsyncAuditLogs:
"""List user actions and configuration changes within this organization."""
return AsyncAuditLogs(self._client)
@cached_property
def admin_api_keys(self) -> AsyncAdminAPIKeys:
return AsyncAdminAPIKeys(self._client)
@cached_property
def usage(self) -> AsyncUsage:
return AsyncUsage(self._client)
@cached_property
def invites(self) -> AsyncInvites:
return AsyncInvites(self._client)
@cached_property
def users(self) -> AsyncUsers:
return AsyncUsers(self._client)
@cached_property
def groups(self) -> AsyncGroups:
return AsyncGroups(self._client)
@cached_property
def roles(self) -> AsyncRoles:
return AsyncRoles(self._client)
@cached_property
def data_retention(self) -> AsyncDataRetention:
return AsyncDataRetention(self._client)
@cached_property
def spend_alerts(self) -> AsyncSpendAlerts:
return AsyncSpendAlerts(self._client)
@cached_property
def certificates(self) -> AsyncCertificates:
return AsyncCertificates(self._client)
@cached_property
def projects(self) -> AsyncProjects:
return AsyncProjects(self._client)
@cached_property
def with_raw_response(self) -> AsyncOrganizationWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncOrganizationWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncOrganizationWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncOrganizationWithStreamingResponse(self)
class OrganizationWithRawResponse:
def __init__(self, organization: Organization) -> None:
self._organization = organization
@cached_property
def audit_logs(self) -> AuditLogsWithRawResponse:
"""List user actions and configuration changes within this organization."""
return AuditLogsWithRawResponse(self._organization.audit_logs)
@cached_property
def admin_api_keys(self) -> AdminAPIKeysWithRawResponse:
return AdminAPIKeysWithRawResponse(self._organization.admin_api_keys)
@cached_property
def usage(self) -> UsageWithRawResponse:
return UsageWithRawResponse(self._organization.usage)
@cached_property
def invites(self) -> InvitesWithRawResponse:
return InvitesWithRawResponse(self._organization.invites)
@cached_property
def users(self) -> UsersWithRawResponse:
return UsersWithRawResponse(self._organization.users)
@cached_property
def groups(self) -> GroupsWithRawResponse:
return GroupsWithRawResponse(self._organization.groups)
@cached_property
def roles(self) -> RolesWithRawResponse:
return RolesWithRawResponse(self._organization.roles)
@cached_property
def data_retention(self) -> DataRetentionWithRawResponse:
return DataRetentionWithRawResponse(self._organization.data_retention)
@cached_property
def spend_alerts(self) -> SpendAlertsWithRawResponse:
return SpendAlertsWithRawResponse(self._organization.spend_alerts)
@cached_property
def certificates(self) -> CertificatesWithRawResponse:
return CertificatesWithRawResponse(self._organization.certificates)
@cached_property
def projects(self) -> ProjectsWithRawResponse:
return ProjectsWithRawResponse(self._organization.projects)
class AsyncOrganizationWithRawResponse:
def __init__(self, organization: AsyncOrganization) -> None:
self._organization = organization
@cached_property
def audit_logs(self) -> AsyncAuditLogsWithRawResponse:
"""List user actions and configuration changes within this organization."""
return AsyncAuditLogsWithRawResponse(self._organization.audit_logs)
@cached_property
def admin_api_keys(self) -> AsyncAdminAPIKeysWithRawResponse:
return AsyncAdminAPIKeysWithRawResponse(self._organization.admin_api_keys)
@cached_property
def usage(self) -> AsyncUsageWithRawResponse:
return AsyncUsageWithRawResponse(self._organization.usage)
@cached_property
def invites(self) -> AsyncInvitesWithRawResponse:
return AsyncInvitesWithRawResponse(self._organization.invites)
@cached_property
def users(self) -> AsyncUsersWithRawResponse:
return AsyncUsersWithRawResponse(self._organization.users)
@cached_property
def groups(self) -> AsyncGroupsWithRawResponse:
return AsyncGroupsWithRawResponse(self._organization.groups)
@cached_property
def roles(self) -> AsyncRolesWithRawResponse:
return AsyncRolesWithRawResponse(self._organization.roles)
@cached_property
def data_retention(self) -> AsyncDataRetentionWithRawResponse:
return AsyncDataRetentionWithRawResponse(self._organization.data_retention)
@cached_property
def spend_alerts(self) -> AsyncSpendAlertsWithRawResponse:
return AsyncSpendAlertsWithRawResponse(self._organization.spend_alerts)
@cached_property
def certificates(self) -> AsyncCertificatesWithRawResponse:
return AsyncCertificatesWithRawResponse(self._organization.certificates)
@cached_property
def projects(self) -> AsyncProjectsWithRawResponse:
return AsyncProjectsWithRawResponse(self._organization.projects)
class OrganizationWithStreamingResponse:
def __init__(self, organization: Organization) -> None:
self._organization = organization
@cached_property
def audit_logs(self) -> AuditLogsWithStreamingResponse:
"""List user actions and configuration changes within this organization."""
return AuditLogsWithStreamingResponse(self._organization.audit_logs)
@cached_property
def admin_api_keys(self) -> AdminAPIKeysWithStreamingResponse:
return AdminAPIKeysWithStreamingResponse(self._organization.admin_api_keys)
@cached_property
def usage(self) -> UsageWithStreamingResponse:
return UsageWithStreamingResponse(self._organization.usage)
@cached_property
def invites(self) -> InvitesWithStreamingResponse:
return InvitesWithStreamingResponse(self._organization.invites)
@cached_property
def users(self) -> UsersWithStreamingResponse:
return UsersWithStreamingResponse(self._organization.users)
@cached_property
def groups(self) -> GroupsWithStreamingResponse:
return GroupsWithStreamingResponse(self._organization.groups)
@cached_property
def roles(self) -> RolesWithStreamingResponse:
return RolesWithStreamingResponse(self._organization.roles)
@cached_property
def data_retention(self) -> DataRetentionWithStreamingResponse:
return DataRetentionWithStreamingResponse(self._organization.data_retention)
@cached_property
def spend_alerts(self) -> SpendAlertsWithStreamingResponse:
return SpendAlertsWithStreamingResponse(self._organization.spend_alerts)
@cached_property
def certificates(self) -> CertificatesWithStreamingResponse:
return CertificatesWithStreamingResponse(self._organization.certificates)
@cached_property
def projects(self) -> ProjectsWithStreamingResponse:
return ProjectsWithStreamingResponse(self._organization.projects)
class AsyncOrganizationWithStreamingResponse:
def __init__(self, organization: AsyncOrganization) -> None:
self._organization = organization
@cached_property
def audit_logs(self) -> AsyncAuditLogsWithStreamingResponse:
"""List user actions and configuration changes within this organization."""
return AsyncAuditLogsWithStreamingResponse(self._organization.audit_logs)
@cached_property
def admin_api_keys(self) -> AsyncAdminAPIKeysWithStreamingResponse:
return AsyncAdminAPIKeysWithStreamingResponse(self._organization.admin_api_keys)
@cached_property
def usage(self) -> AsyncUsageWithStreamingResponse:
return AsyncUsageWithStreamingResponse(self._organization.usage)
@cached_property
def invites(self) -> AsyncInvitesWithStreamingResponse:
return AsyncInvitesWithStreamingResponse(self._organization.invites)
@cached_property
def users(self) -> AsyncUsersWithStreamingResponse:
return AsyncUsersWithStreamingResponse(self._organization.users)
@cached_property
def groups(self) -> AsyncGroupsWithStreamingResponse:
return AsyncGroupsWithStreamingResponse(self._organization.groups)
@cached_property
def roles(self) -> AsyncRolesWithStreamingResponse:
return AsyncRolesWithStreamingResponse(self._organization.roles)
@cached_property
def data_retention(self) -> AsyncDataRetentionWithStreamingResponse:
return AsyncDataRetentionWithStreamingResponse(self._organization.data_retention)
@cached_property
def spend_alerts(self) -> AsyncSpendAlertsWithStreamingResponse:
return AsyncSpendAlertsWithStreamingResponse(self._organization.spend_alerts)
@cached_property
def certificates(self) -> AsyncCertificatesWithStreamingResponse:
return AsyncCertificatesWithStreamingResponse(self._organization.certificates)
@cached_property
def projects(self) -> AsyncProjectsWithStreamingResponse:
return AsyncProjectsWithStreamingResponse(self._organization.projects)

View File

@@ -0,0 +1,173 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
from .groups import (
Groups,
AsyncGroups,
GroupsWithRawResponse,
AsyncGroupsWithRawResponse,
GroupsWithStreamingResponse,
AsyncGroupsWithStreamingResponse,
)
from .api_keys import (
APIKeys,
AsyncAPIKeys,
APIKeysWithRawResponse,
AsyncAPIKeysWithRawResponse,
APIKeysWithStreamingResponse,
AsyncAPIKeysWithStreamingResponse,
)
from .projects import (
Projects,
AsyncProjects,
ProjectsWithRawResponse,
AsyncProjectsWithRawResponse,
ProjectsWithStreamingResponse,
AsyncProjectsWithStreamingResponse,
)
from .rate_limits import (
RateLimits,
AsyncRateLimits,
RateLimitsWithRawResponse,
AsyncRateLimitsWithRawResponse,
RateLimitsWithStreamingResponse,
AsyncRateLimitsWithStreamingResponse,
)
from .certificates import (
Certificates,
AsyncCertificates,
CertificatesWithRawResponse,
AsyncCertificatesWithRawResponse,
CertificatesWithStreamingResponse,
AsyncCertificatesWithStreamingResponse,
)
from .spend_alerts import (
SpendAlerts,
AsyncSpendAlerts,
SpendAlertsWithRawResponse,
AsyncSpendAlertsWithRawResponse,
SpendAlertsWithStreamingResponse,
AsyncSpendAlertsWithStreamingResponse,
)
from .data_retention import (
DataRetention,
AsyncDataRetention,
DataRetentionWithRawResponse,
AsyncDataRetentionWithRawResponse,
DataRetentionWithStreamingResponse,
AsyncDataRetentionWithStreamingResponse,
)
from .service_accounts import (
ServiceAccounts,
AsyncServiceAccounts,
ServiceAccountsWithRawResponse,
AsyncServiceAccountsWithRawResponse,
ServiceAccountsWithStreamingResponse,
AsyncServiceAccountsWithStreamingResponse,
)
from .model_permissions import (
ModelPermissions,
AsyncModelPermissions,
ModelPermissionsWithRawResponse,
AsyncModelPermissionsWithRawResponse,
ModelPermissionsWithStreamingResponse,
AsyncModelPermissionsWithStreamingResponse,
)
from .hosted_tool_permissions import (
HostedToolPermissions,
AsyncHostedToolPermissions,
HostedToolPermissionsWithRawResponse,
AsyncHostedToolPermissionsWithRawResponse,
HostedToolPermissionsWithStreamingResponse,
AsyncHostedToolPermissionsWithStreamingResponse,
)
__all__ = [
"Users",
"AsyncUsers",
"UsersWithRawResponse",
"AsyncUsersWithRawResponse",
"UsersWithStreamingResponse",
"AsyncUsersWithStreamingResponse",
"ServiceAccounts",
"AsyncServiceAccounts",
"ServiceAccountsWithRawResponse",
"AsyncServiceAccountsWithRawResponse",
"ServiceAccountsWithStreamingResponse",
"AsyncServiceAccountsWithStreamingResponse",
"APIKeys",
"AsyncAPIKeys",
"APIKeysWithRawResponse",
"AsyncAPIKeysWithRawResponse",
"APIKeysWithStreamingResponse",
"AsyncAPIKeysWithStreamingResponse",
"RateLimits",
"AsyncRateLimits",
"RateLimitsWithRawResponse",
"AsyncRateLimitsWithRawResponse",
"RateLimitsWithStreamingResponse",
"AsyncRateLimitsWithStreamingResponse",
"ModelPermissions",
"AsyncModelPermissions",
"ModelPermissionsWithRawResponse",
"AsyncModelPermissionsWithRawResponse",
"ModelPermissionsWithStreamingResponse",
"AsyncModelPermissionsWithStreamingResponse",
"HostedToolPermissions",
"AsyncHostedToolPermissions",
"HostedToolPermissionsWithRawResponse",
"AsyncHostedToolPermissionsWithRawResponse",
"HostedToolPermissionsWithStreamingResponse",
"AsyncHostedToolPermissionsWithStreamingResponse",
"Groups",
"AsyncGroups",
"GroupsWithRawResponse",
"AsyncGroupsWithRawResponse",
"GroupsWithStreamingResponse",
"AsyncGroupsWithStreamingResponse",
"Roles",
"AsyncRoles",
"RolesWithRawResponse",
"AsyncRolesWithRawResponse",
"RolesWithStreamingResponse",
"AsyncRolesWithStreamingResponse",
"DataRetention",
"AsyncDataRetention",
"DataRetentionWithRawResponse",
"AsyncDataRetentionWithRawResponse",
"DataRetentionWithStreamingResponse",
"AsyncDataRetentionWithStreamingResponse",
"SpendAlerts",
"AsyncSpendAlerts",
"SpendAlertsWithRawResponse",
"AsyncSpendAlertsWithRawResponse",
"SpendAlertsWithStreamingResponse",
"AsyncSpendAlertsWithStreamingResponse",
"Certificates",
"AsyncCertificates",
"CertificatesWithRawResponse",
"AsyncCertificatesWithRawResponse",
"CertificatesWithStreamingResponse",
"AsyncCertificatesWithStreamingResponse",
"Projects",
"AsyncProjects",
"ProjectsWithRawResponse",
"AsyncProjectsWithRawResponse",
"ProjectsWithStreamingResponse",
"AsyncProjectsWithStreamingResponse",
]

View File

@@ -0,0 +1,413 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.projects import api_key_list_params
from .....types.admin.organization.projects.project_api_key import ProjectAPIKey
from .....types.admin.organization.projects.api_key_delete_response import APIKeyDeleteResponse
__all__ = ["APIKeys", "AsyncAPIKeys"]
class APIKeys(SyncAPIResource):
@cached_property
def with_raw_response(self) -> APIKeysWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return APIKeysWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> APIKeysWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return APIKeysWithStreamingResponse(self)
def retrieve(
self,
api_key_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectAPIKey:
"""
Retrieves an API key in the project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not api_key_id:
raise ValueError(f"Expected a non-empty value for `api_key_id` but received {api_key_id!r}")
return self._get(
path_template(
"/organization/projects/{project_id}/api_keys/{api_key_id}",
project_id=project_id,
api_key_id=api_key_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectAPIKey,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[ProjectAPIKey]:
"""
Returns a list of API keys in the project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/api_keys", project_id=project_id),
page=SyncConversationCursorPage[ProjectAPIKey],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
api_key_list_params.APIKeyListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectAPIKey,
)
def delete(
self,
api_key_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> APIKeyDeleteResponse:
"""
Deletes an API key from the project.
Returns confirmation of the key deletion, or an error if the key belonged to a
service account.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not api_key_id:
raise ValueError(f"Expected a non-empty value for `api_key_id` but received {api_key_id!r}")
return self._delete(
path_template(
"/organization/projects/{project_id}/api_keys/{api_key_id}",
project_id=project_id,
api_key_id=api_key_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=APIKeyDeleteResponse,
)
class AsyncAPIKeys(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncAPIKeysWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncAPIKeysWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncAPIKeysWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncAPIKeysWithStreamingResponse(self)
async def retrieve(
self,
api_key_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectAPIKey:
"""
Retrieves an API key in the project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not api_key_id:
raise ValueError(f"Expected a non-empty value for `api_key_id` but received {api_key_id!r}")
return await self._get(
path_template(
"/organization/projects/{project_id}/api_keys/{api_key_id}",
project_id=project_id,
api_key_id=api_key_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectAPIKey,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ProjectAPIKey, AsyncConversationCursorPage[ProjectAPIKey]]:
"""
Returns a list of API keys in the project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/api_keys", project_id=project_id),
page=AsyncConversationCursorPage[ProjectAPIKey],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
api_key_list_params.APIKeyListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectAPIKey,
)
async def delete(
self,
api_key_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> APIKeyDeleteResponse:
"""
Deletes an API key from the project.
Returns confirmation of the key deletion, or an error if the key belonged to a
service account.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not api_key_id:
raise ValueError(f"Expected a non-empty value for `api_key_id` but received {api_key_id!r}")
return await self._delete(
path_template(
"/organization/projects/{project_id}/api_keys/{api_key_id}",
project_id=project_id,
api_key_id=api_key_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=APIKeyDeleteResponse,
)
class APIKeysWithRawResponse:
def __init__(self, api_keys: APIKeys) -> None:
self._api_keys = api_keys
self.retrieve = _legacy_response.to_raw_response_wrapper(
api_keys.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
api_keys.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
api_keys.delete,
)
class AsyncAPIKeysWithRawResponse:
def __init__(self, api_keys: AsyncAPIKeys) -> None:
self._api_keys = api_keys
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
api_keys.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
api_keys.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
api_keys.delete,
)
class APIKeysWithStreamingResponse:
def __init__(self, api_keys: APIKeys) -> None:
self._api_keys = api_keys
self.retrieve = to_streamed_response_wrapper(
api_keys.retrieve,
)
self.list = to_streamed_response_wrapper(
api_keys.list,
)
self.delete = to_streamed_response_wrapper(
api_keys.delete,
)
class AsyncAPIKeysWithStreamingResponse:
def __init__(self, api_keys: AsyncAPIKeys) -> None:
self._api_keys = api_keys
self.retrieve = async_to_streamed_response_wrapper(
api_keys.retrieve,
)
self.list = async_to_streamed_response_wrapper(
api_keys.list,
)
self.delete = async_to_streamed_response_wrapper(
api_keys.delete,
)

View File

@@ -0,0 +1,428 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from ....._utils import path_template, maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncPage, AsyncPage, SyncConversationCursorPage, AsyncConversationCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.projects import (
certificate_list_params,
certificate_activate_params,
certificate_deactivate_params,
)
from .....types.admin.organization.projects.certificate_list_response import CertificateListResponse
from .....types.admin.organization.projects.certificate_activate_response import CertificateActivateResponse
from .....types.admin.organization.projects.certificate_deactivate_response import CertificateDeactivateResponse
__all__ = ["Certificates", "AsyncCertificates"]
class Certificates(SyncAPIResource):
@cached_property
def with_raw_response(self) -> CertificatesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return CertificatesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> CertificatesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return CertificatesWithStreamingResponse(self)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[CertificateListResponse]:
"""
List certificates for this project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
order and `desc` for descending order.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/certificates", project_id=project_id),
page=SyncConversationCursorPage[CertificateListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
certificate_list_params.CertificateListParams,
),
security={"admin_api_key_auth": True},
),
model=CertificateListResponse,
)
def activate(
self,
project_id: str,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncPage[CertificateActivateResponse]:
"""
Activate certificates at the project level.
You can atomically and idempotently activate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/certificates/activate", project_id=project_id),
page=SyncPage[CertificateActivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_activate_params.CertificateActivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateActivateResponse,
method="post",
)
def deactivate(
self,
project_id: str,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncPage[CertificateDeactivateResponse]:
"""Deactivate certificates at the project level.
You can atomically and
idempotently deactivate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/certificates/deactivate", project_id=project_id),
page=SyncPage[CertificateDeactivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_deactivate_params.CertificateDeactivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateDeactivateResponse,
method="post",
)
class AsyncCertificates(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncCertificatesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncCertificatesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncCertificatesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncCertificatesWithStreamingResponse(self)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[CertificateListResponse, AsyncConversationCursorPage[CertificateListResponse]]:
"""
List certificates for this project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
order and `desc` for descending order.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/certificates", project_id=project_id),
page=AsyncConversationCursorPage[CertificateListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
certificate_list_params.CertificateListParams,
),
security={"admin_api_key_auth": True},
),
model=CertificateListResponse,
)
def activate(
self,
project_id: str,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[CertificateActivateResponse, AsyncPage[CertificateActivateResponse]]:
"""
Activate certificates at the project level.
You can atomically and idempotently activate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/certificates/activate", project_id=project_id),
page=AsyncPage[CertificateActivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_activate_params.CertificateActivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateActivateResponse,
method="post",
)
def deactivate(
self,
project_id: str,
*,
certificate_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[CertificateDeactivateResponse, AsyncPage[CertificateDeactivateResponse]]:
"""Deactivate certificates at the project level.
You can atomically and
idempotently deactivate up to 10 certificates at a time.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/certificates/deactivate", project_id=project_id),
page=AsyncPage[CertificateDeactivateResponse],
body=maybe_transform(
{"certificate_ids": certificate_ids}, certificate_deactivate_params.CertificateDeactivateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
model=CertificateDeactivateResponse,
method="post",
)
class CertificatesWithRawResponse:
def __init__(self, certificates: Certificates) -> None:
self._certificates = certificates
self.list = _legacy_response.to_raw_response_wrapper(
certificates.list,
)
self.activate = _legacy_response.to_raw_response_wrapper(
certificates.activate,
)
self.deactivate = _legacy_response.to_raw_response_wrapper(
certificates.deactivate,
)
class AsyncCertificatesWithRawResponse:
def __init__(self, certificates: AsyncCertificates) -> None:
self._certificates = certificates
self.list = _legacy_response.async_to_raw_response_wrapper(
certificates.list,
)
self.activate = _legacy_response.async_to_raw_response_wrapper(
certificates.activate,
)
self.deactivate = _legacy_response.async_to_raw_response_wrapper(
certificates.deactivate,
)
class CertificatesWithStreamingResponse:
def __init__(self, certificates: Certificates) -> None:
self._certificates = certificates
self.list = to_streamed_response_wrapper(
certificates.list,
)
self.activate = to_streamed_response_wrapper(
certificates.activate,
)
self.deactivate = to_streamed_response_wrapper(
certificates.deactivate,
)
class AsyncCertificatesWithStreamingResponse:
def __init__(self, certificates: AsyncCertificates) -> None:
self._certificates = certificates
self.list = async_to_streamed_response_wrapper(
certificates.list,
)
self.activate = async_to_streamed_response_wrapper(
certificates.activate,
)
self.deactivate = async_to_streamed_response_wrapper(
certificates.deactivate,
)

View File

@@ -0,0 +1,283 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Query, Headers, NotGiven, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....._base_client import make_request_options
from .....types.admin.organization.projects import data_retention_update_params
from .....types.admin.organization.projects.project_data_retention import ProjectDataRetention
__all__ = ["DataRetention", "AsyncDataRetention"]
class DataRetention(SyncAPIResource):
@cached_property
def with_raw_response(self) -> DataRetentionWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return DataRetentionWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> DataRetentionWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return DataRetentionWithStreamingResponse(self)
def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectDataRetention:
"""
Retrieves project data retention controls.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get(
path_template("/organization/projects/{project_id}/data_retention", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectDataRetention,
)
def update(
self,
project_id: str,
*,
retention_type: Literal[
"organization_default",
"none",
"zero_data_retention",
"modified_abuse_monitoring",
"enhanced_zero_data_retention",
"enhanced_modified_abuse_monitoring",
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectDataRetention:
"""
Updates project data retention controls.
Args:
retention_type: The desired project data retention type.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/data_retention", project_id=project_id),
body=maybe_transform(
{"retention_type": retention_type}, data_retention_update_params.DataRetentionUpdateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectDataRetention,
)
class AsyncDataRetention(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncDataRetentionWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncDataRetentionWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncDataRetentionWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncDataRetentionWithStreamingResponse(self)
async def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectDataRetention:
"""
Retrieves project data retention controls.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._get(
path_template("/organization/projects/{project_id}/data_retention", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectDataRetention,
)
async def update(
self,
project_id: str,
*,
retention_type: Literal[
"organization_default",
"none",
"zero_data_retention",
"modified_abuse_monitoring",
"enhanced_zero_data_retention",
"enhanced_modified_abuse_monitoring",
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectDataRetention:
"""
Updates project data retention controls.
Args:
retention_type: The desired project data retention type.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/data_retention", project_id=project_id),
body=await async_maybe_transform(
{"retention_type": retention_type}, data_retention_update_params.DataRetentionUpdateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectDataRetention,
)
class DataRetentionWithRawResponse:
def __init__(self, data_retention: DataRetention) -> None:
self._data_retention = data_retention
self.retrieve = _legacy_response.to_raw_response_wrapper(
data_retention.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
data_retention.update,
)
class AsyncDataRetentionWithRawResponse:
def __init__(self, data_retention: AsyncDataRetention) -> None:
self._data_retention = data_retention
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
data_retention.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
data_retention.update,
)
class DataRetentionWithStreamingResponse:
def __init__(self, data_retention: DataRetention) -> None:
self._data_retention = data_retention
self.retrieve = to_streamed_response_wrapper(
data_retention.retrieve,
)
self.update = to_streamed_response_wrapper(
data_retention.update,
)
class AsyncDataRetentionWithStreamingResponse:
def __init__(self, data_retention: AsyncDataRetention) -> None:
self._data_retention = data_retention
self.retrieve = async_to_streamed_response_wrapper(
data_retention.retrieve,
)
self.update = async_to_streamed_response_wrapper(
data_retention.update,
)

View File

@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .groups import (
Groups,
AsyncGroups,
GroupsWithRawResponse,
AsyncGroupsWithRawResponse,
GroupsWithStreamingResponse,
AsyncGroupsWithStreamingResponse,
)
__all__ = [
"Roles",
"AsyncRoles",
"RolesWithRawResponse",
"AsyncRolesWithRawResponse",
"RolesWithStreamingResponse",
"AsyncRolesWithStreamingResponse",
"Groups",
"AsyncGroups",
"GroupsWithRawResponse",
"AsyncGroupsWithRawResponse",
"GroupsWithStreamingResponse",
"AsyncGroupsWithStreamingResponse",
]

View File

@@ -0,0 +1,557 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ...... import _legacy_response
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ......_utils import path_template, maybe_transform, async_maybe_transform
from ......_compat import cached_property
from ......_resource import SyncAPIResource, AsyncAPIResource
from ......_response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ......pagination import SyncNextCursorPage, AsyncNextCursorPage
from ......_base_client import AsyncPaginator, make_request_options
from ......types.admin.organization.projects import group_list_params, group_create_params, group_retrieve_params
from ......types.admin.organization.projects.project_group import ProjectGroup
from ......types.admin.organization.projects.group_delete_response import GroupDeleteResponse
__all__ = ["Groups", "AsyncGroups"]
class Groups(SyncAPIResource):
@cached_property
def roles(self) -> Roles:
return Roles(self._client)
@cached_property
def with_raw_response(self) -> GroupsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return GroupsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> GroupsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return GroupsWithStreamingResponse(self)
def create(
self,
project_id: str,
*,
group_id: str,
role: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectGroup:
"""
Grants a group access to a project.
Args:
group_id: Identifier of the group to add to the project.
role: Identifier of the project role to grant to the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/groups", project_id=project_id),
body=maybe_transform(
{
"group_id": group_id,
"role": role,
},
group_create_params.GroupCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectGroup,
)
def retrieve(
self,
group_id: str,
*,
project_id: str,
group_type: Literal["group", "tenant_group"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectGroup:
"""
Retrieves a project's group.
Args:
group_type: The type of group to retrieve.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get(
path_template(
"/organization/projects/{project_id}/groups/{group_id}", project_id=project_id, group_id=group_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"group_type": group_type}, group_retrieve_params.GroupRetrieveParams),
security={"admin_api_key_auth": True},
),
cast_to=ProjectGroup,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[ProjectGroup]:
"""
Lists the groups that have access to a project.
Args:
after: Cursor for pagination. Provide the ID of the last group from the previous
response to fetch the next page.
limit: A limit on the number of project groups to return. Defaults to 20.
order: Sort order for the returned groups.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/groups", project_id=project_id),
page=SyncNextCursorPage[ProjectGroup],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
group_list_params.GroupListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectGroup,
)
def delete(
self,
group_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> GroupDeleteResponse:
"""
Revokes a group's access to a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._delete(
path_template(
"/organization/projects/{project_id}/groups/{group_id}", project_id=project_id, group_id=group_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=GroupDeleteResponse,
)
class AsyncGroups(AsyncAPIResource):
@cached_property
def roles(self) -> AsyncRoles:
return AsyncRoles(self._client)
@cached_property
def with_raw_response(self) -> AsyncGroupsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncGroupsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncGroupsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncGroupsWithStreamingResponse(self)
async def create(
self,
project_id: str,
*,
group_id: str,
role: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectGroup:
"""
Grants a group access to a project.
Args:
group_id: Identifier of the group to add to the project.
role: Identifier of the project role to grant to the group.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/groups", project_id=project_id),
body=await async_maybe_transform(
{
"group_id": group_id,
"role": role,
},
group_create_params.GroupCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectGroup,
)
async def retrieve(
self,
group_id: str,
*,
project_id: str,
group_type: Literal["group", "tenant_group"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectGroup:
"""
Retrieves a project's group.
Args:
group_type: The type of group to retrieve.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._get(
path_template(
"/organization/projects/{project_id}/groups/{group_id}", project_id=project_id, group_id=group_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{"group_type": group_type}, group_retrieve_params.GroupRetrieveParams
),
security={"admin_api_key_auth": True},
),
cast_to=ProjectGroup,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ProjectGroup, AsyncNextCursorPage[ProjectGroup]]:
"""
Lists the groups that have access to a project.
Args:
after: Cursor for pagination. Provide the ID of the last group from the previous
response to fetch the next page.
limit: A limit on the number of project groups to return. Defaults to 20.
order: Sort order for the returned groups.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/groups", project_id=project_id),
page=AsyncNextCursorPage[ProjectGroup],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
group_list_params.GroupListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectGroup,
)
async def delete(
self,
group_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> GroupDeleteResponse:
"""
Revokes a group's access to a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._delete(
path_template(
"/organization/projects/{project_id}/groups/{group_id}", project_id=project_id, group_id=group_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=GroupDeleteResponse,
)
class GroupsWithRawResponse:
def __init__(self, groups: Groups) -> None:
self._groups = groups
self.create = _legacy_response.to_raw_response_wrapper(
groups.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
groups.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
groups.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
groups.delete,
)
@cached_property
def roles(self) -> RolesWithRawResponse:
return RolesWithRawResponse(self._groups.roles)
class AsyncGroupsWithRawResponse:
def __init__(self, groups: AsyncGroups) -> None:
self._groups = groups
self.create = _legacy_response.async_to_raw_response_wrapper(
groups.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
groups.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
groups.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
groups.delete,
)
@cached_property
def roles(self) -> AsyncRolesWithRawResponse:
return AsyncRolesWithRawResponse(self._groups.roles)
class GroupsWithStreamingResponse:
def __init__(self, groups: Groups) -> None:
self._groups = groups
self.create = to_streamed_response_wrapper(
groups.create,
)
self.retrieve = to_streamed_response_wrapper(
groups.retrieve,
)
self.list = to_streamed_response_wrapper(
groups.list,
)
self.delete = to_streamed_response_wrapper(
groups.delete,
)
@cached_property
def roles(self) -> RolesWithStreamingResponse:
return RolesWithStreamingResponse(self._groups.roles)
class AsyncGroupsWithStreamingResponse:
def __init__(self, groups: AsyncGroups) -> None:
self._groups = groups
self.create = async_to_streamed_response_wrapper(
groups.create,
)
self.retrieve = async_to_streamed_response_wrapper(
groups.retrieve,
)
self.list = async_to_streamed_response_wrapper(
groups.list,
)
self.delete = async_to_streamed_response_wrapper(
groups.delete,
)
@cached_property
def roles(self) -> AsyncRolesWithStreamingResponse:
return AsyncRolesWithStreamingResponse(self._groups.roles)

View File

@@ -0,0 +1,535 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ...... import _legacy_response
from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ......_utils import path_template, maybe_transform, async_maybe_transform
from ......_compat import cached_property
from ......_resource import SyncAPIResource, AsyncAPIResource
from ......_response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ......pagination import SyncNextCursorPage, AsyncNextCursorPage
from ......_base_client import AsyncPaginator, make_request_options
from ......types.admin.organization.projects.groups import role_list_params, role_create_params
from ......types.admin.organization.projects.groups.role_list_response import RoleListResponse
from ......types.admin.organization.projects.groups.role_create_response import RoleCreateResponse
from ......types.admin.organization.projects.groups.role_delete_response import RoleDeleteResponse
from ......types.admin.organization.projects.groups.role_retrieve_response import RoleRetrieveResponse
__all__ = ["Roles", "AsyncRoles"]
class Roles(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RolesWithStreamingResponse(self)
def create(
self,
group_id: str,
*,
project_id: str,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns a project role to a group within a project.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._post(
path_template("/projects/{project_id}/groups/{group_id}/roles", project_id=project_id, group_id=group_id),
body=maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
def retrieve(
self,
role_id: str,
*,
project_id: str,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves a project role assigned to a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._get(
path_template(
"/projects/{project_id}/groups/{group_id}/roles/{role_id}",
project_id=project_id,
group_id=group_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
group_id: str,
*,
project_id: str,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[RoleListResponse]:
"""
Lists the project roles assigned to a group within a project.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing project roles.
limit: A limit on the number of project role assignments to return.
order: Sort order for the returned project roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get_api_list(
path_template("/projects/{project_id}/groups/{group_id}/roles", project_id=project_id, group_id=group_id),
page=SyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
def delete(
self,
role_id: str,
*,
project_id: str,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns a project role from a group within a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._delete(
path_template(
"/projects/{project_id}/groups/{group_id}/roles/{role_id}",
project_id=project_id,
group_id=group_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class AsyncRoles(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRolesWithStreamingResponse(self)
async def create(
self,
group_id: str,
*,
project_id: str,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns a project role to a group within a project.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return await self._post(
path_template("/projects/{project_id}/groups/{group_id}/roles", project_id=project_id, group_id=group_id),
body=await async_maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
async def retrieve(
self,
role_id: str,
*,
project_id: str,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves a project role assigned to a group.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._get(
path_template(
"/projects/{project_id}/groups/{group_id}/roles/{role_id}",
project_id=project_id,
group_id=group_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
group_id: str,
*,
project_id: str,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[RoleListResponse, AsyncNextCursorPage[RoleListResponse]]:
"""
Lists the project roles assigned to a group within a project.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing project roles.
limit: A limit on the number of project role assignments to return.
order: Sort order for the returned project roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
return self._get_api_list(
path_template("/projects/{project_id}/groups/{group_id}/roles", project_id=project_id, group_id=group_id),
page=AsyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
async def delete(
self,
role_id: str,
*,
project_id: str,
group_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns a project role from a group within a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not group_id:
raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._delete(
path_template(
"/projects/{project_id}/groups/{group_id}/roles/{role_id}",
project_id=project_id,
group_id=group_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class RolesWithRawResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = _legacy_response.to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
roles.delete,
)
class AsyncRolesWithRawResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = _legacy_response.async_to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
roles.delete,
)
class RolesWithStreamingResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = to_streamed_response_wrapper(
roles.create,
)
self.retrieve = to_streamed_response_wrapper(
roles.retrieve,
)
self.list = to_streamed_response_wrapper(
roles.list,
)
self.delete = to_streamed_response_wrapper(
roles.delete,
)
class AsyncRolesWithStreamingResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = async_to_streamed_response_wrapper(
roles.create,
)
self.retrieve = async_to_streamed_response_wrapper(
roles.retrieve,
)
self.list = async_to_streamed_response_wrapper(
roles.list,
)
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)

View File

@@ -0,0 +1,307 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....._base_client import make_request_options
from .....types.admin.organization.projects import hosted_tool_permission_update_params
from .....types.admin.organization.projects.project_hosted_tool_permissions import ProjectHostedToolPermissions
__all__ = ["HostedToolPermissions", "AsyncHostedToolPermissions"]
class HostedToolPermissions(SyncAPIResource):
@cached_property
def with_raw_response(self) -> HostedToolPermissionsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return HostedToolPermissionsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> HostedToolPermissionsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return HostedToolPermissionsWithStreamingResponse(self)
def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectHostedToolPermissions:
"""
Returns hosted tool permissions for a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get(
path_template("/organization/projects/{project_id}/hosted_tool_permissions", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectHostedToolPermissions,
)
def update(
self,
project_id: str,
*,
code_interpreter: Optional[hosted_tool_permission_update_params.CodeInterpreter] | Omit = omit,
file_search: Optional[hosted_tool_permission_update_params.FileSearch] | Omit = omit,
image_generation: Optional[hosted_tool_permission_update_params.ImageGeneration] | Omit = omit,
mcp: Optional[hosted_tool_permission_update_params.Mcp] | Omit = omit,
web_search: Optional[hosted_tool_permission_update_params.WebSearch] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectHostedToolPermissions:
"""
Updates hosted tool permissions for a project.
Args:
code_interpreter: The code interpreter permission update.
file_search: The file search permission update.
image_generation: The image generation permission update.
mcp: The MCP permission update.
web_search: The web search permission update.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/hosted_tool_permissions", project_id=project_id),
body=maybe_transform(
{
"code_interpreter": code_interpreter,
"file_search": file_search,
"image_generation": image_generation,
"mcp": mcp,
"web_search": web_search,
},
hosted_tool_permission_update_params.HostedToolPermissionUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectHostedToolPermissions,
)
class AsyncHostedToolPermissions(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncHostedToolPermissionsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncHostedToolPermissionsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncHostedToolPermissionsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncHostedToolPermissionsWithStreamingResponse(self)
async def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectHostedToolPermissions:
"""
Returns hosted tool permissions for a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._get(
path_template("/organization/projects/{project_id}/hosted_tool_permissions", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectHostedToolPermissions,
)
async def update(
self,
project_id: str,
*,
code_interpreter: Optional[hosted_tool_permission_update_params.CodeInterpreter] | Omit = omit,
file_search: Optional[hosted_tool_permission_update_params.FileSearch] | Omit = omit,
image_generation: Optional[hosted_tool_permission_update_params.ImageGeneration] | Omit = omit,
mcp: Optional[hosted_tool_permission_update_params.Mcp] | Omit = omit,
web_search: Optional[hosted_tool_permission_update_params.WebSearch] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectHostedToolPermissions:
"""
Updates hosted tool permissions for a project.
Args:
code_interpreter: The code interpreter permission update.
file_search: The file search permission update.
image_generation: The image generation permission update.
mcp: The MCP permission update.
web_search: The web search permission update.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/hosted_tool_permissions", project_id=project_id),
body=await async_maybe_transform(
{
"code_interpreter": code_interpreter,
"file_search": file_search,
"image_generation": image_generation,
"mcp": mcp,
"web_search": web_search,
},
hosted_tool_permission_update_params.HostedToolPermissionUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectHostedToolPermissions,
)
class HostedToolPermissionsWithRawResponse:
def __init__(self, hosted_tool_permissions: HostedToolPermissions) -> None:
self._hosted_tool_permissions = hosted_tool_permissions
self.retrieve = _legacy_response.to_raw_response_wrapper(
hosted_tool_permissions.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
hosted_tool_permissions.update,
)
class AsyncHostedToolPermissionsWithRawResponse:
def __init__(self, hosted_tool_permissions: AsyncHostedToolPermissions) -> None:
self._hosted_tool_permissions = hosted_tool_permissions
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
hosted_tool_permissions.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
hosted_tool_permissions.update,
)
class HostedToolPermissionsWithStreamingResponse:
def __init__(self, hosted_tool_permissions: HostedToolPermissions) -> None:
self._hosted_tool_permissions = hosted_tool_permissions
self.retrieve = to_streamed_response_wrapper(
hosted_tool_permissions.retrieve,
)
self.update = to_streamed_response_wrapper(
hosted_tool_permissions.update,
)
class AsyncHostedToolPermissionsWithStreamingResponse:
def __init__(self, hosted_tool_permissions: AsyncHostedToolPermissions) -> None:
self._hosted_tool_permissions = hosted_tool_permissions
self.retrieve = async_to_streamed_response_wrapper(
hosted_tool_permissions.retrieve,
)
self.update = async_to_streamed_response_wrapper(
hosted_tool_permissions.update,
)

View File

@@ -0,0 +1,370 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....._base_client import make_request_options
from .....types.admin.organization.projects import model_permission_update_params
from .....types.admin.organization.projects.project_model_permissions import ProjectModelPermissions
from .....types.admin.organization.projects.project_model_permissions_deleted import ProjectModelPermissionsDeleted
__all__ = ["ModelPermissions", "AsyncModelPermissions"]
class ModelPermissions(SyncAPIResource):
@cached_property
def with_raw_response(self) -> ModelPermissionsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return ModelPermissionsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> ModelPermissionsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return ModelPermissionsWithStreamingResponse(self)
def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectModelPermissions:
"""
Returns model permissions for a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get(
path_template("/organization/projects/{project_id}/model_permissions", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectModelPermissions,
)
def update(
self,
project_id: str,
*,
mode: Literal["allow_list", "deny_list"],
model_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectModelPermissions:
"""
Updates model permissions for a project.
Args:
mode: The model permissions mode to apply.
model_ids: The model IDs included in this permissions policy.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/model_permissions", project_id=project_id),
body=maybe_transform(
{
"mode": mode,
"model_ids": model_ids,
},
model_permission_update_params.ModelPermissionUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectModelPermissions,
)
def delete(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectModelPermissionsDeleted:
"""
Deletes model permissions for a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._delete(
path_template("/organization/projects/{project_id}/model_permissions", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectModelPermissionsDeleted,
)
class AsyncModelPermissions(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncModelPermissionsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncModelPermissionsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncModelPermissionsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncModelPermissionsWithStreamingResponse(self)
async def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectModelPermissions:
"""
Returns model permissions for a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._get(
path_template("/organization/projects/{project_id}/model_permissions", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectModelPermissions,
)
async def update(
self,
project_id: str,
*,
mode: Literal["allow_list", "deny_list"],
model_ids: SequenceNotStr[str],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectModelPermissions:
"""
Updates model permissions for a project.
Args:
mode: The model permissions mode to apply.
model_ids: The model IDs included in this permissions policy.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/model_permissions", project_id=project_id),
body=await async_maybe_transform(
{
"mode": mode,
"model_ids": model_ids,
},
model_permission_update_params.ModelPermissionUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectModelPermissions,
)
async def delete(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectModelPermissionsDeleted:
"""
Deletes model permissions for a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._delete(
path_template("/organization/projects/{project_id}/model_permissions", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectModelPermissionsDeleted,
)
class ModelPermissionsWithRawResponse:
def __init__(self, model_permissions: ModelPermissions) -> None:
self._model_permissions = model_permissions
self.retrieve = _legacy_response.to_raw_response_wrapper(
model_permissions.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
model_permissions.update,
)
self.delete = _legacy_response.to_raw_response_wrapper(
model_permissions.delete,
)
class AsyncModelPermissionsWithRawResponse:
def __init__(self, model_permissions: AsyncModelPermissions) -> None:
self._model_permissions = model_permissions
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
model_permissions.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
model_permissions.update,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
model_permissions.delete,
)
class ModelPermissionsWithStreamingResponse:
def __init__(self, model_permissions: ModelPermissions) -> None:
self._model_permissions = model_permissions
self.retrieve = to_streamed_response_wrapper(
model_permissions.retrieve,
)
self.update = to_streamed_response_wrapper(
model_permissions.update,
)
self.delete = to_streamed_response_wrapper(
model_permissions.delete,
)
class AsyncModelPermissionsWithStreamingResponse:
def __init__(self, model_permissions: AsyncModelPermissions) -> None:
self._model_permissions = model_permissions
self.retrieve = async_to_streamed_response_wrapper(
model_permissions.retrieve,
)
self.update = async_to_streamed_response_wrapper(
model_permissions.update,
)
self.delete = async_to_streamed_response_wrapper(
model_permissions.delete,
)

View File

@@ -0,0 +1,986 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
import httpx
from ..... import _legacy_response
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .api_keys import (
APIKeys,
AsyncAPIKeys,
APIKeysWithRawResponse,
AsyncAPIKeysWithRawResponse,
APIKeysWithStreamingResponse,
AsyncAPIKeysWithStreamingResponse,
)
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from .rate_limits import (
RateLimits,
AsyncRateLimits,
RateLimitsWithRawResponse,
AsyncRateLimitsWithRawResponse,
RateLimitsWithStreamingResponse,
AsyncRateLimitsWithStreamingResponse,
)
from .users.users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
from .certificates import (
Certificates,
AsyncCertificates,
CertificatesWithRawResponse,
AsyncCertificatesWithRawResponse,
CertificatesWithStreamingResponse,
AsyncCertificatesWithStreamingResponse,
)
from .spend_alerts import (
SpendAlerts,
AsyncSpendAlerts,
SpendAlertsWithRawResponse,
AsyncSpendAlertsWithRawResponse,
SpendAlertsWithStreamingResponse,
AsyncSpendAlertsWithStreamingResponse,
)
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .groups.groups import (
Groups,
AsyncGroups,
GroupsWithRawResponse,
AsyncGroupsWithRawResponse,
GroupsWithStreamingResponse,
AsyncGroupsWithStreamingResponse,
)
from .....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from .data_retention import (
DataRetention,
AsyncDataRetention,
DataRetentionWithRawResponse,
AsyncDataRetentionWithRawResponse,
DataRetentionWithStreamingResponse,
AsyncDataRetentionWithStreamingResponse,
)
from ....._base_client import AsyncPaginator, make_request_options
from .service_accounts import (
ServiceAccounts,
AsyncServiceAccounts,
ServiceAccountsWithRawResponse,
AsyncServiceAccountsWithRawResponse,
ServiceAccountsWithStreamingResponse,
AsyncServiceAccountsWithStreamingResponse,
)
from .model_permissions import (
ModelPermissions,
AsyncModelPermissions,
ModelPermissionsWithRawResponse,
AsyncModelPermissionsWithRawResponse,
ModelPermissionsWithStreamingResponse,
AsyncModelPermissionsWithStreamingResponse,
)
from .hosted_tool_permissions import (
HostedToolPermissions,
AsyncHostedToolPermissions,
HostedToolPermissionsWithRawResponse,
AsyncHostedToolPermissionsWithRawResponse,
HostedToolPermissionsWithStreamingResponse,
AsyncHostedToolPermissionsWithStreamingResponse,
)
from .....types.admin.organization import project_list_params, project_create_params, project_update_params
from .....types.admin.organization.project import Project
__all__ = ["Projects", "AsyncProjects"]
class Projects(SyncAPIResource):
@cached_property
def users(self) -> Users:
return Users(self._client)
@cached_property
def service_accounts(self) -> ServiceAccounts:
return ServiceAccounts(self._client)
@cached_property
def api_keys(self) -> APIKeys:
return APIKeys(self._client)
@cached_property
def rate_limits(self) -> RateLimits:
return RateLimits(self._client)
@cached_property
def model_permissions(self) -> ModelPermissions:
return ModelPermissions(self._client)
@cached_property
def hosted_tool_permissions(self) -> HostedToolPermissions:
return HostedToolPermissions(self._client)
@cached_property
def groups(self) -> Groups:
return Groups(self._client)
@cached_property
def roles(self) -> Roles:
return Roles(self._client)
@cached_property
def data_retention(self) -> DataRetention:
return DataRetention(self._client)
@cached_property
def spend_alerts(self) -> SpendAlerts:
return SpendAlerts(self._client)
@cached_property
def certificates(self) -> Certificates:
return Certificates(self._client)
@cached_property
def with_raw_response(self) -> ProjectsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return ProjectsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> ProjectsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return ProjectsWithStreamingResponse(self)
def create(
self,
*,
name: str,
external_key_id: Optional[str] | Omit = omit,
geography: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""Create a new project in the organization.
Projects can be created and archived,
but cannot be deleted.
Args:
name: The friendly name of the project, this name appears in reports.
external_key_id: External key ID to associate with the project.
geography: Create the project with the specified data residency region. Your organization
must have access to Data residency functionality in order to use. See
[data residency controls](https://platform.openai.com/docs/guides/your-data#data-residency-controls)
to review the functionality and limitations of setting this field.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/projects",
body=maybe_transform(
{
"name": name,
"external_key_id": external_key_id,
"geography": geography,
},
project_create_params.ProjectCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""
Retrieves a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get(
path_template("/organization/projects/{project_id}", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
def update(
self,
project_id: str,
*,
external_key_id: Optional[str] | Omit = omit,
geography: Optional[str] | Omit = omit,
name: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""
Modifies a project in the organization.
Args:
external_key_id: External key ID to associate with the project.
geography: Geography for the project.
name: The updated name of the project, this name appears in reports.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}", project_id=project_id),
body=maybe_transform(
{
"external_key_id": external_key_id,
"geography": geography,
"name": name,
},
project_update_params.ProjectUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
def list(
self,
*,
after: str | Omit = omit,
include_archived: bool | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[Project]:
"""Returns a list of projects.
Args:
after: A cursor for use in pagination.
`after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
include_archived: If `true` returns all projects including those that have been `archived`.
Archived projects are not included by default.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/projects",
page=SyncConversationCursorPage[Project],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"include_archived": include_archived,
"limit": limit,
},
project_list_params.ProjectListParams,
),
security={"admin_api_key_auth": True},
),
model=Project,
)
def archive(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""Archives a project in the organization.
Archived projects cannot be used or
updated.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/archive", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
class AsyncProjects(AsyncAPIResource):
@cached_property
def users(self) -> AsyncUsers:
return AsyncUsers(self._client)
@cached_property
def service_accounts(self) -> AsyncServiceAccounts:
return AsyncServiceAccounts(self._client)
@cached_property
def api_keys(self) -> AsyncAPIKeys:
return AsyncAPIKeys(self._client)
@cached_property
def rate_limits(self) -> AsyncRateLimits:
return AsyncRateLimits(self._client)
@cached_property
def model_permissions(self) -> AsyncModelPermissions:
return AsyncModelPermissions(self._client)
@cached_property
def hosted_tool_permissions(self) -> AsyncHostedToolPermissions:
return AsyncHostedToolPermissions(self._client)
@cached_property
def groups(self) -> AsyncGroups:
return AsyncGroups(self._client)
@cached_property
def roles(self) -> AsyncRoles:
return AsyncRoles(self._client)
@cached_property
def data_retention(self) -> AsyncDataRetention:
return AsyncDataRetention(self._client)
@cached_property
def spend_alerts(self) -> AsyncSpendAlerts:
return AsyncSpendAlerts(self._client)
@cached_property
def certificates(self) -> AsyncCertificates:
return AsyncCertificates(self._client)
@cached_property
def with_raw_response(self) -> AsyncProjectsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncProjectsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncProjectsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncProjectsWithStreamingResponse(self)
async def create(
self,
*,
name: str,
external_key_id: Optional[str] | Omit = omit,
geography: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""Create a new project in the organization.
Projects can be created and archived,
but cannot be deleted.
Args:
name: The friendly name of the project, this name appears in reports.
external_key_id: External key ID to associate with the project.
geography: Create the project with the specified data residency region. Your organization
must have access to Data residency functionality in order to use. See
[data residency controls](https://platform.openai.com/docs/guides/your-data#data-residency-controls)
to review the functionality and limitations of setting this field.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/projects",
body=await async_maybe_transform(
{
"name": name,
"external_key_id": external_key_id,
"geography": geography,
},
project_create_params.ProjectCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
async def retrieve(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""
Retrieves a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._get(
path_template("/organization/projects/{project_id}", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
async def update(
self,
project_id: str,
*,
external_key_id: Optional[str] | Omit = omit,
geography: Optional[str] | Omit = omit,
name: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""
Modifies a project in the organization.
Args:
external_key_id: External key ID to associate with the project.
geography: Geography for the project.
name: The updated name of the project, this name appears in reports.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}", project_id=project_id),
body=await async_maybe_transform(
{
"external_key_id": external_key_id,
"geography": geography,
"name": name,
},
project_update_params.ProjectUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
def list(
self,
*,
after: str | Omit = omit,
include_archived: bool | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[Project, AsyncConversationCursorPage[Project]]:
"""Returns a list of projects.
Args:
after: A cursor for use in pagination.
`after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
include_archived: If `true` returns all projects including those that have been `archived`.
Archived projects are not included by default.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/projects",
page=AsyncConversationCursorPage[Project],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"include_archived": include_archived,
"limit": limit,
},
project_list_params.ProjectListParams,
),
security={"admin_api_key_auth": True},
),
model=Project,
)
async def archive(
self,
project_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Project:
"""Archives a project in the organization.
Archived projects cannot be used or
updated.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/archive", project_id=project_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Project,
)
class ProjectsWithRawResponse:
def __init__(self, projects: Projects) -> None:
self._projects = projects
self.create = _legacy_response.to_raw_response_wrapper(
projects.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
projects.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
projects.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
projects.list,
)
self.archive = _legacy_response.to_raw_response_wrapper(
projects.archive,
)
@cached_property
def users(self) -> UsersWithRawResponse:
return UsersWithRawResponse(self._projects.users)
@cached_property
def service_accounts(self) -> ServiceAccountsWithRawResponse:
return ServiceAccountsWithRawResponse(self._projects.service_accounts)
@cached_property
def api_keys(self) -> APIKeysWithRawResponse:
return APIKeysWithRawResponse(self._projects.api_keys)
@cached_property
def rate_limits(self) -> RateLimitsWithRawResponse:
return RateLimitsWithRawResponse(self._projects.rate_limits)
@cached_property
def model_permissions(self) -> ModelPermissionsWithRawResponse:
return ModelPermissionsWithRawResponse(self._projects.model_permissions)
@cached_property
def hosted_tool_permissions(self) -> HostedToolPermissionsWithRawResponse:
return HostedToolPermissionsWithRawResponse(self._projects.hosted_tool_permissions)
@cached_property
def groups(self) -> GroupsWithRawResponse:
return GroupsWithRawResponse(self._projects.groups)
@cached_property
def roles(self) -> RolesWithRawResponse:
return RolesWithRawResponse(self._projects.roles)
@cached_property
def data_retention(self) -> DataRetentionWithRawResponse:
return DataRetentionWithRawResponse(self._projects.data_retention)
@cached_property
def spend_alerts(self) -> SpendAlertsWithRawResponse:
return SpendAlertsWithRawResponse(self._projects.spend_alerts)
@cached_property
def certificates(self) -> CertificatesWithRawResponse:
return CertificatesWithRawResponse(self._projects.certificates)
class AsyncProjectsWithRawResponse:
def __init__(self, projects: AsyncProjects) -> None:
self._projects = projects
self.create = _legacy_response.async_to_raw_response_wrapper(
projects.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
projects.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
projects.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
projects.list,
)
self.archive = _legacy_response.async_to_raw_response_wrapper(
projects.archive,
)
@cached_property
def users(self) -> AsyncUsersWithRawResponse:
return AsyncUsersWithRawResponse(self._projects.users)
@cached_property
def service_accounts(self) -> AsyncServiceAccountsWithRawResponse:
return AsyncServiceAccountsWithRawResponse(self._projects.service_accounts)
@cached_property
def api_keys(self) -> AsyncAPIKeysWithRawResponse:
return AsyncAPIKeysWithRawResponse(self._projects.api_keys)
@cached_property
def rate_limits(self) -> AsyncRateLimitsWithRawResponse:
return AsyncRateLimitsWithRawResponse(self._projects.rate_limits)
@cached_property
def model_permissions(self) -> AsyncModelPermissionsWithRawResponse:
return AsyncModelPermissionsWithRawResponse(self._projects.model_permissions)
@cached_property
def hosted_tool_permissions(self) -> AsyncHostedToolPermissionsWithRawResponse:
return AsyncHostedToolPermissionsWithRawResponse(self._projects.hosted_tool_permissions)
@cached_property
def groups(self) -> AsyncGroupsWithRawResponse:
return AsyncGroupsWithRawResponse(self._projects.groups)
@cached_property
def roles(self) -> AsyncRolesWithRawResponse:
return AsyncRolesWithRawResponse(self._projects.roles)
@cached_property
def data_retention(self) -> AsyncDataRetentionWithRawResponse:
return AsyncDataRetentionWithRawResponse(self._projects.data_retention)
@cached_property
def spend_alerts(self) -> AsyncSpendAlertsWithRawResponse:
return AsyncSpendAlertsWithRawResponse(self._projects.spend_alerts)
@cached_property
def certificates(self) -> AsyncCertificatesWithRawResponse:
return AsyncCertificatesWithRawResponse(self._projects.certificates)
class ProjectsWithStreamingResponse:
def __init__(self, projects: Projects) -> None:
self._projects = projects
self.create = to_streamed_response_wrapper(
projects.create,
)
self.retrieve = to_streamed_response_wrapper(
projects.retrieve,
)
self.update = to_streamed_response_wrapper(
projects.update,
)
self.list = to_streamed_response_wrapper(
projects.list,
)
self.archive = to_streamed_response_wrapper(
projects.archive,
)
@cached_property
def users(self) -> UsersWithStreamingResponse:
return UsersWithStreamingResponse(self._projects.users)
@cached_property
def service_accounts(self) -> ServiceAccountsWithStreamingResponse:
return ServiceAccountsWithStreamingResponse(self._projects.service_accounts)
@cached_property
def api_keys(self) -> APIKeysWithStreamingResponse:
return APIKeysWithStreamingResponse(self._projects.api_keys)
@cached_property
def rate_limits(self) -> RateLimitsWithStreamingResponse:
return RateLimitsWithStreamingResponse(self._projects.rate_limits)
@cached_property
def model_permissions(self) -> ModelPermissionsWithStreamingResponse:
return ModelPermissionsWithStreamingResponse(self._projects.model_permissions)
@cached_property
def hosted_tool_permissions(self) -> HostedToolPermissionsWithStreamingResponse:
return HostedToolPermissionsWithStreamingResponse(self._projects.hosted_tool_permissions)
@cached_property
def groups(self) -> GroupsWithStreamingResponse:
return GroupsWithStreamingResponse(self._projects.groups)
@cached_property
def roles(self) -> RolesWithStreamingResponse:
return RolesWithStreamingResponse(self._projects.roles)
@cached_property
def data_retention(self) -> DataRetentionWithStreamingResponse:
return DataRetentionWithStreamingResponse(self._projects.data_retention)
@cached_property
def spend_alerts(self) -> SpendAlertsWithStreamingResponse:
return SpendAlertsWithStreamingResponse(self._projects.spend_alerts)
@cached_property
def certificates(self) -> CertificatesWithStreamingResponse:
return CertificatesWithStreamingResponse(self._projects.certificates)
class AsyncProjectsWithStreamingResponse:
def __init__(self, projects: AsyncProjects) -> None:
self._projects = projects
self.create = async_to_streamed_response_wrapper(
projects.create,
)
self.retrieve = async_to_streamed_response_wrapper(
projects.retrieve,
)
self.update = async_to_streamed_response_wrapper(
projects.update,
)
self.list = async_to_streamed_response_wrapper(
projects.list,
)
self.archive = async_to_streamed_response_wrapper(
projects.archive,
)
@cached_property
def users(self) -> AsyncUsersWithStreamingResponse:
return AsyncUsersWithStreamingResponse(self._projects.users)
@cached_property
def service_accounts(self) -> AsyncServiceAccountsWithStreamingResponse:
return AsyncServiceAccountsWithStreamingResponse(self._projects.service_accounts)
@cached_property
def api_keys(self) -> AsyncAPIKeysWithStreamingResponse:
return AsyncAPIKeysWithStreamingResponse(self._projects.api_keys)
@cached_property
def rate_limits(self) -> AsyncRateLimitsWithStreamingResponse:
return AsyncRateLimitsWithStreamingResponse(self._projects.rate_limits)
@cached_property
def model_permissions(self) -> AsyncModelPermissionsWithStreamingResponse:
return AsyncModelPermissionsWithStreamingResponse(self._projects.model_permissions)
@cached_property
def hosted_tool_permissions(self) -> AsyncHostedToolPermissionsWithStreamingResponse:
return AsyncHostedToolPermissionsWithStreamingResponse(self._projects.hosted_tool_permissions)
@cached_property
def groups(self) -> AsyncGroupsWithStreamingResponse:
return AsyncGroupsWithStreamingResponse(self._projects.groups)
@cached_property
def roles(self) -> AsyncRolesWithStreamingResponse:
return AsyncRolesWithStreamingResponse(self._projects.roles)
@cached_property
def data_retention(self) -> AsyncDataRetentionWithStreamingResponse:
return AsyncDataRetentionWithStreamingResponse(self._projects.data_retention)
@cached_property
def spend_alerts(self) -> AsyncSpendAlertsWithStreamingResponse:
return AsyncSpendAlertsWithStreamingResponse(self._projects.spend_alerts)
@cached_property
def certificates(self) -> AsyncCertificatesWithStreamingResponse:
return AsyncCertificatesWithStreamingResponse(self._projects.certificates)

View File

@@ -0,0 +1,379 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.projects import (
rate_limit_list_rate_limits_params,
rate_limit_update_rate_limit_params,
)
from .....types.admin.organization.projects.project_rate_limit import ProjectRateLimit
__all__ = ["RateLimits", "AsyncRateLimits"]
class RateLimits(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RateLimitsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RateLimitsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RateLimitsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RateLimitsWithStreamingResponse(self)
def list_rate_limits(
self,
project_id: str,
*,
after: str | Omit = omit,
before: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[ProjectRateLimit]:
"""
Returns the rate limits per model for a project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
before: A cursor for use in pagination. `before` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
beginning with obj_foo, your subsequent call can include before=obj_foo in order
to fetch the previous page of the list.
limit: A limit on the number of objects to be returned. The default is 100.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/rate_limits", project_id=project_id),
page=SyncConversationCursorPage[ProjectRateLimit],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"before": before,
"limit": limit,
},
rate_limit_list_rate_limits_params.RateLimitListRateLimitsParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectRateLimit,
)
def update_rate_limit(
self,
rate_limit_id: str,
*,
project_id: str,
batch_1_day_max_input_tokens: int | Omit = omit,
max_audio_megabytes_per_1_minute: int | Omit = omit,
max_images_per_1_minute: int | Omit = omit,
max_requests_per_1_day: int | Omit = omit,
max_requests_per_1_minute: int | Omit = omit,
max_tokens_per_1_minute: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectRateLimit:
"""
Updates a project rate limit.
Args:
batch_1_day_max_input_tokens: The maximum batch input tokens per day. Only relevant for certain models.
max_audio_megabytes_per_1_minute: The maximum audio megabytes per minute. Only relevant for certain models.
max_images_per_1_minute: The maximum images per minute. Only relevant for certain models.
max_requests_per_1_day: The maximum requests per day. Only relevant for certain models.
max_requests_per_1_minute: The maximum requests per minute.
max_tokens_per_1_minute: The maximum tokens per minute.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not rate_limit_id:
raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}")
return self._post(
path_template(
"/organization/projects/{project_id}/rate_limits/{rate_limit_id}",
project_id=project_id,
rate_limit_id=rate_limit_id,
),
body=maybe_transform(
{
"batch_1_day_max_input_tokens": batch_1_day_max_input_tokens,
"max_audio_megabytes_per_1_minute": max_audio_megabytes_per_1_minute,
"max_images_per_1_minute": max_images_per_1_minute,
"max_requests_per_1_day": max_requests_per_1_day,
"max_requests_per_1_minute": max_requests_per_1_minute,
"max_tokens_per_1_minute": max_tokens_per_1_minute,
},
rate_limit_update_rate_limit_params.RateLimitUpdateRateLimitParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectRateLimit,
)
class AsyncRateLimits(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRateLimitsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRateLimitsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRateLimitsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRateLimitsWithStreamingResponse(self)
def list_rate_limits(
self,
project_id: str,
*,
after: str | Omit = omit,
before: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ProjectRateLimit, AsyncConversationCursorPage[ProjectRateLimit]]:
"""
Returns the rate limits per model for a project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
before: A cursor for use in pagination. `before` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
beginning with obj_foo, your subsequent call can include before=obj_foo in order
to fetch the previous page of the list.
limit: A limit on the number of objects to be returned. The default is 100.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/rate_limits", project_id=project_id),
page=AsyncConversationCursorPage[ProjectRateLimit],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"before": before,
"limit": limit,
},
rate_limit_list_rate_limits_params.RateLimitListRateLimitsParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectRateLimit,
)
async def update_rate_limit(
self,
rate_limit_id: str,
*,
project_id: str,
batch_1_day_max_input_tokens: int | Omit = omit,
max_audio_megabytes_per_1_minute: int | Omit = omit,
max_images_per_1_minute: int | Omit = omit,
max_requests_per_1_day: int | Omit = omit,
max_requests_per_1_minute: int | Omit = omit,
max_tokens_per_1_minute: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectRateLimit:
"""
Updates a project rate limit.
Args:
batch_1_day_max_input_tokens: The maximum batch input tokens per day. Only relevant for certain models.
max_audio_megabytes_per_1_minute: The maximum audio megabytes per minute. Only relevant for certain models.
max_images_per_1_minute: The maximum images per minute. Only relevant for certain models.
max_requests_per_1_day: The maximum requests per day. Only relevant for certain models.
max_requests_per_1_minute: The maximum requests per minute.
max_tokens_per_1_minute: The maximum tokens per minute.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not rate_limit_id:
raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}")
return await self._post(
path_template(
"/organization/projects/{project_id}/rate_limits/{rate_limit_id}",
project_id=project_id,
rate_limit_id=rate_limit_id,
),
body=await async_maybe_transform(
{
"batch_1_day_max_input_tokens": batch_1_day_max_input_tokens,
"max_audio_megabytes_per_1_minute": max_audio_megabytes_per_1_minute,
"max_images_per_1_minute": max_images_per_1_minute,
"max_requests_per_1_day": max_requests_per_1_day,
"max_requests_per_1_minute": max_requests_per_1_minute,
"max_tokens_per_1_minute": max_tokens_per_1_minute,
},
rate_limit_update_rate_limit_params.RateLimitUpdateRateLimitParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectRateLimit,
)
class RateLimitsWithRawResponse:
def __init__(self, rate_limits: RateLimits) -> None:
self._rate_limits = rate_limits
self.list_rate_limits = _legacy_response.to_raw_response_wrapper(
rate_limits.list_rate_limits,
)
self.update_rate_limit = _legacy_response.to_raw_response_wrapper(
rate_limits.update_rate_limit,
)
class AsyncRateLimitsWithRawResponse:
def __init__(self, rate_limits: AsyncRateLimits) -> None:
self._rate_limits = rate_limits
self.list_rate_limits = _legacy_response.async_to_raw_response_wrapper(
rate_limits.list_rate_limits,
)
self.update_rate_limit = _legacy_response.async_to_raw_response_wrapper(
rate_limits.update_rate_limit,
)
class RateLimitsWithStreamingResponse:
def __init__(self, rate_limits: RateLimits) -> None:
self._rate_limits = rate_limits
self.list_rate_limits = to_streamed_response_wrapper(
rate_limits.list_rate_limits,
)
self.update_rate_limit = to_streamed_response_wrapper(
rate_limits.update_rate_limit,
)
class AsyncRateLimitsWithStreamingResponse:
def __init__(self, rate_limits: AsyncRateLimits) -> None:
self._rate_limits = rate_limits
self.list_rate_limits = async_to_streamed_response_wrapper(
rate_limits.list_rate_limits,
)
self.update_rate_limit = async_to_streamed_response_wrapper(
rate_limits.update_rate_limit,
)

View File

@@ -0,0 +1,644 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncNextCursorPage, AsyncNextCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.role import Role
from .....types.admin.organization.projects import role_list_params, role_create_params, role_update_params
from .....types.admin.organization.projects.role_delete_response import RoleDeleteResponse
__all__ = ["Roles", "AsyncRoles"]
class Roles(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RolesWithStreamingResponse(self)
def create(
self,
project_id: str,
*,
permissions: SequenceNotStr[str],
role_name: str,
description: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Creates a custom role for a project.
Args:
permissions: Permissions to grant to the role.
role_name: Unique name for the role.
description: Optional description of the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/projects/{project_id}/roles", project_id=project_id),
body=maybe_transform(
{
"permissions": permissions,
"role_name": role_name,
"description": description,
},
role_create_params.RoleCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def retrieve(
self,
role_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Retrieves a project role.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._get(
path_template("/projects/{project_id}/roles/{role_id}", project_id=project_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def update(
self,
role_id: str,
*,
project_id: str,
description: Optional[str] | Omit = omit,
permissions: Optional[SequenceNotStr[str]] | Omit = omit,
role_name: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Updates an existing project role.
Args:
description: New description for the role.
permissions: Updated set of permissions for the role.
role_name: New name for the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._post(
path_template("/projects/{project_id}/roles/{role_id}", project_id=project_id, role_id=role_id),
body=maybe_transform(
{
"description": description,
"permissions": permissions,
"role_name": role_name,
},
role_update_params.RoleUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[Role]:
"""Lists the roles configured for a project.
Args:
after: Cursor for pagination.
Provide the value from the previous response's `next`
field to continue listing roles.
limit: A limit on the number of roles to return. Defaults to 1000.
order: Sort order for the returned roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/projects/{project_id}/roles", project_id=project_id),
page=SyncNextCursorPage[Role],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=Role,
)
def delete(
self,
role_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Deletes a custom role from a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._delete(
path_template("/projects/{project_id}/roles/{role_id}", project_id=project_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class AsyncRoles(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRolesWithStreamingResponse(self)
async def create(
self,
project_id: str,
*,
permissions: SequenceNotStr[str],
role_name: str,
description: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Creates a custom role for a project.
Args:
permissions: Permissions to grant to the role.
role_name: Unique name for the role.
description: Optional description of the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/projects/{project_id}/roles", project_id=project_id),
body=await async_maybe_transform(
{
"permissions": permissions,
"role_name": role_name,
"description": description,
},
role_create_params.RoleCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
async def retrieve(
self,
role_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Retrieves a project role.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._get(
path_template("/projects/{project_id}/roles/{role_id}", project_id=project_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
async def update(
self,
role_id: str,
*,
project_id: str,
description: Optional[str] | Omit = omit,
permissions: Optional[SequenceNotStr[str]] | Omit = omit,
role_name: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Updates an existing project role.
Args:
description: New description for the role.
permissions: Updated set of permissions for the role.
role_name: New name for the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._post(
path_template("/projects/{project_id}/roles/{role_id}", project_id=project_id, role_id=role_id),
body=await async_maybe_transform(
{
"description": description,
"permissions": permissions,
"role_name": role_name,
},
role_update_params.RoleUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[Role, AsyncNextCursorPage[Role]]:
"""Lists the roles configured for a project.
Args:
after: Cursor for pagination.
Provide the value from the previous response's `next`
field to continue listing roles.
limit: A limit on the number of roles to return. Defaults to 1000.
order: Sort order for the returned roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/projects/{project_id}/roles", project_id=project_id),
page=AsyncNextCursorPage[Role],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=Role,
)
async def delete(
self,
role_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Deletes a custom role from a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._delete(
path_template("/projects/{project_id}/roles/{role_id}", project_id=project_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class RolesWithRawResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = _legacy_response.to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
roles.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
roles.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
roles.delete,
)
class AsyncRolesWithRawResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = _legacy_response.async_to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
roles.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
roles.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
roles.delete,
)
class RolesWithStreamingResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = to_streamed_response_wrapper(
roles.create,
)
self.retrieve = to_streamed_response_wrapper(
roles.retrieve,
)
self.update = to_streamed_response_wrapper(
roles.update,
)
self.list = to_streamed_response_wrapper(
roles.list,
)
self.delete = to_streamed_response_wrapper(
roles.delete,
)
class AsyncRolesWithStreamingResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = async_to_streamed_response_wrapper(
roles.create,
)
self.retrieve = async_to_streamed_response_wrapper(
roles.retrieve,
)
self.update = async_to_streamed_response_wrapper(
roles.update,
)
self.list = async_to_streamed_response_wrapper(
roles.list,
)
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)

View File

@@ -0,0 +1,644 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.projects import (
service_account_list_params,
service_account_create_params,
service_account_update_params,
)
from .....types.admin.organization.projects.project_service_account import ProjectServiceAccount
from .....types.admin.organization.projects.service_account_create_response import ServiceAccountCreateResponse
from .....types.admin.organization.projects.service_account_delete_response import ServiceAccountDeleteResponse
__all__ = ["ServiceAccounts", "AsyncServiceAccounts"]
class ServiceAccounts(SyncAPIResource):
@cached_property
def with_raw_response(self) -> ServiceAccountsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return ServiceAccountsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> ServiceAccountsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return ServiceAccountsWithStreamingResponse(self)
def create(
self,
project_id: str,
*,
name: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ServiceAccountCreateResponse:
"""Creates a new service account in the project.
This also returns an unredacted
API key for the service account.
Args:
name: The name of the service account being created.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/service_accounts", project_id=project_id),
body=maybe_transform({"name": name}, service_account_create_params.ServiceAccountCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ServiceAccountCreateResponse,
)
def retrieve(
self,
service_account_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectServiceAccount:
"""
Retrieves a service account in the project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not service_account_id:
raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
return self._get(
path_template(
"/organization/projects/{project_id}/service_accounts/{service_account_id}",
project_id=project_id,
service_account_id=service_account_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectServiceAccount,
)
def update(
self,
service_account_id: str,
*,
project_id: str,
name: str | Omit = omit,
role: Literal["member", "owner"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectServiceAccount:
"""
Updates a service account in the project.
Args:
name: The updated service account name.
role: The updated service account role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not service_account_id:
raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
return self._post(
path_template(
"/organization/projects/{project_id}/service_accounts/{service_account_id}",
project_id=project_id,
service_account_id=service_account_id,
),
body=maybe_transform(
{
"name": name,
"role": role,
},
service_account_update_params.ServiceAccountUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectServiceAccount,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[ProjectServiceAccount]:
"""
Returns a list of service accounts in the project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/service_accounts", project_id=project_id),
page=SyncConversationCursorPage[ProjectServiceAccount],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
service_account_list_params.ServiceAccountListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectServiceAccount,
)
def delete(
self,
service_account_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ServiceAccountDeleteResponse:
"""
Deletes a service account from the project.
Returns confirmation of service account deletion, or an error if the project is
archived (archived projects have no service accounts).
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not service_account_id:
raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
return self._delete(
path_template(
"/organization/projects/{project_id}/service_accounts/{service_account_id}",
project_id=project_id,
service_account_id=service_account_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ServiceAccountDeleteResponse,
)
class AsyncServiceAccounts(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncServiceAccountsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncServiceAccountsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncServiceAccountsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncServiceAccountsWithStreamingResponse(self)
async def create(
self,
project_id: str,
*,
name: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ServiceAccountCreateResponse:
"""Creates a new service account in the project.
This also returns an unredacted
API key for the service account.
Args:
name: The name of the service account being created.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/service_accounts", project_id=project_id),
body=await async_maybe_transform({"name": name}, service_account_create_params.ServiceAccountCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ServiceAccountCreateResponse,
)
async def retrieve(
self,
service_account_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectServiceAccount:
"""
Retrieves a service account in the project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not service_account_id:
raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
return await self._get(
path_template(
"/organization/projects/{project_id}/service_accounts/{service_account_id}",
project_id=project_id,
service_account_id=service_account_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectServiceAccount,
)
async def update(
self,
service_account_id: str,
*,
project_id: str,
name: str | Omit = omit,
role: Literal["member", "owner"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectServiceAccount:
"""
Updates a service account in the project.
Args:
name: The updated service account name.
role: The updated service account role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not service_account_id:
raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
return await self._post(
path_template(
"/organization/projects/{project_id}/service_accounts/{service_account_id}",
project_id=project_id,
service_account_id=service_account_id,
),
body=await async_maybe_transform(
{
"name": name,
"role": role,
},
service_account_update_params.ServiceAccountUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectServiceAccount,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ProjectServiceAccount, AsyncConversationCursorPage[ProjectServiceAccount]]:
"""
Returns a list of service accounts in the project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/service_accounts", project_id=project_id),
page=AsyncConversationCursorPage[ProjectServiceAccount],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
service_account_list_params.ServiceAccountListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectServiceAccount,
)
async def delete(
self,
service_account_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ServiceAccountDeleteResponse:
"""
Deletes a service account from the project.
Returns confirmation of service account deletion, or an error if the project is
archived (archived projects have no service accounts).
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not service_account_id:
raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
return await self._delete(
path_template(
"/organization/projects/{project_id}/service_accounts/{service_account_id}",
project_id=project_id,
service_account_id=service_account_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ServiceAccountDeleteResponse,
)
class ServiceAccountsWithRawResponse:
def __init__(self, service_accounts: ServiceAccounts) -> None:
self._service_accounts = service_accounts
self.create = _legacy_response.to_raw_response_wrapper(
service_accounts.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
service_accounts.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
service_accounts.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
service_accounts.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
service_accounts.delete,
)
class AsyncServiceAccountsWithRawResponse:
def __init__(self, service_accounts: AsyncServiceAccounts) -> None:
self._service_accounts = service_accounts
self.create = _legacy_response.async_to_raw_response_wrapper(
service_accounts.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
service_accounts.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
service_accounts.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
service_accounts.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
service_accounts.delete,
)
class ServiceAccountsWithStreamingResponse:
def __init__(self, service_accounts: ServiceAccounts) -> None:
self._service_accounts = service_accounts
self.create = to_streamed_response_wrapper(
service_accounts.create,
)
self.retrieve = to_streamed_response_wrapper(
service_accounts.retrieve,
)
self.update = to_streamed_response_wrapper(
service_accounts.update,
)
self.list = to_streamed_response_wrapper(
service_accounts.list,
)
self.delete = to_streamed_response_wrapper(
service_accounts.delete,
)
class AsyncServiceAccountsWithStreamingResponse:
def __init__(self, service_accounts: AsyncServiceAccounts) -> None:
self._service_accounts = service_accounts
self.create = async_to_streamed_response_wrapper(
service_accounts.create,
)
self.retrieve = async_to_streamed_response_wrapper(
service_accounts.retrieve,
)
self.update = async_to_streamed_response_wrapper(
service_accounts.update,
)
self.list = async_to_streamed_response_wrapper(
service_accounts.list,
)
self.delete = async_to_streamed_response_wrapper(
service_accounts.delete,
)

View File

@@ -0,0 +1,685 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.projects import (
spend_alert_list_params,
spend_alert_create_params,
spend_alert_update_params,
)
from .....types.admin.organization.projects.project_spend_alert import ProjectSpendAlert
from .....types.admin.organization.projects.project_spend_alert_deleted import ProjectSpendAlertDeleted
__all__ = ["SpendAlerts", "AsyncSpendAlerts"]
class SpendAlerts(SyncAPIResource):
@cached_property
def with_raw_response(self) -> SpendAlertsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return SpendAlertsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> SpendAlertsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return SpendAlertsWithStreamingResponse(self)
def create(
self,
project_id: str,
*,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_create_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlert:
"""
Creates a project spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/spend_alerts", project_id=project_id),
body=maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_create_params.SpendAlertCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlert,
)
def retrieve(
self,
alert_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlert:
"""
Retrieves a project spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return self._get(
path_template(
"/organization/projects/{project_id}/spend_alerts/{alert_id}", project_id=project_id, alert_id=alert_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlert,
)
def update(
self,
alert_id: str,
*,
project_id: str,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_update_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlert:
"""
Updates a project spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return self._post(
path_template(
"/organization/projects/{project_id}/spend_alerts/{alert_id}", project_id=project_id, alert_id=alert_id
),
body=maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_update_params.SpendAlertUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlert,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
before: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[ProjectSpendAlert]:
"""Lists project spend alerts.
Args:
after: Cursor for pagination.
Provide the ID of the last spend alert from the previous
response to fetch the next page.
before: Cursor for pagination. Provide the ID of the first spend alert from the previous
response to fetch the previous page.
limit: A limit on the number of spend alerts to return. Defaults to 20.
order: Sort order for the returned spend alerts.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/spend_alerts", project_id=project_id),
page=SyncConversationCursorPage[ProjectSpendAlert],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"before": before,
"limit": limit,
"order": order,
},
spend_alert_list_params.SpendAlertListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectSpendAlert,
)
def delete(
self,
alert_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlertDeleted:
"""
Deletes a project spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return self._delete(
path_template(
"/organization/projects/{project_id}/spend_alerts/{alert_id}", project_id=project_id, alert_id=alert_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlertDeleted,
)
class AsyncSpendAlerts(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncSpendAlertsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncSpendAlertsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncSpendAlertsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncSpendAlertsWithStreamingResponse(self)
async def create(
self,
project_id: str,
*,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_create_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlert:
"""
Creates a project spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/spend_alerts", project_id=project_id),
body=await async_maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_create_params.SpendAlertCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlert,
)
async def retrieve(
self,
alert_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlert:
"""
Retrieves a project spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return await self._get(
path_template(
"/organization/projects/{project_id}/spend_alerts/{alert_id}", project_id=project_id, alert_id=alert_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlert,
)
async def update(
self,
alert_id: str,
*,
project_id: str,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_update_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlert:
"""
Updates a project spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return await self._post(
path_template(
"/organization/projects/{project_id}/spend_alerts/{alert_id}", project_id=project_id, alert_id=alert_id
),
body=await async_maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_update_params.SpendAlertUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlert,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
before: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ProjectSpendAlert, AsyncConversationCursorPage[ProjectSpendAlert]]:
"""Lists project spend alerts.
Args:
after: Cursor for pagination.
Provide the ID of the last spend alert from the previous
response to fetch the next page.
before: Cursor for pagination. Provide the ID of the first spend alert from the previous
response to fetch the previous page.
limit: A limit on the number of spend alerts to return. Defaults to 20.
order: Sort order for the returned spend alerts.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/spend_alerts", project_id=project_id),
page=AsyncConversationCursorPage[ProjectSpendAlert],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"before": before,
"limit": limit,
"order": order,
},
spend_alert_list_params.SpendAlertListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectSpendAlert,
)
async def delete(
self,
alert_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectSpendAlertDeleted:
"""
Deletes a project spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return await self._delete(
path_template(
"/organization/projects/{project_id}/spend_alerts/{alert_id}", project_id=project_id, alert_id=alert_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectSpendAlertDeleted,
)
class SpendAlertsWithRawResponse:
def __init__(self, spend_alerts: SpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = _legacy_response.to_raw_response_wrapper(
spend_alerts.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
spend_alerts.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
spend_alerts.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
spend_alerts.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
spend_alerts.delete,
)
class AsyncSpendAlertsWithRawResponse:
def __init__(self, spend_alerts: AsyncSpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.delete,
)
class SpendAlertsWithStreamingResponse:
def __init__(self, spend_alerts: SpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = to_streamed_response_wrapper(
spend_alerts.create,
)
self.retrieve = to_streamed_response_wrapper(
spend_alerts.retrieve,
)
self.update = to_streamed_response_wrapper(
spend_alerts.update,
)
self.list = to_streamed_response_wrapper(
spend_alerts.list,
)
self.delete = to_streamed_response_wrapper(
spend_alerts.delete,
)
class AsyncSpendAlertsWithStreamingResponse:
def __init__(self, spend_alerts: AsyncSpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = async_to_streamed_response_wrapper(
spend_alerts.create,
)
self.retrieve = async_to_streamed_response_wrapper(
spend_alerts.retrieve,
)
self.update = async_to_streamed_response_wrapper(
spend_alerts.update,
)
self.list = async_to_streamed_response_wrapper(
spend_alerts.list,
)
self.delete = async_to_streamed_response_wrapper(
spend_alerts.delete,
)

View File

@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
__all__ = [
"Roles",
"AsyncRoles",
"RolesWithRawResponse",
"AsyncRolesWithRawResponse",
"RolesWithStreamingResponse",
"AsyncRolesWithStreamingResponse",
"Users",
"AsyncUsers",
"UsersWithRawResponse",
"AsyncUsersWithRawResponse",
"UsersWithStreamingResponse",
"AsyncUsersWithStreamingResponse",
]

View File

@@ -0,0 +1,535 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ...... import _legacy_response
from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ......_utils import path_template, maybe_transform, async_maybe_transform
from ......_compat import cached_property
from ......_resource import SyncAPIResource, AsyncAPIResource
from ......_response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ......pagination import SyncNextCursorPage, AsyncNextCursorPage
from ......_base_client import AsyncPaginator, make_request_options
from ......types.admin.organization.projects.users import role_list_params, role_create_params
from ......types.admin.organization.projects.users.role_list_response import RoleListResponse
from ......types.admin.organization.projects.users.role_create_response import RoleCreateResponse
from ......types.admin.organization.projects.users.role_delete_response import RoleDeleteResponse
from ......types.admin.organization.projects.users.role_retrieve_response import RoleRetrieveResponse
__all__ = ["Roles", "AsyncRoles"]
class Roles(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RolesWithStreamingResponse(self)
def create(
self,
user_id: str,
*,
project_id: str,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns a project role to a user within a project.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._post(
path_template("/projects/{project_id}/users/{user_id}/roles", project_id=project_id, user_id=user_id),
body=maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
def retrieve(
self,
role_id: str,
*,
project_id: str,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves a project role assigned to a user.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._get(
path_template(
"/projects/{project_id}/users/{user_id}/roles/{role_id}",
project_id=project_id,
user_id=user_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
user_id: str,
*,
project_id: str,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[RoleListResponse]:
"""
Lists the project roles assigned to a user within a project.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing project roles.
limit: A limit on the number of project role assignments to return.
order: Sort order for the returned project roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get_api_list(
path_template("/projects/{project_id}/users/{user_id}/roles", project_id=project_id, user_id=user_id),
page=SyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
def delete(
self,
role_id: str,
*,
project_id: str,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns a project role from a user within a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._delete(
path_template(
"/projects/{project_id}/users/{user_id}/roles/{role_id}",
project_id=project_id,
user_id=user_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class AsyncRoles(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRolesWithStreamingResponse(self)
async def create(
self,
user_id: str,
*,
project_id: str,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns a project role to a user within a project.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._post(
path_template("/projects/{project_id}/users/{user_id}/roles", project_id=project_id, user_id=user_id),
body=await async_maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
async def retrieve(
self,
role_id: str,
*,
project_id: str,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves a project role assigned to a user.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._get(
path_template(
"/projects/{project_id}/users/{user_id}/roles/{role_id}",
project_id=project_id,
user_id=user_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
user_id: str,
*,
project_id: str,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[RoleListResponse, AsyncNextCursorPage[RoleListResponse]]:
"""
Lists the project roles assigned to a user within a project.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing project roles.
limit: A limit on the number of project role assignments to return.
order: Sort order for the returned project roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get_api_list(
path_template("/projects/{project_id}/users/{user_id}/roles", project_id=project_id, user_id=user_id),
page=AsyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
async def delete(
self,
role_id: str,
*,
project_id: str,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns a project role from a user within a project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._delete(
path_template(
"/projects/{project_id}/users/{user_id}/roles/{role_id}",
project_id=project_id,
user_id=user_id,
role_id=role_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class RolesWithRawResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = _legacy_response.to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
roles.delete,
)
class AsyncRolesWithRawResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = _legacy_response.async_to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
roles.delete,
)
class RolesWithStreamingResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = to_streamed_response_wrapper(
roles.create,
)
self.retrieve = to_streamed_response_wrapper(
roles.retrieve,
)
self.list = to_streamed_response_wrapper(
roles.list,
)
self.delete = to_streamed_response_wrapper(
roles.delete,
)
class AsyncRolesWithStreamingResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = async_to_streamed_response_wrapper(
roles.create,
)
self.retrieve = async_to_streamed_response_wrapper(
roles.retrieve,
)
self.list = async_to_streamed_response_wrapper(
roles.list,
)
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)

View File

@@ -0,0 +1,667 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
import httpx
from ...... import _legacy_response
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from ......_types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ......_utils import path_template, maybe_transform, async_maybe_transform
from ......_compat import cached_property
from ......_resource import SyncAPIResource, AsyncAPIResource
from ......_response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ......pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ......_base_client import AsyncPaginator, make_request_options
from ......types.admin.organization.projects import user_list_params, user_create_params, user_update_params
from ......types.admin.organization.projects.project_user import ProjectUser
from ......types.admin.organization.projects.user_delete_response import UserDeleteResponse
__all__ = ["Users", "AsyncUsers"]
class Users(SyncAPIResource):
@cached_property
def roles(self) -> Roles:
return Roles(self._client)
@cached_property
def with_raw_response(self) -> UsersWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return UsersWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> UsersWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return UsersWithStreamingResponse(self)
def create(
self,
project_id: str,
*,
role: str,
email: Optional[str] | Omit = omit,
user_id: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectUser:
"""Adds a user to the project.
Users must already be members of the organization to
be added to a project.
Args:
role: `owner` or `member`
email: Email of the user to add.
user_id: The ID of the user.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._post(
path_template("/organization/projects/{project_id}/users", project_id=project_id),
body=maybe_transform(
{
"role": role,
"email": email,
"user_id": user_id,
},
user_create_params.UserCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectUser,
)
def retrieve(
self,
user_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectUser:
"""
Retrieves a user in the project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get(
path_template(
"/organization/projects/{project_id}/users/{user_id}", project_id=project_id, user_id=user_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectUser,
)
def update(
self,
user_id: str,
*,
project_id: str,
role: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectUser:
"""
Modifies a user's role in the project.
Args:
role: `owner` or `member`
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._post(
path_template(
"/organization/projects/{project_id}/users/{user_id}", project_id=project_id, user_id=user_id
),
body=maybe_transform({"role": role}, user_update_params.UserUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectUser,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[ProjectUser]:
"""
Returns a list of users in the project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/users", project_id=project_id),
page=SyncConversationCursorPage[ProjectUser],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
user_list_params.UserListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectUser,
)
def delete(
self,
user_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserDeleteResponse:
"""
Deletes a user from the project.
Returns confirmation of project user deletion, or an error if the project is
archived (archived projects have no users).
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._delete(
path_template(
"/organization/projects/{project_id}/users/{user_id}", project_id=project_id, user_id=user_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserDeleteResponse,
)
class AsyncUsers(AsyncAPIResource):
@cached_property
def roles(self) -> AsyncRoles:
return AsyncRoles(self._client)
@cached_property
def with_raw_response(self) -> AsyncUsersWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncUsersWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncUsersWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncUsersWithStreamingResponse(self)
async def create(
self,
project_id: str,
*,
role: str,
email: Optional[str] | Omit = omit,
user_id: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectUser:
"""Adds a user to the project.
Users must already be members of the organization to
be added to a project.
Args:
role: `owner` or `member`
email: Email of the user to add.
user_id: The ID of the user.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return await self._post(
path_template("/organization/projects/{project_id}/users", project_id=project_id),
body=await async_maybe_transform(
{
"role": role,
"email": email,
"user_id": user_id,
},
user_create_params.UserCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectUser,
)
async def retrieve(
self,
user_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectUser:
"""
Retrieves a user in the project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._get(
path_template(
"/organization/projects/{project_id}/users/{user_id}", project_id=project_id, user_id=user_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectUser,
)
async def update(
self,
user_id: str,
*,
project_id: str,
role: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ProjectUser:
"""
Modifies a user's role in the project.
Args:
role: `owner` or `member`
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._post(
path_template(
"/organization/projects/{project_id}/users/{user_id}", project_id=project_id, user_id=user_id
),
body=await async_maybe_transform({"role": role}, user_update_params.UserUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=ProjectUser,
)
def list(
self,
project_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ProjectUser, AsyncConversationCursorPage[ProjectUser]]:
"""
Returns a list of users in the project.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
return self._get_api_list(
path_template("/organization/projects/{project_id}/users", project_id=project_id),
page=AsyncConversationCursorPage[ProjectUser],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
},
user_list_params.UserListParams,
),
security={"admin_api_key_auth": True},
),
model=ProjectUser,
)
async def delete(
self,
user_id: str,
*,
project_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserDeleteResponse:
"""
Deletes a user from the project.
Returns confirmation of project user deletion, or an error if the project is
archived (archived projects have no users).
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not project_id:
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._delete(
path_template(
"/organization/projects/{project_id}/users/{user_id}", project_id=project_id, user_id=user_id
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserDeleteResponse,
)
class UsersWithRawResponse:
def __init__(self, users: Users) -> None:
self._users = users
self.create = _legacy_response.to_raw_response_wrapper(
users.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
users.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
users.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
users.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> RolesWithRawResponse:
return RolesWithRawResponse(self._users.roles)
class AsyncUsersWithRawResponse:
def __init__(self, users: AsyncUsers) -> None:
self._users = users
self.create = _legacy_response.async_to_raw_response_wrapper(
users.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
users.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
users.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
users.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> AsyncRolesWithRawResponse:
return AsyncRolesWithRawResponse(self._users.roles)
class UsersWithStreamingResponse:
def __init__(self, users: Users) -> None:
self._users = users
self.create = to_streamed_response_wrapper(
users.create,
)
self.retrieve = to_streamed_response_wrapper(
users.retrieve,
)
self.update = to_streamed_response_wrapper(
users.update,
)
self.list = to_streamed_response_wrapper(
users.list,
)
self.delete = to_streamed_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> RolesWithStreamingResponse:
return RolesWithStreamingResponse(self._users.roles)
class AsyncUsersWithStreamingResponse:
def __init__(self, users: AsyncUsers) -> None:
self._users = users
self.create = async_to_streamed_response_wrapper(
users.create,
)
self.retrieve = async_to_streamed_response_wrapper(
users.retrieve,
)
self.update = async_to_streamed_response_wrapper(
users.update,
)
self.list = async_to_streamed_response_wrapper(
users.list,
)
self.delete = async_to_streamed_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> AsyncRolesWithStreamingResponse:
return AsyncRolesWithStreamingResponse(self._users.roles)

View File

@@ -0,0 +1,612 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from ...._utils import path_template, maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....pagination import SyncNextCursorPage, AsyncNextCursorPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.admin.organization import role_list_params, role_create_params, role_update_params
from ....types.admin.organization.role import Role
from ....types.admin.organization.role_delete_response import RoleDeleteResponse
__all__ = ["Roles", "AsyncRoles"]
class Roles(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RolesWithStreamingResponse(self)
def create(
self,
*,
permissions: SequenceNotStr[str],
role_name: str,
description: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Creates a custom role for the organization.
Args:
permissions: Permissions to grant to the role.
role_name: Unique name for the role.
description: Optional description of the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/roles",
body=maybe_transform(
{
"permissions": permissions,
"role_name": role_name,
"description": description,
},
role_create_params.RoleCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def retrieve(
self,
role_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Retrieves an organization role.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._get(
path_template("/organization/roles/{role_id}", role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def update(
self,
role_id: str,
*,
description: Optional[str] | Omit = omit,
permissions: Optional[SequenceNotStr[str]] | Omit = omit,
role_name: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Updates an existing organization role.
Args:
description: New description for the role.
permissions: Updated set of permissions for the role.
role_name: New name for the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._post(
path_template("/organization/roles/{role_id}", role_id=role_id),
body=maybe_transform(
{
"description": description,
"permissions": permissions,
"role_name": role_name,
},
role_update_params.RoleUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[Role]:
"""
Lists the roles configured for the organization.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing roles.
limit: A limit on the number of roles to return. Defaults to 1000.
order: Sort order for the returned roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/roles",
page=SyncNextCursorPage[Role],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=Role,
)
def delete(
self,
role_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Deletes a custom role from the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._delete(
path_template("/organization/roles/{role_id}", role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class AsyncRoles(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRolesWithStreamingResponse(self)
async def create(
self,
*,
permissions: SequenceNotStr[str],
role_name: str,
description: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Creates a custom role for the organization.
Args:
permissions: Permissions to grant to the role.
role_name: Unique name for the role.
description: Optional description of the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/roles",
body=await async_maybe_transform(
{
"permissions": permissions,
"role_name": role_name,
"description": description,
},
role_create_params.RoleCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
async def retrieve(
self,
role_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Retrieves an organization role.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._get(
path_template("/organization/roles/{role_id}", role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
async def update(
self,
role_id: str,
*,
description: Optional[str] | Omit = omit,
permissions: Optional[SequenceNotStr[str]] | Omit = omit,
role_name: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Role:
"""
Updates an existing organization role.
Args:
description: New description for the role.
permissions: Updated set of permissions for the role.
role_name: New name for the role.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._post(
path_template("/organization/roles/{role_id}", role_id=role_id),
body=await async_maybe_transform(
{
"description": description,
"permissions": permissions,
"role_name": role_name,
},
role_update_params.RoleUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=Role,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[Role, AsyncNextCursorPage[Role]]:
"""
Lists the roles configured for the organization.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing roles.
limit: A limit on the number of roles to return. Defaults to 1000.
order: Sort order for the returned roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/roles",
page=AsyncNextCursorPage[Role],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=Role,
)
async def delete(
self,
role_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Deletes a custom role from the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._delete(
path_template("/organization/roles/{role_id}", role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class RolesWithRawResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = _legacy_response.to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
roles.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
roles.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
roles.delete,
)
class AsyncRolesWithRawResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = _legacy_response.async_to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
roles.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
roles.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
roles.delete,
)
class RolesWithStreamingResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = to_streamed_response_wrapper(
roles.create,
)
self.retrieve = to_streamed_response_wrapper(
roles.retrieve,
)
self.update = to_streamed_response_wrapper(
roles.update,
)
self.list = to_streamed_response_wrapper(
roles.list,
)
self.delete = to_streamed_response_wrapper(
roles.delete,
)
class AsyncRolesWithStreamingResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = async_to_streamed_response_wrapper(
roles.create,
)
self.retrieve = async_to_streamed_response_wrapper(
roles.retrieve,
)
self.update = async_to_streamed_response_wrapper(
roles.update,
)
self.list = async_to_streamed_response_wrapper(
roles.list,
)
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)

View File

@@ -0,0 +1,639 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from .... import _legacy_response
from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ...._utils import path_template, maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.admin.organization import spend_alert_list_params, spend_alert_create_params, spend_alert_update_params
from ....types.admin.organization.organization_spend_alert import OrganizationSpendAlert
from ....types.admin.organization.organization_spend_alert_deleted import OrganizationSpendAlertDeleted
__all__ = ["SpendAlerts", "AsyncSpendAlerts"]
class SpendAlerts(SyncAPIResource):
@cached_property
def with_raw_response(self) -> SpendAlertsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return SpendAlertsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> SpendAlertsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return SpendAlertsWithStreamingResponse(self)
def create(
self,
*,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_create_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlert:
"""
Creates an organization spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/organization/spend_alerts",
body=maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_create_params.SpendAlertCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlert,
)
def retrieve(
self,
alert_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlert:
"""
Retrieves an organization spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return self._get(
path_template("/organization/spend_alerts/{alert_id}", alert_id=alert_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlert,
)
def update(
self,
alert_id: str,
*,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_update_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlert:
"""
Updates an organization spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return self._post(
path_template("/organization/spend_alerts/{alert_id}", alert_id=alert_id),
body=maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_update_params.SpendAlertUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlert,
)
def list(
self,
*,
after: str | Omit = omit,
before: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[OrganizationSpendAlert]:
"""Lists organization spend alerts.
Args:
after: Cursor for pagination.
Provide the ID of the last spend alert from the previous
response to fetch the next page.
before: Cursor for pagination. Provide the ID of the first spend alert from the previous
response to fetch the previous page.
limit: A limit on the number of spend alerts to return. Defaults to 20.
order: Sort order for the returned spend alerts.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/spend_alerts",
page=SyncConversationCursorPage[OrganizationSpendAlert],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"before": before,
"limit": limit,
"order": order,
},
spend_alert_list_params.SpendAlertListParams,
),
security={"admin_api_key_auth": True},
),
model=OrganizationSpendAlert,
)
def delete(
self,
alert_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlertDeleted:
"""
Deletes an organization spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return self._delete(
path_template("/organization/spend_alerts/{alert_id}", alert_id=alert_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlertDeleted,
)
class AsyncSpendAlerts(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncSpendAlertsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncSpendAlertsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncSpendAlertsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncSpendAlertsWithStreamingResponse(self)
async def create(
self,
*,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_create_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlert:
"""
Creates an organization spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/organization/spend_alerts",
body=await async_maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_create_params.SpendAlertCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlert,
)
async def retrieve(
self,
alert_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlert:
"""
Retrieves an organization spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return await self._get(
path_template("/organization/spend_alerts/{alert_id}", alert_id=alert_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlert,
)
async def update(
self,
alert_id: str,
*,
currency: Literal["USD"],
interval: Literal["month"],
notification_channel: spend_alert_update_params.NotificationChannel,
threshold_amount: int,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlert:
"""
Updates an organization spend alert.
Args:
currency: The currency for the threshold amount.
interval: The time interval for evaluating spend against the threshold.
notification_channel: Email notification settings for a spend alert.
threshold_amount: The alert threshold amount, in cents.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return await self._post(
path_template("/organization/spend_alerts/{alert_id}", alert_id=alert_id),
body=await async_maybe_transform(
{
"currency": currency,
"interval": interval,
"notification_channel": notification_channel,
"threshold_amount": threshold_amount,
},
spend_alert_update_params.SpendAlertUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlert,
)
def list(
self,
*,
after: str | Omit = omit,
before: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[OrganizationSpendAlert, AsyncConversationCursorPage[OrganizationSpendAlert]]:
"""Lists organization spend alerts.
Args:
after: Cursor for pagination.
Provide the ID of the last spend alert from the previous
response to fetch the next page.
before: Cursor for pagination. Provide the ID of the first spend alert from the previous
response to fetch the previous page.
limit: A limit on the number of spend alerts to return. Defaults to 20.
order: Sort order for the returned spend alerts.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/spend_alerts",
page=AsyncConversationCursorPage[OrganizationSpendAlert],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"before": before,
"limit": limit,
"order": order,
},
spend_alert_list_params.SpendAlertListParams,
),
security={"admin_api_key_auth": True},
),
model=OrganizationSpendAlert,
)
async def delete(
self,
alert_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationSpendAlertDeleted:
"""
Deletes an organization spend alert.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not alert_id:
raise ValueError(f"Expected a non-empty value for `alert_id` but received {alert_id!r}")
return await self._delete(
path_template("/organization/spend_alerts/{alert_id}", alert_id=alert_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationSpendAlertDeleted,
)
class SpendAlertsWithRawResponse:
def __init__(self, spend_alerts: SpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = _legacy_response.to_raw_response_wrapper(
spend_alerts.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
spend_alerts.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
spend_alerts.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
spend_alerts.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
spend_alerts.delete,
)
class AsyncSpendAlertsWithRawResponse:
def __init__(self, spend_alerts: AsyncSpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
spend_alerts.delete,
)
class SpendAlertsWithStreamingResponse:
def __init__(self, spend_alerts: SpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = to_streamed_response_wrapper(
spend_alerts.create,
)
self.retrieve = to_streamed_response_wrapper(
spend_alerts.retrieve,
)
self.update = to_streamed_response_wrapper(
spend_alerts.update,
)
self.list = to_streamed_response_wrapper(
spend_alerts.list,
)
self.delete = to_streamed_response_wrapper(
spend_alerts.delete,
)
class AsyncSpendAlertsWithStreamingResponse:
def __init__(self, spend_alerts: AsyncSpendAlerts) -> None:
self._spend_alerts = spend_alerts
self.create = async_to_streamed_response_wrapper(
spend_alerts.create,
)
self.retrieve = async_to_streamed_response_wrapper(
spend_alerts.retrieve,
)
self.update = async_to_streamed_response_wrapper(
spend_alerts.update,
)
self.list = async_to_streamed_response_wrapper(
spend_alerts.list,
)
self.delete = async_to_streamed_response_wrapper(
spend_alerts.delete,
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from .users import (
Users,
AsyncUsers,
UsersWithRawResponse,
AsyncUsersWithRawResponse,
UsersWithStreamingResponse,
AsyncUsersWithStreamingResponse,
)
__all__ = [
"Roles",
"AsyncRoles",
"RolesWithRawResponse",
"AsyncRolesWithRawResponse",
"RolesWithStreamingResponse",
"AsyncRolesWithStreamingResponse",
"Users",
"AsyncUsers",
"UsersWithRawResponse",
"AsyncUsersWithRawResponse",
"UsersWithStreamingResponse",
"AsyncUsersWithStreamingResponse",
]

View File

@@ -0,0 +1,491 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing_extensions import Literal
import httpx
from ..... import _legacy_response
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncNextCursorPage, AsyncNextCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization.users import role_list_params, role_create_params
from .....types.admin.organization.users.role_list_response import RoleListResponse
from .....types.admin.organization.users.role_create_response import RoleCreateResponse
from .....types.admin.organization.users.role_delete_response import RoleDeleteResponse
from .....types.admin.organization.users.role_retrieve_response import RoleRetrieveResponse
__all__ = ["Roles", "AsyncRoles"]
class Roles(SyncAPIResource):
@cached_property
def with_raw_response(self) -> RolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return RolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> RolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return RolesWithStreamingResponse(self)
def create(
self,
user_id: str,
*,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns an organization role to a user within the organization.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._post(
path_template("/organization/users/{user_id}/roles", user_id=user_id),
body=maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
def retrieve(
self,
role_id: str,
*,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves an organization role assigned to a user.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._get(
path_template("/organization/users/{user_id}/roles/{role_id}", user_id=user_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
user_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncNextCursorPage[RoleListResponse]:
"""
Lists the organization roles assigned to a user within the organization.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing organization roles.
limit: A limit on the number of organization role assignments to return.
order: Sort order for the returned organization roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get_api_list(
path_template("/organization/users/{user_id}/roles", user_id=user_id),
page=SyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
def delete(
self,
role_id: str,
*,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns an organization role from a user within the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return self._delete(
path_template("/organization/users/{user_id}/roles/{role_id}", user_id=user_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class AsyncRoles(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncRolesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncRolesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncRolesWithStreamingResponse(self)
async def create(
self,
user_id: str,
*,
role_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleCreateResponse:
"""
Assigns an organization role to a user within the organization.
Args:
role_id: Identifier of the role to assign.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._post(
path_template("/organization/users/{user_id}/roles", user_id=user_id),
body=await async_maybe_transform({"role_id": role_id}, role_create_params.RoleCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleCreateResponse,
)
async def retrieve(
self,
role_id: str,
*,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleRetrieveResponse:
"""
Retrieves an organization role assigned to a user.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._get(
path_template("/organization/users/{user_id}/roles/{role_id}", user_id=user_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleRetrieveResponse,
)
def list(
self,
user_id: str,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
order: Literal["asc", "desc"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[RoleListResponse, AsyncNextCursorPage[RoleListResponse]]:
"""
Lists the organization roles assigned to a user within the organization.
Args:
after: Cursor for pagination. Provide the value from the previous response's `next`
field to continue listing organization roles.
limit: A limit on the number of organization role assignments to return.
order: Sort order for the returned organization roles.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get_api_list(
path_template("/organization/users/{user_id}/roles", user_id=user_id),
page=AsyncNextCursorPage[RoleListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"limit": limit,
"order": order,
},
role_list_params.RoleListParams,
),
security={"admin_api_key_auth": True},
),
model=RoleListResponse,
)
async def delete(
self,
role_id: str,
*,
user_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> RoleDeleteResponse:
"""
Unassigns an organization role from a user within the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not role_id:
raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
return await self._delete(
path_template("/organization/users/{user_id}/roles/{role_id}", user_id=user_id, role_id=role_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=RoleDeleteResponse,
)
class RolesWithRawResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = _legacy_response.to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
roles.delete,
)
class AsyncRolesWithRawResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = _legacy_response.async_to_raw_response_wrapper(
roles.create,
)
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
roles.retrieve,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
roles.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
roles.delete,
)
class RolesWithStreamingResponse:
def __init__(self, roles: Roles) -> None:
self._roles = roles
self.create = to_streamed_response_wrapper(
roles.create,
)
self.retrieve = to_streamed_response_wrapper(
roles.retrieve,
)
self.list = to_streamed_response_wrapper(
roles.list,
)
self.delete = to_streamed_response_wrapper(
roles.delete,
)
class AsyncRolesWithStreamingResponse:
def __init__(self, roles: AsyncRoles) -> None:
self._roles = roles
self.create = async_to_streamed_response_wrapper(
roles.create,
)
self.retrieve = async_to_streamed_response_wrapper(
roles.retrieve,
)
self.list = async_to_streamed_response_wrapper(
roles.list,
)
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)

View File

@@ -0,0 +1,543 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
from typing import Optional
import httpx
from ..... import _legacy_response
from .roles import (
Roles,
AsyncRoles,
RolesWithRawResponse,
AsyncRolesWithRawResponse,
RolesWithStreamingResponse,
AsyncRolesWithStreamingResponse,
)
from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from ....._utils import path_template, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from .....pagination import SyncConversationCursorPage, AsyncConversationCursorPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.admin.organization import user_list_params, user_update_params
from .....types.admin.organization.organization_user import OrganizationUser
from .....types.admin.organization.user_delete_response import UserDeleteResponse
__all__ = ["Users", "AsyncUsers"]
class Users(SyncAPIResource):
@cached_property
def roles(self) -> Roles:
return Roles(self._client)
@cached_property
def with_raw_response(self) -> UsersWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return UsersWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> UsersWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return UsersWithStreamingResponse(self)
def retrieve(
self,
user_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationUser:
"""
Retrieves a user by their identifier.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._get(
path_template("/organization/users/{user_id}", user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationUser,
)
def update(
self,
user_id: str,
*,
developer_persona: Optional[str] | Omit = omit,
role: Optional[str] | Omit = omit,
role_id: Optional[str] | Omit = omit,
technical_level: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationUser:
"""
Modifies a user's role in the organization.
Args:
developer_persona: Developer persona metadata.
role: `owner` or `reader`
role_id: Role ID to assign to the user.
technical_level: Technical level metadata.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._post(
path_template("/organization/users/{user_id}", user_id=user_id),
body=maybe_transform(
{
"developer_persona": developer_persona,
"role": role,
"role_id": role_id,
"technical_level": technical_level,
},
user_update_params.UserUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationUser,
)
def list(
self,
*,
after: str | Omit = omit,
emails: SequenceNotStr[str] | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[OrganizationUser]:
"""
Lists all of the users in the organization.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
emails: Filter by the email address of users.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/users",
page=SyncConversationCursorPage[OrganizationUser],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"emails": emails,
"limit": limit,
},
user_list_params.UserListParams,
),
security={"admin_api_key_auth": True},
),
model=OrganizationUser,
)
def delete(
self,
user_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserDeleteResponse:
"""
Deletes a user from the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._delete(
path_template("/organization/users/{user_id}", user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserDeleteResponse,
)
class AsyncUsers(AsyncAPIResource):
@cached_property
def roles(self) -> AsyncRoles:
return AsyncRoles(self._client)
@cached_property
def with_raw_response(self) -> AsyncUsersWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
"""
return AsyncUsersWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncUsersWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/openai/openai-python#with_streaming_response
"""
return AsyncUsersWithStreamingResponse(self)
async def retrieve(
self,
user_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationUser:
"""
Retrieves a user by their identifier.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._get(
path_template("/organization/users/{user_id}", user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationUser,
)
async def update(
self,
user_id: str,
*,
developer_persona: Optional[str] | Omit = omit,
role: Optional[str] | Omit = omit,
role_id: Optional[str] | Omit = omit,
technical_level: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> OrganizationUser:
"""
Modifies a user's role in the organization.
Args:
developer_persona: Developer persona metadata.
role: `owner` or `reader`
role_id: Role ID to assign to the user.
technical_level: Technical level metadata.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._post(
path_template("/organization/users/{user_id}", user_id=user_id),
body=await async_maybe_transform(
{
"developer_persona": developer_persona,
"role": role,
"role_id": role_id,
"technical_level": technical_level,
},
user_update_params.UserUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=OrganizationUser,
)
def list(
self,
*,
after: str | Omit = omit,
emails: SequenceNotStr[str] | Omit = omit,
limit: int | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[OrganizationUser, AsyncConversationCursorPage[OrganizationUser]]:
"""
Lists all of the users in the organization.
Args:
after: A cursor for use in pagination. `after` is an object ID that defines your place
in the list. For instance, if you make a list request and receive 100 objects,
ending with obj_foo, your subsequent call can include after=obj_foo in order to
fetch the next page of the list.
emails: Filter by the email address of users.
limit: A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get_api_list(
"/organization/users",
page=AsyncConversationCursorPage[OrganizationUser],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"after": after,
"emails": emails,
"limit": limit,
},
user_list_params.UserListParams,
),
security={"admin_api_key_auth": True},
),
model=OrganizationUser,
)
async def delete(
self,
user_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UserDeleteResponse:
"""
Deletes a user from the organization.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._delete(
path_template("/organization/users/{user_id}", user_id=user_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"admin_api_key_auth": True},
),
cast_to=UserDeleteResponse,
)
class UsersWithRawResponse:
def __init__(self, users: Users) -> None:
self._users = users
self.retrieve = _legacy_response.to_raw_response_wrapper(
users.retrieve,
)
self.update = _legacy_response.to_raw_response_wrapper(
users.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
users.list,
)
self.delete = _legacy_response.to_raw_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> RolesWithRawResponse:
return RolesWithRawResponse(self._users.roles)
class AsyncUsersWithRawResponse:
def __init__(self, users: AsyncUsers) -> None:
self._users = users
self.retrieve = _legacy_response.async_to_raw_response_wrapper(
users.retrieve,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
users.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
users.list,
)
self.delete = _legacy_response.async_to_raw_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> AsyncRolesWithRawResponse:
return AsyncRolesWithRawResponse(self._users.roles)
class UsersWithStreamingResponse:
def __init__(self, users: Users) -> None:
self._users = users
self.retrieve = to_streamed_response_wrapper(
users.retrieve,
)
self.update = to_streamed_response_wrapper(
users.update,
)
self.list = to_streamed_response_wrapper(
users.list,
)
self.delete = to_streamed_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> RolesWithStreamingResponse:
return RolesWithStreamingResponse(self._users.roles)
class AsyncUsersWithStreamingResponse:
def __init__(self, users: AsyncUsers) -> None:
self._users = users
self.retrieve = async_to_streamed_response_wrapper(
users.retrieve,
)
self.update = async_to_streamed_response_wrapper(
users.update,
)
self.list = async_to_streamed_response_wrapper(
users.list,
)
self.delete = async_to_streamed_response_wrapper(
users.delete,
)
@cached_property
def roles(self) -> AsyncRolesWithStreamingResponse:
return AsyncRolesWithStreamingResponse(self._users.roles)