From 946e70d9666ee016b9bfa208ba0f2ca5b36280f2 Mon Sep 17 00:00:00 2001 From: Ivan Lopez Hernandez Date: Mon, 20 Jul 2026 16:04:06 -0700 Subject: [PATCH] chore: OAD cleanup. PiperOrigin-RevId: 951104945 --- .../genai/_gaos/_hooks/google_genai_auth.py | 11 + google/genai/_gaos/agents.py | 842 +++++----- google/genai/_gaos/environments.py | 566 ++++--- google/genai/_gaos/errors/__init__.py | 308 ++++ .../_gaos/errors/cancelinteractionbyid.py | 4 +- google/genai/_gaos/errors/createagent.py | 71 + .../genai/_gaos/errors/createenvironment.py | 71 + .../genai/_gaos/errors/createinteraction.py | 4 +- google/genai/_gaos/errors/createtrigger.py | 71 + google/genai/_gaos/errors/createwebhook.py | 71 + google/genai/_gaos/errors/deleteagent.py | 71 + .../genai/_gaos/errors/deleteenvironment.py | 71 + .../genai/_gaos/errors/deleteinteraction.py | 4 +- google/genai/_gaos/errors/deletetrigger.py | 71 + google/genai/_gaos/errors/deletewebhook.py | 71 + google/genai/_gaos/errors/getagent.py | 71 + google/genai/_gaos/errors/getenvironment.py | 71 + .../genai/_gaos/errors/getinteractionbyid.py | 4 +- google/genai/_gaos/errors/gettrigger.py | 71 + google/genai/_gaos/errors/getwebhook.py | 71 + google/genai/_gaos/errors/listagents.py | 71 + google/genai/_gaos/errors/listenvironments.py | 71 + .../_gaos/errors/listtriggerexecutions.py | 71 + google/genai/_gaos/errors/listtriggers.py | 71 + google/genai/_gaos/errors/listwebhooks.py | 71 + google/genai/_gaos/errors/pingwebhook.py | 71 + .../genai/_gaos/errors/rotatesigningsecret.py | 71 + google/genai/_gaos/errors/runtrigger.py | 71 + google/genai/_gaos/errors/updatetrigger.py | 71 + google/genai/_gaos/errors/updatewebhook.py | 71 + google/genai/_gaos/google_genai.py | 166 +- google/genai/_gaos/interactions.py | 1361 ++++++----------- google/genai/_gaos/lib/compat_errors.py | 26 +- google/genai/_gaos/models/__init__.py | 29 +- .../_gaos/models/cancelinteractionbyid.py | 41 +- google/genai/_gaos/models/createagent.py | 23 +- .../genai/_gaos/models/createenvironment.py | 46 +- .../genai/_gaos/models/createinteraction.py | 65 +- google/genai/_gaos/models/createtrigger.py | 33 +- google/genai/_gaos/models/createwebhook.py | 44 +- google/genai/_gaos/models/deleteagent.py | 35 +- .../genai/_gaos/models/deleteenvironment.py | 32 +- .../genai/_gaos/models/deleteinteraction.py | 41 +- google/genai/_gaos/models/deletetrigger.py | 32 +- google/genai/_gaos/models/deletewebhook.py | 28 +- google/genai/_gaos/models/getagent.py | 35 +- google/genai/_gaos/models/getenvironment.py | 32 +- .../genai/_gaos/models/getinteractionbyid.py | 57 +- google/genai/_gaos/models/gettrigger.py | 32 +- google/genai/_gaos/models/getwebhook.py | 28 +- google/genai/_gaos/models/internal/globals.py | 15 +- google/genai/_gaos/models/listagents.py | 14 +- google/genai/_gaos/models/listenvironments.py | 26 +- .../_gaos/models/listtriggerexecutions.py | 34 +- google/genai/_gaos/models/listtriggers.py | 46 +- google/genai/_gaos/models/listwebhooks.py | 22 +- google/genai/_gaos/models/pingwebhook.py | 26 +- .../genai/_gaos/models/rotatesigningsecret.py | 26 +- google/genai/_gaos/models/runtrigger.py | 37 +- google/genai/_gaos/models/updatetrigger.py | 34 +- google/genai/_gaos/models/updatewebhook.py | 22 +- .../_gaos/resources/environments/__init__.py | 10 +- .../_gaos/resources/interactions/__init__.py | 24 +- .../interactions/environment/__init__.py | 2 +- .../interactions/errorevent/__init__.py | 3 +- .../generationconfig}/__init__.py | 4 +- .../interactioncompletedevent}/__init__.py | 4 +- .../interactioncreatedevent/__init__.py | 21 + .../interactionstatusupdate/__init__.py | 21 + .../retrievalcallstep/__init__.py | 23 + .../interactions/stepdelta/__init__.py | 6 +- .../interactions/stepstart/__init__.py | 21 + .../interactions/stepstop/__init__.py | 21 + .../urlcontextcallstep/__init__.py | 4 +- .../urlcontextresultstep/__init__.py | 2 +- .../_gaos/resources/webhooks/__init__.py | 4 +- google/genai/_gaos/sdk.py | 98 +- google/genai/_gaos/triggers.py | 1184 ++++++++------ .../_gaos/types/interactions/__init__.py | 130 +- .../_gaos/types/interactions/allowlist.py | 54 + .../types/interactions/allowlistentry.py | 26 +- .../_gaos/types/interactions/arguments.py | 53 + .../_gaos/types/interactions/audiodelta.py | 22 +- .../interactions/codeexecutioncalldelta.py | 7 +- .../interactions/codeexecutionresultdelta.py | 7 +- .../genai/_gaos/types/interactions/content.py | 8 +- .../interactions/createagentinteraction.py | 195 +-- .../interactions/createinteractionrequest.py | 36 + .../interactions/createmodelinteraction.py | 161 +- .../environmentnetworkegressallowlist.py | 38 +- .../_gaos/types/interactions/errorevent.py | 8 +- .../types/interactions/filesearchcalldelta.py | 7 +- .../interactions/filesearchresultdelta.py | 7 +- .../types/interactions/functioncallstep.py | 28 +- .../types/interactions/functionresultdelta.py | 7 +- .../types/interactions/functionresultstep.py | 9 +- .../types/interactions/generationconfig.py | 68 +- .../types/interactions/googlemapscalldelta.py | 7 +- .../interactions/googlemapsresultdelta.py | 7 +- .../interactions/googlesearchcalldelta.py | 7 +- .../interactions/googlesearchresultdelta.py | 7 +- .../_gaos/types/interactions/harmcategory.py | 1 - .../_gaos/types/interactions/interaction.py | 294 ++-- .../interactions/interactioncompletedevent.py | 18 +- .../interactions/interactioncreatedevent.py | 18 +- .../types/interactions/interactionsinput.py | 5 +- .../types/interactions/interactionsseevent.py | 18 +- .../interactionsseeventinteraction.py | 44 +- .../interactions/interactionstatusupdate.py | 8 +- .../interactions/localenvironmentconfig.py | 72 + .../interactions/mcpservertoolcalldelta.py | 33 +- .../interactions/mcpservertoolcallstep.py | 28 +- .../interactions/mcpservertoolresultdelta.py | 12 +- .../interactions/mcpservertoolresultstep.py | 13 +- .../genai/_gaos/types/interactions/model.py | 2 - .../types/interactions/modeloutputstep.py | 16 +- .../types/interactions/ragretrievalconfig.py | 4 +- .../genai/_gaos/types/interactions/ranking.py | 36 +- .../_gaos/types/interactions/rankservice.py | 53 + .../_gaos/types/interactions/retrieval.py | 20 +- .../interactions/retrievalcallarguments.py | 2 +- .../types/interactions/retrievalcalldelta.py | 7 +- .../types/interactions/retrievalcallstep.py | 110 ++ .../types/interactions/retrievalresultstep.py | 87 ++ .../_gaos/types/interactions/retrievaltype.py | 33 + google/genai/_gaos/types/interactions/step.py | 70 +- .../_gaos/types/interactions/stepdeltadata.py | 24 +- .../_gaos/types/interactions/stepstart.py | 8 +- .../_gaos/types/interactions/stepstop.py | 8 +- .../types/interactions/streammetadata.py | 54 + .../types/interactions/textannotationdelta.py | 36 +- .../types/interactions/transcriptionconfig.py | 22 +- google/genai/_gaos/types/interactions/turn.py | 69 + .../interactions/urlcontextcallarguments.py | 2 +- .../types/interactions/urlcontextcalldelta.py | 11 +- .../types/interactions/urlcontextcallstep.py | 9 +- .../types/interactions/urlcontextresult.py | 2 +- .../interactions/urlcontextresultdelta.py | 11 +- .../interactions/urlcontextresultitem.py | 70 + .../interactions/urlcontextresultstep.py | 6 +- .../_gaos/types/interactions/userinputstep.py | 16 +- google/genai/_gaos/types/security.py | 28 +- .../types/triggers/triggercreateparams.py | 34 +- google/genai/_gaos/utils/security.py | 6 +- google/genai/_gaos/webhooks.py | 1198 ++++++++------- 145 files changed, 6683 insertions(+), 4079 deletions(-) create mode 100644 google/genai/_gaos/errors/createagent.py create mode 100644 google/genai/_gaos/errors/createenvironment.py create mode 100644 google/genai/_gaos/errors/createtrigger.py create mode 100644 google/genai/_gaos/errors/createwebhook.py create mode 100644 google/genai/_gaos/errors/deleteagent.py create mode 100644 google/genai/_gaos/errors/deleteenvironment.py create mode 100644 google/genai/_gaos/errors/deletetrigger.py create mode 100644 google/genai/_gaos/errors/deletewebhook.py create mode 100644 google/genai/_gaos/errors/getagent.py create mode 100644 google/genai/_gaos/errors/getenvironment.py create mode 100644 google/genai/_gaos/errors/gettrigger.py create mode 100644 google/genai/_gaos/errors/getwebhook.py create mode 100644 google/genai/_gaos/errors/listagents.py create mode 100644 google/genai/_gaos/errors/listenvironments.py create mode 100644 google/genai/_gaos/errors/listtriggerexecutions.py create mode 100644 google/genai/_gaos/errors/listtriggers.py create mode 100644 google/genai/_gaos/errors/listwebhooks.py create mode 100644 google/genai/_gaos/errors/pingwebhook.py create mode 100644 google/genai/_gaos/errors/rotatesigningsecret.py create mode 100644 google/genai/_gaos/errors/runtrigger.py create mode 100644 google/genai/_gaos/errors/updatetrigger.py create mode 100644 google/genai/_gaos/errors/updatewebhook.py rename google/genai/_gaos/resources/{environments/createenvironmentrequest => interactions/generationconfig}/__init__.py (86%) rename google/genai/_gaos/resources/{environments/environment => interactions/interactioncompletedevent}/__init__.py (86%) create mode 100644 google/genai/_gaos/resources/interactions/interactioncreatedevent/__init__.py create mode 100644 google/genai/_gaos/resources/interactions/interactionstatusupdate/__init__.py create mode 100644 google/genai/_gaos/resources/interactions/retrievalcallstep/__init__.py create mode 100644 google/genai/_gaos/resources/interactions/stepstart/__init__.py create mode 100644 google/genai/_gaos/resources/interactions/stepstop/__init__.py create mode 100644 google/genai/_gaos/types/interactions/allowlist.py create mode 100644 google/genai/_gaos/types/interactions/arguments.py create mode 100644 google/genai/_gaos/types/interactions/createinteractionrequest.py create mode 100644 google/genai/_gaos/types/interactions/localenvironmentconfig.py create mode 100644 google/genai/_gaos/types/interactions/rankservice.py create mode 100644 google/genai/_gaos/types/interactions/retrievalcallstep.py create mode 100644 google/genai/_gaos/types/interactions/retrievalresultstep.py create mode 100644 google/genai/_gaos/types/interactions/retrievaltype.py create mode 100644 google/genai/_gaos/types/interactions/streammetadata.py create mode 100644 google/genai/_gaos/types/interactions/turn.py create mode 100644 google/genai/_gaos/types/interactions/urlcontextresultitem.py diff --git a/google/genai/_gaos/_hooks/google_genai_auth.py b/google/genai/_gaos/_hooks/google_genai_auth.py index 64687f78d..9230c1bde 100644 --- a/google/genai/_gaos/_hooks/google_genai_auth.py +++ b/google/genai/_gaos/_hooks/google_genai_auth.py @@ -67,6 +67,7 @@ def before_request( security = _resolve_security(hook_ctx.security_source) _apply_default_headers(security, request) + _apply_api_revision(hook_ctx, request) _apply_user_project(hook_ctx, request) _apply_auth(security, request) @@ -105,6 +106,16 @@ def _apply_default_headers( +def _apply_api_revision( + hook_ctx: BeforeRequestContext, request: httpx.Request +) -> None: + if request.headers.get("Api-Revision") is not None: + return + + api_revision = hook_ctx.config.globals.api_revision + request.headers["Api-Revision"] = api_revision or GOOGLE_GENAI_API_REVISION + + def _apply_user_project( hook_ctx: BeforeRequestContext, request: httpx.Request ) -> None: diff --git a/google/genai/_gaos/agents.py b/google/genai/_gaos/agents.py index 425ff97a8..53763b0f3 100644 --- a/google/genai/_gaos/agents.py +++ b/google/genai/_gaos/agents.py @@ -36,44 +36,23 @@ def with_raw_response(self): def with_streaming_response(self): return AgentsWithStreamingResponse(self) - def create( + def list( self, *, - api_version: Optional[str] = None, - agent_config: Optional[ - Union[agents_agent.AgentConfig, agents_agent.AgentConfigParam] - ] = None, - base_agent: Optional[str] = None, - base_environment: Optional[ - Union[agents_agent.BaseEnvironment, agents_agent.BaseEnvironmentParam] - ] = None, - description: Optional[str] = None, - id: Optional[str] = None, - system_instruction: Optional[str] = None, - tools: Optional[ - Union[ - Iterable[agents_agenttool.AgentTool], - Iterable[agents_agenttool.AgentToolParam], - ] - ] = None, + page_size: Optional[int] = None, + page_token: Optional[str] = None, + parent: Optional[str] = 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, - ) -> agents.Agent: - r"""Creates a new Agent (Typed version for SDK). + ) -> agents.AgentListResponse: + r"""Lists agents. - :param api_version: Which version of the API to use. - :param agent_config: Configuration parameters for the agent. - :param base_agent: The base agent to extend. - :param base_environment: The environment configuration for the agent. - :param description: Agent description for developers to quickly read and understand. - :param id: The unique identifier for the agent. - :param system_instruction: System instruction for the agent. - :param tools: The tools available to the agent. + :param page_size: + :param page_token: + :param parent: :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 @@ -90,46 +69,32 @@ def create( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateAgentRequest( - api_version=api_version, - body=agents.Agent( - agent_config=utils.get_pydantic_model( - agent_config, Optional[agents.AgentConfig] - ), - base_agent=base_agent, - base_environment=utils.get_pydantic_model( - base_environment, Optional[agents.BaseEnvironment] - ), - description=description, - id=id, - system_instruction=system_instruction, - tools=utils.get_pydantic_model(tools, Optional[List[agents.AgentTool]]), - ), + request = models.ListAgentsRequest( + page_size=page_size, + page_token=page_token, + parent=parent, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="POST", + method="GET", path="/{api_version}/agents", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.CreateAgentGlobals( + _globals=models.ListAgentsGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, False, False, "json", agents.Agent, extra_body=extra_body - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -150,79 +115,48 @@ def create( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListAgentsClientErrorData, http_res + ) + raise errors.ListAgentsClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListAgentsServerErrorData, http_res + ) + raise errors.ListAgentsServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): - return unmarshal_json_response(agents.Agent, http_res, validate=False) + return unmarshal_json_response( + agents.AgentListResponse, 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="CreateAgent", + operation_id="ListAgents", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "create", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "id": "research-assistant-abc123",\n "base_agent": "antigravity-preview-05-2026",\n "description": "A helpful research assistant.",\n "system_instruction": "You are a helpful research assistant.",\n "base_environment": "remote",\n "tools": [{"type": "google_search"}]\n }\'\n', - }, - { - "label": "create", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\nagent = client.agents.create(\n id=f"research-assistant-{uuid.uuid4().hex[:8]}",\n base_agent="antigravity-preview-05-2026",\n description="A helpful research assistant.",\n system_instruction="You are a helpful research assistant.",\n base_environment="remote",\n tools=[{"type": "google_search"}],\n)\nprint(agent.id)\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "create", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst agentId = `research-assistant-${crypto.randomUUID().slice(0, 8)}`;\nconst agent = await ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n description: 'A helpful research assistant.',\n system_instruction: 'You are a helpful research assistant.',\n base_environment: 'remote',\n tools: [{ type: 'google_search' }],\n});\nif (!agent.id) {\n throw new Error('Agent creation failed: ID is undefined');\n}\nconsole.log(agent.id);\n\n// [cleanup]\nawait ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - { - "label": "with_sources", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "id": "data-analyst-abc123",\n "base_agent": "antigravity-preview-05-2026",\n "system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",\n "base_environment": {\n "type": "remote",\n "sources": [\n {\n "type": "inline",\n "target": ".agents/AGENTS.md",\n "content": "Always use matplotlib for charts. Include a summary table in every report."\n },\n {\n "type": "repository",\n "source": "https://github.com/my-org/analysis-templates",\n "target": "/workspace/templates"\n }\n ]\n }\n }\'\n', - }, - { - "label": "with_sources", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\nagent = client.agents.create(\n id=f"data-analyst-{uuid.uuid4().hex[:8]}",\n base_agent="antigravity-preview-05-2026",\n system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",\n base_environment={\n "type": "remote",\n "sources": [\n {\n "type": "inline",\n "target": ".agents/AGENTS.md",\n "content": "Always use matplotlib for charts. Include a summary table in every report.",\n },\n {\n "type": "repository",\n "source": "https://github.com/my-org/analysis-templates",\n "target": "/workspace/templates",\n },\n ],\n },\n)\nprint(f"Created agent: {agent.id}")\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "with_sources", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst agentId = `data-analyst-${crypto.randomUUID().slice(0, 8)}`;\nconst agent = await ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n system_instruction: 'You are a data analyst. Always include visualizations and export results as PDF.',\n base_environment: {\n type: 'remote',\n sources: [\n {\n type: 'inline',\n target: '.agents/AGENTS.md',\n content: 'Always use matplotlib for charts. Include a summary table in every report.',\n },\n {\n type: 'repository',\n source: 'https://github.com/my-org/analysis-templates',\n target: '/workspace/templates',\n },\n ],\n },\n});\nconsole.log(`Created agent: ${agent.id}`);\n\n// [cleanup]\nif (agent.id) await ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - { - "label": "fork_from_env", - "lang": "sh", - "source": '# Step 1: Set up the environment interactively\nRESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "Write a basic Hello World template to /workspace/template.py.",\n "environment": "remote"\n }\')\nENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)[\'environment_id\'])")\n\n# Step 2: Fork that environment into a named agent\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{\n \\"id\\": \\"my-data-analyst\\",\n \\"base_agent\\": \\"antigravity-preview-05-2026\\",\n \\"system_instruction\\": \\"You are a data analyst. Use the template at /workspace/template.py for all reports.\\",\n \\"base_environment\\": \\"$ENV_ID\\"\n }"\n', - }, - { - "label": "fork_from_env", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Step 1: Set up the environment interactively.\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Write a basic Hello World template to /workspace/template.py.",\n environment="remote",\n)\n\n# Step 2: Fork that environment into a named agent.\nagent_id = f"my-data-analyst-{uuid.uuid4().hex[:8]}"\nagent = client.agents.create(\n id=agent_id,\n base_agent="antigravity-preview-05-2026",\n system_instruction="You are a data analyst. Use the template at /workspace/template.py for all reports.",\n base_environment=interaction.environment_id,\n)\nprint(f"Forked agent: {agent.id}")\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "fork_from_env", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Step 1: Set up the environment interactively.\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Write a basic Hello World template to /workspace/template.py.',\n environment: 'remote',\n});\n\n// Step 2: Fork that environment into a named agent.\nconst agentId = `my-data-analyst-${crypto.randomUUID().slice(0, 8)}`;\nconst agent = await ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n system_instruction: 'You are a data analyst. Use the template at /workspace/template.py for all reports.',\n base_environment: interaction.environment_id,\n});\nconsole.log(`Forked agent: ${agent.id}`);\n\n// [cleanup]\nif (agent.id) await ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -270,25 +204,44 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def list( + def create( self, *, - api_version: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, parent: Optional[str] = None, + agent_config: Optional[ + Union[agents_agent.AgentConfig, agents_agent.AgentConfigParam] + ] = None, + base_agent: Optional[str] = None, + base_environment: Optional[ + Union[agents_agent.BaseEnvironment, agents_agent.BaseEnvironmentParam] + ] = None, + description: Optional[str] = None, + id: Optional[str] = None, + system_instruction: Optional[str] = None, + tools: Optional[ + Union[ + Iterable[agents_agenttool.AgentTool], + Iterable[agents_agenttool.AgentToolParam], + ] + ] = 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, - ) -> agents.AgentListResponse: - r"""Lists all Agents. + ) -> agents.Agent: + r"""Creates or updates an agent (upsert by name). - :param api_version: Which version of the API to use. - :param page_size: - :param page_token: :param parent: + :param agent_config: Configuration parameters for the agent. + :param base_agent: The base agent to extend. + :param base_environment: The environment configuration for the agent. + :param description: Agent description for developers to quickly read and understand. + :param id: The unique identifier for the agent. + :param system_instruction: System instruction for the agent. + :param tools: The tools available to the agent. :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 @@ -305,33 +258,46 @@ def list( else: base_url = self._get_url(base_url, url_variables) - request = models.ListAgentsRequest( - api_version=api_version, - page_size=page_size, - page_token=page_token, + request = models.CreateAgentRequest( parent=parent, + body=agents.Agent( + agent_config=utils.get_pydantic_model( + agent_config, Optional[agents.AgentConfig] + ), + base_agent=base_agent, + base_environment=utils.get_pydantic_model( + base_environment, Optional[agents.BaseEnvironment] + ), + description=description, + id=id, + system_instruction=system_instruction, + tools=utils.get_pydantic_model(tools, Optional[List[agents.AgentTool]]), + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="GET", + method="POST", path="/{api_version}/agents", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.ListAgentsGlobals( + _globals=models.CreateAgentGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body, False, False, "json", agents.Agent, extra_body=extra_body + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -352,51 +318,46 @@ def list( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateAgentClientErrorData, http_res + ) + raise errors.CreateAgentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateAgentServerErrorData, http_res + ) + raise errors.CreateAgentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): - return unmarshal_json_response( - agents.AgentListResponse, http_res, validate=False - ) + return unmarshal_json_response(agents.Agent, 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="ListAgents", + operation_id="CreateAgent", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "list", - "lang": "sh", - "source": 'curl -X GET https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "list", - "lang": "python", - "source": "from google import genai\n\nclient = genai.Client()\nresponse = client.agents.list()\nfor agent in response.agents or []:\n print(agent.id)\n", - }, - { - "label": "list", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst agents = await ai.agents.list();\nfor (const agent of (agents.agents ?? [])) {\n console.log(agent.id);\n}\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -448,15 +409,13 @@ def get( 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, ) -> agents.Agent: - r"""Gets a specific Agent. + r"""Gets an agent (latest version). - :param id: - :param api_version: Which version of the API to use. + :param id: Part of `name`. :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 @@ -476,7 +435,6 @@ def get( base_url = self._get_url(base_url, url_variables) request = models.GetAgentRequest( - api_version=api_version, id=id, ) @@ -485,7 +443,7 @@ def get( ) req = self._build_request( method="GET", - path="/{api_version}/agents/{id}", + path="/{api_version}/agents/{agentsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -520,16 +478,31 @@ def get( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetAgentClientErrorData, http_res + ) + raise errors.GetAgentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetAgentServerErrorData, http_res + ) + raise errors.GetAgentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response(agents.Agent, http_res, validate=False) @@ -544,25 +517,7 @@ def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "get", - "lang": "sh", - "source": 'curl -X GET https://generativelanguage.googleapis.com/v1beta/agents/ag_abc123 \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "get", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Create an agent so we have a valid ID to retrieve.\nagent_id = f"test-agent-{uuid.uuid4().hex[:8]}"\nclient.agents.create(\n id=agent_id,\n base_agent="waverunner",\n description="A test agent.",\n base_environment="remote",\n)\n\nagent = client.agents.get(agent_id)\nprint(agent.id)\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "get", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Create an agent so we have a valid ID to retrieve.\nconst agentId = `test-agent-${crypto.randomUUID().slice(0, 8)}`;\nawait ai.agents.create({\n id: agentId,\n base_agent: 'waverunner',\n description: 'A test agent.',\n base_environment: 'remote',\n});\n\nconst agent = await ai.agents.get(agentId);\nif (!agent.id) {\n throw new Error('Agent retrieval failed: ID is undefined');\n}\nconsole.log(agent.id);\n\n// [cleanup]\nawait ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -614,15 +569,13 @@ def delete( 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 Agent. + r"""Deletes an agent and all its versions. - :param id: - :param api_version: Which version of the API to use. + :param id: Part of `name`. :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 @@ -642,7 +595,6 @@ def delete( base_url = self._get_url(base_url, url_variables) request = models.DeleteAgentRequest( - api_version=api_version, id=id, ) @@ -651,7 +603,7 @@ def delete( ) req = self._build_request( method="DELETE", - path="/{api_version}/agents/{id}", + path="/{api_version}/agents/{agentsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -686,16 +638,31 @@ def delete( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteAgentClientErrorData, http_res + ) + raise errors.DeleteAgentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteAgentServerErrorData, http_res + ) + raise errors.DeleteAgentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( interactions.Empty, http_res, validate=False @@ -712,25 +679,7 @@ def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "delete", - "lang": "sh", - "source": 'curl -X DELETE https://generativelanguage.googleapis.com/v1beta/agents/ag_abc123 \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "delete", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Create an agent so we have a valid ID to delete.\nagent_id = f"delete-test-{uuid.uuid4().hex[:8]}"\nclient.agents.create(\n id=agent_id,\n base_agent="waverunner",\n description="Temporary agent for deletion.",\n base_environment="remote",\n)\n\nclient.agents.delete(agent_id)\nprint("Agent deleted successfully.")\n', - }, - { - "label": "delete", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Create an agent so we have a valid ID to delete.\nconst agentId = `delete-test-${crypto.randomUUID().slice(0, 8)}`;\nawait ai.agents.create({\n id: agentId,\n base_agent: 'waverunner',\n description: 'Temporary agent for deletion.',\n base_environment: 'remote',\n});\n\nawait ai.agents.delete(agentId);\nconsole.log('Agent deleted successfully.');\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -782,10 +731,10 @@ def _speakeasy_parse_response(http_res): class AgentsWithRawResponse: def __init__(self, sdk: Agents) -> None: self._sdk = sdk + self.list = response_helpers.to_raw_response_wrapper(sdk.list, "extra_headers") self.create = response_helpers.to_raw_response_wrapper( sdk.create, "extra_headers" ) - self.list = response_helpers.to_raw_response_wrapper(sdk.list, "extra_headers") self.get = response_helpers.to_raw_response_wrapper(sdk.get, "extra_headers") self.delete = response_helpers.to_raw_response_wrapper( sdk.delete, "extra_headers" @@ -795,12 +744,12 @@ def __init__(self, sdk: Agents) -> None: class AgentsWithStreamingResponse: def __init__(self, sdk: Agents) -> None: self._sdk = sdk - self.create = response_helpers.to_streamed_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.to_streamed_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.to_streamed_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.to_streamed_response_wrapper( sdk.get, "extra_headers" ) @@ -818,44 +767,23 @@ def with_raw_response(self): def with_streaming_response(self): return AsyncAgentsWithStreamingResponse(self) - async def create( + async def list( self, *, - api_version: Optional[str] = None, - agent_config: Optional[ - Union[agents_agent.AgentConfig, agents_agent.AgentConfigParam] - ] = None, - base_agent: Optional[str] = None, - base_environment: Optional[ - Union[agents_agent.BaseEnvironment, agents_agent.BaseEnvironmentParam] - ] = None, - description: Optional[str] = None, - id: Optional[str] = None, - system_instruction: Optional[str] = None, - tools: Optional[ - Union[ - Iterable[agents_agenttool.AgentTool], - Iterable[agents_agenttool.AgentToolParam], - ] - ] = None, + page_size: Optional[int] = None, + page_token: Optional[str] = None, + parent: Optional[str] = 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, - ) -> agents.Agent: - r"""Creates a new Agent (Typed version for SDK). + ) -> agents.AgentListResponse: + r"""Lists agents. - :param api_version: Which version of the API to use. - :param agent_config: Configuration parameters for the agent. - :param base_agent: The base agent to extend. - :param base_environment: The environment configuration for the agent. - :param description: Agent description for developers to quickly read and understand. - :param id: The unique identifier for the agent. - :param system_instruction: System instruction for the agent. - :param tools: The tools available to the agent. + :param page_size: + :param page_token: + :param parent: :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 @@ -872,46 +800,32 @@ async def create( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateAgentRequest( - api_version=api_version, - body=agents.Agent( - agent_config=utils.get_pydantic_model( - agent_config, Optional[agents.AgentConfig] - ), - base_agent=base_agent, - base_environment=utils.get_pydantic_model( - base_environment, Optional[agents.BaseEnvironment] - ), - description=description, - id=id, - system_instruction=system_instruction, - tools=utils.get_pydantic_model(tools, Optional[List[agents.AgentTool]]), - ), + request = models.ListAgentsRequest( + page_size=page_size, + page_token=page_token, + parent=parent, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="POST", + method="GET", path="/{api_version}/agents", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.CreateAgentGlobals( + _globals=models.ListAgentsGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, False, False, "json", agents.Agent, extra_body=extra_body - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -932,79 +846,48 @@ async def create( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListAgentsClientErrorData, http_res + ) + raise errors.ListAgentsClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListAgentsServerErrorData, http_res + ) + raise errors.ListAgentsServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): - return unmarshal_json_response(agents.Agent, http_res, validate=False) + return unmarshal_json_response( + agents.AgentListResponse, 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="CreateAgent", + operation_id="ListAgents", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "create", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "id": "research-assistant-abc123",\n "base_agent": "antigravity-preview-05-2026",\n "description": "A helpful research assistant.",\n "system_instruction": "You are a helpful research assistant.",\n "base_environment": "remote",\n "tools": [{"type": "google_search"}]\n }\'\n', - }, - { - "label": "create", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\nagent = client.agents.create(\n id=f"research-assistant-{uuid.uuid4().hex[:8]}",\n base_agent="antigravity-preview-05-2026",\n description="A helpful research assistant.",\n system_instruction="You are a helpful research assistant.",\n base_environment="remote",\n tools=[{"type": "google_search"}],\n)\nprint(agent.id)\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "create", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst agentId = `research-assistant-${crypto.randomUUID().slice(0, 8)}`;\nconst agent = await ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n description: 'A helpful research assistant.',\n system_instruction: 'You are a helpful research assistant.',\n base_environment: 'remote',\n tools: [{ type: 'google_search' }],\n});\nif (!agent.id) {\n throw new Error('Agent creation failed: ID is undefined');\n}\nconsole.log(agent.id);\n\n// [cleanup]\nawait ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - { - "label": "with_sources", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "id": "data-analyst-abc123",\n "base_agent": "antigravity-preview-05-2026",\n "system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",\n "base_environment": {\n "type": "remote",\n "sources": [\n {\n "type": "inline",\n "target": ".agents/AGENTS.md",\n "content": "Always use matplotlib for charts. Include a summary table in every report."\n },\n {\n "type": "repository",\n "source": "https://github.com/my-org/analysis-templates",\n "target": "/workspace/templates"\n }\n ]\n }\n }\'\n', - }, - { - "label": "with_sources", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\nagent = client.agents.create(\n id=f"data-analyst-{uuid.uuid4().hex[:8]}",\n base_agent="antigravity-preview-05-2026",\n system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",\n base_environment={\n "type": "remote",\n "sources": [\n {\n "type": "inline",\n "target": ".agents/AGENTS.md",\n "content": "Always use matplotlib for charts. Include a summary table in every report.",\n },\n {\n "type": "repository",\n "source": "https://github.com/my-org/analysis-templates",\n "target": "/workspace/templates",\n },\n ],\n },\n)\nprint(f"Created agent: {agent.id}")\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "with_sources", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst agentId = `data-analyst-${crypto.randomUUID().slice(0, 8)}`;\nconst agent = await ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n system_instruction: 'You are a data analyst. Always include visualizations and export results as PDF.',\n base_environment: {\n type: 'remote',\n sources: [\n {\n type: 'inline',\n target: '.agents/AGENTS.md',\n content: 'Always use matplotlib for charts. Include a summary table in every report.',\n },\n {\n type: 'repository',\n source: 'https://github.com/my-org/analysis-templates',\n target: '/workspace/templates',\n },\n ],\n },\n});\nconsole.log(`Created agent: ${agent.id}`);\n\n// [cleanup]\nif (agent.id) await ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - { - "label": "fork_from_env", - "lang": "sh", - "source": '# Step 1: Set up the environment interactively\nRESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "Write a basic Hello World template to /workspace/template.py.",\n "environment": "remote"\n }\')\nENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)[\'environment_id\'])")\n\n# Step 2: Fork that environment into a named agent\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{\n \\"id\\": \\"my-data-analyst\\",\n \\"base_agent\\": \\"antigravity-preview-05-2026\\",\n \\"system_instruction\\": \\"You are a data analyst. Use the template at /workspace/template.py for all reports.\\",\n \\"base_environment\\": \\"$ENV_ID\\"\n }"\n', - }, - { - "label": "fork_from_env", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Step 1: Set up the environment interactively.\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Write a basic Hello World template to /workspace/template.py.",\n environment="remote",\n)\n\n# Step 2: Fork that environment into a named agent.\nagent_id = f"my-data-analyst-{uuid.uuid4().hex[:8]}"\nagent = client.agents.create(\n id=agent_id,\n base_agent="antigravity-preview-05-2026",\n system_instruction="You are a data analyst. Use the template at /workspace/template.py for all reports.",\n base_environment=interaction.environment_id,\n)\nprint(f"Forked agent: {agent.id}")\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "fork_from_env", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Step 1: Set up the environment interactively.\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Write a basic Hello World template to /workspace/template.py.',\n environment: 'remote',\n});\n\n// Step 2: Fork that environment into a named agent.\nconst agentId = `my-data-analyst-${crypto.randomUUID().slice(0, 8)}`;\nconst agent = await ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n system_instruction: 'You are a data analyst. Use the template at /workspace/template.py for all reports.',\n base_environment: interaction.environment_id,\n});\nconsole.log(`Forked agent: ${agent.id}`);\n\n// [cleanup]\nif (agent.id) await ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( @@ -1055,25 +938,44 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def list( + async def create( self, *, - api_version: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, parent: Optional[str] = None, + agent_config: Optional[ + Union[agents_agent.AgentConfig, agents_agent.AgentConfigParam] + ] = None, + base_agent: Optional[str] = None, + base_environment: Optional[ + Union[agents_agent.BaseEnvironment, agents_agent.BaseEnvironmentParam] + ] = None, + description: Optional[str] = None, + id: Optional[str] = None, + system_instruction: Optional[str] = None, + tools: Optional[ + Union[ + Iterable[agents_agenttool.AgentTool], + Iterable[agents_agenttool.AgentToolParam], + ] + ] = 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, - ) -> agents.AgentListResponse: - r"""Lists all Agents. + ) -> agents.Agent: + r"""Creates or updates an agent (upsert by name). - :param api_version: Which version of the API to use. - :param page_size: - :param page_token: :param parent: + :param agent_config: Configuration parameters for the agent. + :param base_agent: The base agent to extend. + :param base_environment: The environment configuration for the agent. + :param description: Agent description for developers to quickly read and understand. + :param id: The unique identifier for the agent. + :param system_instruction: System instruction for the agent. + :param tools: The tools available to the agent. :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 @@ -1090,33 +992,46 @@ async def list( else: base_url = self._get_url(base_url, url_variables) - request = models.ListAgentsRequest( - api_version=api_version, - page_size=page_size, - page_token=page_token, + request = models.CreateAgentRequest( parent=parent, + body=agents.Agent( + agent_config=utils.get_pydantic_model( + agent_config, Optional[agents.AgentConfig] + ), + base_agent=base_agent, + base_environment=utils.get_pydantic_model( + base_environment, Optional[agents.BaseEnvironment] + ), + description=description, + id=id, + system_instruction=system_instruction, + tools=utils.get_pydantic_model(tools, Optional[List[agents.AgentTool]]), + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="GET", + method="POST", path="/{api_version}/agents", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.ListAgentsGlobals( + _globals=models.CreateAgentGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body, False, False, "json", agents.Agent, extra_body=extra_body + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1137,51 +1052,46 @@ async def list( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateAgentClientErrorData, http_res + ) + raise errors.CreateAgentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateAgentServerErrorData, http_res + ) + raise errors.CreateAgentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): - return unmarshal_json_response( - agents.AgentListResponse, http_res, validate=False - ) + return unmarshal_json_response(agents.Agent, 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="ListAgents", + operation_id="CreateAgent", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "list", - "lang": "sh", - "source": 'curl -X GET https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "list", - "lang": "python", - "source": "from google import genai\n\nclient = genai.Client()\nresponse = client.agents.list()\nfor agent in response.agents or []:\n print(agent.id)\n", - }, - { - "label": "list", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst agents = await ai.agents.list();\nfor (const agent of (agents.agents ?? [])) {\n console.log(agent.id);\n}\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( @@ -1236,15 +1146,13 @@ async def get( 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, ) -> agents.Agent: - r"""Gets a specific Agent. + r"""Gets an agent (latest version). - :param id: - :param api_version: Which version of the API to use. + :param id: Part of `name`. :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 @@ -1264,7 +1172,6 @@ async def get( base_url = self._get_url(base_url, url_variables) request = models.GetAgentRequest( - api_version=api_version, id=id, ) @@ -1273,7 +1180,7 @@ async def get( ) req = self._build_request_async( method="GET", - path="/{api_version}/agents/{id}", + path="/{api_version}/agents/{agentsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -1308,16 +1215,31 @@ async def get( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetAgentClientErrorData, http_res + ) + raise errors.GetAgentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetAgentServerErrorData, http_res + ) + raise errors.GetAgentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response(agents.Agent, http_res, validate=False) @@ -1332,25 +1254,7 @@ async def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "get", - "lang": "sh", - "source": 'curl -X GET https://generativelanguage.googleapis.com/v1beta/agents/ag_abc123 \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "get", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Create an agent so we have a valid ID to retrieve.\nagent_id = f"test-agent-{uuid.uuid4().hex[:8]}"\nclient.agents.create(\n id=agent_id,\n base_agent="waverunner",\n description="A test agent.",\n base_environment="remote",\n)\n\nagent = client.agents.get(agent_id)\nprint(agent.id)\n\n# [cleanup]\nclient.agents.delete(agent.id)\n# [/cleanup]\n', - }, - { - "label": "get", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Create an agent so we have a valid ID to retrieve.\nconst agentId = `test-agent-${crypto.randomUUID().slice(0, 8)}`;\nawait ai.agents.create({\n id: agentId,\n base_agent: 'waverunner',\n description: 'A test agent.',\n base_environment: 'remote',\n});\n\nconst agent = await ai.agents.get(agentId);\nif (!agent.id) {\n throw new Error('Agent retrieval failed: ID is undefined');\n}\nconsole.log(agent.id);\n\n// [cleanup]\nawait ai.agents.delete(agent.id);\n// [/cleanup]\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( @@ -1405,15 +1309,13 @@ async def delete( 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 Agent. + r"""Deletes an agent and all its versions. - :param id: - :param api_version: Which version of the API to use. + :param id: Part of `name`. :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 @@ -1433,7 +1335,6 @@ async def delete( base_url = self._get_url(base_url, url_variables) request = models.DeleteAgentRequest( - api_version=api_version, id=id, ) @@ -1442,7 +1343,7 @@ async def delete( ) req = self._build_request_async( method="DELETE", - path="/{api_version}/agents/{id}", + path="/{api_version}/agents/{agentsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -1477,16 +1378,31 @@ async def delete( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteAgentClientErrorData, http_res + ) + raise errors.DeleteAgentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteAgentServerErrorData, http_res + ) + raise errors.DeleteAgentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( interactions.Empty, http_res, validate=False @@ -1503,25 +1419,7 @@ async def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "delete", - "lang": "sh", - "source": 'curl -X DELETE https://generativelanguage.googleapis.com/v1beta/agents/ag_abc123 \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "delete", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Create an agent so we have a valid ID to delete.\nagent_id = f"delete-test-{uuid.uuid4().hex[:8]}"\nclient.agents.create(\n id=agent_id,\n base_agent="waverunner",\n description="Temporary agent for deletion.",\n base_environment="remote",\n)\n\nclient.agents.delete(agent_id)\nprint("Agent deleted successfully.")\n', - }, - { - "label": "delete", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Create an agent so we have a valid ID to delete.\nconst agentId = `delete-test-${crypto.randomUUID().slice(0, 8)}`;\nawait ai.agents.create({\n id: agentId,\n base_agent: 'waverunner',\n description: 'Temporary agent for deletion.',\n base_environment: 'remote',\n});\n\nawait ai.agents.delete(agentId);\nconsole.log('Agent deleted successfully.');\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( @@ -1576,12 +1474,12 @@ async def _speakeasy_parse_response(http_res): class AsyncAgentsWithRawResponse: def __init__(self, sdk: AsyncAgents) -> None: self._sdk = sdk - self.create = response_helpers.async_to_raw_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.async_to_raw_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.async_to_raw_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.async_to_raw_response_wrapper( sdk.get, "extra_headers" ) @@ -1593,12 +1491,12 @@ def __init__(self, sdk: AsyncAgents) -> None: class AsyncAgentsWithStreamingResponse: def __init__(self, sdk: AsyncAgents) -> None: self._sdk = sdk - self.create = response_helpers.async_to_streamed_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.async_to_streamed_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.async_to_streamed_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.async_to_streamed_response_wrapper( sdk.get, "extra_headers" ) diff --git a/google/genai/_gaos/environments.py b/google/genai/_gaos/environments.py index 63debf44e..dc5197542 100644 --- a/google/genai/_gaos/environments.py +++ b/google/genai/_gaos/environments.py @@ -39,35 +39,22 @@ def with_raw_response(self): def with_streaming_response(self): return EnvironmentsWithStreamingResponse(self) - def create_environment( + def list_environments( self, *, - api_version: Optional[str] = None, - network: Optional[ - Union[ - environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnion, - environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnionParam, - ] - ] = None, - sources: Optional[ - Union[ - Iterable[interactions_source.Source], - Iterable[interactions_source.SourceParam], - ] - ] = 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, - extra_body: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, - ) -> environments.Environment: - r"""Creates an environment. + ) -> environments.ListEnvironmentsResponse: + r"""Lists environments (HTTP endpoint). - :param api_version: Which version of the API to use. - :param network: Network configuration for the environment. - :param sources: Sources to be mounted into the environment. + :param page_size: Maximum number of environments to return. + If unspecified, defaults to 50. Maximum is 1000. + :param page_token: Pagination token. :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 @@ -84,46 +71,31 @@ def create_environment( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateEnvironmentRequest( - api_version=api_version, - body=environments.CreateEnvironmentRequest( - network=utils.get_pydantic_model( - network, Optional[environments.CreateEnvironmentRequestNetworkUnion] - ), - sources=utils.get_pydantic_model( - sources, Optional[List[interactions.Source]] - ), - ), + request = models.ListEnvironmentsRequest( + 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="POST", + method="GET", path="/{api_version}/environments", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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( + _globals=models.ListEnvironmentsGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - environments.CreateEnvironmentRequest, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -144,19 +116,34 @@ def create_environment( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListEnvironmentsClientErrorData, http_res + ) + raise errors.ListEnvironmentsClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListEnvironmentsServerErrorData, http_res + ) + raise errors.ListEnvironmentsServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - environments.Environment, http_res, validate=False + environments.ListEnvironmentsResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -164,7 +151,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="CreateEnvironment", + operation_id="ListEnvironments", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -218,23 +205,33 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def list_environments( + def create_environment( self, *, - api_version: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, + network: Optional[ + Union[ + environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnion, + environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnionParam, + ] + ] = None, + sources: Optional[ + Union[ + Iterable[interactions_source.Source], + Iterable[interactions_source.SourceParam], + ] + ] = 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.ListEnvironmentsResponse: - r"""Lists environments. + ) -> environments.Environment: + r"""Creates an environment (HTTP endpoint). - :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 network: Network configuration for the environment. + :param sources: Sources to be mounted into the environment. :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 @@ -251,32 +248,43 @@ def list_environments( 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, + request = environments.CreateEnvironmentRequest( + network=utils.get_pydantic_model( + network, Optional[environments.CreateEnvironmentRequestNetworkUnion] + ), + sources=utils.get_pydantic_model( + sources, Optional[List[interactions.Source]] + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="GET", + method="POST", path="/{api_version}/environments", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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( + _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, + False, + False, + "json", + environments.CreateEnvironmentRequest, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -297,19 +305,34 @@ def list_environments( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateEnvironmentClientErrorData, http_res + ) + raise errors.CreateEnvironmentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateEnvironmentServerErrorData, http_res + ) + raise errors.CreateEnvironmentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - environments.ListEnvironmentsResponse, http_res, validate=False + environments.Environment, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -317,7 +340,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListEnvironments", + operation_id="CreateEnvironment", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -375,15 +398,13 @@ 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. + r"""Gets an environment (HTTP endpoint). - :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 id: Required. The identifier of the environment to retrieve. :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 @@ -403,7 +424,6 @@ def get_environment( base_url = self._get_url(base_url, url_variables) request = models.GetEnvironmentRequest( - api_version=api_version, id=id, ) @@ -447,16 +467,31 @@ def get_environment( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetEnvironmentClientErrorData, http_res + ) + raise errors.GetEnvironmentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetEnvironmentServerErrorData, http_res + ) + raise errors.GetEnvironmentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( environments.Environment, http_res, validate=False @@ -525,15 +560,13 @@ 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. + r"""Deletes an environment (HTTP endpoint). - :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 id: Required. The identifier of the environment to delete. :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 @@ -553,7 +586,6 @@ def delete_environment( base_url = self._get_url(base_url, url_variables) request = models.DeleteEnvironmentRequest( - api_version=api_version, id=id, ) @@ -597,16 +629,31 @@ def delete_environment( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteEnvironmentClientErrorData, http_res + ) + raise errors.DeleteEnvironmentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteEnvironmentServerErrorData, http_res + ) + raise errors.DeleteEnvironmentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( interactions.Empty, http_res, validate=False @@ -675,12 +722,12 @@ def _speakeasy_parse_response(http_res): 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.create_environment = response_helpers.to_raw_response_wrapper( + sdk.create_environment, "extra_headers" + ) self.get_environment = response_helpers.to_raw_response_wrapper( sdk.get_environment, "extra_headers" ) @@ -692,12 +739,12 @@ def __init__(self, sdk: Environments) -> None: 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.create_environment = response_helpers.to_streamed_response_wrapper( + sdk.create_environment, "extra_headers" + ) self.get_environment = response_helpers.to_streamed_response_wrapper( sdk.get_environment, "extra_headers" ) @@ -715,35 +762,22 @@ def with_raw_response(self): def with_streaming_response(self): return AsyncEnvironmentsWithStreamingResponse(self) - async def create_environment( + async def list_environments( self, *, - api_version: Optional[str] = None, - network: Optional[ - Union[ - environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnion, - environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnionParam, - ] - ] = None, - sources: Optional[ - Union[ - Iterable[interactions_source.Source], - Iterable[interactions_source.SourceParam], - ] - ] = 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, - extra_body: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, - ) -> environments.Environment: - r"""Creates an environment. + ) -> environments.ListEnvironmentsResponse: + r"""Lists environments (HTTP endpoint). - :param api_version: Which version of the API to use. - :param network: Network configuration for the environment. - :param sources: Sources to be mounted into the environment. + :param page_size: Maximum number of environments to return. + If unspecified, defaults to 50. Maximum is 1000. + :param page_token: Pagination token. :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 @@ -760,46 +794,31 @@ async def create_environment( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateEnvironmentRequest( - api_version=api_version, - body=environments.CreateEnvironmentRequest( - network=utils.get_pydantic_model( - network, Optional[environments.CreateEnvironmentRequestNetworkUnion] - ), - sources=utils.get_pydantic_model( - sources, Optional[List[interactions.Source]] - ), - ), + request = models.ListEnvironmentsRequest( + 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="POST", + method="GET", path="/{api_version}/environments", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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( + _globals=models.ListEnvironmentsGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - environments.CreateEnvironmentRequest, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -820,19 +839,34 @@ async def create_environment( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListEnvironmentsClientErrorData, http_res + ) + raise errors.ListEnvironmentsClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListEnvironmentsServerErrorData, http_res + ) + raise errors.ListEnvironmentsServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - environments.Environment, http_res, validate=False + environments.ListEnvironmentsResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -840,7 +874,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="CreateEnvironment", + operation_id="ListEnvironments", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -897,23 +931,33 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def list_environments( + async def create_environment( self, *, - api_version: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, + network: Optional[ + Union[ + environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnion, + environments_createenvironmentrequest.CreateEnvironmentRequestNetworkUnionParam, + ] + ] = None, + sources: Optional[ + Union[ + Iterable[interactions_source.Source], + Iterable[interactions_source.SourceParam], + ] + ] = 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.ListEnvironmentsResponse: - r"""Lists environments. + ) -> environments.Environment: + r"""Creates an environment (HTTP endpoint). - :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 network: Network configuration for the environment. + :param sources: Sources to be mounted into the environment. :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 @@ -930,32 +974,43 @@ async def list_environments( 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, + request = environments.CreateEnvironmentRequest( + network=utils.get_pydantic_model( + network, Optional[environments.CreateEnvironmentRequestNetworkUnion] + ), + sources=utils.get_pydantic_model( + sources, Optional[List[interactions.Source]] + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="GET", + method="POST", path="/{api_version}/environments", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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( + _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, + False, + False, + "json", + environments.CreateEnvironmentRequest, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -976,19 +1031,34 @@ async def list_environments( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateEnvironmentClientErrorData, http_res + ) + raise errors.CreateEnvironmentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateEnvironmentServerErrorData, http_res + ) + raise errors.CreateEnvironmentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - environments.ListEnvironmentsResponse, http_res, validate=False + environments.Environment, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -996,7 +1066,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListEnvironments", + operation_id="CreateEnvironment", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1057,15 +1127,13 @@ 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. + r"""Gets an environment (HTTP endpoint). - :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 id: Required. The identifier of the environment to retrieve. :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 @@ -1085,7 +1153,6 @@ async def get_environment( base_url = self._get_url(base_url, url_variables) request = models.GetEnvironmentRequest( - api_version=api_version, id=id, ) @@ -1129,16 +1196,31 @@ async def get_environment( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetEnvironmentClientErrorData, http_res + ) + raise errors.GetEnvironmentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetEnvironmentServerErrorData, http_res + ) + raise errors.GetEnvironmentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( environments.Environment, http_res, validate=False @@ -1210,15 +1292,13 @@ 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. + r"""Deletes an environment (HTTP endpoint). - :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 id: Required. The identifier of the environment to delete. :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 @@ -1238,7 +1318,6 @@ async def delete_environment( base_url = self._get_url(base_url, url_variables) request = models.DeleteEnvironmentRequest( - api_version=api_version, id=id, ) @@ -1282,16 +1361,31 @@ async def delete_environment( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteEnvironmentClientErrorData, http_res + ) + raise errors.DeleteEnvironmentClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteEnvironmentServerErrorData, http_res + ) + raise errors.DeleteEnvironmentServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( interactions.Empty, http_res, validate=False @@ -1363,12 +1457,12 @@ async def _speakeasy_parse_response(http_res): 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.create_environment = response_helpers.async_to_raw_response_wrapper( + sdk.create_environment, "extra_headers" + ) self.get_environment = response_helpers.async_to_raw_response_wrapper( sdk.get_environment, "extra_headers" ) @@ -1380,12 +1474,12 @@ def __init__(self, sdk: AsyncEnvironments) -> None: 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.create_environment = response_helpers.async_to_streamed_response_wrapper( + sdk.create_environment, "extra_headers" + ) self.get_environment = response_helpers.async_to_streamed_response_wrapper( sdk.get_environment, "extra_headers" ) diff --git a/google/genai/_gaos/errors/__init__.py b/google/genai/_gaos/errors/__init__.py index 071907851..f3a497d60 100644 --- a/google/genai/_gaos/errors/__init__.py +++ b/google/genai/_gaos/errors/__init__.py @@ -28,49 +28,269 @@ CancelInteractionByIDServerError, CancelInteractionByIDServerErrorData, ) + from .createagent import ( + CreateAgentClientError, + CreateAgentClientErrorData, + CreateAgentServerError, + CreateAgentServerErrorData, + ) + from .createenvironment import ( + CreateEnvironmentClientError, + CreateEnvironmentClientErrorData, + CreateEnvironmentServerError, + CreateEnvironmentServerErrorData, + ) from .createinteraction import ( CreateInteractionClientError, CreateInteractionClientErrorData, CreateInteractionServerError, CreateInteractionServerErrorData, ) + from .createtrigger import ( + CreateTriggerClientError, + CreateTriggerClientErrorData, + CreateTriggerServerError, + CreateTriggerServerErrorData, + ) + from .createwebhook import ( + CreateWebhookClientError, + CreateWebhookClientErrorData, + CreateWebhookServerError, + CreateWebhookServerErrorData, + ) + from .deleteagent import ( + DeleteAgentClientError, + DeleteAgentClientErrorData, + DeleteAgentServerError, + DeleteAgentServerErrorData, + ) + from .deleteenvironment import ( + DeleteEnvironmentClientError, + DeleteEnvironmentClientErrorData, + DeleteEnvironmentServerError, + DeleteEnvironmentServerErrorData, + ) from .deleteinteraction import ( DeleteInteractionClientError, DeleteInteractionClientErrorData, DeleteInteractionServerError, DeleteInteractionServerErrorData, ) + from .deletetrigger import ( + DeleteTriggerClientError, + DeleteTriggerClientErrorData, + DeleteTriggerServerError, + DeleteTriggerServerErrorData, + ) + from .deletewebhook import ( + DeleteWebhookClientError, + DeleteWebhookClientErrorData, + DeleteWebhookServerError, + DeleteWebhookServerErrorData, + ) from .genaidefaulterror import GenAiDefaultError + from .getagent import ( + GetAgentClientError, + GetAgentClientErrorData, + GetAgentServerError, + GetAgentServerErrorData, + ) + from .getenvironment import ( + GetEnvironmentClientError, + GetEnvironmentClientErrorData, + GetEnvironmentServerError, + GetEnvironmentServerErrorData, + ) from .getinteractionbyid import ( GetInteractionByIDClientError, GetInteractionByIDClientErrorData, GetInteractionByIDServerError, GetInteractionByIDServerErrorData, ) + from .gettrigger import ( + GetTriggerClientError, + GetTriggerClientErrorData, + GetTriggerServerError, + GetTriggerServerErrorData, + ) + from .getwebhook import ( + GetWebhookClientError, + GetWebhookClientErrorData, + GetWebhookServerError, + GetWebhookServerErrorData, + ) + from .listagents import ( + ListAgentsClientError, + ListAgentsClientErrorData, + ListAgentsServerError, + ListAgentsServerErrorData, + ) + from .listenvironments import ( + ListEnvironmentsClientError, + ListEnvironmentsClientErrorData, + ListEnvironmentsServerError, + ListEnvironmentsServerErrorData, + ) + from .listtriggerexecutions import ( + ListTriggerExecutionsClientError, + ListTriggerExecutionsClientErrorData, + ListTriggerExecutionsServerError, + ListTriggerExecutionsServerErrorData, + ) + from .listtriggers import ( + ListTriggersClientError, + ListTriggersClientErrorData, + ListTriggersServerError, + ListTriggersServerErrorData, + ) + from .listwebhooks import ( + ListWebhooksClientError, + ListWebhooksClientErrorData, + ListWebhooksServerError, + ListWebhooksServerErrorData, + ) from .no_response_error import NoResponseError + from .pingwebhook import ( + PingWebhookClientError, + PingWebhookClientErrorData, + PingWebhookServerError, + PingWebhookServerErrorData, + ) from .responsevalidationerror import ResponseValidationError + from .rotatesigningsecret import ( + RotateSigningSecretClientError, + RotateSigningSecretClientErrorData, + RotateSigningSecretServerError, + RotateSigningSecretServerErrorData, + ) + from .runtrigger import ( + RunTriggerClientError, + RunTriggerClientErrorData, + RunTriggerServerError, + RunTriggerServerErrorData, + ) + from .updatetrigger import ( + UpdateTriggerClientError, + UpdateTriggerClientErrorData, + UpdateTriggerServerError, + UpdateTriggerServerErrorData, + ) + from .updatewebhook import ( + UpdateWebhookClientError, + UpdateWebhookClientErrorData, + UpdateWebhookServerError, + UpdateWebhookServerErrorData, + ) __all__ = [ "CancelInteractionByIDClientError", "CancelInteractionByIDClientErrorData", "CancelInteractionByIDServerError", "CancelInteractionByIDServerErrorData", + "CreateAgentClientError", + "CreateAgentClientErrorData", + "CreateAgentServerError", + "CreateAgentServerErrorData", + "CreateEnvironmentClientError", + "CreateEnvironmentClientErrorData", + "CreateEnvironmentServerError", + "CreateEnvironmentServerErrorData", "CreateInteractionClientError", "CreateInteractionClientErrorData", "CreateInteractionServerError", "CreateInteractionServerErrorData", + "CreateTriggerClientError", + "CreateTriggerClientErrorData", + "CreateTriggerServerError", + "CreateTriggerServerErrorData", + "CreateWebhookClientError", + "CreateWebhookClientErrorData", + "CreateWebhookServerError", + "CreateWebhookServerErrorData", + "DeleteAgentClientError", + "DeleteAgentClientErrorData", + "DeleteAgentServerError", + "DeleteAgentServerErrorData", + "DeleteEnvironmentClientError", + "DeleteEnvironmentClientErrorData", + "DeleteEnvironmentServerError", + "DeleteEnvironmentServerErrorData", "DeleteInteractionClientError", "DeleteInteractionClientErrorData", "DeleteInteractionServerError", "DeleteInteractionServerErrorData", + "DeleteTriggerClientError", + "DeleteTriggerClientErrorData", + "DeleteTriggerServerError", + "DeleteTriggerServerErrorData", + "DeleteWebhookClientError", + "DeleteWebhookClientErrorData", + "DeleteWebhookServerError", + "DeleteWebhookServerErrorData", "GenAiDefaultError", "GenAiError", + "GetAgentClientError", + "GetAgentClientErrorData", + "GetAgentServerError", + "GetAgentServerErrorData", + "GetEnvironmentClientError", + "GetEnvironmentClientErrorData", + "GetEnvironmentServerError", + "GetEnvironmentServerErrorData", "GetInteractionByIDClientError", "GetInteractionByIDClientErrorData", "GetInteractionByIDServerError", "GetInteractionByIDServerErrorData", + "GetTriggerClientError", + "GetTriggerClientErrorData", + "GetTriggerServerError", + "GetTriggerServerErrorData", + "GetWebhookClientError", + "GetWebhookClientErrorData", + "GetWebhookServerError", + "GetWebhookServerErrorData", + "ListAgentsClientError", + "ListAgentsClientErrorData", + "ListAgentsServerError", + "ListAgentsServerErrorData", + "ListEnvironmentsClientError", + "ListEnvironmentsClientErrorData", + "ListEnvironmentsServerError", + "ListEnvironmentsServerErrorData", + "ListTriggerExecutionsClientError", + "ListTriggerExecutionsClientErrorData", + "ListTriggerExecutionsServerError", + "ListTriggerExecutionsServerErrorData", + "ListTriggersClientError", + "ListTriggersClientErrorData", + "ListTriggersServerError", + "ListTriggersServerErrorData", + "ListWebhooksClientError", + "ListWebhooksClientErrorData", + "ListWebhooksServerError", + "ListWebhooksServerErrorData", "NoResponseError", + "PingWebhookClientError", + "PingWebhookClientErrorData", + "PingWebhookServerError", + "PingWebhookServerErrorData", "ResponseValidationError", + "RotateSigningSecretClientError", + "RotateSigningSecretClientErrorData", + "RotateSigningSecretServerError", + "RotateSigningSecretServerErrorData", + "RunTriggerClientError", + "RunTriggerClientErrorData", + "RunTriggerServerError", + "RunTriggerServerErrorData", + "UpdateTriggerClientError", + "UpdateTriggerClientErrorData", + "UpdateTriggerServerError", + "UpdateTriggerServerErrorData", + "UpdateWebhookClientError", + "UpdateWebhookClientErrorData", + "UpdateWebhookServerError", + "UpdateWebhookServerErrorData", ] _dynamic_imports: dict[str, str] = { @@ -78,21 +298,109 @@ "CancelInteractionByIDClientErrorData": ".cancelinteractionbyid", "CancelInteractionByIDServerError": ".cancelinteractionbyid", "CancelInteractionByIDServerErrorData": ".cancelinteractionbyid", + "CreateAgentClientError": ".createagent", + "CreateAgentClientErrorData": ".createagent", + "CreateAgentServerError": ".createagent", + "CreateAgentServerErrorData": ".createagent", + "CreateEnvironmentClientError": ".createenvironment", + "CreateEnvironmentClientErrorData": ".createenvironment", + "CreateEnvironmentServerError": ".createenvironment", + "CreateEnvironmentServerErrorData": ".createenvironment", "CreateInteractionClientError": ".createinteraction", "CreateInteractionClientErrorData": ".createinteraction", "CreateInteractionServerError": ".createinteraction", "CreateInteractionServerErrorData": ".createinteraction", + "CreateTriggerClientError": ".createtrigger", + "CreateTriggerClientErrorData": ".createtrigger", + "CreateTriggerServerError": ".createtrigger", + "CreateTriggerServerErrorData": ".createtrigger", + "CreateWebhookClientError": ".createwebhook", + "CreateWebhookClientErrorData": ".createwebhook", + "CreateWebhookServerError": ".createwebhook", + "CreateWebhookServerErrorData": ".createwebhook", + "DeleteAgentClientError": ".deleteagent", + "DeleteAgentClientErrorData": ".deleteagent", + "DeleteAgentServerError": ".deleteagent", + "DeleteAgentServerErrorData": ".deleteagent", + "DeleteEnvironmentClientError": ".deleteenvironment", + "DeleteEnvironmentClientErrorData": ".deleteenvironment", + "DeleteEnvironmentServerError": ".deleteenvironment", + "DeleteEnvironmentServerErrorData": ".deleteenvironment", "DeleteInteractionClientError": ".deleteinteraction", "DeleteInteractionClientErrorData": ".deleteinteraction", "DeleteInteractionServerError": ".deleteinteraction", "DeleteInteractionServerErrorData": ".deleteinteraction", + "DeleteTriggerClientError": ".deletetrigger", + "DeleteTriggerClientErrorData": ".deletetrigger", + "DeleteTriggerServerError": ".deletetrigger", + "DeleteTriggerServerErrorData": ".deletetrigger", + "DeleteWebhookClientError": ".deletewebhook", + "DeleteWebhookClientErrorData": ".deletewebhook", + "DeleteWebhookServerError": ".deletewebhook", + "DeleteWebhookServerErrorData": ".deletewebhook", "GenAiDefaultError": ".genaidefaulterror", + "GetAgentClientError": ".getagent", + "GetAgentClientErrorData": ".getagent", + "GetAgentServerError": ".getagent", + "GetAgentServerErrorData": ".getagent", + "GetEnvironmentClientError": ".getenvironment", + "GetEnvironmentClientErrorData": ".getenvironment", + "GetEnvironmentServerError": ".getenvironment", + "GetEnvironmentServerErrorData": ".getenvironment", "GetInteractionByIDClientError": ".getinteractionbyid", "GetInteractionByIDClientErrorData": ".getinteractionbyid", "GetInteractionByIDServerError": ".getinteractionbyid", "GetInteractionByIDServerErrorData": ".getinteractionbyid", + "GetTriggerClientError": ".gettrigger", + "GetTriggerClientErrorData": ".gettrigger", + "GetTriggerServerError": ".gettrigger", + "GetTriggerServerErrorData": ".gettrigger", + "GetWebhookClientError": ".getwebhook", + "GetWebhookClientErrorData": ".getwebhook", + "GetWebhookServerError": ".getwebhook", + "GetWebhookServerErrorData": ".getwebhook", + "ListAgentsClientError": ".listagents", + "ListAgentsClientErrorData": ".listagents", + "ListAgentsServerError": ".listagents", + "ListAgentsServerErrorData": ".listagents", + "ListEnvironmentsClientError": ".listenvironments", + "ListEnvironmentsClientErrorData": ".listenvironments", + "ListEnvironmentsServerError": ".listenvironments", + "ListEnvironmentsServerErrorData": ".listenvironments", + "ListTriggerExecutionsClientError": ".listtriggerexecutions", + "ListTriggerExecutionsClientErrorData": ".listtriggerexecutions", + "ListTriggerExecutionsServerError": ".listtriggerexecutions", + "ListTriggerExecutionsServerErrorData": ".listtriggerexecutions", + "ListTriggersClientError": ".listtriggers", + "ListTriggersClientErrorData": ".listtriggers", + "ListTriggersServerError": ".listtriggers", + "ListTriggersServerErrorData": ".listtriggers", + "ListWebhooksClientError": ".listwebhooks", + "ListWebhooksClientErrorData": ".listwebhooks", + "ListWebhooksServerError": ".listwebhooks", + "ListWebhooksServerErrorData": ".listwebhooks", "NoResponseError": ".no_response_error", + "PingWebhookClientError": ".pingwebhook", + "PingWebhookClientErrorData": ".pingwebhook", + "PingWebhookServerError": ".pingwebhook", + "PingWebhookServerErrorData": ".pingwebhook", "ResponseValidationError": ".responsevalidationerror", + "RotateSigningSecretClientError": ".rotatesigningsecret", + "RotateSigningSecretClientErrorData": ".rotatesigningsecret", + "RotateSigningSecretServerError": ".rotatesigningsecret", + "RotateSigningSecretServerErrorData": ".rotatesigningsecret", + "RunTriggerClientError": ".runtrigger", + "RunTriggerClientErrorData": ".runtrigger", + "RunTriggerServerError": ".runtrigger", + "RunTriggerServerErrorData": ".runtrigger", + "UpdateTriggerClientError": ".updatetrigger", + "UpdateTriggerClientErrorData": ".updatetrigger", + "UpdateTriggerServerError": ".updatetrigger", + "UpdateTriggerServerErrorData": ".updatetrigger", + "UpdateWebhookClientError": ".updatewebhook", + "UpdateWebhookClientErrorData": ".updatewebhook", + "UpdateWebhookServerError": ".updatewebhook", + "UpdateWebhookServerErrorData": ".updatewebhook", } diff --git a/google/genai/_gaos/errors/cancelinteractionbyid.py b/google/genai/_gaos/errors/cancelinteractionbyid.py index 3ebea6d31..837aff361 100644 --- a/google/genai/_gaos/errors/cancelinteractionbyid.py +++ b/google/genai/_gaos/errors/cancelinteractionbyid.py @@ -32,7 +32,7 @@ class CancelInteractionByIDServerErrorData(BaseModel): @dataclass(unsafe_hash=True) class CancelInteractionByIDServerError(GenAiError): - r"""Error cancelling interaction""" + r"""Server Error""" data: CancelInteractionByIDServerErrorData = field(hash=False) @@ -55,7 +55,7 @@ class CancelInteractionByIDClientErrorData(BaseModel): @dataclass(unsafe_hash=True) class CancelInteractionByIDClientError(GenAiError): - r"""Error cancelling interaction""" + r"""Client Error""" data: CancelInteractionByIDClientErrorData = field(hash=False) diff --git a/google/genai/_gaos/errors/createagent.py b/google/genai/_gaos/errors/createagent.py new file mode 100644 index 000000000..f122eb525 --- /dev/null +++ b/google/genai/_gaos/errors/createagent.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class CreateAgentServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateAgentServerError(GenAiError): + r"""Server Error""" + + data: CreateAgentServerErrorData = field(hash=False) + + def __init__( + self, + data: CreateAgentServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class CreateAgentClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateAgentClientError(GenAiError): + r"""Client Error""" + + data: CreateAgentClientErrorData = field(hash=False) + + def __init__( + self, + data: CreateAgentClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/createenvironment.py b/google/genai/_gaos/errors/createenvironment.py new file mode 100644 index 000000000..f73d2f68d --- /dev/null +++ b/google/genai/_gaos/errors/createenvironment.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class CreateEnvironmentServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateEnvironmentServerError(GenAiError): + r"""Server Error""" + + data: CreateEnvironmentServerErrorData = field(hash=False) + + def __init__( + self, + data: CreateEnvironmentServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class CreateEnvironmentClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateEnvironmentClientError(GenAiError): + r"""Client Error""" + + data: CreateEnvironmentClientErrorData = field(hash=False) + + def __init__( + self, + data: CreateEnvironmentClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/createinteraction.py b/google/genai/_gaos/errors/createinteraction.py index 8e8332393..4c952ed86 100644 --- a/google/genai/_gaos/errors/createinteraction.py +++ b/google/genai/_gaos/errors/createinteraction.py @@ -32,7 +32,7 @@ class CreateInteractionServerErrorData(BaseModel): @dataclass(unsafe_hash=True) class CreateInteractionServerError(GenAiError): - r"""Error creating interaction""" + r"""Server Error""" data: CreateInteractionServerErrorData = field(hash=False) @@ -55,7 +55,7 @@ class CreateInteractionClientErrorData(BaseModel): @dataclass(unsafe_hash=True) class CreateInteractionClientError(GenAiError): - r"""Error creating interaction""" + r"""Client Error""" data: CreateInteractionClientErrorData = field(hash=False) diff --git a/google/genai/_gaos/errors/createtrigger.py b/google/genai/_gaos/errors/createtrigger.py new file mode 100644 index 000000000..e1157a183 --- /dev/null +++ b/google/genai/_gaos/errors/createtrigger.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class CreateTriggerServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateTriggerServerError(GenAiError): + r"""Server Error""" + + data: CreateTriggerServerErrorData = field(hash=False) + + def __init__( + self, + data: CreateTriggerServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class CreateTriggerClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateTriggerClientError(GenAiError): + r"""Client Error""" + + data: CreateTriggerClientErrorData = field(hash=False) + + def __init__( + self, + data: CreateTriggerClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/createwebhook.py b/google/genai/_gaos/errors/createwebhook.py new file mode 100644 index 000000000..e4c9e738b --- /dev/null +++ b/google/genai/_gaos/errors/createwebhook.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class CreateWebhookServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateWebhookServerError(GenAiError): + r"""Server Error""" + + data: CreateWebhookServerErrorData = field(hash=False) + + def __init__( + self, + data: CreateWebhookServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class CreateWebhookClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class CreateWebhookClientError(GenAiError): + r"""Client Error""" + + data: CreateWebhookClientErrorData = field(hash=False) + + def __init__( + self, + data: CreateWebhookClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/deleteagent.py b/google/genai/_gaos/errors/deleteagent.py new file mode 100644 index 000000000..bc9f3e722 --- /dev/null +++ b/google/genai/_gaos/errors/deleteagent.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class DeleteAgentServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteAgentServerError(GenAiError): + r"""Server Error""" + + data: DeleteAgentServerErrorData = field(hash=False) + + def __init__( + self, + data: DeleteAgentServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class DeleteAgentClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteAgentClientError(GenAiError): + r"""Client Error""" + + data: DeleteAgentClientErrorData = field(hash=False) + + def __init__( + self, + data: DeleteAgentClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/deleteenvironment.py b/google/genai/_gaos/errors/deleteenvironment.py new file mode 100644 index 000000000..62821ed68 --- /dev/null +++ b/google/genai/_gaos/errors/deleteenvironment.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class DeleteEnvironmentServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteEnvironmentServerError(GenAiError): + r"""Server Error""" + + data: DeleteEnvironmentServerErrorData = field(hash=False) + + def __init__( + self, + data: DeleteEnvironmentServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class DeleteEnvironmentClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteEnvironmentClientError(GenAiError): + r"""Client Error""" + + data: DeleteEnvironmentClientErrorData = field(hash=False) + + def __init__( + self, + data: DeleteEnvironmentClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/deleteinteraction.py b/google/genai/_gaos/errors/deleteinteraction.py index 4ae8ff328..10a9229f1 100644 --- a/google/genai/_gaos/errors/deleteinteraction.py +++ b/google/genai/_gaos/errors/deleteinteraction.py @@ -32,7 +32,7 @@ class DeleteInteractionServerErrorData(BaseModel): @dataclass(unsafe_hash=True) class DeleteInteractionServerError(GenAiError): - r"""Error deleting interaction""" + r"""Server Error""" data: DeleteInteractionServerErrorData = field(hash=False) @@ -55,7 +55,7 @@ class DeleteInteractionClientErrorData(BaseModel): @dataclass(unsafe_hash=True) class DeleteInteractionClientError(GenAiError): - r"""Error deleting interaction""" + r"""Client Error""" data: DeleteInteractionClientErrorData = field(hash=False) diff --git a/google/genai/_gaos/errors/deletetrigger.py b/google/genai/_gaos/errors/deletetrigger.py new file mode 100644 index 000000000..ce331ff19 --- /dev/null +++ b/google/genai/_gaos/errors/deletetrigger.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class DeleteTriggerServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteTriggerServerError(GenAiError): + r"""Server Error""" + + data: DeleteTriggerServerErrorData = field(hash=False) + + def __init__( + self, + data: DeleteTriggerServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class DeleteTriggerClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteTriggerClientError(GenAiError): + r"""Client Error""" + + data: DeleteTriggerClientErrorData = field(hash=False) + + def __init__( + self, + data: DeleteTriggerClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/deletewebhook.py b/google/genai/_gaos/errors/deletewebhook.py new file mode 100644 index 000000000..571133974 --- /dev/null +++ b/google/genai/_gaos/errors/deletewebhook.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class DeleteWebhookServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteWebhookServerError(GenAiError): + r"""Server Error""" + + data: DeleteWebhookServerErrorData = field(hash=False) + + def __init__( + self, + data: DeleteWebhookServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class DeleteWebhookClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class DeleteWebhookClientError(GenAiError): + r"""Client Error""" + + data: DeleteWebhookClientErrorData = field(hash=False) + + def __init__( + self, + data: DeleteWebhookClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/getagent.py b/google/genai/_gaos/errors/getagent.py new file mode 100644 index 000000000..2077707f6 --- /dev/null +++ b/google/genai/_gaos/errors/getagent.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class GetAgentServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetAgentServerError(GenAiError): + r"""Server Error""" + + data: GetAgentServerErrorData = field(hash=False) + + def __init__( + self, + data: GetAgentServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class GetAgentClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetAgentClientError(GenAiError): + r"""Client Error""" + + data: GetAgentClientErrorData = field(hash=False) + + def __init__( + self, + data: GetAgentClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/getenvironment.py b/google/genai/_gaos/errors/getenvironment.py new file mode 100644 index 000000000..728ece27a --- /dev/null +++ b/google/genai/_gaos/errors/getenvironment.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class GetEnvironmentServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetEnvironmentServerError(GenAiError): + r"""Server Error""" + + data: GetEnvironmentServerErrorData = field(hash=False) + + def __init__( + self, + data: GetEnvironmentServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class GetEnvironmentClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetEnvironmentClientError(GenAiError): + r"""Client Error""" + + data: GetEnvironmentClientErrorData = field(hash=False) + + def __init__( + self, + data: GetEnvironmentClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/getinteractionbyid.py b/google/genai/_gaos/errors/getinteractionbyid.py index 72b48a921..1c1051cd9 100644 --- a/google/genai/_gaos/errors/getinteractionbyid.py +++ b/google/genai/_gaos/errors/getinteractionbyid.py @@ -32,7 +32,7 @@ class GetInteractionByIDServerErrorData(BaseModel): @dataclass(unsafe_hash=True) class GetInteractionByIDServerError(GenAiError): - r"""Error getting interaction""" + r"""Server Error""" data: GetInteractionByIDServerErrorData = field(hash=False) @@ -55,7 +55,7 @@ class GetInteractionByIDClientErrorData(BaseModel): @dataclass(unsafe_hash=True) class GetInteractionByIDClientError(GenAiError): - r"""Error getting interaction""" + r"""Client Error""" data: GetInteractionByIDClientErrorData = field(hash=False) diff --git a/google/genai/_gaos/errors/gettrigger.py b/google/genai/_gaos/errors/gettrigger.py new file mode 100644 index 000000000..a80f53e36 --- /dev/null +++ b/google/genai/_gaos/errors/gettrigger.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class GetTriggerServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetTriggerServerError(GenAiError): + r"""Server Error""" + + data: GetTriggerServerErrorData = field(hash=False) + + def __init__( + self, + data: GetTriggerServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class GetTriggerClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetTriggerClientError(GenAiError): + r"""Client Error""" + + data: GetTriggerClientErrorData = field(hash=False) + + def __init__( + self, + data: GetTriggerClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/getwebhook.py b/google/genai/_gaos/errors/getwebhook.py new file mode 100644 index 000000000..ecd1a5fbd --- /dev/null +++ b/google/genai/_gaos/errors/getwebhook.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class GetWebhookServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetWebhookServerError(GenAiError): + r"""Server Error""" + + data: GetWebhookServerErrorData = field(hash=False) + + def __init__( + self, + data: GetWebhookServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class GetWebhookClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class GetWebhookClientError(GenAiError): + r"""Client Error""" + + data: GetWebhookClientErrorData = field(hash=False) + + def __init__( + self, + data: GetWebhookClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/listagents.py b/google/genai/_gaos/errors/listagents.py new file mode 100644 index 000000000..47644ff14 --- /dev/null +++ b/google/genai/_gaos/errors/listagents.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class ListAgentsServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListAgentsServerError(GenAiError): + r"""Server Error""" + + data: ListAgentsServerErrorData = field(hash=False) + + def __init__( + self, + data: ListAgentsServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class ListAgentsClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListAgentsClientError(GenAiError): + r"""Client Error""" + + data: ListAgentsClientErrorData = field(hash=False) + + def __init__( + self, + data: ListAgentsClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/listenvironments.py b/google/genai/_gaos/errors/listenvironments.py new file mode 100644 index 000000000..d357bb047 --- /dev/null +++ b/google/genai/_gaos/errors/listenvironments.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class ListEnvironmentsServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListEnvironmentsServerError(GenAiError): + r"""Server Error""" + + data: ListEnvironmentsServerErrorData = field(hash=False) + + def __init__( + self, + data: ListEnvironmentsServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class ListEnvironmentsClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListEnvironmentsClientError(GenAiError): + r"""Client Error""" + + data: ListEnvironmentsClientErrorData = field(hash=False) + + def __init__( + self, + data: ListEnvironmentsClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/listtriggerexecutions.py b/google/genai/_gaos/errors/listtriggerexecutions.py new file mode 100644 index 000000000..f172a143f --- /dev/null +++ b/google/genai/_gaos/errors/listtriggerexecutions.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class ListTriggerExecutionsServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListTriggerExecutionsServerError(GenAiError): + r"""Server Error""" + + data: ListTriggerExecutionsServerErrorData = field(hash=False) + + def __init__( + self, + data: ListTriggerExecutionsServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class ListTriggerExecutionsClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListTriggerExecutionsClientError(GenAiError): + r"""Client Error""" + + data: ListTriggerExecutionsClientErrorData = field(hash=False) + + def __init__( + self, + data: ListTriggerExecutionsClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/listtriggers.py b/google/genai/_gaos/errors/listtriggers.py new file mode 100644 index 000000000..64b411418 --- /dev/null +++ b/google/genai/_gaos/errors/listtriggers.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class ListTriggersServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListTriggersServerError(GenAiError): + r"""Server Error""" + + data: ListTriggersServerErrorData = field(hash=False) + + def __init__( + self, + data: ListTriggersServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class ListTriggersClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListTriggersClientError(GenAiError): + r"""Client Error""" + + data: ListTriggersClientErrorData = field(hash=False) + + def __init__( + self, + data: ListTriggersClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/listwebhooks.py b/google/genai/_gaos/errors/listwebhooks.py new file mode 100644 index 000000000..425a4134c --- /dev/null +++ b/google/genai/_gaos/errors/listwebhooks.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class ListWebhooksServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListWebhooksServerError(GenAiError): + r"""Server Error""" + + data: ListWebhooksServerErrorData = field(hash=False) + + def __init__( + self, + data: ListWebhooksServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class ListWebhooksClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class ListWebhooksClientError(GenAiError): + r"""Client Error""" + + data: ListWebhooksClientErrorData = field(hash=False) + + def __init__( + self, + data: ListWebhooksClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/pingwebhook.py b/google/genai/_gaos/errors/pingwebhook.py new file mode 100644 index 000000000..7c578adeb --- /dev/null +++ b/google/genai/_gaos/errors/pingwebhook.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class PingWebhookServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class PingWebhookServerError(GenAiError): + r"""Server Error""" + + data: PingWebhookServerErrorData = field(hash=False) + + def __init__( + self, + data: PingWebhookServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class PingWebhookClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class PingWebhookClientError(GenAiError): + r"""Client Error""" + + data: PingWebhookClientErrorData = field(hash=False) + + def __init__( + self, + data: PingWebhookClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/rotatesigningsecret.py b/google/genai/_gaos/errors/rotatesigningsecret.py new file mode 100644 index 000000000..f83ebb5b5 --- /dev/null +++ b/google/genai/_gaos/errors/rotatesigningsecret.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class RotateSigningSecretServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class RotateSigningSecretServerError(GenAiError): + r"""Server Error""" + + data: RotateSigningSecretServerErrorData = field(hash=False) + + def __init__( + self, + data: RotateSigningSecretServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class RotateSigningSecretClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class RotateSigningSecretClientError(GenAiError): + r"""Client Error""" + + data: RotateSigningSecretClientErrorData = field(hash=False) + + def __init__( + self, + data: RotateSigningSecretClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/runtrigger.py b/google/genai/_gaos/errors/runtrigger.py new file mode 100644 index 000000000..353981116 --- /dev/null +++ b/google/genai/_gaos/errors/runtrigger.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class RunTriggerServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class RunTriggerServerError(GenAiError): + r"""Server Error""" + + data: RunTriggerServerErrorData = field(hash=False) + + def __init__( + self, + data: RunTriggerServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class RunTriggerClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class RunTriggerClientError(GenAiError): + r"""Client Error""" + + data: RunTriggerClientErrorData = field(hash=False) + + def __init__( + self, + data: RunTriggerClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/updatetrigger.py b/google/genai/_gaos/errors/updatetrigger.py new file mode 100644 index 000000000..ede2597e7 --- /dev/null +++ b/google/genai/_gaos/errors/updatetrigger.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class UpdateTriggerServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class UpdateTriggerServerError(GenAiError): + r"""Server Error""" + + data: UpdateTriggerServerErrorData = field(hash=False) + + def __init__( + self, + data: UpdateTriggerServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class UpdateTriggerClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class UpdateTriggerClientError(GenAiError): + r"""Client Error""" + + data: UpdateTriggerClientErrorData = field(hash=False) + + def __init__( + self, + data: UpdateTriggerClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/errors/updatewebhook.py b/google/genai/_gaos/errors/updatewebhook.py new file mode 100644 index 000000000..bbc2cd538 --- /dev/null +++ b/google/genai/_gaos/errors/updatewebhook.py @@ -0,0 +1,71 @@ +# 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 GenAiError +from ..types import BaseModel +from ..types.interactions import error as interactions_error +from dataclasses import dataclass, field +import httpx +from typing import Optional + + +class UpdateWebhookServerErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class UpdateWebhookServerError(GenAiError): + r"""Server Error""" + + data: UpdateWebhookServerErrorData = field(hash=False) + + def __init__( + self, + data: UpdateWebhookServerErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) + + +class UpdateWebhookClientErrorData(BaseModel): + error: interactions_error.Error + r"""Error message from an interaction.""" + + +@dataclass(unsafe_hash=True) +class UpdateWebhookClientError(GenAiError): + r"""Client Error""" + + data: UpdateWebhookClientErrorData = field(hash=False) + + def __init__( + self, + data: UpdateWebhookClientErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + object.__setattr__(self, "data", data) diff --git a/google/genai/_gaos/google_genai.py b/google/genai/_gaos/google_genai.py index dc9b3e44c..52fe5689c 100644 --- a/google/genai/_gaos/google_genai.py +++ b/google/genai/_gaos/google_genai.py @@ -223,9 +223,20 @@ class GeminiNextGenInteractions(GeneratedInteractions): """ def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + # api_version is a hidden global on the generated client; a per-call + # override routes through a client built for that version. + if api_version: + sdk = build_google_genai_client( + self._google_genai_api_client, api_version + ) + return GeneratedInteractions(sdk.sdk_configuration, parent_ref=sdk) + return super(GeminiNextGenInteractions, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -254,11 +265,11 @@ def create( if request is not None: if body: raise TypeError(_REQUEST_AND_BODY_ERROR) + request = _unwrap_create_request(request) stream = _request_stream(request) response = wrap_sdk_call( - super().create, + self._generated(api_version).create, request=request, - api_version=api_version, extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, @@ -273,8 +284,7 @@ def create( stream = _optional_bool(body.get('stream'), default=False) body = _normalize_create_body(body) response = wrap_sdk_call( - super().create, - api_version=api_version, + self._generated(api_version).create, **cast(Any, body), extra_headers=extra_headers, extra_query=extra_query, @@ -306,9 +316,8 @@ def get( ]: stream_bool = bool(_optional_bool(stream, default=False)) response = wrap_sdk_call( - super().get, + self._generated(api_version).get, id=id, - api_version=api_version, include_input=_optional_bool(include_input), last_event_id=_optional_str(last_event_id), stream=stream_bool, @@ -341,9 +350,8 @@ def cancel( interactions.Interaction, _add_output_properties_if_interaction( wrap_sdk_call( - super().cancel, + self._generated(api_version).cancel, id=id, - api_version=api_version, extra_headers=extra_headers, extra_query=extra_query, timeout=timeout, @@ -362,9 +370,8 @@ def delete( timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Any: return wrap_sdk_call( - super().delete, + self._generated(api_version).delete, id=id, - api_version=api_version, extra_headers=extra_headers, extra_query=extra_query, timeout=timeout, @@ -375,9 +382,20 @@ class AsyncGeminiNextGenInteractions(GeneratedAsyncInteractions): """Async public interactions resource backed by the NextGen client.""" def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_async_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_async_client( + self._google_genai_api_client, api_version + ) + return GeneratedAsyncInteractions( + sdk.sdk_configuration, parent_ref=sdk + ) + return super(AsyncGeminiNextGenInteractions, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -406,11 +424,11 @@ async def create( if request is not None: if body: raise TypeError(_REQUEST_AND_BODY_ERROR) + request = _unwrap_create_request(request) stream = _request_stream(request) response = await async_wrap_sdk_call( - super().create, + self._generated(api_version).create, request=request, - api_version=api_version, extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, @@ -425,8 +443,7 @@ async def create( stream = _optional_bool(body.get('stream'), default=False) body = _normalize_create_body(body) response = await async_wrap_sdk_call( - super().create, - api_version=api_version, + self._generated(api_version).create, **cast(Any, body), extra_headers=extra_headers, extra_query=extra_query, @@ -458,9 +475,8 @@ async def get( ]: stream_bool = bool(_optional_bool(stream, default=False)) response = await async_wrap_sdk_call( - super().get, + self._generated(api_version).get, id=id, - api_version=api_version, include_input=_optional_bool(include_input), last_event_id=_optional_str(last_event_id), stream=stream_bool, @@ -493,9 +509,8 @@ async def cancel( interactions.Interaction, _add_output_properties_if_interaction( await async_wrap_sdk_call( - super().cancel, + self._generated(api_version).cancel, id=id, - api_version=api_version, extra_headers=extra_headers, extra_query=extra_query, timeout=timeout, @@ -514,9 +529,8 @@ async def delete( timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Any: return await async_wrap_sdk_call( - super().delete, + self._generated(api_version).delete, id=id, - api_version=api_version, extra_headers=extra_headers, extra_query=extra_query, timeout=timeout, @@ -533,9 +547,18 @@ class GeminiNextGenWebhooks(GeneratedWebhooks): """ def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_client( + self._google_genai_api_client, api_version + ) + return GeneratedWebhooks(sdk.sdk_configuration, parent_ref=sdk) + return super(GeminiNextGenWebhooks, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -571,9 +594,18 @@ class AsyncGeminiNextGenWebhooks(GeneratedAsyncWebhooks): """Async public webhooks resource backed by the NextGen client.""" def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_async_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_async_client( + self._google_genai_api_client, api_version + ) + return GeneratedAsyncWebhooks(sdk.sdk_configuration, parent_ref=sdk) + return super(AsyncGeminiNextGenWebhooks, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -617,9 +649,18 @@ class GeminiNextGenAgents(GeneratedAgents): """ def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_client( + self._google_genai_api_client, api_version + ) + return GeneratedAgents(sdk.sdk_configuration, parent_ref=sdk) + return super(GeminiNextGenAgents, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -646,9 +687,18 @@ class AsyncGeminiNextGenAgents(GeneratedAsyncAgents): """Async public agents resource backed by the NextGen client.""" def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_async_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_async_client( + self._google_genai_api_client, api_version + ) + return GeneratedAsyncAgents(sdk.sdk_configuration, parent_ref=sdk) + return super(AsyncGeminiNextGenAgents, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -681,9 +731,18 @@ class GeminiNextGenTriggers(GeneratedTriggers): """ def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_client( + self._google_genai_api_client, api_version + ) + return GeneratedTriggers(sdk.sdk_configuration, parent_ref=sdk) + return super(GeminiNextGenTriggers, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -723,9 +782,18 @@ class AsyncGeminiNextGenTriggers(GeneratedAsyncTriggers): """Async public triggers resource backed by the NextGen client.""" def __init__(self, api_client: Any): + self._google_genai_api_client = api_client sdk = build_google_genai_async_client(api_client) super().__init__(sdk.sdk_configuration, parent_ref=sdk) + def _generated(self, api_version: Optional[str] = None) -> Any: + if api_version: + sdk = build_google_genai_async_client( + self._google_genai_api_client, api_version + ) + return GeneratedAsyncTriggers(sdk.sdk_configuration, parent_ref=sdk) + return super(AsyncGeminiNextGenTriggers, self) + if not TYPE_CHECKING: @property def with_raw_response(self): @@ -801,8 +869,13 @@ def delete_environment(self, *args: Any, **kwargs: Any) -> Any: 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) + # get_environment_files exists only in the internal generation + # (internal/genai-next); the public spec does not emit it. Wrap it + # only when the generated resource provides it so the bridge never + # exposes a method that would fail on super(). + if hasattr(GeneratedEnvironments, "get_environment_files"): + 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. @@ -847,8 +920,9 @@ async def delete_environment(self, *args: Any, **kwargs: Any) -> Any: 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) + if hasattr(GeneratedAsyncEnvironments, "get_environment_files"): + 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: @@ -971,7 +1045,6 @@ 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( @@ -990,6 +1063,12 @@ def _get_value(value: Any, name: str) -> Any: ) +def _normalize_content_item(item: Any) -> Any: + if isinstance(item, dict) and 'text' in item and 'type' not in item: + return {'type': 'text', **item} + return item + + def _normalize_create_body(body: dict[str, Any]) -> dict[str, Any]: unknown = set(body) - _CREATE_BODY_KEYS if unknown: @@ -1000,10 +1079,21 @@ def _normalize_create_body(body: dict[str, Any]) -> dict[str, Any]: ) input_value = body.get('input') - if not _is_content_list(input_value): - return body + if _is_content_list(input_value): + normalized_content = [_normalize_content_item(item) for item in input_value] + return {**body, 'input': [{'type': 'user_input', 'content': normalized_content}]} + + if isinstance(input_value, list): + normalized_steps = [] + for step in input_value: + if isinstance(step, dict) and isinstance(step.get('content'), list): + norm_c = [_normalize_content_item(item) for item in step['content']] + normalized_steps.append({**step, 'content': norm_c}) + else: + normalized_steps.append(step) + return {**body, 'input': normalized_steps} - return {**body, 'input': [{'type': 'user_input', 'content': input_value}]} + return body def _is_content_list(value: Any) -> bool: @@ -1058,12 +1148,22 @@ def _optional_str(value: Any) -> Optional[str]: return None +def _unwrap_create_request(request: Any) -> Any: + # The published `request=` overload takes the operation-shaped + # `{"body": }`; the generated create() (api_version is a + # hidden global, so the operation has no other parameters) takes the + # create params directly. Accept both and hand the generated method the + # body payload. + if isinstance(request, Mapping): + if 'body' in request: + return request['body'] + return request + body = getattr(request, 'body', None) + return request if body is None else body + + def _request_stream(request: Any) -> bool: - body = ( - request.get('body') - if isinstance(request, Mapping) - else getattr(request, 'body', None) - ) + body = _unwrap_create_request(request) stream = ( body.get('stream') if isinstance(body, Mapping) diff --git a/google/genai/_gaos/interactions.py b/google/genai/_gaos/interactions.py index 52fe581f6..19534371d 100644 --- a/google/genai/_gaos/interactions.py +++ b/google/genai/_gaos/interactions.py @@ -20,6 +20,9 @@ from ._hooks import AfterParseErrorContext, HookContext, ResponseContext from .basesdk import AsyncBaseSDK, BaseSDK from .types import BaseModel, OptionalNullable, UNSET, interactions +from .types.interactions import ( + createinteractionrequest as interactions_createinteractionrequest, +) from .utils import get_security_from_env, response_helpers from .utils.eventstreaming import AsyncStream, Stream from .utils.unmarshal_json_response import unmarshal_json_response @@ -41,19 +44,17 @@ def create( self, *, request: Union[ - models.CreateInteractionRequest, models.CreateInteractionRequestParam + interactions_createinteractionrequest.CreateInteractionRequest, + interactions_createinteractionrequest.CreateInteractionRequestParam, ], 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, ) -> Union[interactions.Interaction, Stream[interactions.InteractionSSEEvent]]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. - - :param body: The request body. - :param api_version: Which version of the API to use. + :param request: The request object to send. :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. @@ -64,51 +65,53 @@ def create( def create( self, *, - api_version: Optional[str] = None, - model: interactions.Model, - stream: Union[Literal[False], None] = None, - store: bool = ..., background: bool = ..., + environment: interactions.CreateModelInteractionEnvironmentParam = ..., + generation_config: interactions.GenerationConfigParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateModelInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Union[Literal[False], None] = None, system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateModelInteractionResponseFormatParam = ..., - environment: interactions.CreateModelInteractionEnvironmentParam = ..., - generation_config: interactions.GenerationConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + model: interactions.Model, 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, ) -> interactions.Interaction: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. :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. @@ -119,51 +122,53 @@ def create( def create( self, *, - api_version: Optional[str] = None, - model: interactions.Model, - stream: Literal[True], - store: bool = ..., background: bool = ..., + environment: interactions.CreateModelInteractionEnvironmentParam = ..., + generation_config: interactions.GenerationConfigParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateModelInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Literal[True], system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateModelInteractionResponseFormatParam = ..., - environment: interactions.CreateModelInteractionEnvironmentParam = ..., - generation_config: interactions.GenerationConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + model: interactions.Model, 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, ) -> Stream[interactions.InteractionSSEEvent]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. :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. @@ -174,51 +179,53 @@ def create( def create( self, *, - api_version: Optional[str] = None, - agent: interactions.AgentOption, - stream: Union[Literal[False], None] = None, - store: bool = ..., + agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., background: bool = ..., + environment: interactions.CreateAgentInteractionEnvironmentParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Union[Literal[False], None] = None, system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., - environment: interactions.CreateAgentInteractionEnvironmentParam = ..., - agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + agent: interactions.AgentOption, 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, ) -> interactions.Interaction: - r"""Creating an interaction - - Creates a new interaction. + r"""Generates a set of responses from the model. - :param api_version: Which version of the API to use. - :param agent: The agent to interact with. - :param stream: Input only. Whether the interaction will be streamed. - :param store: Input only. Whether to store the response and request for later retrieval. + :param agent_config: Parameters for the agent interaction. :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: + :param store: Input only. Whether to store the response and request for later retrieval. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param agent_config: Configuration parameters for the agent interaction. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param agent: The agent to interact with. :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. @@ -229,51 +236,53 @@ def create( def create( self, *, - api_version: Optional[str] = None, - agent: interactions.AgentOption, - stream: Literal[True], - store: bool = ..., + agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., background: bool = ..., + environment: interactions.CreateAgentInteractionEnvironmentParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Literal[True], system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., - environment: interactions.CreateAgentInteractionEnvironmentParam = ..., - agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + agent: interactions.AgentOption, 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, ) -> Stream[interactions.InteractionSSEEvent]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. - - :param api_version: Which version of the API to use. - :param agent: The agent to interact with. - :param stream: Input only. Whether the interaction will be streamed. - :param store: Input only. Whether to store the response and request for later retrieval. + :param agent_config: Parameters for the agent interaction. :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: + :param store: Input only. Whether to store the response and request for later retrieval. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param agent_config: Configuration parameters for the agent interaction. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param agent: The agent to interact with. :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. @@ -285,39 +294,44 @@ def create( self, *, request: OptionalNullable[ - Union[models.CreateInteractionRequest, models.CreateInteractionRequestParam] + Union[ + interactions_createinteractionrequest.CreateInteractionRequest, + interactions_createinteractionrequest.CreateInteractionRequestParam, + ] ] = UNSET, - api_version: OptionalNullable[str] = UNSET, 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, **body_kwargs: Any, ) -> Union[interactions.Interaction, Stream[interactions.InteractionSSEEvent]]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + :param agent_config: Parameters for the agent interaction. :param agent: The agent to interact with. - :param agent_config: Configuration parameters for the agent interaction. :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. @@ -328,54 +342,59 @@ def create( self, *, request: OptionalNullable[ - Union[models.CreateInteractionRequest, models.CreateInteractionRequestParam] + Union[ + interactions_createinteractionrequest.CreateInteractionRequest, + interactions_createinteractionrequest.CreateInteractionRequestParam, + ] ] = UNSET, - api_version: OptionalNullable[str] = UNSET, 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, **body_kwargs: Any, ) -> Union[interactions.Interaction, Stream[interactions.InteractionSSEEvent]]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + :param agent_config: Parameters for the agent interaction. :param agent: The agent to interact with. - :param agent_config: Configuration parameters for the agent interaction. :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 """ - if "model" in body_kwargs and "agent" in body_kwargs: - raise ValueError("Cannot supply both 'model' and 'agent'.") - if "model" in body_kwargs and "agent_config" in body_kwargs: - raise ValueError("Cannot supply both 'model' and 'agent_config'.") - if "generation_config" in body_kwargs and "agent" in body_kwargs: - raise ValueError("Cannot supply both 'generation_config' and 'agent'.") if "generation_config" in body_kwargs and "agent_config" in body_kwargs: raise ValueError( "Cannot supply both 'generation_config' and 'agent_config'." ) + if "generation_config" in body_kwargs and "agent" in body_kwargs: + raise ValueError("Cannot supply both 'generation_config' and 'agent'.") + if "model" in body_kwargs and "agent_config" in body_kwargs: + raise ValueError("Cannot supply both 'model' and 'agent_config'.") + if "model" in body_kwargs and "agent" in body_kwargs: + raise ValueError("Cannot supply both 'model' and 'agent'.") base_url = None url_variables = None retries: OptionalNullable[utils.RetryConfig] = UNSET @@ -392,24 +411,19 @@ def create( if request is not UNSET: request = cast( - models.CreateInteractionRequest, + interactions.CreateInteractionRequest, request if isinstance(request, BaseModel) else utils.unmarshal( - cast(Any, request), models.CreateInteractionRequest + cast(Any, request), interactions.CreateInteractionRequest ), ) else: _body_kwargs = dict(body_kwargs) _body_kwargs = {k: v for k, v in _body_kwargs.items() if v is not UNSET} - _request_kwargs: dict[str, Any] = {"api_version": api_version} - _request_kwargs = { - k: v for k, v in _request_kwargs.items() if v is not UNSET - } - _request_kwargs["body"] = _body_kwargs request = cast( - models.CreateInteractionRequest, - utils.unmarshal(_request_kwargs, models.CreateInteractionRequest), + interactions.CreateInteractionRequest, + utils.unmarshal(_body_kwargs, interactions.CreateInteractionRequest), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -426,7 +440,7 @@ def create( request_has_query_params=True, user_agent_header="user-agent", accept_header_value="text/event-stream" - if getattr(getattr(request, "body", None), "stream", False) is True + if getattr(request, "stream", False) is True else "application/json", http_headers=http_headers, extra_query_params=extra_query, @@ -435,11 +449,11 @@ def create( ), security=self.sdk_configuration.security, get_serialized_body=lambda: utils.serialize_request_body( - request.body, + request, False, False, "json", - models.CreateInteractionRequestBody, + interactions.CreateInteractionRequest, extra_body=extra_body, ), allow_empty_value=None, @@ -525,152 +539,14 @@ def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "simple", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "input": "Hello, how are you?"\n }\'\n', - }, - { - "label": "simple", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n model="gemini-3.6-flash",\n input="Hello, how are you?",\n)\nprint(interaction.output_text)\n', - }, - { - "label": "simple", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Hello, how are you?',\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "multi_turn", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "input": [\n { "type": "user_input", "content": [{ "type": "text", "text": "Hello!" }] },\n { "type": "model_output", "content": [{ "type": "text", "text": "Hi there! How can I help you today?" }] },\n { "type": "user_input", "content": [{ "type": "text", "text": "What is the capital of France?" }] }\n ]\n }\'\n', - }, - { - "label": "multi_turn", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\nresponse = client.interactions.create(\n model="gemini-3.6-flash",\n input=[\n { "type": "user_input", "content": [{ "type": "text", "text": "Hello!" }] },\n { "type": "model_output", "content": [{ "type": "text", "text": "Hi there! How can I help you today?" }] },\n { "type": "user_input", "content": [{ "type": "text", "text": "What is the capital of France?" }] }\n ]\n)\nprint(response.output_text)\n', - }, - { - "label": "multi_turn", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: [\n { type: 'user_input', content: [{ type: 'text', text: 'Hello' }] },\n { type: 'model_output', content: [{ type: 'text', text: 'Hi there! How can I help you today?' }] },\n { type: 'user_input', content: [{ type: 'text', text: 'What is the capital of France?' }] }\n ]\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "multimodal_image", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "input": [\n {\n "type": "text",\n "text": "What is in this picture?"\n },\n {\n "type": "image",\n "data": "BASE64_ENCODED_IMAGE",\n "mime_type": "image/png"\n }\n ]\n }\'\n', - }, - { - "label": "multimodal_image", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\nresponse = client.interactions.create(\n model="gemini-3.6-flash",\n input=[\n { "type": "text", "text": "What is in this picture?" },\n { "type": "image", "data": "BASE64_ENCODED_IMAGE", "mime_type": "image/png" }\n ]\n)\nprint(response.output_text)\n', - }, - { - "label": "multimodal_image", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: [\n { type: 'text', text: 'What is in this picture?' },\n { type: 'image', data: 'BASE64_ENCODED_IMAGE', mime_type: 'image/png' }\n ]\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "function_calling", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "tools": [\n {\n "type": "function",\n "name": "get_weather",\n "description": "Get the current weather in a given location",\n "parameters": {\n "type": "object",\n "properties": {\n "location": {\n "type": "string",\n "description": "The city and state, e.g. San Francisco, CA"\n }\n },\n "required": [\n "location"\n ]\n }\n }\n ],\n "input": "What is the weather like in Boston, MA?"\n }\'\n', - }, - { - "label": "function_calling", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\nresponse = client.interactions.create(\n model="gemini-3.6-flash",\n tools=[{\n "type": "function",\n "name": "get_weather",\n "description": "Get the current weather in a given location",\n "parameters": {\n "type": "object",\n "properties": {\n "location": {\n "type": "string",\n "description": "The city and state, e.g. San Francisco, CA"\n }\n },\n "required": ["location"]\n }\n }],\n input="What is the weather like in Boston, MA?"\n)\nprint(response.steps[-1])\n', - }, - { - "label": "function_calling", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n tools: [{\n type: 'function',\n name: 'get_weather',\n description: 'Get the current weather in a given location',\n parameters: {\n type: 'object',\n properties: {\n location: {\n type: 'string',\n description: 'The city and state, e.g. San Francisco, CA'\n }\n },\n required: ['location']\n }\n }],\n input: 'What is the weather like in Boston, MA?'\n});\nconsole.log(interaction.steps.at(-1));\n", - }, - { - "label": "deep_research", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "deep-research-pro-preview-12-2025",\n "input": "Find a cure to cancer",\n "background": true\n }\'\n', - }, - { - "label": "deep_research", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n agent="deep-research-pro-preview-12-2025",\n input="find a cure to cancer",\n background=True,\n)\nprint(interaction.status)\n', - }, - { - "label": "deep_research", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n agent: 'deep-research-pro-preview-12-2025',\n input: 'find a cure to cancer',\n background: true,\n});\nconsole.log(interaction.status);\n", - }, - { - "label": "antigravity", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "Read Hacker News, summarize the top 5 stories, and save results as a markdown file.",\n "environment": "remote"\n }\'\n', - }, - { - "label": "antigravity", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Read Hacker News, summarize the top 5 stories, and save results as a markdown file.",\n environment="remote",\n)\nprint(interaction.output_text)\n', - }, - { - "label": "antigravity", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Read Hacker News, summarize the top 5 stories, and save results as a markdown file.',\n environment: 'remote',\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "reuse_env", - "lang": "sh", - "source": '# Step 1: Create an interaction with a fresh remote environment.\nRESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -H "Api-Revision: 2026-05-20" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "Write a hello world script at /workspace/hello.py.",\n "environment": "remote"\n }\')\nINTERACTION_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\nENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)[\'environment_id\'])")\n\n# Step 2: Reuse the same environment in a follow-up interaction.\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{\n \\"agent\\": \\"antigravity-preview-05-2026\\",\n \\"input\\": \\"Modify the script to accept a name argument and greet the user.\\",\n \\"environment\\": \\"$ENV_ID\\",\n \\"previous_interaction_id\\": \\"$INTERACTION_ID\\"\n }"\n', - }, - { - "label": "reuse_env", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# Step 1: Create an interaction with a fresh remote environment.\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Write a hello world script at /workspace/hello.py.",\n environment="remote",\n)\nprint(f"Environment ID: {interaction.environment_id}")\n\n# Step 2: Reuse the same environment in a follow-up interaction.\ninteraction_2 = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Modify the script to accept a name argument and greet the user.",\n environment=interaction.environment_id,\n previous_interaction_id=interaction.id,\n)\nprint(interaction_2.output_text)\n', - }, - { - "label": "reuse_env", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Step 1: Create an interaction with a fresh remote environment.\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Write a hello world script at /workspace/hello.py.',\n environment: 'remote',\n});\nconsole.log(`Environment ID: ${interaction.environment_id}`);\n\n// Step 2: Reuse the same environment in a follow-up interaction.\nconst interaction2 = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Modify the script to accept a name argument and greet the user.',\n environment: interaction.environment_id,\n previous_interaction_id: interaction.id,\n});\nconsole.log(interaction2.output_text);\n", - }, - { - "label": "with_sources", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "List all files under /workspace and summarize what you find.",\n "environment": {\n "type": "remote",\n "sources": [\n {\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo"\n },\n {\n "type": "inline",\n "content": "Focus on Python files only.",\n "target": "/workspace/notes.txt"\n }\n ]\n }\n }\'\n', - }, - { - "label": "with_sources", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="List all files under /workspace and summarize what you find.",\n environment={\n "type": "remote",\n "sources": [\n {\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo",\n },\n {\n "type": "inline",\n "content": "Focus on Python files only.",\n "target": "/workspace/notes.txt",\n },\n ],\n },\n)\nprint(interaction.output_text)\n', - }, - { - "label": "with_sources", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'List all files under /workspace and summarize what you find.',\n environment: {\n type: 'remote',\n sources: [\n {\n type: 'repository',\n source: 'https://github.com/octocat/Spoon-Knife',\n target: '/workspace/repo',\n },\n {\n type: 'inline',\n content: 'Focus on Python files only.',\n target: '/workspace/notes.txt',\n },\n ],\n },\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "custom_agent", - "lang": "sh", - "source": '# Step 1: Create a custom agent.\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "id": "code-reviewer",\n "base_agent": "antigravity-preview-05-2026",\n "system_instruction": "You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",\n "base_environment": {\n "type": "remote",\n "sources": [{\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo"\n }]\n }\n }\'\n\n# Step 2: Use the custom agent.\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "code-reviewer",\n "input": "Review the latest changes in /workspace/repo/src and file a summary.",\n "environment": "remote"\n }\'\n', - }, - { - "label": "custom_agent", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Step 1: Create a custom agent.\nagent_id = f"code-reviewer-{uuid.uuid4().hex[:8]}"\nclient.agents.create(\n id=agent_id,\n base_agent="antigravity-preview-05-2026",\n system_instruction="You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",\n base_environment={\n "type": "remote",\n "sources": [{\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo",\n }],\n },\n)\n\n# Step 2: Use the custom agent.\nresult = client.interactions.create(\n agent=agent_id,\n input="Review the latest changes in /workspace/repo/src and file a summary.",\n environment="remote",\n)\nprint(result.output_text)\n\n# [cleanup]\nclient.agents.delete(agent_id)\n# [/cleanup]\n', - }, - { - "label": "custom_agent", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Step 1: Create a custom agent.\nconst agentId = `code-reviewer-${crypto.randomUUID().slice(0, 8)}`;\nawait ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n system_instruction: 'You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.',\n base_environment: {\n type: 'remote',\n sources: [{\n type: 'repository',\n source: 'https://github.com/octocat/Spoon-Knife',\n target: '/workspace/repo',\n }],\n },\n});\n\n// Step 2: Use the custom agent.\nconst result = await ai.interactions.create({\n agent: agentId,\n input: 'Review the latest changes in /workspace/repo/src and file a summary.',\n environment: 'remote',\n});\nconsole.log(result.output_text);\n\n// [cleanup]\nawait ai.agents.delete(agentId);\n// [/cleanup]\n", - }, - ] - }, + 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=getattr(getattr(request, "body", None), "stream", False) is True + stream=getattr(request, "stream", False) is True or _speakeasy_response_mode == "streaming", retry_config=retry_config, ) @@ -698,8 +574,7 @@ def _speakeasy_parse_response(http_res): parser=_speakeasy_parse_response, mode=( "event_stream" - if getattr(getattr(request, "body", None), "stream", False) - is True + if getattr(request, "stream", False) is True else "buffered" ), client_ref=self, @@ -722,23 +597,21 @@ def get( self, id: str, *, - stream: Union[Literal[False], None] = None, + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: Union[Literal[False], None] = None, extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> interactions.Interaction: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -749,23 +622,21 @@ def get( self, id: str, *, - stream: Literal[True], + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: Literal[True], extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Stream[interactions.InteractionSSEEvent]: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -776,23 +647,21 @@ def get( self, id: str, *, - stream: bool, + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: bool, extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Union[interactions.Interaction, Stream[interactions.InteractionSSEEvent]]: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -802,23 +671,21 @@ def get( self, id: str, *, - stream: Optional[bool] = False, + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: Optional[bool] = None, extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Union[interactions.Interaction, Stream[interactions.InteractionSSEEvent]]: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -838,11 +705,10 @@ def get( base_url = self._get_url(base_url, url_variables) request = models.GetInteractionByIDRequest( + include_input=include_input, id=id, - stream=stream, last_event_id=last_event_id, - include_input=include_input, - api_version=api_version, + stream=stream, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -850,7 +716,7 @@ def get( ) req = self._build_request( method="GET", - path="/{api_version}/interactions/{id}", + path="/{api_version}/interactions/{interactionsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -954,25 +820,7 @@ def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "get", - "lang": "sh", - "source": '# [setup]\nINTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -H "Api-Revision: 2026-05-20" \\\n -d \'{"model": "gemini-3.6-flash", "input": "Say hello."}\' \\\n | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\n# [/setup]\n\ncurl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Api-Revision: 2026-05-20"\n', - }, - { - "label": "get", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# [setup]\ncreated = client.interactions.create(\n model="gemini-3.6-flash",\n input="Say hello."\n)\n# [/setup]\n\ninteraction = client.interactions.get(id=created.id)\nprint(interaction.status)\n', - }, - { - "label": "get", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// [setup]\nconst created = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Say hello.'\n});\n// [/setup]\n\nconst interaction = await ai.interactions.get(created.id);\nconsole.log(interaction.status);\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -1024,17 +872,14 @@ def delete( 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, ): - r"""Deleting an interaction + r"""Deletes an interaction. - Deletes the interaction by id. - - :param id: The unique identifier of the interaction to delete. - :param api_version: Which version of the API to use. + :param id: Part of `name`. Required. The name of the interaction to delete. + Format: interactions/{interaction} :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 @@ -1055,7 +900,6 @@ def delete( request = models.DeleteInteractionRequest( id=id, - api_version=api_version, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -1063,7 +907,7 @@ def delete( ) req = self._build_request( method="DELETE", - path="/{api_version}/interactions/{id}", + path="/{api_version}/interactions/{interactionsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -1137,25 +981,7 @@ def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "delete", - "lang": "sh", - "source": '# [setup]\nINTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\ -d \'{"model": "gemini-3.6-flash", "input": "Hello"}\' \\\n | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\n# [/setup]\n\ncurl -X DELETE "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "delete", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# [setup]\ncreated = client.interactions.create(\n model="gemini-3.6-flash",\n input="Hello",\n)\n# [/setup]\n\nclient.interactions.delete(id=created.id)\nprint("Interaction deleted successfully.")\n', - }, - { - "label": "delete", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// [setup]\nconst created = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Hello',\n});\n// [/setup]\n\nawait ai.interactions.delete(created.id);\nconsole.log('Interaction deleted successfully.');\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -1207,17 +1033,14 @@ def cancel( 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.Interaction: - r"""Canceling an interaction - - Cancels an interaction by id. This only applies to background interactions that are still running. + r"""Cancels an interaction. - :param id: The unique identifier of the interaction to cancel. - :param api_version: Which version of the API to use. + :param id: Part of `name`. Required. The name of the interaction to cancel. + Format: `interactions/{interaction}`. :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 @@ -1238,7 +1061,6 @@ def cancel( request = models.CancelInteractionByIDRequest( id=id, - api_version=api_version, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -1246,7 +1068,7 @@ def cancel( ) req = self._build_request( method="POST", - path="/{api_version}/interactions/{id}/cancel", + path="/{api_version}/interactions/{interactionsId}/cancel", base_url=base_url, url_variables=url_variables, request=request, @@ -1282,10 +1104,6 @@ def cancel( def _speakeasy_parse_response(http_res): response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return unmarshal_json_response( - interactions.Interaction, http_res, validate=False - ) if utils.match_response(http_res, "4XX", "application/json"): try: response_data = unmarshal_json_response( @@ -1314,6 +1132,10 @@ def _speakeasy_parse_response(http_res): http_res, http_res.text, ) from e + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + interactions.Interaction, http_res, validate=False + ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1326,25 +1148,7 @@ def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "cancel", - "lang": "sh", - "source": '# [setup]\nINTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\ -d \'{"model": "gemini-3.6-flash", "input": "Write a long essay about the history of computing.", "background": true}\' \\\n | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\n# [/setup]\n\ncurl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID/cancel" \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "cancel", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# Start a background interaction so it stays in-progress.\ncreated = client.interactions.create(\n model="gemini-3.6-flash",\n input="Write a long essay about the history of computing.",\n tools=[{"type": "computer_use"}],\n background=True,\n)\n\n# Cancel the in-progress interaction.\ninteraction = client.interactions.cancel(id=created.id)\nprint(interaction.status)\n', - }, - { - "label": "cancel", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Start a background interaction so it stays in-progress.\nconst created = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Write a long essay about the history of computing.',\n tools: [{ type: 'computer_use' }],\n background: true,\n});\n\n// Cancel the in-progress interaction.\nconst interaction = await ai.interactions.cancel(created.id);\nconsole.log(interaction.status);\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="sync"), ) http_res = self.do_request( @@ -1439,19 +1243,17 @@ async def create( self, *, request: Union[ - models.CreateInteractionRequest, models.CreateInteractionRequestParam + interactions_createinteractionrequest.CreateInteractionRequest, + interactions_createinteractionrequest.CreateInteractionRequestParam, ], 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, ) -> Union[interactions.Interaction, AsyncStream[interactions.InteractionSSEEvent]]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. - - :param body: The request body. - :param api_version: Which version of the API to use. + :param request: The request object to send. :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. @@ -1462,51 +1264,53 @@ async def create( async def create( self, *, - api_version: Optional[str] = None, - model: interactions.Model, - stream: Union[Literal[False], None] = None, - store: bool = ..., background: bool = ..., + environment: interactions.CreateModelInteractionEnvironmentParam = ..., + generation_config: interactions.GenerationConfigParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateModelInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Union[Literal[False], None] = None, system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateModelInteractionResponseFormatParam = ..., - environment: interactions.CreateModelInteractionEnvironmentParam = ..., - generation_config: interactions.GenerationConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + model: interactions.Model, 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, ) -> interactions.Interaction: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. :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. @@ -1517,51 +1321,53 @@ async def create( async def create( self, *, - api_version: Optional[str] = None, - model: interactions.Model, - stream: Literal[True], - store: bool = ..., background: bool = ..., + environment: interactions.CreateModelInteractionEnvironmentParam = ..., + generation_config: interactions.GenerationConfigParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateModelInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Literal[True], system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateModelInteractionResponseFormatParam = ..., - environment: interactions.CreateModelInteractionEnvironmentParam = ..., - generation_config: interactions.GenerationConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + model: interactions.Model, 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, ) -> AsyncStream[interactions.InteractionSSEEvent]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. :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. @@ -1572,51 +1378,53 @@ async def create( async def create( self, *, - api_version: Optional[str] = None, - agent: interactions.AgentOption, - stream: Union[Literal[False], None] = None, - store: bool = ..., + agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., background: bool = ..., + environment: interactions.CreateAgentInteractionEnvironmentParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Union[Literal[False], None] = None, system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., - environment: interactions.CreateAgentInteractionEnvironmentParam = ..., - agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + agent: interactions.AgentOption, 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, ) -> interactions.Interaction: - r"""Creating an interaction - - Creates a new interaction. + r"""Generates a set of responses from the model. - :param api_version: Which version of the API to use. - :param agent: The agent to interact with. - :param stream: Input only. Whether the interaction will be streamed. - :param store: Input only. Whether to store the response and request for later retrieval. + :param agent_config: Parameters for the agent interaction. :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: + :param store: Input only. Whether to store the response and request for later retrieval. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param agent_config: Configuration parameters for the agent interaction. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param agent: The agent to interact with. :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. @@ -1627,51 +1435,53 @@ async def create( async def create( self, *, - api_version: Optional[str] = None, - agent: interactions.AgentOption, - stream: Literal[True], - store: bool = ..., + agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., background: bool = ..., + environment: interactions.CreateAgentInteractionEnvironmentParam = ..., + labels: Dict[str, str] = ..., + previous_interaction_id: str = ..., + response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., + safety_settings: List[interactions.SafetySettingParam] = ..., + service_tier: interactions.ServiceTier = ..., + store: bool = ..., + stream: Literal[True], system_instruction: str = ..., tools: List[interactions.ToolParam] = ..., + webhook_config: interactions.WebhookConfigParam = ..., response_modalities: List[interactions.ResponseModality] = ..., response_mime_type: str = ..., - previous_interaction_id: str = ..., - service_tier: interactions.ServiceTier = ..., - webhook_config: interactions.WebhookConfigParam = ..., - response_format: interactions.CreateAgentInteractionResponseFormatParam = ..., - environment: interactions.CreateAgentInteractionEnvironmentParam = ..., - agent_config: interactions.CreateAgentInteractionAgentConfigParam = ..., - safety_settings: List[interactions.SafetySettingParam] = ..., - labels: Dict[str, str] = ..., - input: interactions.InteractionsInputParam, + input: interactions.InteractionsInputParam = ..., + agent: interactions.AgentOption, 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, ) -> AsyncStream[interactions.InteractionSSEEvent]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. - - :param api_version: Which version of the API to use. - :param agent: The agent to interact with. - :param stream: Input only. Whether the interaction will be streamed. - :param store: Input only. Whether to store the response and request for later retrieval. + :param agent_config: Parameters for the agent interaction. :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: + :param store: Input only. Whether to store the response and request for later retrieval. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param agent_config: Configuration parameters for the agent interaction. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param agent: The agent to interact with. :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. @@ -1683,39 +1493,44 @@ async def create( self, *, request: OptionalNullable[ - Union[models.CreateInteractionRequest, models.CreateInteractionRequestParam] + Union[ + interactions_createinteractionrequest.CreateInteractionRequest, + interactions_createinteractionrequest.CreateInteractionRequestParam, + ] ] = UNSET, - api_version: OptionalNullable[str] = UNSET, 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, **body_kwargs: Any, ) -> Union[interactions.Interaction, AsyncStream[interactions.InteractionSSEEvent]]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + :param agent_config: Parameters for the agent interaction. :param agent: The agent to interact with. - :param agent_config: Configuration parameters for the agent interaction. :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. @@ -1726,54 +1541,59 @@ async def create( self, *, request: OptionalNullable[ - Union[models.CreateInteractionRequest, models.CreateInteractionRequestParam] + Union[ + interactions_createinteractionrequest.CreateInteractionRequest, + interactions_createinteractionrequest.CreateInteractionRequestParam, + ] ] = UNSET, - api_version: OptionalNullable[str] = UNSET, 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, **body_kwargs: Any, ) -> Union[interactions.Interaction, AsyncStream[interactions.InteractionSSEEvent]]: - r"""Creating an interaction + r"""Generates a set of responses from the model. - Creates a new interaction. + :param background: Input only. Whether to run the model interaction in the background. + :param environment: The environment configuration for the interaction. + :param generation_config: Configuration parameters for model interactions. + :param labels: The labels with user-defined metadata for the request. It is used for + billing and reporting only. - :param api_version: Which version of the API to use. - :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. - :param stream: Input only. Whether the interaction will be streamed. + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + :param previous_interaction_id: The ID of the previous interaction, if any. + :param response_format: + :param safety_settings: Safety settings for the interaction. + :param service_tier: :param store: Input only. Whether to store the response and request for later retrieval. - :param background: Input only. Whether to run the model interaction in the background. + :param stream: Input only. Whether the interaction will be streamed. :param system_instruction: System instruction for the interaction. :param tools: A list of tool declarations the model may call during interaction. + :param webhook_config: Message for configuring webhook events for a request. :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO). :param response_mime_type: The mime type of the response. This is required if response_format is set. - :param previous_interaction_id: The ID of the previous interaction, if any. - :param service_tier: - :param webhook_config: Message for configuring webhook events for a request. - :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field. - :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. - :param generation_config: Configuration parameters for model interactions. - :param safety_settings: Safety settings for the interaction. - :param labels: The labels with user-defined metadata for the request. :param input: The input for the interaction. + :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + :param agent_config: Parameters for the agent interaction. :param agent: The agent to interact with. - :param agent_config: Configuration parameters for the agent interaction. :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 """ - if "model" in body_kwargs and "agent" in body_kwargs: - raise ValueError("Cannot supply both 'model' and 'agent'.") - if "model" in body_kwargs and "agent_config" in body_kwargs: - raise ValueError("Cannot supply both 'model' and 'agent_config'.") - if "generation_config" in body_kwargs and "agent" in body_kwargs: - raise ValueError("Cannot supply both 'generation_config' and 'agent'.") if "generation_config" in body_kwargs and "agent_config" in body_kwargs: raise ValueError( "Cannot supply both 'generation_config' and 'agent_config'." ) + if "generation_config" in body_kwargs and "agent" in body_kwargs: + raise ValueError("Cannot supply both 'generation_config' and 'agent'.") + if "model" in body_kwargs and "agent_config" in body_kwargs: + raise ValueError("Cannot supply both 'model' and 'agent_config'.") + if "model" in body_kwargs and "agent" in body_kwargs: + raise ValueError("Cannot supply both 'model' and 'agent'.") base_url = None url_variables = None retries: OptionalNullable[utils.RetryConfig] = UNSET @@ -1790,24 +1610,19 @@ async def create( if request is not UNSET: request = cast( - models.CreateInteractionRequest, + interactions.CreateInteractionRequest, request if isinstance(request, BaseModel) else utils.unmarshal( - cast(Any, request), models.CreateInteractionRequest + cast(Any, request), interactions.CreateInteractionRequest ), ) else: _body_kwargs = dict(body_kwargs) _body_kwargs = {k: v for k, v in _body_kwargs.items() if v is not UNSET} - _request_kwargs: dict[str, Any] = {"api_version": api_version} - _request_kwargs = { - k: v for k, v in _request_kwargs.items() if v is not UNSET - } - _request_kwargs["body"] = _body_kwargs request = cast( - models.CreateInteractionRequest, - utils.unmarshal(_request_kwargs, models.CreateInteractionRequest), + interactions.CreateInteractionRequest, + utils.unmarshal(_body_kwargs, interactions.CreateInteractionRequest), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -1824,7 +1639,7 @@ async def create( request_has_query_params=True, user_agent_header="user-agent", accept_header_value="text/event-stream" - if getattr(getattr(request, "body", None), "stream", False) is True + if getattr(request, "stream", False) is True else "application/json", http_headers=http_headers, extra_query_params=extra_query, @@ -1833,11 +1648,11 @@ async def create( ), security=self.sdk_configuration.security, get_serialized_body=lambda: utils.serialize_request_body( - request.body, + request, False, False, "json", - models.CreateInteractionRequestBody, + interactions.CreateInteractionRequest, extra_body=extra_body, ), allow_empty_value=None, @@ -1923,152 +1738,14 @@ async def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "simple", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "input": "Hello, how are you?"\n }\'\n', - }, - { - "label": "simple", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n model="gemini-3.6-flash",\n input="Hello, how are you?",\n)\nprint(interaction.output_text)\n', - }, - { - "label": "simple", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Hello, how are you?',\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "multi_turn", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "input": [\n { "type": "user_input", "content": [{ "type": "text", "text": "Hello!" }] },\n { "type": "model_output", "content": [{ "type": "text", "text": "Hi there! How can I help you today?" }] },\n { "type": "user_input", "content": [{ "type": "text", "text": "What is the capital of France?" }] }\n ]\n }\'\n', - }, - { - "label": "multi_turn", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\nresponse = client.interactions.create(\n model="gemini-3.6-flash",\n input=[\n { "type": "user_input", "content": [{ "type": "text", "text": "Hello!" }] },\n { "type": "model_output", "content": [{ "type": "text", "text": "Hi there! How can I help you today?" }] },\n { "type": "user_input", "content": [{ "type": "text", "text": "What is the capital of France?" }] }\n ]\n)\nprint(response.output_text)\n', - }, - { - "label": "multi_turn", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: [\n { type: 'user_input', content: [{ type: 'text', text: 'Hello' }] },\n { type: 'model_output', content: [{ type: 'text', text: 'Hi there! How can I help you today?' }] },\n { type: 'user_input', content: [{ type: 'text', text: 'What is the capital of France?' }] }\n ]\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "multimodal_image", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "input": [\n {\n "type": "text",\n "text": "What is in this picture?"\n },\n {\n "type": "image",\n "data": "BASE64_ENCODED_IMAGE",\n "mime_type": "image/png"\n }\n ]\n }\'\n', - }, - { - "label": "multimodal_image", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\nresponse = client.interactions.create(\n model="gemini-3.6-flash",\n input=[\n { "type": "text", "text": "What is in this picture?" },\n { "type": "image", "data": "BASE64_ENCODED_IMAGE", "mime_type": "image/png" }\n ]\n)\nprint(response.output_text)\n', - }, - { - "label": "multimodal_image", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: [\n { type: 'text', text: 'What is in this picture?' },\n { type: 'image', data: 'BASE64_ENCODED_IMAGE', mime_type: 'image/png' }\n ]\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "function_calling", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "model": "gemini-3.6-flash",\n "tools": [\n {\n "type": "function",\n "name": "get_weather",\n "description": "Get the current weather in a given location",\n "parameters": {\n "type": "object",\n "properties": {\n "location": {\n "type": "string",\n "description": "The city and state, e.g. San Francisco, CA"\n }\n },\n "required": [\n "location"\n ]\n }\n }\n ],\n "input": "What is the weather like in Boston, MA?"\n }\'\n', - }, - { - "label": "function_calling", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\nresponse = client.interactions.create(\n model="gemini-3.6-flash",\n tools=[{\n "type": "function",\n "name": "get_weather",\n "description": "Get the current weather in a given location",\n "parameters": {\n "type": "object",\n "properties": {\n "location": {\n "type": "string",\n "description": "The city and state, e.g. San Francisco, CA"\n }\n },\n "required": ["location"]\n }\n }],\n input="What is the weather like in Boston, MA?"\n)\nprint(response.steps[-1])\n', - }, - { - "label": "function_calling", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n tools: [{\n type: 'function',\n name: 'get_weather',\n description: 'Get the current weather in a given location',\n parameters: {\n type: 'object',\n properties: {\n location: {\n type: 'string',\n description: 'The city and state, e.g. San Francisco, CA'\n }\n },\n required: ['location']\n }\n }],\n input: 'What is the weather like in Boston, MA?'\n});\nconsole.log(interaction.steps.at(-1));\n", - }, - { - "label": "deep_research", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "deep-research-pro-preview-12-2025",\n "input": "Find a cure to cancer",\n "background": true\n }\'\n', - }, - { - "label": "deep_research", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n agent="deep-research-pro-preview-12-2025",\n input="find a cure to cancer",\n background=True,\n)\nprint(interaction.status)\n', - }, - { - "label": "deep_research", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n agent: 'deep-research-pro-preview-12-2025',\n input: 'find a cure to cancer',\n background: true,\n});\nconsole.log(interaction.status);\n", - }, - { - "label": "antigravity", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "Read Hacker News, summarize the top 5 stories, and save results as a markdown file.",\n "environment": "remote"\n }\'\n', - }, - { - "label": "antigravity", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Read Hacker News, summarize the top 5 stories, and save results as a markdown file.",\n environment="remote",\n)\nprint(interaction.output_text)\n', - }, - { - "label": "antigravity", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Read Hacker News, summarize the top 5 stories, and save results as a markdown file.',\n environment: 'remote',\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "reuse_env", - "lang": "sh", - "source": '# Step 1: Create an interaction with a fresh remote environment.\nRESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -H "Api-Revision: 2026-05-20" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "Write a hello world script at /workspace/hello.py.",\n "environment": "remote"\n }\')\nINTERACTION_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\nENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)[\'environment_id\'])")\n\n# Step 2: Reuse the same environment in a follow-up interaction.\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d "{\n \\"agent\\": \\"antigravity-preview-05-2026\\",\n \\"input\\": \\"Modify the script to accept a name argument and greet the user.\\",\n \\"environment\\": \\"$ENV_ID\\",\n \\"previous_interaction_id\\": \\"$INTERACTION_ID\\"\n }"\n', - }, - { - "label": "reuse_env", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# Step 1: Create an interaction with a fresh remote environment.\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Write a hello world script at /workspace/hello.py.",\n environment="remote",\n)\nprint(f"Environment ID: {interaction.environment_id}")\n\n# Step 2: Reuse the same environment in a follow-up interaction.\ninteraction_2 = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="Modify the script to accept a name argument and greet the user.",\n environment=interaction.environment_id,\n previous_interaction_id=interaction.id,\n)\nprint(interaction_2.output_text)\n', - }, - { - "label": "reuse_env", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Step 1: Create an interaction with a fresh remote environment.\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Write a hello world script at /workspace/hello.py.',\n environment: 'remote',\n});\nconsole.log(`Environment ID: ${interaction.environment_id}`);\n\n// Step 2: Reuse the same environment in a follow-up interaction.\nconst interaction2 = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'Modify the script to accept a name argument and greet the user.',\n environment: interaction.environment_id,\n previous_interaction_id: interaction.id,\n});\nconsole.log(interaction2.output_text);\n", - }, - { - "label": "with_sources", - "lang": "sh", - "source": 'curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "antigravity-preview-05-2026",\n "input": "List all files under /workspace and summarize what you find.",\n "environment": {\n "type": "remote",\n "sources": [\n {\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo"\n },\n {\n "type": "inline",\n "content": "Focus on Python files only.",\n "target": "/workspace/notes.txt"\n }\n ]\n }\n }\'\n', - }, - { - "label": "with_sources", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\ninteraction = client.interactions.create(\n agent="antigravity-preview-05-2026",\n input="List all files under /workspace and summarize what you find.",\n environment={\n "type": "remote",\n "sources": [\n {\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo",\n },\n {\n "type": "inline",\n "content": "Focus on Python files only.",\n "target": "/workspace/notes.txt",\n },\n ],\n },\n)\nprint(interaction.output_text)\n', - }, - { - "label": "with_sources", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\nconst interaction = await ai.interactions.create({\n agent: 'antigravity-preview-05-2026',\n input: 'List all files under /workspace and summarize what you find.',\n environment: {\n type: 'remote',\n sources: [\n {\n type: 'repository',\n source: 'https://github.com/octocat/Spoon-Knife',\n target: '/workspace/repo',\n },\n {\n type: 'inline',\n content: 'Focus on Python files only.',\n target: '/workspace/notes.txt',\n },\n ],\n },\n});\nconsole.log(interaction.output_text);\n", - }, - { - "label": "custom_agent", - "lang": "sh", - "source": '# Step 1: Create a custom agent.\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/agents \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "id": "code-reviewer",\n "base_agent": "antigravity-preview-05-2026",\n "system_instruction": "You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",\n "base_environment": {\n "type": "remote",\n "sources": [{\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo"\n }]\n }\n }\'\n\n# Step 2: Use the custom agent.\ncurl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "agent": "code-reviewer",\n "input": "Review the latest changes in /workspace/repo/src and file a summary.",\n "environment": "remote"\n }\'\n', - }, - { - "label": "custom_agent", - "lang": "python", - "source": 'import uuid\nfrom google import genai\n\nclient = genai.Client()\n\n# Step 1: Create a custom agent.\nagent_id = f"code-reviewer-{uuid.uuid4().hex[:8]}"\nclient.agents.create(\n id=agent_id,\n base_agent="antigravity-preview-05-2026",\n system_instruction="You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",\n base_environment={\n "type": "remote",\n "sources": [{\n "type": "repository",\n "source": "https://github.com/octocat/Spoon-Knife",\n "target": "/workspace/repo",\n }],\n },\n)\n\n# Step 2: Use the custom agent.\nresult = client.interactions.create(\n agent=agent_id,\n input="Review the latest changes in /workspace/repo/src and file a summary.",\n environment="remote",\n)\nprint(result.output_text)\n\n# [cleanup]\nclient.agents.delete(agent_id)\n# [/cleanup]\n', - }, - { - "label": "custom_agent", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Step 1: Create a custom agent.\nconst agentId = `code-reviewer-${crypto.randomUUID().slice(0, 8)}`;\nawait ai.agents.create({\n id: agentId,\n base_agent: 'antigravity-preview-05-2026',\n system_instruction: 'You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.',\n base_environment: {\n type: 'remote',\n sources: [{\n type: 'repository',\n source: 'https://github.com/octocat/Spoon-Knife',\n target: '/workspace/repo',\n }],\n },\n});\n\n// Step 2: Use the custom agent.\nconst result = await ai.interactions.create({\n agent: agentId,\n input: 'Review the latest changes in /workspace/repo/src and file a summary.',\n environment: 'remote',\n});\nconsole.log(result.output_text);\n\n// [cleanup]\nawait ai.agents.delete(agentId);\n// [/cleanup]\n", - }, - ] - }, + 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=getattr(getattr(request, "body", None), "stream", False) is True + stream=getattr(request, "stream", False) is True or _speakeasy_response_mode == "streaming", retry_config=retry_config, ) @@ -2097,8 +1774,7 @@ async def _speakeasy_parse_response(http_res): parser=_speakeasy_parse_response, mode=( "event_stream" - if getattr(getattr(request, "body", None), "stream", False) - is True + if getattr(request, "stream", False) is True else "buffered" ), client_ref=self, @@ -2123,23 +1799,21 @@ async def get( self, id: str, *, - stream: Union[Literal[False], None] = None, + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: Union[Literal[False], None] = None, extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> interactions.Interaction: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -2150,23 +1824,21 @@ async def get( self, id: str, *, - stream: Literal[True], + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: Literal[True], extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> AsyncStream[interactions.InteractionSSEEvent]: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -2177,23 +1849,21 @@ async def get( self, id: str, *, - stream: bool, + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: bool, extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Union[interactions.Interaction, AsyncStream[interactions.InteractionSSEEvent]]: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -2203,23 +1873,21 @@ async def get( self, id: str, *, - stream: Optional[bool] = False, + include_input: Optional[bool] = None, last_event_id: Optional[str] = None, - include_input: Optional[bool] = False, - api_version: Optional[str] = None, + stream: Optional[bool] = None, extra_headers: Optional[Mapping[str, str]] = None, extra_query: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, ) -> Union[interactions.Interaction, AsyncStream[interactions.InteractionSSEEvent]]: - r"""Retrieving an interaction - - Retrieves the full details of a single interaction based on its `Interaction.id`. - - :param id: The unique identifier of the interaction to retrieve. - :param stream: If set to true, the generated content will be streamed incrementally. - :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true. - :param include_input: If set to true, includes the input in the response. - :param api_version: Which version of the API to use. + r"""Gets an interaction. + + :param id: Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + :param include_input: If true, includes the input in the response. + :param last_event_id: If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + :param stream: If true, streams the interaction events as Server-Sent Events. :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 @@ -2239,11 +1907,10 @@ async def get( base_url = self._get_url(base_url, url_variables) request = models.GetInteractionByIDRequest( + include_input=include_input, id=id, - stream=stream, last_event_id=last_event_id, - include_input=include_input, - api_version=api_version, + stream=stream, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -2251,7 +1918,7 @@ async def get( ) req = self._build_request_async( method="GET", - path="/{api_version}/interactions/{id}", + path="/{api_version}/interactions/{interactionsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -2355,25 +2022,7 @@ async def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "get", - "lang": "sh", - "source": '# [setup]\nINTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\\n -H "Api-Revision: 2026-05-20" \\\n -d \'{"model": "gemini-3.6-flash", "input": "Say hello."}\' \\\n | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\n# [/setup]\n\ncurl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Api-Revision: 2026-05-20"\n', - }, - { - "label": "get", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# [setup]\ncreated = client.interactions.create(\n model="gemini-3.6-flash",\n input="Say hello."\n)\n# [/setup]\n\ninteraction = client.interactions.get(id=created.id)\nprint(interaction.status)\n', - }, - { - "label": "get", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// [setup]\nconst created = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Say hello.'\n});\n// [/setup]\n\nconst interaction = await ai.interactions.get(created.id);\nconsole.log(interaction.status);\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( @@ -2428,17 +2077,14 @@ async def delete( 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, ): - r"""Deleting an interaction + r"""Deletes an interaction. - Deletes the interaction by id. - - :param id: The unique identifier of the interaction to delete. - :param api_version: Which version of the API to use. + :param id: Part of `name`. Required. The name of the interaction to delete. + Format: interactions/{interaction} :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 @@ -2459,7 +2105,6 @@ async def delete( request = models.DeleteInteractionRequest( id=id, - api_version=api_version, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -2467,7 +2112,7 @@ async def delete( ) req = self._build_request_async( method="DELETE", - path="/{api_version}/interactions/{id}", + path="/{api_version}/interactions/{interactionsId}", base_url=base_url, url_variables=url_variables, request=request, @@ -2541,25 +2186,7 @@ async def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "delete", - "lang": "sh", - "source": '# [setup]\nINTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\ -d \'{"model": "gemini-3.6-flash", "input": "Hello"}\' \\\n | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\n# [/setup]\n\ncurl -X DELETE "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "delete", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# [setup]\ncreated = client.interactions.create(\n model="gemini-3.6-flash",\n input="Hello",\n)\n# [/setup]\n\nclient.interactions.delete(id=created.id)\nprint("Interaction deleted successfully.")\n', - }, - { - "label": "delete", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// [setup]\nconst created = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Hello',\n});\n// [/setup]\n\nawait ai.interactions.delete(created.id);\nconsole.log('Interaction deleted successfully.');\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( @@ -2614,17 +2241,14 @@ async def cancel( 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.Interaction: - r"""Canceling an interaction - - Cancels an interaction by id. This only applies to background interactions that are still running. + r"""Cancels an interaction. - :param id: The unique identifier of the interaction to cancel. - :param api_version: Which version of the API to use. + :param id: Part of `name`. Required. The name of the interaction to cancel. + Format: `interactions/{interaction}`. :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 @@ -2645,7 +2269,6 @@ async def cancel( request = models.CancelInteractionByIDRequest( id=id, - api_version=api_version, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -2653,7 +2276,7 @@ async def cancel( ) req = self._build_request_async( method="POST", - path="/{api_version}/interactions/{id}/cancel", + path="/{api_version}/interactions/{interactionsId}/cancel", base_url=base_url, url_variables=url_variables, request=request, @@ -2689,10 +2312,6 @@ async def cancel( async def _speakeasy_parse_response(http_res): response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return unmarshal_json_response( - interactions.Interaction, http_res, validate=False - ) if utils.match_response(http_res, "4XX", "application/json"): try: response_data = unmarshal_json_response( @@ -2721,6 +2340,10 @@ async def _speakeasy_parse_response(http_res): http_res, http_res.text, ) from e + if utils.match_response(http_res, "default", "application/json"): + return unmarshal_json_response( + interactions.Interaction, http_res, validate=False + ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -2733,25 +2356,7 @@ async def _speakeasy_parse_response(http_res): self.sdk_configuration.security, types.Security ), tags=None, - extensions={ - "x-codeSamples": [ - { - "label": "cancel", - "lang": "sh", - "source": '# [setup]\nINTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \\\n -H "x-goog-api-key: $GEMINI_API_KEY" \\\n -H "Content-Type: application/json" \\ -d \'{"model": "gemini-3.6-flash", "input": "Write a long essay about the history of computing.", "background": true}\' \\\n | python3 -c "import sys,json; print(json.load(sys.stdin)[\'id\'])")\n# [/setup]\n\ncurl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID/cancel" \\\n -H "x-goog-api-key: $GEMINI_API_KEY"\n', - }, - { - "label": "cancel", - "lang": "python", - "source": 'from google import genai\n\nclient = genai.Client()\n\n# Start a background interaction so it stays in-progress.\ncreated = client.interactions.create(\n model="gemini-3.6-flash",\n input="Write a long essay about the history of computing.",\n tools=[{"type": "computer_use"}],\n background=True,\n)\n\n# Cancel the in-progress interaction.\ninteraction = client.interactions.cancel(id=created.id)\nprint(interaction.status)\n', - }, - { - "label": "cancel", - "lang": "javascript", - "source": "import {GoogleGenAI} from '@google/genai';\n\nconst ai = new GoogleGenAI({});\n\n// Start a background interaction so it stays in-progress.\nconst created = await ai.interactions.create({\n model: 'gemini-3.6-flash',\n input: 'Write a long essay about the history of computing.',\n tools: [{ type: 'computer_use' }],\n background: true,\n});\n\n// Cancel the in-progress interaction.\nconst interaction = await ai.interactions.cancel(created.id);\nconsole.log(interaction.status);\n", - }, - ] - }, + extensions=None, response=ResponseContext(mode=_speakeasy_response_mode, execution="async"), ) http_res = await self.do_request_async( diff --git a/google/genai/_gaos/lib/compat_errors.py b/google/genai/_gaos/lib/compat_errors.py index 970564c43..a9de44ede 100644 --- a/google/genai/_gaos/lib/compat_errors.py +++ b/google/genai/_gaos/lib/compat_errors.py @@ -28,24 +28,8 @@ import json from typing import Any, Awaitable, Callable, Optional, TypeVar, cast -try: - import httpx2 -except ImportError: - httpx2 = None - import httpx -_HTTPX_TIMEOUT_ERRORS = ( - (httpx.TimeoutException,) - if httpx2 is None - else (httpx.TimeoutException, httpx2.TimeoutException) -) -_HTTPX_HTTP_ERRORS = ( - (httpx.HTTPError,) - if httpx2 is None - else (httpx.HTTPError, httpx2.HTTPError) -) - from ..errors.genaierror import GenAiError from ..errors.no_response_error import NoResponseError from ..errors.responsevalidationerror import ResponseValidationError @@ -287,7 +271,7 @@ def _wrap_httpx_error(error: BaseException) -> APIConnectionError: tolerates the edge case rather than fabricating a misleading stand-in. """ request = getattr(error, "_request", None) - if isinstance(error, _HTTPX_TIMEOUT_ERRORS): + if isinstance(error, httpx.TimeoutException): wrapped: APIConnectionError = APITimeoutError(request=request) # type: ignore[arg-type] else: wrapped = APIConnectionError( @@ -316,7 +300,7 @@ def wrap_sdk_error(error: BaseException) -> BaseException: return _wrap_validation_error(error) if isinstance(error, NoResponseError): return _wrap_no_response_error(error) - if isinstance(error, _HTTPX_HTTP_ERRORS): + if isinstance(error, httpx.HTTPError): return _wrap_httpx_error(error) if not isinstance(error, GenAiError): return error @@ -333,11 +317,7 @@ def wrap_sdk_error(error: BaseException) -> BaseException: return wrapped -_WRAP_EXCEPTIONS = ( - (GenAiError, NoResponseError, httpx.HTTPError) - if httpx2 is None - else (GenAiError, NoResponseError, httpx.HTTPError, httpx2.HTTPError) -) +_WRAP_EXCEPTIONS = (GenAiError, NoResponseError, httpx.HTTPError) class CompatErrorHook: diff --git a/google/genai/_gaos/models/__init__.py b/google/genai/_gaos/models/__init__.py index 024cabd61..dde8c9969 100644 --- a/google/genai/_gaos/models/__init__.py +++ b/google/genai/_gaos/models/__init__.py @@ -36,16 +36,10 @@ from .createenvironment import ( CreateEnvironmentGlobals, CreateEnvironmentGlobalsTypedDict, - CreateEnvironmentRequest, - CreateEnvironmentRequestParam, ) from .createinteraction import ( CreateInteractionGlobals, CreateInteractionGlobalsTypedDict, - CreateInteractionRequest, - CreateInteractionRequestBody, - CreateInteractionRequestBodyParam, - CreateInteractionRequestParam, CreateInteractionResponse, CreateInteractionResponseTypedDict, ) @@ -55,12 +49,7 @@ CreateTriggerRequest, CreateTriggerRequestParam, ) - from .createwebhook import ( - CreateWebhookGlobals, - CreateWebhookGlobalsTypedDict, - CreateWebhookRequest, - CreateWebhookRequestParam, - ) + from .createwebhook import CreateWebhookGlobals, CreateWebhookGlobalsTypedDict from .deleteagent import ( DeleteAgentGlobals, DeleteAgentGlobalsTypedDict, @@ -196,14 +185,8 @@ "CreateAgentRequestParam", "CreateEnvironmentGlobals", "CreateEnvironmentGlobalsTypedDict", - "CreateEnvironmentRequest", - "CreateEnvironmentRequestParam", "CreateInteractionGlobals", "CreateInteractionGlobalsTypedDict", - "CreateInteractionRequest", - "CreateInteractionRequestBody", - "CreateInteractionRequestBodyParam", - "CreateInteractionRequestParam", "CreateInteractionResponse", "CreateInteractionResponseTypedDict", "CreateTriggerGlobals", @@ -212,8 +195,6 @@ "CreateTriggerRequestParam", "CreateWebhookGlobals", "CreateWebhookGlobalsTypedDict", - "CreateWebhookRequest", - "CreateWebhookRequestParam", "DeleteAgentGlobals", "DeleteAgentGlobalsTypedDict", "DeleteAgentRequest", @@ -309,14 +290,8 @@ "CreateAgentRequestParam": ".createagent", "CreateEnvironmentGlobals": ".createenvironment", "CreateEnvironmentGlobalsTypedDict": ".createenvironment", - "CreateEnvironmentRequest": ".createenvironment", - "CreateEnvironmentRequestParam": ".createenvironment", "CreateInteractionGlobals": ".createinteraction", "CreateInteractionGlobalsTypedDict": ".createinteraction", - "CreateInteractionRequest": ".createinteraction", - "CreateInteractionRequestBody": ".createinteraction", - "CreateInteractionRequestBodyParam": ".createinteraction", - "CreateInteractionRequestParam": ".createinteraction", "CreateInteractionResponse": ".createinteraction", "CreateInteractionResponseTypedDict": ".createinteraction", "CreateTriggerGlobals": ".createtrigger", @@ -325,8 +300,6 @@ "CreateTriggerRequestParam": ".createtrigger", "CreateWebhookGlobals": ".createwebhook", "CreateWebhookGlobalsTypedDict": ".createwebhook", - "CreateWebhookRequest": ".createwebhook", - "CreateWebhookRequestParam": ".createwebhook", "DeleteAgentGlobals": ".deleteagent", "DeleteAgentGlobalsTypedDict": ".deleteagent", "DeleteAgentRequest": ".deleteagent", diff --git a/google/genai/_gaos/models/cancelinteractionbyid.py b/google/genai/_gaos/models/cancelinteractionbyid.py index 4db947eb1..789df3eca 100644 --- a/google/genai/_gaos/models/cancelinteractionbyid.py +++ b/google/genai/_gaos/models/cancelinteractionbyid.py @@ -19,6 +19,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..utils import FieldMetadata, PathParamMetadata +import pydantic from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -26,7 +27,7 @@ class CancelInteractionByIDGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class CancelInteractionByIDGlobals(BaseModel): @@ -34,7 +35,7 @@ class CancelInteractionByIDGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +56,17 @@ def serialize_model(self, handler): class CancelInteractionByIDRequestParam(TypedDict): id: str - r"""The unique identifier of the interaction to cancel.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Part of `name`. Required. The name of the interaction to cancel. + Format: `interactions/{interaction}`. + """ class CancelInteractionByIDRequest(BaseModel): id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) - ] - r"""The unique identifier of the interaction to cancel.""" - - api_version: Annotated[ - Optional[str], + str, + pydantic.Field(alias="interactionsId"), 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 + ] + r"""Part of `name`. Required. The name of the interaction to cancel. + Format: `interactions/{interaction}`. + """ diff --git a/google/genai/_gaos/models/createagent.py b/google/genai/_gaos/models/createagent.py index ff72ddf45..1a77ca27d 100644 --- a/google/genai/_gaos/models/createagent.py +++ b/google/genai/_gaos/models/createagent.py @@ -19,7 +19,12 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..types.agents import agent as agents_agent -from ..utils import FieldMetadata, PathParamMetadata, RequestMetadata +from ..utils import ( + FieldMetadata, + PathParamMetadata, + QueryParamMetadata, + RequestMetadata, +) from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -27,7 +32,7 @@ class CreateAgentGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class CreateAgentGlobals(BaseModel): @@ -35,7 +40,7 @@ class CreateAgentGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -56,9 +61,7 @@ def serialize_model(self, handler): class CreateAgentRequestParam(TypedDict): body: agents_agent.AgentParam - r"""The request body.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + parent: NotRequired[str] class CreateAgentRequest(BaseModel): @@ -66,17 +69,15 @@ class CreateAgentRequest(BaseModel): agents_agent.Agent, FieldMetadata(request=RequestMetadata(media_type="application/json")), ] - r"""The request body.""" - api_version: Annotated[ + parent: Annotated[ Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Which version of the API to use.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version"]) + optional_fields = set(["parent"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/createenvironment.py b/google/genai/_gaos/models/createenvironment.py index 706ada53a..65148b37d 100644 --- a/google/genai/_gaos/models/createenvironment.py +++ b/google/genai/_gaos/models/createenvironment.py @@ -18,10 +18,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL -from ..types.environments import ( - createenvironmentrequest as environments_createenvironmentrequest, -) -from ..utils import FieldMetadata, PathParamMetadata, RequestMetadata +from ..utils import FieldMetadata, PathParamMetadata from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -29,7 +26,7 @@ class CreateEnvironmentGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class CreateEnvironmentGlobals(BaseModel): @@ -37,44 +34,7 @@ class CreateEnvironmentGlobals(BaseModel): 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): - body: environments_createenvironmentrequest.CreateEnvironmentRequestParam - r"""Required. The environment to create.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" - - -class CreateEnvironmentRequest(BaseModel): - body: Annotated[ - environments_createenvironmentrequest.CreateEnvironmentRequest, - FieldMetadata(request=RequestMetadata(media_type="application/json")), - ] - r"""Required. The environment to create.""" - - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): diff --git a/google/genai/_gaos/models/createinteraction.py b/google/genai/_gaos/models/createinteraction.py index 6e9a57206..601e2dba7 100644 --- a/google/genai/_gaos/models/createinteraction.py +++ b/google/genai/_gaos/models/createinteraction.py @@ -19,12 +19,10 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..types.interactions import ( - createagentinteraction as interactions_createagentinteraction, - createmodelinteraction as interactions_createmodelinteraction, interaction as interactions_interaction, interactionsseevent as interactions_interactionsseevent, ) -from ..utils import FieldMetadata, PathParamMetadata, RequestMetadata +from ..utils import FieldMetadata, PathParamMetadata from ..utils.eventstreaming import AsyncStream, Stream from pydantic import model_serializer from typing import Optional, Union @@ -33,7 +31,7 @@ class CreateInteractionGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class CreateInteractionGlobals(BaseModel): @@ -41,64 +39,7 @@ class CreateInteractionGlobals(BaseModel): 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 - - -CreateInteractionRequestBodyParam = TypeAliasType( - "CreateInteractionRequestBodyParam", - Union[ - interactions_createmodelinteraction.CreateModelInteractionParam, - interactions_createagentinteraction.CreateAgentInteractionParam, - ], -) -r"""The request body.""" - - -CreateInteractionRequestBody = TypeAliasType( - "CreateInteractionRequestBody", - Union[ - interactions_createmodelinteraction.CreateModelInteraction, - interactions_createagentinteraction.CreateAgentInteraction, - ], -) -r"""The request body.""" - - -class CreateInteractionRequestParam(TypedDict): - body: CreateInteractionRequestBodyParam - r"""The request body.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" - - -class CreateInteractionRequest(BaseModel): - body: Annotated[ - CreateInteractionRequestBody, - FieldMetadata(request=RequestMetadata(media_type="application/json")), - ] - r"""The request body.""" - - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): diff --git a/google/genai/_gaos/models/createtrigger.py b/google/genai/_gaos/models/createtrigger.py index 2e4c8ddcb..e2bd66cf5 100644 --- a/google/genai/_gaos/models/createtrigger.py +++ b/google/genai/_gaos/models/createtrigger.py @@ -19,7 +19,12 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..types.triggers import triggercreateparams as triggers_triggercreateparams -from ..utils import FieldMetadata, PathParamMetadata, RequestMetadata +from ..utils import ( + FieldMetadata, + PathParamMetadata, + QueryParamMetadata, + RequestMetadata, +) from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -27,7 +32,7 @@ class CreateTriggerGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class CreateTriggerGlobals(BaseModel): @@ -35,7 +40,7 @@ class CreateTriggerGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -56,8 +61,13 @@ def serialize_model(self, handler): class CreateTriggerRequestParam(TypedDict): body: triggers_triggercreateparams.TriggerCreateParamsParam - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The trigger configuration to create.""" + parent: NotRequired[str] + r"""Required. The parent resource where this trigger will be created. + Format: `projects/{project}/locations/{location}` + + Supported only by the Vertex API only. + """ class CreateTriggerRequest(BaseModel): @@ -65,16 +75,21 @@ class CreateTriggerRequest(BaseModel): triggers_triggercreateparams.TriggerCreateParams, FieldMetadata(request=RequestMetadata(media_type="application/json")), ] + r"""Required. The trigger configuration to create.""" - api_version: Annotated[ + parent: Annotated[ Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Which version of the API to use.""" + r"""Required. The parent resource where this trigger will be created. + Format: `projects/{project}/locations/{location}` + + Supported only by the Vertex API only. + """ @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version"]) + optional_fields = set(["parent"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/createwebhook.py b/google/genai/_gaos/models/createwebhook.py index 8999f2f82..d605d507c 100644 --- a/google/genai/_gaos/models/createwebhook.py +++ b/google/genai/_gaos/models/createwebhook.py @@ -18,8 +18,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL -from ..types.webhooks import webhook as webhooks_webhook -from ..utils import FieldMetadata, PathParamMetadata, RequestMetadata +from ..utils import FieldMetadata, PathParamMetadata from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -27,7 +26,7 @@ class CreateWebhookGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class CreateWebhookGlobals(BaseModel): @@ -35,44 +34,7 @@ class CreateWebhookGlobals(BaseModel): 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 CreateWebhookRequestParam(TypedDict): - body: webhooks_webhook.WebhookInputParam - r"""Required. The webhook to create.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" - - -class CreateWebhookRequest(BaseModel): - body: Annotated[ - webhooks_webhook.WebhookInput, - FieldMetadata(request=RequestMetadata(media_type="application/json")), - ] - r"""Required. The webhook to create.""" - - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): diff --git a/google/genai/_gaos/models/deleteagent.py b/google/genai/_gaos/models/deleteagent.py index 2c14d54c3..52dbd5ab7 100644 --- a/google/genai/_gaos/models/deleteagent.py +++ b/google/genai/_gaos/models/deleteagent.py @@ -19,6 +19,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..utils import FieldMetadata, PathParamMetadata +import pydantic from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -26,7 +27,7 @@ class DeleteAgentGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class DeleteAgentGlobals(BaseModel): @@ -34,7 +35,7 @@ class DeleteAgentGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,33 +56,13 @@ def serialize_model(self, handler): class DeleteAgentRequestParam(TypedDict): id: str - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Part of `name`.""" class DeleteAgentRequest(BaseModel): id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) - ] - - api_version: Annotated[ - Optional[str], + str, + pydantic.Field(alias="agentsId"), 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 + ] + r"""Part of `name`.""" diff --git a/google/genai/_gaos/models/deleteenvironment.py b/google/genai/_gaos/models/deleteenvironment.py index 80f4a6272..553c7b314 100644 --- a/google/genai/_gaos/models/deleteenvironment.py +++ b/google/genai/_gaos/models/deleteenvironment.py @@ -26,7 +26,7 @@ class DeleteEnvironmentGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class DeleteEnvironmentGlobals(BaseModel): @@ -34,7 +34,7 @@ class DeleteEnvironmentGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +55,11 @@ def serialize_model(self, handler): 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.""" + r"""Required. The identifier of the environment to delete.""" 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 + r"""Required. The identifier of the environment to delete.""" diff --git a/google/genai/_gaos/models/deleteinteraction.py b/google/genai/_gaos/models/deleteinteraction.py index 34cfdd4d7..21e0d58a2 100644 --- a/google/genai/_gaos/models/deleteinteraction.py +++ b/google/genai/_gaos/models/deleteinteraction.py @@ -19,6 +19,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..utils import FieldMetadata, PathParamMetadata +import pydantic from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -26,7 +27,7 @@ class DeleteInteractionGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class DeleteInteractionGlobals(BaseModel): @@ -34,7 +35,7 @@ class DeleteInteractionGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +56,17 @@ def serialize_model(self, handler): class DeleteInteractionRequestParam(TypedDict): id: str - r"""The unique identifier of the interaction to delete.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Part of `name`. Required. The name of the interaction to delete. + Format: interactions/{interaction} + """ class DeleteInteractionRequest(BaseModel): id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) - ] - r"""The unique identifier of the interaction to delete.""" - - api_version: Annotated[ - Optional[str], + str, + pydantic.Field(alias="interactionsId"), 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 + ] + r"""Part of `name`. Required. The name of the interaction to delete. + Format: interactions/{interaction} + """ diff --git a/google/genai/_gaos/models/deletetrigger.py b/google/genai/_gaos/models/deletetrigger.py index edecf6c55..547151675 100644 --- a/google/genai/_gaos/models/deletetrigger.py +++ b/google/genai/_gaos/models/deletetrigger.py @@ -26,7 +26,7 @@ class DeleteTriggerGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class DeleteTriggerGlobals(BaseModel): @@ -34,7 +34,7 @@ class DeleteTriggerGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +55,11 @@ def serialize_model(self, handler): class DeleteTriggerRequestParam(TypedDict): id: str - r"""Resource name of the trigger.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The ID of the trigger to delete.""" class DeleteTriggerRequest(BaseModel): id: Annotated[ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) ] - r"""Resource name of the trigger.""" - - 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 + r"""Required. The ID of the trigger to delete.""" diff --git a/google/genai/_gaos/models/deletewebhook.py b/google/genai/_gaos/models/deletewebhook.py index 378082d2a..7a8d48561 100644 --- a/google/genai/_gaos/models/deletewebhook.py +++ b/google/genai/_gaos/models/deletewebhook.py @@ -26,7 +26,7 @@ class DeleteWebhookGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class DeleteWebhookGlobals(BaseModel): @@ -34,7 +34,7 @@ class DeleteWebhookGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -58,8 +58,6 @@ class DeleteWebhookRequestParam(TypedDict): r"""Required. The ID of the webhook to delete. Format: `{webhook_id}` """ - api_version: NotRequired[str] - r"""Which version of the API to use.""" class DeleteWebhookRequest(BaseModel): @@ -69,25 +67,3 @@ class DeleteWebhookRequest(BaseModel): r"""Required. The ID of the webhook to delete. Format: `{webhook_id}` """ - - 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/getagent.py b/google/genai/_gaos/models/getagent.py index 0dbaf2ab7..5371fe08f 100644 --- a/google/genai/_gaos/models/getagent.py +++ b/google/genai/_gaos/models/getagent.py @@ -19,6 +19,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..utils import FieldMetadata, PathParamMetadata +import pydantic from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -26,7 +27,7 @@ class GetAgentGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class GetAgentGlobals(BaseModel): @@ -34,7 +35,7 @@ class GetAgentGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,33 +56,13 @@ def serialize_model(self, handler): class GetAgentRequestParam(TypedDict): id: str - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Part of `name`.""" class GetAgentRequest(BaseModel): id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) - ] - - api_version: Annotated[ - Optional[str], + str, + pydantic.Field(alias="agentsId"), 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 + ] + r"""Part of `name`.""" diff --git a/google/genai/_gaos/models/getenvironment.py b/google/genai/_gaos/models/getenvironment.py index 9afaccccf..d954da579 100644 --- a/google/genai/_gaos/models/getenvironment.py +++ b/google/genai/_gaos/models/getenvironment.py @@ -26,7 +26,7 @@ class GetEnvironmentGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class GetEnvironmentGlobals(BaseModel): @@ -34,7 +34,7 @@ class GetEnvironmentGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +55,11 @@ def serialize_model(self, handler): 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.""" + r"""Required. The identifier of the environment to retrieve.""" 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 + r"""Required. The identifier of the environment to retrieve.""" diff --git a/google/genai/_gaos/models/getinteractionbyid.py b/google/genai/_gaos/models/getinteractionbyid.py index 9360d64f6..5d852762d 100644 --- a/google/genai/_gaos/models/getinteractionbyid.py +++ b/google/genai/_gaos/models/getinteractionbyid.py @@ -32,7 +32,7 @@ class GetInteractionByIDGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class GetInteractionByIDGlobals(BaseModel): @@ -40,7 +40,7 @@ class GetInteractionByIDGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -61,55 +61,52 @@ def serialize_model(self, handler): class GetInteractionByIDRequestParam(TypedDict): id: str - r"""The unique identifier of the interaction to retrieve.""" - stream: NotRequired[bool] - r"""If set to true, the generated content will be streamed incrementally.""" - last_event_id: NotRequired[str] - r"""Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.""" + r"""Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + """ include_input: NotRequired[bool] - r"""If set to true, includes the input in the response.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""If true, includes the input in the response.""" + last_event_id: NotRequired[str] + r"""If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + """ + stream: NotRequired[bool] + r"""If true, streams the interaction events as Server-Sent Events.""" class GetInteractionByIDRequest(BaseModel): id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + str, + pydantic.Field(alias="interactionsId"), + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] - r"""The unique identifier of the interaction to retrieve.""" + r"""Part of `name`. Required. The name of the interaction to retrieve. + Format: interactions/{interaction} + """ - stream: Annotated[ + include_input: Annotated[ Optional[bool], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), - ] = False - r"""If set to true, the generated content will be streamed incrementally.""" + ] = None + r"""If true, includes the input in the response.""" last_event_id: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.""" + r"""If set, resumes the interaction stream from the chunk after the event + marked by the event id. Can only be used if `stream` is true. + """ - include_input: Annotated[ + stream: Annotated[ Optional[bool], - pydantic.Field( - deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." - ), FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), - ] = False - r"""If set to true, includes the input in the response.""" - - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""If true, streams the interaction events as Server-Sent Events.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set( - ["stream", "last_event_id", "include_input", "api_version"] - ) + optional_fields = set(["include_input", "last_event_id", "stream"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/gettrigger.py b/google/genai/_gaos/models/gettrigger.py index a108858fe..a47796551 100644 --- a/google/genai/_gaos/models/gettrigger.py +++ b/google/genai/_gaos/models/gettrigger.py @@ -26,7 +26,7 @@ class GetTriggerGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class GetTriggerGlobals(BaseModel): @@ -34,7 +34,7 @@ class GetTriggerGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +55,11 @@ def serialize_model(self, handler): class GetTriggerRequestParam(TypedDict): id: str - r"""Resource name of the trigger.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The ID of the trigger to retrieve.""" class GetTriggerRequest(BaseModel): id: Annotated[ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) ] - r"""Resource name of the trigger.""" - - 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 + r"""Required. The ID of the trigger to retrieve.""" diff --git a/google/genai/_gaos/models/getwebhook.py b/google/genai/_gaos/models/getwebhook.py index bb0ac9a89..2614d9c67 100644 --- a/google/genai/_gaos/models/getwebhook.py +++ b/google/genai/_gaos/models/getwebhook.py @@ -26,7 +26,7 @@ class GetWebhookGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class GetWebhookGlobals(BaseModel): @@ -34,7 +34,7 @@ class GetWebhookGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -56,8 +56,6 @@ def serialize_model(self, handler): class GetWebhookRequestParam(TypedDict): id: str r"""Required. The ID of the webhook to retrieve.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" class GetWebhookRequest(BaseModel): @@ -65,25 +63,3 @@ class GetWebhookRequest(BaseModel): str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) ] r"""Required. The ID of the webhook to retrieve.""" - - 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/internal/globals.py b/google/genai/_gaos/models/internal/globals.py index a6f03da5a..dc8035ca2 100644 --- a/google/genai/_gaos/models/internal/globals.py +++ b/google/genai/_gaos/models/internal/globals.py @@ -27,9 +27,11 @@ class GlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" user_project: NotRequired[str] r"""Quota project header to send with Google GenAI API requests.""" + api_revision: NotRequired[str] + r"""API revision header to send with Google GenAI API requests.""" class Globals(BaseModel): @@ -37,7 +39,7 @@ class Globals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" user_project: Annotated[ Optional[str], @@ -46,9 +48,16 @@ class Globals(BaseModel): ] = None r"""Quota project header to send with Google GenAI API requests.""" + api_revision: Annotated[ + Optional[str], + pydantic.Field(alias="Api-Revision"), + FieldMetadata(header=HeaderMetadata(style="simple", explode=False)), + ] = None + r"""API revision header to send with Google GenAI API requests.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "user_project"]) + optional_fields = set(["api_version", "user_project", "api_revision"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/listagents.py b/google/genai/_gaos/models/listagents.py index 9f2549e43..83e0a4569 100644 --- a/google/genai/_gaos/models/listagents.py +++ b/google/genai/_gaos/models/listagents.py @@ -26,7 +26,7 @@ class ListAgentsGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class ListAgentsGlobals(BaseModel): @@ -34,7 +34,7 @@ class ListAgentsGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -54,20 +54,12 @@ def serialize_model(self, handler): class ListAgentsRequestParam(TypedDict): - api_version: NotRequired[str] - r"""Which version of the API to use.""" page_size: NotRequired[int] page_token: NotRequired[str] parent: NotRequired[str] class ListAgentsRequest(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)), @@ -85,7 +77,7 @@ class ListAgentsRequest(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "page_size", "page_token", "parent"]) + optional_fields = set(["page_size", "page_token", "parent"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/listenvironments.py b/google/genai/_gaos/models/listenvironments.py index 939749aba..11417b6b1 100644 --- a/google/genai/_gaos/models/listenvironments.py +++ b/google/genai/_gaos/models/listenvironments.py @@ -26,7 +26,7 @@ class ListEnvironmentsGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class ListEnvironmentsGlobals(BaseModel): @@ -34,7 +34,7 @@ class ListEnvironmentsGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -54,36 +54,32 @@ def serialize_model(self, handler): 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.""" + r"""Maximum number of environments to return. + If unspecified, defaults to 50. Maximum is 1000. + """ page_token: NotRequired[str] - r"""Optional. Pagination token.""" + r"""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.""" + r"""Maximum number of environments to return. + If unspecified, defaults to 50. Maximum is 1000. + """ page_token: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. Pagination token.""" + r"""Pagination token.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "page_size", "page_token"]) + optional_fields = set(["page_size", "page_token"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/listtriggerexecutions.py b/google/genai/_gaos/models/listtriggerexecutions.py index 84ec75c6a..df8d74a66 100644 --- a/google/genai/_gaos/models/listtriggerexecutions.py +++ b/google/genai/_gaos/models/listtriggerexecutions.py @@ -19,6 +19,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..utils import FieldMetadata, PathParamMetadata, QueryParamMetadata +import pydantic from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -26,7 +27,7 @@ class ListTriggerExecutionsGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class ListTriggerExecutionsGlobals(BaseModel): @@ -34,7 +35,7 @@ class ListTriggerExecutionsGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,42 +56,45 @@ def serialize_model(self, handler): class ListTriggerExecutionsRequestParam(TypedDict): trigger_id: str - r"""Resource name of the trigger.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The trigger ID to list executions from.""" + filter_: NotRequired[str] + r"""Optional. Filter expression.""" page_size: NotRequired[int] - r"""Optional. The maximum number of executions to return per page.""" + r"""The maximum number of executions to return per page.""" page_token: NotRequired[str] - r"""Optional. A page token from a previous ListTriggerExecutions call.""" + r"""A page token from a previous ListTriggerExecutions call.""" class ListTriggerExecutionsRequest(BaseModel): trigger_id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) + str, + pydantic.Field(alias="triggerId"), + FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] - r"""Resource name of the trigger.""" + r"""Required. The trigger ID to list executions from.""" - api_version: Annotated[ + filter_: Annotated[ Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), + pydantic.Field(alias="filter"), + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Which version of the API to use.""" + r"""Optional. Filter expression.""" page_size: Annotated[ Optional[int], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. The maximum number of executions to return per page.""" + r"""The maximum number of executions to return per page.""" page_token: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. A page token from a previous ListTriggerExecutions call.""" + r"""A page token from a previous ListTriggerExecutions call.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "page_size", "page_token"]) + optional_fields = set(["filter", "page_size", "page_token"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/listtriggers.py b/google/genai/_gaos/models/listtriggers.py index 58e3602b9..0801bf7aa 100644 --- a/google/genai/_gaos/models/listtriggers.py +++ b/google/genai/_gaos/models/listtriggers.py @@ -27,7 +27,7 @@ class ListTriggersGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class ListTriggersGlobals(BaseModel): @@ -35,7 +35,7 @@ class ListTriggersGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,45 +55,57 @@ def serialize_model(self, handler): class ListTriggersRequestParam(TypedDict): - api_version: NotRequired[str] - r"""Which version of the API to use.""" filter_: NotRequired[str] - r"""Optional. Filter expression (e.g., by state).""" + r"""Optional. Filter expression (e.g. `agent=\"agents/my-agent-id\"`). Only + equality filtering on the `agent` field is currently supported. + """ page_size: NotRequired[int] - r"""Optional. The maximum number of triggers to return per page.""" + r"""The maximum number of triggers to return per page.""" page_token: NotRequired[str] - r"""Optional. A page token from a previous ListTriggers call.""" + r"""A page token from a previous ListTriggers call.""" + parent: NotRequired[str] + r"""Required. The parent resource to list triggers from. + Format: `projects/{project}/locations/{location}` + Supported only by the Vertex API only. + """ -class ListTriggersRequest(BaseModel): - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" +class ListTriggersRequest(BaseModel): filter_: Annotated[ Optional[str], pydantic.Field(alias="filter"), FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. Filter expression (e.g., by state).""" + r"""Optional. Filter expression (e.g. `agent=\"agents/my-agent-id\"`). Only + equality filtering on the `agent` field is currently supported. + """ page_size: Annotated[ Optional[int], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. The maximum number of triggers to return per page.""" + r"""The maximum number of triggers to return per page.""" page_token: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. A page token from a previous ListTriggers call.""" + r"""A page token from a previous ListTriggers call.""" + + parent: Annotated[ + Optional[str], + FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), + ] = None + r"""Required. The parent resource to list triggers from. + Format: `projects/{project}/locations/{location}` + + Supported only by the Vertex API only. + """ @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "filter", "page_size", "page_token"]) + optional_fields = set(["filter", "page_size", "page_token", "parent"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/listwebhooks.py b/google/genai/_gaos/models/listwebhooks.py index 352f56600..c3a905c1d 100644 --- a/google/genai/_gaos/models/listwebhooks.py +++ b/google/genai/_gaos/models/listwebhooks.py @@ -26,7 +26,7 @@ class ListWebhooksGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class ListWebhooksGlobals(BaseModel): @@ -34,7 +34,7 @@ class ListWebhooksGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -54,31 +54,23 @@ def serialize_model(self, handler): class ListWebhooksRequestParam(TypedDict): - api_version: NotRequired[str] - r"""Which version of the API to use.""" page_size: NotRequired[int] - r"""Optional. The maximum number of webhooks to return. The service may return fewer than + r"""The maximum number of webhooks to return. The service may return fewer than this value. If unspecified, at most 50 webhooks will be returned. The maximum value is 1000. """ page_token: NotRequired[str] - r"""Optional. A page token, received from a previous `ListWebhooks` call. + r"""A page token, received from a previous `ListWebhooks` call. Provide this to retrieve the subsequent page. """ class ListWebhooksRequest(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. The maximum number of webhooks to return. The service may return fewer than + r"""The maximum number of webhooks to return. The service may return fewer than this value. If unspecified, at most 50 webhooks will be returned. The maximum value is 1000. """ @@ -87,13 +79,13 @@ class ListWebhooksRequest(BaseModel): Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. A page token, received from a previous `ListWebhooks` call. + r"""A page token, received from a previous `ListWebhooks` call. Provide this to retrieve the subsequent page. """ @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "page_size", "page_token"]) + optional_fields = set(["page_size", "page_token"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/pingwebhook.py b/google/genai/_gaos/models/pingwebhook.py index f2644c154..d903cc3a4 100644 --- a/google/genai/_gaos/models/pingwebhook.py +++ b/google/genai/_gaos/models/pingwebhook.py @@ -27,7 +27,7 @@ class PingWebhookGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class PingWebhookGlobals(BaseModel): @@ -35,7 +35,7 @@ class PingWebhookGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -56,38 +56,26 @@ def serialize_model(self, handler): class PingWebhookRequestParam(TypedDict): id: str - r"""Required. The ID of the webhook to ping. - Format: `{webhook_id}` - """ - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The ID of the webhook to ping.""" body: NotRequired[webhooks_pingwebhookrequest.PingWebhookRequestParam] - r"""The request body.""" + r"""Required. The HTTP body of the payload.""" class PingWebhookRequest(BaseModel): id: Annotated[ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) ] - r"""Required. The ID of the webhook to ping. - Format: `{webhook_id}` - """ - - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" + r"""Required. The ID of the webhook to ping.""" body: Annotated[ Optional[webhooks_pingwebhookrequest.PingWebhookRequest], FieldMetadata(request=RequestMetadata(media_type="application/json")), ] = None - r"""The request body.""" + r"""Required. The HTTP body of the payload.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "body"]) + optional_fields = set(["body"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/rotatesigningsecret.py b/google/genai/_gaos/models/rotatesigningsecret.py index 8727ac5c3..dbe88782f 100644 --- a/google/genai/_gaos/models/rotatesigningsecret.py +++ b/google/genai/_gaos/models/rotatesigningsecret.py @@ -29,7 +29,7 @@ class RotateSigningSecretGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class RotateSigningSecretGlobals(BaseModel): @@ -37,7 +37,7 @@ class RotateSigningSecretGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -58,40 +58,28 @@ def serialize_model(self, handler): class RotateSigningSecretRequestParam(TypedDict): id: str - r"""Required. The ID of the webhook for which to generate a signing secret. - Format: `{webhook_id}` - """ - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The ID of the webhook for which to rotate the signing secret.""" body: NotRequired[ webhooks_rotatesigningsecretrequest.RotateSigningSecretRequestParam ] - r"""The request body.""" + r"""Required. The HTTP body of the payload mapping to `revocation_behavior`.""" class RotateSigningSecretRequest(BaseModel): id: Annotated[ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) ] - r"""Required. The ID of the webhook for which to generate a signing secret. - Format: `{webhook_id}` - """ - - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" + r"""Required. The ID of the webhook for which to rotate the signing secret.""" body: Annotated[ Optional[webhooks_rotatesigningsecretrequest.RotateSigningSecretRequest], FieldMetadata(request=RequestMetadata(media_type="application/json")), ] = None - r"""The request body.""" + r"""Required. The HTTP body of the payload mapping to `revocation_behavior`.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "body"]) + optional_fields = set(["body"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/models/runtrigger.py b/google/genai/_gaos/models/runtrigger.py index 1fde70f22..537ea8d3c 100644 --- a/google/genai/_gaos/models/runtrigger.py +++ b/google/genai/_gaos/models/runtrigger.py @@ -19,6 +19,7 @@ from __future__ import annotations from ..types import BaseModel, UNSET_SENTINEL from ..utils import FieldMetadata, PathParamMetadata +import pydantic from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict @@ -26,7 +27,7 @@ class RunTriggerGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class RunTriggerGlobals(BaseModel): @@ -34,7 +35,7 @@ class RunTriggerGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -55,35 +56,13 @@ def serialize_model(self, handler): class RunTriggerRequestParam(TypedDict): trigger_id: str - r"""Resource name of the trigger.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The ID of the trigger to run immediately.""" class RunTriggerRequest(BaseModel): trigger_id: Annotated[ - str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) - ] - r"""Resource name of the trigger.""" - - api_version: Annotated[ - Optional[str], + str, + pydantic.Field(alias="triggerId"), 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 + ] + r"""Required. The ID of the trigger to run immediately.""" diff --git a/google/genai/_gaos/models/updatetrigger.py b/google/genai/_gaos/models/updatetrigger.py index 6cbd4ac7f..6777e1c60 100644 --- a/google/genai/_gaos/models/updatetrigger.py +++ b/google/genai/_gaos/models/updatetrigger.py @@ -27,7 +27,7 @@ class UpdateTriggerGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class UpdateTriggerGlobals(BaseModel): @@ -35,7 +35,7 @@ class UpdateTriggerGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -56,41 +56,19 @@ def serialize_model(self, handler): class UpdateTriggerRequestParam(TypedDict): id: str - r"""Resource name of the trigger.""" + r"""Required. The ID of the trigger to update.""" body: triggers_triggerupdate.TriggerUpdateParam - api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""Required. The trigger with updated fields.""" class UpdateTriggerRequest(BaseModel): id: Annotated[ str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False)) ] - r"""Resource name of the trigger.""" + r"""Required. The ID of the trigger to update.""" body: Annotated[ triggers_triggerupdate.TriggerUpdate, FieldMetadata(request=RequestMetadata(media_type="application/json")), ] - - 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 + r"""Required. The trigger with updated fields.""" diff --git a/google/genai/_gaos/models/updatewebhook.py b/google/genai/_gaos/models/updatewebhook.py index 7dc6a0109..5e9e9f04c 100644 --- a/google/genai/_gaos/models/updatewebhook.py +++ b/google/genai/_gaos/models/updatewebhook.py @@ -32,7 +32,7 @@ class UpdateWebhookGlobalsTypedDict(TypedDict): api_version: NotRequired[str] - r"""Which version of the API to use.""" + r"""API version for request routing.""" class UpdateWebhookGlobals(BaseModel): @@ -40,7 +40,7 @@ class UpdateWebhookGlobals(BaseModel): Optional[str], FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), ] = None - r"""Which version of the API to use.""" + r"""API version for request routing.""" @model_serializer(mode="wrap") def serialize_model(self, handler): @@ -62,12 +62,10 @@ def serialize_model(self, handler): class UpdateWebhookRequestParam(TypedDict): id: str r"""Required. The ID of the webhook to update.""" - api_version: NotRequired[str] - r"""Which version of the API to use.""" update_mask: NotRequired[str] - r"""Optional. The list of fields to update.""" + r"""Optional list of fields to update.""" body: NotRequired[webhooks_webhookupdate.WebhookUpdateParam] - r"""Required. The webhook to update.""" + r"""Required. The HTTP body of the payload.""" class UpdateWebhookRequest(BaseModel): @@ -76,27 +74,21 @@ class UpdateWebhookRequest(BaseModel): ] r"""Required. The ID of the webhook to update.""" - api_version: Annotated[ - Optional[str], - FieldMetadata(path=PathParamMetadata(style="simple", explode=False)), - ] = None - r"""Which version of the API to use.""" - update_mask: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None - r"""Optional. The list of fields to update.""" + r"""Optional list of fields to update.""" body: Annotated[ Optional[webhooks_webhookupdate.WebhookUpdate], FieldMetadata(request=RequestMetadata(media_type="application/json")), ] = None - r"""Required. The webhook to update.""" + r"""Required. The HTTP body of the payload.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["api_version", "update_mask", "body"]) + optional_fields = set(["update_mask", "body"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/resources/environments/__init__.py b/google/genai/_gaos/resources/environments/__init__.py index dd96730ea..3f473c485 100644 --- a/google/genai/_gaos/resources/environments/__init__.py +++ b/google/genai/_gaos/resources/environments/__init__.py @@ -18,18 +18,14 @@ from ...types.environments.createenvironmentrequest import CreateEnvironmentRequest from ...types.environments.environment import Environment -from ...types.environments.listenvironmentsresponse import ( - ListEnvironmentsResponse as EnvironmentListResponse, -) +from ...types.environments.listenvironmentsresponse import ListEnvironmentsResponse from ...types.interactions.empty import Empty as EnvironmentDeleteResponse -from . import createenvironmentrequest -from . import environment +EnvironmentListResponse = ListEnvironmentsResponse __all__ = [ "CreateEnvironmentRequest", "Environment", "EnvironmentDeleteResponse", "EnvironmentListResponse", - "createenvironmentrequest", - "environment", + "ListEnvironmentsResponse", ] diff --git a/google/genai/_gaos/resources/interactions/__init__.py b/google/genai/_gaos/resources/interactions/__init__.py index 5bdf1ef5e..8c818fa43 100644 --- a/google/genai/_gaos/resources/interactions/__init__.py +++ b/google/genai/_gaos/resources/interactions/__init__.py @@ -19,9 +19,6 @@ from ...models.cancelinteractionbyid import ( CancelInteractionByIDRequestParam as InteractionCancelParams, ) -from ...models.createinteraction import ( - CreateInteractionRequestParam as InteractionCreateParams, -) from ...models.deleteinteraction import ( DeleteInteractionRequestParam as InteractionDeleteParams, ) @@ -41,6 +38,9 @@ from ...types.interactions.createagentinteraction import ( CreateAgentInteractionParam as CreateAgentInteractionParamsNonStreaming, ) +from ...types.interactions.createinteractionrequest import ( + CreateInteractionRequestParam as InteractionCreateParams, +) from ...types.interactions.createmodelinteraction import ( CreateModelInteractionParam as CreateModelInteractionParamsNonStreaming, ) @@ -82,7 +82,9 @@ from ...types.interactions.placecitation import PlaceCitation from ...types.interactions.retrievalcallarguments import RetrievalCallArguments from ...types.interactions.retrievalcalldelta import RetrievalCallDelta +from ...types.interactions.retrievalcallstep import RetrievalCallStep from ...types.interactions.retrievalresultdelta import RetrievalResultDelta +from ...types.interactions.retrievalresultstep import RetrievalResultStep from ...types.interactions.safetysetting import SafetySetting from ...types.interactions.speechconfig import SpeechConfig from ...types.interactions.step import Step @@ -113,14 +115,21 @@ from . import codemenderagentconfig from . import environment from . import errorevent +from . import generationconfig from . import googlemapscallstep from . import googlemapsresult from . import googlemapsresultstep from . import googlesearchcallstep from . import googlesearchresultstep +from . import interactioncompletedevent +from . import interactioncreatedevent +from . import interactionstatusupdate from . import placecitation from . import retrievalcalldelta +from . import retrievalcallstep from . import stepdelta +from . import stepstart +from . import stepstop from . import tool from . import urlcontextcallstep from . import urlcontextresultstep @@ -186,7 +195,9 @@ "PlaceCitation", "RetrievalCallArguments", "RetrievalCallDelta", + "RetrievalCallStep", "RetrievalResultDelta", + "RetrievalResultStep", "SafetySetting", "SpeechConfig", "Step", @@ -217,14 +228,21 @@ "codemenderagentconfig", "environment", "errorevent", + "generationconfig", "googlemapscallstep", "googlemapsresult", "googlemapsresultstep", "googlesearchcallstep", "googlesearchresultstep", + "interactioncompletedevent", + "interactioncreatedevent", + "interactionstatusupdate", "placecitation", "retrievalcalldelta", + "retrievalcallstep", "stepdelta", + "stepstart", + "stepstop", "tool", "urlcontextcallstep", "urlcontextresultstep", diff --git a/google/genai/_gaos/resources/interactions/environment/__init__.py b/google/genai/_gaos/resources/interactions/environment/__init__.py index 56de8d46e..685e09bad 100644 --- a/google/genai/_gaos/resources/interactions/environment/__init__.py +++ b/google/genai/_gaos/resources/interactions/environment/__init__.py @@ -16,7 +16,7 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ....types.interactions.environmentnetworkegressallowlist import Allowlist +from ....types.interactions.allowlist import Allowlist from ....types.interactions.source import Source __all__ = ["Allowlist", "Source"] diff --git a/google/genai/_gaos/resources/interactions/errorevent/__init__.py b/google/genai/_gaos/resources/interactions/errorevent/__init__.py index f260248e1..e0585bd3b 100644 --- a/google/genai/_gaos/resources/interactions/errorevent/__init__.py +++ b/google/genai/_gaos/resources/interactions/errorevent/__init__.py @@ -17,5 +17,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from ....types.interactions.error import Error +from ....types.interactions.streammetadata import StreamMetadata as Metadata -__all__ = ["Error"] +__all__ = ["Error", "Metadata"] diff --git a/google/genai/_gaos/resources/environments/createenvironmentrequest/__init__.py b/google/genai/_gaos/resources/interactions/generationconfig/__init__.py similarity index 86% rename from google/genai/_gaos/resources/environments/createenvironmentrequest/__init__.py rename to google/genai/_gaos/resources/interactions/generationconfig/__init__.py index e59659f56..15119fe9d 100644 --- a/google/genai/_gaos/resources/environments/createenvironmentrequest/__init__.py +++ b/google/genai/_gaos/resources/interactions/generationconfig/__init__.py @@ -16,6 +16,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ....types.interactions.environmentnetworkegressallowlist import Allowlist +from ....types.interactions.speakerconfig import SpeakerConfig as Speaker -__all__ = ["Allowlist"] +__all__ = ["Speaker"] diff --git a/google/genai/_gaos/resources/environments/environment/__init__.py b/google/genai/_gaos/resources/interactions/interactioncompletedevent/__init__.py similarity index 86% rename from google/genai/_gaos/resources/environments/environment/__init__.py rename to google/genai/_gaos/resources/interactions/interactioncompletedevent/__init__.py index e59659f56..cefc54863 100644 --- a/google/genai/_gaos/resources/environments/environment/__init__.py +++ b/google/genai/_gaos/resources/interactions/interactioncompletedevent/__init__.py @@ -16,6 +16,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ....types.interactions.environmentnetworkegressallowlist import Allowlist +from ....types.interactions.streammetadata import StreamMetadata as Metadata -__all__ = ["Allowlist"] +__all__ = ["Metadata"] diff --git a/google/genai/_gaos/resources/interactions/interactioncreatedevent/__init__.py b/google/genai/_gaos/resources/interactions/interactioncreatedevent/__init__.py new file mode 100644 index 000000000..cefc54863 --- /dev/null +++ b/google/genai/_gaos/resources/interactions/interactioncreatedevent/__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.streammetadata import StreamMetadata as Metadata + +__all__ = ["Metadata"] diff --git a/google/genai/_gaos/resources/interactions/interactionstatusupdate/__init__.py b/google/genai/_gaos/resources/interactions/interactionstatusupdate/__init__.py new file mode 100644 index 000000000..cefc54863 --- /dev/null +++ b/google/genai/_gaos/resources/interactions/interactionstatusupdate/__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.streammetadata import StreamMetadata as Metadata + +__all__ = ["Metadata"] diff --git a/google/genai/_gaos/resources/interactions/retrievalcallstep/__init__.py b/google/genai/_gaos/resources/interactions/retrievalcallstep/__init__.py new file mode 100644 index 000000000..4acb4a917 --- /dev/null +++ b/google/genai/_gaos/resources/interactions/retrievalcallstep/__init__.py @@ -0,0 +1,23 @@ +# 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.retrievalcallarguments import ( + RetrievalCallArguments as Arguments, +) + +__all__ = ["Arguments"] diff --git a/google/genai/_gaos/resources/interactions/stepdelta/__init__.py b/google/genai/_gaos/resources/interactions/stepdelta/__init__.py index e45245eb5..936fe121a 100644 --- a/google/genai/_gaos/resources/interactions/stepdelta/__init__.py +++ b/google/genai/_gaos/resources/interactions/stepdelta/__init__.py @@ -54,7 +54,9 @@ MCPServerToolResultDelta as MCPServerToolResult, ) from ....types.interactions.stepdeltametadata import StepDeltaMetadata as Metadata -from ....types.interactions.textannotationdelta import TextAnnotationDelta +from ....types.interactions.textannotationdelta import ( + TextAnnotationDelta as TextAnnotation, +) from ....types.interactions.textdelta import TextDelta as Text from ....types.interactions.thoughtsignaturedelta import ( ThoughtSignatureDelta as ThoughtSignature, @@ -88,7 +90,7 @@ "MCPServerToolResult", "Metadata", "Text", - "TextAnnotationDelta", + "TextAnnotation", "ThoughtSignature", "ThoughtSummary", "URLContextCall", diff --git a/google/genai/_gaos/resources/interactions/stepstart/__init__.py b/google/genai/_gaos/resources/interactions/stepstart/__init__.py new file mode 100644 index 000000000..cefc54863 --- /dev/null +++ b/google/genai/_gaos/resources/interactions/stepstart/__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.streammetadata import StreamMetadata as Metadata + +__all__ = ["Metadata"] diff --git a/google/genai/_gaos/resources/interactions/stepstop/__init__.py b/google/genai/_gaos/resources/interactions/stepstop/__init__.py new file mode 100644 index 000000000..cefc54863 --- /dev/null +++ b/google/genai/_gaos/resources/interactions/stepstop/__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.streammetadata import StreamMetadata as Metadata + +__all__ = ["Metadata"] diff --git a/google/genai/_gaos/resources/interactions/urlcontextcallstep/__init__.py b/google/genai/_gaos/resources/interactions/urlcontextcallstep/__init__.py index 58edddb58..0088d72c1 100644 --- a/google/genai/_gaos/resources/interactions/urlcontextcallstep/__init__.py +++ b/google/genai/_gaos/resources/interactions/urlcontextcallstep/__init__.py @@ -16,8 +16,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ....types.interactions.urlcontextcallarguments import ( - URLContextCallArguments as Arguments, -) +from ....types.interactions.arguments import Arguments __all__ = ["Arguments"] diff --git a/google/genai/_gaos/resources/interactions/urlcontextresultstep/__init__.py b/google/genai/_gaos/resources/interactions/urlcontextresultstep/__init__.py index 1b6e9711a..e99023a9f 100644 --- a/google/genai/_gaos/resources/interactions/urlcontextresultstep/__init__.py +++ b/google/genai/_gaos/resources/interactions/urlcontextresultstep/__init__.py @@ -16,6 +16,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ....types.interactions.urlcontextresult import URLContextResult as Result +from ....types.interactions.urlcontextresultitem import URLContextResultItem as Result __all__ = ["Result"] diff --git a/google/genai/_gaos/resources/webhooks/__init__.py b/google/genai/_gaos/resources/webhooks/__init__.py index a029efd6d..dcc397f4b 100644 --- a/google/genai/_gaos/resources/webhooks/__init__.py +++ b/google/genai/_gaos/resources/webhooks/__init__.py @@ -16,7 +16,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" -from ...models.createwebhook import CreateWebhookRequestParam as WebhookCreateParams from ...models.deletewebhook import DeleteWebhookRequestParam as WebhookDeleteParams from ...models.getwebhook import GetWebhookRequestParam as WebhookGetParams from ...models.listwebhooks import ListWebhooksRequestParam as WebhookListParams @@ -30,7 +29,7 @@ RotateSigningSecretRequestParam as WebhookRotateSigningSecretParams, ) from ...types.webhooks.signingsecret import SigningSecret -from ...types.webhooks.webhook import Webhook, WebhookInputParam as WebhookInput +from ...types.webhooks.webhook import Webhook, WebhookInputParam as WebhookCreateParams from ...types.webhooks.webhooklistresponse import WebhookListResponse from ...types.webhooks.webhookpingresponse import WebhookPingResponse from ...types.webhooks.webhookrotatesigningsecretresponse import ( @@ -41,6 +40,7 @@ WebhookUpdateParam as WebhookUpdateParams, ) +WebhookInput = WebhookCreateParams __all__ = [ "PingWebhookRequest", "RotateSigningSecretRequest", diff --git a/google/genai/_gaos/sdk.py b/google/genai/_gaos/sdk.py index 06fd8e874..cbb8d4925 100644 --- a/google/genai/_gaos/sdk.py +++ b/google/genai/_gaos/sdk.py @@ -56,17 +56,17 @@ def with_raw_response(self): def with_streaming_response(self): return GenAIWithStreamingResponse(self) - interactions: "Interactions" - webhooks: "Webhooks" agents: "Agents" - triggers: "Triggers" environments: "Environments" + interactions: "Interactions" + triggers: "Triggers" + webhooks: "Webhooks" _sub_sdk_map = { - "interactions": (".interactions", "Interactions"), - "webhooks": (".webhooks", "Webhooks"), "agents": (".agents", "Agents"), - "triggers": (".triggers", "Triggers"), "environments": (".environments", "Environments"), + "interactions": (".interactions", "Interactions"), + "triggers": (".triggers", "Triggers"), + "webhooks": (".webhooks", "Webhooks"), } def __init__( @@ -74,6 +74,7 @@ def __init__( security: Optional[Union[types.Security, Callable[[], types.Security]]] = None, api_version: Optional[str] = None, user_project: Optional[str] = None, + api_revision: Optional[str] = None, server_idx: Optional[int] = None, url_params: Optional[Dict[str, str]] = None, server_url: Optional[str] = None, @@ -87,6 +88,7 @@ def __init__( :param security: The security details required for authentication :param api_version: Configures the api_version parameter for all supported operations :param user_project: Configures the user_project parameter for all supported operations + :param api_revision: Configures the api_revision parameter for all supported operations :param server_idx: The index of the server to use for all methods :param server_url: The server URL to use for all methods :param url_params: Parameters to optionally template the server URL with @@ -117,6 +119,9 @@ def __init__( user_project=utils.get_global_from_env( user_project, "GOOGLE_GENAI_USER_PROJECT", str ), + api_revision=utils.get_global_from_env( + api_revision, "GOOGLE_GENAI_API_REVISION", str + ), ) BaseSDK.__init__( @@ -211,24 +216,24 @@ def __init__(self, sdk: GenAI) -> None: self._sdk = sdk @property - def interactions(self): - return self._sdk.interactions.with_raw_response + def agents(self): + return self._sdk.agents.with_raw_response @property - def webhooks(self): - return self._sdk.webhooks.with_raw_response + def environments(self): + return self._sdk.environments.with_raw_response @property - def agents(self): - return self._sdk.agents.with_raw_response + def interactions(self): + return self._sdk.interactions.with_raw_response @property def triggers(self): return self._sdk.triggers.with_raw_response @property - def environments(self): - return self._sdk.environments.with_raw_response + def webhooks(self): + return self._sdk.webhooks.with_raw_response class GenAIWithStreamingResponse: @@ -236,24 +241,24 @@ def __init__(self, sdk: GenAI) -> None: self._sdk = sdk @property - def interactions(self): - return self._sdk.interactions.with_streaming_response + def agents(self): + return self._sdk.agents.with_streaming_response @property - def webhooks(self): - return self._sdk.webhooks.with_streaming_response + def environments(self): + return self._sdk.environments.with_streaming_response @property - def agents(self): - return self._sdk.agents.with_streaming_response + def interactions(self): + return self._sdk.interactions.with_streaming_response @property def triggers(self): return self._sdk.triggers.with_streaming_response @property - def environments(self): - return self._sdk.environments.with_streaming_response + def webhooks(self): + return self._sdk.webhooks.with_streaming_response class AsyncGenAI(AsyncBaseSDK): @@ -267,17 +272,17 @@ def with_raw_response(self): def with_streaming_response(self): return AsyncGenAIWithStreamingResponse(self) - interactions: "AsyncInteractions" - webhooks: "AsyncWebhooks" agents: "AsyncAgents" - triggers: "AsyncTriggers" environments: "AsyncEnvironments" + interactions: "AsyncInteractions" + triggers: "AsyncTriggers" + webhooks: "AsyncWebhooks" _sub_sdk_map = { - "interactions": (".interactions", "AsyncInteractions"), - "webhooks": (".webhooks", "AsyncWebhooks"), "agents": (".agents", "AsyncAgents"), - "triggers": (".triggers", "AsyncTriggers"), "environments": (".environments", "AsyncEnvironments"), + "interactions": (".interactions", "AsyncInteractions"), + "triggers": (".triggers", "AsyncTriggers"), + "webhooks": (".webhooks", "AsyncWebhooks"), } def __init__( @@ -285,6 +290,7 @@ def __init__( security: Optional[Union[types.Security, Callable[[], types.Security]]] = None, api_version: Optional[str] = None, user_project: Optional[str] = None, + api_revision: Optional[str] = None, server_idx: Optional[int] = None, url_params: Optional[Dict[str, str]] = None, server_url: Optional[str] = None, @@ -298,6 +304,7 @@ def __init__( :param security: The security details required for authentication :param api_version: Configures the api_version parameter for all supported operations :param user_project: Configures the user_project parameter for all supported operations + :param api_revision: Configures the api_revision parameter for all supported operations :param server_idx: The index of the server to use for all methods :param server_url: The server URL to use for all methods :param url_params: Parameters to optionally template the server URL with @@ -326,6 +333,9 @@ def __init__( user_project=utils.get_global_from_env( user_project, "GOOGLE_GENAI_USER_PROJECT", str ), + api_revision=utils.get_global_from_env( + api_revision, "GOOGLE_GENAI_API_REVISION", str + ), ) AsyncBaseSDK.__init__( @@ -420,24 +430,24 @@ def __init__(self, sdk: AsyncGenAI) -> None: self._sdk = sdk @property - def interactions(self): - return self._sdk.interactions.with_raw_response + def agents(self): + return self._sdk.agents.with_raw_response @property - def webhooks(self): - return self._sdk.webhooks.with_raw_response + def environments(self): + return self._sdk.environments.with_raw_response @property - def agents(self): - return self._sdk.agents.with_raw_response + def interactions(self): + return self._sdk.interactions.with_raw_response @property def triggers(self): return self._sdk.triggers.with_raw_response @property - def environments(self): - return self._sdk.environments.with_raw_response + def webhooks(self): + return self._sdk.webhooks.with_raw_response class AsyncGenAIWithStreamingResponse: @@ -445,21 +455,21 @@ def __init__(self, sdk: AsyncGenAI) -> None: self._sdk = sdk @property - def interactions(self): - return self._sdk.interactions.with_streaming_response + def agents(self): + return self._sdk.agents.with_streaming_response @property - def webhooks(self): - return self._sdk.webhooks.with_streaming_response + def environments(self): + return self._sdk.environments.with_streaming_response @property - def agents(self): - return self._sdk.agents.with_streaming_response + def interactions(self): + return self._sdk.interactions.with_streaming_response @property def triggers(self): return self._sdk.triggers.with_streaming_response @property - def environments(self): - return self._sdk.environments.with_streaming_response + def webhooks(self): + return self._sdk.webhooks.with_streaming_response diff --git a/google/genai/_gaos/triggers.py b/google/genai/_gaos/triggers.py index 4ec871e3f..608ceeefc 100644 --- a/google/genai/_gaos/triggers.py +++ b/google/genai/_gaos/triggers.py @@ -39,38 +39,29 @@ def with_raw_response(self): def with_streaming_response(self): return TriggersWithStreamingResponse(self) - def create( + def list( self, *, - schedule: str, - time_zone: str, - interaction: Union[ - triggers_triggercreateparams.Interaction, - triggers_triggercreateparams.InteractionParam, - ], - api_version: Optional[str] = None, - display_name: Optional[str] = None, - environment_id: Optional[str] = None, - max_consecutive_failures: Optional[int] = None, - execution_timeout_seconds: Optional[int] = None, + filter_: Optional[str] = None, + page_size: Optional[int] = None, + page_token: Optional[str] = None, + parent: Optional[str] = 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, - ) -> triggers.Trigger: - r"""Creates a new trigger that will invoke the specified agent on the given cron schedule. + ) -> triggers.ListTriggersResponse: + r"""Lists triggers for a project. - :param schedule: Required. The cron schedule on which the trigger should run. Standard cron format. - :param time_zone: Required. Time zone in which the schedule should be interpreted. - :param interaction: Required. The interaction request template to be executed. - :param api_version: Which version of the API to use. - :param display_name: Optional. The display name of the trigger. - :param environment_id: Optional. The environment ID for the trigger execution. - :param max_consecutive_failures: Optional. The maximum number of consecutive failures allowed before the trigger is automatically paused (status becomes ERROR). - :param execution_timeout_seconds: Optional. The execution timeout for the triggered interaction. + :param filter_: Optional. Filter expression (e.g. `agent=\"agents/my-agent-id\"`). Only + equality filtering on the `agent` field is currently supported. + :param page_size: The maximum number of triggers to return per page. + :param page_token: A page token from a previous ListTriggers call. + :param parent: Required. The parent resource to list triggers from. + Format: `projects/{project}/locations/{location}` + + Supported only by the Vertex API only. :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 @@ -87,47 +78,33 @@ def create( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateTriggerRequest( - api_version=api_version, - body=triggers.TriggerCreateParams( - schedule=schedule, - time_zone=time_zone, - display_name=display_name, - environment_id=environment_id, - max_consecutive_failures=max_consecutive_failures, - execution_timeout_seconds=execution_timeout_seconds, - interaction=utils.get_pydantic_model(interaction, triggers.Interaction), - ), + request = models.ListTriggersRequest( + filter_=filter_, + page_size=page_size, + page_token=page_token, + parent=parent, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="POST", + method="GET", path="/{api_version}/triggers", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.CreateTriggerGlobals( + _globals=models.ListTriggersGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - triggers.TriggerCreateParams, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -148,19 +125,34 @@ def create( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggersClientErrorData, http_res + ) + raise errors.ListTriggersClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggersServerErrorData, http_res + ) + raise errors.ListTriggersServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.Trigger, http_res, validate=False - ) - 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 + triggers.ListTriggersResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -168,7 +160,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="CreateTrigger", + operation_id="ListTriggers", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -222,25 +214,44 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def list( + def create( self, *, - api_version: Optional[str] = None, - filter_: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, + interaction: Union[ + triggers_triggercreateparams.Interaction, + triggers_triggercreateparams.InteractionParam, + ], + schedule: str, + time_zone: str, + parent: Optional[str] = None, + display_name: Optional[str] = None, + environment_id: Optional[str] = None, + execution_timeout_seconds: Optional[int] = None, + max_consecutive_failures: Optional[int] = 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, - ) -> triggers.ListTriggersResponse: - r"""Lists triggers for a project. + ) -> triggers.Trigger: + r"""Creates a new trigger that will invoke the specified agent + on the given cron schedule. - :param api_version: Which version of the API to use. - :param filter_: Optional. Filter expression (e.g., by state). - :param page_size: Optional. The maximum number of triggers to return per page. - :param page_token: Optional. A page token from a previous ListTriggers call. + :param interaction: Required. The interaction request template to be executed. + :param schedule: Required. The cron schedule on which the trigger should run. + Standard cron format. + :param time_zone: Required. Time zone in which the schedule should be interpreted. + :param parent: Required. The parent resource where this trigger will be created. + Format: `projects/{project}/locations/{location}` + + Supported only by the Vertex API only. + :param display_name: Optional. The display name of the trigger. + :param environment_id: Optional. The environment ID for the trigger execution. + :param execution_timeout_seconds: Optional. The execution timeout for the triggered interaction. + :param max_consecutive_failures: Optional. The maximum number of consecutive failures allowed before + the trigger is automatically paused (status becomes ERROR). :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 @@ -257,33 +268,47 @@ def list( else: base_url = self._get_url(base_url, url_variables) - request = models.ListTriggersRequest( - api_version=api_version, - filter_=filter_, - page_size=page_size, - page_token=page_token, + request = models.CreateTriggerRequest( + parent=parent, + body=triggers.TriggerCreateParams( + display_name=display_name, + environment_id=environment_id, + execution_timeout_seconds=execution_timeout_seconds, + interaction=utils.get_pydantic_model(interaction, triggers.Interaction), + max_consecutive_failures=max_consecutive_failures, + schedule=schedule, + time_zone=time_zone, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="GET", + method="POST", path="/{api_version}/triggers", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.ListTriggersGlobals( + _globals=models.CreateTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body, + False, + False, + "json", + triggers.TriggerCreateParams, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -304,19 +329,34 @@ def list( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateTriggerClientErrorData, http_res + ) + raise errors.CreateTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateTriggerServerErrorData, http_res + ) + raise errors.CreateTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.ListTriggersResponse, http_res, validate=False - ) - 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 + triggers.Trigger, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -324,7 +364,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListTriggers", + operation_id="CreateTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -382,15 +422,13 @@ def get( 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, ) -> triggers.Trigger: - r"""Gets details of a single trigger. + r"""Gets a trigger, including recent execution history. - :param id: Resource name of the trigger. - :param api_version: Which version of the API to use. + :param id: Required. The ID of the trigger to retrieve. :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 @@ -410,7 +448,6 @@ def get( base_url = self._get_url(base_url, url_variables) request = models.GetTriggerRequest( - api_version=api_version, id=id, ) @@ -454,20 +491,35 @@ def get( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetTriggerClientErrorData, http_res + ) + raise errors.GetTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetTriggerServerErrorData, http_res + ) + raise errors.GetTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( triggers.Trigger, http_res, validate=False ) - 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 - ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -528,27 +580,20 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def update( + def delete( self, id: str, *, - api_version: Optional[str] = None, - display_name: Optional[str] = None, - status: Optional[triggers_triggerupdate.TriggerUpdateStatus] = 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, - ) -> triggers.Trigger: - r"""Updates a trigger. + ) -> interactions.Empty: + r"""Deletes a trigger. Does not delete past interaction histories + or environments created by past executions. - :param id: Resource name of the trigger. - :param api_version: Which version of the API to use. - :param display_name: Optional. The display name of the trigger. - :param status: Optional. The status of the trigger. + :param id: Required. The ID of the trigger to delete. :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 @@ -565,43 +610,30 @@ def update( else: base_url = self._get_url(base_url, url_variables) - request = models.UpdateTriggerRequest( - api_version=api_version, + request = models.DeleteTriggerRequest( id=id, - body=triggers.TriggerUpdate( - display_name=display_name, - status=status, - ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="PATCH", + method="DELETE", path="/{api_version}/triggers/{id}", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.UpdateTriggerGlobals( + _globals=models.DeleteTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - triggers.TriggerUpdate, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -622,19 +654,34 @@ def update( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteTriggerClientErrorData, http_res + ) + raise errors.DeleteTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteTriggerServerErrorData, http_res + ) + raise errors.DeleteTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.Trigger, http_res, validate=False - ) - 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 + interactions.Empty, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -642,7 +689,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="UpdateTrigger", + operation_id="DeleteTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -696,21 +743,25 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def delete( + def update( self, id: str, *, - api_version: Optional[str] = None, + display_name: Optional[str] = None, + status: Optional[triggers_triggerupdate.TriggerUpdateStatus] = 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, - ) -> interactions.Empty: - r"""Deletes a trigger. + ) -> triggers.Trigger: + r"""Updates a trigger. Supports partial updates via field_mask. - :param id: Resource name of the trigger. - :param api_version: Which version of the API to use. + :param id: Required. The ID of the trigger to update. + :param display_name: Optional. The display name of the trigger. + :param status: Optional. The status of the trigger. :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 @@ -727,31 +778,42 @@ def delete( else: base_url = self._get_url(base_url, url_variables) - request = models.DeleteTriggerRequest( - api_version=api_version, + request = models.UpdateTriggerRequest( id=id, + body=triggers.TriggerUpdate( + display_name=display_name, + status=status, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="DELETE", + method="PATCH", path="/{api_version}/triggers/{id}", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.DeleteTriggerGlobals( + _globals=models.UpdateTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body, + False, + False, + "json", + triggers.TriggerUpdate, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -772,19 +834,34 @@ def delete( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateTriggerClientErrorData, http_res + ) + raise errors.UpdateTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateTriggerServerErrorData, http_res + ) + raise errors.UpdateTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - interactions.Empty, http_res, validate=False - ) - 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 + triggers.Trigger, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -792,7 +869,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="DeleteTrigger", + operation_id="UpdateTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -846,19 +923,23 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def run( + def list_executions( self, trigger_id: str, *, - api_version: Optional[str] = None, + filter_: 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, - ) -> triggers.TriggerExecution: - r"""Runs a trigger immediately. + ) -> triggers.ListTriggerExecutionsResponse: + r"""Lists executions for a trigger. - :param trigger_id: Resource name of the trigger. - :param api_version: Which version of the API to use. + :param trigger_id: Required. The trigger ID to list executions from. + :param filter_: Optional. Filter expression. + :param page_size: The maximum number of executions to return per page. + :param page_token: A page token from a previous ListTriggerExecutions call. :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 @@ -877,8 +958,10 @@ def run( else: base_url = self._get_url(base_url, url_variables) - request = models.RunTriggerRequest( - api_version=api_version, + request = models.ListTriggerExecutionsRequest( + filter_=filter_, + page_size=page_size, + page_token=page_token, trigger_id=trigger_id, ) @@ -886,8 +969,8 @@ def run( http_headers ) req = self._build_request( - method="POST", - path="/{api_version}/triggers/{trigger_id}/executions", + method="GET", + path="/{api_version}/triggers/{triggerId}/executions", base_url=base_url, url_variables=url_variables, request=request, @@ -898,7 +981,7 @@ def run( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.RunTriggerGlobals( + _globals=models.ListTriggerExecutionsGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -922,19 +1005,38 @@ def run( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggerExecutionsClientErrorData, http_res + ) + raise errors.ListTriggerExecutionsClientError( + response_data, http_res + ) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggerExecutionsServerErrorData, http_res + ) + raise errors.ListTriggerExecutionsServerError( + response_data, http_res + ) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.TriggerExecution, http_res, validate=False - ) - 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 + triggers.ListTriggerExecutionsResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -942,7 +1044,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="RunTrigger", + operation_id="ListTriggerExecutions", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -996,23 +1098,18 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def list_executions( + def run( self, trigger_id: str, *, - 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, - ) -> triggers.ListTriggerExecutionsResponse: - r"""Lists executions for a trigger. + ) -> triggers.TriggerExecution: + r"""Immediately fires a trigger, bypassing the cron schedule. + Useful for testing and manual runs. - :param trigger_id: Resource name of the trigger. - :param api_version: Which version of the API to use. - :param page_size: Optional. The maximum number of executions to return per page. - :param page_token: Optional. A page token from a previous ListTriggerExecutions call. + :param trigger_id: Required. The ID of the trigger to run immediately. :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 @@ -1031,19 +1128,16 @@ def list_executions( else: base_url = self._get_url(base_url, url_variables) - request = models.ListTriggerExecutionsRequest( - api_version=api_version, + request = models.RunTriggerRequest( trigger_id=trigger_id, - 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}/triggers/{trigger_id}/executions", + method="POST", + path="/{api_version}/triggers/{triggerId}/executions", base_url=base_url, url_variables=url_variables, request=request, @@ -1054,7 +1148,7 @@ def list_executions( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.ListTriggerExecutionsGlobals( + _globals=models.RunTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -1078,19 +1172,34 @@ def list_executions( retry_config = (retries, ["408", "409", "429", "5XX"]) def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RunTriggerClientErrorData, http_res + ) + raise errors.RunTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RunTriggerServerErrorData, http_res + ) + raise errors.RunTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.ListTriggerExecutionsResponse, http_res, validate=False - ) - 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 + triggers.TriggerExecution, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1098,7 +1207,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListTriggerExecutions", + operation_id="RunTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1156,47 +1265,47 @@ def _speakeasy_parse_response(http_res): class TriggersWithRawResponse: def __init__(self, sdk: Triggers) -> None: self._sdk = sdk + self.list = response_helpers.to_raw_response_wrapper(sdk.list, "extra_headers") self.create = response_helpers.to_raw_response_wrapper( sdk.create, "extra_headers" ) - self.list = response_helpers.to_raw_response_wrapper(sdk.list, "extra_headers") self.get = response_helpers.to_raw_response_wrapper(sdk.get, "extra_headers") - self.update = response_helpers.to_raw_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.to_raw_response_wrapper( sdk.delete, "extra_headers" ) - self.run = response_helpers.to_raw_response_wrapper(sdk.run, "extra_headers") + self.update = response_helpers.to_raw_response_wrapper( + sdk.update, "extra_headers" + ) self.list_executions = response_helpers.to_raw_response_wrapper( sdk.list_executions, "extra_headers" ) + self.run = response_helpers.to_raw_response_wrapper(sdk.run, "extra_headers") class TriggersWithStreamingResponse: def __init__(self, sdk: Triggers) -> None: self._sdk = sdk - self.create = response_helpers.to_streamed_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.to_streamed_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.to_streamed_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.to_streamed_response_wrapper( sdk.get, "extra_headers" ) - self.update = response_helpers.to_streamed_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.to_streamed_response_wrapper( sdk.delete, "extra_headers" ) - self.run = response_helpers.to_streamed_response_wrapper( - sdk.run, "extra_headers" + self.update = response_helpers.to_streamed_response_wrapper( + sdk.update, "extra_headers" ) self.list_executions = response_helpers.to_streamed_response_wrapper( sdk.list_executions, "extra_headers" ) + self.run = response_helpers.to_streamed_response_wrapper( + sdk.run, "extra_headers" + ) class AsyncTriggers(AsyncBaseSDK): @@ -1208,38 +1317,29 @@ def with_raw_response(self): def with_streaming_response(self): return AsyncTriggersWithStreamingResponse(self) - async def create( + async def list( self, *, - schedule: str, - time_zone: str, - interaction: Union[ - triggers_triggercreateparams.Interaction, - triggers_triggercreateparams.InteractionParam, - ], - api_version: Optional[str] = None, - display_name: Optional[str] = None, - environment_id: Optional[str] = None, - max_consecutive_failures: Optional[int] = None, - execution_timeout_seconds: Optional[int] = None, + filter_: Optional[str] = None, + page_size: Optional[int] = None, + page_token: Optional[str] = None, + parent: Optional[str] = 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, - ) -> triggers.Trigger: - r"""Creates a new trigger that will invoke the specified agent on the given cron schedule. + ) -> triggers.ListTriggersResponse: + r"""Lists triggers for a project. - :param schedule: Required. The cron schedule on which the trigger should run. Standard cron format. - :param time_zone: Required. Time zone in which the schedule should be interpreted. - :param interaction: Required. The interaction request template to be executed. - :param api_version: Which version of the API to use. - :param display_name: Optional. The display name of the trigger. - :param environment_id: Optional. The environment ID for the trigger execution. - :param max_consecutive_failures: Optional. The maximum number of consecutive failures allowed before the trigger is automatically paused (status becomes ERROR). - :param execution_timeout_seconds: Optional. The execution timeout for the triggered interaction. + :param filter_: Optional. Filter expression (e.g. `agent=\"agents/my-agent-id\"`). Only + equality filtering on the `agent` field is currently supported. + :param page_size: The maximum number of triggers to return per page. + :param page_token: A page token from a previous ListTriggers call. + :param parent: Required. The parent resource to list triggers from. + Format: `projects/{project}/locations/{location}` + + Supported only by the Vertex API only. :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 @@ -1256,47 +1356,33 @@ async def create( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateTriggerRequest( - api_version=api_version, - body=triggers.TriggerCreateParams( - schedule=schedule, - time_zone=time_zone, - display_name=display_name, - environment_id=environment_id, - max_consecutive_failures=max_consecutive_failures, - execution_timeout_seconds=execution_timeout_seconds, - interaction=utils.get_pydantic_model(interaction, triggers.Interaction), - ), + request = models.ListTriggersRequest( + filter_=filter_, + page_size=page_size, + page_token=page_token, + parent=parent, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="POST", + method="GET", path="/{api_version}/triggers", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.CreateTriggerGlobals( + _globals=models.ListTriggersGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - triggers.TriggerCreateParams, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1317,19 +1403,34 @@ async def create( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggersClientErrorData, http_res + ) + raise errors.ListTriggersClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggersServerErrorData, http_res + ) + raise errors.ListTriggersServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.Trigger, http_res, validate=False - ) - 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 + triggers.ListTriggersResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1337,7 +1438,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="CreateTrigger", + operation_id="ListTriggers", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1394,25 +1495,44 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def list( + async def create( self, *, - api_version: Optional[str] = None, - filter_: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, + interaction: Union[ + triggers_triggercreateparams.Interaction, + triggers_triggercreateparams.InteractionParam, + ], + schedule: str, + time_zone: str, + parent: Optional[str] = None, + display_name: Optional[str] = None, + environment_id: Optional[str] = None, + execution_timeout_seconds: Optional[int] = None, + max_consecutive_failures: Optional[int] = 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, - ) -> triggers.ListTriggersResponse: - r"""Lists triggers for a project. + ) -> triggers.Trigger: + r"""Creates a new trigger that will invoke the specified agent + on the given cron schedule. + + :param interaction: Required. The interaction request template to be executed. + :param schedule: Required. The cron schedule on which the trigger should run. + Standard cron format. + :param time_zone: Required. Time zone in which the schedule should be interpreted. + :param parent: Required. The parent resource where this trigger will be created. + Format: `projects/{project}/locations/{location}` - :param api_version: Which version of the API to use. - :param filter_: Optional. Filter expression (e.g., by state). - :param page_size: Optional. The maximum number of triggers to return per page. - :param page_token: Optional. A page token from a previous ListTriggers call. + Supported only by the Vertex API only. + :param display_name: Optional. The display name of the trigger. + :param environment_id: Optional. The environment ID for the trigger execution. + :param execution_timeout_seconds: Optional. The execution timeout for the triggered interaction. + :param max_consecutive_failures: Optional. The maximum number of consecutive failures allowed before + the trigger is automatically paused (status becomes ERROR). :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 @@ -1429,33 +1549,47 @@ async def list( else: base_url = self._get_url(base_url, url_variables) - request = models.ListTriggersRequest( - api_version=api_version, - filter_=filter_, - page_size=page_size, - page_token=page_token, + request = models.CreateTriggerRequest( + parent=parent, + body=triggers.TriggerCreateParams( + display_name=display_name, + environment_id=environment_id, + execution_timeout_seconds=execution_timeout_seconds, + interaction=utils.get_pydantic_model(interaction, triggers.Interaction), + max_consecutive_failures=max_consecutive_failures, + schedule=schedule, + time_zone=time_zone, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="GET", + method="POST", path="/{api_version}/triggers", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.ListTriggersGlobals( + _globals=models.CreateTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body, + False, + False, + "json", + triggers.TriggerCreateParams, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1476,19 +1610,34 @@ async def list( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateTriggerClientErrorData, http_res + ) + raise errors.CreateTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateTriggerServerErrorData, http_res + ) + raise errors.CreateTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.ListTriggersResponse, http_res, validate=False - ) - 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 + triggers.Trigger, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1496,7 +1645,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListTriggers", + operation_id="CreateTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1557,15 +1706,13 @@ async def get( 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, ) -> triggers.Trigger: - r"""Gets details of a single trigger. + r"""Gets a trigger, including recent execution history. - :param id: Resource name of the trigger. - :param api_version: Which version of the API to use. + :param id: Required. The ID of the trigger to retrieve. :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 @@ -1585,7 +1732,6 @@ async def get( base_url = self._get_url(base_url, url_variables) request = models.GetTriggerRequest( - api_version=api_version, id=id, ) @@ -1629,20 +1775,35 @@ async def get( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetTriggerClientErrorData, http_res + ) + raise errors.GetTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetTriggerServerErrorData, http_res + ) + raise errors.GetTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( triggers.Trigger, http_res, validate=False ) - 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 - ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1706,27 +1867,20 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def update( + async def delete( self, id: str, *, - api_version: Optional[str] = None, - display_name: Optional[str] = None, - status: Optional[triggers_triggerupdate.TriggerUpdateStatus] = 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, - ) -> triggers.Trigger: - r"""Updates a trigger. + ) -> interactions.Empty: + r"""Deletes a trigger. Does not delete past interaction histories + or environments created by past executions. - :param id: Resource name of the trigger. - :param api_version: Which version of the API to use. - :param display_name: Optional. The display name of the trigger. - :param status: Optional. The status of the trigger. + :param id: Required. The ID of the trigger to delete. :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 @@ -1743,43 +1897,30 @@ async def update( else: base_url = self._get_url(base_url, url_variables) - request = models.UpdateTriggerRequest( - api_version=api_version, + request = models.DeleteTriggerRequest( id=id, - body=triggers.TriggerUpdate( - display_name=display_name, - status=status, - ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="PATCH", + method="DELETE", path="/{api_version}/triggers/{id}", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.UpdateTriggerGlobals( + _globals=models.DeleteTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - triggers.TriggerUpdate, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1800,19 +1941,34 @@ async def update( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteTriggerClientErrorData, http_res + ) + raise errors.DeleteTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteTriggerServerErrorData, http_res + ) + raise errors.DeleteTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.Trigger, http_res, validate=False - ) - 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 + interactions.Empty, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1820,7 +1976,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="UpdateTrigger", + operation_id="DeleteTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1877,21 +2033,25 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def delete( + async def update( self, id: str, *, - api_version: Optional[str] = None, + display_name: Optional[str] = None, + status: Optional[triggers_triggerupdate.TriggerUpdateStatus] = 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, - ) -> interactions.Empty: - r"""Deletes a trigger. + ) -> triggers.Trigger: + r"""Updates a trigger. Supports partial updates via field_mask. - :param id: Resource name of the trigger. - :param api_version: Which version of the API to use. + :param id: Required. The ID of the trigger to update. + :param display_name: Optional. The display name of the trigger. + :param status: Optional. The status of the trigger. :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 @@ -1908,31 +2068,42 @@ async def delete( else: base_url = self._get_url(base_url, url_variables) - request = models.DeleteTriggerRequest( - api_version=api_version, + request = models.UpdateTriggerRequest( id=id, + body=triggers.TriggerUpdate( + display_name=display_name, + status=status, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="DELETE", + method="PATCH", path="/{api_version}/triggers/{id}", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.DeleteTriggerGlobals( + _globals=models.UpdateTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request.body, + False, + False, + "json", + triggers.TriggerUpdate, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1953,19 +2124,34 @@ async def delete( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateTriggerClientErrorData, http_res + ) + raise errors.UpdateTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateTriggerServerErrorData, http_res + ) + raise errors.UpdateTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - interactions.Empty, http_res, validate=False - ) - 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 + triggers.Trigger, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1973,7 +2159,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="DeleteTrigger", + operation_id="UpdateTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -2030,19 +2216,23 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def run( + async def list_executions( self, trigger_id: str, *, - api_version: Optional[str] = None, + filter_: 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, - ) -> triggers.TriggerExecution: - r"""Runs a trigger immediately. + ) -> triggers.ListTriggerExecutionsResponse: + r"""Lists executions for a trigger. - :param trigger_id: Resource name of the trigger. - :param api_version: Which version of the API to use. + :param trigger_id: Required. The trigger ID to list executions from. + :param filter_: Optional. Filter expression. + :param page_size: The maximum number of executions to return per page. + :param page_token: A page token from a previous ListTriggerExecutions call. :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 @@ -2061,8 +2251,10 @@ async def run( else: base_url = self._get_url(base_url, url_variables) - request = models.RunTriggerRequest( - api_version=api_version, + request = models.ListTriggerExecutionsRequest( + filter_=filter_, + page_size=page_size, + page_token=page_token, trigger_id=trigger_id, ) @@ -2070,8 +2262,8 @@ async def run( http_headers ) req = self._build_request_async( - method="POST", - path="/{api_version}/triggers/{trigger_id}/executions", + method="GET", + path="/{api_version}/triggers/{triggerId}/executions", base_url=base_url, url_variables=url_variables, request=request, @@ -2082,7 +2274,7 @@ async def run( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.RunTriggerGlobals( + _globals=models.ListTriggerExecutionsGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -2106,19 +2298,38 @@ async def run( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggerExecutionsClientErrorData, http_res + ) + raise errors.ListTriggerExecutionsClientError( + response_data, http_res + ) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListTriggerExecutionsServerErrorData, http_res + ) + raise errors.ListTriggerExecutionsServerError( + response_data, http_res + ) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.TriggerExecution, http_res, validate=False - ) - 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 + triggers.ListTriggerExecutionsResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -2126,7 +2337,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="RunTrigger", + operation_id="ListTriggerExecutions", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -2183,23 +2394,18 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def list_executions( + async def run( self, trigger_id: str, *, - 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, - ) -> triggers.ListTriggerExecutionsResponse: - r"""Lists executions for a trigger. + ) -> triggers.TriggerExecution: + r"""Immediately fires a trigger, bypassing the cron schedule. + Useful for testing and manual runs. - :param trigger_id: Resource name of the trigger. - :param api_version: Which version of the API to use. - :param page_size: Optional. The maximum number of executions to return per page. - :param page_token: Optional. A page token from a previous ListTriggerExecutions call. + :param trigger_id: Required. The ID of the trigger to run immediately. :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 @@ -2218,19 +2424,16 @@ async def list_executions( else: base_url = self._get_url(base_url, url_variables) - request = models.ListTriggerExecutionsRequest( - api_version=api_version, + request = models.RunTriggerRequest( trigger_id=trigger_id, - 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}/triggers/{trigger_id}/executions", + method="POST", + path="/{api_version}/triggers/{triggerId}/executions", base_url=base_url, url_variables=url_variables, request=request, @@ -2241,7 +2444,7 @@ async def list_executions( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.ListTriggerExecutionsGlobals( + _globals=models.RunTriggerGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -2265,19 +2468,34 @@ async def list_executions( retry_config = (retries, ["408", "409", "429", "5XX"]) async def _speakeasy_parse_response(http_res): - if utils.match_response(http_res, "200", "application/json"): + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RunTriggerClientErrorData, http_res + ) + raise errors.RunTriggerClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RunTriggerServerErrorData, http_res + ) + raise errors.RunTriggerServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - triggers.ListTriggerExecutionsResponse, http_res, validate=False - ) - 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 + triggers.TriggerExecution, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -2285,7 +2503,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListTriggerExecutions", + operation_id="RunTrigger", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -2346,50 +2564,50 @@ async def _speakeasy_parse_response(http_res): class AsyncTriggersWithRawResponse: def __init__(self, sdk: AsyncTriggers) -> None: self._sdk = sdk - self.create = response_helpers.async_to_raw_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.async_to_raw_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.async_to_raw_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.async_to_raw_response_wrapper( sdk.get, "extra_headers" ) - self.update = response_helpers.async_to_raw_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.async_to_raw_response_wrapper( sdk.delete, "extra_headers" ) - self.run = response_helpers.async_to_raw_response_wrapper( - sdk.run, "extra_headers" + self.update = response_helpers.async_to_raw_response_wrapper( + sdk.update, "extra_headers" ) self.list_executions = response_helpers.async_to_raw_response_wrapper( sdk.list_executions, "extra_headers" ) + self.run = response_helpers.async_to_raw_response_wrapper( + sdk.run, "extra_headers" + ) class AsyncTriggersWithStreamingResponse: def __init__(self, sdk: AsyncTriggers) -> None: self._sdk = sdk - self.create = response_helpers.async_to_streamed_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.async_to_streamed_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.async_to_streamed_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.async_to_streamed_response_wrapper( sdk.get, "extra_headers" ) - self.update = response_helpers.async_to_streamed_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.async_to_streamed_response_wrapper( sdk.delete, "extra_headers" ) - self.run = response_helpers.async_to_streamed_response_wrapper( - sdk.run, "extra_headers" + self.update = response_helpers.async_to_streamed_response_wrapper( + sdk.update, "extra_headers" ) self.list_executions = response_helpers.async_to_streamed_response_wrapper( sdk.list_executions, "extra_headers" ) + self.run = response_helpers.async_to_streamed_response_wrapper( + sdk.run, "extra_headers" + ) diff --git a/google/genai/_gaos/types/interactions/__init__.py b/google/genai/_gaos/types/interactions/__init__.py index 71bfd6481..0e9892f12 100644 --- a/google/genai/_gaos/types/interactions/__init__.py +++ b/google/genai/_gaos/types/interactions/__init__.py @@ -23,6 +23,7 @@ if TYPE_CHECKING: from .agentoption import AgentOption from .allowedtools import AllowedTools, AllowedToolsParam + from .allowlist import Allowlist, AllowlistParam from .allowlistentry import ( AllowlistEntry, AllowlistEntryParam, @@ -34,6 +35,7 @@ AntigravityAgentConfig, AntigravityAgentConfigParam, ) + from .arguments import Arguments, ArgumentsParam from .argumentsdelta import ArgumentsDelta, ArgumentsDeltaTypedDict from .audiocontent import AudioContent, AudioContentMimeType, AudioContentParam from .audiodelta import AudioDelta, AudioDeltaMimeType, AudioDeltaTypedDict @@ -80,6 +82,10 @@ CreateAgentInteractionResponseFormat, CreateAgentInteractionResponseFormatParam, ) + from .createinteractionrequest import ( + CreateInteractionRequest, + CreateInteractionRequestParam, + ) from .createmodelinteraction import ( CreateModelInteraction, CreateModelInteractionEnvironment, @@ -113,8 +119,6 @@ NetworkParam, ) from .environmentnetworkegressallowlist import ( - Allowlist, - AllowlistParam, Disabled, EnvironmentNetworkEgressAllowlist, EnvironmentNetworkEgressAllowlistParam, @@ -162,8 +166,8 @@ from .generationconfig import ( GenerationConfig, GenerationConfigParam, - SpeechConfigUnion, - SpeechConfigUnionParam, + StructuredSpeechConfig, + StructuredSpeechConfigParam, ToolChoice, ToolChoiceParam, ) @@ -270,6 +274,10 @@ InteractionStatusUpdateStatus, InteractionStatusUpdateTypedDict, ) + from .localenvironmentconfig import ( + LocalEnvironmentConfig, + LocalEnvironmentConfigParam, + ) from .mcpserver import MCPServer, MCPServerParam from .mcpservertoolcalldelta import ( MCPServerToolCallDelta, @@ -306,22 +314,30 @@ from .ragretrievalconfig import RagRetrievalConfig, RagRetrievalConfigParam from .ragstoreconfig import RagStoreConfig, RagStoreConfigParam from .ranking import Ranking, RankingParam + from .rankservice import RankService, RankServiceParam from .responseformat import ResponseFormat, ResponseFormatParam from .responsemodality import ResponseModality - from .retrieval import Retrieval, RetrievalParam, RetrievalRetrievalType + from .retrieval import Retrieval, RetrievalParam from .retrievalcallarguments import ( RetrievalCallArguments, - RetrievalCallArgumentsTypedDict, + RetrievalCallArgumentsParam, ) from .retrievalcalldelta import ( RetrievalCallDelta, RetrievalCallDeltaRetrievalType, RetrievalCallDeltaTypedDict, ) + from .retrievalcallstep import ( + RetrievalCallStep, + RetrievalCallStepParam, + RetrievalCallStepRetrievalType, + ) from .retrievalresultdelta import ( RetrievalResultDelta, RetrievalResultDeltaTypedDict, ) + from .retrievalresultstep import RetrievalResultStep, RetrievalResultStepParam + from .retrievaltype import RetrievalType from .reviewsnippet import ReviewSnippet, ReviewSnippetParam from .safetysetting import Method, SafetySetting, SafetySettingParam, Threshold from .servicetier import ServiceTier @@ -341,7 +357,12 @@ from .stepdeltametadata import StepDeltaMetadata, StepDeltaMetadataTypedDict from .stepstart import StepStart, StepStartTypedDict from .stepstop import StepStop, StepStopTypedDict - from .textannotationdelta import TextAnnotationDelta, TextAnnotationDeltaTypedDict + from .streammetadata import StreamMetadata, StreamMetadataTypedDict + from .textannotationdelta import ( + TextAnnotationDelta, + TextAnnotationDeltaType, + TextAnnotationDeltaTypedDict, + ) from .textcontent import TextContent, TextContentParam from .textdelta import TextDelta, TextDeltaTypedDict from .textresponseformat import ( @@ -366,26 +387,37 @@ from .toolchoiceconfig import ToolChoiceConfig, ToolChoiceConfigParam from .toolchoicetype import ToolChoiceType from .transcriptionconfig import TranscriptionConfig, TranscriptionConfigParam + from .turn import Turn, TurnContent, TurnContentParam, TurnParam from .urlcitation import URLCitation, URLCitationParam from .urlcontext import URLContext, URLContextParam from .urlcontextcallarguments import ( URLContextCallArguments, - URLContextCallArgumentsParam, + URLContextCallArgumentsTypedDict, ) from .urlcontextcalldelta import URLContextCallDelta, URLContextCallDeltaTypedDict from .urlcontextcallstep import URLContextCallStep, URLContextCallStepParam from .urlcontextresult import ( URLContextResult, - URLContextResultParam, URLContextResultStatus, + URLContextResultTypedDict, ) from .urlcontextresultdelta import ( URLContextResultDelta, URLContextResultDeltaTypedDict, ) + from .urlcontextresultitem import ( + URLContextResultItem, + URLContextResultItemParam, + URLContextResultItemStatus, + ) from .urlcontextresultstep import URLContextResultStep, URLContextResultStepParam from .usage import Usage, UsageTypedDict - from .userinputstep import UserInputStep, UserInputStepParam + from .userinputstep import ( + UserInputStep, + UserInputStepContent, + UserInputStepContentParam, + UserInputStepParam, + ) from .vertexaisearchconfig import VertexAISearchConfig, VertexAISearchConfigParam from .videoconfig import Task, VideoConfig, VideoConfigParam from .videocontent import ( @@ -419,8 +451,10 @@ "AnnotationParam", "AntigravityAgentConfig", "AntigravityAgentConfigParam", + "Arguments", "ArgumentsDelta", "ArgumentsDeltaTypedDict", + "ArgumentsParam", "AudioContent", "AudioContentMimeType", "AudioContentParam", @@ -457,6 +491,8 @@ "CreateAgentInteractionParam", "CreateAgentInteractionResponseFormat", "CreateAgentInteractionResponseFormatParam", + "CreateInteractionRequest", + "CreateInteractionRequestParam", "CreateModelInteraction", "CreateModelInteractionEnvironment", "CreateModelInteractionEnvironmentParam", @@ -610,6 +646,8 @@ "InteractionsInput", "InteractionsInputParam", "Language", + "LocalEnvironmentConfig", + "LocalEnvironmentConfigParam", "MCPServer", "MCPServerParam", "MCPServerToolCallDelta", @@ -654,6 +692,8 @@ "RagRetrievalConfigParam", "RagStoreConfig", "RagStoreConfigParam", + "RankService", + "RankServiceParam", "Ranking", "RankingParam", "Resolution", @@ -662,14 +702,19 @@ "ResponseModality", "Retrieval", "RetrievalCallArguments", - "RetrievalCallArgumentsTypedDict", + "RetrievalCallArgumentsParam", "RetrievalCallDelta", "RetrievalCallDeltaRetrievalType", "RetrievalCallDeltaTypedDict", + "RetrievalCallStep", + "RetrievalCallStepParam", + "RetrievalCallStepRetrievalType", "RetrievalParam", "RetrievalResultDelta", "RetrievalResultDeltaTypedDict", - "RetrievalRetrievalType", + "RetrievalResultStep", + "RetrievalResultStepParam", + "RetrievalType", "ReviewSnippet", "ReviewSnippetParam", "SafetySetting", @@ -684,8 +729,6 @@ "SpeakerConfigParam", "SpeechConfig", "SpeechConfigParam", - "SpeechConfigUnion", - "SpeechConfigUnionParam", "StaticMediaProcessing", "StaticMediaProcessingParam", "Status", @@ -702,8 +745,13 @@ "StepStartTypedDict", "StepStop", "StepStopTypedDict", + "StreamMetadata", + "StreamMetadataTypedDict", + "StructuredSpeechConfig", + "StructuredSpeechConfigParam", "Task", "TextAnnotationDelta", + "TextAnnotationDeltaType", "TextAnnotationDeltaTypedDict", "TextContent", "TextContentParam", @@ -734,11 +782,15 @@ "TranscriptionConfigParam", "Transform", "TransformParam", + "Turn", + "TurnContent", + "TurnContentParam", + "TurnParam", "URLCitation", "URLCitationParam", "URLContext", "URLContextCallArguments", - "URLContextCallArgumentsParam", + "URLContextCallArgumentsTypedDict", "URLContextCallDelta", "URLContextCallDeltaTypedDict", "URLContextCallStep", @@ -747,10 +799,13 @@ "URLContextResult", "URLContextResultDelta", "URLContextResultDeltaTypedDict", - "URLContextResultParam", + "URLContextResultItem", + "URLContextResultItemParam", + "URLContextResultItemStatus", "URLContextResultStatus", "URLContextResultStep", "URLContextResultStepParam", + "URLContextResultTypedDict", "UnknownAnnotation", "UnknownContent", "UnknownFunctionResultSubcontent", @@ -763,6 +818,8 @@ "Usage", "UsageTypedDict", "UserInputStep", + "UserInputStepContent", + "UserInputStepContentParam", "UserInputStepParam", "VertexAISearchConfig", "VertexAISearchConfigParam", @@ -789,6 +846,8 @@ "AgentOption": ".agentoption", "AllowedTools": ".allowedtools", "AllowedToolsParam": ".allowedtools", + "Allowlist": ".allowlist", + "AllowlistParam": ".allowlist", "AllowlistEntry": ".allowlistentry", "AllowlistEntryParam": ".allowlistentry", "Transform": ".allowlistentry", @@ -798,6 +857,8 @@ "UnknownAnnotation": ".annotation", "AntigravityAgentConfig": ".antigravityagentconfig", "AntigravityAgentConfigParam": ".antigravityagentconfig", + "Arguments": ".arguments", + "ArgumentsParam": ".arguments", "ArgumentsDelta": ".argumentsdelta", "ArgumentsDeltaTypedDict": ".argumentsdelta", "AudioContent": ".audiocontent", @@ -840,6 +901,8 @@ "CreateAgentInteractionParam": ".createagentinteraction", "CreateAgentInteractionResponseFormat": ".createagentinteraction", "CreateAgentInteractionResponseFormatParam": ".createagentinteraction", + "CreateInteractionRequest": ".createinteractionrequest", + "CreateInteractionRequestParam": ".createinteractionrequest", "CreateModelInteraction": ".createmodelinteraction", "CreateModelInteractionEnvironment": ".createmodelinteraction", "CreateModelInteractionEnvironmentParam": ".createmodelinteraction", @@ -864,8 +927,6 @@ "Network": ".environment", "NetworkEnum": ".environment", "NetworkParam": ".environment", - "Allowlist": ".environmentnetworkegressallowlist", - "AllowlistParam": ".environmentnetworkegressallowlist", "Disabled": ".environmentnetworkegressallowlist", "EnvironmentNetworkEgressAllowlist": ".environmentnetworkegressallowlist", "EnvironmentNetworkEgressAllowlistParam": ".environmentnetworkegressallowlist", @@ -919,8 +980,8 @@ "UnknownFunctionResultSubcontent": ".functionresultsubcontent", "GenerationConfig": ".generationconfig", "GenerationConfigParam": ".generationconfig", - "SpeechConfigUnion": ".generationconfig", - "SpeechConfigUnionParam": ".generationconfig", + "StructuredSpeechConfig": ".generationconfig", + "StructuredSpeechConfigParam": ".generationconfig", "ToolChoice": ".generationconfig", "ToolChoiceParam": ".generationconfig", "GoogleMaps": ".googlemaps", @@ -1004,6 +1065,8 @@ "InteractionStatusUpdate": ".interactionstatusupdate", "InteractionStatusUpdateStatus": ".interactionstatusupdate", "InteractionStatusUpdateTypedDict": ".interactionstatusupdate", + "LocalEnvironmentConfig": ".localenvironmentconfig", + "LocalEnvironmentConfigParam": ".localenvironmentconfig", "MCPServer": ".mcpserver", "MCPServerParam": ".mcpserver", "MCPServerToolCallDelta": ".mcpservertoolcalldelta", @@ -1042,19 +1105,26 @@ "RagStoreConfigParam": ".ragstoreconfig", "Ranking": ".ranking", "RankingParam": ".ranking", + "RankService": ".rankservice", + "RankServiceParam": ".rankservice", "ResponseFormat": ".responseformat", "ResponseFormatParam": ".responseformat", "ResponseModality": ".responsemodality", "Retrieval": ".retrieval", "RetrievalParam": ".retrieval", - "RetrievalRetrievalType": ".retrieval", "RetrievalCallArguments": ".retrievalcallarguments", - "RetrievalCallArgumentsTypedDict": ".retrievalcallarguments", + "RetrievalCallArgumentsParam": ".retrievalcallarguments", "RetrievalCallDelta": ".retrievalcalldelta", "RetrievalCallDeltaRetrievalType": ".retrievalcalldelta", "RetrievalCallDeltaTypedDict": ".retrievalcalldelta", + "RetrievalCallStep": ".retrievalcallstep", + "RetrievalCallStepParam": ".retrievalcallstep", + "RetrievalCallStepRetrievalType": ".retrievalcallstep", "RetrievalResultDelta": ".retrievalresultdelta", "RetrievalResultDeltaTypedDict": ".retrievalresultdelta", + "RetrievalResultStep": ".retrievalresultstep", + "RetrievalResultStepParam": ".retrievalresultstep", + "RetrievalType": ".retrievaltype", "ReviewSnippet": ".reviewsnippet", "ReviewSnippetParam": ".reviewsnippet", "Method": ".safetysetting", @@ -1089,7 +1159,10 @@ "StepStartTypedDict": ".stepstart", "StepStop": ".stepstop", "StepStopTypedDict": ".stepstop", + "StreamMetadata": ".streammetadata", + "StreamMetadataTypedDict": ".streammetadata", "TextAnnotationDelta": ".textannotationdelta", + "TextAnnotationDeltaType": ".textannotationdelta", "TextAnnotationDeltaTypedDict": ".textannotationdelta", "TextContent": ".textcontent", "TextContentParam": ".textcontent", @@ -1117,26 +1190,35 @@ "ToolChoiceType": ".toolchoicetype", "TranscriptionConfig": ".transcriptionconfig", "TranscriptionConfigParam": ".transcriptionconfig", + "Turn": ".turn", + "TurnContent": ".turn", + "TurnContentParam": ".turn", + "TurnParam": ".turn", "URLCitation": ".urlcitation", "URLCitationParam": ".urlcitation", "URLContext": ".urlcontext", "URLContextParam": ".urlcontext", "URLContextCallArguments": ".urlcontextcallarguments", - "URLContextCallArgumentsParam": ".urlcontextcallarguments", + "URLContextCallArgumentsTypedDict": ".urlcontextcallarguments", "URLContextCallDelta": ".urlcontextcalldelta", "URLContextCallDeltaTypedDict": ".urlcontextcalldelta", "URLContextCallStep": ".urlcontextcallstep", "URLContextCallStepParam": ".urlcontextcallstep", "URLContextResult": ".urlcontextresult", - "URLContextResultParam": ".urlcontextresult", "URLContextResultStatus": ".urlcontextresult", + "URLContextResultTypedDict": ".urlcontextresult", "URLContextResultDelta": ".urlcontextresultdelta", "URLContextResultDeltaTypedDict": ".urlcontextresultdelta", + "URLContextResultItem": ".urlcontextresultitem", + "URLContextResultItemParam": ".urlcontextresultitem", + "URLContextResultItemStatus": ".urlcontextresultitem", "URLContextResultStep": ".urlcontextresultstep", "URLContextResultStepParam": ".urlcontextresultstep", "Usage": ".usage", "UsageTypedDict": ".usage", "UserInputStep": ".userinputstep", + "UserInputStepContent": ".userinputstep", + "UserInputStepContentParam": ".userinputstep", "UserInputStepParam": ".userinputstep", "VertexAISearchConfig": ".vertexaisearchconfig", "VertexAISearchConfigParam": ".vertexaisearchconfig", diff --git a/google/genai/_gaos/types/interactions/allowlist.py b/google/genai/_gaos/types/interactions/allowlist.py new file mode 100644 index 000000000..e4bd9f5e1 --- /dev/null +++ b/google/genai/_gaos/types/interactions/allowlist.py @@ -0,0 +1,54 @@ +# 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 .allowlistentry import AllowlistEntry, AllowlistEntryParam +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class AllowlistParam(TypedDict): + r"""Network egress configuration for the environment.""" + + allowlist: NotRequired[List[AllowlistEntryParam]] + r"""List of allowed domains and their configurations.""" + + +class Allowlist(BaseModel): + r"""Network egress configuration for the environment.""" + + allowlist: Optional[List[AllowlistEntry]] = None + r"""List of allowed domains and their configurations.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["allowlist"]) + 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/interactions/allowlistentry.py b/google/genai/_gaos/types/interactions/allowlistentry.py index 3968fa31c..8fc3fd444 100644 --- a/google/genai/_gaos/types/interactions/allowlistentry.py +++ b/google/genai/_gaos/types/interactions/allowlistentry.py @@ -24,29 +24,43 @@ TransformParam = TypeAliasType( - "TransformParam", Union[Dict[str, str], List[Dict[str, str]]] + "TransformParam", Union[List[Dict[str, str]], Dict[str, str]] ) r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically.""" -Transform = TypeAliasType("Transform", Union[Dict[str, str], List[Dict[str, str]]]) +Transform = TypeAliasType("Transform", Union[List[Dict[str, str]], Dict[str, str]]) r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically.""" class AllowlistEntryParam(TypedDict): - r"""A single domain allowlist rule with optional header injection.""" + r"""A network egress rule that controls which external domains the + environment is allowed to reach. Each rule identifies a target domain + and, optionally, a set of HTTP headers to inject into every matching + outbound request. + """ domain: str - r"""Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). Use '*' to allow all domains.""" + r"""The domain pattern to match for this rule. + Use an exact hostname (e.g., `github.com`), a wildcard prefix + (e.g., `*.googleapis.com`), or `*` to match all domains. + """ transform: NotRequired[TransformParam] r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically.""" class AllowlistEntry(BaseModel): - r"""A single domain allowlist rule with optional header injection.""" + r"""A network egress rule that controls which external domains the + environment is allowed to reach. Each rule identifies a target domain + and, optionally, a set of HTTP headers to inject into every matching + outbound request. + """ domain: str - r"""Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). Use '*' to allow all domains.""" + r"""The domain pattern to match for this rule. + Use an exact hostname (e.g., `github.com`), a wildcard prefix + (e.g., `*.googleapis.com`), or `*` to match all domains. + """ transform: Optional[Transform] = None r"""Headers to inject on all outbound requests matching this domain. Accepts a single dict or a list of dicts. The egress proxy injects these automatically.""" diff --git a/google/genai/_gaos/types/interactions/arguments.py b/google/genai/_gaos/types/interactions/arguments.py new file mode 100644 index 000000000..8cd339df1 --- /dev/null +++ b/google/genai/_gaos/types/interactions/arguments.py @@ -0,0 +1,53 @@ +# 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 pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class ArgumentsParam(TypedDict): + r"""The arguments to pass to the URL context.""" + + urls: NotRequired[List[str]] + r"""The URLs to fetch.""" + + +class Arguments(BaseModel): + r"""The arguments to pass to the URL context.""" + + urls: Optional[List[str]] = None + r"""The URLs to fetch.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["urls"]) + 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/interactions/audiodelta.py b/google/genai/_gaos/types/interactions/audiodelta.py index 910e99cec..20b26f46c 100644 --- a/google/genai/_gaos/types/interactions/audiodelta.py +++ b/google/genai/_gaos/types/interactions/audiodelta.py @@ -50,12 +50,12 @@ class AudioDeltaTypedDict(TypedDict): r"""The number of audio channels.""" data: NotRequired[str] mime_type: NotRequired[AudioDeltaMimeType] - rate: NotRequired[int] - r"""Deprecated. Use sample_rate instead. The value is ignored.""" sample_rate: NotRequired[int] r"""The sample rate of the audio.""" type: Literal["audio"] uri: NotRequired[str] + rate: NotRequired[int] + r"""Deprecated. Use sample_rate instead. The value is ignored.""" class AudioDelta(BaseModel): @@ -66,14 +66,6 @@ class AudioDelta(BaseModel): mime_type: Optional[AudioDeltaMimeType] = None - rate: Annotated[ - Optional[int], - pydantic.Field( - deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." - ), - ] = None - r"""Deprecated. Use sample_rate instead. The value is ignored.""" - sample_rate: Optional[int] = None r"""The sample rate of the audio.""" @@ -84,10 +76,18 @@ class AudioDelta(BaseModel): uri: Optional[str] = None + rate: Annotated[ + Optional[int], + pydantic.Field( + deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." + ), + ] = None + r"""Deprecated. Use sample_rate instead. The value is ignored.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( - ["channels", "data", "mime_type", "rate", "sample_rate", "uri"] + ["channels", "data", "mime_type", "sample_rate", "uri", "rate"] ) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/codeexecutioncalldelta.py b/google/genai/_gaos/types/interactions/codeexecutioncalldelta.py index 3eb9027db..004b7ef0b 100644 --- a/google/genai/_gaos/types/interactions/codeexecutioncalldelta.py +++ b/google/genai/_gaos/types/interactions/codeexecutioncalldelta.py @@ -33,6 +33,8 @@ class CodeExecutionCallDeltaTypedDict(TypedDict): arguments: CodeExecutionCallArgumentsParam r"""The arguments to pass to the code execution.""" + id: NotRequired[str] + r"""Required. A unique ID for this specific tool call.""" signature: NotRequired[str] r"""A signature hash for backend validation.""" type: Literal["code_execution_call"] @@ -42,6 +44,9 @@ class CodeExecutionCallDelta(BaseModel): arguments: CodeExecutionCallArguments r"""The arguments to pass to the code execution.""" + id: Optional[str] = None + r"""Required. A unique ID for this specific tool call.""" + signature: Optional[str] = None r"""A signature hash for backend validation.""" @@ -55,7 +60,7 @@ class CodeExecutionCallDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["signature"]) + optional_fields = set(["id", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/codeexecutionresultdelta.py b/google/genai/_gaos/types/interactions/codeexecutionresultdelta.py index 34cfcc912..a56465db8 100644 --- a/google/genai/_gaos/types/interactions/codeexecutionresultdelta.py +++ b/google/genai/_gaos/types/interactions/codeexecutionresultdelta.py @@ -28,6 +28,8 @@ class CodeExecutionResultDeltaTypedDict(TypedDict): result: str + call_id: NotRequired[str] + r"""Required. ID to match the ID from the function call block.""" is_error: NotRequired[bool] signature: NotRequired[str] r"""A signature hash for backend validation.""" @@ -37,6 +39,9 @@ class CodeExecutionResultDeltaTypedDict(TypedDict): class CodeExecutionResultDelta(BaseModel): result: str + call_id: Optional[str] = None + r"""Required. ID to match the ID from the function call block.""" + is_error: Optional[bool] = None signature: Optional[str] = None @@ -52,7 +57,7 @@ class CodeExecutionResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["is_error", "signature"]) + optional_fields = set(["call_id", "is_error", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/content.py b/google/genai/_gaos/types/interactions/content.py index 8fd96d054..7941c7c6e 100644 --- a/google/genai/_gaos/types/interactions/content.py +++ b/google/genai/_gaos/types/interactions/content.py @@ -55,20 +55,20 @@ class UnknownContent(BaseModel): _CONTENT_VARIANTS: dict[str, Any] = { - "text": TextContent, - "image": ImageContent, "audio": AudioContent, "document": DocumentContent, + "image": ImageContent, + "text": TextContent, "video": VideoContent, } Content = Annotated[ Union[ - TextContent, - ImageContent, AudioContent, DocumentContent, + ImageContent, + TextContent, VideoContent, UnknownContent, ], diff --git a/google/genai/_gaos/types/interactions/createagentinteraction.py b/google/genai/_gaos/types/interactions/createagentinteraction.py index f91c4cc43..75b4d369b 100644 --- a/google/genai/_gaos/types/interactions/createagentinteraction.py +++ b/google/genai/_gaos/types/interactions/createagentinteraction.py @@ -28,6 +28,7 @@ from .dynamicagentconfig import DynamicAgentConfig, DynamicAgentConfigParam from .environment import Environment, EnvironmentParam from .interactionsinput import InteractionsInput, InteractionsInputParam +from .localenvironmentconfig import LocalEnvironmentConfig, LocalEnvironmentConfigParam from .responseformat import ResponseFormat, ResponseFormatParam from .responsemodality import ResponseModality from .safetysetting import SafetySetting, SafetySettingParam @@ -40,31 +41,6 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict -CreateAgentInteractionResponseFormatParam = TypeAliasType( - "CreateAgentInteractionResponseFormatParam", - Union[List[ResponseFormatParam], ResponseFormatParam], -) -r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - - -CreateAgentInteractionResponseFormat = TypeAliasType( - "CreateAgentInteractionResponseFormat", Union[List[ResponseFormat], ResponseFormat] -) -r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - - -CreateAgentInteractionEnvironmentParam = TypeAliasType( - "CreateAgentInteractionEnvironmentParam", Union[EnvironmentParam, str] -) -r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - - -CreateAgentInteractionEnvironment = TypeAliasType( - "CreateAgentInteractionEnvironment", Union[Environment, str] -) -r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - - CreateAgentInteractionAgentConfigParam = TypeAliasType( "CreateAgentInteractionAgentConfigParam", Union[ @@ -74,76 +50,129 @@ CodeMenderAgentConfigParam, ], ) -r"""Configuration parameters for the agent interaction.""" +r"""Parameters for the agent interaction.""" CreateAgentInteractionAgentConfig = Annotated[ Union[ - DynamicAgentConfig, - DeepResearchAgentConfig, - CodeMenderAgentConfig, AntigravityAgentConfig, + CodeMenderAgentConfig, + DeepResearchAgentConfig, + DynamicAgentConfig, ], Field(discriminator="type"), ] -r"""Configuration parameters for the agent interaction.""" +r"""Parameters for the agent interaction.""" + + +CreateAgentInteractionEnvironmentParam = TypeAliasType( + "CreateAgentInteractionEnvironmentParam", + Union[LocalEnvironmentConfigParam, EnvironmentParam, str], +) +r"""The environment configuration for the interaction.""" + + +CreateAgentInteractionEnvironment = TypeAliasType( + "CreateAgentInteractionEnvironment", Union[LocalEnvironmentConfig, Environment, str] +) +r"""The environment configuration for the interaction.""" + + +CreateAgentInteractionResponseFormatParam = TypeAliasType( + "CreateAgentInteractionResponseFormatParam", + Union[ResponseFormatParam, List[ResponseFormatParam]], +) + + +CreateAgentInteractionResponseFormat = TypeAliasType( + "CreateAgentInteractionResponseFormat", Union[ResponseFormat, List[ResponseFormat]] +) class CreateAgentInteractionParam(TypedDict): - r"""Parameters for creating agent interactions""" + r"""Interaction for generating the completion using agents.""" agent: AgentOption r"""The agent to interact with.""" - input: InteractionsInputParam - r"""The input for the interaction.""" - stream: NotRequired[bool] - r"""Input only. Whether the interaction will be streamed.""" - store: NotRequired[bool] - r"""Input only. Whether to store the response and request for later retrieval.""" + agent_config: NotRequired[CreateAgentInteractionAgentConfigParam] + r"""Parameters for the agent interaction.""" background: NotRequired[bool] r"""Input only. Whether to run the model interaction in the background.""" + environment: NotRequired[CreateAgentInteractionEnvironmentParam] + r"""The environment configuration for the interaction.""" + labels: NotRequired[Dict[str, str]] + r"""The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + """ + previous_interaction_id: NotRequired[str] + r"""The ID of the previous interaction, if any.""" + response_format: NotRequired[CreateAgentInteractionResponseFormatParam] + safety_settings: NotRequired[List[SafetySettingParam]] + r"""Safety settings for the interaction.""" + service_tier: NotRequired[ServiceTier] + store: NotRequired[bool] + r"""Input only. Whether to store the response and request for later retrieval.""" + stream: NotRequired[bool] + r"""Input only. Whether the interaction will be streamed.""" system_instruction: NotRequired[str] r"""System instruction for the interaction.""" tools: NotRequired[List[ToolParam]] r"""A list of tool declarations the model may call during interaction.""" + webhook_config: NotRequired[WebhookConfigParam] + r"""Message for configuring webhook events for a request.""" response_modalities: NotRequired[List[ResponseModality]] r"""The requested modalities of the response (TEXT, IMAGE, AUDIO).""" response_mime_type: NotRequired[str] r"""The mime type of the response. This is required if response_format is set.""" - previous_interaction_id: NotRequired[str] - r"""The ID of the previous interaction, if any.""" - service_tier: NotRequired[ServiceTier] - webhook_config: NotRequired[WebhookConfigParam] - r"""Message for configuring webhook events for a request.""" - response_format: NotRequired[CreateAgentInteractionResponseFormatParam] - r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - environment: NotRequired[CreateAgentInteractionEnvironmentParam] - r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - agent_config: NotRequired[CreateAgentInteractionAgentConfigParam] - r"""Configuration parameters for the agent interaction.""" - safety_settings: NotRequired[List[SafetySettingParam]] - r"""Safety settings for the interaction.""" - labels: NotRequired[Dict[str, str]] - r"""The labels with user-defined metadata for the request.""" + input: NotRequired[InteractionsInputParam] + r"""The input for the interaction.""" class CreateAgentInteraction(BaseModel): - r"""Parameters for creating agent interactions""" + r"""Interaction for generating the completion using agents.""" agent: AgentOption r"""The agent to interact with.""" - input: InteractionsInput - r"""The input for the interaction.""" + agent_config: Optional[CreateAgentInteractionAgentConfig] = None + r"""Parameters for the agent interaction.""" - stream: Optional[bool] = None - r"""Input only. Whether the interaction will be streamed.""" + background: Optional[bool] = None + r"""Input only. Whether to run the model interaction in the background.""" + + environment: Optional[CreateAgentInteractionEnvironment] = None + r"""The environment configuration for the interaction.""" + + labels: Optional[Dict[str, str]] = None + r"""The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + """ + + previous_interaction_id: Optional[str] = None + r"""The ID of the previous interaction, if any.""" + + response_format: Optional[CreateAgentInteractionResponseFormat] = None + + safety_settings: Optional[List[SafetySetting]] = None + r"""Safety settings for the interaction.""" + + service_tier: Optional[ServiceTier] = None store: Optional[bool] = None r"""Input only. Whether to store the response and request for later retrieval.""" - background: Optional[bool] = None - r"""Input only. Whether to run the model interaction in the background.""" + stream: Optional[bool] = None + r"""Input only. Whether the interaction will be streamed.""" system_instruction: Optional[str] = None r"""System instruction for the interaction.""" @@ -151,6 +180,9 @@ class CreateAgentInteraction(BaseModel): tools: Optional[List[Tool]] = None r"""A list of tool declarations the model may call during interaction.""" + webhook_config: Optional[WebhookConfig] = None + r"""Message for configuring webhook events for a request.""" + response_modalities: Annotated[ Optional[List[ResponseModality]], pydantic.Field( @@ -167,48 +199,29 @@ class CreateAgentInteraction(BaseModel): ] = None r"""The mime type of the response. This is required if response_format is set.""" - previous_interaction_id: Optional[str] = None - r"""The ID of the previous interaction, if any.""" - - service_tier: Optional[ServiceTier] = None - - webhook_config: Optional[WebhookConfig] = None - r"""Message for configuring webhook events for a request.""" - - response_format: Optional[CreateAgentInteractionResponseFormat] = None - r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - - environment: Optional[CreateAgentInteractionEnvironment] = None - r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - - agent_config: Optional[CreateAgentInteractionAgentConfig] = None - r"""Configuration parameters for the agent interaction.""" - - safety_settings: Optional[List[SafetySetting]] = None - r"""Safety settings for the interaction.""" - - labels: Optional[Dict[str, str]] = None - r"""The labels with user-defined metadata for the request.""" + input: Optional[InteractionsInput] = None + r"""The input for the interaction.""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ - "stream", - "store", + "agent_config", "background", + "environment", + "labels", + "previous_interaction_id", + "response_format", + "safety_settings", + "service_tier", + "store", + "stream", "system_instruction", "tools", + "webhook_config", "response_modalities", "response_mime_type", - "previous_interaction_id", - "service_tier", - "webhook_config", - "response_format", - "environment", - "agent_config", - "safety_settings", - "labels", + "input", ] ) serialized = handler(self) diff --git a/google/genai/_gaos/types/interactions/createinteractionrequest.py b/google/genai/_gaos/types/interactions/createinteractionrequest.py new file mode 100644 index 000000000..e59285461 --- /dev/null +++ b/google/genai/_gaos/types/interactions/createinteractionrequest.py @@ -0,0 +1,36 @@ +# 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 .createagentinteraction import CreateAgentInteraction, CreateAgentInteractionParam +from .createmodelinteraction import CreateModelInteraction, CreateModelInteractionParam +from typing import Union +from typing_extensions import TypeAliasType + + +CreateInteractionRequestParam = TypeAliasType( + "CreateInteractionRequestParam", + Union[CreateAgentInteractionParam, CreateModelInteractionParam], +) +r"""Configuration parameters for creating an interaction.""" + + +CreateInteractionRequest = TypeAliasType( + "CreateInteractionRequest", Union[CreateAgentInteraction, CreateModelInteraction] +) +r"""Configuration parameters for creating an interaction.""" diff --git a/google/genai/_gaos/types/interactions/createmodelinteraction.py b/google/genai/_gaos/types/interactions/createmodelinteraction.py index 7d1efd340..8e9980632 100644 --- a/google/genai/_gaos/types/interactions/createmodelinteraction.py +++ b/google/genai/_gaos/types/interactions/createmodelinteraction.py @@ -21,6 +21,7 @@ from .environment import Environment, EnvironmentParam from .generationconfig import GenerationConfig, GenerationConfigParam from .interactionsinput import InteractionsInput, InteractionsInputParam +from .localenvironmentconfig import LocalEnvironmentConfig, LocalEnvironmentConfigParam from .model import Model from .responseformat import ResponseFormat, ResponseFormatParam from .responsemodality import ResponseModality @@ -34,86 +35,114 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict -CreateModelInteractionResponseFormatParam = TypeAliasType( - "CreateModelInteractionResponseFormatParam", - Union[List[ResponseFormatParam], ResponseFormatParam], +CreateModelInteractionEnvironmentParam = TypeAliasType( + "CreateModelInteractionEnvironmentParam", + Union[LocalEnvironmentConfigParam, EnvironmentParam, str], ) -r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" +r"""The environment configuration for the interaction.""" -CreateModelInteractionResponseFormat = TypeAliasType( - "CreateModelInteractionResponseFormat", Union[List[ResponseFormat], ResponseFormat] +CreateModelInteractionEnvironment = TypeAliasType( + "CreateModelInteractionEnvironment", Union[LocalEnvironmentConfig, Environment, str] ) -r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" +r"""The environment configuration for the interaction.""" -CreateModelInteractionEnvironmentParam = TypeAliasType( - "CreateModelInteractionEnvironmentParam", Union[EnvironmentParam, str] +CreateModelInteractionResponseFormatParam = TypeAliasType( + "CreateModelInteractionResponseFormatParam", + Union[ResponseFormatParam, List[ResponseFormatParam]], ) -r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" -CreateModelInteractionEnvironment = TypeAliasType( - "CreateModelInteractionEnvironment", Union[Environment, str] +CreateModelInteractionResponseFormat = TypeAliasType( + "CreateModelInteractionResponseFormat", Union[ResponseFormat, List[ResponseFormat]] ) -r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" class CreateModelInteractionParam(TypedDict): - r"""Parameters for creating model interactions""" + r"""Interaction for generating the completion using models.""" model: Model r"""The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.""" - input: InteractionsInputParam - r"""The input for the interaction.""" - stream: NotRequired[bool] - r"""Input only. Whether the interaction will be streamed.""" - store: NotRequired[bool] - r"""Input only. Whether to store the response and request for later retrieval.""" background: NotRequired[bool] r"""Input only. Whether to run the model interaction in the background.""" + environment: NotRequired[CreateModelInteractionEnvironmentParam] + r"""The environment configuration for the interaction.""" + generation_config: NotRequired[GenerationConfigParam] + r"""Configuration parameters for model interactions.""" + labels: NotRequired[Dict[str, str]] + r"""The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + """ + previous_interaction_id: NotRequired[str] + r"""The ID of the previous interaction, if any.""" + response_format: NotRequired[CreateModelInteractionResponseFormatParam] + safety_settings: NotRequired[List[SafetySettingParam]] + r"""Safety settings for the interaction.""" + service_tier: NotRequired[ServiceTier] + store: NotRequired[bool] + r"""Input only. Whether to store the response and request for later retrieval.""" + stream: NotRequired[bool] + r"""Input only. Whether the interaction will be streamed.""" system_instruction: NotRequired[str] r"""System instruction for the interaction.""" tools: NotRequired[List[ToolParam]] r"""A list of tool declarations the model may call during interaction.""" + webhook_config: NotRequired[WebhookConfigParam] + r"""Message for configuring webhook events for a request.""" response_modalities: NotRequired[List[ResponseModality]] r"""The requested modalities of the response (TEXT, IMAGE, AUDIO).""" response_mime_type: NotRequired[str] r"""The mime type of the response. This is required if response_format is set.""" - previous_interaction_id: NotRequired[str] - r"""The ID of the previous interaction, if any.""" - service_tier: NotRequired[ServiceTier] - webhook_config: NotRequired[WebhookConfigParam] - r"""Message for configuring webhook events for a request.""" - response_format: NotRequired[CreateModelInteractionResponseFormatParam] - r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - environment: NotRequired[CreateModelInteractionEnvironmentParam] - r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - generation_config: NotRequired[GenerationConfigParam] - r"""Configuration parameters for model interactions.""" - safety_settings: NotRequired[List[SafetySettingParam]] - r"""Safety settings for the interaction.""" - labels: NotRequired[Dict[str, str]] - r"""The labels with user-defined metadata for the request.""" + input: NotRequired[InteractionsInputParam] + r"""The input for the interaction.""" class CreateModelInteraction(BaseModel): - r"""Parameters for creating model interactions""" + r"""Interaction for generating the completion using models.""" model: Model r"""The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.""" - input: InteractionsInput - r"""The input for the interaction.""" + background: Optional[bool] = None + r"""Input only. Whether to run the model interaction in the background.""" - stream: Optional[bool] = None - r"""Input only. Whether the interaction will be streamed.""" + environment: Optional[CreateModelInteractionEnvironment] = None + r"""The environment configuration for the interaction.""" + + generation_config: Optional[GenerationConfig] = None + r"""Configuration parameters for model interactions.""" + + labels: Optional[Dict[str, str]] = None + r"""The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + """ + + previous_interaction_id: Optional[str] = None + r"""The ID of the previous interaction, if any.""" + + response_format: Optional[CreateModelInteractionResponseFormat] = None + + safety_settings: Optional[List[SafetySetting]] = None + r"""Safety settings for the interaction.""" + + service_tier: Optional[ServiceTier] = None store: Optional[bool] = None r"""Input only. Whether to store the response and request for later retrieval.""" - background: Optional[bool] = None - r"""Input only. Whether to run the model interaction in the background.""" + stream: Optional[bool] = None + r"""Input only. Whether the interaction will be streamed.""" system_instruction: Optional[str] = None r"""System instruction for the interaction.""" @@ -121,6 +150,9 @@ class CreateModelInteraction(BaseModel): tools: Optional[List[Tool]] = None r"""A list of tool declarations the model may call during interaction.""" + webhook_config: Optional[WebhookConfig] = None + r"""Message for configuring webhook events for a request.""" + response_modalities: Annotated[ Optional[List[ResponseModality]], pydantic.Field( @@ -137,48 +169,29 @@ class CreateModelInteraction(BaseModel): ] = None r"""The mime type of the response. This is required if response_format is set.""" - previous_interaction_id: Optional[str] = None - r"""The ID of the previous interaction, if any.""" - - service_tier: Optional[ServiceTier] = None - - webhook_config: Optional[WebhookConfig] = None - r"""Message for configuring webhook events for a request.""" - - response_format: Optional[CreateModelInteractionResponseFormat] = None - r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - - environment: Optional[CreateModelInteractionEnvironment] = None - r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - - generation_config: Optional[GenerationConfig] = None - r"""Configuration parameters for model interactions.""" - - safety_settings: Optional[List[SafetySetting]] = None - r"""Safety settings for the interaction.""" - - labels: Optional[Dict[str, str]] = None - r"""The labels with user-defined metadata for the request.""" + input: Optional[InteractionsInput] = None + r"""The input for the interaction.""" @model_serializer(mode="wrap") def _serialize_model(self, handler): optional_fields = set( [ - "stream", - "store", "background", + "environment", + "generation_config", + "labels", + "previous_interaction_id", + "response_format", + "safety_settings", + "service_tier", + "store", + "stream", "system_instruction", "tools", + "webhook_config", "response_modalities", "response_mime_type", - "previous_interaction_id", - "service_tier", - "webhook_config", - "response_format", - "environment", - "generation_config", - "safety_settings", - "labels", + "input", ] ) serialized = handler(self) diff --git a/google/genai/_gaos/types/interactions/environmentnetworkegressallowlist.py b/google/genai/_gaos/types/interactions/environmentnetworkegressallowlist.py index bbab00de7..1bd7af208 100644 --- a/google/genai/_gaos/types/interactions/environmentnetworkegressallowlist.py +++ b/google/genai/_gaos/types/interactions/environmentnetworkegressallowlist.py @@ -17,47 +17,15 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel, UNSET_SENTINEL -from .allowlistentry import AllowlistEntry, AllowlistEntryParam -from pydantic import model_serializer -from typing import List, Literal, Optional, Union -from typing_extensions import NotRequired, TypeAliasType, TypedDict +from .allowlist import Allowlist, AllowlistParam +from typing import Literal, Union +from typing_extensions import TypeAliasType Disabled = Literal["disabled",] r"""Turns all network off.""" -class AllowlistParam(TypedDict): - r"""Outbound networking configuration for the sandbox. When specified, restricts which external domains the sandbox can reach. Omit entirely to allow all outbound traffic with no header injection.""" - - allowlist: NotRequired[List[AllowlistEntryParam]] - r"""List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': '*'}] to allow all domains while still injecting headers on specific ones.""" - - -class Allowlist(BaseModel): - r"""Outbound networking configuration for the sandbox. When specified, restricts which external domains the sandbox can reach. Omit entirely to allow all outbound traffic with no header injection.""" - - allowlist: Optional[List[AllowlistEntry]] = None - r"""List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': '*'}] to allow all domains while still injecting headers on specific ones.""" - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = set(["allowlist"]) - 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 - - EnvironmentNetworkEgressAllowlistParam = TypeAliasType( "EnvironmentNetworkEgressAllowlistParam", Union[AllowlistParam, Disabled] ) diff --git a/google/genai/_gaos/types/interactions/errorevent.py b/google/genai/_gaos/types/interactions/errorevent.py index 4360b0e9f..d87d12db4 100644 --- a/google/genai/_gaos/types/interactions/errorevent.py +++ b/google/genai/_gaos/types/interactions/errorevent.py @@ -20,6 +20,7 @@ from .. import BaseModel, UNSET_SENTINEL from ...utils import validate_const from .error import Error, ErrorTypedDict +from .streammetadata import StreamMetadata, StreamMetadataTypedDict import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -35,6 +36,8 @@ class ErrorEventTypedDict(TypedDict): this event. """ event_type: Literal["error"] + metadata: NotRequired[StreamMetadataTypedDict] + r"""Optional metadata accompanying ANY streamed event.""" class ErrorEvent(BaseModel): @@ -51,9 +54,12 @@ class ErrorEvent(BaseModel): pydantic.Field(alias="event_type"), ] = "error" + metadata: Optional[StreamMetadata] = None + r"""Optional metadata accompanying ANY streamed event.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["error", "event_id"]) + optional_fields = set(["error", "event_id", "metadata"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/filesearchcalldelta.py b/google/genai/_gaos/types/interactions/filesearchcalldelta.py index 4663be364..457010c43 100644 --- a/google/genai/_gaos/types/interactions/filesearchcalldelta.py +++ b/google/genai/_gaos/types/interactions/filesearchcalldelta.py @@ -27,12 +27,17 @@ class FileSearchCallDeltaTypedDict(TypedDict): + id: NotRequired[str] + r"""Required. A unique ID for this specific tool call.""" signature: NotRequired[str] r"""A signature hash for backend validation.""" type: Literal["file_search_call"] class FileSearchCallDelta(BaseModel): + id: Optional[str] = None + r"""Required. A unique ID for this specific tool call.""" + signature: Optional[str] = None r"""A signature hash for backend validation.""" @@ -46,7 +51,7 @@ class FileSearchCallDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["signature"]) + optional_fields = set(["id", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/filesearchresultdelta.py b/google/genai/_gaos/types/interactions/filesearchresultdelta.py index 0a8507ee6..3028a6b88 100644 --- a/google/genai/_gaos/types/interactions/filesearchresultdelta.py +++ b/google/genai/_gaos/types/interactions/filesearchresultdelta.py @@ -29,6 +29,8 @@ class FileSearchResultDeltaTypedDict(TypedDict): result: List[FileSearchResultTypedDict] + call_id: NotRequired[str] + r"""Required. ID to match the ID from the function call block.""" signature: NotRequired[str] r"""A signature hash for backend validation.""" type: Literal["file_search_result"] @@ -37,6 +39,9 @@ class FileSearchResultDeltaTypedDict(TypedDict): class FileSearchResultDelta(BaseModel): result: List[FileSearchResult] + call_id: Optional[str] = None + r"""Required. ID to match the ID from the function call block.""" + signature: Optional[str] = None r"""A signature hash for backend validation.""" @@ -50,7 +55,7 @@ class FileSearchResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["signature"]) + optional_fields = set(["call_id", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/functioncallstep.py b/google/genai/_gaos/types/interactions/functioncallstep.py index 943051df0..b038e85b3 100644 --- a/google/genai/_gaos/types/interactions/functioncallstep.py +++ b/google/genai/_gaos/types/interactions/functioncallstep.py @@ -17,12 +17,13 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel +from .. import Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL from ...utils import validate_const import pydantic +from pydantic import model_serializer from pydantic.functional_validators import AfterValidator -from typing import Any, Dict, Literal -from typing_extensions import Annotated, TypedDict +from typing import Any, Dict, Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class FunctionCallStepParam(TypedDict): @@ -34,6 +35,8 @@ class FunctionCallStepParam(TypedDict): r"""Required. A unique ID for this specific tool call.""" name: str r"""Required. The name of the tool to call.""" + signature: NotRequired[Union[str, Base64FileInput]] + r"""A signature hash for backend validation.""" type: Literal["function_call"] @@ -49,6 +52,9 @@ class FunctionCallStep(BaseModel): name: str r"""Required. The name of the tool to call.""" + signature: Optional[Base64EncodedString] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["function_call"], AfterValidator(validate_const("function_call")) @@ -56,6 +62,22 @@ class FunctionCallStep(BaseModel): pydantic.Field(alias="type"), ] = "function_call" + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["signature"]) + 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 + try: FunctionCallStep.model_rebuild() diff --git a/google/genai/_gaos/types/interactions/functionresultdelta.py b/google/genai/_gaos/types/interactions/functionresultdelta.py index 335357fbc..e65134dc8 100644 --- a/google/genai/_gaos/types/interactions/functionresultdelta.py +++ b/google/genai/_gaos/types/interactions/functionresultdelta.py @@ -56,6 +56,8 @@ class FunctionResultDeltaTypedDict(TypedDict): result: FunctionResultDeltaResultUnionTypedDict is_error: NotRequired[bool] name: NotRequired[str] + signature: NotRequired[str] + r"""A signature hash for backend validation.""" type: Literal["function_result"] @@ -69,6 +71,9 @@ class FunctionResultDelta(BaseModel): name: Optional[str] = None + signature: Optional[str] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["function_result"], @@ -79,7 +84,7 @@ class FunctionResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["is_error", "name"]) + optional_fields = set(["is_error", "name", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/functionresultstep.py b/google/genai/_gaos/types/interactions/functionresultstep.py index 3599ee57e..0fc9438e1 100644 --- a/google/genai/_gaos/types/interactions/functionresultstep.py +++ b/google/genai/_gaos/types/interactions/functionresultstep.py @@ -17,7 +17,7 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel, UNSET_SENTINEL +from .. import Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL from ...utils import validate_const from .functionresultsubcontent import ( FunctionResultSubcontent, @@ -63,6 +63,8 @@ class FunctionResultStepParam(TypedDict): r"""Whether the tool call resulted in an error.""" name: NotRequired[str] r"""The name of the tool that was called.""" + signature: NotRequired[Union[str, Base64FileInput]] + r"""A signature hash for backend validation.""" type: Literal["function_result"] @@ -81,6 +83,9 @@ class FunctionResultStep(BaseModel): name: Optional[str] = None r"""The name of the tool that was called.""" + signature: Optional[Base64EncodedString] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["function_result"], @@ -91,7 +96,7 @@ class FunctionResultStep(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["is_error", "name"]) + optional_fields = set(["is_error", "name", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/generationconfig.py b/google/genai/_gaos/types/interactions/generationconfig.py index 55dc1885c..2f4ad2bdf 100644 --- a/google/genai/_gaos/types/interactions/generationconfig.py +++ b/google/genai/_gaos/types/interactions/generationconfig.py @@ -33,62 +33,58 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict -ToolChoiceParam = TypeAliasType( - "ToolChoiceParam", Union[ToolChoiceConfigParam, ToolChoiceType] +StructuredSpeechConfigParam = TypeAliasType( + "StructuredSpeechConfigParam", Union[SpeakerConfigParam, List[SpeechConfigParam]] ) -r"""The tool choice configuration.""" +r"""Speech and multi-speaker configuration.""" -ToolChoice = TypeAliasType("ToolChoice", Union[ToolChoiceConfig, ToolChoiceType]) -r"""The tool choice configuration.""" +StructuredSpeechConfig = TypeAliasType( + "StructuredSpeechConfig", Union[SpeakerConfig, List[SpeechConfig]] +) +r"""Speech and multi-speaker configuration.""" -SpeechConfigUnionParam = TypeAliasType( - "SpeechConfigUnionParam", Union[SpeakerConfigParam, List[SpeechConfigParam]] +ToolChoiceParam = TypeAliasType( + "ToolChoiceParam", Union[ToolChoiceConfigParam, ToolChoiceType] ) -r"""Optional. Speech and multi-speaker configuration.""" +r"""The tool choice configuration.""" -SpeechConfigUnion = TypeAliasType( - "SpeechConfigUnion", Union[SpeakerConfig, List[SpeechConfig]] -) -r"""Optional. Speech and multi-speaker configuration.""" +ToolChoice = TypeAliasType("ToolChoice", Union[ToolChoiceConfig, ToolChoiceType]) +r"""The tool choice configuration.""" class GenerationConfigParam(TypedDict): r"""Configuration parameters for model interactions.""" - image_config: NotRequired[ImageConfigParam] - r"""The configuration for image interaction.""" max_output_tokens: NotRequired[int] r"""The maximum number of tokens to include in the response.""" seed: NotRequired[int] r"""Seed used in decoding for reproducibility.""" stop_sequences: NotRequired[List[str]] r"""A list of character sequences that will stop output interaction.""" + structured_speech_config: NotRequired[StructuredSpeechConfigParam] + r"""Speech and multi-speaker configuration.""" + temperature: NotRequired[float] + r"""Controls the randomness of the output.""" thinking_level: NotRequired[ThinkingLevel] thinking_summaries: NotRequired[ThinkingSummaries] tool_choice: NotRequired[ToolChoiceParam] r"""The tool choice configuration.""" + top_p: NotRequired[float] + r"""The maximum cumulative probability of tokens to consider when sampling.""" transcription_config: NotRequired[TranscriptionConfigParam] r"""Configuration for speech recognition (transcription).""" video_config: NotRequired[VideoConfigParam] r"""Configuration options for video generation.""" - speech_config: NotRequired[SpeechConfigUnionParam] - r"""Optional. Speech and multi-speaker configuration.""" + image_config: NotRequired[ImageConfigParam] + r"""The configuration for image interaction.""" class GenerationConfig(BaseModel): r"""Configuration parameters for model interactions.""" - image_config: Annotated[ - Optional[ImageConfig], - pydantic.Field( - deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." - ), - ] = None - r"""The configuration for image interaction.""" - max_output_tokens: Optional[int] = None r"""The maximum number of tokens to include in the response.""" @@ -98,6 +94,12 @@ class GenerationConfig(BaseModel): stop_sequences: Optional[List[str]] = None r"""A list of character sequences that will stop output interaction.""" + structured_speech_config: Optional[StructuredSpeechConfig] = None + r"""Speech and multi-speaker configuration.""" + + temperature: Optional[float] = None + r"""Controls the randomness of the output.""" + thinking_level: Optional[ThinkingLevel] = None thinking_summaries: Optional[ThinkingSummaries] = None @@ -105,29 +107,39 @@ class GenerationConfig(BaseModel): tool_choice: Optional[ToolChoice] = None r"""The tool choice configuration.""" + top_p: Optional[float] = None + r"""The maximum cumulative probability of tokens to consider when sampling.""" + transcription_config: Optional[TranscriptionConfig] = None r"""Configuration for speech recognition (transcription).""" video_config: Optional[VideoConfig] = None r"""Configuration options for video generation.""" - speech_config: Optional[SpeechConfigUnion] = None - r"""Optional. Speech and multi-speaker configuration.""" + image_config: Annotated[ + Optional[ImageConfig], + pydantic.Field( + deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." + ), + ] = None + r"""The configuration for image interaction.""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ - "image_config", "max_output_tokens", "seed", "stop_sequences", + "structured_speech_config", + "temperature", "thinking_level", "thinking_summaries", "tool_choice", + "top_p", "transcription_config", "video_config", - "speech_config", + "image_config", ] ) serialized = handler(self) diff --git a/google/genai/_gaos/types/interactions/googlemapscalldelta.py b/google/genai/_gaos/types/interactions/googlemapscalldelta.py index 56f5c3cf8..1845081ab 100644 --- a/google/genai/_gaos/types/interactions/googlemapscalldelta.py +++ b/google/genai/_gaos/types/interactions/googlemapscalldelta.py @@ -33,6 +33,8 @@ class GoogleMapsCallDeltaTypedDict(TypedDict): arguments: NotRequired[GoogleMapsCallArgumentsParam] r"""The arguments to pass to the Google Maps tool.""" + id: NotRequired[str] + r"""Required. A unique ID for this specific tool call.""" signature: NotRequired[str] r"""A signature hash for backend validation.""" type: Literal["google_maps_call"] @@ -42,6 +44,9 @@ class GoogleMapsCallDelta(BaseModel): arguments: Optional[GoogleMapsCallArguments] = None r"""The arguments to pass to the Google Maps tool.""" + id: Optional[str] = None + r"""Required. A unique ID for this specific tool call.""" + signature: Optional[str] = None r"""A signature hash for backend validation.""" @@ -55,7 +60,7 @@ class GoogleMapsCallDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["arguments", "signature"]) + optional_fields = set(["arguments", "id", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/googlemapsresultdelta.py b/google/genai/_gaos/types/interactions/googlemapsresultdelta.py index b5b38f4d8..694361951 100644 --- a/google/genai/_gaos/types/interactions/googlemapsresultdelta.py +++ b/google/genai/_gaos/types/interactions/googlemapsresultdelta.py @@ -28,6 +28,8 @@ class GoogleMapsResultDeltaTypedDict(TypedDict): + call_id: NotRequired[str] + r"""Required. ID to match the ID from the function call block.""" result: NotRequired[List[GoogleMapsResultParam]] r"""The results of the Google Maps.""" signature: NotRequired[str] @@ -36,6 +38,9 @@ class GoogleMapsResultDeltaTypedDict(TypedDict): class GoogleMapsResultDelta(BaseModel): + call_id: Optional[str] = None + r"""Required. ID to match the ID from the function call block.""" + result: Optional[List[GoogleMapsResult]] = None r"""The results of the Google Maps.""" @@ -52,7 +57,7 @@ class GoogleMapsResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["result", "signature"]) + optional_fields = set(["call_id", "result", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/googlesearchcalldelta.py b/google/genai/_gaos/types/interactions/googlesearchcalldelta.py index 816d20c8a..97e853d44 100644 --- a/google/genai/_gaos/types/interactions/googlesearchcalldelta.py +++ b/google/genai/_gaos/types/interactions/googlesearchcalldelta.py @@ -33,6 +33,8 @@ class GoogleSearchCallDeltaTypedDict(TypedDict): arguments: GoogleSearchCallArgumentsParam r"""The arguments to pass to Google Search.""" + id: NotRequired[str] + r"""Required. A unique ID for this specific tool call.""" signature: NotRequired[str] r"""A signature hash for backend validation.""" type: Literal["google_search_call"] @@ -42,6 +44,9 @@ class GoogleSearchCallDelta(BaseModel): arguments: GoogleSearchCallArguments r"""The arguments to pass to Google Search.""" + id: Optional[str] = None + r"""Required. A unique ID for this specific tool call.""" + signature: Optional[str] = None r"""A signature hash for backend validation.""" @@ -55,7 +60,7 @@ class GoogleSearchCallDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["signature"]) + optional_fields = set(["id", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/googlesearchresultdelta.py b/google/genai/_gaos/types/interactions/googlesearchresultdelta.py index 1f88b3957..53f8feb89 100644 --- a/google/genai/_gaos/types/interactions/googlesearchresultdelta.py +++ b/google/genai/_gaos/types/interactions/googlesearchresultdelta.py @@ -29,6 +29,8 @@ class GoogleSearchResultDeltaTypedDict(TypedDict): result: List[GoogleSearchResultParam] + call_id: NotRequired[str] + r"""Required. ID to match the ID from the function call block.""" is_error: NotRequired[bool] signature: NotRequired[str] r"""A signature hash for backend validation.""" @@ -38,6 +40,9 @@ class GoogleSearchResultDeltaTypedDict(TypedDict): class GoogleSearchResultDelta(BaseModel): result: List[GoogleSearchResult] + call_id: Optional[str] = None + r"""Required. ID to match the ID from the function call block.""" + is_error: Optional[bool] = None signature: Optional[str] = None @@ -53,7 +58,7 @@ class GoogleSearchResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["is_error", "signature"]) + optional_fields = set(["call_id", "is_error", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/harmcategory.py b/google/genai/_gaos/types/interactions/harmcategory.py index 412108e5c..01c90b33d 100644 --- a/google/genai/_gaos/types/interactions/harmcategory.py +++ b/google/genai/_gaos/types/interactions/harmcategory.py @@ -27,7 +27,6 @@ "dangerous_content", "harassment", "sexually_explicit", - "civic_integrity", "image_hate", "image_dangerous_content", "image_harassment", diff --git a/google/genai/_gaos/types/interactions/interaction.py b/google/genai/_gaos/types/interactions/interaction.py index fd87df6fb..4ffc1c725 100644 --- a/google/genai/_gaos/types/interactions/interaction.py +++ b/google/genai/_gaos/types/interactions/interaction.py @@ -33,6 +33,7 @@ from .generationconfig import GenerationConfig, GenerationConfigParam from .imagecontent import ImageContent, ImageContentParam from .interactionsinput import InteractionsInput, InteractionsInputParam +from .localenvironmentconfig import LocalEnvironmentConfig, LocalEnvironmentConfigParam from .model import Model from .responseformat import ResponseFormat, ResponseFormatParam from .responsemodality import ResponseModality @@ -51,6 +52,30 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict +InteractionEnvironmentTypedDict = TypeAliasType( + "InteractionEnvironmentTypedDict", + Union[LocalEnvironmentConfigParam, EnvironmentParam, str], +) +r"""The environment configuration for the interaction.""" + + +InteractionEnvironment = TypeAliasType( + "InteractionEnvironment", Union[LocalEnvironmentConfig, Environment, str] +) +r"""The environment configuration for the interaction.""" + + +InteractionResponseFormatTypedDict = TypeAliasType( + "InteractionResponseFormatTypedDict", + Union[ResponseFormatParam, List[ResponseFormatParam]], +) + + +InteractionResponseFormat = TypeAliasType( + "InteractionResponseFormat", Union[ResponseFormat, List[ResponseFormat]] +) + + InteractionStatus = Union[ Literal[ "in_progress", @@ -67,31 +92,6 @@ r"""Required. Output only. The status of the interaction.""" -InteractionResponseFormatTypedDict = TypeAliasType( - "InteractionResponseFormatTypedDict", - Union[List[ResponseFormatParam], ResponseFormatParam], -) -r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - - -InteractionResponseFormat = TypeAliasType( - "InteractionResponseFormat", Union[List[ResponseFormat], ResponseFormat] -) -r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - - -InteractionEnvironmentTypedDict = TypeAliasType( - "InteractionEnvironmentTypedDict", Union[EnvironmentParam, str] -) -r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - - -InteractionEnvironment = TypeAliasType( - "InteractionEnvironment", Union[Environment, str] -) -r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - - InteractionAgentConfigTypedDict = TypeAliasType( "InteractionAgentConfigTypedDict", Union[ @@ -101,7 +101,7 @@ CodeMenderAgentConfigParam, ], ) -r"""Configuration parameters for the agent interaction.""" +r"""Parameters for the agent interaction.""" class UnknownInteractionAgentConfig(BaseModel): @@ -115,19 +115,19 @@ class UnknownInteractionAgentConfig(BaseModel): _INTERACTION_AGENT_CONFIG_VARIANTS: dict[str, Any] = { - "dynamic": DynamicAgentConfig, - "deep-research": DeepResearchAgentConfig, - "code-mender": CodeMenderAgentConfig, "antigravity": AntigravityAgentConfig, + "code-mender": CodeMenderAgentConfig, + "deep-research": DeepResearchAgentConfig, + "dynamic": DynamicAgentConfig, } InteractionAgentConfig = Annotated[ Union[ - DynamicAgentConfig, - DeepResearchAgentConfig, - CodeMenderAgentConfig, AntigravityAgentConfig, + CodeMenderAgentConfig, + DeepResearchAgentConfig, + DynamicAgentConfig, UnknownInteractionAgentConfig, ], BeforeValidator( @@ -141,7 +141,7 @@ class UnknownInteractionAgentConfig(BaseModel): ) ), ] -r"""Configuration parameters for the agent interaction.""" +r"""Parameters for the agent interaction.""" class InteractionTypedDict(TypedDict): @@ -149,66 +149,72 @@ class InteractionTypedDict(TypedDict): status: InteractionStatus r"""Required. Output only. The status of the interaction.""" - model: NotRequired[Model] - r"""The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.""" - agent: NotRequired[AgentOption] - r"""The agent to interact with.""" - id: NotRequired[str] - r"""Required. Output only. A unique identifier for the interaction completion.""" created: NotRequired[str] - r"""Output only. The time at which the response was created in ISO 8601 format + r"""Required. Output only. The time at which the response was created in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ). """ - updated: NotRequired[str] - r"""Output only. The time at which the response was last updated in ISO 8601 format - (YYYY-MM-DDThh:mm:ssZ). + environment: NotRequired[InteractionEnvironmentTypedDict] + r"""The environment configuration for the interaction.""" + environment_id: NotRequired[str] + r"""Output only. The environment ID for the interaction. Only populated if environment + config is set in the request. """ + errors: NotRequired[List[ErrorTypedDict]] + r"""Output only. Diagnostic faults / platform errors recorded on the interaction.""" + generation_config: NotRequired[GenerationConfigParam] + r"""Configuration parameters for model interactions.""" + id: NotRequired[str] + r"""Required. Output only. A unique identifier for the interaction completion.""" + labels: NotRequired[Dict[str, str]] + r"""The labels with user-defined metadata for the request. It is used for + billing and reporting only. + + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. + """ + previous_interaction_id: NotRequired[str] + r"""The ID of the previous interaction, if any.""" + response_format: NotRequired[InteractionResponseFormatTypedDict] + safety_settings: NotRequired[List[SafetySettingParam]] + r"""Safety settings for the interaction.""" + service_tier: NotRequired[ServiceTier] + steps: NotRequired[List[StepParam]] + r"""Required. Output only. The steps that make up the interaction.""" system_instruction: NotRequired[str] r"""System instruction for the interaction.""" tools: NotRequired[List[ToolParam]] r"""A list of tool declarations the model may call during interaction.""" - errors: NotRequired[List[ErrorTypedDict]] - r"""Output only. Diagnostic faults / platform errors recorded on the interaction.""" + updated: NotRequired[str] + r"""Required. Output only. The time at which the response was last updated in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ usage: NotRequired[UsageTypedDict] r"""Statistics on the interaction request's token usage.""" + webhook_config: NotRequired[WebhookConfigParam] + r"""Message for configuring webhook events for a request.""" response_modalities: NotRequired[List[ResponseModality]] r"""The requested modalities of the response (TEXT, IMAGE, AUDIO).""" response_mime_type: NotRequired[str] r"""The mime type of the response. This is required if response_format is set.""" - previous_interaction_id: NotRequired[str] - r"""The ID of the previous interaction, if any.""" - environment_id: NotRequired[str] - r"""Output only. The environment ID for the interaction. Only populated if environment - config is set in the request. - """ - service_tier: NotRequired[ServiceTier] - webhook_config: NotRequired[WebhookConfigParam] - r"""Message for configuring webhook events for a request.""" - steps: NotRequired[List[StepParam]] - r"""Output only. The steps that make up the interaction, when included in the response.""" - response_format: NotRequired[InteractionResponseFormatTypedDict] - r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" - environment: NotRequired[InteractionEnvironmentTypedDict] - r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" - generation_config: NotRequired[GenerationConfigParam] - r"""Configuration parameters for model interactions.""" - agent_config: NotRequired[InteractionAgentConfigTypedDict] - r"""Configuration parameters for the agent interaction.""" - safety_settings: NotRequired[List[SafetySettingParam]] - r"""Safety settings for the interaction.""" - labels: NotRequired[Dict[str, str]] - r"""The labels with user-defined metadata for the request.""" input: NotRequired[InteractionsInputParam] r"""The input for the interaction.""" + model: NotRequired[Model] + r"""The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.""" + agent: NotRequired[AgentOption] + r"""The agent to interact with.""" + agent_config: NotRequired[InteractionAgentConfigTypedDict] + r"""Parameters for the agent interaction.""" + output_audio: NotRequired[AudioContentParam] + r"""An audio content block.""" + output_image: NotRequired[ImageContentParam] + r"""An image content block.""" output_text: NotRequired[str] r"""Concatenated text from the last model output in response to the current request. Note: this is added by the SDK. """ - output_image: NotRequired[ImageContentParam] - r"""An image content block.""" - output_audio: NotRequired[AudioContentParam] - r"""An audio content block.""" output_video: NotRequired[VideoContentParam] r"""A video content block.""" @@ -219,37 +225,68 @@ class Interaction(BaseModel): status: InteractionStatus r"""Required. Output only. The status of the interaction.""" - model: Optional[Model] = None - r"""The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.""" + created: Optional[str] = None + r"""Required. Output only. The time at which the response was created in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ - agent: Optional[AgentOption] = None - r"""The agent to interact with.""" + environment: Optional[InteractionEnvironment] = None + r"""The environment configuration for the interaction.""" + + environment_id: Optional[str] = None + r"""Output only. The environment ID for the interaction. Only populated if environment + config is set in the request. + """ - id: Optional[str] = "" + errors: Optional[List[Error]] = None + r"""Output only. Diagnostic faults / platform errors recorded on the interaction.""" + + generation_config: Optional[GenerationConfig] = None + r"""Configuration parameters for model interactions.""" + + id: Optional[str] = None r"""Required. Output only. A unique identifier for the interaction completion.""" - created: Optional[str] = None - r"""Output only. The time at which the response was created in ISO 8601 format - (YYYY-MM-DDThh:mm:ssZ). - """ + labels: Optional[Dict[str, str]] = None + r"""The labels with user-defined metadata for the request. It is used for + billing and reporting only. - updated: Optional[str] = None - r"""Output only. The time at which the response was last updated in ISO 8601 format - (YYYY-MM-DDThh:mm:ssZ). + Label keys and values can be no longer than 63 characters + (Unicode codepoints) and can only contain lowercase letters, numeric + characters, underscores, and dashes. International characters are allowed. + Label values are optional. Label keys must start with a letter. """ + previous_interaction_id: Optional[str] = None + r"""The ID of the previous interaction, if any.""" + + response_format: Optional[InteractionResponseFormat] = None + + safety_settings: Optional[List[SafetySetting]] = None + r"""Safety settings for the interaction.""" + + service_tier: Optional[ServiceTier] = None + + steps: Optional[List[Step]] = None + r"""Required. Output only. The steps that make up the interaction.""" + system_instruction: Optional[str] = None r"""System instruction for the interaction.""" tools: Optional[List[Tool]] = None r"""A list of tool declarations the model may call during interaction.""" - errors: Optional[List[Error]] = None - r"""Output only. Diagnostic faults / platform errors recorded on the interaction.""" + updated: Optional[str] = None + r"""Required. Output only. The time at which the response was last updated in ISO 8601 format + (YYYY-MM-DDThh:mm:ssZ). + """ usage: Optional[Usage] = None r"""Statistics on the interaction request's token usage.""" + webhook_config: Optional[WebhookConfig] = None + r"""Message for configuring webhook events for a request.""" + response_modalities: Annotated[ Optional[List[ResponseModality]], pydantic.Field( @@ -266,42 +303,23 @@ class Interaction(BaseModel): ] = None r"""The mime type of the response. This is required if response_format is set.""" - previous_interaction_id: Optional[str] = None - r"""The ID of the previous interaction, if any.""" - - environment_id: Optional[str] = None - r"""Output only. The environment ID for the interaction. Only populated if environment - config is set in the request. - """ - - service_tier: Optional[ServiceTier] = None - - webhook_config: Optional[WebhookConfig] = None - r"""Message for configuring webhook events for a request.""" - - steps: Optional[List[Step]] = None - r"""Output only. The steps that make up the interaction, when included in the response.""" - - response_format: Optional[InteractionResponseFormat] = None - r"""Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.""" + input: Optional[InteractionsInput] = None + r"""The input for the interaction.""" - environment: Optional[InteractionEnvironment] = None - r"""The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.""" + model: Optional[Model] = None + r"""The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.""" - generation_config: Optional[GenerationConfig] = None - r"""Configuration parameters for model interactions.""" + agent: Optional[AgentOption] = None + r"""The agent to interact with.""" agent_config: Optional[InteractionAgentConfig] = None - r"""Configuration parameters for the agent interaction.""" + r"""Parameters for the agent interaction.""" - safety_settings: Optional[List[SafetySetting]] = None - r"""Safety settings for the interaction.""" - - labels: Optional[Dict[str, str]] = None - r"""The labels with user-defined metadata for the request.""" + output_audio: Optional[AudioContent] = None + r"""An audio content block.""" - input: Optional[InteractionsInput] = None - r"""The input for the interaction.""" + output_image: Optional[ImageContent] = None + r"""An image content block.""" output_text: Optional[str] = None r"""Concatenated text from the last model output in response to the current request. @@ -309,12 +327,6 @@ class Interaction(BaseModel): Note: this is added by the SDK. """ - output_image: Optional[ImageContent] = None - r"""An image content block.""" - - output_audio: Optional[AudioContent] = None - r"""An audio content block.""" - output_video: Optional[VideoContent] = None r"""A video content block.""" @@ -322,32 +334,32 @@ class Interaction(BaseModel): def _serialize_model(self, handler): optional_fields = set( [ - "model", - "agent", - "id", "created", - "updated", + "environment", + "environment_id", + "errors", + "generation_config", + "id", + "labels", + "previous_interaction_id", + "response_format", + "safety_settings", + "service_tier", + "steps", "system_instruction", "tools", - "errors", + "updated", "usage", + "webhook_config", "response_modalities", "response_mime_type", - "previous_interaction_id", - "environment_id", - "service_tier", - "webhook_config", - "steps", - "response_format", - "environment", - "generation_config", - "agent_config", - "safety_settings", - "labels", "input", - "output_text", - "output_image", + "model", + "agent", + "agent_config", "output_audio", + "output_image", + "output_text", "output_video", ] ) @@ -396,7 +408,7 @@ def _coerce_outputs_to_steps(cls, data: Any) -> Any: def model_construct(cls, _fields_set=None, **values): # Coerce legacy lyria ``outputs`` -> ``steps`` here as well: validators # do not run on model_construct (used by deferred SSE parsing). - return pydantic.BaseModel.model_construct( + return super(cls, cls).model_construct( _fields_set, **cls._maybe_coerce_outputs(values) ) diff --git a/google/genai/_gaos/types/interactions/interactioncompletedevent.py b/google/genai/_gaos/types/interactions/interactioncompletedevent.py index a7efc3fcd..15aba3faf 100644 --- a/google/genai/_gaos/types/interactions/interactioncompletedevent.py +++ b/google/genai/_gaos/types/interactions/interactioncompletedevent.py @@ -23,6 +23,7 @@ InteractionSseEventInteraction, InteractionSseEventInteractionTypedDict, ) +from .streammetadata import StreamMetadata, StreamMetadataTypedDict import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -37,11 +38,13 @@ class InteractionCompletedEventTypedDict(TypedDict): full non-streaming Interaction responses. """ - event_type: Literal["interaction.completed"] event_id: NotRequired[str] r"""The event_id token to be used to resume the interaction stream, from this event. """ + event_type: Literal["interaction.completed"] + metadata: NotRequired[StreamMetadataTypedDict] + r"""Optional metadata accompanying ANY streamed event.""" class InteractionCompletedEvent(BaseModel): @@ -52,6 +55,11 @@ class InteractionCompletedEvent(BaseModel): """ + event_id: Optional[str] = None + r"""The event_id token to be used to resume the interaction stream, from + this event. + """ + event_type: Annotated[ Annotated[ Literal["interaction.completed"], @@ -60,14 +68,12 @@ class InteractionCompletedEvent(BaseModel): pydantic.Field(alias="event_type"), ] = "interaction.completed" - event_id: Optional[str] = None - r"""The event_id token to be used to resume the interaction stream, from - this event. - """ + metadata: Optional[StreamMetadata] = None + r"""Optional metadata accompanying ANY streamed event.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["event_id"]) + optional_fields = set(["event_id", "metadata"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/interactioncreatedevent.py b/google/genai/_gaos/types/interactions/interactioncreatedevent.py index 496035cd0..1e768bcea 100644 --- a/google/genai/_gaos/types/interactions/interactioncreatedevent.py +++ b/google/genai/_gaos/types/interactions/interactioncreatedevent.py @@ -23,6 +23,7 @@ InteractionSseEventInteraction, InteractionSseEventInteractionTypedDict, ) +from .streammetadata import StreamMetadata, StreamMetadataTypedDict import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -37,11 +38,13 @@ class InteractionCreatedEventTypedDict(TypedDict): full non-streaming Interaction responses. """ - event_type: Literal["interaction.created"] event_id: NotRequired[str] r"""The event_id token to be used to resume the interaction stream, from this event. """ + event_type: Literal["interaction.created"] + metadata: NotRequired[StreamMetadataTypedDict] + r"""Optional metadata accompanying ANY streamed event.""" class InteractionCreatedEvent(BaseModel): @@ -52,6 +55,11 @@ class InteractionCreatedEvent(BaseModel): """ + event_id: Optional[str] = None + r"""The event_id token to be used to resume the interaction stream, from + this event. + """ + event_type: Annotated[ Annotated[ Literal["interaction.created"], @@ -60,14 +68,12 @@ class InteractionCreatedEvent(BaseModel): pydantic.Field(alias="event_type"), ] = "interaction.created" - event_id: Optional[str] = None - r"""The event_id token to be used to resume the interaction stream, from - this event. - """ + metadata: Optional[StreamMetadata] = None + r"""Optional metadata accompanying ANY streamed event.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["event_id"]) + optional_fields = set(["event_id", "metadata"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/interactionsinput.py b/google/genai/_gaos/types/interactions/interactionsinput.py index 6b294d9dd..1e33edf6d 100644 --- a/google/genai/_gaos/types/interactions/interactionsinput.py +++ b/google/genai/_gaos/types/interactions/interactionsinput.py @@ -19,18 +19,19 @@ from __future__ import annotations from .content import Content, ContentParam from .step import Step, StepParam +from .turn import Turn, TurnParam from typing import List, Union from typing_extensions import TypeAliasType InteractionsInputParam = TypeAliasType( "InteractionsInputParam", - Union[str, List[StepParam], List[ContentParam], ContentParam], + Union[ContentParam, List[StepParam], List[ContentParam], List[TurnParam], str], ) r"""The input for the interaction.""" InteractionsInput = TypeAliasType( - "InteractionsInput", Union[str, List[Step], List[Content], Content] + "InteractionsInput", Union[Content, List[Step], List[Content], List[Turn], str] ) r"""The input for the interaction.""" diff --git a/google/genai/_gaos/types/interactions/interactionsseevent.py b/google/genai/_gaos/types/interactions/interactionsseevent.py index 58ffffe77..d3bad342c 100644 --- a/google/genai/_gaos/types/interactions/interactionsseevent.py +++ b/google/genai/_gaos/types/interactions/interactionsseevent.py @@ -45,12 +45,12 @@ InteractionSSEEventTypedDict = TypeAliasType( "InteractionSSEEventTypedDict", Union[ - InteractionCreatedEventTypedDict, - InteractionCompletedEventTypedDict, ErrorEventTypedDict, + InteractionCompletedEventTypedDict, + InteractionCreatedEventTypedDict, InteractionStatusUpdateTypedDict, - StepStartTypedDict, StepDeltaTypedDict, + StepStartTypedDict, StepStopTypedDict, ], ) @@ -67,24 +67,24 @@ class UnknownInteractionSSEEvent(BaseModel): _INTERACTION_SSE_EVENT_VARIANTS: dict[str, Any] = { - "interaction.created": InteractionCreatedEvent, + "error": ErrorEvent, "interaction.completed": InteractionCompletedEvent, + "interaction.created": InteractionCreatedEvent, "interaction.status_update": InteractionStatusUpdate, - "error": ErrorEvent, - "step.start": StepStart, "step.delta": StepDelta, + "step.start": StepStart, "step.stop": StepStop, } InteractionSSEEvent = Annotated[ Union[ - InteractionCreatedEvent, + ErrorEvent, InteractionCompletedEvent, + InteractionCreatedEvent, InteractionStatusUpdate, - ErrorEvent, - StepStart, StepDelta, + StepStart, StepStop, UnknownInteractionSSEEvent, ], diff --git a/google/genai/_gaos/types/interactions/interactionsseeventinteraction.py b/google/genai/_gaos/types/interactions/interactionsseeventinteraction.py index 5754c6f8d..8978e99e6 100644 --- a/google/genai/_gaos/types/interactions/interactionsseeventinteraction.py +++ b/google/genai/_gaos/types/interactions/interactionsseeventinteraction.py @@ -51,21 +51,21 @@ class InteractionSseEventInteractionTypedDict(TypedDict): r"""Required. Output only. A unique identifier for the interaction completion.""" status: InteractionSseEventInteractionStatus r"""Required. Output only. The status of the interaction.""" - object: NotRequired[str] - r"""Output only. The resource type.""" - model: NotRequired[str] - r"""The model that will complete your prompt.""" agent: NotRequired[str] r"""The agent to interact with.""" created: NotRequired[str] r"""Output only. The time at which the response was created in ISO 8601 format.""" + model: NotRequired[str] + r"""The model that will complete your prompt.""" + object: NotRequired[str] + r"""Output only. The resource type.""" + service_tier: NotRequired[ServiceTier] + steps: NotRequired[List[StepParam]] + r"""Output only. The steps that make up the interaction, if included in this event.""" updated: NotRequired[str] r"""Output only. The time at which the response was last updated in ISO 8601 format.""" - service_tier: NotRequired[ServiceTier] usage: NotRequired[UsageTypedDict] r"""Statistics on the interaction request's token usage.""" - steps: NotRequired[List[StepParam]] - r"""Output only. The steps that make up the interaction, if included in this event.""" class InteractionSseEventInteraction(BaseModel): @@ -81,41 +81,41 @@ class InteractionSseEventInteraction(BaseModel): status: InteractionSseEventInteractionStatus r"""Required. Output only. The status of the interaction.""" - object: Optional[str] = None - r"""Output only. The resource type.""" - - model: Optional[str] = None - r"""The model that will complete your prompt.""" - agent: Optional[str] = None r"""The agent to interact with.""" created: Optional[str] = None r"""Output only. The time at which the response was created in ISO 8601 format.""" - updated: Optional[str] = None - r"""Output only. The time at which the response was last updated in ISO 8601 format.""" + model: Optional[str] = None + r"""The model that will complete your prompt.""" - service_tier: Optional[ServiceTier] = None + object: Optional[str] = None + r"""Output only. The resource type.""" - usage: Optional[Usage] = None - r"""Statistics on the interaction request's token usage.""" + service_tier: Optional[ServiceTier] = None steps: Optional[List[Step]] = None r"""Output only. The steps that make up the interaction, if included in this event.""" + updated: Optional[str] = None + r"""Output only. The time at which the response was last updated in ISO 8601 format.""" + + usage: Optional[Usage] = None + r"""Statistics on the interaction request's token usage.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ - "object", - "model", "agent", "created", - "updated", + "model", + "object", "service_tier", - "usage", "steps", + "updated", + "usage", ] ) serialized = handler(self) diff --git a/google/genai/_gaos/types/interactions/interactionstatusupdate.py b/google/genai/_gaos/types/interactions/interactionstatusupdate.py index 2735dbc78..80c424dde 100644 --- a/google/genai/_gaos/types/interactions/interactionstatusupdate.py +++ b/google/genai/_gaos/types/interactions/interactionstatusupdate.py @@ -19,6 +19,7 @@ from __future__ import annotations from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr from ...utils import validate_const +from .streammetadata import StreamMetadata, StreamMetadataTypedDict import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -49,6 +50,8 @@ class InteractionStatusUpdateTypedDict(TypedDict): this event. """ event_type: Literal["interaction.status_update"] + metadata: NotRequired[StreamMetadataTypedDict] + r"""Optional metadata accompanying ANY streamed event.""" class InteractionStatusUpdate(BaseModel): @@ -69,9 +72,12 @@ class InteractionStatusUpdate(BaseModel): pydantic.Field(alias="event_type"), ] = "interaction.status_update" + metadata: Optional[StreamMetadata] = None + r"""Optional metadata accompanying ANY streamed event.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["event_id"]) + optional_fields = set(["event_id", "metadata"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/localenvironmentconfig.py b/google/genai/_gaos/types/interactions/localenvironmentconfig.py new file mode 100644 index 000000000..1055361d3 --- /dev/null +++ b/google/genai/_gaos/types/interactions/localenvironmentconfig.py @@ -0,0 +1,72 @@ +# 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 +from ...utils import validate_const +import pydantic +from pydantic.functional_validators import AfterValidator +from typing import Literal +from typing_extensions import Annotated, TypedDict + + +class LocalEnvironmentConfigParam(TypedDict): + r"""Configuration for an environment that lives on the client connection rather + than in a server-managed sandbox. + + When set (via Interaction.local_environment), the agent's filesystem and + shell are treated as living on the client: the agent's built-in environment + operations (e.g. reading/listing/editing files and running commands) are + suspended on the server and yielded back to the client to execute, with their + results returned on a subsequent turn. This is mutually exclusive with a + server-managed `EnvironmentConfig` (remote_environment), since the + environment is either on the client or in a server sandbox, never both. + + This governs only the agent's built-in environment. Client-declared function + tools are always executed on the client regardless of this field. + """ + + type: Literal["local"] + + +class LocalEnvironmentConfig(BaseModel): + r"""Configuration for an environment that lives on the client connection rather + than in a server-managed sandbox. + + When set (via Interaction.local_environment), the agent's filesystem and + shell are treated as living on the client: the agent's built-in environment + operations (e.g. reading/listing/editing files and running commands) are + suspended on the server and yielded back to the client to execute, with their + results returned on a subsequent turn. This is mutually exclusive with a + server-managed `EnvironmentConfig` (remote_environment), since the + environment is either on the client or in a server sandbox, never both. + + This governs only the agent's built-in environment. Client-declared function + tools are always executed on the client regardless of this field. + """ + + type: Annotated[ + Annotated[Literal["local"], AfterValidator(validate_const("local"))], + pydantic.Field(alias="type"), + ] = "local" + + +try: + LocalEnvironmentConfig.model_rebuild() +except NameError: + pass diff --git a/google/genai/_gaos/types/interactions/mcpservertoolcalldelta.py b/google/genai/_gaos/types/interactions/mcpservertoolcalldelta.py index 33c3c3ddf..824b79bce 100644 --- a/google/genai/_gaos/types/interactions/mcpservertoolcalldelta.py +++ b/google/genai/_gaos/types/interactions/mcpservertoolcalldelta.py @@ -17,18 +17,23 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel +from .. import BaseModel, UNSET_SENTINEL from ...utils import validate_const import pydantic +from pydantic import model_serializer from pydantic.functional_validators import AfterValidator -from typing import Any, Dict, Literal -from typing_extensions import Annotated, TypedDict +from typing import Any, Dict, Literal, Optional +from typing_extensions import Annotated, NotRequired, TypedDict class MCPServerToolCallDeltaTypedDict(TypedDict): arguments: Dict[str, Any] name: str server_name: str + id: NotRequired[str] + r"""Required. A unique ID for this specific tool call.""" + signature: NotRequired[str] + r"""A signature hash for backend validation.""" type: Literal["mcp_server_tool_call"] @@ -39,6 +44,12 @@ class MCPServerToolCallDelta(BaseModel): server_name: str + id: Optional[str] = None + r"""Required. A unique ID for this specific tool call.""" + + signature: Optional[str] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["mcp_server_tool_call"], @@ -47,6 +58,22 @@ class MCPServerToolCallDelta(BaseModel): pydantic.Field(alias="type"), ] = "mcp_server_tool_call" + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["id", "signature"]) + 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 + try: MCPServerToolCallDelta.model_rebuild() diff --git a/google/genai/_gaos/types/interactions/mcpservertoolcallstep.py b/google/genai/_gaos/types/interactions/mcpservertoolcallstep.py index 20b064f00..748d281b2 100644 --- a/google/genai/_gaos/types/interactions/mcpservertoolcallstep.py +++ b/google/genai/_gaos/types/interactions/mcpservertoolcallstep.py @@ -17,12 +17,13 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel +from .. import Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL from ...utils import validate_const import pydantic +from pydantic import model_serializer from pydantic.functional_validators import AfterValidator -from typing import Any, Dict, Literal -from typing_extensions import Annotated, TypedDict +from typing import Any, Dict, Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class MCPServerToolCallStepParam(TypedDict): @@ -36,6 +37,8 @@ class MCPServerToolCallStepParam(TypedDict): r"""Required. The name of the tool which was called.""" server_name: str r"""Required. The name of the used MCP server.""" + signature: NotRequired[Union[str, Base64FileInput]] + r"""A signature hash for backend validation.""" type: Literal["mcp_server_tool_call"] @@ -54,6 +57,9 @@ class MCPServerToolCallStep(BaseModel): server_name: str r"""Required. The name of the used MCP server.""" + signature: Optional[Base64EncodedString] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["mcp_server_tool_call"], @@ -62,6 +68,22 @@ class MCPServerToolCallStep(BaseModel): pydantic.Field(alias="type"), ] = "mcp_server_tool_call" + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["signature"]) + 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 + try: MCPServerToolCallStep.model_rebuild() diff --git a/google/genai/_gaos/types/interactions/mcpservertoolresultdelta.py b/google/genai/_gaos/types/interactions/mcpservertoolresultdelta.py index 662f5da7e..8312d2121 100644 --- a/google/genai/_gaos/types/interactions/mcpservertoolresultdelta.py +++ b/google/genai/_gaos/types/interactions/mcpservertoolresultdelta.py @@ -56,18 +56,28 @@ class MCPServerToolResultDeltaResult(BaseModel): class MCPServerToolResultDeltaTypedDict(TypedDict): result: MCPServerToolResultDeltaResultUnionTypedDict + call_id: NotRequired[str] + r"""Required. ID to match the ID from the function call block.""" name: NotRequired[str] server_name: NotRequired[str] + signature: NotRequired[str] + r"""A signature hash for backend validation.""" type: Literal["mcp_server_tool_result"] class MCPServerToolResultDelta(BaseModel): result: MCPServerToolResultDeltaResultUnion + call_id: Optional[str] = None + r"""Required. ID to match the ID from the function call block.""" + name: Optional[str] = None server_name: Optional[str] = None + signature: Optional[str] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["mcp_server_tool_result"], @@ -78,7 +88,7 @@ class MCPServerToolResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["name", "server_name"]) + optional_fields = set(["call_id", "name", "server_name", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/mcpservertoolresultstep.py b/google/genai/_gaos/types/interactions/mcpservertoolresultstep.py index c1cf9a6ab..b7de9baec 100644 --- a/google/genai/_gaos/types/interactions/mcpservertoolresultstep.py +++ b/google/genai/_gaos/types/interactions/mcpservertoolresultstep.py @@ -17,7 +17,7 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel, UNSET_SENTINEL +from .. import Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL from ...utils import validate_const from .functionresultsubcontent import ( FunctionResultSubcontent, @@ -40,14 +40,14 @@ class MCPServerToolResultStepResult(BaseModel): MCPServerToolResultStepResultUnionParam = TypeAliasType( "MCPServerToolResultStepResultUnionParam", - Union[MCPServerToolResultStepResultParam, str, List[FunctionResultSubcontentParam]], + Union[MCPServerToolResultStepResultParam, List[FunctionResultSubcontentParam], str], ) r"""Required. The output from the MCP server call. Can be simple text or rich content.""" MCPServerToolResultStepResultUnion = TypeAliasType( "MCPServerToolResultStepResultUnion", - Union[MCPServerToolResultStepResult, str, List[FunctionResultSubcontent]], + Union[MCPServerToolResultStepResult, List[FunctionResultSubcontent], str], ) r"""Required. The output from the MCP server call. Can be simple text or rich content.""" @@ -63,6 +63,8 @@ class MCPServerToolResultStepParam(TypedDict): r"""Name of the tool which is called for this specific tool call.""" server_name: NotRequired[str] r"""The name of the used MCP server.""" + signature: NotRequired[Union[str, Base64FileInput]] + r"""A signature hash for backend validation.""" type: Literal["mcp_server_tool_result"] @@ -81,6 +83,9 @@ class MCPServerToolResultStep(BaseModel): server_name: Optional[str] = None r"""The name of the used MCP server.""" + signature: Optional[Base64EncodedString] = None + r"""A signature hash for backend validation.""" + type: Annotated[ Annotated[ Literal["mcp_server_tool_result"], @@ -91,7 +96,7 @@ class MCPServerToolResultStep(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["name", "server_name"]) + optional_fields = set(["name", "server_name", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/model.py b/google/genai/_gaos/types/interactions/model.py index 220ad6c22..eec2a2c93 100644 --- a/google/genai/_gaos/types/interactions/model.py +++ b/google/genai/_gaos/types/interactions/model.py @@ -59,8 +59,6 @@ "gemini-3.5-flash", # Our most intelligent model for sustained frontier performance in agentic and coding tasks. "gemini-3.6-flash", - # Our most intelligent model for sustained frontier performance in agentic and coding tasks. - "gemini-3.7-flash", # Our low-latency, music generation model optimized for high-fidelity audio clips and precise rhythmic control. "lyria-3-clip-preview", # Our advanced, full-song generative model with deep compositional understanding, optimized for precise structural control and complex transitions across diverse musical styles. diff --git a/google/genai/_gaos/types/interactions/modeloutputstep.py b/google/genai/_gaos/types/interactions/modeloutputstep.py index 48efaed17..96e145add 100644 --- a/google/genai/_gaos/types/interactions/modeloutputstep.py +++ b/google/genai/_gaos/types/interactions/modeloutputstep.py @@ -32,6 +32,7 @@ class ModelOutputStepParam(TypedDict): r"""Output generated by the model.""" content: NotRequired[List[ContentParam]] + type: Literal["model_output"] error: NotRequired[StatusParam] r"""The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is @@ -41,7 +42,6 @@ class ModelOutputStepParam(TypedDict): You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). """ - type: Literal["model_output"] class ModelOutputStep(BaseModel): @@ -49,6 +49,13 @@ class ModelOutputStep(BaseModel): content: Optional[List[Content]] = None + type: Annotated[ + Annotated[ + Literal["model_output"], AfterValidator(validate_const("model_output")) + ], + pydantic.Field(alias="type"), + ] = "model_output" + error: Optional[Status] = None r"""The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is @@ -59,13 +66,6 @@ class ModelOutputStep(BaseModel): [API Design Guide](https://cloud.google.com/apis/design/errors). """ - type: Annotated[ - Annotated[ - Literal["model_output"], AfterValidator(validate_const("model_output")) - ], - pydantic.Field(alias="type"), - ] = "model_output" - @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["content", "error"]) diff --git a/google/genai/_gaos/types/interactions/ragretrievalconfig.py b/google/genai/_gaos/types/interactions/ragretrievalconfig.py index cbeb45e55..7fe1fa48d 100644 --- a/google/genai/_gaos/types/interactions/ragretrievalconfig.py +++ b/google/genai/_gaos/types/interactions/ragretrievalconfig.py @@ -35,7 +35,7 @@ class RagRetrievalConfigParam(TypedDict): hybrid_search: NotRequired[HybridSearchParam] r"""Config for Hybrid Search.""" ranking: NotRequired[RankingParam] - r"""Config for Rank Service.""" + r"""Config for ranking and reranking.""" top_k: NotRequired[int] r"""Optional. The number of contexts to retrieve.""" @@ -50,7 +50,7 @@ class RagRetrievalConfig(BaseModel): r"""Config for Hybrid Search.""" ranking: Optional[Ranking] = None - r"""Config for Rank Service.""" + r"""Config for ranking and reranking.""" top_k: Optional[int] = None r"""Optional. The number of contexts to retrieve.""" diff --git a/google/genai/_gaos/types/interactions/ranking.py b/google/genai/_gaos/types/interactions/ranking.py index 1caeaa677..05c7ed5a8 100644 --- a/google/genai/_gaos/types/interactions/ranking.py +++ b/google/genai/_gaos/types/interactions/ranking.py @@ -18,38 +18,28 @@ from __future__ import annotations from .. import BaseModel, UNSET_SENTINEL -from ...utils import validate_const -import pydantic +from .rankservice import RankService, RankServiceParam from pydantic import model_serializer -from pydantic.functional_validators import AfterValidator -from typing import Literal, Optional -from typing_extensions import Annotated, NotRequired, TypedDict +from typing import Optional +from typing_extensions import NotRequired, TypedDict class RankingParam(TypedDict): - r"""Config for Rank Service.""" + r"""Config for ranking and reranking.""" - model_name: NotRequired[str] - r"""Optional. The model name of the rank service.""" - ranking_config: Literal["rank_service"] + rank_service: NotRequired[RankServiceParam] + r"""Config for Rank Service.""" class Ranking(BaseModel): - r"""Config for Rank Service.""" - - model_name: Optional[str] = None - r"""Optional. The model name of the rank service.""" + r"""Config for ranking and reranking.""" - ranking_config: Annotated[ - Annotated[ - Literal["rank_service"], AfterValidator(validate_const("rank_service")) - ], - pydantic.Field(alias="ranking_config"), - ] = "rank_service" + rank_service: Optional[RankService] = None + r"""Config for Rank Service.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["model_name"]) + optional_fields = set(["rank_service"]) serialized = handler(self) m = {} @@ -62,9 +52,3 @@ def serialize_model(self, handler): m[k] = val return m - - -try: - Ranking.model_rebuild() -except NameError: - pass diff --git a/google/genai/_gaos/types/interactions/rankservice.py b/google/genai/_gaos/types/interactions/rankservice.py new file mode 100644 index 000000000..8a45c3fea --- /dev/null +++ b/google/genai/_gaos/types/interactions/rankservice.py @@ -0,0 +1,53 @@ +# 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 pydantic import model_serializer +from typing import Optional +from typing_extensions import NotRequired, TypedDict + + +class RankServiceParam(TypedDict): + r"""Config for Rank Service.""" + + model_name: NotRequired[str] + r"""Optional. The model name of the rank service.""" + + +class RankService(BaseModel): + r"""Config for Rank Service.""" + + model_name: Optional[str] = None + r"""Optional. The model name of the rank service.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["model_name"]) + 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/interactions/retrieval.py b/google/genai/_gaos/types/interactions/retrieval.py index 859ee4e20..623f1e13e 100644 --- a/google/genai/_gaos/types/interactions/retrieval.py +++ b/google/genai/_gaos/types/interactions/retrieval.py @@ -17,30 +17,20 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr +from .. import BaseModel, UNSET_SENTINEL from ...utils import validate_const from .exaaisearchconfig import ExaAISearchConfig, ExaAISearchConfigParam from .parallelaisearchconfig import ParallelAISearchConfig, ParallelAISearchConfigParam from .ragstoreconfig import RagStoreConfig, RagStoreConfigParam +from .retrievaltype import RetrievalType from .vertexaisearchconfig import VertexAISearchConfig, VertexAISearchConfigParam import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator -from typing import List, Literal, Optional, Union +from typing import List, Literal, Optional from typing_extensions import Annotated, NotRequired, TypedDict -RetrievalRetrievalType = Union[ - Literal[ - "vertex_ai_search", - "rag_store", - "exa_ai_search", - "parallel_ai_search", - ], - UnrecognizedStr, -] - - class RetrievalParam(TypedDict): r"""A tool that can be used by the model to retrieve files.""" @@ -50,7 +40,7 @@ class RetrievalParam(TypedDict): r"""Used to specify configuration for ParallelAISearch.""" rag_store_config: NotRequired[RagStoreConfigParam] r"""Use to specify configuration for RAG Store.""" - retrieval_types: NotRequired[List[RetrievalRetrievalType]] + retrieval_types: NotRequired[List[RetrievalType]] r"""The types of file retrieval to enable.""" type: Literal["retrieval"] vertex_ai_search_config: NotRequired[VertexAISearchConfigParam] @@ -69,7 +59,7 @@ class Retrieval(BaseModel): rag_store_config: Optional[RagStoreConfig] = None r"""Use to specify configuration for RAG Store.""" - retrieval_types: Optional[List[RetrievalRetrievalType]] = None + retrieval_types: Optional[List[RetrievalType]] = None r"""The types of file retrieval to enable.""" type: Annotated[ diff --git a/google/genai/_gaos/types/interactions/retrievalcallarguments.py b/google/genai/_gaos/types/interactions/retrievalcallarguments.py index 9746017e0..52aab64b5 100644 --- a/google/genai/_gaos/types/interactions/retrievalcallarguments.py +++ b/google/genai/_gaos/types/interactions/retrievalcallarguments.py @@ -23,7 +23,7 @@ from typing_extensions import NotRequired, TypedDict -class RetrievalCallArgumentsTypedDict(TypedDict): +class RetrievalCallArgumentsParam(TypedDict): r"""The arguments to pass to Retrieval tools.""" queries: NotRequired[List[str]] diff --git a/google/genai/_gaos/types/interactions/retrievalcalldelta.py b/google/genai/_gaos/types/interactions/retrievalcalldelta.py index bcff610a3..25ba11017 100644 --- a/google/genai/_gaos/types/interactions/retrievalcalldelta.py +++ b/google/genai/_gaos/types/interactions/retrievalcalldelta.py @@ -19,10 +19,7 @@ from __future__ import annotations from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr from ...utils import validate_const -from .retrievalcallarguments import ( - RetrievalCallArguments, - RetrievalCallArgumentsTypedDict, -) +from .retrievalcallarguments import RetrievalCallArguments, RetrievalCallArgumentsParam import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -47,7 +44,7 @@ class RetrievalCallDeltaTypedDict(TypedDict): etc. RetrievalType decides which tool is used. """ - arguments: RetrievalCallArgumentsTypedDict + arguments: RetrievalCallArgumentsParam r"""The arguments to pass to Retrieval tools.""" retrieval_type: NotRequired[RetrievalCallDeltaRetrievalType] r"""The type of retrieval tools.""" diff --git a/google/genai/_gaos/types/interactions/retrievalcallstep.py b/google/genai/_gaos/types/interactions/retrievalcallstep.py new file mode 100644 index 000000000..f2da3d12b --- /dev/null +++ b/google/genai/_gaos/types/interactions/retrievalcallstep.py @@ -0,0 +1,110 @@ +# 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 ( + Base64EncodedString, + Base64FileInput, + BaseModel, + UNSET_SENTINEL, + UnrecognizedStr, +) +from ...utils import validate_const +from .retrievalcallarguments import RetrievalCallArguments, RetrievalCallArgumentsParam +import pydantic +from pydantic import model_serializer +from pydantic.functional_validators import AfterValidator +from typing import Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict + + +RetrievalCallStepRetrievalType = Union[ + Literal[ + "vertex_ai_search", + "rag_store", + "exa_ai_search", + "parallel_ai_search", + ], + UnrecognizedStr, +] +r"""The type of retrieval tools.""" + + +class RetrievalCallStepParam(TypedDict): + r"""Retrieval call step. + Used by Vertex Retrieval tools such as Parallel AI, Exa AI, Vertex AI Search, + etc. RetrievalType decides which tool is used. + """ + + arguments: RetrievalCallArgumentsParam + r"""The arguments to pass to Retrieval tools.""" + id: str + r"""Required. A unique ID for this specific tool call.""" + retrieval_type: NotRequired[RetrievalCallStepRetrievalType] + r"""The type of retrieval tools.""" + signature: NotRequired[Union[str, Base64FileInput]] + r"""A signature hash for backend validation.""" + type: Literal["retrieval_call"] + + +class RetrievalCallStep(BaseModel): + r"""Retrieval call step. + Used by Vertex Retrieval tools such as Parallel AI, Exa AI, Vertex AI Search, + etc. RetrievalType decides which tool is used. + """ + + arguments: RetrievalCallArguments + r"""The arguments to pass to Retrieval tools.""" + + id: str + r"""Required. A unique ID for this specific tool call.""" + + retrieval_type: Optional[RetrievalCallStepRetrievalType] = None + r"""The type of retrieval tools.""" + + signature: Optional[Base64EncodedString] = None + r"""A signature hash for backend validation.""" + + type: Annotated[ + Annotated[ + Literal["retrieval_call"], AfterValidator(validate_const("retrieval_call")) + ], + pydantic.Field(alias="type"), + ] = "retrieval_call" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["retrieval_type", "signature"]) + 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 + + +try: + RetrievalCallStep.model_rebuild() +except NameError: + pass diff --git a/google/genai/_gaos/types/interactions/retrievalresultstep.py b/google/genai/_gaos/types/interactions/retrievalresultstep.py new file mode 100644 index 000000000..75faee4a3 --- /dev/null +++ b/google/genai/_gaos/types/interactions/retrievalresultstep.py @@ -0,0 +1,87 @@ +# 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 Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL +from ...utils import validate_const +import pydantic +from pydantic import model_serializer +from pydantic.functional_validators import AfterValidator +from typing import Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict + + +class RetrievalResultStepParam(TypedDict): + r"""Vertex Retrieval result step. + Used by Vertex Retrieval tools such as Parallel AI, Exa AI, Vertex AI Search, + etc. + """ + + call_id: str + r"""Required. ID to match the ID from the function call block.""" + is_error: NotRequired[bool] + r"""Whether the retrieval resulted in an error.""" + signature: NotRequired[Union[str, Base64FileInput]] + r"""A signature hash for backend validation.""" + type: Literal["retrieval_result"] + + +class RetrievalResultStep(BaseModel): + r"""Vertex Retrieval result step. + Used by Vertex Retrieval tools such as Parallel AI, Exa AI, Vertex AI Search, + etc. + """ + + call_id: str + r"""Required. ID to match the ID from the function call block.""" + + is_error: Optional[bool] = None + r"""Whether the retrieval resulted in an error.""" + + signature: Optional[Base64EncodedString] = None + r"""A signature hash for backend validation.""" + + type: Annotated[ + Annotated[ + Literal["retrieval_result"], + AfterValidator(validate_const("retrieval_result")), + ], + pydantic.Field(alias="type"), + ] = "retrieval_result" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["is_error", "signature"]) + 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 + + +try: + RetrievalResultStep.model_rebuild() +except NameError: + pass diff --git a/google/genai/_gaos/types/interactions/retrievaltype.py b/google/genai/_gaos/types/interactions/retrievaltype.py new file mode 100644 index 000000000..9e4f7b67c --- /dev/null +++ b/google/genai/_gaos/types/interactions/retrievaltype.py @@ -0,0 +1,33 @@ +# 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 UnrecognizedStr +from typing import Literal, Union + + +RetrievalType = Union[ + Literal[ + "vertex_ai_search", + "rag_store", + "exa_ai_search", + "parallel_ai_search", + ], + UnrecognizedStr, +] +r"""The type of file retrieval to enable.""" diff --git a/google/genai/_gaos/types/interactions/step.py b/google/genai/_gaos/types/interactions/step.py index d10aabbbb..95dc56783 100644 --- a/google/genai/_gaos/types/interactions/step.py +++ b/google/genai/_gaos/types/interactions/step.py @@ -38,6 +38,8 @@ MCPServerToolResultStepParam, ) from .modeloutputstep import ModelOutputStep, ModelOutputStepParam +from .retrievalcallstep import RetrievalCallStep, RetrievalCallStepParam +from .retrievalresultstep import RetrievalResultStep, RetrievalResultStepParam from .thoughtstep import ThoughtStep, ThoughtStepParam from .urlcontextcallstep import URLContextCallStep, URLContextCallStepParam from .urlcontextresultstep import URLContextResultStep, URLContextResultStepParam @@ -53,22 +55,24 @@ "StepParam", Union[ UserInputStepParam, - FileSearchCallStepParam, ModelOutputStepParam, - ThoughtStepParam, + FileSearchCallStepParam, FileSearchResultStepParam, + ThoughtStepParam, CodeExecutionCallStepParam, URLContextCallStepParam, GoogleMapsCallStepParam, - FunctionCallStepParam, GoogleMapsResultStepParam, - MCPServerToolCallStepParam, + RetrievalResultStepParam, + FunctionCallStepParam, + RetrievalCallStepParam, + GoogleSearchResultStepParam, GoogleSearchCallStepParam, - FunctionResultStepParam, - CodeExecutionResultStepParam, URLContextResultStepParam, - GoogleSearchResultStepParam, + CodeExecutionResultStepParam, MCPServerToolResultStepParam, + MCPServerToolCallStepParam, + FunctionResultStepParam, ], ) r"""A step in the interaction.""" @@ -85,45 +89,49 @@ class UnknownStep(BaseModel): _STEP_VARIANTS: dict[str, Any] = { - "user_input": UserInputStep, - "model_output": ModelOutputStep, - "thought": ThoughtStep, - "function_call": FunctionCallStep, "code_execution_call": CodeExecutionCallStep, - "url_context_call": URLContextCallStep, - "mcp_server_tool_call": MCPServerToolCallStep, - "google_search_call": GoogleSearchCallStep, + "code_execution_result": CodeExecutionResultStep, "file_search_call": FileSearchCallStep, - "google_maps_call": GoogleMapsCallStep, + "file_search_result": FileSearchResultStep, + "function_call": FunctionCallStep, "function_result": FunctionResultStep, - "code_execution_result": CodeExecutionResultStep, - "url_context_result": URLContextResultStep, + "google_maps_call": GoogleMapsCallStep, + "google_maps_result": GoogleMapsResultStep, + "google_search_call": GoogleSearchCallStep, "google_search_result": GoogleSearchResultStep, + "mcp_server_tool_call": MCPServerToolCallStep, "mcp_server_tool_result": MCPServerToolResultStep, - "file_search_result": FileSearchResultStep, - "google_maps_result": GoogleMapsResultStep, + "model_output": ModelOutputStep, + "retrieval_call": RetrievalCallStep, + "retrieval_result": RetrievalResultStep, + "thought": ThoughtStep, + "url_context_call": URLContextCallStep, + "url_context_result": URLContextResultStep, + "user_input": UserInputStep, } Step = Annotated[ Union[ - UserInputStep, - ModelOutputStep, - ThoughtStep, - FunctionCallStep, CodeExecutionCallStep, - URLContextCallStep, - MCPServerToolCallStep, - GoogleSearchCallStep, + CodeExecutionResultStep, FileSearchCallStep, - GoogleMapsCallStep, + FileSearchResultStep, + FunctionCallStep, FunctionResultStep, - CodeExecutionResultStep, - URLContextResultStep, + GoogleMapsCallStep, + GoogleMapsResultStep, + GoogleSearchCallStep, GoogleSearchResultStep, + MCPServerToolCallStep, MCPServerToolResultStep, - FileSearchResultStep, - GoogleMapsResultStep, + ModelOutputStep, + RetrievalCallStep, + RetrievalResultStep, + ThoughtStep, + URLContextCallStep, + URLContextResultStep, + UserInputStep, UnknownStep, ], BeforeValidator( diff --git a/google/genai/_gaos/types/interactions/stepdeltadata.py b/google/genai/_gaos/types/interactions/stepdeltadata.py index 35045362f..f534a16d2 100644 --- a/google/genai/_gaos/types/interactions/stepdeltadata.py +++ b/google/genai/_gaos/types/interactions/stepdeltadata.py @@ -68,29 +68,29 @@ StepDeltaDataTypedDict = TypeAliasType( "StepDeltaDataTypedDict", Union[ - ArgumentsDeltaTypedDict, ThoughtSummaryDeltaTypedDict, ThoughtSignatureDeltaTypedDict, TextDeltaTypedDict, TextAnnotationDeltaTypedDict, + ArgumentsDeltaTypedDict, + RetrievalResultDeltaTypedDict, FileSearchCallDeltaTypedDict, FileSearchResultDeltaTypedDict, - RetrievalResultDeltaTypedDict, - GoogleMapsCallDeltaTypedDict, + URLContextCallDeltaTypedDict, GoogleMapsResultDeltaTypedDict, GoogleSearchCallDeltaTypedDict, - URLContextCallDeltaTypedDict, - CodeExecutionCallDeltaTypedDict, - GoogleSearchResultDeltaTypedDict, - MCPServerToolResultDeltaTypedDict, RetrievalCallDeltaTypedDict, - MCPServerToolCallDeltaTypedDict, + GoogleMapsCallDeltaTypedDict, DocumentDeltaTypedDict, - CodeExecutionResultDeltaTypedDict, - URLContextResultDeltaTypedDict, + CodeExecutionCallDeltaTypedDict, + GoogleSearchResultDeltaTypedDict, ImageDeltaTypedDict, - FunctionResultDeltaTypedDict, VideoDeltaTypedDict, + URLContextResultDeltaTypedDict, + CodeExecutionResultDeltaTypedDict, + FunctionResultDeltaTypedDict, + MCPServerToolResultDeltaTypedDict, + MCPServerToolCallDeltaTypedDict, AudioDeltaTypedDict, ], ) @@ -125,6 +125,7 @@ class UnknownStepDeltaData(BaseModel): "retrieval_call": RetrievalCallDelta, "retrieval_result": RetrievalResultDelta, "text_annotation_delta": TextAnnotationDelta, + "text_annotation": TextAnnotationDelta, "text": TextDelta, "thought_signature": ThoughtSignatureDelta, "thought_summary": ThoughtSummaryDelta, @@ -154,6 +155,7 @@ class UnknownStepDeltaData(BaseModel): RetrievalCallDelta, RetrievalResultDelta, TextAnnotationDelta, + TextAnnotationDelta, TextDelta, ThoughtSignatureDelta, ThoughtSummaryDelta, diff --git a/google/genai/_gaos/types/interactions/stepstart.py b/google/genai/_gaos/types/interactions/stepstart.py index cc848ee54..a64b2668e 100644 --- a/google/genai/_gaos/types/interactions/stepstart.py +++ b/google/genai/_gaos/types/interactions/stepstart.py @@ -20,6 +20,7 @@ from .. import BaseModel, UNSET_SENTINEL from ...utils import validate_const from .step import Step, StepParam +from .streammetadata import StreamMetadata, StreamMetadataTypedDict import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -36,6 +37,8 @@ class StepStartTypedDict(TypedDict): this event. """ event_type: Literal["step.start"] + metadata: NotRequired[StreamMetadataTypedDict] + r"""Optional metadata accompanying ANY streamed event.""" class StepStart(BaseModel): @@ -54,9 +57,12 @@ class StepStart(BaseModel): pydantic.Field(alias="event_type"), ] = "step.start" + metadata: Optional[StreamMetadata] = None + r"""Optional metadata accompanying ANY streamed event.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["event_id"]) + optional_fields = set(["event_id", "metadata"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/stepstop.py b/google/genai/_gaos/types/interactions/stepstop.py index 26f2b4178..87eb7b828 100644 --- a/google/genai/_gaos/types/interactions/stepstop.py +++ b/google/genai/_gaos/types/interactions/stepstop.py @@ -19,6 +19,7 @@ from __future__ import annotations from .. import BaseModel, UNSET_SENTINEL from ...utils import validate_const +from .streammetadata import StreamMetadata, StreamMetadataTypedDict from .usage import Usage, UsageTypedDict import pydantic from pydantic import model_serializer @@ -38,6 +39,8 @@ class StepStopTypedDict(TypedDict): r"""Statistics on the interaction request's token usage.""" usage: NotRequired[UsageTypedDict] r"""Statistics on the interaction request's token usage.""" + metadata: NotRequired[StreamMetadataTypedDict] + r"""Optional metadata accompanying ANY streamed event.""" class StepStop(BaseModel): @@ -59,9 +62,12 @@ class StepStop(BaseModel): usage: Optional[Usage] = None r"""Statistics on the interaction request's token usage.""" + metadata: Optional[StreamMetadata] = None + r"""Optional metadata accompanying ANY streamed event.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["event_id", "step_usage", "usage"]) + optional_fields = set(["event_id", "step_usage", "usage", "metadata"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/streammetadata.py b/google/genai/_gaos/types/interactions/streammetadata.py new file mode 100644 index 000000000..33c6acf51 --- /dev/null +++ b/google/genai/_gaos/types/interactions/streammetadata.py @@ -0,0 +1,54 @@ +# 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 .usage import Usage, UsageTypedDict +from pydantic import model_serializer +from typing import Optional +from typing_extensions import NotRequired, TypedDict + + +class StreamMetadataTypedDict(TypedDict): + r"""Optional metadata accompanying ANY streamed event.""" + + total_usage: NotRequired[UsageTypedDict] + r"""Statistics on the interaction request's token usage.""" + + +class StreamMetadata(BaseModel): + r"""Optional metadata accompanying ANY streamed event.""" + + total_usage: Optional[Usage] = None + r"""Statistics on the interaction request's token usage.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["total_usage"]) + 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/interactions/textannotationdelta.py b/google/genai/_gaos/types/interactions/textannotationdelta.py index 68c5580a8..9030b54c4 100644 --- a/google/genai/_gaos/types/interactions/textannotationdelta.py +++ b/google/genai/_gaos/types/interactions/textannotationdelta.py @@ -17,34 +17,34 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from .. import BaseModel, UNSET_SENTINEL -from ...utils import validate_const +from .. import BaseModel, UNSET_SENTINEL, UnrecognizedStr from .annotation import Annotation, AnnotationParam -import pydantic from pydantic import model_serializer -from pydantic.functional_validators import AfterValidator -from typing import List, Literal, Optional -from typing_extensions import Annotated, NotRequired, TypedDict +from typing import List, Literal, Optional, Union +from typing_extensions import NotRequired, TypedDict + + +TextAnnotationDeltaType = Union[ + Literal[ + "text_annotation_delta", + "text_annotation", + ], + UnrecognizedStr, +] class TextAnnotationDeltaTypedDict(TypedDict): + type: TextAnnotationDeltaType annotations: NotRequired[List[AnnotationParam]] r"""Citation information for model-generated content.""" - type: Literal["text_annotation_delta"] class TextAnnotationDelta(BaseModel): + type: TextAnnotationDeltaType + annotations: Optional[List[Annotation]] = None r"""Citation information for model-generated content.""" - type: Annotated[ - Annotated[ - Literal["text_annotation_delta"], - AfterValidator(validate_const("text_annotation_delta")), - ], - pydantic.Field(alias="type"), - ] = "text_annotation_delta" - @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["annotations"]) @@ -60,9 +60,3 @@ def serialize_model(self, handler): m[k] = val return m - - -try: - TextAnnotationDelta.model_rebuild() -except NameError: - pass diff --git a/google/genai/_gaos/types/interactions/transcriptionconfig.py b/google/genai/_gaos/types/interactions/transcriptionconfig.py index f86a67495..df9b55266 100644 --- a/google/genai/_gaos/types/interactions/transcriptionconfig.py +++ b/google/genai/_gaos/types/interactions/transcriptionconfig.py @@ -27,8 +27,6 @@ class TranscriptionConfigParam(TypedDict): r"""Configuration for speech recognition (transcription).""" - adaptation_phrases: NotRequired[List[str]] - r"""Optional. A list of phrases to bias the ASR model towards.""" custom_vocabulary: NotRequired[List[str]] r"""Optional. A list of custom vocabulary phrases to bias the speech recognition model toward recognizing specific terms. @@ -43,19 +41,13 @@ class TranscriptionConfigParam(TypedDict): r"""Optional. The granularity of timestamps to include in the transcription output. Supported values: \"word\". If empty, no timestamps are generated. """ + language_hints: NotRequired[List[str]] + r"""Deprecated: use language_codes. BCP-47 language codes providing hints about the languages present in the audio.""" class TranscriptionConfig(BaseModel): r"""Configuration for speech recognition (transcription).""" - adaptation_phrases: Annotated[ - Optional[List[str]], - pydantic.Field( - deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." - ), - ] = None - r"""Optional. A list of phrases to bias the ASR model towards.""" - custom_vocabulary: Optional[List[str]] = None r"""Optional. A list of custom vocabulary phrases to bias the speech recognition model toward recognizing specific terms. @@ -74,15 +66,23 @@ class TranscriptionConfig(BaseModel): Supported values: \"word\". If empty, no timestamps are generated. """ + language_hints: Annotated[ + Optional[List[str]], + pydantic.Field( + deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." + ), + ] = None + r"""Deprecated: use language_codes. BCP-47 language codes providing hints about the languages present in the audio.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ - "adaptation_phrases", "custom_vocabulary", "diarization_mode", "language_codes", "timestamp_granularities", + "language_hints", ] ) serialized = handler(self) diff --git a/google/genai/_gaos/types/interactions/turn.py b/google/genai/_gaos/types/interactions/turn.py new file mode 100644 index 000000000..2f24c65f0 --- /dev/null +++ b/google/genai/_gaos/types/interactions/turn.py @@ -0,0 +1,69 @@ +# 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 .content import Content, ContentParam +from pydantic import model_serializer +from typing import List, Optional, Union +from typing_extensions import NotRequired, TypeAliasType, TypedDict, deprecated + + +TurnContentParam = TypeAliasType("TurnContentParam", Union[List[ContentParam], str]) + + +TurnContent = TypeAliasType("TurnContent", Union[List[Content], str]) + + +@deprecated( + "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." +) +class TurnParam(TypedDict): + content: NotRequired[TurnContentParam] + role: NotRequired[str] + r"""The originator of this turn. Must be user for input or model for + model output. + """ + + +@deprecated( + "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible." +) +class Turn(BaseModel): + content: Optional[TurnContent] = None + + role: Optional[str] = None + r"""The originator of this turn. Must be user for input or model for + model output. + """ + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["content", "role"]) + 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/interactions/urlcontextcallarguments.py b/google/genai/_gaos/types/interactions/urlcontextcallarguments.py index 6fce0335a..afeefa382 100644 --- a/google/genai/_gaos/types/interactions/urlcontextcallarguments.py +++ b/google/genai/_gaos/types/interactions/urlcontextcallarguments.py @@ -23,7 +23,7 @@ from typing_extensions import NotRequired, TypedDict -class URLContextCallArgumentsParam(TypedDict): +class URLContextCallArgumentsTypedDict(TypedDict): r"""The arguments to pass to the URL context.""" urls: NotRequired[List[str]] diff --git a/google/genai/_gaos/types/interactions/urlcontextcalldelta.py b/google/genai/_gaos/types/interactions/urlcontextcalldelta.py index 1e0877f17..d50d7f2c5 100644 --- a/google/genai/_gaos/types/interactions/urlcontextcalldelta.py +++ b/google/genai/_gaos/types/interactions/urlcontextcalldelta.py @@ -21,7 +21,7 @@ from ...utils import validate_const from .urlcontextcallarguments import ( URLContextCallArguments, - URLContextCallArgumentsParam, + URLContextCallArgumentsTypedDict, ) import pydantic from pydantic import model_serializer @@ -31,8 +31,10 @@ class URLContextCallDeltaTypedDict(TypedDict): - arguments: URLContextCallArgumentsParam + arguments: URLContextCallArgumentsTypedDict r"""The arguments to pass to the URL context.""" + id: NotRequired[str] + r"""Required. A unique ID for this specific tool call.""" signature: NotRequired[str] r"""A signature hash for backend validation.""" type: Literal["url_context_call"] @@ -42,6 +44,9 @@ class URLContextCallDelta(BaseModel): arguments: URLContextCallArguments r"""The arguments to pass to the URL context.""" + id: Optional[str] = None + r"""Required. A unique ID for this specific tool call.""" + signature: Optional[str] = None r"""A signature hash for backend validation.""" @@ -55,7 +60,7 @@ class URLContextCallDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["signature"]) + optional_fields = set(["id", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/urlcontextcallstep.py b/google/genai/_gaos/types/interactions/urlcontextcallstep.py index cb849e6af..7f244d403 100644 --- a/google/genai/_gaos/types/interactions/urlcontextcallstep.py +++ b/google/genai/_gaos/types/interactions/urlcontextcallstep.py @@ -19,10 +19,7 @@ from __future__ import annotations from .. import Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL from ...utils import validate_const -from .urlcontextcallarguments import ( - URLContextCallArguments, - URLContextCallArgumentsParam, -) +from .arguments import Arguments, ArgumentsParam import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -33,7 +30,7 @@ class URLContextCallStepParam(TypedDict): r"""URL context call step.""" - arguments: URLContextCallArgumentsParam + arguments: ArgumentsParam r"""The arguments to pass to the URL context.""" id: str r"""Required. A unique ID for this specific tool call.""" @@ -45,7 +42,7 @@ class URLContextCallStepParam(TypedDict): class URLContextCallStep(BaseModel): r"""URL context call step.""" - arguments: URLContextCallArguments + arguments: Arguments r"""The arguments to pass to the URL context.""" id: str diff --git a/google/genai/_gaos/types/interactions/urlcontextresult.py b/google/genai/_gaos/types/interactions/urlcontextresult.py index 919a4d290..6bde5817a 100644 --- a/google/genai/_gaos/types/interactions/urlcontextresult.py +++ b/google/genai/_gaos/types/interactions/urlcontextresult.py @@ -35,7 +35,7 @@ r"""The status of the URL retrieval.""" -class URLContextResultParam(TypedDict): +class URLContextResultTypedDict(TypedDict): r"""The result of the URL context.""" status: NotRequired[URLContextResultStatus] diff --git a/google/genai/_gaos/types/interactions/urlcontextresultdelta.py b/google/genai/_gaos/types/interactions/urlcontextresultdelta.py index f4a9b1e7e..d76fdd298 100644 --- a/google/genai/_gaos/types/interactions/urlcontextresultdelta.py +++ b/google/genai/_gaos/types/interactions/urlcontextresultdelta.py @@ -19,7 +19,7 @@ from __future__ import annotations from .. import BaseModel, UNSET_SENTINEL from ...utils import validate_const -from .urlcontextresult import URLContextResult, URLContextResultParam +from .urlcontextresult import URLContextResult, URLContextResultTypedDict import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -28,7 +28,9 @@ class URLContextResultDeltaTypedDict(TypedDict): - result: List[URLContextResultParam] + result: List[URLContextResultTypedDict] + call_id: NotRequired[str] + r"""Required. ID to match the ID from the function call block.""" is_error: NotRequired[bool] signature: NotRequired[str] r"""A signature hash for backend validation.""" @@ -38,6 +40,9 @@ class URLContextResultDeltaTypedDict(TypedDict): class URLContextResultDelta(BaseModel): result: List[URLContextResult] + call_id: Optional[str] = None + r"""Required. ID to match the ID from the function call block.""" + is_error: Optional[bool] = None signature: Optional[str] = None @@ -53,7 +58,7 @@ class URLContextResultDelta(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["is_error", "signature"]) + optional_fields = set(["call_id", "is_error", "signature"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/interactions/urlcontextresultitem.py b/google/genai/_gaos/types/interactions/urlcontextresultitem.py new file mode 100644 index 000000000..912b5cadc --- /dev/null +++ b/google/genai/_gaos/types/interactions/urlcontextresultitem.py @@ -0,0 +1,70 @@ +# 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 pydantic import model_serializer +from typing import Literal, Optional, Union +from typing_extensions import NotRequired, TypedDict + + +URLContextResultItemStatus = Union[ + Literal[ + "success", + "error", + "paywall", + "unsafe", + ], + UnrecognizedStr, +] +r"""The status of the URL retrieval.""" + + +class URLContextResultItemParam(TypedDict): + r"""The result of the URL context.""" + + status: NotRequired[URLContextResultItemStatus] + r"""The status of the URL retrieval.""" + url: NotRequired[str] + r"""The URL that was fetched.""" + + +class URLContextResultItem(BaseModel): + r"""The result of the URL context.""" + + status: Optional[URLContextResultItemStatus] = None + r"""The status of the URL retrieval.""" + + url: Optional[str] = None + r"""The URL that was fetched.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["status", "url"]) + 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/interactions/urlcontextresultstep.py b/google/genai/_gaos/types/interactions/urlcontextresultstep.py index 063fd2723..76aab3640 100644 --- a/google/genai/_gaos/types/interactions/urlcontextresultstep.py +++ b/google/genai/_gaos/types/interactions/urlcontextresultstep.py @@ -19,7 +19,7 @@ from __future__ import annotations from .. import Base64EncodedString, Base64FileInput, BaseModel, UNSET_SENTINEL from ...utils import validate_const -from .urlcontextresult import URLContextResult, URLContextResultParam +from .urlcontextresultitem import URLContextResultItem, URLContextResultItemParam import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator @@ -32,7 +32,7 @@ class URLContextResultStepParam(TypedDict): call_id: str r"""Required. ID to match the ID from the function call block.""" - result: List[URLContextResultParam] + result: List[URLContextResultItemParam] r"""Required. The results of the URL context.""" is_error: NotRequired[bool] r"""Whether the URL context resulted in an error.""" @@ -47,7 +47,7 @@ class URLContextResultStep(BaseModel): call_id: str r"""Required. ID to match the ID from the function call block.""" - result: List[URLContextResult] + result: List[URLContextResultItem] r"""Required. The results of the URL context.""" is_error: Optional[bool] = None diff --git a/google/genai/_gaos/types/interactions/userinputstep.py b/google/genai/_gaos/types/interactions/userinputstep.py index ea84c0d7d..1b62a9786 100644 --- a/google/genai/_gaos/types/interactions/userinputstep.py +++ b/google/genai/_gaos/types/interactions/userinputstep.py @@ -23,21 +23,29 @@ import pydantic from pydantic import model_serializer from pydantic.functional_validators import AfterValidator -from typing import List, Literal, Optional -from typing_extensions import Annotated, NotRequired, TypedDict +from typing import List, Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict + + +UserInputStepContentParam = TypeAliasType( + "UserInputStepContentParam", Union[List[ContentParam], str] +) + + +UserInputStepContent = TypeAliasType("UserInputStepContent", Union[List[Content], str]) class UserInputStepParam(TypedDict): r"""Input provided by the user.""" - content: NotRequired[List[ContentParam]] + content: NotRequired[UserInputStepContentParam] type: Literal["user_input"] class UserInputStep(BaseModel): r"""Input provided by the user.""" - content: Optional[List[Content]] = None + content: Optional[UserInputStepContent] = None type: Annotated[ Annotated[Literal["user_input"], AfterValidator(validate_const("user_input"))], diff --git a/google/genai/_gaos/types/security.py b/google/genai/_gaos/types/security.py index b7492fe7a..dc1aef8e1 100644 --- a/google/genai/_gaos/types/security.py +++ b/google/genai/_gaos/types/security.py @@ -26,26 +26,15 @@ class SecurityTypedDict(TypedDict): - api_key: NotRequired[str] - r"""Gemini API key sent as x-goog-api-key.""" access_token: NotRequired[str] r"""OAuth access token sent as a bearer Authorization header.""" + api_key: NotRequired[str] + r"""Gemini API key sent as x-goog-api-key.""" default_headers: NotRequired[Dict[str, str]] r"""Additional default headers to apply before request-specific headers and auth.""" class Security(BaseModel): - api_key: Annotated[ - Optional[str], - pydantic.Field(alias="apiKey"), - FieldMetadata( - security=SecurityMetadata( - scheme=True, scheme_type="http", sub_type="custom", field_name="apiKey" - ) - ), - ] = None - r"""Gemini API key sent as x-goog-api-key.""" - access_token: Annotated[ Optional[str], pydantic.Field(alias="accessToken"), @@ -60,6 +49,17 @@ class Security(BaseModel): ] = None r"""OAuth access token sent as a bearer Authorization header.""" + api_key: Annotated[ + Optional[str], + pydantic.Field(alias="apiKey"), + FieldMetadata( + security=SecurityMetadata( + scheme=True, scheme_type="http", sub_type="custom", field_name="apiKey" + ) + ), + ] = None + r"""Gemini API key sent as x-goog-api-key.""" + default_headers: Annotated[ Optional[Dict[str, str]], pydantic.Field(alias="defaultHeaders"), @@ -76,7 +76,7 @@ class Security(BaseModel): @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["apiKey", "accessToken", "defaultHeaders"]) + optional_fields = set(["accessToken", "apiKey", "defaultHeaders"]) serialized = handler(self) m = {} diff --git a/google/genai/_gaos/types/triggers/triggercreateparams.py b/google/genai/_gaos/types/triggers/triggercreateparams.py index ef21726fb..5feb09ef8 100644 --- a/google/genai/_gaos/types/triggers/triggercreateparams.py +++ b/google/genai/_gaos/types/triggers/triggercreateparams.py @@ -50,54 +50,62 @@ class TriggerCreateParamsParam(TypedDict): r"""Parameters for creating a trigger.""" + interaction: InteractionParam + r"""Required. The interaction request template to be executed.""" schedule: str - r"""Required. The cron schedule on which the trigger should run. Standard cron format.""" + r"""Required. The cron schedule on which the trigger should run. + Standard cron format. + """ time_zone: str r"""Required. Time zone in which the schedule should be interpreted.""" - interaction: InteractionParam - r"""Required. The interaction request template to be executed.""" display_name: NotRequired[str] r"""Optional. The display name of the trigger.""" environment_id: NotRequired[str] r"""Optional. The environment ID for the trigger execution.""" - max_consecutive_failures: NotRequired[int] - r"""Optional. The maximum number of consecutive failures allowed before the trigger is automatically paused (status becomes ERROR).""" execution_timeout_seconds: NotRequired[int] r"""Optional. The execution timeout for the triggered interaction.""" + max_consecutive_failures: NotRequired[int] + r"""Optional. The maximum number of consecutive failures allowed before + the trigger is automatically paused (status becomes ERROR). + """ class TriggerCreateParams(BaseModel): r"""Parameters for creating a trigger.""" + interaction: Interaction + r"""Required. The interaction request template to be executed.""" + schedule: str - r"""Required. The cron schedule on which the trigger should run. Standard cron format.""" + r"""Required. The cron schedule on which the trigger should run. + Standard cron format. + """ time_zone: str r"""Required. Time zone in which the schedule should be interpreted.""" - interaction: Interaction - r"""Required. The interaction request template to be executed.""" - display_name: Optional[str] = None r"""Optional. The display name of the trigger.""" environment_id: Optional[str] = None r"""Optional. The environment ID for the trigger execution.""" - max_consecutive_failures: Optional[int] = None - r"""Optional. The maximum number of consecutive failures allowed before the trigger is automatically paused (status becomes ERROR).""" - execution_timeout_seconds: Optional[int] = None r"""Optional. The execution timeout for the triggered interaction.""" + max_consecutive_failures: Optional[int] = None + r"""Optional. The maximum number of consecutive failures allowed before + the trigger is automatically paused (status becomes ERROR). + """ + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "display_name", "environment_id", - "max_consecutive_failures", "execution_timeout_seconds", + "max_consecutive_failures", ] ) serialized = handler(self) diff --git a/google/genai/_gaos/utils/security.py b/google/genai/_gaos/utils/security.py index 01c11f875..b4a1b1a6d 100644 --- a/google/genai/_gaos/utils/security.py +++ b/google/genai/_gaos/utils/security.py @@ -92,12 +92,12 @@ def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseMo security_dict: Any = {} - if os.getenv("GOOGLE_GENAI_API_KEY"): - security_dict["api_key"] = os.getenv("GOOGLE_GENAI_API_KEY") - if os.getenv("GOOGLE_GENAI_ACCESS_TOKEN"): security_dict["access_token"] = os.getenv("GOOGLE_GENAI_ACCESS_TOKEN") + if os.getenv("GOOGLE_GENAI_API_KEY"): + security_dict["api_key"] = os.getenv("GOOGLE_GENAI_API_KEY") + if os.getenv("GOOGLE_GENAI_DEFAULT_HEADERS"): security_dict["default_headers"] = os.getenv("GOOGLE_GENAI_DEFAULT_HEADERS") diff --git a/google/genai/_gaos/webhooks.py b/google/genai/_gaos/webhooks.py index e5939301d..2cc65951a 100644 --- a/google/genai/_gaos/webhooks.py +++ b/google/genai/_gaos/webhooks.py @@ -41,35 +41,24 @@ def with_raw_response(self): def with_streaming_response(self): return WebhooksWithStreamingResponse(self) - def create( + def list( self, *, - subscribed_events: Iterable[webhooks_webhook.WebhookSubscribedEvent], - uri: str, - api_version: Optional[str] = None, - name: 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, - extra_body: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, - ) -> webhooks.Webhook: - r"""Creates a new Webhook. + ) -> webhooks.WebhookListResponse: + r"""Lists all Webhooks. - :param subscribed_events: Required. The events that the webhook is subscribed to. - Available events: - - batch.succeeded - - batch.expired - - batch.failed - - interaction.requires_action - - interaction.completed - - interaction.failed - - video.generated - :param uri: Required. The URI to which webhook events will be sent. - :param api_version: Which version of the API to use. - :param name: Optional. The user-provided name of the webhook. + :param page_size: The maximum number of webhooks to return. The service may return fewer than + this value. If unspecified, at most 50 webhooks will be returned. + The maximum value is 1000. + :param page_token: A page token, received from a previous `ListWebhooks` call. + Provide this to retrieve the subsequent page. :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 @@ -86,45 +75,31 @@ def create( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateWebhookRequest( - api_version=api_version, - body=webhooks.WebhookInput( - name=name, - subscribed_events=utils.unmarshal( - subscribed_events, List[webhooks.WebhookSubscribedEvent] - ), - uri=uri, - ), + request = models.ListWebhooksRequest( + 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="POST", + method="GET", path="/{api_version}/webhooks", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.CreateWebhookGlobals( + _globals=models.ListWebhooksGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - webhooks.WebhookInput, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -145,19 +120,34 @@ def create( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListWebhooksClientErrorData, http_res + ) + raise errors.ListWebhooksClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListWebhooksServerErrorData, http_res + ) + raise errors.ListWebhooksServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.Webhook, http_res, validate=False + webhooks.WebhookListResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -165,7 +155,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="CreateWebhook", + operation_id="ListWebhooks", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -219,26 +209,33 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def list( + def create( self, *, - api_version: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, + subscribed_events: Iterable[webhooks_webhook.WebhookSubscribedEvent], + uri: str, + name: Optional[str] = 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, - ) -> webhooks.WebhookListResponse: - r"""Lists all Webhooks. + ) -> webhooks.Webhook: + r"""Creates a new Webhook. - :param api_version: Which version of the API to use. - :param page_size: Optional. The maximum number of webhooks to return. The service may return fewer than - this value. If unspecified, at most 50 webhooks will be returned. - The maximum value is 1000. - :param page_token: Optional. A page token, received from a previous `ListWebhooks` call. - Provide this to retrieve the subsequent page. + :param subscribed_events: Required. The events that the webhook is subscribed to. + Available events: + - batch.succeeded + - batch.expired + - batch.failed + - interaction.requires_action + - interaction.completed + - interaction.failed + - video.generated + :param uri: Required. The URI to which webhook events will be sent. + :param name: Optional. The user-provided name of the webhook. :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 @@ -255,32 +252,42 @@ def list( else: base_url = self._get_url(base_url, url_variables) - request = models.ListWebhooksRequest( - api_version=api_version, - page_size=page_size, - page_token=page_token, + request = webhooks.WebhookInput( + name=name, + subscribed_events=utils.unmarshal( + subscribed_events, List[webhooks.WebhookSubscribedEvent] + ), + uri=uri, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="GET", + method="POST", path="/{api_version}/webhooks", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.ListWebhooksGlobals( + _globals=models.CreateWebhookGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request, + False, + False, + "json", + webhooks.WebhookInput, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -301,19 +308,34 @@ def list( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateWebhookClientErrorData, http_res + ) + raise errors.CreateWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateWebhookServerErrorData, http_res + ) + raise errors.CreateWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.WebhookListResponse, http_res, validate=False + webhooks.Webhook, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -321,7 +343,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListWebhooks", + operation_id="CreateWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -379,7 +401,6 @@ def get( 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, @@ -387,7 +408,6 @@ def get( r"""Gets a specific Webhook. :param id: Required. The ID of the webhook to retrieve. - :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 @@ -407,7 +427,6 @@ def get( base_url = self._get_url(base_url, url_variables) request = models.GetWebhookRequest( - api_version=api_version, id=id, ) @@ -451,16 +470,31 @@ def get( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetWebhookClientErrorData, http_res + ) + raise errors.GetWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetWebhookServerErrorData, http_res + ) + raise errors.GetWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( webhooks.Webhook, http_res, validate=False @@ -525,43 +559,20 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def update( + def delete( self, id: str, *, - api_version: Optional[str] = None, - update_mask: Optional[str] = None, - name: Optional[str] = None, - state: Optional[webhooks_webhookupdate.WebhookUpdateState] = None, - subscribed_events: Optional[ - Iterable[webhooks_webhookupdate.WebhookUpdateSubscribedEvent] - ] = None, - uri: Optional[str] = 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, - ) -> webhooks.Webhook: - r"""Updates an existing Webhook. + ) -> interactions.Empty: + r"""Deletes a Webhook. - :param id: Required. The ID of the webhook to update. - :param api_version: Which version of the API to use. - :param update_mask: Optional. The list of fields to update. - :param name: Optional. The user-provided name of the webhook. - :param state: Optional. The state of the webhook. - :param subscribed_events: Optional. The events that the webhook is subscribed to. - Available events: - - batch.succeeded - - batch.expired - - batch.failed - - interaction.requires_action - - interaction.completed - - interaction.failed - - video.generated - :param uri: Optional. The URI to which webhook events will be sent. + :param id: Required. The ID of the webhook to delete. + Format: `{webhook_id}` :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 @@ -578,26 +589,15 @@ def update( else: base_url = self._get_url(base_url, url_variables) - request = models.UpdateWebhookRequest( - api_version=api_version, + request = models.DeleteWebhookRequest( id=id, - update_mask=update_mask, - body=webhooks.WebhookUpdate( - name=name, - state=state, - subscribed_events=utils.unmarshal( - subscribed_events, - Optional[List[webhooks.WebhookUpdateSubscribedEvent]], - ), - uri=uri, - ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="PATCH", + method="DELETE", path="/{api_version}/webhooks/{id}", base_url=base_url, url_variables=url_variables, @@ -609,18 +609,10 @@ def update( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.UpdateWebhookGlobals( + _globals=models.DeleteWebhookGlobals( 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[webhooks.WebhookUpdate], - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -641,19 +633,34 @@ def update( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteWebhookClientErrorData, http_res + ) + raise errors.DeleteWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteWebhookServerErrorData, http_res + ) + raise errors.DeleteWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.Webhook, http_res, validate=False + interactions.Empty, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -661,7 +668,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="UpdateWebhook", + operation_id="DeleteWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -715,22 +722,41 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def delete( + def update( self, id: str, *, - api_version: Optional[str] = None, + update_mask: Optional[str] = None, + name: Optional[str] = None, + state: Optional[webhooks_webhookupdate.WebhookUpdateState] = None, + subscribed_events: Optional[ + Iterable[webhooks_webhookupdate.WebhookUpdateSubscribedEvent] + ] = None, + uri: Optional[str] = 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, - ) -> interactions.Empty: - r"""Deletes a Webhook. + ) -> webhooks.Webhook: + r"""Updates an existing Webhook. - :param id: Required. The ID of the webhook to delete. - Format: `{webhook_id}` - :param api_version: Which version of the API to use. + :param id: Required. The ID of the webhook to update. + :param update_mask: Optional list of fields to update. + :param name: Optional. The user-provided name of the webhook. + :param state: Optional. The state of the webhook. + :param subscribed_events: Optional. The events that the webhook is subscribed to. + Available events: + - batch.succeeded + - batch.expired + - batch.failed + - interaction.requires_action + - interaction.completed + - interaction.failed + - video.generated + :param uri: Optional. The URI to which webhook events will be sent. :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 @@ -747,16 +773,25 @@ def delete( else: base_url = self._get_url(base_url, url_variables) - request = models.DeleteWebhookRequest( - api_version=api_version, + request = models.UpdateWebhookRequest( id=id, + update_mask=update_mask, + body=webhooks.WebhookUpdate( + name=name, + state=state, + subscribed_events=utils.unmarshal( + subscribed_events, + Optional[List[webhooks.WebhookUpdateSubscribedEvent]], + ), + uri=uri, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request( - method="DELETE", + method="PATCH", path="/{api_version}/webhooks/{id}", base_url=base_url, url_variables=url_variables, @@ -768,10 +803,18 @@ def delete( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.DeleteWebhookGlobals( + _globals=models.UpdateWebhookGlobals( 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[webhooks.WebhookUpdate], + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -792,19 +835,34 @@ def delete( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateWebhookClientErrorData, http_res + ) + raise errors.UpdateWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateWebhookServerErrorData, http_res + ) + raise errors.UpdateWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - interactions.Empty, http_res, validate=False + webhooks.Webhook, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -812,7 +870,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="DeleteWebhook", + operation_id="UpdateWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -866,25 +924,25 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def rotate_signing_secret( + def ping( self, id: str, *, - api_version: Optional[str] = None, - revocation_behavior: Optional[ - webhooks_rotatesigningsecretrequest.RevocationBehavior + body: Optional[ + Union[ + webhooks_pingwebhookrequest.PingWebhookRequest, + webhooks_pingwebhookrequest.PingWebhookRequestParam, + ] ] = 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, - ) -> webhooks.WebhookRotateSigningSecretResponse: - r"""Generates a new signing secret for a Webhook. + ) -> webhooks.WebhookPingResponse: + r"""Sends a ping event to a Webhook. - :param id: Required. The ID of the webhook for which to generate a signing secret. - Format: `{webhook_id}` - :param api_version: Which version of the API to use. - :param revocation_behavior: Optional. The revocation behavior for previous signing secrets. + :param id: Required. The ID of the webhook to ping. + :param body: Required. The HTTP body of the payload. :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. @@ -904,12 +962,9 @@ def rotate_signing_secret( else: base_url = self._get_url(base_url, url_variables) - request = models.RotateSigningSecretRequest( - api_version=api_version, + request = models.PingWebhookRequest( id=id, - body=webhooks.RotateSigningSecretRequest( - revocation_behavior=revocation_behavior, - ), + body=utils.get_pydantic_model(body, Optional[webhooks.PingWebhookRequest]), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -917,7 +972,7 @@ def rotate_signing_secret( ) req = self._build_request( method="POST", - path="/{api_version}/webhooks/{id}:rotateSigningSecret", + path="/{api_version}/webhooks/{id}:ping", base_url=base_url, url_variables=url_variables, request=request, @@ -928,7 +983,7 @@ def rotate_signing_secret( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.RotateSigningSecretGlobals( + _globals=models.PingWebhookGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -937,7 +992,7 @@ def rotate_signing_secret( False, True, "json", - Optional[webhooks.RotateSigningSecretRequest], + Optional[webhooks.PingWebhookRequest], extra_body=extra_body, ), allow_empty_value=None, @@ -960,21 +1015,34 @@ def rotate_signing_secret( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.PingWebhookClientErrorData, http_res + ) + raise errors.PingWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.PingWebhookServerErrorData, http_res + ) + raise errors.PingWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.WebhookRotateSigningSecretResponse, - http_res, - validate=False, + webhooks.WebhookPingResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -982,7 +1050,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="RotateSigningSecret", + operation_id="PingWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1036,28 +1104,22 @@ def _speakeasy_parse_response(http_res): parse_exc_, ) - def ping( + def rotate_signing_secret( self, id: str, *, - api_version: Optional[str] = None, - body: Optional[ - Union[ - webhooks_pingwebhookrequest.PingWebhookRequest, - webhooks_pingwebhookrequest.PingWebhookRequestParam, - ] + revocation_behavior: Optional[ + webhooks_rotatesigningsecretrequest.RevocationBehavior ] = 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, - ) -> webhooks.WebhookPingResponse: - r"""Sends a ping event to a Webhook. + ) -> webhooks.WebhookRotateSigningSecretResponse: + r"""Generates a new signing secret for a Webhook. - :param id: Required. The ID of the webhook to ping. - Format: `{webhook_id}` - :param api_version: Which version of the API to use. - :param body: The request body. + :param id: Required. The ID of the webhook for which to rotate the signing secret. + :param revocation_behavior: Optional. The revocation behavior for previous signing secrets. :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. @@ -1077,10 +1139,11 @@ def ping( else: base_url = self._get_url(base_url, url_variables) - request = models.PingWebhookRequest( - api_version=api_version, + request = models.RotateSigningSecretRequest( id=id, - body=utils.get_pydantic_model(body, Optional[webhooks.PingWebhookRequest]), + body=webhooks.RotateSigningSecretRequest( + revocation_behavior=revocation_behavior, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -1088,7 +1151,7 @@ def ping( ) req = self._build_request( method="POST", - path="/{api_version}/webhooks/{id}:ping", + path="/{api_version}/webhooks/{id}:rotateSigningSecret", base_url=base_url, url_variables=url_variables, request=request, @@ -1099,7 +1162,7 @@ def ping( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.PingWebhookGlobals( + _globals=models.RotateSigningSecretGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -1108,7 +1171,7 @@ def ping( False, True, "json", - Optional[webhooks.PingWebhookRequest], + Optional[webhooks.RotateSigningSecretRequest], extra_body=extra_body, ), allow_empty_value=None, @@ -1131,19 +1194,36 @@ def ping( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RotateSigningSecretClientErrorData, http_res + ) + raise errors.RotateSigningSecretClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RotateSigningSecretServerErrorData, http_res + ) + raise errors.RotateSigningSecretServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.WebhookPingResponse, http_res, validate=False + webhooks.WebhookRotateSigningSecretResponse, + http_res, + validate=False, ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1151,7 +1231,7 @@ def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="PingWebhook", + operation_id="RotateSigningSecret", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1209,47 +1289,47 @@ def _speakeasy_parse_response(http_res): class WebhooksWithRawResponse: def __init__(self, sdk: Webhooks) -> None: self._sdk = sdk + self.list = response_helpers.to_raw_response_wrapper(sdk.list, "extra_headers") self.create = response_helpers.to_raw_response_wrapper( sdk.create, "extra_headers" ) - self.list = response_helpers.to_raw_response_wrapper(sdk.list, "extra_headers") self.get = response_helpers.to_raw_response_wrapper(sdk.get, "extra_headers") - self.update = response_helpers.to_raw_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.to_raw_response_wrapper( sdk.delete, "extra_headers" ) + self.update = response_helpers.to_raw_response_wrapper( + sdk.update, "extra_headers" + ) + self.ping = response_helpers.to_raw_response_wrapper(sdk.ping, "extra_headers") self.rotate_signing_secret = response_helpers.to_raw_response_wrapper( sdk.rotate_signing_secret, "extra_headers" ) - self.ping = response_helpers.to_raw_response_wrapper(sdk.ping, "extra_headers") class WebhooksWithStreamingResponse: def __init__(self, sdk: Webhooks) -> None: self._sdk = sdk - self.create = response_helpers.to_streamed_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.to_streamed_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.to_streamed_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.to_streamed_response_wrapper( sdk.get, "extra_headers" ) - self.update = response_helpers.to_streamed_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.to_streamed_response_wrapper( sdk.delete, "extra_headers" ) - self.rotate_signing_secret = response_helpers.to_streamed_response_wrapper( - sdk.rotate_signing_secret, "extra_headers" + self.update = response_helpers.to_streamed_response_wrapper( + sdk.update, "extra_headers" ) self.ping = response_helpers.to_streamed_response_wrapper( sdk.ping, "extra_headers" ) + self.rotate_signing_secret = response_helpers.to_streamed_response_wrapper( + sdk.rotate_signing_secret, "extra_headers" + ) class AsyncWebhooks(AsyncBaseSDK): @@ -1261,35 +1341,24 @@ def with_raw_response(self): def with_streaming_response(self): return AsyncWebhooksWithStreamingResponse(self) - async def create( + async def list( self, *, - subscribed_events: Iterable[webhooks_webhook.WebhookSubscribedEvent], - uri: str, - api_version: Optional[str] = None, - name: 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, - extra_body: Optional[Mapping[str, Any]] = None, timeout: Optional[Union[float, httpx.Timeout]] = None, - ) -> webhooks.Webhook: - r"""Creates a new Webhook. + ) -> webhooks.WebhookListResponse: + r"""Lists all Webhooks. - :param subscribed_events: Required. The events that the webhook is subscribed to. - Available events: - - batch.succeeded - - batch.expired - - batch.failed - - interaction.requires_action - - interaction.completed - - interaction.failed - - video.generated - :param uri: Required. The URI to which webhook events will be sent. - :param api_version: Which version of the API to use. - :param name: Optional. The user-provided name of the webhook. + :param page_size: The maximum number of webhooks to return. The service may return fewer than + this value. If unspecified, at most 50 webhooks will be returned. + The maximum value is 1000. + :param page_token: A page token, received from a previous `ListWebhooks` call. + Provide this to retrieve the subsequent page. :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 @@ -1306,45 +1375,31 @@ async def create( else: base_url = self._get_url(base_url, url_variables) - request = models.CreateWebhookRequest( - api_version=api_version, - body=webhooks.WebhookInput( - name=name, - subscribed_events=utils.unmarshal( - subscribed_events, List[webhooks.WebhookSubscribedEvent] - ), - uri=uri, - ), + request = models.ListWebhooksRequest( + 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="POST", + method="GET", path="/{api_version}/webhooks", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=True, + 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.CreateWebhookGlobals( + _globals=models.ListWebhooksGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request.body, - False, - False, - "json", - webhooks.WebhookInput, - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1365,19 +1420,34 @@ async def create( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListWebhooksClientErrorData, http_res + ) + raise errors.ListWebhooksClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.ListWebhooksServerErrorData, http_res + ) + raise errors.ListWebhooksServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.Webhook, http_res, validate=False + webhooks.WebhookListResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1385,7 +1455,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="CreateWebhook", + operation_id="ListWebhooks", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1442,26 +1512,33 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def list( + async def create( self, *, - api_version: Optional[str] = None, - page_size: Optional[int] = None, - page_token: Optional[str] = None, + subscribed_events: Iterable[webhooks_webhook.WebhookSubscribedEvent], + uri: str, + name: Optional[str] = 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, - ) -> webhooks.WebhookListResponse: - r"""Lists all Webhooks. + ) -> webhooks.Webhook: + r"""Creates a new Webhook. - :param api_version: Which version of the API to use. - :param page_size: Optional. The maximum number of webhooks to return. The service may return fewer than - this value. If unspecified, at most 50 webhooks will be returned. - The maximum value is 1000. - :param page_token: Optional. A page token, received from a previous `ListWebhooks` call. - Provide this to retrieve the subsequent page. + :param subscribed_events: Required. The events that the webhook is subscribed to. + Available events: + - batch.succeeded + - batch.expired + - batch.failed + - interaction.requires_action + - interaction.completed + - interaction.failed + - video.generated + :param uri: Required. The URI to which webhook events will be sent. + :param name: Optional. The user-provided name of the webhook. :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 @@ -1478,32 +1555,42 @@ async def list( else: base_url = self._get_url(base_url, url_variables) - request = models.ListWebhooksRequest( - api_version=api_version, - page_size=page_size, - page_token=page_token, + request = webhooks.WebhookInput( + name=name, + subscribed_events=utils.unmarshal( + subscribed_events, List[webhooks.WebhookSubscribedEvent] + ), + uri=uri, ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="GET", + method="POST", path="/{api_version}/webhooks", base_url=base_url, url_variables=url_variables, request=request, - request_body_required=False, + request_body_required=True, 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.ListWebhooksGlobals( + _globals=models.CreateWebhookGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request, + False, + False, + "json", + webhooks.WebhookInput, + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1524,19 +1611,34 @@ async def list( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateWebhookClientErrorData, http_res + ) + raise errors.CreateWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.CreateWebhookServerErrorData, http_res + ) + raise errors.CreateWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.WebhookListResponse, http_res, validate=False + webhooks.Webhook, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1544,7 +1646,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="ListWebhooks", + operation_id="CreateWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1605,7 +1707,6 @@ async def get( 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, @@ -1613,7 +1714,6 @@ async def get( r"""Gets a specific Webhook. :param id: Required. The ID of the webhook to retrieve. - :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 @@ -1633,7 +1733,6 @@ async def get( base_url = self._get_url(base_url, url_variables) request = models.GetWebhookRequest( - api_version=api_version, id=id, ) @@ -1677,16 +1776,31 @@ async def get( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetWebhookClientErrorData, http_res + ) + raise errors.GetWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.GetWebhookServerErrorData, http_res + ) + raise errors.GetWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( webhooks.Webhook, http_res, validate=False @@ -1754,43 +1868,20 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def update( + async def delete( self, id: str, *, - api_version: Optional[str] = None, - update_mask: Optional[str] = None, - name: Optional[str] = None, - state: Optional[webhooks_webhookupdate.WebhookUpdateState] = None, - subscribed_events: Optional[ - Iterable[webhooks_webhookupdate.WebhookUpdateSubscribedEvent] - ] = None, - uri: Optional[str] = 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, - ) -> webhooks.Webhook: - r"""Updates an existing Webhook. + ) -> interactions.Empty: + r"""Deletes a Webhook. - :param id: Required. The ID of the webhook to update. - :param api_version: Which version of the API to use. - :param update_mask: Optional. The list of fields to update. - :param name: Optional. The user-provided name of the webhook. - :param state: Optional. The state of the webhook. - :param subscribed_events: Optional. The events that the webhook is subscribed to. - Available events: - - batch.succeeded - - batch.expired - - batch.failed - - interaction.requires_action - - interaction.completed - - interaction.failed - - video.generated - :param uri: Optional. The URI to which webhook events will be sent. + :param id: Required. The ID of the webhook to delete. + Format: `{webhook_id}` :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 @@ -1807,26 +1898,15 @@ async def update( else: base_url = self._get_url(base_url, url_variables) - request = models.UpdateWebhookRequest( - api_version=api_version, + request = models.DeleteWebhookRequest( id=id, - update_mask=update_mask, - body=webhooks.WebhookUpdate( - name=name, - state=state, - subscribed_events=utils.unmarshal( - subscribed_events, - Optional[List[webhooks.WebhookUpdateSubscribedEvent]], - ), - uri=uri, - ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="PATCH", + method="DELETE", path="/{api_version}/webhooks/{id}", base_url=base_url, url_variables=url_variables, @@ -1838,18 +1918,10 @@ async def update( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.UpdateWebhookGlobals( + _globals=models.DeleteWebhookGlobals( 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[webhooks.WebhookUpdate], - extra_body=extra_body, - ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -1870,19 +1942,34 @@ async def update( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteWebhookClientErrorData, http_res + ) + raise errors.DeleteWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.DeleteWebhookServerErrorData, http_res + ) + raise errors.DeleteWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.Webhook, http_res, validate=False + interactions.Empty, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -1890,7 +1977,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="UpdateWebhook", + operation_id="DeleteWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -1947,22 +2034,41 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def delete( + async def update( self, id: str, *, - api_version: Optional[str] = None, + update_mask: Optional[str] = None, + name: Optional[str] = None, + state: Optional[webhooks_webhookupdate.WebhookUpdateState] = None, + subscribed_events: Optional[ + Iterable[webhooks_webhookupdate.WebhookUpdateSubscribedEvent] + ] = None, + uri: Optional[str] = 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, - ) -> interactions.Empty: - r"""Deletes a Webhook. + ) -> webhooks.Webhook: + r"""Updates an existing Webhook. - :param id: Required. The ID of the webhook to delete. - Format: `{webhook_id}` - :param api_version: Which version of the API to use. + :param id: Required. The ID of the webhook to update. + :param update_mask: Optional list of fields to update. + :param name: Optional. The user-provided name of the webhook. + :param state: Optional. The state of the webhook. + :param subscribed_events: Optional. The events that the webhook is subscribed to. + Available events: + - batch.succeeded + - batch.expired + - batch.failed + - interaction.requires_action + - interaction.completed + - interaction.failed + - video.generated + :param uri: Optional. The URI to which webhook events will be sent. :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 @@ -1979,16 +2085,25 @@ async def delete( else: base_url = self._get_url(base_url, url_variables) - request = models.DeleteWebhookRequest( - api_version=api_version, + request = models.UpdateWebhookRequest( id=id, + update_mask=update_mask, + body=webhooks.WebhookUpdate( + name=name, + state=state, + subscribed_events=utils.unmarshal( + subscribed_events, + Optional[List[webhooks.WebhookUpdateSubscribedEvent]], + ), + uri=uri, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( http_headers ) req = self._build_request_async( - method="DELETE", + method="PATCH", path="/{api_version}/webhooks/{id}", base_url=base_url, url_variables=url_variables, @@ -2000,10 +2115,18 @@ async def delete( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.DeleteWebhookGlobals( + _globals=models.UpdateWebhookGlobals( 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[webhooks.WebhookUpdate], + extra_body=extra_body, + ), allow_empty_value=None, timeout_ms=timeout_ms, ) @@ -2024,19 +2147,34 @@ async def delete( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateWebhookClientErrorData, http_res + ) + raise errors.UpdateWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.UpdateWebhookServerErrorData, http_res + ) + raise errors.UpdateWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - interactions.Empty, http_res, validate=False + webhooks.Webhook, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -2044,7 +2182,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="DeleteWebhook", + operation_id="UpdateWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -2101,25 +2239,25 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def rotate_signing_secret( + async def ping( self, id: str, *, - api_version: Optional[str] = None, - revocation_behavior: Optional[ - webhooks_rotatesigningsecretrequest.RevocationBehavior + body: Optional[ + Union[ + webhooks_pingwebhookrequest.PingWebhookRequest, + webhooks_pingwebhookrequest.PingWebhookRequestParam, + ] ] = 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, - ) -> webhooks.WebhookRotateSigningSecretResponse: - r"""Generates a new signing secret for a Webhook. + ) -> webhooks.WebhookPingResponse: + r"""Sends a ping event to a Webhook. - :param id: Required. The ID of the webhook for which to generate a signing secret. - Format: `{webhook_id}` - :param api_version: Which version of the API to use. - :param revocation_behavior: Optional. The revocation behavior for previous signing secrets. + :param id: Required. The ID of the webhook to ping. + :param body: Required. The HTTP body of the payload. :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. @@ -2139,12 +2277,9 @@ async def rotate_signing_secret( else: base_url = self._get_url(base_url, url_variables) - request = models.RotateSigningSecretRequest( - api_version=api_version, + request = models.PingWebhookRequest( id=id, - body=webhooks.RotateSigningSecretRequest( - revocation_behavior=revocation_behavior, - ), + body=utils.get_pydantic_model(body, Optional[webhooks.PingWebhookRequest]), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -2152,7 +2287,7 @@ async def rotate_signing_secret( ) req = self._build_request_async( method="POST", - path="/{api_version}/webhooks/{id}:rotateSigningSecret", + path="/{api_version}/webhooks/{id}:ping", base_url=base_url, url_variables=url_variables, request=request, @@ -2163,7 +2298,7 @@ async def rotate_signing_secret( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.RotateSigningSecretGlobals( + _globals=models.PingWebhookGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -2172,7 +2307,7 @@ async def rotate_signing_secret( False, True, "json", - Optional[webhooks.RotateSigningSecretRequest], + Optional[webhooks.PingWebhookRequest], extra_body=extra_body, ), allow_empty_value=None, @@ -2195,21 +2330,34 @@ async def rotate_signing_secret( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.PingWebhookClientErrorData, http_res + ) + raise errors.PingWebhookClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.PingWebhookServerErrorData, http_res + ) + raise errors.PingWebhookServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.WebhookRotateSigningSecretResponse, - http_res, - validate=False, + webhooks.WebhookPingResponse, http_res, validate=False ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -2217,7 +2365,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="RotateSigningSecret", + operation_id="PingWebhook", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -2274,28 +2422,22 @@ async def _speakeasy_parse_response(http_res): parse_exc_, ) - async def ping( + async def rotate_signing_secret( self, id: str, *, - api_version: Optional[str] = None, - body: Optional[ - Union[ - webhooks_pingwebhookrequest.PingWebhookRequest, - webhooks_pingwebhookrequest.PingWebhookRequestParam, - ] + revocation_behavior: Optional[ + webhooks_rotatesigningsecretrequest.RevocationBehavior ] = 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, - ) -> webhooks.WebhookPingResponse: - r"""Sends a ping event to a Webhook. + ) -> webhooks.WebhookRotateSigningSecretResponse: + r"""Generates a new signing secret for a Webhook. - :param id: Required. The ID of the webhook to ping. - Format: `{webhook_id}` - :param api_version: Which version of the API to use. - :param body: The request body. + :param id: Required. The ID of the webhook for which to rotate the signing secret. + :param revocation_behavior: Optional. The revocation behavior for previous signing secrets. :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. @@ -2315,10 +2457,11 @@ async def ping( else: base_url = self._get_url(base_url, url_variables) - request = models.PingWebhookRequest( - api_version=api_version, + request = models.RotateSigningSecretRequest( id=id, - body=utils.get_pydantic_model(body, Optional[webhooks.PingWebhookRequest]), + body=webhooks.RotateSigningSecretRequest( + revocation_behavior=revocation_behavior, + ), ) _speakeasy_response_mode, http_headers = response_helpers.consume_response_mode( @@ -2326,7 +2469,7 @@ async def ping( ) req = self._build_request_async( method="POST", - path="/{api_version}/webhooks/{id}:ping", + path="/{api_version}/webhooks/{id}:rotateSigningSecret", base_url=base_url, url_variables=url_variables, request=request, @@ -2337,7 +2480,7 @@ async def ping( accept_header_value="application/json", http_headers=http_headers, extra_query_params=extra_query, - _globals=models.PingWebhookGlobals( + _globals=models.RotateSigningSecretGlobals( api_version=self.sdk_configuration.globals.api_version, ), security=self.sdk_configuration.security, @@ -2346,7 +2489,7 @@ async def ping( False, True, "json", - Optional[webhooks.PingWebhookRequest], + Optional[webhooks.RotateSigningSecretRequest], extra_body=extra_body, ), allow_empty_value=None, @@ -2369,19 +2512,36 @@ async def ping( 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 - ) + response_data: Any = None + if utils.match_response(http_res, "4XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RotateSigningSecretClientErrorData, http_res + ) + raise errors.RotateSigningSecretClientError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e + if utils.match_response(http_res, "5XX", "application/json"): + try: + response_data = unmarshal_json_response( + errors.RotateSigningSecretServerErrorData, http_res + ) + raise errors.RotateSigningSecretServerError(response_data, http_res) + except errors.ResponseValidationError as e: + raise errors.GenAiDefaultError( + "Error response body did not match expected schema", + http_res, + http_res.text, + ) from e if utils.match_response(http_res, "default", "application/json"): return unmarshal_json_response( - webhooks.WebhookPingResponse, http_res, validate=False + webhooks.WebhookRotateSigningSecretResponse, + http_res, + validate=False, ) raise errors.GenAiDefaultError("Unexpected response received", http_res) @@ -2389,7 +2549,7 @@ async def _speakeasy_parse_response(http_res): _speakeasy_hook_ctx = HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="PingWebhook", + operation_id="RotateSigningSecret", oauth2_scopes=None, security_source=get_security_from_env( self.sdk_configuration.security, types.Security @@ -2450,52 +2610,52 @@ async def _speakeasy_parse_response(http_res): class AsyncWebhooksWithRawResponse: def __init__(self, sdk: AsyncWebhooks) -> None: self._sdk = sdk - self.create = response_helpers.async_to_raw_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.async_to_raw_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.async_to_raw_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.async_to_raw_response_wrapper( sdk.get, "extra_headers" ) - self.update = response_helpers.async_to_raw_response_wrapper( - sdk.update, "extra_headers" - ) self.delete = response_helpers.async_to_raw_response_wrapper( sdk.delete, "extra_headers" ) - self.rotate_signing_secret = response_helpers.async_to_raw_response_wrapper( - sdk.rotate_signing_secret, "extra_headers" + self.update = response_helpers.async_to_raw_response_wrapper( + sdk.update, "extra_headers" ) self.ping = response_helpers.async_to_raw_response_wrapper( sdk.ping, "extra_headers" ) + self.rotate_signing_secret = response_helpers.async_to_raw_response_wrapper( + sdk.rotate_signing_secret, "extra_headers" + ) class AsyncWebhooksWithStreamingResponse: def __init__(self, sdk: AsyncWebhooks) -> None: self._sdk = sdk - self.create = response_helpers.async_to_streamed_response_wrapper( - sdk.create, "extra_headers" - ) self.list = response_helpers.async_to_streamed_response_wrapper( sdk.list, "extra_headers" ) + self.create = response_helpers.async_to_streamed_response_wrapper( + sdk.create, "extra_headers" + ) self.get = response_helpers.async_to_streamed_response_wrapper( sdk.get, "extra_headers" ) + self.delete = response_helpers.async_to_streamed_response_wrapper( + sdk.delete, "extra_headers" + ) self.update = response_helpers.async_to_streamed_response_wrapper( sdk.update, "extra_headers" ) - self.delete = response_helpers.async_to_streamed_response_wrapper( - sdk.delete, "extra_headers" + self.ping = response_helpers.async_to_streamed_response_wrapper( + sdk.ping, "extra_headers" ) self.rotate_signing_secret = ( response_helpers.async_to_streamed_response_wrapper( sdk.rotate_signing_secret, "extra_headers" ) ) - self.ping = response_helpers.async_to_streamed_response_wrapper( - sdk.ping, "extra_headers" - )