diff --git a/google/genai/_gaos/environments.py b/google/genai/_gaos/environments.py new file mode 100644 index 000000000..0198f6940 --- /dev/null +++ b/google/genai/_gaos/environments.py @@ -0,0 +1,1367 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from . import errors, models, types, utils +from ._hooks import AfterParseErrorContext, HookContext, ResponseContext +from .basesdk import AsyncBaseSDK, BaseSDK +from .types import OptionalNullable, UNSET, environments, interactions +from .types.environments import environment as environments_environment +from .utils import get_security_from_env, response_helpers +from .utils.unmarshal_json_response import unmarshal_json_response +import httpx +from typing import Any, Mapping, Optional, Union, cast + + +class Environments(BaseSDK): + @property + def with_raw_response(self): + return EnvironmentsWithRawResponse(self) + + @property + def with_streaming_response(self): + return EnvironmentsWithStreamingResponse(self) + + def create_environment( + self, + *, + api_version: Optional[str] = None, + body: Optional[ + Union[ + environments_environment.EnvironmentInput, + environments_environment.EnvironmentInputParam, + ] + ] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + extra_body: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> environments.Environment: + r"""Creates an environment. + + :param api_version: Which version of the API to use. + :param body: Required. The environment to create. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param extra_body: Additional JSON object fields to merge into request bodies. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.CreateEnvironmentRequest( + api_version=api_version, + body=utils.get_pydantic_model( + body, Optional[environments.EnvironmentInput] + ), + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request( + method="POST", + path="/{api_version}/environments", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.CreateEnvironmentGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body if request is not None else None, + False, + True, + "json", + Optional[environments.EnvironmentInput], + extra_body=extra_body, + ), + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + environments.Environment, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="CreateEnvironment", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), + ) + http_res = self.do_request( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + http_res.read() + try: + _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.StreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.APIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + ), + ) + try: + return _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + def list_environments( + self, + *, + api_version: Optional[str] = None, + page_size: Optional[int] = None, + page_token: Optional[str] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> environments.ListEnvironmentsResponse: + r"""Lists environments. + + :param api_version: Which version of the API to use. + :param page_size: Optional. Maximum number of environments to return.\nIf unspecified, defaults to 50. Maximum is 1000. + :param page_token: Optional. Pagination token. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.ListEnvironmentsRequest( + api_version=api_version, + page_size=page_size, + page_token=page_token, + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request( + method="GET", + path="/{api_version}/environments", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.ListEnvironmentsGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + environments.ListEnvironmentsResponse, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="ListEnvironments", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), + ) + http_res = self.do_request( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + http_res.read() + try: + _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.StreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.APIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + ), + ) + try: + return _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + def get_environment( + self, + id: str, + *, + api_version: Optional[str] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> environments.Environment: + r"""Gets an environment. + + :param id: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. + :param api_version: Which version of the API to use. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.GetEnvironmentRequest( + api_version=api_version, + id=id, + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request( + method="GET", + path="/{api_version}/environments/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.GetEnvironmentGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + environments.Environment, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="GetEnvironment", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), + ) + http_res = self.do_request( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + http_res.read() + try: + _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.StreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.APIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + ), + ) + try: + return _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + def delete_environment( + self, + id: str, + *, + api_version: Optional[str] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> interactions.Empty: + r"""Deletes an environment. + + :param id: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. + :param api_version: Which version of the API to use. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.DeleteEnvironmentRequest( + api_version=api_version, + id=id, + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request( + method="DELETE", + path="/{api_version}/environments/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.DeleteEnvironmentGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + interactions.Empty, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="DeleteEnvironment", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), + ) + http_res = self.do_request( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + http_res.read() + try: + _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.StreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.APIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + ), + ) + try: + return _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + response_helpers.raise_parse_error( + self.sdk_configuration.__dict__["_hooks"], + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + +class EnvironmentsWithRawResponse: + def __init__(self, sdk: Environments) -> None: + self._sdk = sdk + self.create_environment = response_helpers.to_raw_response_wrapper( + sdk.create_environment, "extra_headers" + ) + self.list_environments = response_helpers.to_raw_response_wrapper( + sdk.list_environments, "extra_headers" + ) + self.get_environment = response_helpers.to_raw_response_wrapper( + sdk.get_environment, "extra_headers" + ) + self.delete_environment = response_helpers.to_raw_response_wrapper( + sdk.delete_environment, "extra_headers" + ) + + +class EnvironmentsWithStreamingResponse: + def __init__(self, sdk: Environments) -> None: + self._sdk = sdk + self.create_environment = response_helpers.to_streamed_response_wrapper( + sdk.create_environment, "extra_headers" + ) + self.list_environments = response_helpers.to_streamed_response_wrapper( + sdk.list_environments, "extra_headers" + ) + self.get_environment = response_helpers.to_streamed_response_wrapper( + sdk.get_environment, "extra_headers" + ) + self.delete_environment = response_helpers.to_streamed_response_wrapper( + sdk.delete_environment, "extra_headers" + ) + + +class AsyncEnvironments(AsyncBaseSDK): + @property + def with_raw_response(self): + return AsyncEnvironmentsWithRawResponse(self) + + @property + def with_streaming_response(self): + return AsyncEnvironmentsWithStreamingResponse(self) + + async def create_environment( + self, + *, + api_version: Optional[str] = None, + body: Optional[ + Union[ + environments_environment.EnvironmentInput, + environments_environment.EnvironmentInputParam, + ] + ] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + extra_body: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> environments.Environment: + r"""Creates an environment. + + :param api_version: Which version of the API to use. + :param body: Required. The environment to create. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param extra_body: Additional JSON object fields to merge into request bodies. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.CreateEnvironmentRequest( + api_version=api_version, + body=utils.get_pydantic_model( + body, Optional[environments.EnvironmentInput] + ), + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request_async( + method="POST", + path="/{api_version}/environments", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.CreateEnvironmentGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body if request is not None else None, + False, + True, + "json", + Optional[environments.EnvironmentInput], + extra_body=extra_body, + ), + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + async def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + environments.Environment, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="CreateEnvironment", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), + ) + http_res = await self.do_request_async( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + await http_res.aread() + try: + await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.AsyncStreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.AsyncAPIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + async_hooks=self.sdk_configuration.__dict__.get("_async_hooks"), + ), + ) + try: + return await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + async def list_environments( + self, + *, + api_version: Optional[str] = None, + page_size: Optional[int] = None, + page_token: Optional[str] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> environments.ListEnvironmentsResponse: + r"""Lists environments. + + :param api_version: Which version of the API to use. + :param page_size: Optional. Maximum number of environments to return.\nIf unspecified, defaults to 50. Maximum is 1000. + :param page_token: Optional. Pagination token. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.ListEnvironmentsRequest( + api_version=api_version, + page_size=page_size, + page_token=page_token, + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request_async( + method="GET", + path="/{api_version}/environments", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.ListEnvironmentsGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + async def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + environments.ListEnvironmentsResponse, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="ListEnvironments", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), + ) + http_res = await self.do_request_async( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + await http_res.aread() + try: + await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.AsyncStreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.AsyncAPIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + async_hooks=self.sdk_configuration.__dict__.get("_async_hooks"), + ), + ) + try: + return await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + async def get_environment( + self, + id: str, + *, + api_version: Optional[str] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> environments.Environment: + r"""Gets an environment. + + :param id: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. + :param api_version: Which version of the API to use. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.GetEnvironmentRequest( + api_version=api_version, + id=id, + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request_async( + method="GET", + path="/{api_version}/environments/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.GetEnvironmentGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + async def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + environments.Environment, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="GetEnvironment", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), + ) + http_res = await self.do_request_async( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + await http_res.aread() + try: + await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.AsyncStreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.AsyncAPIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + async_hooks=self.sdk_configuration.__dict__.get("_async_hooks"), + ), + ) + try: + return await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + async def delete_environment( + self, + id: str, + *, + api_version: Optional[str] = None, + extra_headers: Optional[Mapping[str, str]] = None, + extra_query: Optional[Mapping[str, Any]] = None, + timeout: Optional[Union[float, httpx.Timeout]] = None, + ) -> interactions.Empty: + r"""Deletes an environment. + + :param id: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. + :param api_version: Which version of the API to use. + :param extra_headers: Additional headers to set or replace on requests. + :param extra_query: Additional query parameters to append to requests. + :param timeout: Override the default request timeout configuration for this method in seconds + """ + base_url = None + url_variables = None + retries: OptionalNullable[utils.RetryConfig] = UNSET + server_url = None + http_headers = extra_headers + timeout_ms = self._coerce_timeout_ms(timeout) + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + else: + base_url = self._get_url(base_url, url_variables) + + request = models.DeleteEnvironmentRequest( + api_version=api_version, + id=id, + ) + + _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( + http_headers + ) + req = self._build_request_async( + method="DELETE", + path="/{api_version}/environments/{id}", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=False, + request_has_path_params=True, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + http_headers=http_headers, + extra_query_params=extra_query, + _globals=models.DeleteEnvironmentGlobals( + api_version=self.sdk_configuration.globals.api_version, + ), + security=self.sdk_configuration.security, + allow_empty_value=None, + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + else: + retries = utils.RetryConfig( + "attempt-count-backoff", + utils.BackoffStrategy(500, 8000, 2, 30000), + True, + max_retries=4, + ) + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["408", "409", "429", "5XX"]) + + async def _speakeasy_parse_response(http_res): + if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "5XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.GenAiDefaultError( + "API error occurred", http_res, http_res_text + ) + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + interactions.Empty, http_res, validate=False + ) + + raise errors.GenAiDefaultError("Unexpected response received", http_res) + + _speakeasy_hook_ctx = HookContext( + config=self.sdk_configuration, + base_url=base_url or "", + operation_id="DeleteEnvironment", + oauth2_scopes=None, + security_source=get_security_from_env( + self.sdk_configuration.security, types.Security + ), + tags=None, + extensions=None, + response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), + ) + http_res = await self.do_request_async( + hook_ctx=_speakeasy_hook_ctx, + request=req, + is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c), + stream=_speakeasy_response_mode == "streaming", + retry_config=retry_config, + ) + if _speakeasy_response_mode != "parsed": + if utils.match_status_codes(["4XX", "5XX"], http_res.status_code): + await http_res.aread() + try: + await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + _speakeasy_response_cls = ( + response_helpers.AsyncStreamedAPIResponse + if _speakeasy_response_mode == "streaming" + else response_helpers.AsyncAPIResponse + ) + return cast( + Any, + _speakeasy_response_cls( + raw=http_res, + parser=_speakeasy_parse_response, + mode="buffered", + client_ref=self, + hook_ctx=AfterParseErrorContext(_speakeasy_hook_ctx), + hooks=self.sdk_configuration.__dict__.get("_hooks"), + async_hooks=self.sdk_configuration.__dict__.get("_async_hooks"), + ), + ) + try: + return await _speakeasy_parse_response(http_res) + except Exception as parse_exc_: + await response_helpers.raise_parse_error_async( + self.sdk_configuration.__dict__.get("_async_hooks"), + self.sdk_configuration.__dict__.get("_hooks"), + AfterParseErrorContext(_speakeasy_hook_ctx), + http_res, + parse_exc_, + ) + + +class AsyncEnvironmentsWithRawResponse: + def __init__(self, sdk: AsyncEnvironments) -> None: + self._sdk = sdk + self.create_environment = response_helpers.async_to_raw_response_wrapper( + sdk.create_environment, "extra_headers" + ) + self.list_environments = response_helpers.async_to_raw_response_wrapper( + sdk.list_environments, "extra_headers" + ) + self.get_environment = response_helpers.async_to_raw_response_wrapper( + sdk.get_environment, "extra_headers" + ) + self.delete_environment = response_helpers.async_to_raw_response_wrapper( + sdk.delete_environment, "extra_headers" + ) + + +class AsyncEnvironmentsWithStreamingResponse: + def __init__(self, sdk: AsyncEnvironments) -> None: + self._sdk = sdk + self.create_environment = response_helpers.async_to_streamed_response_wrapper( + sdk.create_environment, "extra_headers" + ) + self.list_environments = response_helpers.async_to_streamed_response_wrapper( + sdk.list_environments, "extra_headers" + ) + self.get_environment = response_helpers.async_to_streamed_response_wrapper( + sdk.get_environment, "extra_headers" + ) + self.delete_environment = response_helpers.async_to_streamed_response_wrapper( + sdk.delete_environment, "extra_headers" + ) diff --git a/google/genai/_gaos/google_genai.py b/google/genai/_gaos/google_genai.py index c0552c105..a2191823a 100644 --- a/google/genai/_gaos/google_genai.py +++ b/google/genai/_gaos/google_genai.py @@ -52,6 +52,8 @@ from .triggers import Triggers as GeneratedTriggers from .webhooks import AsyncWebhooks as GeneratedAsyncWebhooks from .webhooks import Webhooks as GeneratedWebhooks +from .environments import AsyncEnvironments as GeneratedAsyncEnvironments +from .environments import Environments as GeneratedEnvironments GOOGLE_GENAI_API_REVISION = _GOOGLE_GENAI_API_REVISION @@ -759,6 +761,98 @@ async def list_executions(self, *args: Any, **kwargs: Any) -> Any: return await async_wrap_sdk_call(super().list_executions, *args, **kwargs) +class GeminiNextGenEnvironments(GeneratedEnvironments): + """Public environments resource backed by the NextGen client.""" + + def __init__(self, api_client: Any): + sdk = build_google_genai_client(api_client) + super().__init__(sdk.sdk_configuration, parent_ref=sdk) + + if not TYPE_CHECKING: + @property + def with_raw_response(self): + return _RawResponseAccessorProxy(super().with_raw_response) + + @property + def with_streaming_response(self): + return _RawResponseAccessorProxy(super().with_streaming_response) + + def create_environment(self, *args: Any, **kwargs: Any) -> Any: + return wrap_sdk_call(super().create_environment, *args, **kwargs) + + def create(self, *args: Any, **kwargs: Any) -> Any: + if 'environment' in kwargs: + kwargs['body'] = kwargs.pop('environment') + return self.create_environment(*args, **kwargs) + + def list_environments(self, *args: Any, **kwargs: Any) -> Any: + return wrap_sdk_call(super().list_environments, *args, **kwargs) + + def list(self, *args: Any, **kwargs: Any) -> Any: + return self.list_environments(*args, **kwargs) + + def get_environment(self, *args: Any, **kwargs: Any) -> Any: + return wrap_sdk_call(super().get_environment, *args, **kwargs) + + def get(self, *args: Any, **kwargs: Any) -> Any: + return self.get_environment(*args, **kwargs) + + def delete_environment(self, *args: Any, **kwargs: Any) -> Any: + return wrap_sdk_call(super().delete_environment, *args, **kwargs) + + def delete(self, *args: Any, **kwargs: Any) -> Any: + return self.delete_environment(*args, **kwargs) + + def get_environment_files(self, *args: Any, **kwargs: Any) -> Any: + return wrap_sdk_call(super().get_environment_files, *args, **kwargs) + + # NOTE: update_environment, patch_environment are handled by fallback if they exist, but we assume they aren't generated based on our openapi.json. + + +class AsyncGeminiNextGenEnvironments(GeneratedAsyncEnvironments): + """Async public environments resource backed by the NextGen client.""" + + def __init__(self, api_client: Any): + sdk = build_google_genai_async_client(api_client) + super().__init__(sdk.sdk_configuration, parent_ref=sdk) + + if not TYPE_CHECKING: + @property + def with_raw_response(self): + return _AsyncRawResponseAccessorProxy(super().with_raw_response) + + @property + def with_streaming_response(self): + return _AsyncRawResponseAccessorProxy(super().with_streaming_response) + + async def create_environment(self, *args: Any, **kwargs: Any) -> Any: + return await async_wrap_sdk_call(super().create_environment, *args, **kwargs) + + async def create(self, *args: Any, **kwargs: Any) -> Any: + return await self.create_environment(*args, **kwargs) + + async def list_environments(self, *args: Any, **kwargs: Any) -> Any: + return await async_wrap_sdk_call(super().list_environments, *args, **kwargs) + + async def list(self, *args: Any, **kwargs: Any) -> Any: + return await self.list_environments(*args, **kwargs) + + async def get_environment(self, *args: Any, **kwargs: Any) -> Any: + return await async_wrap_sdk_call(super().get_environment, *args, **kwargs) + + async def get(self, *args: Any, **kwargs: Any) -> Any: + return await self.get_environment(*args, **kwargs) + + async def delete_environment(self, *args: Any, **kwargs: Any) -> Any: + return await async_wrap_sdk_call(super().delete_environment, *args, **kwargs) + + async def delete(self, *args: Any, **kwargs: Any) -> Any: + return await self.delete_environment(*args, **kwargs) + + async def get_environment_files(self, *args: Any, **kwargs: Any) -> Any: + return await async_wrap_sdk_call(super().get_environment_files, *args, **kwargs) + + def _add_output_properties_if_interaction(value: Any) -> Any: normalized = _normalize_interaction_shape(value) if normalized is None: @@ -879,6 +973,7 @@ def _get_value(value: Any, name: str) -> Any: return value.get(name) return getattr(value, name, None) + # Allowed create() body keys, derived from the generated request models so the # set tracks the schema; output-only fields are excluded. _CREATE_BODY_KEYS = frozenset( diff --git a/google/genai/_gaos/models/__init__.py b/google/genai/_gaos/models/__init__.py index 6e3953107..024cabd61 100644 --- a/google/genai/_gaos/models/__init__.py +++ b/google/genai/_gaos/models/__init__.py @@ -33,6 +33,12 @@ CreateAgentRequest, CreateAgentRequestParam, ) + from .createenvironment import ( + CreateEnvironmentGlobals, + CreateEnvironmentGlobalsTypedDict, + CreateEnvironmentRequest, + CreateEnvironmentRequestParam, + ) from .createinteraction import ( CreateInteractionGlobals, CreateInteractionGlobalsTypedDict, @@ -61,6 +67,12 @@ DeleteAgentRequest, DeleteAgentRequestParam, ) + from .deleteenvironment import ( + DeleteEnvironmentGlobals, + DeleteEnvironmentGlobalsTypedDict, + DeleteEnvironmentRequest, + DeleteEnvironmentRequestParam, + ) from .deleteinteraction import ( DeleteInteractionGlobals, DeleteInteractionGlobalsTypedDict, @@ -85,6 +97,12 @@ GetAgentRequest, GetAgentRequestParam, ) + from .getenvironment import ( + GetEnvironmentGlobals, + GetEnvironmentGlobalsTypedDict, + GetEnvironmentRequest, + GetEnvironmentRequestParam, + ) from .getinteractionbyid import ( GetInteractionByIDGlobals, GetInteractionByIDGlobalsTypedDict, @@ -111,6 +129,12 @@ ListAgentsRequest, ListAgentsRequestParam, ) + from .listenvironments import ( + ListEnvironmentsGlobals, + ListEnvironmentsGlobalsTypedDict, + ListEnvironmentsRequest, + ListEnvironmentsRequestParam, + ) from .listtriggerexecutions import ( ListTriggerExecutionsGlobals, ListTriggerExecutionsGlobalsTypedDict, @@ -170,6 +194,10 @@ "CreateAgentGlobalsTypedDict", "CreateAgentRequest", "CreateAgentRequestParam", + "CreateEnvironmentGlobals", + "CreateEnvironmentGlobalsTypedDict", + "CreateEnvironmentRequest", + "CreateEnvironmentRequestParam", "CreateInteractionGlobals", "CreateInteractionGlobalsTypedDict", "CreateInteractionRequest", @@ -190,6 +218,10 @@ "DeleteAgentGlobalsTypedDict", "DeleteAgentRequest", "DeleteAgentRequestParam", + "DeleteEnvironmentGlobals", + "DeleteEnvironmentGlobalsTypedDict", + "DeleteEnvironmentRequest", + "DeleteEnvironmentRequestParam", "DeleteInteractionGlobals", "DeleteInteractionGlobalsTypedDict", "DeleteInteractionRequest", @@ -206,6 +238,10 @@ "GetAgentGlobalsTypedDict", "GetAgentRequest", "GetAgentRequestParam", + "GetEnvironmentGlobals", + "GetEnvironmentGlobalsTypedDict", + "GetEnvironmentRequest", + "GetEnvironmentRequestParam", "GetInteractionByIDGlobals", "GetInteractionByIDGlobalsTypedDict", "GetInteractionByIDRequest", @@ -224,6 +260,10 @@ "ListAgentsGlobalsTypedDict", "ListAgentsRequest", "ListAgentsRequestParam", + "ListEnvironmentsGlobals", + "ListEnvironmentsGlobalsTypedDict", + "ListEnvironmentsRequest", + "ListEnvironmentsRequestParam", "ListTriggerExecutionsGlobals", "ListTriggerExecutionsGlobalsTypedDict", "ListTriggerExecutionsRequest", @@ -267,6 +307,10 @@ "CreateAgentGlobalsTypedDict": ".createagent", "CreateAgentRequest": ".createagent", "CreateAgentRequestParam": ".createagent", + "CreateEnvironmentGlobals": ".createenvironment", + "CreateEnvironmentGlobalsTypedDict": ".createenvironment", + "CreateEnvironmentRequest": ".createenvironment", + "CreateEnvironmentRequestParam": ".createenvironment", "CreateInteractionGlobals": ".createinteraction", "CreateInteractionGlobalsTypedDict": ".createinteraction", "CreateInteractionRequest": ".createinteraction", @@ -287,6 +331,10 @@ "DeleteAgentGlobalsTypedDict": ".deleteagent", "DeleteAgentRequest": ".deleteagent", "DeleteAgentRequestParam": ".deleteagent", + "DeleteEnvironmentGlobals": ".deleteenvironment", + "DeleteEnvironmentGlobalsTypedDict": ".deleteenvironment", + "DeleteEnvironmentRequest": ".deleteenvironment", + "DeleteEnvironmentRequestParam": ".deleteenvironment", "DeleteInteractionGlobals": ".deleteinteraction", "DeleteInteractionGlobalsTypedDict": ".deleteinteraction", "DeleteInteractionRequest": ".deleteinteraction", @@ -303,6 +351,10 @@ "GetAgentGlobalsTypedDict": ".getagent", "GetAgentRequest": ".getagent", "GetAgentRequestParam": ".getagent", + "GetEnvironmentGlobals": ".getenvironment", + "GetEnvironmentGlobalsTypedDict": ".getenvironment", + "GetEnvironmentRequest": ".getenvironment", + "GetEnvironmentRequestParam": ".getenvironment", "GetInteractionByIDGlobals": ".getinteractionbyid", "GetInteractionByIDGlobalsTypedDict": ".getinteractionbyid", "GetInteractionByIDRequest": ".getinteractionbyid", @@ -321,6 +373,10 @@ "ListAgentsGlobalsTypedDict": ".listagents", "ListAgentsRequest": ".listagents", "ListAgentsRequestParam": ".listagents", + "ListEnvironmentsGlobals": ".listenvironments", + "ListEnvironmentsGlobalsTypedDict": ".listenvironments", + "ListEnvironmentsRequest": ".listenvironments", + "ListEnvironmentsRequestParam": ".listenvironments", "ListTriggerExecutionsGlobals": ".listtriggerexecutions", "ListTriggerExecutionsGlobalsTypedDict": ".listtriggerexecutions", "ListTriggerExecutionsRequest": ".listtriggerexecutions", diff --git a/google/genai/_gaos/models/createenvironment.py b/google/genai/_gaos/models/createenvironment.py new file mode 100644 index 000000000..dfbc3687e --- /dev/null +++ b/google/genai/_gaos/models/createenvironment.py @@ -0,0 +1,91 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from ..types import BaseModel, UNSET_SENTINEL +from ..types.environments import environment as environments_environment +from ..utils import FieldMetadata, PathParamMetadata, RequestMetadata +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class CreateEnvironmentGlobalsTypedDict(TypedDict): + api_version: NotRequired[str] + r"""Which version of the API to use.""" + + +class CreateEnvironmentGlobals(BaseModel): + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class CreateEnvironmentRequestParam(TypedDict): + api_version: NotRequired[str] + r"""Which version of the API to use.""" + body: NotRequired[environments_environment.EnvironmentInputParam] + r"""Required. The environment to create.""" + + +class CreateEnvironmentRequest(BaseModel): + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + body: Annotated[ + Optional[environments_environment.EnvironmentInput], + FieldMetadata(request=RequestMetadata(media_type="application/json")), + ] = None + r"""Required. The environment to create.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version", "body"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/google/genai/_gaos/models/deleteenvironment.py b/google/genai/_gaos/models/deleteenvironment.py new file mode 100644 index 000000000..80f4a6272 --- /dev/null +++ b/google/genai/_gaos/models/deleteenvironment.py @@ -0,0 +1,89 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from ..types import BaseModel, UNSET_SENTINEL +from ..utils import FieldMetadata, PathParamMetadata +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class DeleteEnvironmentGlobalsTypedDict(TypedDict): + api_version: NotRequired[str] + r"""Which version of the API to use.""" + + +class DeleteEnvironmentGlobals(BaseModel): + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class DeleteEnvironmentRequestParam(TypedDict): + id: str + r"""Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.""" + api_version: NotRequired[str] + r"""Which version of the API to use.""" + + +class DeleteEnvironmentRequest(BaseModel): + id: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.""" + + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/google/genai/_gaos/models/getenvironment.py b/google/genai/_gaos/models/getenvironment.py new file mode 100644 index 000000000..9afaccccf --- /dev/null +++ b/google/genai/_gaos/models/getenvironment.py @@ -0,0 +1,89 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from ..types import BaseModel, UNSET_SENTINEL +from ..utils import FieldMetadata, PathParamMetadata +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class GetEnvironmentGlobalsTypedDict(TypedDict): + api_version: NotRequired[str] + r"""Which version of the API to use.""" + + +class GetEnvironmentGlobals(BaseModel): + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class GetEnvironmentRequestParam(TypedDict): + id: str + r"""Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.""" + api_version: NotRequired[str] + r"""Which version of the API to use.""" + + +class GetEnvironmentRequest(BaseModel): + id: Annotated[ + str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + ] + r"""Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.""" + + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/google/genai/_gaos/models/listenvironments.py b/google/genai/_gaos/models/listenvironments.py new file mode 100644 index 000000000..939749aba --- /dev/null +++ b/google/genai/_gaos/models/listenvironments.py @@ -0,0 +1,98 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from ..types import BaseModel, UNSET_SENTINEL +from ..utils import FieldMetadata, PathParamMetadata, QueryParamMetadata +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class ListEnvironmentsGlobalsTypedDict(TypedDict): + api_version: NotRequired[str] + r"""Which version of the API to use.""" + + +class ListEnvironmentsGlobals(BaseModel): + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class ListEnvironmentsRequestParam(TypedDict): + api_version: NotRequired[str] + r"""Which version of the API to use.""" + page_size: NotRequired[int] + r"""Optional. Maximum number of environments to return.\nIf unspecified, defaults to 50. Maximum is 1000.""" + page_token: NotRequired[str] + r"""Optional. Pagination token.""" + + +class ListEnvironmentsRequest(BaseModel): + api_version: Annotated[ + Optional[str], + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + ] = None + r"""Which version of the API to use.""" + + page_size: Annotated[ + Optional[int], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Optional. Maximum number of environments to return.\nIf unspecified, defaults to 50. Maximum is 1000.""" + + page_token: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Optional. Pagination token.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["api_version", "page_size", "page_token"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/google/genai/_gaos/resources/__init__.py b/google/genai/_gaos/resources/__init__.py index 787000262..09f580823 100644 --- a/google/genai/_gaos/resources/__init__.py +++ b/google/genai/_gaos/resources/__init__.py @@ -17,8 +17,9 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from . import agents +from . import environments from . import interactions from . import triggers from . import webhooks -__all__ = ["agents", "interactions", "triggers", "webhooks"] +__all__ = ["agents", "environments", "interactions", "triggers", "webhooks"] diff --git a/google/genai/_gaos/resources/environments/__init__.py b/google/genai/_gaos/resources/environments/__init__.py new file mode 100644 index 000000000..e4ff3e72f --- /dev/null +++ b/google/genai/_gaos/resources/environments/__init__.py @@ -0,0 +1,31 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from ...types.environments.environment import Environment +from ...types.environments.listenvironmentsresponse import ( + ListEnvironmentsResponse as EnvironmentListResponse, +) +from ...types.interactions.empty import Empty as EnvironmentDeleteResponse +from . import environment + +__all__ = [ + "Environment", + "EnvironmentDeleteResponse", + "EnvironmentListResponse", + "environment", +] diff --git a/google/genai/_gaos/resources/environments/environment/__init__.py b/google/genai/_gaos/resources/environments/environment/__init__.py new file mode 100644 index 000000000..e59659f56 --- /dev/null +++ b/google/genai/_gaos/resources/environments/environment/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from ....types.interactions.environmentnetworkegressallowlist import Allowlist + +__all__ = ["Allowlist"] diff --git a/google/genai/_gaos/sdk.py b/google/genai/_gaos/sdk.py index 57562e585..06fd8e874 100644 --- a/google/genai/_gaos/sdk.py +++ b/google/genai/_gaos/sdk.py @@ -39,6 +39,7 @@ if TYPE_CHECKING: from .agents import Agents, AsyncAgents + from .environments import AsyncEnvironments, Environments from .interactions import AsyncInteractions, Interactions from .triggers import AsyncTriggers, Triggers from .webhooks import AsyncWebhooks, Webhooks @@ -59,11 +60,13 @@ def with_streaming_response(self): webhooks: "Webhooks" agents: "Agents" triggers: "Triggers" + environments: "Environments" _sub_sdk_map = { "interactions": (".interactions", "Interactions"), "webhooks": (".webhooks", "Webhooks"), "agents": (".agents", "Agents"), "triggers": (".triggers", "Triggers"), + "environments": (".environments", "Environments"), } def __init__( @@ -223,6 +226,10 @@ def agents(self): def triggers(self): return self._sdk.triggers.with_raw_response + @property + def environments(self): + return self._sdk.environments.with_raw_response + class GenAIWithStreamingResponse: def __init__(self, sdk: GenAI) -> None: @@ -244,6 +251,10 @@ def agents(self): def triggers(self): return self._sdk.triggers.with_streaming_response + @property + def environments(self): + return self._sdk.environments.with_streaming_response + class AsyncGenAI(AsyncBaseSDK): r"""Gemini API: The Gemini Interactions API allows developers to build generative AI applications using Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can generalize and seamlessly understand, operate across, and combine different types of information including language, images, audio, video, and code. You can use the Gemini API for use cases like reasoning across text and images, content generation, dialogue agents, summarization and classification systems, and more.""" @@ -260,11 +271,13 @@ def with_streaming_response(self): webhooks: "AsyncWebhooks" agents: "AsyncAgents" triggers: "AsyncTriggers" + environments: "AsyncEnvironments" _sub_sdk_map = { "interactions": (".interactions", "AsyncInteractions"), "webhooks": (".webhooks", "AsyncWebhooks"), "agents": (".agents", "AsyncAgents"), "triggers": (".triggers", "AsyncTriggers"), + "environments": (".environments", "AsyncEnvironments"), } def __init__( @@ -422,6 +435,10 @@ def agents(self): def triggers(self): return self._sdk.triggers.with_raw_response + @property + def environments(self): + return self._sdk.environments.with_raw_response + class AsyncGenAIWithStreamingResponse: def __init__(self, sdk: AsyncGenAI) -> None: @@ -442,3 +459,7 @@ def agents(self): @property def triggers(self): return self._sdk.triggers.with_streaming_response + + @property + def environments(self): + return self._sdk.environments.with_streaming_response diff --git a/google/genai/_gaos/types/__init__.py b/google/genai/_gaos/types/__init__.py index cc3a48953..7ef0921ca 100644 --- a/google/genai/_gaos/types/__init__.py +++ b/google/genai/_gaos/types/__init__.py @@ -32,7 +32,7 @@ if TYPE_CHECKING: from .security import Security, SecurityTypedDict - from . import agents, interactions, triggers, webhooks + from . import agents, environments, interactions, triggers, webhooks __all__ = [ "Base64EncodedString", @@ -53,7 +53,7 @@ "SecurityTypedDict": ".security", } -_sub_packages = ["agents", "interactions", "triggers", "webhooks"] +_sub_packages = ["agents", "environments", "interactions", "triggers", "webhooks"] def __getattr__(attr_name: str) -> Any: diff --git a/google/genai/_gaos/types/environments/__init__.py b/google/genai/_gaos/types/environments/__init__.py new file mode 100644 index 000000000..50fb6142e --- /dev/null +++ b/google/genai/_gaos/types/environments/__init__.py @@ -0,0 +1,73 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import Any, TYPE_CHECKING + +from ...utils.dynamic_imports import lazy_getattr, lazy_dir + +if TYPE_CHECKING: + from .environment import ( + Environment, + EnvironmentInput, + EnvironmentInputParam, + EnvironmentTypedDict, + Network, + NetworkEnum, + NetworkParam, + Status, + ) + from .listenvironmentsresponse import ( + ListEnvironmentsResponse, + ListEnvironmentsResponseTypedDict, + ) + +__all__ = [ + "Environment", + "EnvironmentInput", + "EnvironmentInputParam", + "EnvironmentTypedDict", + "ListEnvironmentsResponse", + "ListEnvironmentsResponseTypedDict", + "Network", + "NetworkEnum", + "NetworkParam", + "Status", +] + +_dynamic_imports: dict[str, str] = { + "Environment": ".environment", + "EnvironmentInput": ".environment", + "EnvironmentInputParam": ".environment", + "EnvironmentTypedDict": ".environment", + "Network": ".environment", + "NetworkEnum": ".environment", + "NetworkParam": ".environment", + "Status": ".environment", + "ListEnvironmentsResponse": ".listenvironmentsresponse", + "ListEnvironmentsResponseTypedDict": ".listenvironmentsresponse", +} + + +def __getattr__(attr_name: str) -> Any: + return lazy_getattr( + attr_name, package=__package__, dynamic_imports=_dynamic_imports + ) + + +def __dir__(): + return lazy_dir(dynamic_imports=_dynamic_imports) diff --git a/google/genai/_gaos/types/environments/environment.py b/google/genai/_gaos/types/environments/environment.py new file mode 100644 index 000000000..f8f6391d7 --- /dev/null +++ b/google/genai/_gaos/types/environments/environment.py @@ -0,0 +1,199 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr +from ...utils import serialize_int, validate_int +from ..interactions import ( + environmentnetworkegressallowlist as interactions_environmentnetworkegressallowlist, + source as interactions_source, +) +from pydantic import model_serializer +from pydantic.functional_serializers import PlainSerializer +from pydantic.functional_validators import BeforeValidator +from typing import List, Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict + + +NetworkEnum = Literal["disabled",] + + +NetworkParam = TypeAliasType( + "NetworkParam", + Union[ + interactions_environmentnetworkegressallowlist.EnvironmentNetworkEgressAllowlistParam, + NetworkEnum, + ], +) +r"""Network configuration for the environment.""" + + +Network = TypeAliasType( + "Network", + Union[ + interactions_environmentnetworkegressallowlist.EnvironmentNetworkEgressAllowlist, + NetworkEnum, + ], +) +r"""Network configuration for the environment.""" + + +Status = Union[ + Literal[ + "active", + "expired", + ], + UnrecognizedStr, +] +r"""Output only. The status of the environment container.""" + + +class EnvironmentTypedDict(TypedDict): + r"""An execution environment for an agent.""" + + id: str + r"""Required. Output only. The ID of the environment.""" + created: NotRequired[str] + r"""Output only. The time at which the environment was created in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ + file_count: NotRequired[int] + r"""Output only. The number of files in the environment, output only.""" + last_accessed: NotRequired[str] + r"""Output only. The time at which the environment was last accessed in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ + network: NotRequired[NetworkParam] + r"""Network configuration for the environment.""" + size_bytes: NotRequired[int] + r"""Output only. The total size of the environment files in bytes, output only.""" + sources: NotRequired[List[interactions_source.SourceParam]] + r"""Sources to be mounted into the environment.""" + status: NotRequired[Status] + r"""Output only. The status of the environment container.""" + updated: NotRequired[str] + r"""Output only. The time at which the environment was last updated in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ + + +class Environment(BaseModel): + r"""An execution environment for an agent.""" + + id: str + r"""Required. Output only. The ID of the environment.""" + + created: Optional[str] = None + r"""Output only. The time at which the environment was created in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ + + file_count: Annotated[ + Optional[int], + BeforeValidator(validate_int), + PlainSerializer(serialize_int(True)), + ] = None + r"""Output only. The number of files in the environment, output only.""" + + last_accessed: Optional[str] = None + r"""Output only. The time at which the environment was last accessed in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ + + network: Optional[Network] = None + r"""Network configuration for the environment.""" + + size_bytes: Annotated[ + Optional[int], + BeforeValidator(validate_int), + PlainSerializer(serialize_int(True)), + ] = None + r"""Output only. The total size of the environment files in bytes, output only.""" + + sources: Optional[List[interactions_source.Source]] = None + r"""Sources to be mounted into the environment.""" + + status: Optional[Status] = None + r"""Output only. The status of the environment container.""" + + updated: Optional[str] = None + r"""Output only. The time at which the environment was last updated in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "created", + "file_count", + "last_accessed", + "network", + "size_bytes", + "sources", + "status", + "updated", + ] + ) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m + + +class EnvironmentInputParam(TypedDict): + r"""An execution environment for an agent.""" + + network: NotRequired[NetworkParam] + r"""Network configuration for the environment.""" + sources: NotRequired[List[interactions_source.SourceParam]] + r"""Sources to be mounted into the environment.""" + + +class EnvironmentInput(BaseModel): + r"""An execution environment for an agent.""" + + network: Optional[Network] = None + r"""Network configuration for the environment.""" + + sources: Optional[List[interactions_source.Source]] = None + r"""Sources to be mounted into the environment.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["network", "sources"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/google/genai/_gaos/types/environments/listenvironmentsresponse.py b/google/genai/_gaos/types/environments/listenvironmentsresponse.py new file mode 100644 index 000000000..fa2c1f719 --- /dev/null +++ b/google/genai/_gaos/types/environments/listenvironmentsresponse.py @@ -0,0 +1,59 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .. import BaseModel, UNSET_SENTINEL +from .environment import Environment, EnvironmentTypedDict +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class ListEnvironmentsResponseTypedDict(TypedDict): + r"""Response for `ListEnvironments`.""" + + environments: NotRequired[List[EnvironmentTypedDict]] + r"""Environments belonging to the provided project.""" + next_page_token: NotRequired[str] + r"""Pagination token.""" + + +class ListEnvironmentsResponse(BaseModel): + r"""Response for `ListEnvironments`.""" + + environments: Optional[List[Environment]] = None + r"""Environments belonging to the provided project.""" + + next_page_token: Optional[str] = None + r"""Pagination token.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["environments", "next_page_token"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m