diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b56d745d..07c725da 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.150.0" + ".": "0.151.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a4bdf76d..ffd2a69b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 189 +configured_endpoints: 206 diff --git a/CHANGELOG.md b/CHANGELOG.md index 218f952e..8f020579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [0.151.0](https://github.com/kernel/kernel-python-sdk/compare/v0.150.0...v0.151.0) (2026-11-19) + + +### Features + +* Add service account, workload identity issuer, federation rule and authentication event resources. They require a signed-in session; API keys get 403 ([a6dd0c4](https://github.com/kernel/kernel-python-sdk/commit/a6dd0c4f794bc33f50dc2bd9ecc93489f55cf8c2)) +* Add `service_account_id`, `principal_type`, `created_by` and `project_id` filters and the `expired` status to API key listing. `status=active`, the default, no longer returns expired keys ([a6dd0c4](https://github.com/kernel/kernel-python-sdk/commit/a6dd0c4f794bc33f50dc2bd9ecc93489f55cf8c2)) +* Rename two types that 0.150.0 introduced: `kernel.types.api_key.Principal` is now `kernel.types.APIKeyPrincipal`, and `kernel.types.auth.auth_context.WorkloadIdentity` is now `kernel.types.auth.AuthContextWorkloadIdentity` ([a6dd0c4](https://github.com/kernel/kernel-python-sdk/commit/a6dd0c4f794bc33f50dc2bd9ecc93489f55cf8c2)) + ## [0.150.0](https://github.com/kernel/kernel-python-sdk/compare/v0.149.0...v0.150.0) (2026-11-19) diff --git a/api.md b/api.md index 2a3ee41c..2c11b4b2 100644 --- a/api.md +++ b/api.md @@ -487,7 +487,7 @@ Methods: Types: ```python -from kernel.types.auth import AuthContext +from kernel.types.auth import AuthContext, AuthContextWorkloadIdentity ``` Methods: @@ -875,7 +875,7 @@ Methods: Types: ```python -from kernel.types import APIKey, CreatedAPIKey +from kernel.types import APIKey, APIKeyPrincipal, CreatedAPIKey ``` Methods: @@ -887,6 +887,80 @@ Methods: - client.api_keys.delete(id) -> None - client.api_keys.rotate(id, \*\*params) -> CreatedAPIKey +# ServiceAccounts + +Types: + +```python +from kernel.types import ServiceAccount, ServiceAccountConfig +``` + +Methods: + +- client.service_accounts.create(\*\*params) -> ServiceAccount +- client.service_accounts.retrieve(id) -> ServiceAccount +- client.service_accounts.update(id, \*\*params) -> ServiceAccount +- client.service_accounts.list(\*\*params) -> SyncOffsetPagination[ServiceAccount] +- client.service_accounts.delete(id) -> None + +# WorkloadIdentityIssuers + +Types: + +```python +from kernel.types import ( + WorkloadIdentityIssuer, + WorkloadIdentityIssuerConfig, + WorkloadIdentityIssuerKeyCheck, + WorkloadIdentityKeySource, + WorkloadIdentityPresetType, + WorkloadIdentityTokenValidation, +) +``` + +Methods: + +- client.workload_identity_issuers.create(\*\*params) -> WorkloadIdentityIssuer +- client.workload_identity_issuers.retrieve(id) -> WorkloadIdentityIssuer +- client.workload_identity_issuers.update(id, \*\*params) -> WorkloadIdentityIssuer +- client.workload_identity_issuers.list(\*\*params) -> SyncOffsetPagination[WorkloadIdentityIssuer] +- client.workload_identity_issuers.delete(id) -> None +- client.workload_identity_issuers.verify(id) -> WorkloadIdentityIssuerKeyCheck + +# WorkloadIdentityFederationRules + +Types: + +```python +from kernel.types import ( + WorkloadIdentityAuthorization, + WorkloadIdentityFederationRule, + WorkloadIdentityFederationRuleConfig, + WorkloadIdentityMatch, + WorkloadIdentityTarget, +) +``` + +Methods: + +- client.workload_identity_federation_rules.create(\*\*params) -> WorkloadIdentityFederationRule +- client.workload_identity_federation_rules.retrieve(id) -> WorkloadIdentityFederationRule +- client.workload_identity_federation_rules.update(id, \*\*params) -> WorkloadIdentityFederationRule +- client.workload_identity_federation_rules.list(\*\*params) -> SyncOffsetPagination[WorkloadIdentityFederationRule] +- client.workload_identity_federation_rules.delete(id) -> None + +# WorkloadIdentityAuthenticationEvents + +Types: + +```python +from kernel.types import WorkloadIdentityAuthenticationEvent +``` + +Methods: + +- client.workload_identity_authentication_events.list(\*\*params) -> SyncOffsetPagination[WorkloadIdentityAuthenticationEvent] + # CredentialProviders Types: diff --git a/pyproject.toml b/pyproject.toml index 6eeeff77..14403001 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "kernel" -version = "0.150.0" +version = "0.151.0" description = "The official Python library for the kernel API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/kernel/_client.py b/src/kernel/_client.py index 9059f4da..aa415cf3 100644 --- a/src/kernel/_client.py +++ b/src/kernel/_client.py @@ -91,8 +91,12 @@ report_types, browser_pools, config_registry, + service_accounts, credential_providers, vault_provider_configs, + workload_identity_issuers, + workload_identity_federation_rules, + workload_identity_authentication_events, ) from .resources.apps import AppsResource, AsyncAppsResource from .resources.tasks import TasksResource, AsyncTasksResource @@ -109,6 +113,7 @@ from .resources.browser_pools import BrowserPoolsResource, AsyncBrowserPoolsResource from .resources.search.search import SearchResource, AsyncSearchResource from .resources.vaults.vaults import VaultsResource, AsyncVaultsResource + from .resources.service_accounts import ServiceAccountsResource, AsyncServiceAccountsResource from .resources.browsers.browsers import BrowsersResource, AsyncBrowsersResource from .resources.projects.projects import ProjectsResource, AsyncProjectsResource from .resources.telemetry.telemetry import TelemetryResource, AsyncTelemetryResource @@ -117,7 +122,19 @@ from .resources.vault_provider_configs import VaultProviderConfigsResource, AsyncVaultProviderConfigsResource from .resources.organization.organization import OrganizationResource, AsyncOrganizationResource from .resources.report_types.report_types import ReportTypesResource, AsyncReportTypesResource + from .resources.workload_identity_issuers import ( + WorkloadIdentityIssuersResource, + AsyncWorkloadIdentityIssuersResource, + ) from .resources.config_registry.config_registry import ConfigRegistryResource, AsyncConfigRegistryResource + from .resources.workload_identity_federation_rules import ( + WorkloadIdentityFederationRulesResource, + AsyncWorkloadIdentityFederationRulesResource, + ) + from .resources.workload_identity_authentication_events import ( + WorkloadIdentityAuthenticationEventsResource, + AsyncWorkloadIdentityAuthenticationEventsResource, + ) __all__ = [ "ENVIRONMENTS", @@ -398,6 +415,30 @@ def api_keys(self) -> APIKeysResource: return APIKeysResource(self) + @cached_property + def service_accounts(self) -> ServiceAccountsResource: + from .resources.service_accounts import ServiceAccountsResource + + return ServiceAccountsResource(self) + + @cached_property + def workload_identity_issuers(self) -> WorkloadIdentityIssuersResource: + from .resources.workload_identity_issuers import WorkloadIdentityIssuersResource + + return WorkloadIdentityIssuersResource(self) + + @cached_property + def workload_identity_federation_rules(self) -> WorkloadIdentityFederationRulesResource: + from .resources.workload_identity_federation_rules import WorkloadIdentityFederationRulesResource + + return WorkloadIdentityFederationRulesResource(self) + + @cached_property + def workload_identity_authentication_events(self) -> WorkloadIdentityAuthenticationEventsResource: + from .resources.workload_identity_authentication_events import WorkloadIdentityAuthenticationEventsResource + + return WorkloadIdentityAuthenticationEventsResource(self) + @cached_property def credential_providers(self) -> CredentialProvidersResource: """Configure external credential providers like 1Password.""" @@ -859,6 +900,30 @@ def api_keys(self) -> AsyncAPIKeysResource: return AsyncAPIKeysResource(self) + @cached_property + def service_accounts(self) -> AsyncServiceAccountsResource: + from .resources.service_accounts import AsyncServiceAccountsResource + + return AsyncServiceAccountsResource(self) + + @cached_property + def workload_identity_issuers(self) -> AsyncWorkloadIdentityIssuersResource: + from .resources.workload_identity_issuers import AsyncWorkloadIdentityIssuersResource + + return AsyncWorkloadIdentityIssuersResource(self) + + @cached_property + def workload_identity_federation_rules(self) -> AsyncWorkloadIdentityFederationRulesResource: + from .resources.workload_identity_federation_rules import AsyncWorkloadIdentityFederationRulesResource + + return AsyncWorkloadIdentityFederationRulesResource(self) + + @cached_property + def workload_identity_authentication_events(self) -> AsyncWorkloadIdentityAuthenticationEventsResource: + from .resources.workload_identity_authentication_events import AsyncWorkloadIdentityAuthenticationEventsResource + + return AsyncWorkloadIdentityAuthenticationEventsResource(self) + @cached_property def credential_providers(self) -> AsyncCredentialProvidersResource: """Configure external credential providers like 1Password.""" @@ -1214,6 +1279,38 @@ def api_keys(self) -> api_keys.APIKeysResourceWithRawResponse: return APIKeysResourceWithRawResponse(self._client.api_keys) + @cached_property + def service_accounts(self) -> service_accounts.ServiceAccountsResourceWithRawResponse: + from .resources.service_accounts import ServiceAccountsResourceWithRawResponse + + return ServiceAccountsResourceWithRawResponse(self._client.service_accounts) + + @cached_property + def workload_identity_issuers(self) -> workload_identity_issuers.WorkloadIdentityIssuersResourceWithRawResponse: + from .resources.workload_identity_issuers import WorkloadIdentityIssuersResourceWithRawResponse + + return WorkloadIdentityIssuersResourceWithRawResponse(self._client.workload_identity_issuers) + + @cached_property + def workload_identity_federation_rules( + self, + ) -> workload_identity_federation_rules.WorkloadIdentityFederationRulesResourceWithRawResponse: + from .resources.workload_identity_federation_rules import WorkloadIdentityFederationRulesResourceWithRawResponse + + return WorkloadIdentityFederationRulesResourceWithRawResponse(self._client.workload_identity_federation_rules) + + @cached_property + def workload_identity_authentication_events( + self, + ) -> workload_identity_authentication_events.WorkloadIdentityAuthenticationEventsResourceWithRawResponse: + from .resources.workload_identity_authentication_events import ( + WorkloadIdentityAuthenticationEventsResourceWithRawResponse, + ) + + return WorkloadIdentityAuthenticationEventsResourceWithRawResponse( + self._client.workload_identity_authentication_events + ) + @cached_property def credential_providers(self) -> credential_providers.CredentialProvidersResourceWithRawResponse: """Configure external credential providers like 1Password.""" @@ -1383,6 +1480,44 @@ def api_keys(self) -> api_keys.AsyncAPIKeysResourceWithRawResponse: return AsyncAPIKeysResourceWithRawResponse(self._client.api_keys) + @cached_property + def service_accounts(self) -> service_accounts.AsyncServiceAccountsResourceWithRawResponse: + from .resources.service_accounts import AsyncServiceAccountsResourceWithRawResponse + + return AsyncServiceAccountsResourceWithRawResponse(self._client.service_accounts) + + @cached_property + def workload_identity_issuers( + self, + ) -> workload_identity_issuers.AsyncWorkloadIdentityIssuersResourceWithRawResponse: + from .resources.workload_identity_issuers import AsyncWorkloadIdentityIssuersResourceWithRawResponse + + return AsyncWorkloadIdentityIssuersResourceWithRawResponse(self._client.workload_identity_issuers) + + @cached_property + def workload_identity_federation_rules( + self, + ) -> workload_identity_federation_rules.AsyncWorkloadIdentityFederationRulesResourceWithRawResponse: + from .resources.workload_identity_federation_rules import ( + AsyncWorkloadIdentityFederationRulesResourceWithRawResponse, + ) + + return AsyncWorkloadIdentityFederationRulesResourceWithRawResponse( + self._client.workload_identity_federation_rules + ) + + @cached_property + def workload_identity_authentication_events( + self, + ) -> workload_identity_authentication_events.AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse: + from .resources.workload_identity_authentication_events import ( + AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse, + ) + + return AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse( + self._client.workload_identity_authentication_events + ) + @cached_property def credential_providers(self) -> credential_providers.AsyncCredentialProvidersResourceWithRawResponse: """Configure external credential providers like 1Password.""" @@ -1552,6 +1687,44 @@ def api_keys(self) -> api_keys.APIKeysResourceWithStreamingResponse: return APIKeysResourceWithStreamingResponse(self._client.api_keys) + @cached_property + def service_accounts(self) -> service_accounts.ServiceAccountsResourceWithStreamingResponse: + from .resources.service_accounts import ServiceAccountsResourceWithStreamingResponse + + return ServiceAccountsResourceWithStreamingResponse(self._client.service_accounts) + + @cached_property + def workload_identity_issuers( + self, + ) -> workload_identity_issuers.WorkloadIdentityIssuersResourceWithStreamingResponse: + from .resources.workload_identity_issuers import WorkloadIdentityIssuersResourceWithStreamingResponse + + return WorkloadIdentityIssuersResourceWithStreamingResponse(self._client.workload_identity_issuers) + + @cached_property + def workload_identity_federation_rules( + self, + ) -> workload_identity_federation_rules.WorkloadIdentityFederationRulesResourceWithStreamingResponse: + from .resources.workload_identity_federation_rules import ( + WorkloadIdentityFederationRulesResourceWithStreamingResponse, + ) + + return WorkloadIdentityFederationRulesResourceWithStreamingResponse( + self._client.workload_identity_federation_rules + ) + + @cached_property + def workload_identity_authentication_events( + self, + ) -> workload_identity_authentication_events.WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse: + from .resources.workload_identity_authentication_events import ( + WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse, + ) + + return WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse( + self._client.workload_identity_authentication_events + ) + @cached_property def credential_providers(self) -> credential_providers.CredentialProvidersResourceWithStreamingResponse: """Configure external credential providers like 1Password.""" @@ -1721,6 +1894,44 @@ def api_keys(self) -> api_keys.AsyncAPIKeysResourceWithStreamingResponse: return AsyncAPIKeysResourceWithStreamingResponse(self._client.api_keys) + @cached_property + def service_accounts(self) -> service_accounts.AsyncServiceAccountsResourceWithStreamingResponse: + from .resources.service_accounts import AsyncServiceAccountsResourceWithStreamingResponse + + return AsyncServiceAccountsResourceWithStreamingResponse(self._client.service_accounts) + + @cached_property + def workload_identity_issuers( + self, + ) -> workload_identity_issuers.AsyncWorkloadIdentityIssuersResourceWithStreamingResponse: + from .resources.workload_identity_issuers import AsyncWorkloadIdentityIssuersResourceWithStreamingResponse + + return AsyncWorkloadIdentityIssuersResourceWithStreamingResponse(self._client.workload_identity_issuers) + + @cached_property + def workload_identity_federation_rules( + self, + ) -> workload_identity_federation_rules.AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse: + from .resources.workload_identity_federation_rules import ( + AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse, + ) + + return AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse( + self._client.workload_identity_federation_rules + ) + + @cached_property + def workload_identity_authentication_events( + self, + ) -> workload_identity_authentication_events.AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse: + from .resources.workload_identity_authentication_events import ( + AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse, + ) + + return AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse( + self._client.workload_identity_authentication_events + ) + @cached_property def credential_providers(self) -> credential_providers.AsyncCredentialProvidersResourceWithStreamingResponse: """Configure external credential providers like 1Password.""" diff --git a/src/kernel/_version.py b/src/kernel/_version.py index f8631114..528a1cdc 100644 --- a/src/kernel/_version.py +++ b/src/kernel/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "kernel" -__version__ = "0.150.0" # x-release-please-version +__version__ = "0.151.0" # x-release-please-version diff --git a/src/kernel/resources/__init__.py b/src/kernel/resources/__init__.py index 100f8646..9f64bfe0 100644 --- a/src/kernel/resources/__init__.py +++ b/src/kernel/resources/__init__.py @@ -176,6 +176,14 @@ ConfigRegistryResourceWithStreamingResponse, AsyncConfigRegistryResourceWithStreamingResponse, ) +from .service_accounts import ( + ServiceAccountsResource, + AsyncServiceAccountsResource, + ServiceAccountsResourceWithRawResponse, + AsyncServiceAccountsResourceWithRawResponse, + ServiceAccountsResourceWithStreamingResponse, + AsyncServiceAccountsResourceWithStreamingResponse, +) from .credential_providers import ( CredentialProvidersResource, AsyncCredentialProvidersResource, @@ -192,6 +200,30 @@ VaultProviderConfigsResourceWithStreamingResponse, AsyncVaultProviderConfigsResourceWithStreamingResponse, ) +from .workload_identity_issuers import ( + WorkloadIdentityIssuersResource, + AsyncWorkloadIdentityIssuersResource, + WorkloadIdentityIssuersResourceWithRawResponse, + AsyncWorkloadIdentityIssuersResourceWithRawResponse, + WorkloadIdentityIssuersResourceWithStreamingResponse, + AsyncWorkloadIdentityIssuersResourceWithStreamingResponse, +) +from .workload_identity_federation_rules import ( + WorkloadIdentityFederationRulesResource, + AsyncWorkloadIdentityFederationRulesResource, + WorkloadIdentityFederationRulesResourceWithRawResponse, + AsyncWorkloadIdentityFederationRulesResourceWithRawResponse, + WorkloadIdentityFederationRulesResourceWithStreamingResponse, + AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse, +) +from .workload_identity_authentication_events import ( + WorkloadIdentityAuthenticationEventsResource, + AsyncWorkloadIdentityAuthenticationEventsResource, + WorkloadIdentityAuthenticationEventsResourceWithRawResponse, + AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse, + WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse, + AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse, +) __all__ = [ "DeploymentsResource", @@ -326,6 +358,30 @@ "AsyncAPIKeysResourceWithRawResponse", "APIKeysResourceWithStreamingResponse", "AsyncAPIKeysResourceWithStreamingResponse", + "ServiceAccountsResource", + "AsyncServiceAccountsResource", + "ServiceAccountsResourceWithRawResponse", + "AsyncServiceAccountsResourceWithRawResponse", + "ServiceAccountsResourceWithStreamingResponse", + "AsyncServiceAccountsResourceWithStreamingResponse", + "WorkloadIdentityIssuersResource", + "AsyncWorkloadIdentityIssuersResource", + "WorkloadIdentityIssuersResourceWithRawResponse", + "AsyncWorkloadIdentityIssuersResourceWithRawResponse", + "WorkloadIdentityIssuersResourceWithStreamingResponse", + "AsyncWorkloadIdentityIssuersResourceWithStreamingResponse", + "WorkloadIdentityFederationRulesResource", + "AsyncWorkloadIdentityFederationRulesResource", + "WorkloadIdentityFederationRulesResourceWithRawResponse", + "AsyncWorkloadIdentityFederationRulesResourceWithRawResponse", + "WorkloadIdentityFederationRulesResourceWithStreamingResponse", + "AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse", + "WorkloadIdentityAuthenticationEventsResource", + "AsyncWorkloadIdentityAuthenticationEventsResource", + "WorkloadIdentityAuthenticationEventsResourceWithRawResponse", + "AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse", + "WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse", + "AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse", "CredentialProvidersResource", "AsyncCredentialProvidersResource", "CredentialProvidersResourceWithRawResponse", diff --git a/src/kernel/resources/api_keys.py b/src/kernel/resources/api_keys.py index 4dde52ca..f61d5d75 100644 --- a/src/kernel/resources/api_keys.py +++ b/src/kernel/resources/api_keys.py @@ -245,14 +245,18 @@ def update( def list( self, *, + created_by: str | Omit = omit, include_deleted: bool | Omit = omit, limit: int | Omit = omit, name: str | Omit = omit, offset: int | Omit = omit, + principal_type: Literal["user", "service_account"] | Omit = omit, + project_id: str | Omit = omit, query: str | Omit = omit, + service_account_id: str | Omit = omit, sort_by: Literal["created_at", "name", "expires_at", "last_used_at"] | Omit = omit, sort_direction: Literal["asc", "desc"] | Omit = omit, - status: Literal["active", "deleted", "all"] | Omit = omit, + status: Literal["active", "expired", "deleted", "all"] | 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, @@ -265,6 +269,9 @@ def list( API keys are masked. Args: + created_by: Return only keys created by this user ID. This is the same person the key's + created_by field describes. + include_deleted: Deprecated: use status=all instead. When true, include deleted (soft-deleted) API keys in the results for audit purposes. @@ -277,17 +284,24 @@ def list( offset: Number of results to skip + principal_type: Return only keys that act as a user, or only keys that act as a service account. + + project_id: Return only keys scoped to this project ID. The value "org" returns keys that + are not scoped to a project. + query: Case-insensitive substring match against API key name, creator, and project. API key identifiers and masked keys match by exact value or prefix. + service_account_id: Return only keys that belong to this service account. + sort_by: Field to sort API keys by. Keys with no expiry or no recorded use sort last for expires_at and last_used_at in either direction. sort_direction: Sort direction for API keys. - status: Filter API keys by status. "active" returns keys that are not deleted (default; - expired-but-not-deleted keys are still included), "deleted" returns only - soft-deleted keys, "all" returns both. + status: Filter API keys by status. "active" returns keys that are neither deleted nor + expired (default), "expired" returns keys that are not deleted and whose expiry + has passed, "deleted" returns only soft-deleted keys, "all" returns every key. extra_headers: Send extra headers @@ -307,11 +321,15 @@ def list( timeout=timeout, query=maybe_transform( { + "created_by": created_by, "include_deleted": include_deleted, "limit": limit, "name": name, "offset": offset, + "principal_type": principal_type, + "project_id": project_id, "query": query, + "service_account_id": service_account_id, "sort_by": sort_by, "sort_direction": sort_direction, "status": status, @@ -642,14 +660,18 @@ async def update( def list( self, *, + created_by: str | Omit = omit, include_deleted: bool | Omit = omit, limit: int | Omit = omit, name: str | Omit = omit, offset: int | Omit = omit, + principal_type: Literal["user", "service_account"] | Omit = omit, + project_id: str | Omit = omit, query: str | Omit = omit, + service_account_id: str | Omit = omit, sort_by: Literal["created_at", "name", "expires_at", "last_used_at"] | Omit = omit, sort_direction: Literal["asc", "desc"] | Omit = omit, - status: Literal["active", "deleted", "all"] | Omit = omit, + status: Literal["active", "expired", "deleted", "all"] | 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, @@ -662,6 +684,9 @@ def list( API keys are masked. Args: + created_by: Return only keys created by this user ID. This is the same person the key's + created_by field describes. + include_deleted: Deprecated: use status=all instead. When true, include deleted (soft-deleted) API keys in the results for audit purposes. @@ -674,17 +699,24 @@ def list( offset: Number of results to skip + principal_type: Return only keys that act as a user, or only keys that act as a service account. + + project_id: Return only keys scoped to this project ID. The value "org" returns keys that + are not scoped to a project. + query: Case-insensitive substring match against API key name, creator, and project. API key identifiers and masked keys match by exact value or prefix. + service_account_id: Return only keys that belong to this service account. + sort_by: Field to sort API keys by. Keys with no expiry or no recorded use sort last for expires_at and last_used_at in either direction. sort_direction: Sort direction for API keys. - status: Filter API keys by status. "active" returns keys that are not deleted (default; - expired-but-not-deleted keys are still included), "deleted" returns only - soft-deleted keys, "all" returns both. + status: Filter API keys by status. "active" returns keys that are neither deleted nor + expired (default), "expired" returns keys that are not deleted and whose expiry + has passed, "deleted" returns only soft-deleted keys, "all" returns every key. extra_headers: Send extra headers @@ -704,11 +736,15 @@ def list( timeout=timeout, query=maybe_transform( { + "created_by": created_by, "include_deleted": include_deleted, "limit": limit, "name": name, "offset": offset, + "principal_type": principal_type, + "project_id": project_id, "query": query, + "service_account_id": service_account_id, "sort_by": sort_by, "sort_direction": sort_direction, "status": status, diff --git a/src/kernel/resources/service_accounts.py b/src/kernel/resources/service_accounts.py new file mode 100644 index 00000000..2b044d9b --- /dev/null +++ b/src/kernel/resources/service_accounts.py @@ -0,0 +1,600 @@ +# 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 ..types import service_account_list_params, service_account_create_params, service_account_update_params +from .._types import Body, Omit, Query, Headers, NoneType, 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_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..pagination import SyncOffsetPagination, AsyncOffsetPagination +from .._base_client import AsyncPaginator, make_request_options +from ..types.service_account import ServiceAccount + +__all__ = ["ServiceAccountsResource", "AsyncServiceAccountsResource"] + + +class ServiceAccountsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ServiceAccountsResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return ServiceAccountsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ServiceAccountsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return ServiceAccountsResourceWithStreamingResponse(self) + + def create( + self, + *, + name: str, + description: 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, + idempotency_key: str | None = None, + ) -> ServiceAccount: + """Organization credential administrators only. + + No external namespace-ownership or + staff approval is required. New trust resources default disabled. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + return self._post( + "/org/service_accounts", + body=maybe_transform( + { + "name": name, + "description": description, + }, + service_account_create_params.ServiceAccountCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=ServiceAccount, + ) + + def retrieve( + self, + 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, + ) -> ServiceAccount: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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 id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/org/service_accounts/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ServiceAccount, + ) + + def update( + self, + id: str, + *, + expected_version: int, + description: str | Omit = omit, + 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, + idempotency_key: str | None = None, + ) -> ServiceAccount: + """ + Update 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._patch( + path_template("/org/service_accounts/{id}", id=id), + body=maybe_transform( + { + "expected_version": expected_version, + "description": description, + "name": name, + }, + service_account_update_params.ServiceAccountUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=ServiceAccount, + ) + + def list( + self, + *, + limit: int | Omit = omit, + offset: int | Omit = omit, + query: str | Omit = omit, + status: Literal["active", "archived", "all"] | 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, + ) -> SyncOffsetPagination[ServiceAccount]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + Args: + query: Case-insensitive substring match against name or description; exact ID match. + + 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( + "/org/service_accounts", + page=SyncOffsetPagination[ServiceAccount], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "offset": offset, + "query": query, + "status": status, + }, + service_account_list_params.ServiceAccountListParams, + ), + ), + model=ServiceAccount, + ) + + def delete( + self, + 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, + idempotency_key: str | None = None, + ) -> None: + """ + Retains history and invalidates associated authority within the documented + status bound. Does not delete created browser resources. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template("/org/service_accounts/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=NoneType, + ) + + +class AsyncServiceAccountsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncServiceAccountsResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncServiceAccountsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncServiceAccountsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return AsyncServiceAccountsResourceWithStreamingResponse(self) + + async def create( + self, + *, + name: str, + description: 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, + idempotency_key: str | None = None, + ) -> ServiceAccount: + """Organization credential administrators only. + + No external namespace-ownership or + staff approval is required. New trust resources default disabled. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + return await self._post( + "/org/service_accounts", + body=await async_maybe_transform( + { + "name": name, + "description": description, + }, + service_account_create_params.ServiceAccountCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=ServiceAccount, + ) + + async def retrieve( + self, + 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, + ) -> ServiceAccount: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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 id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/org/service_accounts/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ServiceAccount, + ) + + async def update( + self, + id: str, + *, + expected_version: int, + description: str | Omit = omit, + 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, + idempotency_key: str | None = None, + ) -> ServiceAccount: + """ + Update 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._patch( + path_template("/org/service_accounts/{id}", id=id), + body=await async_maybe_transform( + { + "expected_version": expected_version, + "description": description, + "name": name, + }, + service_account_update_params.ServiceAccountUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=ServiceAccount, + ) + + def list( + self, + *, + limit: int | Omit = omit, + offset: int | Omit = omit, + query: str | Omit = omit, + status: Literal["active", "archived", "all"] | 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[ServiceAccount, AsyncOffsetPagination[ServiceAccount]]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + Args: + query: Case-insensitive substring match against name or description; exact ID match. + + 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( + "/org/service_accounts", + page=AsyncOffsetPagination[ServiceAccount], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "offset": offset, + "query": query, + "status": status, + }, + service_account_list_params.ServiceAccountListParams, + ), + ), + model=ServiceAccount, + ) + + async def delete( + self, + 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, + idempotency_key: str | None = None, + ) -> None: + """ + Retains history and invalidates associated authority within the documented + status bound. Does not delete created browser resources. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template("/org/service_accounts/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=NoneType, + ) + + +class ServiceAccountsResourceWithRawResponse: + def __init__(self, service_accounts: ServiceAccountsResource) -> None: + self._service_accounts = service_accounts + + self.create = to_raw_response_wrapper( + service_accounts.create, + ) + self.retrieve = to_raw_response_wrapper( + service_accounts.retrieve, + ) + self.update = to_raw_response_wrapper( + service_accounts.update, + ) + self.list = to_raw_response_wrapper( + service_accounts.list, + ) + self.delete = to_raw_response_wrapper( + service_accounts.delete, + ) + + +class AsyncServiceAccountsResourceWithRawResponse: + def __init__(self, service_accounts: AsyncServiceAccountsResource) -> None: + self._service_accounts = service_accounts + + self.create = async_to_raw_response_wrapper( + service_accounts.create, + ) + self.retrieve = async_to_raw_response_wrapper( + service_accounts.retrieve, + ) + self.update = async_to_raw_response_wrapper( + service_accounts.update, + ) + self.list = async_to_raw_response_wrapper( + service_accounts.list, + ) + self.delete = async_to_raw_response_wrapper( + service_accounts.delete, + ) + + +class ServiceAccountsResourceWithStreamingResponse: + def __init__(self, service_accounts: ServiceAccountsResource) -> 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 AsyncServiceAccountsResourceWithStreamingResponse: + def __init__(self, service_accounts: AsyncServiceAccountsResource) -> 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, + ) diff --git a/src/kernel/resources/workload_identity_authentication_events.py b/src/kernel/resources/workload_identity_authentication_events.py new file mode 100644 index 00000000..9c0f4bae --- /dev/null +++ b/src/kernel/resources/workload_identity_authentication_events.py @@ -0,0 +1,226 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ..types import workload_identity_authentication_event_list_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..pagination import SyncOffsetPagination, AsyncOffsetPagination +from .._base_client import AsyncPaginator, make_request_options +from ..types.workload_identity_authentication_event import WorkloadIdentityAuthenticationEvent + +__all__ = ["WorkloadIdentityAuthenticationEventsResource", "AsyncWorkloadIdentityAuthenticationEventsResource"] + + +class WorkloadIdentityAuthenticationEventsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WorkloadIdentityAuthenticationEventsResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return WorkloadIdentityAuthenticationEventsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse(self) + + def list( + self, + *, + end_time: Union[str, datetime] | Omit = omit, + federation_rule_id: str | Omit = omit, + issuer_id: str | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + outcome: Literal["success", "failure"] | Omit = omit, + project_id: str | Omit = omit, + service_account_id: str | Omit = omit, + start_time: Union[str, datetime] | 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, + ) -> SyncOffsetPagination[WorkloadIdentityAuthenticationEvent]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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( + "/org/workload_identity_authentication_events", + page=SyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "end_time": end_time, + "federation_rule_id": federation_rule_id, + "issuer_id": issuer_id, + "limit": limit, + "offset": offset, + "outcome": outcome, + "project_id": project_id, + "service_account_id": service_account_id, + "start_time": start_time, + }, + workload_identity_authentication_event_list_params.WorkloadIdentityAuthenticationEventListParams, + ), + ), + model=WorkloadIdentityAuthenticationEvent, + ) + + +class AsyncWorkloadIdentityAuthenticationEventsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse(self) + + def list( + self, + *, + end_time: Union[str, datetime] | Omit = omit, + federation_rule_id: str | Omit = omit, + issuer_id: str | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + outcome: Literal["success", "failure"] | Omit = omit, + project_id: str | Omit = omit, + service_account_id: str | Omit = omit, + start_time: Union[str, datetime] | 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[ + WorkloadIdentityAuthenticationEvent, AsyncOffsetPagination[WorkloadIdentityAuthenticationEvent] + ]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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( + "/org/workload_identity_authentication_events", + page=AsyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "end_time": end_time, + "federation_rule_id": federation_rule_id, + "issuer_id": issuer_id, + "limit": limit, + "offset": offset, + "outcome": outcome, + "project_id": project_id, + "service_account_id": service_account_id, + "start_time": start_time, + }, + workload_identity_authentication_event_list_params.WorkloadIdentityAuthenticationEventListParams, + ), + ), + model=WorkloadIdentityAuthenticationEvent, + ) + + +class WorkloadIdentityAuthenticationEventsResourceWithRawResponse: + def __init__(self, workload_identity_authentication_events: WorkloadIdentityAuthenticationEventsResource) -> None: + self._workload_identity_authentication_events = workload_identity_authentication_events + + self.list = to_raw_response_wrapper( + workload_identity_authentication_events.list, + ) + + +class AsyncWorkloadIdentityAuthenticationEventsResourceWithRawResponse: + def __init__( + self, workload_identity_authentication_events: AsyncWorkloadIdentityAuthenticationEventsResource + ) -> None: + self._workload_identity_authentication_events = workload_identity_authentication_events + + self.list = async_to_raw_response_wrapper( + workload_identity_authentication_events.list, + ) + + +class WorkloadIdentityAuthenticationEventsResourceWithStreamingResponse: + def __init__(self, workload_identity_authentication_events: WorkloadIdentityAuthenticationEventsResource) -> None: + self._workload_identity_authentication_events = workload_identity_authentication_events + + self.list = to_streamed_response_wrapper( + workload_identity_authentication_events.list, + ) + + +class AsyncWorkloadIdentityAuthenticationEventsResourceWithStreamingResponse: + def __init__( + self, workload_identity_authentication_events: AsyncWorkloadIdentityAuthenticationEventsResource + ) -> None: + self._workload_identity_authentication_events = workload_identity_authentication_events + + self.list = async_to_streamed_response_wrapper( + workload_identity_authentication_events.list, + ) diff --git a/src/kernel/resources/workload_identity_federation_rules.py b/src/kernel/resources/workload_identity_federation_rules.py new file mode 100644 index 00000000..56a60f74 --- /dev/null +++ b/src/kernel/resources/workload_identity_federation_rules.py @@ -0,0 +1,667 @@ +# 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 ..types import ( + workload_identity_federation_rule_list_params, + workload_identity_federation_rule_create_params, + workload_identity_federation_rule_update_params, +) +from .._types import Body, Omit, Query, Headers, NoneType, 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_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..pagination import SyncOffsetPagination, AsyncOffsetPagination +from .._base_client import AsyncPaginator, make_request_options +from ..types.workload_identity_match_param import WorkloadIdentityMatchParam +from ..types.workload_identity_target_param import WorkloadIdentityTargetParam +from ..types.workload_identity_federation_rule import WorkloadIdentityFederationRule +from ..types.workload_identity_authorization_param import WorkloadIdentityAuthorizationParam + +__all__ = ["WorkloadIdentityFederationRulesResource", "AsyncWorkloadIdentityFederationRulesResource"] + + +class WorkloadIdentityFederationRulesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WorkloadIdentityFederationRulesResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return WorkloadIdentityFederationRulesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WorkloadIdentityFederationRulesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return WorkloadIdentityFederationRulesResourceWithStreamingResponse(self) + + def create( + self, + *, + authorization: WorkloadIdentityAuthorizationParam, + expected_audience: str, + issuer_id: str, + match: WorkloadIdentityMatchParam, + name: str, + target: WorkloadIdentityTargetParam, + description: str | Omit = omit, + enabled: 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityFederationRule: + """Organization credential administrators only. + + No external namespace-ownership or + staff approval is required. New trust resources default disabled. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + return self._post( + "/org/workload_identity_federation_rules", + body=maybe_transform( + { + "authorization": authorization, + "expected_audience": expected_audience, + "issuer_id": issuer_id, + "match": match, + "name": name, + "target": target, + "description": description, + "enabled": enabled, + }, + workload_identity_federation_rule_create_params.WorkloadIdentityFederationRuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityFederationRule, + ) + + def retrieve( + self, + 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, + ) -> WorkloadIdentityFederationRule: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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 id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/org/workload_identity_federation_rules/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WorkloadIdentityFederationRule, + ) + + def update( + self, + id: str, + *, + expected_version: int, + authorization: WorkloadIdentityAuthorizationParam | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + expected_audience: str | Omit = omit, + issuer_id: str | Omit = omit, + match: WorkloadIdentityMatchParam | Omit = omit, + name: str | Omit = omit, + target: WorkloadIdentityTargetParam | 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityFederationRule: + """ + Update a workload identity federation rule + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._patch( + path_template("/org/workload_identity_federation_rules/{id}", id=id), + body=maybe_transform( + { + "expected_version": expected_version, + "authorization": authorization, + "description": description, + "enabled": enabled, + "expected_audience": expected_audience, + "issuer_id": issuer_id, + "match": match, + "name": name, + "target": target, + }, + workload_identity_federation_rule_update_params.WorkloadIdentityFederationRuleUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityFederationRule, + ) + + def list( + self, + *, + issuer_id: str | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + project_id: str | Omit = omit, + query: str | Omit = omit, + service_account_id: str | Omit = omit, + status: Literal["active", "archived", "all"] | 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, + ) -> SyncOffsetPagination[WorkloadIdentityFederationRule]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + Args: + query: Case-insensitive substring match against name or description; exact ID match. + + 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( + "/org/workload_identity_federation_rules", + page=SyncOffsetPagination[WorkloadIdentityFederationRule], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "issuer_id": issuer_id, + "limit": limit, + "offset": offset, + "project_id": project_id, + "query": query, + "service_account_id": service_account_id, + "status": status, + }, + workload_identity_federation_rule_list_params.WorkloadIdentityFederationRuleListParams, + ), + ), + model=WorkloadIdentityFederationRule, + ) + + def delete( + self, + 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, + idempotency_key: str | None = None, + ) -> None: + """ + Retains history and invalidates associated authority within the documented + status bound. Does not delete created browser resources. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template("/org/workload_identity_federation_rules/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=NoneType, + ) + + +class AsyncWorkloadIdentityFederationRulesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWorkloadIdentityFederationRulesResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncWorkloadIdentityFederationRulesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse(self) + + async def create( + self, + *, + authorization: WorkloadIdentityAuthorizationParam, + expected_audience: str, + issuer_id: str, + match: WorkloadIdentityMatchParam, + name: str, + target: WorkloadIdentityTargetParam, + description: str | Omit = omit, + enabled: 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityFederationRule: + """Organization credential administrators only. + + No external namespace-ownership or + staff approval is required. New trust resources default disabled. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + return await self._post( + "/org/workload_identity_federation_rules", + body=await async_maybe_transform( + { + "authorization": authorization, + "expected_audience": expected_audience, + "issuer_id": issuer_id, + "match": match, + "name": name, + "target": target, + "description": description, + "enabled": enabled, + }, + workload_identity_federation_rule_create_params.WorkloadIdentityFederationRuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityFederationRule, + ) + + async def retrieve( + self, + 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, + ) -> WorkloadIdentityFederationRule: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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 id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/org/workload_identity_federation_rules/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WorkloadIdentityFederationRule, + ) + + async def update( + self, + id: str, + *, + expected_version: int, + authorization: WorkloadIdentityAuthorizationParam | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + expected_audience: str | Omit = omit, + issuer_id: str | Omit = omit, + match: WorkloadIdentityMatchParam | Omit = omit, + name: str | Omit = omit, + target: WorkloadIdentityTargetParam | 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityFederationRule: + """ + Update a workload identity federation rule + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._patch( + path_template("/org/workload_identity_federation_rules/{id}", id=id), + body=await async_maybe_transform( + { + "expected_version": expected_version, + "authorization": authorization, + "description": description, + "enabled": enabled, + "expected_audience": expected_audience, + "issuer_id": issuer_id, + "match": match, + "name": name, + "target": target, + }, + workload_identity_federation_rule_update_params.WorkloadIdentityFederationRuleUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityFederationRule, + ) + + def list( + self, + *, + issuer_id: str | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + project_id: str | Omit = omit, + query: str | Omit = omit, + service_account_id: str | Omit = omit, + status: Literal["active", "archived", "all"] | 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[WorkloadIdentityFederationRule, AsyncOffsetPagination[WorkloadIdentityFederationRule]]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + Args: + query: Case-insensitive substring match against name or description; exact ID match. + + 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( + "/org/workload_identity_federation_rules", + page=AsyncOffsetPagination[WorkloadIdentityFederationRule], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "issuer_id": issuer_id, + "limit": limit, + "offset": offset, + "project_id": project_id, + "query": query, + "service_account_id": service_account_id, + "status": status, + }, + workload_identity_federation_rule_list_params.WorkloadIdentityFederationRuleListParams, + ), + ), + model=WorkloadIdentityFederationRule, + ) + + async def delete( + self, + 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, + idempotency_key: str | None = None, + ) -> None: + """ + Retains history and invalidates associated authority within the documented + status bound. Does not delete created browser resources. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template("/org/workload_identity_federation_rules/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=NoneType, + ) + + +class WorkloadIdentityFederationRulesResourceWithRawResponse: + def __init__(self, workload_identity_federation_rules: WorkloadIdentityFederationRulesResource) -> None: + self._workload_identity_federation_rules = workload_identity_federation_rules + + self.create = to_raw_response_wrapper( + workload_identity_federation_rules.create, + ) + self.retrieve = to_raw_response_wrapper( + workload_identity_federation_rules.retrieve, + ) + self.update = to_raw_response_wrapper( + workload_identity_federation_rules.update, + ) + self.list = to_raw_response_wrapper( + workload_identity_federation_rules.list, + ) + self.delete = to_raw_response_wrapper( + workload_identity_federation_rules.delete, + ) + + +class AsyncWorkloadIdentityFederationRulesResourceWithRawResponse: + def __init__(self, workload_identity_federation_rules: AsyncWorkloadIdentityFederationRulesResource) -> None: + self._workload_identity_federation_rules = workload_identity_federation_rules + + self.create = async_to_raw_response_wrapper( + workload_identity_federation_rules.create, + ) + self.retrieve = async_to_raw_response_wrapper( + workload_identity_federation_rules.retrieve, + ) + self.update = async_to_raw_response_wrapper( + workload_identity_federation_rules.update, + ) + self.list = async_to_raw_response_wrapper( + workload_identity_federation_rules.list, + ) + self.delete = async_to_raw_response_wrapper( + workload_identity_federation_rules.delete, + ) + + +class WorkloadIdentityFederationRulesResourceWithStreamingResponse: + def __init__(self, workload_identity_federation_rules: WorkloadIdentityFederationRulesResource) -> None: + self._workload_identity_federation_rules = workload_identity_federation_rules + + self.create = to_streamed_response_wrapper( + workload_identity_federation_rules.create, + ) + self.retrieve = to_streamed_response_wrapper( + workload_identity_federation_rules.retrieve, + ) + self.update = to_streamed_response_wrapper( + workload_identity_federation_rules.update, + ) + self.list = to_streamed_response_wrapper( + workload_identity_federation_rules.list, + ) + self.delete = to_streamed_response_wrapper( + workload_identity_federation_rules.delete, + ) + + +class AsyncWorkloadIdentityFederationRulesResourceWithStreamingResponse: + def __init__(self, workload_identity_federation_rules: AsyncWorkloadIdentityFederationRulesResource) -> None: + self._workload_identity_federation_rules = workload_identity_federation_rules + + self.create = async_to_streamed_response_wrapper( + workload_identity_federation_rules.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + workload_identity_federation_rules.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + workload_identity_federation_rules.update, + ) + self.list = async_to_streamed_response_wrapper( + workload_identity_federation_rules.list, + ) + self.delete = async_to_streamed_response_wrapper( + workload_identity_federation_rules.delete, + ) diff --git a/src/kernel/resources/workload_identity_issuers.py b/src/kernel/resources/workload_identity_issuers.py new file mode 100644 index 00000000..ccd13682 --- /dev/null +++ b/src/kernel/resources/workload_identity_issuers.py @@ -0,0 +1,777 @@ +# 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 ..types import ( + WorkloadIdentityPresetType, + workload_identity_issuer_list_params, + workload_identity_issuer_create_params, + workload_identity_issuer_update_params, +) +from .._types import Body, Omit, Query, Headers, NoneType, 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_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..pagination import SyncOffsetPagination, AsyncOffsetPagination +from .._base_client import AsyncPaginator, make_request_options +from ..types.workload_identity_issuer import WorkloadIdentityIssuer +from ..types.workload_identity_preset_type import WorkloadIdentityPresetType +from ..types.workload_identity_issuer_key_check import WorkloadIdentityIssuerKeyCheck +from ..types.workload_identity_key_source_param import WorkloadIdentityKeySourceParam +from ..types.workload_identity_token_validation_param import WorkloadIdentityTokenValidationParam + +__all__ = ["WorkloadIdentityIssuersResource", "AsyncWorkloadIdentityIssuersResource"] + + +class WorkloadIdentityIssuersResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WorkloadIdentityIssuersResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return WorkloadIdentityIssuersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WorkloadIdentityIssuersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return WorkloadIdentityIssuersResourceWithStreamingResponse(self) + + def create( + self, + *, + name: str, + description: str | Omit = omit, + enabled: bool | Omit = omit, + issuer_url: str | Omit = omit, + jwks: WorkloadIdentityKeySourceParam | Omit = omit, + preset_type: WorkloadIdentityPresetType | Omit = omit, + token_validation: WorkloadIdentityTokenValidationParam | 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityIssuer: + """Organization credential administrators only. + + No external namespace-ownership or + staff approval is required. New trust resources default disabled. + + Args: + issuer_url: Exact expected signed issuer. Optional for github_actions and google_cloud, + which each have one fixed issuer. + + preset_type: The kind of identity provider. GitHub Actions, Google Cloud and Microsoft Entra + issuers are recognized by their issuer URL and must use their own type. Defaults + to the type the issuer URL belongs to, or custom_oidc. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + return self._post( + "/org/workload_identity_issuers", + body=maybe_transform( + { + "name": name, + "description": description, + "enabled": enabled, + "issuer_url": issuer_url, + "jwks": jwks, + "preset_type": preset_type, + "token_validation": token_validation, + }, + workload_identity_issuer_create_params.WorkloadIdentityIssuerCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityIssuer, + ) + + def retrieve( + self, + 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, + ) -> WorkloadIdentityIssuer: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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 id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/org/workload_identity_issuers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WorkloadIdentityIssuer, + ) + + def update( + self, + id: str, + *, + expected_version: int, + description: str | Omit = omit, + enabled: bool | Omit = omit, + issuer_url: str | Omit = omit, + jwks: WorkloadIdentityKeySourceParam | Omit = omit, + name: str | Omit = omit, + preset_type: WorkloadIdentityPresetType | Omit = omit, + token_validation: WorkloadIdentityTokenValidationParam | 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityIssuer: + """ + Update a workload identity issuer + + Args: + issuer_url: Exact expected signed issuer. Optional for github_actions and google_cloud, + which each have one fixed issuer. + + preset_type: The kind of identity provider. GitHub Actions, Google Cloud and Microsoft Entra + issuers are recognized by their issuer URL and must use their own type. Defaults + to the type the issuer URL belongs to, or custom_oidc. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._patch( + path_template("/org/workload_identity_issuers/{id}", id=id), + body=maybe_transform( + { + "expected_version": expected_version, + "description": description, + "enabled": enabled, + "issuer_url": issuer_url, + "jwks": jwks, + "name": name, + "preset_type": preset_type, + "token_validation": token_validation, + }, + workload_identity_issuer_update_params.WorkloadIdentityIssuerUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityIssuer, + ) + + def list( + self, + *, + enabled: bool | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + query: str | Omit = omit, + status: Literal["active", "archived", "all"] | 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, + ) -> SyncOffsetPagination[WorkloadIdentityIssuer]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + Args: + query: Case-insensitive substring match against name or description; exact ID match. + + 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( + "/org/workload_identity_issuers", + page=SyncOffsetPagination[WorkloadIdentityIssuer], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "enabled": enabled, + "limit": limit, + "offset": offset, + "query": query, + "status": status, + }, + workload_identity_issuer_list_params.WorkloadIdentityIssuerListParams, + ), + ), + model=WorkloadIdentityIssuer, + ) + + def delete( + self, + 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, + idempotency_key: str | None = None, + ) -> None: + """ + Retains history and invalidates associated authority within the documented + status bound. Does not delete created browser resources. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template("/org/workload_identity_issuers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=NoneType, + ) + + def verify( + self, + 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityIssuerKeyCheck: + """Read-only. + + Does not enable trust, approve namespace ownership, create a grant or + issue credentials. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/org/workload_identity_issuers/{id}/verify", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityIssuerKeyCheck, + ) + + +class AsyncWorkloadIdentityIssuersResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWorkloadIdentityIssuersResourceWithRawResponse: + """ + 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/kernel/kernel-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncWorkloadIdentityIssuersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWorkloadIdentityIssuersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/kernel/kernel-python-sdk#with_streaming_response + """ + return AsyncWorkloadIdentityIssuersResourceWithStreamingResponse(self) + + async def create( + self, + *, + name: str, + description: str | Omit = omit, + enabled: bool | Omit = omit, + issuer_url: str | Omit = omit, + jwks: WorkloadIdentityKeySourceParam | Omit = omit, + preset_type: WorkloadIdentityPresetType | Omit = omit, + token_validation: WorkloadIdentityTokenValidationParam | 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityIssuer: + """Organization credential administrators only. + + No external namespace-ownership or + staff approval is required. New trust resources default disabled. + + Args: + issuer_url: Exact expected signed issuer. Optional for github_actions and google_cloud, + which each have one fixed issuer. + + preset_type: The kind of identity provider. GitHub Actions, Google Cloud and Microsoft Entra + issuers are recognized by their issuer URL and must use their own type. Defaults + to the type the issuer URL belongs to, or custom_oidc. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + return await self._post( + "/org/workload_identity_issuers", + body=await async_maybe_transform( + { + "name": name, + "description": description, + "enabled": enabled, + "issuer_url": issuer_url, + "jwks": jwks, + "preset_type": preset_type, + "token_validation": token_validation, + }, + workload_identity_issuer_create_params.WorkloadIdentityIssuerCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityIssuer, + ) + + async def retrieve( + self, + 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, + ) -> WorkloadIdentityIssuer: + """Any signed-in member of the organization can read this. + + API keys cannot. + + 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 id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/org/workload_identity_issuers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=WorkloadIdentityIssuer, + ) + + async def update( + self, + id: str, + *, + expected_version: int, + description: str | Omit = omit, + enabled: bool | Omit = omit, + issuer_url: str | Omit = omit, + jwks: WorkloadIdentityKeySourceParam | Omit = omit, + name: str | Omit = omit, + preset_type: WorkloadIdentityPresetType | Omit = omit, + token_validation: WorkloadIdentityTokenValidationParam | 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityIssuer: + """ + Update a workload identity issuer + + Args: + issuer_url: Exact expected signed issuer. Optional for github_actions and google_cloud, + which each have one fixed issuer. + + preset_type: The kind of identity provider. GitHub Actions, Google Cloud and Microsoft Entra + issuers are recognized by their issuer URL and must use their own type. Defaults + to the type the issuer URL belongs to, or custom_oidc. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._patch( + path_template("/org/workload_identity_issuers/{id}", id=id), + body=await async_maybe_transform( + { + "expected_version": expected_version, + "description": description, + "enabled": enabled, + "issuer_url": issuer_url, + "jwks": jwks, + "name": name, + "preset_type": preset_type, + "token_validation": token_validation, + }, + workload_identity_issuer_update_params.WorkloadIdentityIssuerUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityIssuer, + ) + + def list( + self, + *, + enabled: bool | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + query: str | Omit = omit, + status: Literal["active", "archived", "all"] | 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[WorkloadIdentityIssuer, AsyncOffsetPagination[WorkloadIdentityIssuer]]: + """Any signed-in member of the organization can read this. + + API keys cannot. + + Args: + query: Case-insensitive substring match against name or description; exact ID match. + + 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( + "/org/workload_identity_issuers", + page=AsyncOffsetPagination[WorkloadIdentityIssuer], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "enabled": enabled, + "limit": limit, + "offset": offset, + "query": query, + "status": status, + }, + workload_identity_issuer_list_params.WorkloadIdentityIssuerListParams, + ), + ), + model=WorkloadIdentityIssuer, + ) + + async def delete( + self, + 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, + idempotency_key: str | None = None, + ) -> None: + """ + Retains history and invalidates associated authority within the documented + status bound. Does not delete created browser resources. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template("/org/workload_identity_issuers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=NoneType, + ) + + async def verify( + self, + 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, + idempotency_key: str | None = None, + ) -> WorkloadIdentityIssuerKeyCheck: + """Read-only. + + Does not enable trust, approve namespace ownership, create a grant or + issue credentials. + + 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 + + idempotency_key: Specify a custom idempotency key for this request + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/org/workload_identity_issuers/{id}/verify", id=id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + idempotency_key=idempotency_key, + ), + cast_to=WorkloadIdentityIssuerKeyCheck, + ) + + +class WorkloadIdentityIssuersResourceWithRawResponse: + def __init__(self, workload_identity_issuers: WorkloadIdentityIssuersResource) -> None: + self._workload_identity_issuers = workload_identity_issuers + + self.create = to_raw_response_wrapper( + workload_identity_issuers.create, + ) + self.retrieve = to_raw_response_wrapper( + workload_identity_issuers.retrieve, + ) + self.update = to_raw_response_wrapper( + workload_identity_issuers.update, + ) + self.list = to_raw_response_wrapper( + workload_identity_issuers.list, + ) + self.delete = to_raw_response_wrapper( + workload_identity_issuers.delete, + ) + self.verify = to_raw_response_wrapper( + workload_identity_issuers.verify, + ) + + +class AsyncWorkloadIdentityIssuersResourceWithRawResponse: + def __init__(self, workload_identity_issuers: AsyncWorkloadIdentityIssuersResource) -> None: + self._workload_identity_issuers = workload_identity_issuers + + self.create = async_to_raw_response_wrapper( + workload_identity_issuers.create, + ) + self.retrieve = async_to_raw_response_wrapper( + workload_identity_issuers.retrieve, + ) + self.update = async_to_raw_response_wrapper( + workload_identity_issuers.update, + ) + self.list = async_to_raw_response_wrapper( + workload_identity_issuers.list, + ) + self.delete = async_to_raw_response_wrapper( + workload_identity_issuers.delete, + ) + self.verify = async_to_raw_response_wrapper( + workload_identity_issuers.verify, + ) + + +class WorkloadIdentityIssuersResourceWithStreamingResponse: + def __init__(self, workload_identity_issuers: WorkloadIdentityIssuersResource) -> None: + self._workload_identity_issuers = workload_identity_issuers + + self.create = to_streamed_response_wrapper( + workload_identity_issuers.create, + ) + self.retrieve = to_streamed_response_wrapper( + workload_identity_issuers.retrieve, + ) + self.update = to_streamed_response_wrapper( + workload_identity_issuers.update, + ) + self.list = to_streamed_response_wrapper( + workload_identity_issuers.list, + ) + self.delete = to_streamed_response_wrapper( + workload_identity_issuers.delete, + ) + self.verify = to_streamed_response_wrapper( + workload_identity_issuers.verify, + ) + + +class AsyncWorkloadIdentityIssuersResourceWithStreamingResponse: + def __init__(self, workload_identity_issuers: AsyncWorkloadIdentityIssuersResource) -> None: + self._workload_identity_issuers = workload_identity_issuers + + self.create = async_to_streamed_response_wrapper( + workload_identity_issuers.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + workload_identity_issuers.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + workload_identity_issuers.update, + ) + self.list = async_to_streamed_response_wrapper( + workload_identity_issuers.list, + ) + self.delete = async_to_streamed_response_wrapper( + workload_identity_issuers.delete, + ) + self.verify = async_to_streamed_response_wrapper( + workload_identity_issuers.verify, + ) diff --git a/src/kernel/types/__init__.py b/src/kernel/types/__init__.py index d2ace47c..5ad9e40f 100644 --- a/src/kernel/types/__init__.py +++ b/src/kernel/types/__init__.py @@ -48,11 +48,13 @@ from .created_api_key import CreatedAPIKey as CreatedAPIKey from .lookup_response import LookupResponse as LookupResponse from .proxy_ip_detail import ProxyIPDetail as ProxyIPDetail +from .service_account import ServiceAccount as ServiceAccount from .vault_reference import VaultReference as VaultReference from .analysis_summary import AnalysisSummary as AnalysisSummary from .browser_location import BrowserLocation as BrowserLocation from .browser_pool_ref import BrowserPoolRef as BrowserPoolRef from .task_list_params import TaskListParams as TaskListParams +from .api_key_principal import APIKeyPrincipal as APIKeyPrincipal from .app_list_response import AppListResponse as AppListResponse from .no_recommendation import NoRecommendation as NoRecommendation from .proxy_list_params import ProxyListParams as ProxyListParams @@ -124,6 +126,7 @@ from .profile_download_params import ProfileDownloadParams as ProfileDownloadParams from .proxy_retrieve_response import ProxyRetrieveResponse as ProxyRetrieveResponse from .report_type_list_params import ReportTypeListParams as ReportTypeListParams +from .workload_identity_match import WorkloadIdentityMatch as WorkloadIdentityMatch from .browser_pool_list_params import BrowserPoolListParams as BrowserPoolListParams from .config_registry_response import ConfigRegistryResponse as ConfigRegistryResponse from .credential_create_params import CredentialCreateParams as CredentialCreateParams @@ -136,6 +139,8 @@ from .invocation_follow_params import InvocationFollowParams as InvocationFollowParams from .invocation_list_response import InvocationListResponse as InvocationListResponse from .invocation_update_params import InvocationUpdateParams as InvocationUpdateParams +from .workload_identity_issuer import WorkloadIdentityIssuer as WorkloadIdentityIssuer +from .workload_identity_target import WorkloadIdentityTarget as WorkloadIdentityTarget from .browser_fingerprint_param import BrowserFingerprintParam as BrowserFingerprintParam from .browser_repl_text_content import BrowserReplTextContent as BrowserReplTextContent from .browser_retrieve_response import BrowserRetrieveResponse as BrowserRetrieveResponse @@ -156,36 +161,76 @@ from .browser_save_profile_params import BrowserSaveProfileParams as BrowserSaveProfileParams from .config_registry_list_params import ConfigRegistryListParams as ConfigRegistryListParams from .report_type_version_summary import ReportTypeVersionSummary as ReportTypeVersionSummary +from .service_account_list_params import ServiceAccountListParams as ServiceAccountListParams from .browser_captcha_solver_param import BrowserCaptchaSolverParam as BrowserCaptchaSolverParam from .browser_network_config_param import BrowserNetworkConfigParam as BrowserNetworkConfigParam from .browser_network_update_param import BrowserNetworkUpdateParam as BrowserNetworkUpdateParam from .deployment_retrieve_response import DeploymentRetrieveResponse as DeploymentRetrieveResponse from .invocation_retrieve_response import InvocationRetrieveResponse as InvocationRetrieveResponse +from .workload_identity_key_source import WorkloadIdentityKeySource as WorkloadIdentityKeySource from .audit_log_export_chunk_params import AuditLogExportChunkParams as AuditLogExportChunkParams from .browser_allowlist_state_param import BrowserAllowlistStateParam as BrowserAllowlistStateParam from .browser_pool_acquire_response import BrowserPoolAcquireResponse as BrowserPoolAcquireResponse from .config_registry_lookup_params import ConfigRegistryLookupParams as ConfigRegistryLookupParams from .credential_totp_code_response import CredentialTotpCodeResponse as CredentialTotpCodeResponse +from .service_account_create_params import ServiceAccountCreateParams as ServiceAccountCreateParams +from .service_account_update_params import ServiceAccountUpdateParams as ServiceAccountUpdateParams +from .workload_identity_match_param import WorkloadIdentityMatchParam as WorkloadIdentityMatchParam +from .workload_identity_preset_type import WorkloadIdentityPresetType as WorkloadIdentityPresetType from .browser_load_extensions_params import BrowserLoadExtensionsParams as BrowserLoadExtensionsParams from .browser_location_request_param import BrowserLocationRequestParam as BrowserLocationRequestParam from .config_registry_resolve_params import ConfigRegistryResolveParams as ConfigRegistryResolveParams +from .workload_identity_target_param import WorkloadIdentityTargetParam as WorkloadIdentityTargetParam from .credential_provider_list_params import CredentialProviderListParams as CredentialProviderListParams from .credential_provider_test_result import CredentialProviderTestResult as CredentialProviderTestResult +from .workload_identity_authorization import WorkloadIdentityAuthorization as WorkloadIdentityAuthorization from .credential_provider_create_params import CredentialProviderCreateParams as CredentialProviderCreateParams from .credential_provider_update_params import CredentialProviderUpdateParams as CredentialProviderUpdateParams from .invocation_list_browsers_response import InvocationListBrowsersResponse as InvocationListBrowsersResponse from .vault_provider_config_list_params import VaultProviderConfigListParams as VaultProviderConfigListParams +from .workload_identity_federation_rule import WorkloadIdentityFederationRule as WorkloadIdentityFederationRule +from .workload_identity_issuer_key_check import WorkloadIdentityIssuerKeyCheck as WorkloadIdentityIssuerKeyCheck +from .workload_identity_key_source_param import WorkloadIdentityKeySourceParam as WorkloadIdentityKeySourceParam +from .workload_identity_token_validation import WorkloadIdentityTokenValidation as WorkloadIdentityTokenValidation from .vault_provider_config_create_params import VaultProviderConfigCreateParams as VaultProviderConfigCreateParams from .vault_provider_config_update_params import VaultProviderConfigUpdateParams as VaultProviderConfigUpdateParams +from .workload_identity_issuer_list_params import WorkloadIdentityIssuerListParams as WorkloadIdentityIssuerListParams from .browser_location_update_request_param import ( BrowserLocationUpdateRequestParam as BrowserLocationUpdateRequestParam, ) +from .workload_identity_authorization_param import ( + WorkloadIdentityAuthorizationParam as WorkloadIdentityAuthorizationParam, +) +from .workload_identity_authentication_event import ( + WorkloadIdentityAuthenticationEvent as WorkloadIdentityAuthenticationEvent, +) +from .workload_identity_issuer_create_params import ( + WorkloadIdentityIssuerCreateParams as WorkloadIdentityIssuerCreateParams, +) +from .workload_identity_issuer_update_params import ( + WorkloadIdentityIssuerUpdateParams as WorkloadIdentityIssuerUpdateParams, +) from .credential_provider_list_items_response import ( CredentialProviderListItemsResponse as CredentialProviderListItemsResponse, ) +from .workload_identity_token_validation_param import ( + WorkloadIdentityTokenValidationParam as WorkloadIdentityTokenValidationParam, +) from .extension_download_from_chrome_store_params import ( ExtensionDownloadFromChromeStoreParams as ExtensionDownloadFromChromeStoreParams, ) +from .workload_identity_federation_rule_list_params import ( + WorkloadIdentityFederationRuleListParams as WorkloadIdentityFederationRuleListParams, +) +from .workload_identity_federation_rule_create_params import ( + WorkloadIdentityFederationRuleCreateParams as WorkloadIdentityFederationRuleCreateParams, +) +from .workload_identity_federation_rule_update_params import ( + WorkloadIdentityFederationRuleUpdateParams as WorkloadIdentityFederationRuleUpdateParams, +) +from .workload_identity_authentication_event_list_params import ( + WorkloadIdentityAuthenticationEventListParams as WorkloadIdentityAuthenticationEventListParams, +) # Rebuild cyclical models only after all modules are imported. # This ensures that, when building the deferred (due to cyclical references) model schema, diff --git a/src/kernel/types/api_key.py b/src/kernel/types/api_key.py index 65000a30..ae3e56b7 100644 --- a/src/kernel/types/api_key.py +++ b/src/kernel/types/api_key.py @@ -5,8 +5,9 @@ from typing_extensions import Literal from .._models import BaseModel +from .api_key_principal import APIKeyPrincipal -__all__ = ["APIKey", "CreatedBy", "Policy", "PolicyStatement", "PolicyStatementCondition", "Principal"] +__all__ = ["APIKey", "CreatedBy", "Policy", "PolicyStatement", "PolicyStatementCondition"] class CreatedBy(BaseModel): @@ -75,12 +76,6 @@ class Policy(BaseModel): """Allow statements. Every action and resource not listed is denied.""" -class Principal(BaseModel): - id: str - - type: Literal["user", "service_account"] - - class APIKey(BaseModel): id: str """Unique API key identifier""" @@ -135,7 +130,7 @@ class APIKey(BaseModel): organization or project. """ - principal: Optional[Principal] = None + principal: Optional[APIKeyPrincipal] = None service_account_id: Optional[str] = None """Organization-owned service principal, when linked.""" diff --git a/src/kernel/types/api_key_list_params.py b/src/kernel/types/api_key_list_params.py index 780dbf04..56b94f0e 100644 --- a/src/kernel/types/api_key_list_params.py +++ b/src/kernel/types/api_key_list_params.py @@ -8,6 +8,12 @@ class APIKeyListParams(TypedDict, total=False): + created_by: str + """Return only keys created by this user ID. + + This is the same person the key's created_by field describes. + """ + include_deleted: bool """Deprecated: use status=all instead. @@ -30,12 +36,26 @@ class APIKeyListParams(TypedDict, total=False): offset: int """Number of results to skip""" + principal_type: Literal["user", "service_account"] + """ + Return only keys that act as a user, or only keys that act as a service account. + """ + + project_id: str + """Return only keys scoped to this project ID. + + The value "org" returns keys that are not scoped to a project. + """ + query: str """Case-insensitive substring match against API key name, creator, and project. API key identifiers and masked keys match by exact value or prefix. """ + service_account_id: str + """Return only keys that belong to this service account.""" + sort_by: Literal["created_at", "name", "expires_at", "last_used_at"] """Field to sort API keys by. @@ -46,10 +66,10 @@ class APIKeyListParams(TypedDict, total=False): sort_direction: Literal["asc", "desc"] """Sort direction for API keys.""" - status: Literal["active", "deleted", "all"] + status: Literal["active", "expired", "deleted", "all"] """Filter API keys by status. - "active" returns keys that are not deleted (default; expired-but-not-deleted - keys are still included), "deleted" returns only soft-deleted keys, "all" - returns both. + "active" returns keys that are neither deleted nor expired (default), "expired" + returns keys that are not deleted and whose expiry has passed, "deleted" returns + only soft-deleted keys, "all" returns every key. """ diff --git a/src/kernel/types/api_key_principal.py b/src/kernel/types/api_key_principal.py new file mode 100644 index 00000000..ff69027c --- /dev/null +++ b/src/kernel/types/api_key_principal.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["APIKeyPrincipal"] + + +class APIKeyPrincipal(BaseModel): + id: str + + type: Literal["user", "service_account"] diff --git a/src/kernel/types/auth/__init__.py b/src/kernel/types/auth/__init__.py index a3830af1..e41fce10 100644 --- a/src/kernel/types/auth/__init__.py +++ b/src/kernel/types/auth/__init__.py @@ -16,5 +16,6 @@ from .managed_auth_browser_config import ManagedAuthBrowserConfig as ManagedAuthBrowserConfig from .managed_auth_timeline_event import ManagedAuthTimelineEvent as ManagedAuthTimelineEvent from .managed_auth_browser_location import ManagedAuthBrowserLocation as ManagedAuthBrowserLocation +from .auth_context_workload_identity import AuthContextWorkloadIdentity as AuthContextWorkloadIdentity from .managed_auth_browser_config_param import ManagedAuthBrowserConfigParam as ManagedAuthBrowserConfigParam from .managed_auth_browser_location_param import ManagedAuthBrowserLocationParam as ManagedAuthBrowserLocationParam diff --git a/src/kernel/types/auth/auth_context.py b/src/kernel/types/auth/auth_context.py index ca449a06..5abfb9ee 100644 --- a/src/kernel/types/auth/auth_context.py +++ b/src/kernel/types/auth/auth_context.py @@ -4,6 +4,7 @@ from typing_extensions import Literal from ..._models import BaseModel +from .auth_context_workload_identity import AuthContextWorkloadIdentity __all__ = [ "AuthContext", @@ -16,7 +17,6 @@ "AuthorizationEffectivePolicyStatementCondition", "Organization", "Principal", - "WorkloadIdentity", ] @@ -141,18 +141,6 @@ class Principal(BaseModel): """The kind of principal authenticated for the request.""" -class WorkloadIdentity(BaseModel): - external_subject_digest: str - """Digest of the verified external subject. - - Never the original assertion or arbitrary claims. - """ - - federation_rule_id: str - - issuer_id: str - - class AuthContext(BaseModel): """The identity and authorization context resolved for the current request.""" @@ -169,4 +157,4 @@ class AuthContext(BaseModel): principal: Principal - workload_identity: Optional[WorkloadIdentity] = None + workload_identity: Optional[AuthContextWorkloadIdentity] = None diff --git a/src/kernel/types/auth/auth_context_workload_identity.py b/src/kernel/types/auth/auth_context_workload_identity.py new file mode 100644 index 00000000..92f47cd6 --- /dev/null +++ b/src/kernel/types/auth/auth_context_workload_identity.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from ..._models import BaseModel + +__all__ = ["AuthContextWorkloadIdentity"] + + +class AuthContextWorkloadIdentity(BaseModel): + external_subject_digest: str + """Digest of the verified external subject. + + Never the original assertion or arbitrary claims. + """ + + federation_rule_id: str + + issuer_id: str diff --git a/src/kernel/types/service_account.py b/src/kernel/types/service_account.py new file mode 100644 index 00000000..fbd65775 --- /dev/null +++ b/src/kernel/types/service_account.py @@ -0,0 +1,36 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from .._models import BaseModel + +__all__ = ["ServiceAccount"] + + +class ServiceAccount(BaseModel): + id: str + + archived_at: Optional[datetime] = None + + created_at: datetime + + created_by_user_id: Optional[str] = None + + description: str + + last_used_at: Optional[datetime] = None + """ + When one of the account's API keys last authenticated or one of its rules last + issued a token. Recorded at most once every 15 minutes, so it can lag. Null if + the account has never been used. + """ + + name: str + + org_id: str + + security_version: int + """Authority revision. Cosmetic updates do not widen permissions.""" + + updated_at: datetime diff --git a/src/kernel/types/service_account_create_params.py b/src/kernel/types/service_account_create_params.py new file mode 100644 index 00000000..14ba2e1f --- /dev/null +++ b/src/kernel/types/service_account_create_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ServiceAccountCreateParams"] + + +class ServiceAccountCreateParams(TypedDict, total=False): + name: Required[str] + + description: str diff --git a/src/kernel/types/service_account_list_params.py b/src/kernel/types/service_account_list_params.py new file mode 100644 index 00000000..b30b7079 --- /dev/null +++ b/src/kernel/types/service_account_list_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["ServiceAccountListParams"] + + +class ServiceAccountListParams(TypedDict, total=False): + limit: int + + offset: int + + query: str + """Case-insensitive substring match against name or description; exact ID match.""" + + status: Literal["active", "archived", "all"] diff --git a/src/kernel/types/service_account_update_params.py b/src/kernel/types/service_account_update_params.py new file mode 100644 index 00000000..ffc0c298 --- /dev/null +++ b/src/kernel/types/service_account_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ServiceAccountUpdateParams"] + + +class ServiceAccountUpdateParams(TypedDict, total=False): + expected_version: Required[int] + + description: str + + name: str diff --git a/src/kernel/types/workload_identity_authentication_event.py b/src/kernel/types/workload_identity_authentication_event.py new file mode 100644 index 00000000..7706a55b --- /dev/null +++ b/src/kernel/types/workload_identity_authentication_event.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityAuthenticationEvent"] + + +class WorkloadIdentityAuthenticationEvent(BaseModel): + id: str + + correlation_id: str + + created_at: datetime + + credential_id: Optional[str] = None + + federation_rule_id: Optional[str] = None + + issuer_id: Optional[str] = None + + org_id: str + + outcome: Literal["success", "failure"] + + project_id: Optional[str] = None + + reason: str + + service_account_id: Optional[str] = None diff --git a/src/kernel/types/workload_identity_authentication_event_list_params.py b/src/kernel/types/workload_identity_authentication_event_list_params.py new file mode 100644 index 00000000..a791a536 --- /dev/null +++ b/src/kernel/types/workload_identity_authentication_event_list_params.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["WorkloadIdentityAuthenticationEventListParams"] + + +class WorkloadIdentityAuthenticationEventListParams(TypedDict, total=False): + end_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + + federation_rule_id: str + + issuer_id: str + + limit: int + + offset: int + + outcome: Literal["success", "failure"] + + project_id: str + + service_account_id: str + + start_time: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/kernel/types/workload_identity_authorization.py b/src/kernel/types/workload_identity_authorization.py new file mode 100644 index 00000000..cb4be438 --- /dev/null +++ b/src/kernel/types/workload_identity_authorization.py @@ -0,0 +1,72 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityAuthorization", "Policy", "PolicyStatement", "PolicyStatementCondition"] + + +class PolicyStatementCondition(BaseModel): + """ + A condition narrows a policy statement to requests matching its constraint: the request attribute, a comparison operator, and that operator's values. + """ + + key: Literal["source_ip"] + """Request attribute the condition constrains. + + `source_ip` restricts the statement to requests whose client address falls + inside one of `values`. + """ + + operator: Literal["in"] + """Comparison the condition applies between the request attribute and values.""" + + values: List[str] + """Values the request attribute must match. + + For `source_ip`, CIDR networks: a bare address without a mask is rejected, and + so are an entry with host bits set and an IPv4 network written in IPv6 notation. + """ + + +class PolicyStatement(BaseModel): + action: str + """Permitted action, such as browsers:use or vaults:read.""" + + resource: str + """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. + + Wildcards are supported. + """ + + condition: Optional[PolicyStatementCondition] = None + """ + A condition narrows a policy statement to requests matching its constraint: the + request attribute, a comparison operator, and that operator's values. + """ + + +class Policy(BaseModel): + """ + Allow statements for resources in this rule's project, in the same format as a scoped API key policy. API key actions are not allowed. + """ + + statements: List[PolicyStatement] + """Allow statements. Every action and resource not listed is denied.""" + + +class WorkloadIdentityAuthorization(BaseModel): + policy: Policy + """ + Allow statements for resources in this rule's project, in the same format as a + scoped API key policy. API key actions are not allowed. + """ + + project_id: str + """The one project credentials from this rule are limited to.""" + + token_audience: str + + max_token_ttl_seconds: Optional[int] = None diff --git a/src/kernel/types/workload_identity_authorization_param.py b/src/kernel/types/workload_identity_authorization_param.py new file mode 100644 index 00000000..1227db95 --- /dev/null +++ b/src/kernel/types/workload_identity_authorization_param.py @@ -0,0 +1,74 @@ +# 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, Required, TypedDict + +from .._types import SequenceNotStr + +__all__ = ["WorkloadIdentityAuthorizationParam", "Policy", "PolicyStatement", "PolicyStatementCondition"] + + +class PolicyStatementCondition(TypedDict, total=False): + """ + A condition narrows a policy statement to requests matching its constraint: the request attribute, a comparison operator, and that operator's values. + """ + + key: Required[Literal["source_ip"]] + """Request attribute the condition constrains. + + `source_ip` restricts the statement to requests whose client address falls + inside one of `values`. + """ + + operator: Required[Literal["in"]] + """Comparison the condition applies between the request attribute and values.""" + + values: Required[SequenceNotStr[str]] + """Values the request attribute must match. + + For `source_ip`, CIDR networks: a bare address without a mask is rejected, and + so are an entry with host bits set and an IPv4 network written in IPv6 notation. + """ + + +class PolicyStatement(TypedDict, total=False): + action: Required[str] + """Permitted action, such as browsers:use or vaults:read.""" + + resource: Required[str] + """Resource the action applies to, in the format projects/{project_id}/{kind}/{id}. + + Wildcards are supported. + """ + + condition: PolicyStatementCondition + """ + A condition narrows a policy statement to requests matching its constraint: the + request attribute, a comparison operator, and that operator's values. + """ + + +class Policy(TypedDict, total=False): + """ + Allow statements for resources in this rule's project, in the same format as a scoped API key policy. API key actions are not allowed. + """ + + statements: Required[Iterable[PolicyStatement]] + """Allow statements. Every action and resource not listed is denied.""" + + +class WorkloadIdentityAuthorizationParam(TypedDict, total=False): + policy: Required[Policy] + """ + Allow statements for resources in this rule's project, in the same format as a + scoped API key policy. API key actions are not allowed. + """ + + project_id: Required[str] + """The one project credentials from this rule are limited to.""" + + token_audience: Required[str] + + max_token_ttl_seconds: int diff --git a/src/kernel/types/workload_identity_federation_rule.py b/src/kernel/types/workload_identity_federation_rule.py new file mode 100644 index 00000000..79fe4787 --- /dev/null +++ b/src/kernel/types/workload_identity_federation_rule.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from .._models import BaseModel +from .workload_identity_match import WorkloadIdentityMatch +from .workload_identity_target import WorkloadIdentityTarget +from .workload_identity_authorization import WorkloadIdentityAuthorization + +__all__ = ["WorkloadIdentityFederationRule"] + + +class WorkloadIdentityFederationRule(BaseModel): + id: str + + archived_at: Optional[datetime] = None + + authorization: WorkloadIdentityAuthorization + + created_at: datetime + + created_by_user_id: Optional[str] = None + + description: str + + enabled: bool + + expected_audience: str + + issuer_id: str + + last_exchange_at: Optional[datetime] = None + + match: WorkloadIdentityMatch + + name: str + + org_id: str + + security_version: int + """Authority revision. Cosmetic updates do not widen permissions.""" + + target: WorkloadIdentityTarget + + updated_at: datetime diff --git a/src/kernel/types/workload_identity_federation_rule_create_params.py b/src/kernel/types/workload_identity_federation_rule_create_params.py new file mode 100644 index 00000000..bc90779d --- /dev/null +++ b/src/kernel/types/workload_identity_federation_rule_create_params.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .workload_identity_match_param import WorkloadIdentityMatchParam +from .workload_identity_target_param import WorkloadIdentityTargetParam +from .workload_identity_authorization_param import WorkloadIdentityAuthorizationParam + +__all__ = ["WorkloadIdentityFederationRuleCreateParams"] + + +class WorkloadIdentityFederationRuleCreateParams(TypedDict, total=False): + authorization: Required[WorkloadIdentityAuthorizationParam] + + expected_audience: Required[str] + + issuer_id: Required[str] + + match: Required[WorkloadIdentityMatchParam] + + name: Required[str] + + target: Required[WorkloadIdentityTargetParam] + + description: str + + enabled: bool diff --git a/src/kernel/types/workload_identity_federation_rule_list_params.py b/src/kernel/types/workload_identity_federation_rule_list_params.py new file mode 100644 index 00000000..b632bf53 --- /dev/null +++ b/src/kernel/types/workload_identity_federation_rule_list_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["WorkloadIdentityFederationRuleListParams"] + + +class WorkloadIdentityFederationRuleListParams(TypedDict, total=False): + issuer_id: str + + limit: int + + offset: int + + project_id: str + + query: str + """Case-insensitive substring match against name or description; exact ID match.""" + + service_account_id: str + + status: Literal["active", "archived", "all"] diff --git a/src/kernel/types/workload_identity_federation_rule_update_params.py b/src/kernel/types/workload_identity_federation_rule_update_params.py new file mode 100644 index 00000000..20a60121 --- /dev/null +++ b/src/kernel/types/workload_identity_federation_rule_update_params.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .workload_identity_match_param import WorkloadIdentityMatchParam +from .workload_identity_target_param import WorkloadIdentityTargetParam +from .workload_identity_authorization_param import WorkloadIdentityAuthorizationParam + +__all__ = ["WorkloadIdentityFederationRuleUpdateParams"] + + +class WorkloadIdentityFederationRuleUpdateParams(TypedDict, total=False): + expected_version: Required[int] + + authorization: WorkloadIdentityAuthorizationParam + + description: str + + enabled: bool + + expected_audience: str + + issuer_id: str + + match: WorkloadIdentityMatchParam + + name: str + + target: WorkloadIdentityTargetParam diff --git a/src/kernel/types/workload_identity_issuer.py b/src/kernel/types/workload_identity_issuer.py new file mode 100644 index 00000000..12f19fcb --- /dev/null +++ b/src/kernel/types/workload_identity_issuer.py @@ -0,0 +1,52 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from .._models import BaseModel +from .workload_identity_key_source import WorkloadIdentityKeySource +from .workload_identity_preset_type import WorkloadIdentityPresetType +from .workload_identity_token_validation import WorkloadIdentityTokenValidation + +__all__ = ["WorkloadIdentityIssuer"] + + +class WorkloadIdentityIssuer(BaseModel): + id: str + + archived_at: Optional[datetime] = None + + created_at: datetime + + created_by_user_id: Optional[str] = None + + description: str + + enabled: bool + + issuer_url: str + """Exact expected signed issuer. + + Optional for github_actions and google_cloud, which each have one fixed issuer. + """ + + jwks: WorkloadIdentityKeySource + + name: str + + org_id: str + + preset_type: WorkloadIdentityPresetType + """The kind of identity provider. + + GitHub Actions, Google Cloud and Microsoft Entra issuers are recognized by their + issuer URL and must use their own type. Defaults to the type the issuer URL + belongs to, or custom_oidc. + """ + + security_version: int + """Authority revision. Cosmetic updates do not widen permissions.""" + + token_validation: WorkloadIdentityTokenValidation + + updated_at: datetime diff --git a/src/kernel/types/workload_identity_issuer_create_params.py b/src/kernel/types/workload_identity_issuer_create_params.py new file mode 100644 index 00000000..52e4878f --- /dev/null +++ b/src/kernel/types/workload_identity_issuer_create_params.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .workload_identity_preset_type import WorkloadIdentityPresetType +from .workload_identity_key_source_param import WorkloadIdentityKeySourceParam +from .workload_identity_token_validation_param import WorkloadIdentityTokenValidationParam + +__all__ = ["WorkloadIdentityIssuerCreateParams"] + + +class WorkloadIdentityIssuerCreateParams(TypedDict, total=False): + name: Required[str] + + description: str + + enabled: bool + + issuer_url: str + """Exact expected signed issuer. + + Optional for github_actions and google_cloud, which each have one fixed issuer. + """ + + jwks: WorkloadIdentityKeySourceParam + + preset_type: WorkloadIdentityPresetType + """The kind of identity provider. + + GitHub Actions, Google Cloud and Microsoft Entra issuers are recognized by their + issuer URL and must use their own type. Defaults to the type the issuer URL + belongs to, or custom_oidc. + """ + + token_validation: WorkloadIdentityTokenValidationParam diff --git a/src/kernel/types/workload_identity_issuer_key_check.py b/src/kernel/types/workload_identity_issuer_key_check.py new file mode 100644 index 00000000..b5e6a47a --- /dev/null +++ b/src/kernel/types/workload_identity_issuer_key_check.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityIssuerKeyCheck"] + + +class WorkloadIdentityIssuerKeyCheck(BaseModel): + issuer_id: str + + key_ids: List[str] diff --git a/src/kernel/types/workload_identity_issuer_list_params.py b/src/kernel/types/workload_identity_issuer_list_params.py new file mode 100644 index 00000000..5d18dae5 --- /dev/null +++ b/src/kernel/types/workload_identity_issuer_list_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["WorkloadIdentityIssuerListParams"] + + +class WorkloadIdentityIssuerListParams(TypedDict, total=False): + enabled: bool + + limit: int + + offset: int + + query: str + """Case-insensitive substring match against name or description; exact ID match.""" + + status: Literal["active", "archived", "all"] diff --git a/src/kernel/types/workload_identity_issuer_update_params.py b/src/kernel/types/workload_identity_issuer_update_params.py new file mode 100644 index 00000000..cbae9b40 --- /dev/null +++ b/src/kernel/types/workload_identity_issuer_update_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .workload_identity_preset_type import WorkloadIdentityPresetType +from .workload_identity_key_source_param import WorkloadIdentityKeySourceParam +from .workload_identity_token_validation_param import WorkloadIdentityTokenValidationParam + +__all__ = ["WorkloadIdentityIssuerUpdateParams"] + + +class WorkloadIdentityIssuerUpdateParams(TypedDict, total=False): + expected_version: Required[int] + + description: str + + enabled: bool + + issuer_url: str + """Exact expected signed issuer. + + Optional for github_actions and google_cloud, which each have one fixed issuer. + """ + + jwks: WorkloadIdentityKeySourceParam + + name: str + + preset_type: WorkloadIdentityPresetType + """The kind of identity provider. + + GitHub Actions, Google Cloud and Microsoft Entra issuers are recognized by their + issuer URL and must use their own type. Defaults to the type the issuer URL + belongs to, or custom_oidc. + """ + + token_validation: WorkloadIdentityTokenValidationParam diff --git a/src/kernel/types/workload_identity_key_source.py b/src/kernel/types/workload_identity_key_source.py new file mode 100644 index 00000000..763aa692 --- /dev/null +++ b/src/kernel/types/workload_identity_key_source.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityKeySource"] + + +class WorkloadIdentityKeySource(BaseModel): + type: Literal["discovery", "explicit_url", "inline"] + + ca_cert_pem: Optional[str] = None + """Optional public CA certificates. + + When set, only these CAs are trusted for key retrieval, in place of the system + roots. Private keys and private-network retrieval are not supported. + """ + + discovery_base_url: Optional[str] = None + + keys: Optional[List[Dict[str, object]]] = None + + url: Optional[str] = None diff --git a/src/kernel/types/workload_identity_key_source_param.py b/src/kernel/types/workload_identity_key_source_param.py new file mode 100644 index 00000000..da2c82f1 --- /dev/null +++ b/src/kernel/types/workload_identity_key_source_param.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Iterable +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["WorkloadIdentityKeySourceParam"] + + +class WorkloadIdentityKeySourceParam(TypedDict, total=False): + type: Required[Literal["discovery", "explicit_url", "inline"]] + + ca_cert_pem: str + """Optional public CA certificates. + + When set, only these CAs are trusted for key retrieval, in place of the system + roots. Private keys and private-network retrieval are not supported. + """ + + discovery_base_url: str + + keys: Iterable[Dict[str, object]] + + url: str diff --git a/src/kernel/types/workload_identity_match.py b/src/kernel/types/workload_identity_match.py new file mode 100644 index 00000000..da1b6686 --- /dev/null +++ b/src/kernel/types/workload_identity_match.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityMatch"] + + +class WorkloadIdentityMatch(BaseModel): + type: Literal["github_actions", "aws", "google_cloud", "microsoft_entra", "kubernetes", "custom_oidc"] + """Must be the issuer's preset_type.""" + + claims: Optional[Dict[str, str]] = None + """Exact string conditions keyed by RFC 6901 JSON Pointers. + + All conditions are ANDed. + """ + + environment: Optional[str] = None + + event_names: Optional[List[str]] = None + + job_workflow_ref: Optional[str] = None + + namespace: Optional[str] = None + + ref: Optional[str] = None + + repository: Optional[str] = None + """Friendly display name. Immutable IDs define the repository identity.""" + + repository_id: Optional[str] = None + + repository_owner_id: Optional[str] = None + + service_account: Optional[str] = None + + subject: Optional[str] = None + + subject_prefix: Optional[str] = None + + workflow: Optional[str] = None + + workflow_ref: Optional[str] = None diff --git a/src/kernel/types/workload_identity_match_param.py b/src/kernel/types/workload_identity_match_param.py new file mode 100644 index 00000000..bc534a5a --- /dev/null +++ b/src/kernel/types/workload_identity_match_param.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Literal, Required, TypedDict + +from .._types import SequenceNotStr + +__all__ = ["WorkloadIdentityMatchParam"] + + +class WorkloadIdentityMatchParam(TypedDict, total=False): + type: Required[Literal["github_actions", "aws", "google_cloud", "microsoft_entra", "kubernetes", "custom_oidc"]] + """Must be the issuer's preset_type.""" + + claims: Dict[str, str] + """Exact string conditions keyed by RFC 6901 JSON Pointers. + + All conditions are ANDed. + """ + + environment: str + + event_names: SequenceNotStr[str] + + job_workflow_ref: str + + namespace: str + + ref: str + + repository: str + """Friendly display name. Immutable IDs define the repository identity.""" + + repository_id: str + + repository_owner_id: str + + service_account: str + + subject: str + + subject_prefix: str + + workflow: str + + workflow_ref: str diff --git a/src/kernel/types/workload_identity_preset_type.py b/src/kernel/types/workload_identity_preset_type.py new file mode 100644 index 00000000..bb1ce26b --- /dev/null +++ b/src/kernel/types/workload_identity_preset_type.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal, TypeAlias + +__all__ = ["WorkloadIdentityPresetType"] + +WorkloadIdentityPresetType: TypeAlias = Literal[ + "github_actions", "aws", "google_cloud", "microsoft_entra", "kubernetes", "custom_oidc" +] diff --git a/src/kernel/types/workload_identity_target.py b/src/kernel/types/workload_identity_target.py new file mode 100644 index 00000000..c6119a75 --- /dev/null +++ b/src/kernel/types/workload_identity_target.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityTarget"] + + +class WorkloadIdentityTarget(BaseModel): + service_account_id: str + + type: Literal["service_account"] diff --git a/src/kernel/types/workload_identity_target_param.py b/src/kernel/types/workload_identity_target_param.py new file mode 100644 index 00000000..8a24c68f --- /dev/null +++ b/src/kernel/types/workload_identity_target_param.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["WorkloadIdentityTargetParam"] + + +class WorkloadIdentityTargetParam(TypedDict, total=False): + service_account_id: Required[str] + + type: Required[Literal["service_account"]] diff --git a/src/kernel/types/workload_identity_token_validation.py b/src/kernel/types/workload_identity_token_validation.py new file mode 100644 index 00000000..b9473dcd --- /dev/null +++ b/src/kernel/types/workload_identity_token_validation.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["WorkloadIdentityTokenValidation"] + + +class WorkloadIdentityTokenValidation(BaseModel): + max_lifetime_seconds: Optional[int] = None + """Maximum incoming signed exp minus iat, independent of outgoing token lifetime.""" + + replay_protection: Optional[Literal["single_use", "allow_reuse"]] = None + """Whether an incoming token can be exchanged more than once before it expires. + + Defaults to single_use for github_actions, aws, microsoft_entra and custom_oidc, + and to allow_reuse for kubernetes, because a pod reads the same projected token + until it is rotated. google_cloud is always allow_reuse because Google identity + tokens carry no token ID. allow_reuse can be set on microsoft_entra and + custom_oidc, and single_use on kubernetes. github_actions and aws are always + single_use. + """ diff --git a/src/kernel/types/workload_identity_token_validation_param.py b/src/kernel/types/workload_identity_token_validation_param.py new file mode 100644 index 00000000..34ee0067 --- /dev/null +++ b/src/kernel/types/workload_identity_token_validation_param.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["WorkloadIdentityTokenValidationParam"] + + +class WorkloadIdentityTokenValidationParam(TypedDict, total=False): + max_lifetime_seconds: int + """Maximum incoming signed exp minus iat, independent of outgoing token lifetime.""" + + replay_protection: Literal["single_use", "allow_reuse"] + """Whether an incoming token can be exchanged more than once before it expires. + + Defaults to single_use for github_actions, aws, microsoft_entra and custom_oidc, + and to allow_reuse for kubernetes, because a pod reads the same projected token + until it is rotated. google_cloud is always allow_reuse because Google identity + tokens carry no token ID. allow_reuse can be set on microsoft_entra and + custom_oidc, and single_use on kubernetes. github_actions and aws are always + single_use. + """ diff --git a/tests/api_resources/test_api_keys.py b/tests/api_resources/test_api_keys.py index 4dad1181..0814f239 100644 --- a/tests/api_resources/test_api_keys.py +++ b/tests/api_resources/test_api_keys.py @@ -206,11 +206,15 @@ def test_method_list(self, client: Kernel) -> None: @parametrize def test_method_list_with_all_params(self, client: Kernel) -> None: api_key = client.api_keys.list( + created_by="created_by", include_deleted=True, limit=100, name="name", offset=0, + principal_type="user", + project_id="project_id", query="query", + service_account_id="service_account_id", sort_by="created_at", sort_direction="asc", status="active", @@ -523,11 +527,15 @@ async def test_method_list(self, async_client: AsyncKernel) -> None: @parametrize async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> None: api_key = await async_client.api_keys.list( + created_by="created_by", include_deleted=True, limit=100, name="name", offset=0, + principal_type="user", + project_id="project_id", query="query", + service_account_id="service_account_id", sort_by="created_at", sort_direction="asc", status="active", diff --git a/tests/api_resources/test_service_accounts.py b/tests/api_resources/test_service_accounts.py new file mode 100644 index 00000000..e5bce5f9 --- /dev/null +++ b/tests/api_resources/test_service_accounts.py @@ -0,0 +1,473 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from kernel import Kernel, AsyncKernel +from tests.utils import assert_matches_type +from kernel.types import ( + ServiceAccount, +) +from kernel.pagination import SyncOffsetPagination, AsyncOffsetPagination + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestServiceAccounts: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: Kernel) -> None: + service_account = client.service_accounts.create( + name="name", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Kernel) -> None: + service_account = client.service_accounts.create( + name="name", + description="description", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Kernel) -> None: + response = client.service_accounts.with_raw_response.create( + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Kernel) -> None: + with client.service_accounts.with_streaming_response.create( + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: Kernel) -> None: + service_account = client.service_accounts.retrieve( + "id", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Kernel) -> None: + response = client.service_accounts.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Kernel) -> None: + with client.service_accounts.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.service_accounts.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: Kernel) -> None: + service_account = client.service_accounts.update( + id="id", + expected_version=1, + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update_with_all_params(self, client: Kernel) -> None: + service_account = client.service_accounts.update( + id="id", + expected_version=1, + description="description", + name="name", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: Kernel) -> None: + response = client.service_accounts.with_raw_response.update( + id="id", + expected_version=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: Kernel) -> None: + with client.service_accounts.with_streaming_response.update( + id="id", + expected_version=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.service_accounts.with_raw_response.update( + id="", + expected_version=1, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Kernel) -> None: + service_account = client.service_accounts.list() + assert_matches_type(SyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Kernel) -> None: + service_account = client.service_accounts.list( + limit=1, + offset=0, + query="query", + status="active", + ) + assert_matches_type(SyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Kernel) -> None: + response = client.service_accounts.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = response.parse() + assert_matches_type(SyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Kernel) -> None: + with client.service_accounts.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = response.parse() + assert_matches_type(SyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: Kernel) -> None: + service_account = client.service_accounts.delete( + "id", + ) + assert service_account is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Kernel) -> None: + response = client.service_accounts.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = response.parse() + assert service_account is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Kernel) -> None: + with client.service_accounts.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = response.parse() + assert service_account is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.service_accounts.with_raw_response.delete( + "", + ) + + +class TestAsyncServiceAccounts: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.create( + name="name", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.create( + name="name", + description="description", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncKernel) -> None: + response = await async_client.service_accounts.with_raw_response.create( + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = await response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncKernel) -> None: + async with async_client.service_accounts.with_streaming_response.create( + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = await response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.retrieve( + "id", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncKernel) -> None: + response = await async_client.service_accounts.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = await response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncKernel) -> None: + async with async_client.service_accounts.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = await response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.service_accounts.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.update( + id="id", + expected_version=1, + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.update( + id="id", + expected_version=1, + description="description", + name="name", + ) + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncKernel) -> None: + response = await async_client.service_accounts.with_raw_response.update( + id="id", + expected_version=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = await response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncKernel) -> None: + async with async_client.service_accounts.with_streaming_response.update( + id="id", + expected_version=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = await response.parse() + assert_matches_type(ServiceAccount, service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.service_accounts.with_raw_response.update( + id="", + expected_version=1, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.list() + assert_matches_type(AsyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.list( + limit=1, + offset=0, + query="query", + status="active", + ) + assert_matches_type(AsyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncKernel) -> None: + response = await async_client.service_accounts.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = await response.parse() + assert_matches_type(AsyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncKernel) -> None: + async with async_client.service_accounts.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = await response.parse() + assert_matches_type(AsyncOffsetPagination[ServiceAccount], service_account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncKernel) -> None: + service_account = await async_client.service_accounts.delete( + "id", + ) + assert service_account is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncKernel) -> None: + response = await async_client.service_accounts.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_account = await response.parse() + assert service_account is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncKernel) -> None: + async with async_client.service_accounts.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_account = await response.parse() + assert service_account is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.service_accounts.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/test_workload_identity_authentication_events.py b/tests/api_resources/test_workload_identity_authentication_events.py new file mode 100644 index 00000000..ba537138 --- /dev/null +++ b/tests/api_resources/test_workload_identity_authentication_events.py @@ -0,0 +1,146 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from kernel import Kernel, AsyncKernel +from tests.utils import assert_matches_type +from kernel.types import WorkloadIdentityAuthenticationEvent +from kernel._utils import parse_datetime +from kernel.pagination import SyncOffsetPagination, AsyncOffsetPagination + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWorkloadIdentityAuthenticationEvents: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Kernel) -> None: + workload_identity_authentication_event = client.workload_identity_authentication_events.list() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Kernel) -> None: + workload_identity_authentication_event = client.workload_identity_authentication_events.list( + end_time=parse_datetime("2019-12-27T18:11:19.117Z"), + federation_rule_id="federation_rule_id", + issuer_id="issuer_id", + limit=1, + offset=0, + outcome="success", + project_id="project_id", + service_account_id="service_account_id", + start_time=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Kernel) -> None: + response = client.workload_identity_authentication_events.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_authentication_event = response.parse() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Kernel) -> None: + with client.workload_identity_authentication_events.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_authentication_event = response.parse() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncWorkloadIdentityAuthenticationEvents: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncKernel) -> None: + workload_identity_authentication_event = await async_client.workload_identity_authentication_events.list() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_authentication_event = await async_client.workload_identity_authentication_events.list( + end_time=parse_datetime("2019-12-27T18:11:19.117Z"), + federation_rule_id="federation_rule_id", + issuer_id="issuer_id", + limit=1, + offset=0, + outcome="success", + project_id="project_id", + service_account_id="service_account_id", + start_time=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_authentication_events.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_authentication_event = await response.parse() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_authentication_events.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_authentication_event = await response.parse() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityAuthenticationEvent], + workload_identity_authentication_event, + path=["response"], + ) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_workload_identity_federation_rules.py b/tests/api_resources/test_workload_identity_federation_rules.py new file mode 100644 index 00000000..e9fc96ca --- /dev/null +++ b/tests/api_resources/test_workload_identity_federation_rules.py @@ -0,0 +1,781 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from kernel import Kernel, AsyncKernel +from tests.utils import assert_matches_type +from kernel.types import ( + WorkloadIdentityFederationRule, +) +from kernel.pagination import SyncOffsetPagination, AsyncOffsetPagination + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWorkloadIdentityFederationRules: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + } + ] + }, + "project_id": "x", + "token_audience": "x", + }, + expected_audience="x", + issuer_id="x", + match={"type": "github_actions"}, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + "condition": { + "key": "source_ip", + "operator": "in", + "values": ["203.0.113.0/24"], + }, + } + ] + }, + "project_id": "x", + "token_audience": "x", + "max_token_ttl_seconds": 1, + }, + expected_audience="x", + issuer_id="x", + match={ + "type": "github_actions", + "claims": {"foo": "x"}, + "environment": "environment", + "event_names": ["x"], + "job_workflow_ref": "job_workflow_ref", + "namespace": "namespace", + "ref": "ref", + "repository": "repository", + "repository_id": "269125115713", + "repository_owner_id": "269125115713", + "service_account": "service_account", + "subject": "x", + "subject_prefix": "x", + "workflow": "workflow", + "workflow_ref": "workflow_ref", + }, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + description="description", + enabled=True, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Kernel) -> None: + response = client.workload_identity_federation_rules.with_raw_response.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + } + ] + }, + "project_id": "x", + "token_audience": "x", + }, + expected_audience="x", + issuer_id="x", + match={"type": "github_actions"}, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Kernel) -> None: + with client.workload_identity_federation_rules.with_streaming_response.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + } + ] + }, + "project_id": "x", + "token_audience": "x", + }, + expected_audience="x", + issuer_id="x", + match={"type": "github_actions"}, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.retrieve( + "id", + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Kernel) -> None: + response = client.workload_identity_federation_rules.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Kernel) -> None: + with client.workload_identity_federation_rules.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_federation_rules.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.update( + id="id", + expected_version=1, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update_with_all_params(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.update( + id="id", + expected_version=1, + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + "condition": { + "key": "source_ip", + "operator": "in", + "values": ["203.0.113.0/24"], + }, + } + ] + }, + "project_id": "x", + "token_audience": "x", + "max_token_ttl_seconds": 1, + }, + description="description", + enabled=True, + expected_audience="x", + issuer_id="x", + match={ + "type": "github_actions", + "claims": {"foo": "x"}, + "environment": "environment", + "event_names": ["x"], + "job_workflow_ref": "job_workflow_ref", + "namespace": "namespace", + "ref": "ref", + "repository": "repository", + "repository_id": "269125115713", + "repository_owner_id": "269125115713", + "service_account": "service_account", + "subject": "x", + "subject_prefix": "x", + "workflow": "workflow", + "workflow_ref": "workflow_ref", + }, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: Kernel) -> None: + response = client.workload_identity_federation_rules.with_raw_response.update( + id="id", + expected_version=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: Kernel) -> None: + with client.workload_identity_federation_rules.with_streaming_response.update( + id="id", + expected_version=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_federation_rules.with_raw_response.update( + id="", + expected_version=1, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.list() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityFederationRule], workload_identity_federation_rule, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.list( + issuer_id="issuer_id", + limit=1, + offset=0, + project_id="project_id", + query="query", + service_account_id="service_account_id", + status="active", + ) + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityFederationRule], workload_identity_federation_rule, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Kernel) -> None: + response = client.workload_identity_federation_rules.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = response.parse() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityFederationRule], workload_identity_federation_rule, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Kernel) -> None: + with client.workload_identity_federation_rules.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = response.parse() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityFederationRule], + workload_identity_federation_rule, + path=["response"], + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: Kernel) -> None: + workload_identity_federation_rule = client.workload_identity_federation_rules.delete( + "id", + ) + assert workload_identity_federation_rule is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Kernel) -> None: + response = client.workload_identity_federation_rules.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = response.parse() + assert workload_identity_federation_rule is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Kernel) -> None: + with client.workload_identity_federation_rules.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = response.parse() + assert workload_identity_federation_rule is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_federation_rules.with_raw_response.delete( + "", + ) + + +class TestAsyncWorkloadIdentityFederationRules: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + } + ] + }, + "project_id": "x", + "token_audience": "x", + }, + expected_audience="x", + issuer_id="x", + match={"type": "github_actions"}, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + "condition": { + "key": "source_ip", + "operator": "in", + "values": ["203.0.113.0/24"], + }, + } + ] + }, + "project_id": "x", + "token_audience": "x", + "max_token_ttl_seconds": 1, + }, + expected_audience="x", + issuer_id="x", + match={ + "type": "github_actions", + "claims": {"foo": "x"}, + "environment": "environment", + "event_names": ["x"], + "job_workflow_ref": "job_workflow_ref", + "namespace": "namespace", + "ref": "ref", + "repository": "repository", + "repository_id": "269125115713", + "repository_owner_id": "269125115713", + "service_account": "service_account", + "subject": "x", + "subject_prefix": "x", + "workflow": "workflow", + "workflow_ref": "workflow_ref", + }, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + description="description", + enabled=True, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_federation_rules.with_raw_response.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + } + ] + }, + "project_id": "x", + "token_audience": "x", + }, + expected_audience="x", + issuer_id="x", + match={"type": "github_actions"}, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = await response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_federation_rules.with_streaming_response.create( + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + } + ] + }, + "project_id": "x", + "token_audience": "x", + }, + expected_audience="x", + issuer_id="x", + match={"type": "github_actions"}, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = await response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.retrieve( + "id", + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_federation_rules.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = await response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_federation_rules.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = await response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_federation_rules.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.update( + id="id", + expected_version=1, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.update( + id="id", + expected_version=1, + authorization={ + "policy": { + "statements": [ + { + "action": "browsers:use", + "resource": "projects/proj_abc123/browsers/br_abc123", + "condition": { + "key": "source_ip", + "operator": "in", + "values": ["203.0.113.0/24"], + }, + } + ] + }, + "project_id": "x", + "token_audience": "x", + "max_token_ttl_seconds": 1, + }, + description="description", + enabled=True, + expected_audience="x", + issuer_id="x", + match={ + "type": "github_actions", + "claims": {"foo": "x"}, + "environment": "environment", + "event_names": ["x"], + "job_workflow_ref": "job_workflow_ref", + "namespace": "namespace", + "ref": "ref", + "repository": "repository", + "repository_id": "269125115713", + "repository_owner_id": "269125115713", + "service_account": "service_account", + "subject": "x", + "subject_prefix": "x", + "workflow": "workflow", + "workflow_ref": "workflow_ref", + }, + name="name", + target={ + "service_account_id": "x", + "type": "service_account", + }, + ) + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_federation_rules.with_raw_response.update( + id="id", + expected_version=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = await response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_federation_rules.with_streaming_response.update( + id="id", + expected_version=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = await response.parse() + assert_matches_type(WorkloadIdentityFederationRule, workload_identity_federation_rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_federation_rules.with_raw_response.update( + id="", + expected_version=1, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.list() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityFederationRule], workload_identity_federation_rule, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.list( + issuer_id="issuer_id", + limit=1, + offset=0, + project_id="project_id", + query="query", + service_account_id="service_account_id", + status="active", + ) + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityFederationRule], workload_identity_federation_rule, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_federation_rules.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = await response.parse() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityFederationRule], workload_identity_federation_rule, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_federation_rules.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = await response.parse() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityFederationRule], + workload_identity_federation_rule, + path=["response"], + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncKernel) -> None: + workload_identity_federation_rule = await async_client.workload_identity_federation_rules.delete( + "id", + ) + assert workload_identity_federation_rule is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_federation_rules.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_federation_rule = await response.parse() + assert workload_identity_federation_rule is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_federation_rules.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_federation_rule = await response.parse() + assert workload_identity_federation_rule is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_federation_rules.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/test_workload_identity_issuers.py b/tests/api_resources/test_workload_identity_issuers.py new file mode 100644 index 00000000..4e77af6d --- /dev/null +++ b/tests/api_resources/test_workload_identity_issuers.py @@ -0,0 +1,620 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from kernel import Kernel, AsyncKernel +from tests.utils import assert_matches_type +from kernel.types import ( + WorkloadIdentityIssuer, + WorkloadIdentityIssuerKeyCheck, +) +from kernel.pagination import SyncOffsetPagination, AsyncOffsetPagination + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWorkloadIdentityIssuers: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.create( + name="name", + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.create( + name="name", + description="description", + enabled=True, + issuer_url="https://example.com", + jwks={ + "type": "discovery", + "ca_cert_pem": "ca_cert_pem", + "discovery_base_url": "https://example.com", + "keys": [{"foo": "bar"}], + "url": "https://example.com", + }, + preset_type="github_actions", + token_validation={ + "max_lifetime_seconds": 1, + "replay_protection": "single_use", + }, + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Kernel) -> None: + response = client.workload_identity_issuers.with_raw_response.create( + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Kernel) -> None: + with client.workload_identity_issuers.with_streaming_response.create( + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.retrieve( + "id", + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: Kernel) -> None: + response = client.workload_identity_issuers.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: Kernel) -> None: + with client.workload_identity_issuers.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_issuers.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.update( + id="id", + expected_version=1, + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update_with_all_params(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.update( + id="id", + expected_version=1, + description="description", + enabled=True, + issuer_url="https://example.com", + jwks={ + "type": "discovery", + "ca_cert_pem": "ca_cert_pem", + "discovery_base_url": "https://example.com", + "keys": [{"foo": "bar"}], + "url": "https://example.com", + }, + name="name", + preset_type="github_actions", + token_validation={ + "max_lifetime_seconds": 1, + "replay_protection": "single_use", + }, + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: Kernel) -> None: + response = client.workload_identity_issuers.with_raw_response.update( + id="id", + expected_version=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: Kernel) -> None: + with client.workload_identity_issuers.with_streaming_response.update( + id="id", + expected_version=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_issuers.with_raw_response.update( + id="", + expected_version=1, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.list() + assert_matches_type(SyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.list( + enabled=True, + limit=1, + offset=0, + query="query", + status="active", + ) + assert_matches_type(SyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Kernel) -> None: + response = client.workload_identity_issuers.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = response.parse() + assert_matches_type(SyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Kernel) -> None: + with client.workload_identity_issuers.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = response.parse() + assert_matches_type( + SyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.delete( + "id", + ) + assert workload_identity_issuer is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Kernel) -> None: + response = client.workload_identity_issuers.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = response.parse() + assert workload_identity_issuer is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Kernel) -> None: + with client.workload_identity_issuers.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = response.parse() + assert workload_identity_issuer is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_issuers.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_verify(self, client: Kernel) -> None: + workload_identity_issuer = client.workload_identity_issuers.verify( + "id", + ) + assert_matches_type(WorkloadIdentityIssuerKeyCheck, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_verify(self, client: Kernel) -> None: + response = client.workload_identity_issuers.with_raw_response.verify( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuerKeyCheck, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_verify(self, client: Kernel) -> None: + with client.workload_identity_issuers.with_streaming_response.verify( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = response.parse() + assert_matches_type(WorkloadIdentityIssuerKeyCheck, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_verify(self, client: Kernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.workload_identity_issuers.with_raw_response.verify( + "", + ) + + +class TestAsyncWorkloadIdentityIssuers: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.create( + name="name", + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.create( + name="name", + description="description", + enabled=True, + issuer_url="https://example.com", + jwks={ + "type": "discovery", + "ca_cert_pem": "ca_cert_pem", + "discovery_base_url": "https://example.com", + "keys": [{"foo": "bar"}], + "url": "https://example.com", + }, + preset_type="github_actions", + token_validation={ + "max_lifetime_seconds": 1, + "replay_protection": "single_use", + }, + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_issuers.with_raw_response.create( + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_issuers.with_streaming_response.create( + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.retrieve( + "id", + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_issuers.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_issuers.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_issuers.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.update( + id="id", + expected_version=1, + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.update( + id="id", + expected_version=1, + description="description", + enabled=True, + issuer_url="https://example.com", + jwks={ + "type": "discovery", + "ca_cert_pem": "ca_cert_pem", + "discovery_base_url": "https://example.com", + "keys": [{"foo": "bar"}], + "url": "https://example.com", + }, + name="name", + preset_type="github_actions", + token_validation={ + "max_lifetime_seconds": 1, + "replay_protection": "single_use", + }, + ) + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_issuers.with_raw_response.update( + id="id", + expected_version=1, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_issuers.with_streaming_response.update( + id="id", + expected_version=1, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuer, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_issuers.with_raw_response.update( + id="", + expected_version=1, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.list() + assert_matches_type(AsyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.list( + enabled=True, + limit=1, + offset=0, + query="query", + status="active", + ) + assert_matches_type(AsyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_issuers.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = await response.parse() + assert_matches_type(AsyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_issuers.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = await response.parse() + assert_matches_type( + AsyncOffsetPagination[WorkloadIdentityIssuer], workload_identity_issuer, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.delete( + "id", + ) + assert workload_identity_issuer is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_issuers.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = await response.parse() + assert workload_identity_issuer is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_issuers.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = await response.parse() + assert workload_identity_issuer is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_issuers.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_verify(self, async_client: AsyncKernel) -> None: + workload_identity_issuer = await async_client.workload_identity_issuers.verify( + "id", + ) + assert_matches_type(WorkloadIdentityIssuerKeyCheck, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_verify(self, async_client: AsyncKernel) -> None: + response = await async_client.workload_identity_issuers.with_raw_response.verify( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuerKeyCheck, workload_identity_issuer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_verify(self, async_client: AsyncKernel) -> None: + async with async_client.workload_identity_issuers.with_streaming_response.verify( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + workload_identity_issuer = await response.parse() + assert_matches_type(WorkloadIdentityIssuerKeyCheck, workload_identity_issuer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_verify(self, async_client: AsyncKernel) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.workload_identity_issuers.with_raw_response.verify( + "", + )