diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d2d60a3..fea3454 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.24.0" + ".": "1.0.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index b3475dd..a88a788 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 54 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nimbleway/nimbleway-bf1b1bed98ef9bce4fe48bad669f2548d0c20816d351821365bdb3ca86ccd723.yml -openapi_spec_hash: 30d0670c85632cc2100bc2cafb6aec0e -config_hash: 1f331615274d4cb8fcdb997da6f9d23e +configured_endpoints: 58 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nimbleway/nimbleway-46d484b69bce8b655b4cb2741903af321088ee25d778dd1f9974925b75ae0c76.yml +openapi_spec_hash: e4c1f68f0083d3b13501f3c85d29b4f4 +config_hash: 2a7bb5e7a725315963e311126f1f7e4c diff --git a/CHANGELOG.md b/CHANGELOG.md index ebe4459..5ed7ae9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.0.0 (2026-07-20) + +Full Changelog: [v0.24.0...v1.0.0](https://github.com/Nimbleway/nimble-python/compare/v0.24.0...v1.0.0) + +### Features + +* **api:** api update ([1f846bf](https://github.com/Nimbleway/nimble-python/commit/1f846bff007afa2bd17e3dbe720e858dde41a062)) +* **api:** Api v2 ([54c125b](https://github.com/Nimbleway/nimble-python/commit/54c125b46e2eaa6e64aa5267f3e3fef7853b3085)) + ## 0.24.0 (2026-07-19) Full Changelog: [v0.23.0...v0.24.0](https://github.com/Nimbleway/nimble-python/compare/v0.23.0...v0.24.0) diff --git a/README.md b/README.md index e62e67e..cfaefaa 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ client = Nimble( api_key=os.environ.get("NIMBLE_API_KEY"), # This is the default and can be omitted ) -response = client.extract( +response = client.extract.run( url="https://exapmle.com", ) print(response.task_id) @@ -67,7 +67,7 @@ client = AsyncNimble( async def main() -> None: - response = await client.extract( + response = await client.extract.run( url="https://exapmle.com", ) print(response.task_id) @@ -103,7 +103,7 @@ async def main() -> None: api_key=os.environ.get("NIMBLE_API_KEY"), # This is the default and can be omitted http_client=DefaultAioHttpClient(), ) as client: - response = await client.extract( + response = await client.extract.run( url="https://exapmle.com", ) print(response.task_id) @@ -130,7 +130,7 @@ from nimble_python import Nimble client = Nimble() -response = client.extract( +response = client.extract.run( url="url", session={}, ) @@ -153,7 +153,7 @@ from nimble_python import Nimble client = Nimble() try: - client.extract( + client.extract.run( url="https://exapmle.com", ) except nimble_python.APIConnectionError as e: @@ -198,7 +198,7 @@ client = Nimble( ) # Or, configure per-request: -client.with_options(max_retries=5).extract( +client.with_options(max_retries=5).extract.run( url="https://exapmle.com", ) ``` @@ -223,7 +223,7 @@ client = Nimble( ) # Override per-request: -client.with_options(timeout=5.0).extract( +client.with_options(timeout=5.0).extract.run( url="https://exapmle.com", ) ``` @@ -266,13 +266,13 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to from nimble_python import Nimble client = Nimble() -response = client.with_raw_response.extract( +response = client.extract.with_raw_response.run( url="https://exapmle.com", ) print(response.headers.get('X-My-Header')) -client = response.parse() # get the object that `extract()` would have returned -print(client.task_id) +extract = response.parse() # get the object that `extract.run()` would have returned +print(extract.task_id) ``` These methods return an [`APIResponse`](https://github.com/Nimbleway/nimble-python/tree/main/src/nimble_python/_response.py) object. @@ -286,7 +286,7 @@ The above interface eagerly reads the full response body when you make the reque To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods. ```python -with client.with_streaming_response.extract( +with client.extract.with_streaming_response.run( url="https://exapmle.com", ) as response: print(response.headers.get("X-My-Header")) diff --git a/api.md b/api.md index 35a96ac..d8cfcc6 100644 --- a/api.md +++ b/api.md @@ -23,198 +23,232 @@ from nimble_python.types import ( Types: ```python -from nimble_python.types import ( - ExtractResponse, - ExtractAsyncResponse, - ExtractBatchResponse, - MapResponse, - SearchResponse, -) +from nimble_python.types import MapResponse, SearchResponse ``` Methods: -- client.extract(\*\*params) -> ExtractResponse -- client.extract_async(\*\*params) -> ExtractAsyncResponse -- client.extract_batch(\*\*params) -> ExtractBatchResponse -- client.map(\*\*params) -> MapResponse -- client.search(\*\*params) -> SearchResponse +- client.map(\*\*params) -> MapResponse +- client.search(\*\*params) -> SearchResponse -# Agent +# Extract Types: ```python -from nimble_python.types import ( - AgentListResponse, - AgentGenerateResponse, - AgentGetResponse, - AgentGetGenerationResponse, - AgentRunResponse, - AgentRunAsyncResponse, - AgentRunBatchResponse, +from nimble_python.types import ExtractAsyncResponse, ExtractBatchResponse, ExtractRunResponse +``` + +Methods: + +- client.extract.async\_(\*\*params) -> ExtractAsyncResponse +- client.extract.batch(\*\*params) -> ExtractBatchResponse +- client.extract.run(\*\*params) -> ExtractRunResponse + +## Templates + +Types: + +```python +from nimble_python.types.extract import ( + TemplateUpdateResponse, + TemplateListResponse, + TemplateAsyncResponse, + TemplateBatchResponse, + TemplateGetResponse, + TemplateRunResponse, ) ``` Methods: -- client.agent.list(\*\*params) -> AgentListResponse -- client.agent.generate(\*\*params) -> AgentGenerateResponse -- client.agent.get(template_name) -> AgentGetResponse -- client.agent.get_generation(generation_id) -> AgentGetGenerationResponse -- client.agent.run(\*\*params) -> AgentRunResponse -- client.agent.run_async(\*\*params) -> AgentRunAsyncResponse -- client.agent.run_batch(\*\*params) -> AgentRunBatchResponse +- client.extract.templates.update(extract_template_name, \*\*params) -> TemplateUpdateResponse +- client.extract.templates.list(\*\*params) -> TemplateListResponse +- client.extract.templates.delete(extract_template_name) -> None +- client.extract.templates.async\_(\*\*params) -> TemplateAsyncResponse +- client.extract.templates.batch(\*\*params) -> TemplateBatchResponse +- client.extract.templates.get(extract_template_name) -> TemplateGetResponse +- client.extract.templates.run(\*\*params) -> TemplateRunResponse -# Crawl +### Generations + +Types: + +```python +from nimble_python.types.extract.templates import GenerationCreateResponse, GenerationGetResponse +``` + +Methods: + +- client.extract.templates.generations.create(\*\*params) -> GenerationCreateResponse +- client.extract.templates.generations.get(generation_id) -> GenerationGetResponse + +### Versions + +Types: + +```python +from nimble_python.types.extract.templates import VersionListResponse, VersionGetResponse +``` + +Methods: + +- client.extract.templates.versions.list(extract_template_name, \*\*params) -> VersionListResponse +- client.extract.templates.versions.get(version_id, \*, extract_template_name) -> VersionGetResponse + +# Agents Types: ```python from nimble_python.types import ( - CrawlListResponse, - CrawlRunResponse, - CrawlStatusResponse, - CrawlTerminateResponse, + AgentCreateResponse, + AgentUpdateResponse, + AgentListResponse, + AgentGetResponse, ) ``` Methods: -- client.crawl.list(\*\*params) -> CrawlListResponse -- client.crawl.run(\*\*params) -> CrawlRunResponse -- client.crawl.status(id) -> CrawlStatusResponse -- client.crawl.terminate(id) -> CrawlTerminateResponse +- client.agents.create(\*\*params) -> AgentCreateResponse +- client.agents.update(agent_id, \*\*params) -> AgentUpdateResponse +- client.agents.list(\*\*params) -> AgentListResponse +- client.agents.delete(agent_id) -> None +- client.agents.get(agent_id) -> AgentGetResponse -# Tasks +## Templates Types: ```python -from nimble_python.types import TaskListResponse, TaskGetResponse, TaskResultsResponse +from nimble_python.types.agents import TemplateListResponse, TemplateGetResponse ``` Methods: -- client.tasks.list(\*\*params) -> TaskListResponse -- client.tasks.get(task_id) -> TaskGetResponse -- client.tasks.results(task_id) -> TaskResultsResponse +- client.agents.templates.list(\*\*params) -> TemplateListResponse +- client.agents.templates.get(template_name) -> TemplateGetResponse -# Batches +## Runs Types: ```python -from nimble_python.types import BatchGetResponse, BatchProgressResponse +from nimble_python.types.agents import ( + RunCreateResponse, + RunListResponse, + RunGetResponse, + RunResultResponse, +) ``` Methods: -- client.batches.list() -> None -- client.batches.get(batch_id) -> BatchGetResponse -- client.batches.progress(batch_id) -> BatchProgressResponse +- client.agents.runs.create(agent_id, \*\*params) -> RunCreateResponse +- client.agents.runs.list(agent_id, \*\*params) -> RunListResponse +- client.agents.runs.get(run_id, \*, agent_id) -> RunGetResponse +- client.agents.runs.result(run_id, \*, agent_id) -> RunResultResponse +- client.agents.runs.stream_events(run_id, \*, agent_id) -> None -# DomainKnowledge +# Crawl Types: ```python -from nimble_python.types import DomainKnowledgeGetDriverResponse +from nimble_python.types import ( + CrawlListResponse, + CrawlRunResponse, + CrawlStatusResponse, + CrawlTerminateResponse, +) ``` Methods: -- client.domain_knowledge.get_driver(\*\*params) -> DomainKnowledgeGetDriverResponse +- client.crawl.list(\*\*params) -> CrawlListResponse +- client.crawl.run(\*\*params) -> CrawlRunResponse +- client.crawl.status(id) -> CrawlStatusResponse +- client.crawl.terminate(id) -> CrawlTerminateResponse -# Media +# Tasks Types: ```python -from nimble_python.types import MediaRunResponse, MediaRunAsyncResponse +from nimble_python.types import TaskListResponse, TaskGetResponse, TaskResultsResponse ``` Methods: -- client.media.run(\*\*params) -> MediaRunResponse -- client.media.run_async(\*\*params) -> MediaRunAsyncResponse +- client.tasks.list(\*\*params) -> TaskListResponse +- client.tasks.get(task_id) -> TaskGetResponse +- client.tasks.results(task_id) -> TaskResultsResponse -# Serp +# Batches Types: ```python -from nimble_python.types import SerpRunResponse, SerpRunAsyncResponse, SerpRunBatchResponse +from nimble_python.types import BatchGetResponse, BatchProgressResponse ``` Methods: -- client.serp.run(\*\*params) -> SerpRunResponse -- client.serp.run_async(\*\*params) -> SerpRunAsyncResponse -- client.serp.run_batch(\*\*params) -> SerpRunBatchResponse +- client.batches.list() -> None +- client.batches.get(batch_id) -> BatchGetResponse +- client.batches.progress(batch_id) -> BatchProgressResponse -# FastSerp +# DomainKnowledge Types: ```python -from nimble_python.types import FastSerpRunResponse +from nimble_python.types import DomainKnowledgeGetDriverResponse ``` Methods: -- client.fast_serp.run(\*\*params) -> FastSerpRunResponse +- client.domain_knowledge.get_driver(\*\*params) -> DomainKnowledgeGetDriverResponse -# TaskAgent +# Media Types: ```python -from nimble_python.types import ( - TaskAgentCreateResponse, - TaskAgentUpdateResponse, - TaskAgentListResponse, - TaskAgentGetResponse, - TaskAgentRunResponse, -) +from nimble_python.types import MediaRunResponse, MediaRunAsyncResponse ``` Methods: -- client.task_agent.create(\*\*params) -> TaskAgentCreateResponse -- client.task_agent.update(agent_id, \*\*params) -> TaskAgentUpdateResponse -- client.task_agent.list(\*\*params) -> TaskAgentListResponse -- client.task_agent.deactivate(agent_id) -> None -- client.task_agent.get(agent_id) -> TaskAgentGetResponse -- client.task_agent.run(agent_id, \*\*params) -> TaskAgentRunResponse +- client.media.run(\*\*params) -> MediaRunResponse +- client.media.run_async(\*\*params) -> MediaRunAsyncResponse -## Templates +# Serp Types: ```python -from nimble_python.types.task_agent import TemplateListResponse, TemplateGetResponse +from nimble_python.types import SerpRunResponse, SerpRunAsyncResponse, SerpRunBatchResponse ``` Methods: -- client.task_agent.templates.list(\*\*params) -> TemplateListResponse -- client.task_agent.templates.get(template_name) -> TemplateGetResponse +- client.serp.run(\*\*params) -> SerpRunResponse +- client.serp.run_async(\*\*params) -> SerpRunAsyncResponse +- client.serp.run_batch(\*\*params) -> SerpRunBatchResponse -## Runs +# FastSerp Types: ```python -from nimble_python.types.task_agent import RunListResponse, RunGetResponse, RunGetResultResponse +from nimble_python.types import FastSerpRunResponse ``` Methods: -- client.task_agent.runs.list(agent_id, \*\*params) -> RunListResponse -- client.task_agent.runs.get(run_id, \*, agent_id) -> RunGetResponse -- client.task_agent.runs.get_result(run_id, \*, agent_id) -> RunGetResultResponse -- client.task_agent.runs.stream_events(run_id, \*, agent_id) -> None +- client.fast_serp.run(\*\*params) -> FastSerpRunResponse # Jobs @@ -226,32 +260,36 @@ from nimble_python.types import ( JobUpdateResponse, JobListResponse, JobGetResponse, - JobRunResponse, ) ``` Methods: -- client.jobs.create(\*\*params) -> JobCreateResponse -- client.jobs.update(job_id, \*\*params) -> JobUpdateResponse -- client.jobs.list(\*\*params) -> JobListResponse -- client.jobs.delete(job_id) -> None -- client.jobs.get(job_id) -> JobGetResponse -- client.jobs.run(job_id) -> JobRunResponse +- client.jobs.create(\*\*params) -> JobCreateResponse +- client.jobs.update(job_id, \*\*params) -> JobUpdateResponse +- client.jobs.list(\*\*params) -> JobListResponse +- client.jobs.delete(job_id) -> None +- client.jobs.get(job_id) -> JobGetResponse ## Runs Types: ```python -from nimble_python.types.jobs import RunListResponse, RunCancelResponse, RunGetResponse +from nimble_python.types.jobs import ( + RunCreateResponse, + RunListResponse, + RunCancelResponse, + RunGetResponse, +) ``` Methods: -- client.jobs.runs.list(job_id, \*\*params) -> RunListResponse -- client.jobs.runs.cancel(run_id) -> RunCancelResponse -- client.jobs.runs.get(run_id) -> RunGetResponse +- client.jobs.runs.create(job_id) -> RunCreateResponse +- client.jobs.runs.list(job_id, \*\*params) -> RunListResponse +- client.jobs.runs.cancel(run_id) -> RunCancelResponse +- client.jobs.runs.get(run_id) -> RunGetResponse ### Artifacts @@ -268,7 +306,7 @@ from nimble_python.types.jobs.runs import ( Methods: -- client.jobs.runs.artifacts.list(run_id) -> ArtifactListResponse -- client.jobs.runs.artifacts.download_url(artifact_id, \*, run_id) -> ArtifactDownloadURLResponse -- client.jobs.runs.artifacts.get(artifact_id, \*, run_id) -> ArtifactGetResponse -- client.jobs.runs.artifacts.preview(artifact_id, \*, run_id) -> ArtifactPreviewResponse +- client.jobs.runs.artifacts.list(run_id) -> ArtifactListResponse +- client.jobs.runs.artifacts.download_url(artifact_id, \*, run_id) -> ArtifactDownloadURLResponse +- client.jobs.runs.artifacts.get(artifact_id, \*, run_id) -> ArtifactGetResponse +- client.jobs.runs.artifacts.preview(artifact_id, \*, run_id) -> ArtifactPreviewResponse diff --git a/pyproject.toml b/pyproject.toml index b91358a..683fd33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nimble_python" -version = "0.24.0" +version = "1.0.0" description = "The official Python library for the nimble API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/nimble_python/_client.py b/src/nimble_python/_client.py index 354dbd0..99b5711 100644 --- a/src/nimble_python/_client.py +++ b/src/nimble_python/_client.py @@ -3,20 +3,14 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, Any, Dict, List, Union, Mapping, Iterable, Optional +from typing import TYPE_CHECKING, Any, Union, Mapping, Optional from typing_extensions import Self, Literal, override import httpx from . import _exceptions from ._qs import Querystring -from .types import ( - client_map_params, - client_search_params, - client_extract_params, - client_extract_async_params, - client_extract_batch_params, -) +from .types import client_map_params, client_search_params from ._types import ( Body, Omit, @@ -56,22 +50,19 @@ ) from .types.map_response import MapResponse from .types.search_response import SearchResponse -from .types.extract_response import ExtractResponse -from .types.extract_async_response import ExtractAsyncResponse -from .types.extract_batch_response import ExtractBatchResponse if TYPE_CHECKING: - from .resources import jobs, serp, agent, crawl, media, tasks, batches, fast_serp, task_agent, domain_knowledge + from .resources import jobs, serp, crawl, media, tasks, agents, batches, extract, fast_serp, domain_knowledge from .resources.serp import SerpResource, AsyncSerpResource - from .resources.agent import AgentResource, AsyncAgentResource from .resources.crawl import CrawlResource, AsyncCrawlResource from .resources.media import MediaResource, AsyncMediaResource from .resources.tasks import TasksResource, AsyncTasksResource from .resources.batches import BatchesResource, AsyncBatchesResource from .resources.fast_serp import FastSerpResource, AsyncFastSerpResource from .resources.jobs.jobs import JobsResource, AsyncJobsResource + from .resources.agents.agents import AgentsResource, AsyncAgentsResource + from .resources.extract.extract import ExtractResource, AsyncExtractResource from .resources.domain_knowledge import DomainKnowledgeResource, AsyncDomainKnowledgeResource - from .resources.task_agent.task_agent import TaskAgentResource, AsyncTaskAgentResource __all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Nimble", "AsyncNimble", "Client", "AsyncClient"] @@ -145,10 +136,16 @@ def __init__( ) @cached_property - def agent(self) -> AgentResource: - from .resources.agent import AgentResource + def extract(self) -> ExtractResource: + from .resources.extract import ExtractResource + + return ExtractResource(self) + + @cached_property + def agents(self) -> AgentsResource: + from .resources.agents import AgentsResource - return AgentResource(self) + return AgentsResource(self) @cached_property def crawl(self) -> CrawlResource: @@ -192,12 +189,6 @@ def fast_serp(self) -> FastSerpResource: return FastSerpResource(self) - @cached_property - def task_agent(self) -> TaskAgentResource: - from .resources.task_agent import TaskAgentResource - - return TaskAgentResource(self) - @cached_property def jobs(self) -> JobsResource: from .resources.jobs import JobsResource @@ -297,17 +288,10 @@ def copy( # client.with_options(timeout=10).foo.create(...) with_options = copy - def extract( + def map( self, *, url: str, - auto_driver_configuration: Dict[str, int] | Omit = omit, - body: object | Omit = omit, - browser: client_extract_params.Browser | Omit = omit, - browser_actions: Iterable[client_extract_params.BrowserAction] | Omit = omit, - city: str | Omit = omit, - consent_header: bool | Omit = omit, - cookies: Union[Iterable[client_extract_params.CookiesUnionMember0], str] | Omit = omit, country: Literal[ "AD", "AE", @@ -559,19 +543,10 @@ def extract( "ZA", "ZM", "ZW", - "ALL", ] | Omit = omit, - device: Literal["desktop", "mobile", "tablet"] | Omit = omit, - driver: Literal[ - "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" - ] - | Omit = omit, - expected_status_codes: Iterable[int] | Omit = omit, - formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, - headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, - http2: bool | Omit = omit, - is_xhr: bool | Omit = omit, + domain_filter: Literal["domain", "subdomain", "all"] | Omit = omit, + limit: int | Omit = omit, locale: Literal[ "aa-DJ", "aa-ER", @@ -1108,153 +1083,128 @@ def extract( "auto", ] | Omit = omit, - markdown_backend: Literal["full_page", "main_content"] | Omit = omit, - method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, - network_capture: Iterable[client_extract_params.NetworkCapture] | Omit = omit, - os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, - parse: bool | Omit = omit, - parser: Union[Dict[str, object], str] | Omit = omit, - referrer_type: Literal[ - "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" - ] - | Omit = omit, - render: Union[bool, Literal["auto"]] | Omit = omit, - request_timeout: float | Omit = omit, - session: client_extract_params.Session | Omit = omit, - skill: Union[str, SequenceNotStr[str]] | Omit = omit, - state: Literal[ - "AL", - "AK", - "AS", - "AZ", - "AR", - "CA", - "CO", - "CT", - "DE", - "DC", - "FL", - "GA", - "GU", - "HI", - "ID", - "IL", - "IN", - "IA", - "KS", - "KY", - "LA", - "ME", - "MD", - "MA", - "MI", - "MN", - "MS", - "MO", - "MT", - "NE", - "NV", - "NH", - "NJ", - "NM", - "NY", - "NC", - "ND", - "MP", - "OH", - "OK", - "OR", - "PA", - "PR", - "RI", - "SC", - "SD", - "TN", - "TX", - "UT", - "VT", - "VA", - "VI", - "WA", - "WV", - "WI", - "WY", - ] - | Omit = omit, - tag: str | Omit = omit, + sitemap: Literal["skip", "include", "only"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ExtractResponse: + ) -> MapResponse: """ - Extract + Create map task Args: - url: Target URL to scrape - - auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of - attempts to spend on each candidate before advancing (0 skips it). Key order - defines the flow order. Providing it opts the request into 'auto' driver - selection. + url: Url to map. - body: Request body for POST, PUT, PATCH methods + country: Country code for geolocation and proxy selection - browser: Browser type to emulate + domain_filter: Includes subdomains of the main domain in the mapping process. - browser_actions: Array of browser automation actions to execute sequentially + limit: Maximum number of links to return. - city: City for geolocation + locale: Locale for browser language and region settings - consent_header: Whether to automatically handle cookie consent headers + sitemap: Sitemap and other methods will be used together to find URLs. - cookies: Browser cookies as array of cookie objects + extra_headers: Send extra headers - country: Country code for geolocation and proxy selection + extra_query: Add additional query parameters to the request - device: Device type for browser emulation + extra_body: Add additional JSON properties to the request - driver: Browser driver to use + timeout: Override the client-level default timeout for this request, in seconds + """ + return self.post( + "/v2/map", + body=maybe_transform( + { + "url": url, + "country": country, + "domain_filter": domain_filter, + "limit": limit, + "locale": locale, + "sitemap": sitemap, + }, + client_map_params.ClientMapParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=MapResponse, + ) - expected_status_codes: Expected HTTP status codes for successful requests + def search( + self, + *, + query: str, + content_type: Optional[SequenceNotStr[str]] | Omit = omit, + country: str | Omit = omit, + deep_search: Optional[bool] | Omit = omit, + end_date: Optional[str] | Omit = omit, + exclude_domains: Optional[SequenceNotStr[str]] | Omit = omit, + focus: Union[str, SequenceNotStr[str]] | Omit = omit, + include_answer: bool | Omit = omit, + include_domains: Optional[SequenceNotStr[str]] | Omit = omit, + locale: str | Omit = omit, + max_results: int | Omit = omit, + max_subagents: int | Omit = omit, + output_format: Literal["plain_text", "markdown", "simplified_html"] | Omit = omit, + search_depth: Optional[Literal["lite", "fast", "deep"]] | Omit = omit, + start_date: Optional[str] | Omit = omit, + time_range: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SearchResponse: + """ + Search - formats: List of acceptable response formats in order of preference + Args: + query: Search query string - headers: Custom HTTP headers to include in the request + content_type: Filter by content type (only supported with focus=general). Supports semantic + groups ('documents', 'spreadsheets', 'presentations') and specific formats + ('pdf', 'docx', 'xlsx', etc.) - http2: Whether to use HTTP/2 protocol + country: Country code for geo-targeted results (e.g., 'US', 'GB', 'IL') - is_xhr: Whether to emulate XMLHttpRequest behavior + deep_search: Deprecated. Use search_depth instead. true maps to 'deep', false maps to 'lite'. - locale: Locale for browser language and region settings + end_date: Filter results before this date (format: YYYY-MM-DD or YYYY) - markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the - entire HTML page. "main_content" uses Mozilla Readability to extract the main - article content before converting. + exclude_domains: List of domains to exclude from search results. Maximum 50 domains. - method: HTTP method for the request + focus: Search focus mode (e.g., 'general', 'news', 'shopping') or a list of explicit + subagent names (e.g., ['amazon_serp', 'target_serp']) - network_capture: Filters for capturing network traffic + include_answer: Generate an LLM-powered answer summary based on search result snippets. - os: Operating system to emulate + include_domains: List of domains to include in search results. Maximum 50 domains. - parse: Whether to parse the response content + locale: Language/locale code (e.g., 'en', 'fr', 'de') - parser: Custom parser configuration as a key-value map + max_results: Maximum number of results to return. Actual count may be lower depending on + availability. - referrer_type: Referrer policy for the request + max_subagents: Maximum number of subagents to execute in parallel for WSA focus modes + (shopping, social, geo). Ignored for SERP focus modes. - render: Whether to render JavaScript content using a browser + output_format: Output format: plain_text, markdown, or simplified_html - request_timeout: Request timeout in milliseconds + search_depth: Controls content richness and latency of search results. - skill: Skills or capabilities required for the request + - lite: Token-efficient metadata for high-volume pipelines (title, URL, + description only) + - fast: Rich content (~2K chars) optimized for AI agents + - deep: Full page content via Webit scraping for comprehensive analysis - state: US state for geolocation (only valid when country is US) + start_date: Filter results after this date (format: YYYY-MM-DD or YYYY) - tag: User-defined tag for request identification + time_range: Time range filters passed to Webit SERP API as 'time' parameter. extra_headers: Send extra headers @@ -1265,4420 +1215,289 @@ def extract( timeout: Override the client-level default timeout for this request, in seconds """ return self.post( - "/v1/extract", + "/v2/search", body=maybe_transform( { - "url": url, - "auto_driver_configuration": auto_driver_configuration, - "body": body, - "browser": browser, - "browser_actions": browser_actions, - "city": city, - "consent_header": consent_header, - "cookies": cookies, + "query": query, + "content_type": content_type, "country": country, - "device": device, - "driver": driver, - "expected_status_codes": expected_status_codes, - "formats": formats, - "headers": headers, - "http2": http2, - "is_xhr": is_xhr, + "deep_search": deep_search, + "end_date": end_date, + "exclude_domains": exclude_domains, + "focus": focus, + "include_answer": include_answer, + "include_domains": include_domains, "locale": locale, - "markdown_backend": markdown_backend, - "method": method, - "network_capture": network_capture, - "os": os, - "parse": parse, - "parser": parser, - "referrer_type": referrer_type, - "render": render, - "request_timeout": request_timeout, - "session": session, - "skill": skill, - "state": state, - "tag": tag, + "max_results": max_results, + "max_subagents": max_subagents, + "output_format": output_format, + "search_depth": search_depth, + "start_date": start_date, + "time_range": time_range, }, - client_extract_params.ClientExtractParams, + client_search_params.ClientSearchParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=ExtractResponse, + cast_to=SearchResponse, ) - def extract_async( + @override + def _make_status_error( self, + err_msg: str, *, - url: str, - auto_driver_configuration: Dict[str, int] | Omit = omit, - body: object | Omit = omit, - browser: client_extract_async_params.Browser | Omit = omit, - browser_actions: Iterable[client_extract_async_params.BrowserAction] | Omit = omit, - callback_url: str | Omit = omit, - city: str | Omit = omit, - consent_header: bool | Omit = omit, - cookies: Union[Iterable[client_extract_async_params.CookiesUnionMember0], str] | Omit = omit, - country: Literal[ - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CR", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SV", - "SX", - "SY", - "SZ", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XK", - "YE", - "YT", - "ZA", - "ZM", - "ZW", - "ALL", - ] - | Omit = omit, - device: Literal["desktop", "mobile", "tablet"] | Omit = omit, - driver: Literal[ - "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" - ] - | Omit = omit, - expected_status_codes: Iterable[int] | Omit = omit, - formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, - headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, - http2: bool | Omit = omit, - is_xhr: bool | Omit = omit, - locale: Literal[ - "aa-DJ", - "aa-ER", - "aa-ET", - "af", - "af-NA", - "af-ZA", - "ak", - "ak-GH", - "am", - "am-ET", - "an-ES", - "ar", - "ar-AE", - "ar-BH", - "ar-DZ", - "ar-EG", - "ar-IN", - "ar-IQ", - "ar-JO", - "ar-KW", - "ar-LB", - "ar-LY", - "ar-MA", - "ar-OM", - "ar-QA", - "ar-SA", - "ar-SD", - "ar-SY", - "ar-TN", - "ar-YE", - "as", - "as-IN", - "asa", - "asa-TZ", - "ast-ES", - "az", - "az-AZ", - "az-Cyrl", - "az-Cyrl-AZ", - "az-Latn", - "az-Latn-AZ", - "be", - "be-BY", - "bem", - "bem-ZM", - "ber-DZ", - "ber-MA", - "bez", - "bez-TZ", - "bg", - "bg-BG", - "bho-IN", - "bm", - "bm-ML", - "bn", - "bn-BD", - "bn-IN", - "bo", - "bo-CN", - "bo-IN", - "br-FR", - "brx-IN", - "bs", - "bs-BA", - "byn-ER", - "ca", - "ca-AD", - "ca-ES", - "ca-FR", - "ca-IT", - "cgg", - "cgg-UG", - "chr", - "chr-US", - "crh-UA", - "cs", - "cs-CZ", - "csb-PL", - "cv-RU", - "cy", - "cy-GB", - "da", - "da-DK", - "dav", - "dav-KE", - "de", - "de-AT", - "de-BE", - "de-CH", - "de-DE", - "de-LI", - "de-LU", - "dv-MV", - "dz-BT", - "ebu", - "ebu-KE", - "ee", - "ee-GH", - "ee-TG", - "el", - "el-CY", - "el-GR", - "en", - "en-AG", - "en-AS", - "en-AU", - "en-BE", - "en-BW", - "en-BZ", - "en-CA", - "en-DK", - "en-GB", - "en-GU", - "en-HK", - "en-IE", - "en-IN", - "en-JM", - "en-MH", - "en-MP", - "en-MT", - "en-MU", - "en-NA", - "en-NG", - "en-NZ", - "en-PH", - "en-PK", - "en-SG", - "en-TT", - "en-UM", - "en-US", - "en-VI", - "en-ZA", - "en-ZM", - "en-ZW", - "eo", - "es", - "es-419", - "es-AR", - "es-BO", - "es-CL", - "es-CO", - "es-CR", - "es-CU", - "es-DO", - "es-EC", - "es-ES", - "es-GQ", - "es-GT", - "es-HN", - "es-MX", - "es-NI", - "es-PA", - "es-PE", - "es-PR", - "es-PY", - "es-SV", - "es-US", - "es-UY", - "es-VE", - "et", - "et-EE", - "eu", - "eu-ES", - "fa", - "fa-AF", - "fa-IR", - "ff", - "ff-SN", - "fi", - "fi-FI", - "fil", - "fil-PH", - "fo", - "fo-FO", - "fr", - "fr-BE", - "fr-BF", - "fr-BI", - "fr-BJ", - "fr-BL", - "fr-CA", - "fr-CD", - "fr-CF", - "fr-CG", - "fr-CH", - "fr-CI", - "fr-CM", - "fr-DJ", - "fr-FR", - "fr-GA", - "fr-GN", - "fr-GP", - "fr-GQ", - "fr-KM", - "fr-LU", - "fr-MC", - "fr-MF", - "fr-MG", - "fr-ML", - "fr-MQ", - "fr-NE", - "fr-RE", - "fr-RW", - "fr-SN", - "fr-TD", - "fr-TG", - "fur-IT", - "fy-DE", - "fy-NL", - "ga", - "ga-IE", - "gd-GB", - "gez-ER", - "gez-ET", - "gl", - "gl-ES", - "gsw", - "gsw-CH", - "gu", - "gu-IN", - "guz", - "guz-KE", - "gv", - "gv-GB", - "ha", - "ha-Latn", - "ha-Latn-GH", - "ha-Latn-NE", - "ha-Latn-NG", - "ha-NG", - "haw", - "haw-US", - "he", - "he-IL", - "hi", - "hi-IN", - "hne-IN", - "hr", - "hr-HR", - "hsb-DE", - "ht-HT", - "hu", - "hu-HU", - "hy", - "hy-AM", - "id", - "id-ID", - "ig", - "ig-NG", - "ii", - "ii-CN", - "ik-CA", - "is", - "is-IS", - "it", - "it-CH", - "it-IT", - "iu-CA", - "iw-IL", - "ja", - "ja-JP", - "jmc", - "jmc-TZ", - "ka", - "ka-GE", - "kab", - "kab-DZ", - "kam", - "kam-KE", - "kde", - "kde-TZ", - "kea", - "kea-CV", - "khq", - "khq-ML", - "ki", - "ki-KE", - "kk", - "kk-Cyrl", - "kk-Cyrl-KZ", - "kk-KZ", - "kl", - "kl-GL", - "kln", - "kln-KE", - "km", - "km-KH", - "kn", - "kn-IN", - "ko", - "ko-KR", - "kok", - "kok-IN", - "ks-IN", - "ku-TR", - "kw", - "kw-GB", - "ky-KG", - "lag", - "lag-TZ", - "lb-LU", - "lg", - "lg-UG", - "li-BE", - "li-NL", - "lij-IT", - "lo-LA", - "lt", - "lt-LT", - "luo", - "luo-KE", - "luy", - "luy-KE", - "lv", - "lv-LV", - "mag-IN", - "mai-IN", - "mas", - "mas-KE", - "mas-TZ", - "mer", - "mer-KE", - "mfe", - "mfe-MU", - "mg", - "mg-MG", - "mhr-RU", - "mi-NZ", - "mk", - "mk-MK", - "ml", - "ml-IN", - "mn-MN", - "mr", - "mr-IN", - "ms", - "ms-BN", - "ms-MY", - "mt", - "mt-MT", - "my", - "my-MM", - "nan-TW", - "naq", - "naq-NA", - "nb", - "nb-NO", - "nd", - "nd-ZW", - "nds-DE", - "nds-NL", - "ne", - "ne-IN", - "ne-NP", - "nl", - "nl-AW", - "nl-BE", - "nl-NL", - "nn", - "nn-NO", - "nr-ZA", - "nso-ZA", - "nyn", - "nyn-UG", - "oc-FR", - "om", - "om-ET", - "om-KE", - "or", - "or-IN", - "os-RU", - "pa", - "pa-Arab", - "pa-Arab-PK", - "pa-Guru", - "pa-Guru-IN", - "pa-IN", - "pa-PK", - "pap-AN", - "pl", - "pl-PL", - "ps", - "ps-AF", - "pt", - "pt-BR", - "pt-GW", - "pt-MZ", - "pt-PT", - "rm", - "rm-CH", - "ro", - "ro-MD", - "ro-RO", - "rof", - "rof-TZ", - "ru", - "ru-MD", - "ru-RU", - "ru-UA", - "rw", - "rw-RW", - "rwk", - "rwk-TZ", - "sa-IN", - "saq", - "saq-KE", - "sc-IT", - "sd-IN", - "se-NO", - "seh", - "seh-MZ", - "ses", - "ses-ML", - "sg", - "sg-CF", - "shi", - "shi-Latn", - "shi-Latn-MA", - "shi-Tfng", - "shi-Tfng-MA", - "shs-CA", - "si", - "si-LK", - "sid-ET", - "sk", - "sk-SK", - "sl", - "sl-SI", - "sn", - "sn-ZW", - "so", - "so-DJ", - "so-ET", - "so-KE", - "so-SO", - "sq", - "sq-AL", - "sq-MK", - "sr", - "sr-Cyrl", - "sr-Cyrl-BA", - "sr-Cyrl-ME", - "sr-Cyrl-RS", - "sr-Latn", - "sr-Latn-BA", - "sr-Latn-ME", - "sr-Latn-RS", - "sr-ME", - "sr-RS", - "ss-ZA", - "st-ZA", - "sv", - "sv-FI", - "sv-SE", - "sw", - "sw-KE", - "sw-TZ", - "ta", - "ta-IN", - "ta-LK", - "te", - "te-IN", - "teo", - "teo-KE", - "teo-UG", - "tg-TJ", - "th", - "th-TH", - "ti", - "ti-ER", - "ti-ET", - "tig-ER", - "tk-TM", - "tl-PH", - "tn-ZA", - "to", - "to-TO", - "tr", - "tr-CY", - "tr-TR", - "ts-ZA", - "tt-RU", - "tzm", - "tzm-Latn", - "tzm-Latn-MA", - "ug-CN", - "uk", - "uk-UA", - "unm-US", - "ur", - "ur-IN", - "ur-PK", - "uz", - "uz-Arab", - "uz-Arab-AF", - "uz-Cyrl", - "uz-Cyrl-UZ", - "uz-Latn", - "uz-Latn-UZ", - "uz-UZ", - "ve-ZA", - "vi", - "vi-VN", - "vun", - "vun-TZ", - "wa-BE", - "wae-CH", - "wal-ET", - "wo-SN", - "xh-ZA", - "xog", - "xog-UG", - "yi-US", - "yo", - "yo-NG", - "yue-HK", - "zh", - "zh-CN", - "zh-HK", - "zh-Hans", - "zh-Hans-CN", - "zh-Hans-HK", - "zh-Hans-MO", - "zh-Hans-SG", - "zh-Hant", - "zh-Hant-HK", - "zh-Hant-MO", - "zh-Hant-TW", - "zh-SG", - "zh-TW", - "zu", - "zu-ZA", - "auto", - ] - | Omit = omit, - markdown_backend: Literal["full_page", "main_content"] | Omit = omit, - method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, - network_capture: Iterable[client_extract_async_params.NetworkCapture] | Omit = omit, - os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, - parse: bool | Omit = omit, - parser: Union[Dict[str, object], str] | Omit = omit, - referrer_type: Literal[ - "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" - ] - | Omit = omit, - render: Union[bool, Literal["auto"]] | Omit = omit, - request_timeout: float | Omit = omit, - session: client_extract_async_params.Session | Omit = omit, - skill: Union[str, SequenceNotStr[str]] | Omit = omit, - state: Literal[ - "AL", - "AK", - "AS", - "AZ", - "AR", - "CA", - "CO", - "CT", - "DE", - "DC", - "FL", - "GA", - "GU", - "HI", - "ID", - "IL", - "IN", - "IA", - "KS", - "KY", - "LA", - "ME", - "MD", - "MA", - "MI", - "MN", - "MS", - "MO", - "MT", - "NE", - "NV", - "NH", - "NJ", - "NM", - "NY", - "NC", - "ND", - "MP", - "OH", - "OK", - "OR", - "PA", - "PR", - "RI", - "SC", - "SD", - "TN", - "TX", - "UT", - "VT", - "VA", - "VI", - "WA", - "WV", - "WI", - "WY", - ] - | Omit = omit, - storage_compress: bool | Omit = omit, - storage_object_name: str | Omit = omit, - storage_type: str | Omit = omit, - storage_url: str | Omit = omit, - tag: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ExtractAsyncResponse: - """ - Extract Async Endpoint - - Args: - url: Target URL to scrape - - auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of - attempts to spend on each candidate before advancing (0 skips it). Key order - defines the flow order. Providing it opts the request into 'auto' driver - selection. - - body: Request body for POST, PUT, PATCH methods - - browser: Browser type to emulate - - browser_actions: Array of browser automation actions to execute sequentially - - callback_url: URL to call back when async operation completes - - city: City for geolocation - - consent_header: Whether to automatically handle cookie consent headers - - cookies: Browser cookies as array of cookie objects - - country: Country code for geolocation and proxy selection - - device: Device type for browser emulation - - driver: Browser driver to use - - expected_status_codes: Expected HTTP status codes for successful requests - - formats: List of acceptable response formats in order of preference - - headers: Custom HTTP headers to include in the request - - http2: Whether to use HTTP/2 protocol - - is_xhr: Whether to emulate XMLHttpRequest behavior - - locale: Locale for browser language and region settings - - markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the - entire HTML page. "main_content" uses Mozilla Readability to extract the main - article content before converting. - - method: HTTP method for the request - - network_capture: Filters for capturing network traffic - - os: Operating system to emulate - - parse: Whether to parse the response content - - parser: Custom parser configuration as a key-value map - - referrer_type: Referrer policy for the request - - render: Whether to render JavaScript content using a browser - - request_timeout: Request timeout in milliseconds - - skill: Skills or capabilities required for the request - - state: US state for geolocation (only valid when country is US) - - storage_compress: Whether to compress stored data - - storage_object_name: Custom name for the stored object - - storage_type: Type of storage to use for results - - storage_url: URL for storage location - - tag: User-defined tag for request identification - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self.post( - "/v1/extract/async", - body=maybe_transform( - { - "url": url, - "auto_driver_configuration": auto_driver_configuration, - "body": body, - "browser": browser, - "browser_actions": browser_actions, - "callback_url": callback_url, - "city": city, - "consent_header": consent_header, - "cookies": cookies, - "country": country, - "device": device, - "driver": driver, - "expected_status_codes": expected_status_codes, - "formats": formats, - "headers": headers, - "http2": http2, - "is_xhr": is_xhr, - "locale": locale, - "markdown_backend": markdown_backend, - "method": method, - "network_capture": network_capture, - "os": os, - "parse": parse, - "parser": parser, - "referrer_type": referrer_type, - "render": render, - "request_timeout": request_timeout, - "session": session, - "skill": skill, - "state": state, - "storage_compress": storage_compress, - "storage_object_name": storage_object_name, - "storage_type": storage_type, - "storage_url": storage_url, - "tag": tag, - }, - client_extract_async_params.ClientExtractAsyncParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ExtractAsyncResponse, - ) - - def extract_batch( - self, - *, - inputs: Iterable[client_extract_batch_params.Input], - shared_inputs: client_extract_batch_params.SharedInputs | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ExtractBatchResponse: - """Extract Batch Endpoint - - Args: - inputs: Array of extraction requests. - - Each object can include extraction parameters and - async/storage settings. - - shared_inputs: Shared parameters applied to the entire batch. Can include extraction parameters - and async/storage settings. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self.post( - "/v1/extract/batch", - body=maybe_transform( - { - "inputs": inputs, - "shared_inputs": shared_inputs, - }, - client_extract_batch_params.ClientExtractBatchParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ExtractBatchResponse, - ) - - def map( - self, - *, - url: str, - country: Literal[ - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CR", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SV", - "SX", - "SY", - "SZ", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XK", - "YE", - "YT", - "ZA", - "ZM", - "ZW", - ] - | Omit = omit, - domain_filter: Literal["domain", "subdomain", "all"] | Omit = omit, - limit: int | Omit = omit, - locale: Literal[ - "aa-DJ", - "aa-ER", - "aa-ET", - "af", - "af-NA", - "af-ZA", - "ak", - "ak-GH", - "am", - "am-ET", - "an-ES", - "ar", - "ar-AE", - "ar-BH", - "ar-DZ", - "ar-EG", - "ar-IN", - "ar-IQ", - "ar-JO", - "ar-KW", - "ar-LB", - "ar-LY", - "ar-MA", - "ar-OM", - "ar-QA", - "ar-SA", - "ar-SD", - "ar-SY", - "ar-TN", - "ar-YE", - "as", - "as-IN", - "asa", - "asa-TZ", - "ast-ES", - "az", - "az-AZ", - "az-Cyrl", - "az-Cyrl-AZ", - "az-Latn", - "az-Latn-AZ", - "be", - "be-BY", - "bem", - "bem-ZM", - "ber-DZ", - "ber-MA", - "bez", - "bez-TZ", - "bg", - "bg-BG", - "bho-IN", - "bm", - "bm-ML", - "bn", - "bn-BD", - "bn-IN", - "bo", - "bo-CN", - "bo-IN", - "br-FR", - "brx-IN", - "bs", - "bs-BA", - "byn-ER", - "ca", - "ca-AD", - "ca-ES", - "ca-FR", - "ca-IT", - "cgg", - "cgg-UG", - "chr", - "chr-US", - "crh-UA", - "cs", - "cs-CZ", - "csb-PL", - "cv-RU", - "cy", - "cy-GB", - "da", - "da-DK", - "dav", - "dav-KE", - "de", - "de-AT", - "de-BE", - "de-CH", - "de-DE", - "de-LI", - "de-LU", - "dv-MV", - "dz-BT", - "ebu", - "ebu-KE", - "ee", - "ee-GH", - "ee-TG", - "el", - "el-CY", - "el-GR", - "en", - "en-AG", - "en-AS", - "en-AU", - "en-BE", - "en-BW", - "en-BZ", - "en-CA", - "en-DK", - "en-GB", - "en-GU", - "en-HK", - "en-IE", - "en-IN", - "en-JM", - "en-MH", - "en-MP", - "en-MT", - "en-MU", - "en-NA", - "en-NG", - "en-NZ", - "en-PH", - "en-PK", - "en-SG", - "en-TT", - "en-UM", - "en-US", - "en-VI", - "en-ZA", - "en-ZM", - "en-ZW", - "eo", - "es", - "es-419", - "es-AR", - "es-BO", - "es-CL", - "es-CO", - "es-CR", - "es-CU", - "es-DO", - "es-EC", - "es-ES", - "es-GQ", - "es-GT", - "es-HN", - "es-MX", - "es-NI", - "es-PA", - "es-PE", - "es-PR", - "es-PY", - "es-SV", - "es-US", - "es-UY", - "es-VE", - "et", - "et-EE", - "eu", - "eu-ES", - "fa", - "fa-AF", - "fa-IR", - "ff", - "ff-SN", - "fi", - "fi-FI", - "fil", - "fil-PH", - "fo", - "fo-FO", - "fr", - "fr-BE", - "fr-BF", - "fr-BI", - "fr-BJ", - "fr-BL", - "fr-CA", - "fr-CD", - "fr-CF", - "fr-CG", - "fr-CH", - "fr-CI", - "fr-CM", - "fr-DJ", - "fr-FR", - "fr-GA", - "fr-GN", - "fr-GP", - "fr-GQ", - "fr-KM", - "fr-LU", - "fr-MC", - "fr-MF", - "fr-MG", - "fr-ML", - "fr-MQ", - "fr-NE", - "fr-RE", - "fr-RW", - "fr-SN", - "fr-TD", - "fr-TG", - "fur-IT", - "fy-DE", - "fy-NL", - "ga", - "ga-IE", - "gd-GB", - "gez-ER", - "gez-ET", - "gl", - "gl-ES", - "gsw", - "gsw-CH", - "gu", - "gu-IN", - "guz", - "guz-KE", - "gv", - "gv-GB", - "ha", - "ha-Latn", - "ha-Latn-GH", - "ha-Latn-NE", - "ha-Latn-NG", - "ha-NG", - "haw", - "haw-US", - "he", - "he-IL", - "hi", - "hi-IN", - "hne-IN", - "hr", - "hr-HR", - "hsb-DE", - "ht-HT", - "hu", - "hu-HU", - "hy", - "hy-AM", - "id", - "id-ID", - "ig", - "ig-NG", - "ii", - "ii-CN", - "ik-CA", - "is", - "is-IS", - "it", - "it-CH", - "it-IT", - "iu-CA", - "iw-IL", - "ja", - "ja-JP", - "jmc", - "jmc-TZ", - "ka", - "ka-GE", - "kab", - "kab-DZ", - "kam", - "kam-KE", - "kde", - "kde-TZ", - "kea", - "kea-CV", - "khq", - "khq-ML", - "ki", - "ki-KE", - "kk", - "kk-Cyrl", - "kk-Cyrl-KZ", - "kk-KZ", - "kl", - "kl-GL", - "kln", - "kln-KE", - "km", - "km-KH", - "kn", - "kn-IN", - "ko", - "ko-KR", - "kok", - "kok-IN", - "ks-IN", - "ku-TR", - "kw", - "kw-GB", - "ky-KG", - "lag", - "lag-TZ", - "lb-LU", - "lg", - "lg-UG", - "li-BE", - "li-NL", - "lij-IT", - "lo-LA", - "lt", - "lt-LT", - "luo", - "luo-KE", - "luy", - "luy-KE", - "lv", - "lv-LV", - "mag-IN", - "mai-IN", - "mas", - "mas-KE", - "mas-TZ", - "mer", - "mer-KE", - "mfe", - "mfe-MU", - "mg", - "mg-MG", - "mhr-RU", - "mi-NZ", - "mk", - "mk-MK", - "ml", - "ml-IN", - "mn-MN", - "mr", - "mr-IN", - "ms", - "ms-BN", - "ms-MY", - "mt", - "mt-MT", - "my", - "my-MM", - "nan-TW", - "naq", - "naq-NA", - "nb", - "nb-NO", - "nd", - "nd-ZW", - "nds-DE", - "nds-NL", - "ne", - "ne-IN", - "ne-NP", - "nl", - "nl-AW", - "nl-BE", - "nl-NL", - "nn", - "nn-NO", - "nr-ZA", - "nso-ZA", - "nyn", - "nyn-UG", - "oc-FR", - "om", - "om-ET", - "om-KE", - "or", - "or-IN", - "os-RU", - "pa", - "pa-Arab", - "pa-Arab-PK", - "pa-Guru", - "pa-Guru-IN", - "pa-IN", - "pa-PK", - "pap-AN", - "pl", - "pl-PL", - "ps", - "ps-AF", - "pt", - "pt-BR", - "pt-GW", - "pt-MZ", - "pt-PT", - "rm", - "rm-CH", - "ro", - "ro-MD", - "ro-RO", - "rof", - "rof-TZ", - "ru", - "ru-MD", - "ru-RU", - "ru-UA", - "rw", - "rw-RW", - "rwk", - "rwk-TZ", - "sa-IN", - "saq", - "saq-KE", - "sc-IT", - "sd-IN", - "se-NO", - "seh", - "seh-MZ", - "ses", - "ses-ML", - "sg", - "sg-CF", - "shi", - "shi-Latn", - "shi-Latn-MA", - "shi-Tfng", - "shi-Tfng-MA", - "shs-CA", - "si", - "si-LK", - "sid-ET", - "sk", - "sk-SK", - "sl", - "sl-SI", - "sn", - "sn-ZW", - "so", - "so-DJ", - "so-ET", - "so-KE", - "so-SO", - "sq", - "sq-AL", - "sq-MK", - "sr", - "sr-Cyrl", - "sr-Cyrl-BA", - "sr-Cyrl-ME", - "sr-Cyrl-RS", - "sr-Latn", - "sr-Latn-BA", - "sr-Latn-ME", - "sr-Latn-RS", - "sr-ME", - "sr-RS", - "ss-ZA", - "st-ZA", - "sv", - "sv-FI", - "sv-SE", - "sw", - "sw-KE", - "sw-TZ", - "ta", - "ta-IN", - "ta-LK", - "te", - "te-IN", - "teo", - "teo-KE", - "teo-UG", - "tg-TJ", - "th", - "th-TH", - "ti", - "ti-ER", - "ti-ET", - "tig-ER", - "tk-TM", - "tl-PH", - "tn-ZA", - "to", - "to-TO", - "tr", - "tr-CY", - "tr-TR", - "ts-ZA", - "tt-RU", - "tzm", - "tzm-Latn", - "tzm-Latn-MA", - "ug-CN", - "uk", - "uk-UA", - "unm-US", - "ur", - "ur-IN", - "ur-PK", - "uz", - "uz-Arab", - "uz-Arab-AF", - "uz-Cyrl", - "uz-Cyrl-UZ", - "uz-Latn", - "uz-Latn-UZ", - "uz-UZ", - "ve-ZA", - "vi", - "vi-VN", - "vun", - "vun-TZ", - "wa-BE", - "wae-CH", - "wal-ET", - "wo-SN", - "xh-ZA", - "xog", - "xog-UG", - "yi-US", - "yo", - "yo-NG", - "yue-HK", - "zh", - "zh-CN", - "zh-HK", - "zh-Hans", - "zh-Hans-CN", - "zh-Hans-HK", - "zh-Hans-MO", - "zh-Hans-SG", - "zh-Hant", - "zh-Hant-HK", - "zh-Hant-MO", - "zh-Hant-TW", - "zh-SG", - "zh-TW", - "zu", - "zu-ZA", - "auto", - ] - | Omit = omit, - sitemap: Literal["skip", "include", "only"] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> MapResponse: - """ - Create map task - - Args: - url: Url to map. - - country: Country code for geolocation and proxy selection - - domain_filter: Includes subdomains of the main domain in the mapping process. - - limit: Maximum number of links to return. - - locale: Locale for browser language and region settings - - sitemap: Sitemap and other methods will be used together to find URLs. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self.post( - "/v1/map", - body=maybe_transform( - { - "url": url, - "country": country, - "domain_filter": domain_filter, - "limit": limit, - "locale": locale, - "sitemap": sitemap, - }, - client_map_params.ClientMapParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=MapResponse, - ) - - def search( - self, - *, - query: str, - content_type: Optional[SequenceNotStr[str]] | Omit = omit, - country: str | Omit = omit, - deep_search: Optional[bool] | Omit = omit, - end_date: Optional[str] | Omit = omit, - exclude_domains: Optional[SequenceNotStr[str]] | Omit = omit, - focus: Union[str, SequenceNotStr[str]] | Omit = omit, - include_answer: bool | Omit = omit, - include_domains: Optional[SequenceNotStr[str]] | Omit = omit, - locale: str | Omit = omit, - max_results: int | Omit = omit, - max_subagents: int | Omit = omit, - output_format: Literal["plain_text", "markdown", "simplified_html"] | Omit = omit, - search_depth: Optional[Literal["lite", "fast", "deep"]] | Omit = omit, - start_date: Optional[str] | Omit = omit, - time_range: Optional[Literal["hour", "day", "week", "month", "year"]] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SearchResponse: - """ - Search - - Args: - query: Search query string - - content_type: Filter by content type (only supported with focus=general). Supports semantic - groups ('documents', 'spreadsheets', 'presentations') and specific formats - ('pdf', 'docx', 'xlsx', etc.) - - country: Country code for geo-targeted results (e.g., 'US', 'GB', 'IL') - - deep_search: Deprecated. Use search_depth instead. true maps to 'deep', false maps to 'lite'. - - end_date: Filter results before this date (format: YYYY-MM-DD or YYYY) - - exclude_domains: List of domains to exclude from search results. Maximum 50 domains. - - focus: Search focus mode (e.g., 'general', 'news', 'shopping') or a list of explicit - subagent names (e.g., ['amazon_serp', 'target_serp']) - - include_answer: Generate an LLM-powered answer summary based on search result snippets. - - include_domains: List of domains to include in search results. Maximum 50 domains. - - locale: Language/locale code (e.g., 'en', 'fr', 'de') - - max_results: Maximum number of results to return. Actual count may be lower depending on - availability. - - max_subagents: Maximum number of subagents to execute in parallel for WSA focus modes - (shopping, social, geo). Ignored for SERP focus modes. - - output_format: Output format: plain_text, markdown, or simplified_html - - search_depth: Controls content richness and latency of search results. - - - lite: Token-efficient metadata for high-volume pipelines (title, URL, - description only) - - fast: Rich content (~2K chars) optimized for AI agents - - deep: Full page content via Webit scraping for comprehensive analysis - - start_date: Filter results after this date (format: YYYY-MM-DD or YYYY) - - time_range: Time range filters passed to Webit SERP API as 'time' parameter. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self.post( - "/v1/search", - body=maybe_transform( - { - "query": query, - "content_type": content_type, - "country": country, - "deep_search": deep_search, - "end_date": end_date, - "exclude_domains": exclude_domains, - "focus": focus, - "include_answer": include_answer, - "include_domains": include_domains, - "locale": locale, - "max_results": max_results, - "max_subagents": max_subagents, - "output_format": output_format, - "search_depth": search_depth, - "start_date": start_date, - "time_range": time_range, - }, - client_search_params.ClientSearchParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SearchResponse, - ) - - @override - def _make_status_error( - self, - err_msg: str, - *, - body: object, - response: httpx.Response, - ) -> APIStatusError: - if response.status_code == 400: - return _exceptions.BadRequestError(err_msg, response=response, body=body) - - if response.status_code == 401: - return _exceptions.AuthenticationError(err_msg, response=response, body=body) - - if response.status_code == 403: - return _exceptions.PermissionDeniedError(err_msg, response=response, body=body) - - if response.status_code == 404: - return _exceptions.NotFoundError(err_msg, response=response, body=body) - - if response.status_code == 409: - return _exceptions.ConflictError(err_msg, response=response, body=body) - - if response.status_code == 422: - return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body) - - if response.status_code == 429: - return _exceptions.RateLimitError(err_msg, response=response, body=body) - - if response.status_code >= 500: - return _exceptions.InternalServerError(err_msg, response=response, body=body) - return APIStatusError(err_msg, response=response, body=body) - - -class AsyncNimble(AsyncAPIClient): - # client options - api_key: str | None - client_source: str | None - - def __init__( - self, - *, - api_key: str | None = None, - client_source: str | None = None, - base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = not_given, - max_retries: int = DEFAULT_MAX_RETRIES, - default_headers: Mapping[str, str] | None = None, - default_query: Mapping[str, object] | None = None, - # Configure a custom httpx client. - # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`. - # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details. - http_client: httpx.AsyncClient | None = None, - # Enable or disable schema validation for data returned by the API. - # When enabled an error APIResponseValidationError is raised - # if the API responds with invalid data for the expected schema. - # - # This parameter may be removed or changed in the future. - # If you rely on this feature, please open a GitHub issue - # outlining your use-case to help us decide if it should be - # part of our public interface in the future. - _strict_response_validation: bool = False, - ) -> None: - """Construct a new async AsyncNimble client instance. - - This automatically infers the following arguments from their corresponding environment variables if they are not provided: - - `api_key` from `NIMBLE_API_KEY` - - `client_source` from `CLIENT_SOURCE` - """ - if api_key is None: - api_key = os.environ.get("NIMBLE_API_KEY") - self.api_key = api_key - - if client_source is None: - client_source = os.environ.get("CLIENT_SOURCE") or "sdk" - self.client_source = client_source - - if base_url is None: - base_url = os.environ.get("NIMBLE_BASE_URL") - if base_url is None: - base_url = f"https://sdk.nimbleway.com" - - custom_headers_env = os.environ.get("NIMBLE_CUSTOM_HEADERS") - if custom_headers_env is not None: - parsed: dict[str, str] = {} - for line in custom_headers_env.split("\n"): - colon = line.find(":") - if colon >= 0: - parsed[line[:colon].strip()] = line[colon + 1 :].strip() - default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})} - - super().__init__( - version=__version__, - base_url=base_url, - max_retries=max_retries, - timeout=timeout, - http_client=http_client, - custom_headers=default_headers, - custom_query=default_query, - _strict_response_validation=_strict_response_validation, - ) - - @cached_property - def agent(self) -> AsyncAgentResource: - from .resources.agent import AsyncAgentResource - - return AsyncAgentResource(self) - - @cached_property - def crawl(self) -> AsyncCrawlResource: - from .resources.crawl import AsyncCrawlResource - - return AsyncCrawlResource(self) - - @cached_property - def tasks(self) -> AsyncTasksResource: - from .resources.tasks import AsyncTasksResource - - return AsyncTasksResource(self) - - @cached_property - def batches(self) -> AsyncBatchesResource: - from .resources.batches import AsyncBatchesResource - - return AsyncBatchesResource(self) - - @cached_property - def domain_knowledge(self) -> AsyncDomainKnowledgeResource: - from .resources.domain_knowledge import AsyncDomainKnowledgeResource - - return AsyncDomainKnowledgeResource(self) - - @cached_property - def media(self) -> AsyncMediaResource: - from .resources.media import AsyncMediaResource - - return AsyncMediaResource(self) - - @cached_property - def serp(self) -> AsyncSerpResource: - from .resources.serp import AsyncSerpResource - - return AsyncSerpResource(self) - - @cached_property - def fast_serp(self) -> AsyncFastSerpResource: - from .resources.fast_serp import AsyncFastSerpResource - - return AsyncFastSerpResource(self) - - @cached_property - def task_agent(self) -> AsyncTaskAgentResource: - from .resources.task_agent import AsyncTaskAgentResource - - return AsyncTaskAgentResource(self) - - @cached_property - def jobs(self) -> AsyncJobsResource: - from .resources.jobs import AsyncJobsResource - - return AsyncJobsResource(self) - - @cached_property - def with_raw_response(self) -> AsyncNimbleWithRawResponse: - return AsyncNimbleWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncNimbleWithStreamedResponse: - return AsyncNimbleWithStreamedResponse(self) - - @property - @override - def qs(self) -> Querystring: - return Querystring(array_format="comma") - - @property - @override - def auth_headers(self) -> dict[str, str]: - api_key = self.api_key - if api_key is None: - return {} - return {"Authorization": f"Bearer {api_key}"} - - @property - @override - def default_headers(self) -> dict[str, str | Omit]: - return { - **super().default_headers, - "X-Stainless-Async": f"async:{get_async_library()}", - "X-Client-Source": self.client_source if self.client_source is not None else Omit(), - **self._custom_headers, - } - - @override - def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None: - if headers.get("Authorization") or isinstance(custom_headers.get("Authorization"), Omit): - return - - raise TypeError( - '"Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted"' - ) - - def copy( - self, - *, - api_key: str | None = None, - client_source: str | None = None, - base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = not_given, - http_client: httpx.AsyncClient | None = None, - max_retries: int | NotGiven = not_given, - default_headers: Mapping[str, str] | None = None, - set_default_headers: Mapping[str, str] | None = None, - default_query: Mapping[str, object] | None = None, - set_default_query: Mapping[str, object] | None = None, - _extra_kwargs: Mapping[str, Any] = {}, - ) -> Self: - """ - Create a new client instance re-using the same options given to the current client with optional overriding. - """ - if default_headers is not None and set_default_headers is not None: - raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive") - - if default_query is not None and set_default_query is not None: - raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive") - - headers = self._custom_headers - if default_headers is not None: - headers = {**headers, **default_headers} - elif set_default_headers is not None: - headers = set_default_headers - - params = self._custom_query - if default_query is not None: - params = {**params, **default_query} - elif set_default_query is not None: - params = set_default_query - - http_client = http_client or self._client - return self.__class__( - api_key=api_key or self.api_key, - client_source=client_source or self.client_source, - base_url=base_url or self.base_url, - timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, - http_client=http_client, - max_retries=max_retries if is_given(max_retries) else self.max_retries, - default_headers=headers, - default_query=params, - **_extra_kwargs, - ) - - # Alias for `copy` for nicer inline usage, e.g. - # client.with_options(timeout=10).foo.create(...) - with_options = copy - - async def extract( - self, - *, - url: str, - auto_driver_configuration: Dict[str, int] | Omit = omit, - body: object | Omit = omit, - browser: client_extract_params.Browser | Omit = omit, - browser_actions: Iterable[client_extract_params.BrowserAction] | Omit = omit, - city: str | Omit = omit, - consent_header: bool | Omit = omit, - cookies: Union[Iterable[client_extract_params.CookiesUnionMember0], str] | Omit = omit, - country: Literal[ - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CR", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SV", - "SX", - "SY", - "SZ", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XK", - "YE", - "YT", - "ZA", - "ZM", - "ZW", - "ALL", - ] - | Omit = omit, - device: Literal["desktop", "mobile", "tablet"] | Omit = omit, - driver: Literal[ - "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" - ] - | Omit = omit, - expected_status_codes: Iterable[int] | Omit = omit, - formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, - headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, - http2: bool | Omit = omit, - is_xhr: bool | Omit = omit, - locale: Literal[ - "aa-DJ", - "aa-ER", - "aa-ET", - "af", - "af-NA", - "af-ZA", - "ak", - "ak-GH", - "am", - "am-ET", - "an-ES", - "ar", - "ar-AE", - "ar-BH", - "ar-DZ", - "ar-EG", - "ar-IN", - "ar-IQ", - "ar-JO", - "ar-KW", - "ar-LB", - "ar-LY", - "ar-MA", - "ar-OM", - "ar-QA", - "ar-SA", - "ar-SD", - "ar-SY", - "ar-TN", - "ar-YE", - "as", - "as-IN", - "asa", - "asa-TZ", - "ast-ES", - "az", - "az-AZ", - "az-Cyrl", - "az-Cyrl-AZ", - "az-Latn", - "az-Latn-AZ", - "be", - "be-BY", - "bem", - "bem-ZM", - "ber-DZ", - "ber-MA", - "bez", - "bez-TZ", - "bg", - "bg-BG", - "bho-IN", - "bm", - "bm-ML", - "bn", - "bn-BD", - "bn-IN", - "bo", - "bo-CN", - "bo-IN", - "br-FR", - "brx-IN", - "bs", - "bs-BA", - "byn-ER", - "ca", - "ca-AD", - "ca-ES", - "ca-FR", - "ca-IT", - "cgg", - "cgg-UG", - "chr", - "chr-US", - "crh-UA", - "cs", - "cs-CZ", - "csb-PL", - "cv-RU", - "cy", - "cy-GB", - "da", - "da-DK", - "dav", - "dav-KE", - "de", - "de-AT", - "de-BE", - "de-CH", - "de-DE", - "de-LI", - "de-LU", - "dv-MV", - "dz-BT", - "ebu", - "ebu-KE", - "ee", - "ee-GH", - "ee-TG", - "el", - "el-CY", - "el-GR", - "en", - "en-AG", - "en-AS", - "en-AU", - "en-BE", - "en-BW", - "en-BZ", - "en-CA", - "en-DK", - "en-GB", - "en-GU", - "en-HK", - "en-IE", - "en-IN", - "en-JM", - "en-MH", - "en-MP", - "en-MT", - "en-MU", - "en-NA", - "en-NG", - "en-NZ", - "en-PH", - "en-PK", - "en-SG", - "en-TT", - "en-UM", - "en-US", - "en-VI", - "en-ZA", - "en-ZM", - "en-ZW", - "eo", - "es", - "es-419", - "es-AR", - "es-BO", - "es-CL", - "es-CO", - "es-CR", - "es-CU", - "es-DO", - "es-EC", - "es-ES", - "es-GQ", - "es-GT", - "es-HN", - "es-MX", - "es-NI", - "es-PA", - "es-PE", - "es-PR", - "es-PY", - "es-SV", - "es-US", - "es-UY", - "es-VE", - "et", - "et-EE", - "eu", - "eu-ES", - "fa", - "fa-AF", - "fa-IR", - "ff", - "ff-SN", - "fi", - "fi-FI", - "fil", - "fil-PH", - "fo", - "fo-FO", - "fr", - "fr-BE", - "fr-BF", - "fr-BI", - "fr-BJ", - "fr-BL", - "fr-CA", - "fr-CD", - "fr-CF", - "fr-CG", - "fr-CH", - "fr-CI", - "fr-CM", - "fr-DJ", - "fr-FR", - "fr-GA", - "fr-GN", - "fr-GP", - "fr-GQ", - "fr-KM", - "fr-LU", - "fr-MC", - "fr-MF", - "fr-MG", - "fr-ML", - "fr-MQ", - "fr-NE", - "fr-RE", - "fr-RW", - "fr-SN", - "fr-TD", - "fr-TG", - "fur-IT", - "fy-DE", - "fy-NL", - "ga", - "ga-IE", - "gd-GB", - "gez-ER", - "gez-ET", - "gl", - "gl-ES", - "gsw", - "gsw-CH", - "gu", - "gu-IN", - "guz", - "guz-KE", - "gv", - "gv-GB", - "ha", - "ha-Latn", - "ha-Latn-GH", - "ha-Latn-NE", - "ha-Latn-NG", - "ha-NG", - "haw", - "haw-US", - "he", - "he-IL", - "hi", - "hi-IN", - "hne-IN", - "hr", - "hr-HR", - "hsb-DE", - "ht-HT", - "hu", - "hu-HU", - "hy", - "hy-AM", - "id", - "id-ID", - "ig", - "ig-NG", - "ii", - "ii-CN", - "ik-CA", - "is", - "is-IS", - "it", - "it-CH", - "it-IT", - "iu-CA", - "iw-IL", - "ja", - "ja-JP", - "jmc", - "jmc-TZ", - "ka", - "ka-GE", - "kab", - "kab-DZ", - "kam", - "kam-KE", - "kde", - "kde-TZ", - "kea", - "kea-CV", - "khq", - "khq-ML", - "ki", - "ki-KE", - "kk", - "kk-Cyrl", - "kk-Cyrl-KZ", - "kk-KZ", - "kl", - "kl-GL", - "kln", - "kln-KE", - "km", - "km-KH", - "kn", - "kn-IN", - "ko", - "ko-KR", - "kok", - "kok-IN", - "ks-IN", - "ku-TR", - "kw", - "kw-GB", - "ky-KG", - "lag", - "lag-TZ", - "lb-LU", - "lg", - "lg-UG", - "li-BE", - "li-NL", - "lij-IT", - "lo-LA", - "lt", - "lt-LT", - "luo", - "luo-KE", - "luy", - "luy-KE", - "lv", - "lv-LV", - "mag-IN", - "mai-IN", - "mas", - "mas-KE", - "mas-TZ", - "mer", - "mer-KE", - "mfe", - "mfe-MU", - "mg", - "mg-MG", - "mhr-RU", - "mi-NZ", - "mk", - "mk-MK", - "ml", - "ml-IN", - "mn-MN", - "mr", - "mr-IN", - "ms", - "ms-BN", - "ms-MY", - "mt", - "mt-MT", - "my", - "my-MM", - "nan-TW", - "naq", - "naq-NA", - "nb", - "nb-NO", - "nd", - "nd-ZW", - "nds-DE", - "nds-NL", - "ne", - "ne-IN", - "ne-NP", - "nl", - "nl-AW", - "nl-BE", - "nl-NL", - "nn", - "nn-NO", - "nr-ZA", - "nso-ZA", - "nyn", - "nyn-UG", - "oc-FR", - "om", - "om-ET", - "om-KE", - "or", - "or-IN", - "os-RU", - "pa", - "pa-Arab", - "pa-Arab-PK", - "pa-Guru", - "pa-Guru-IN", - "pa-IN", - "pa-PK", - "pap-AN", - "pl", - "pl-PL", - "ps", - "ps-AF", - "pt", - "pt-BR", - "pt-GW", - "pt-MZ", - "pt-PT", - "rm", - "rm-CH", - "ro", - "ro-MD", - "ro-RO", - "rof", - "rof-TZ", - "ru", - "ru-MD", - "ru-RU", - "ru-UA", - "rw", - "rw-RW", - "rwk", - "rwk-TZ", - "sa-IN", - "saq", - "saq-KE", - "sc-IT", - "sd-IN", - "se-NO", - "seh", - "seh-MZ", - "ses", - "ses-ML", - "sg", - "sg-CF", - "shi", - "shi-Latn", - "shi-Latn-MA", - "shi-Tfng", - "shi-Tfng-MA", - "shs-CA", - "si", - "si-LK", - "sid-ET", - "sk", - "sk-SK", - "sl", - "sl-SI", - "sn", - "sn-ZW", - "so", - "so-DJ", - "so-ET", - "so-KE", - "so-SO", - "sq", - "sq-AL", - "sq-MK", - "sr", - "sr-Cyrl", - "sr-Cyrl-BA", - "sr-Cyrl-ME", - "sr-Cyrl-RS", - "sr-Latn", - "sr-Latn-BA", - "sr-Latn-ME", - "sr-Latn-RS", - "sr-ME", - "sr-RS", - "ss-ZA", - "st-ZA", - "sv", - "sv-FI", - "sv-SE", - "sw", - "sw-KE", - "sw-TZ", - "ta", - "ta-IN", - "ta-LK", - "te", - "te-IN", - "teo", - "teo-KE", - "teo-UG", - "tg-TJ", - "th", - "th-TH", - "ti", - "ti-ER", - "ti-ET", - "tig-ER", - "tk-TM", - "tl-PH", - "tn-ZA", - "to", - "to-TO", - "tr", - "tr-CY", - "tr-TR", - "ts-ZA", - "tt-RU", - "tzm", - "tzm-Latn", - "tzm-Latn-MA", - "ug-CN", - "uk", - "uk-UA", - "unm-US", - "ur", - "ur-IN", - "ur-PK", - "uz", - "uz-Arab", - "uz-Arab-AF", - "uz-Cyrl", - "uz-Cyrl-UZ", - "uz-Latn", - "uz-Latn-UZ", - "uz-UZ", - "ve-ZA", - "vi", - "vi-VN", - "vun", - "vun-TZ", - "wa-BE", - "wae-CH", - "wal-ET", - "wo-SN", - "xh-ZA", - "xog", - "xog-UG", - "yi-US", - "yo", - "yo-NG", - "yue-HK", - "zh", - "zh-CN", - "zh-HK", - "zh-Hans", - "zh-Hans-CN", - "zh-Hans-HK", - "zh-Hans-MO", - "zh-Hans-SG", - "zh-Hant", - "zh-Hant-HK", - "zh-Hant-MO", - "zh-Hant-TW", - "zh-SG", - "zh-TW", - "zu", - "zu-ZA", - "auto", - ] - | Omit = omit, - markdown_backend: Literal["full_page", "main_content"] | Omit = omit, - method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, - network_capture: Iterable[client_extract_params.NetworkCapture] | Omit = omit, - os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, - parse: bool | Omit = omit, - parser: Union[Dict[str, object], str] | Omit = omit, - referrer_type: Literal[ - "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" - ] - | Omit = omit, - render: Union[bool, Literal["auto"]] | Omit = omit, - request_timeout: float | Omit = omit, - session: client_extract_params.Session | Omit = omit, - skill: Union[str, SequenceNotStr[str]] | Omit = omit, - state: Literal[ - "AL", - "AK", - "AS", - "AZ", - "AR", - "CA", - "CO", - "CT", - "DE", - "DC", - "FL", - "GA", - "GU", - "HI", - "ID", - "IL", - "IN", - "IA", - "KS", - "KY", - "LA", - "ME", - "MD", - "MA", - "MI", - "MN", - "MS", - "MO", - "MT", - "NE", - "NV", - "NH", - "NJ", - "NM", - "NY", - "NC", - "ND", - "MP", - "OH", - "OK", - "OR", - "PA", - "PR", - "RI", - "SC", - "SD", - "TN", - "TX", - "UT", - "VT", - "VA", - "VI", - "WA", - "WV", - "WI", - "WY", - ] - | Omit = omit, - tag: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ExtractResponse: - """ - Extract - - Args: - url: Target URL to scrape - - auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of - attempts to spend on each candidate before advancing (0 skips it). Key order - defines the flow order. Providing it opts the request into 'auto' driver - selection. - - body: Request body for POST, PUT, PATCH methods - - browser: Browser type to emulate - - browser_actions: Array of browser automation actions to execute sequentially - - city: City for geolocation - - consent_header: Whether to automatically handle cookie consent headers - - cookies: Browser cookies as array of cookie objects - - country: Country code for geolocation and proxy selection - - device: Device type for browser emulation - - driver: Browser driver to use - - expected_status_codes: Expected HTTP status codes for successful requests - - formats: List of acceptable response formats in order of preference - - headers: Custom HTTP headers to include in the request - - http2: Whether to use HTTP/2 protocol - - is_xhr: Whether to emulate XMLHttpRequest behavior - - locale: Locale for browser language and region settings - - markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the - entire HTML page. "main_content" uses Mozilla Readability to extract the main - article content before converting. - - method: HTTP method for the request - - network_capture: Filters for capturing network traffic - - os: Operating system to emulate - - parse: Whether to parse the response content - - parser: Custom parser configuration as a key-value map - - referrer_type: Referrer policy for the request - - render: Whether to render JavaScript content using a browser - - request_timeout: Request timeout in milliseconds - - skill: Skills or capabilities required for the request - - state: US state for geolocation (only valid when country is US) - - tag: User-defined tag for request identification - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self.post( - "/v1/extract", - body=await async_maybe_transform( - { - "url": url, - "auto_driver_configuration": auto_driver_configuration, - "body": body, - "browser": browser, - "browser_actions": browser_actions, - "city": city, - "consent_header": consent_header, - "cookies": cookies, - "country": country, - "device": device, - "driver": driver, - "expected_status_codes": expected_status_codes, - "formats": formats, - "headers": headers, - "http2": http2, - "is_xhr": is_xhr, - "locale": locale, - "markdown_backend": markdown_backend, - "method": method, - "network_capture": network_capture, - "os": os, - "parse": parse, - "parser": parser, - "referrer_type": referrer_type, - "render": render, - "request_timeout": request_timeout, - "session": session, - "skill": skill, - "state": state, - "tag": tag, - }, - client_extract_params.ClientExtractParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ExtractResponse, - ) - - async def extract_async( - self, - *, - url: str, - auto_driver_configuration: Dict[str, int] | Omit = omit, - body: object | Omit = omit, - browser: client_extract_async_params.Browser | Omit = omit, - browser_actions: Iterable[client_extract_async_params.BrowserAction] | Omit = omit, - callback_url: str | Omit = omit, - city: str | Omit = omit, - consent_header: bool | Omit = omit, - cookies: Union[Iterable[client_extract_async_params.CookiesUnionMember0], str] | Omit = omit, - country: Literal[ - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CR", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SV", - "SX", - "SY", - "SZ", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XK", - "YE", - "YT", - "ZA", - "ZM", - "ZW", - "ALL", - ] - | Omit = omit, - device: Literal["desktop", "mobile", "tablet"] | Omit = omit, - driver: Literal[ - "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" - ] - | Omit = omit, - expected_status_codes: Iterable[int] | Omit = omit, - formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, - headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, - http2: bool | Omit = omit, - is_xhr: bool | Omit = omit, - locale: Literal[ - "aa-DJ", - "aa-ER", - "aa-ET", - "af", - "af-NA", - "af-ZA", - "ak", - "ak-GH", - "am", - "am-ET", - "an-ES", - "ar", - "ar-AE", - "ar-BH", - "ar-DZ", - "ar-EG", - "ar-IN", - "ar-IQ", - "ar-JO", - "ar-KW", - "ar-LB", - "ar-LY", - "ar-MA", - "ar-OM", - "ar-QA", - "ar-SA", - "ar-SD", - "ar-SY", - "ar-TN", - "ar-YE", - "as", - "as-IN", - "asa", - "asa-TZ", - "ast-ES", - "az", - "az-AZ", - "az-Cyrl", - "az-Cyrl-AZ", - "az-Latn", - "az-Latn-AZ", - "be", - "be-BY", - "bem", - "bem-ZM", - "ber-DZ", - "ber-MA", - "bez", - "bez-TZ", - "bg", - "bg-BG", - "bho-IN", - "bm", - "bm-ML", - "bn", - "bn-BD", - "bn-IN", - "bo", - "bo-CN", - "bo-IN", - "br-FR", - "brx-IN", - "bs", - "bs-BA", - "byn-ER", - "ca", - "ca-AD", - "ca-ES", - "ca-FR", - "ca-IT", - "cgg", - "cgg-UG", - "chr", - "chr-US", - "crh-UA", - "cs", - "cs-CZ", - "csb-PL", - "cv-RU", - "cy", - "cy-GB", - "da", - "da-DK", - "dav", - "dav-KE", - "de", - "de-AT", - "de-BE", - "de-CH", - "de-DE", - "de-LI", - "de-LU", - "dv-MV", - "dz-BT", - "ebu", - "ebu-KE", - "ee", - "ee-GH", - "ee-TG", - "el", - "el-CY", - "el-GR", - "en", - "en-AG", - "en-AS", - "en-AU", - "en-BE", - "en-BW", - "en-BZ", - "en-CA", - "en-DK", - "en-GB", - "en-GU", - "en-HK", - "en-IE", - "en-IN", - "en-JM", - "en-MH", - "en-MP", - "en-MT", - "en-MU", - "en-NA", - "en-NG", - "en-NZ", - "en-PH", - "en-PK", - "en-SG", - "en-TT", - "en-UM", - "en-US", - "en-VI", - "en-ZA", - "en-ZM", - "en-ZW", - "eo", - "es", - "es-419", - "es-AR", - "es-BO", - "es-CL", - "es-CO", - "es-CR", - "es-CU", - "es-DO", - "es-EC", - "es-ES", - "es-GQ", - "es-GT", - "es-HN", - "es-MX", - "es-NI", - "es-PA", - "es-PE", - "es-PR", - "es-PY", - "es-SV", - "es-US", - "es-UY", - "es-VE", - "et", - "et-EE", - "eu", - "eu-ES", - "fa", - "fa-AF", - "fa-IR", - "ff", - "ff-SN", - "fi", - "fi-FI", - "fil", - "fil-PH", - "fo", - "fo-FO", - "fr", - "fr-BE", - "fr-BF", - "fr-BI", - "fr-BJ", - "fr-BL", - "fr-CA", - "fr-CD", - "fr-CF", - "fr-CG", - "fr-CH", - "fr-CI", - "fr-CM", - "fr-DJ", - "fr-FR", - "fr-GA", - "fr-GN", - "fr-GP", - "fr-GQ", - "fr-KM", - "fr-LU", - "fr-MC", - "fr-MF", - "fr-MG", - "fr-ML", - "fr-MQ", - "fr-NE", - "fr-RE", - "fr-RW", - "fr-SN", - "fr-TD", - "fr-TG", - "fur-IT", - "fy-DE", - "fy-NL", - "ga", - "ga-IE", - "gd-GB", - "gez-ER", - "gez-ET", - "gl", - "gl-ES", - "gsw", - "gsw-CH", - "gu", - "gu-IN", - "guz", - "guz-KE", - "gv", - "gv-GB", - "ha", - "ha-Latn", - "ha-Latn-GH", - "ha-Latn-NE", - "ha-Latn-NG", - "ha-NG", - "haw", - "haw-US", - "he", - "he-IL", - "hi", - "hi-IN", - "hne-IN", - "hr", - "hr-HR", - "hsb-DE", - "ht-HT", - "hu", - "hu-HU", - "hy", - "hy-AM", - "id", - "id-ID", - "ig", - "ig-NG", - "ii", - "ii-CN", - "ik-CA", - "is", - "is-IS", - "it", - "it-CH", - "it-IT", - "iu-CA", - "iw-IL", - "ja", - "ja-JP", - "jmc", - "jmc-TZ", - "ka", - "ka-GE", - "kab", - "kab-DZ", - "kam", - "kam-KE", - "kde", - "kde-TZ", - "kea", - "kea-CV", - "khq", - "khq-ML", - "ki", - "ki-KE", - "kk", - "kk-Cyrl", - "kk-Cyrl-KZ", - "kk-KZ", - "kl", - "kl-GL", - "kln", - "kln-KE", - "km", - "km-KH", - "kn", - "kn-IN", - "ko", - "ko-KR", - "kok", - "kok-IN", - "ks-IN", - "ku-TR", - "kw", - "kw-GB", - "ky-KG", - "lag", - "lag-TZ", - "lb-LU", - "lg", - "lg-UG", - "li-BE", - "li-NL", - "lij-IT", - "lo-LA", - "lt", - "lt-LT", - "luo", - "luo-KE", - "luy", - "luy-KE", - "lv", - "lv-LV", - "mag-IN", - "mai-IN", - "mas", - "mas-KE", - "mas-TZ", - "mer", - "mer-KE", - "mfe", - "mfe-MU", - "mg", - "mg-MG", - "mhr-RU", - "mi-NZ", - "mk", - "mk-MK", - "ml", - "ml-IN", - "mn-MN", - "mr", - "mr-IN", - "ms", - "ms-BN", - "ms-MY", - "mt", - "mt-MT", - "my", - "my-MM", - "nan-TW", - "naq", - "naq-NA", - "nb", - "nb-NO", - "nd", - "nd-ZW", - "nds-DE", - "nds-NL", - "ne", - "ne-IN", - "ne-NP", - "nl", - "nl-AW", - "nl-BE", - "nl-NL", - "nn", - "nn-NO", - "nr-ZA", - "nso-ZA", - "nyn", - "nyn-UG", - "oc-FR", - "om", - "om-ET", - "om-KE", - "or", - "or-IN", - "os-RU", - "pa", - "pa-Arab", - "pa-Arab-PK", - "pa-Guru", - "pa-Guru-IN", - "pa-IN", - "pa-PK", - "pap-AN", - "pl", - "pl-PL", - "ps", - "ps-AF", - "pt", - "pt-BR", - "pt-GW", - "pt-MZ", - "pt-PT", - "rm", - "rm-CH", - "ro", - "ro-MD", - "ro-RO", - "rof", - "rof-TZ", - "ru", - "ru-MD", - "ru-RU", - "ru-UA", - "rw", - "rw-RW", - "rwk", - "rwk-TZ", - "sa-IN", - "saq", - "saq-KE", - "sc-IT", - "sd-IN", - "se-NO", - "seh", - "seh-MZ", - "ses", - "ses-ML", - "sg", - "sg-CF", - "shi", - "shi-Latn", - "shi-Latn-MA", - "shi-Tfng", - "shi-Tfng-MA", - "shs-CA", - "si", - "si-LK", - "sid-ET", - "sk", - "sk-SK", - "sl", - "sl-SI", - "sn", - "sn-ZW", - "so", - "so-DJ", - "so-ET", - "so-KE", - "so-SO", - "sq", - "sq-AL", - "sq-MK", - "sr", - "sr-Cyrl", - "sr-Cyrl-BA", - "sr-Cyrl-ME", - "sr-Cyrl-RS", - "sr-Latn", - "sr-Latn-BA", - "sr-Latn-ME", - "sr-Latn-RS", - "sr-ME", - "sr-RS", - "ss-ZA", - "st-ZA", - "sv", - "sv-FI", - "sv-SE", - "sw", - "sw-KE", - "sw-TZ", - "ta", - "ta-IN", - "ta-LK", - "te", - "te-IN", - "teo", - "teo-KE", - "teo-UG", - "tg-TJ", - "th", - "th-TH", - "ti", - "ti-ER", - "ti-ET", - "tig-ER", - "tk-TM", - "tl-PH", - "tn-ZA", - "to", - "to-TO", - "tr", - "tr-CY", - "tr-TR", - "ts-ZA", - "tt-RU", - "tzm", - "tzm-Latn", - "tzm-Latn-MA", - "ug-CN", - "uk", - "uk-UA", - "unm-US", - "ur", - "ur-IN", - "ur-PK", - "uz", - "uz-Arab", - "uz-Arab-AF", - "uz-Cyrl", - "uz-Cyrl-UZ", - "uz-Latn", - "uz-Latn-UZ", - "uz-UZ", - "ve-ZA", - "vi", - "vi-VN", - "vun", - "vun-TZ", - "wa-BE", - "wae-CH", - "wal-ET", - "wo-SN", - "xh-ZA", - "xog", - "xog-UG", - "yi-US", - "yo", - "yo-NG", - "yue-HK", - "zh", - "zh-CN", - "zh-HK", - "zh-Hans", - "zh-Hans-CN", - "zh-Hans-HK", - "zh-Hans-MO", - "zh-Hans-SG", - "zh-Hant", - "zh-Hant-HK", - "zh-Hant-MO", - "zh-Hant-TW", - "zh-SG", - "zh-TW", - "zu", - "zu-ZA", - "auto", - ] - | Omit = omit, - markdown_backend: Literal["full_page", "main_content"] | Omit = omit, - method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, - network_capture: Iterable[client_extract_async_params.NetworkCapture] | Omit = omit, - os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, - parse: bool | Omit = omit, - parser: Union[Dict[str, object], str] | Omit = omit, - referrer_type: Literal[ - "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" - ] - | Omit = omit, - render: Union[bool, Literal["auto"]] | Omit = omit, - request_timeout: float | Omit = omit, - session: client_extract_async_params.Session | Omit = omit, - skill: Union[str, SequenceNotStr[str]] | Omit = omit, - state: Literal[ - "AL", - "AK", - "AS", - "AZ", - "AR", - "CA", - "CO", - "CT", - "DE", - "DC", - "FL", - "GA", - "GU", - "HI", - "ID", - "IL", - "IN", - "IA", - "KS", - "KY", - "LA", - "ME", - "MD", - "MA", - "MI", - "MN", - "MS", - "MO", - "MT", - "NE", - "NV", - "NH", - "NJ", - "NM", - "NY", - "NC", - "ND", - "MP", - "OH", - "OK", - "OR", - "PA", - "PR", - "RI", - "SC", - "SD", - "TN", - "TX", - "UT", - "VT", - "VA", - "VI", - "WA", - "WV", - "WI", - "WY", - ] - | Omit = omit, - storage_compress: bool | Omit = omit, - storage_object_name: str | Omit = omit, - storage_type: str | Omit = omit, - storage_url: str | Omit = omit, - tag: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ExtractAsyncResponse: - """ - Extract Async Endpoint + body: object, + response: httpx.Response, + ) -> APIStatusError: + if response.status_code == 400: + return _exceptions.BadRequestError(err_msg, response=response, body=body) - Args: - url: Target URL to scrape + if response.status_code == 401: + return _exceptions.AuthenticationError(err_msg, response=response, body=body) + + if response.status_code == 403: + return _exceptions.PermissionDeniedError(err_msg, response=response, body=body) + + if response.status_code == 404: + return _exceptions.NotFoundError(err_msg, response=response, body=body) + + if response.status_code == 409: + return _exceptions.ConflictError(err_msg, response=response, body=body) + + if response.status_code == 422: + return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body) - auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of - attempts to spend on each candidate before advancing (0 skips it). Key order - defines the flow order. Providing it opts the request into 'auto' driver - selection. + if response.status_code == 429: + return _exceptions.RateLimitError(err_msg, response=response, body=body) - body: Request body for POST, PUT, PATCH methods + if response.status_code >= 500: + return _exceptions.InternalServerError(err_msg, response=response, body=body) + return APIStatusError(err_msg, response=response, body=body) - browser: Browser type to emulate - browser_actions: Array of browser automation actions to execute sequentially +class AsyncNimble(AsyncAPIClient): + # client options + api_key: str | None + client_source: str | None - callback_url: URL to call back when async operation completes + def __init__( + self, + *, + api_key: str | None = None, + client_source: str | None = None, + base_url: str | httpx.URL | None = None, + timeout: float | Timeout | None | NotGiven = not_given, + max_retries: int = DEFAULT_MAX_RETRIES, + default_headers: Mapping[str, str] | None = None, + default_query: Mapping[str, object] | None = None, + # Configure a custom httpx client. + # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`. + # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details. + http_client: httpx.AsyncClient | None = None, + # Enable or disable schema validation for data returned by the API. + # When enabled an error APIResponseValidationError is raised + # if the API responds with invalid data for the expected schema. + # + # This parameter may be removed or changed in the future. + # If you rely on this feature, please open a GitHub issue + # outlining your use-case to help us decide if it should be + # part of our public interface in the future. + _strict_response_validation: bool = False, + ) -> None: + """Construct a new async AsyncNimble client instance. - city: City for geolocation + This automatically infers the following arguments from their corresponding environment variables if they are not provided: + - `api_key` from `NIMBLE_API_KEY` + - `client_source` from `CLIENT_SOURCE` + """ + if api_key is None: + api_key = os.environ.get("NIMBLE_API_KEY") + self.api_key = api_key - consent_header: Whether to automatically handle cookie consent headers + if client_source is None: + client_source = os.environ.get("CLIENT_SOURCE") or "sdk" + self.client_source = client_source - cookies: Browser cookies as array of cookie objects + if base_url is None: + base_url = os.environ.get("NIMBLE_BASE_URL") + if base_url is None: + base_url = f"https://sdk.nimbleway.com" - country: Country code for geolocation and proxy selection + custom_headers_env = os.environ.get("NIMBLE_CUSTOM_HEADERS") + if custom_headers_env is not None: + parsed: dict[str, str] = {} + for line in custom_headers_env.split("\n"): + colon = line.find(":") + if colon >= 0: + parsed[line[:colon].strip()] = line[colon + 1 :].strip() + default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})} - device: Device type for browser emulation + super().__init__( + version=__version__, + base_url=base_url, + max_retries=max_retries, + timeout=timeout, + http_client=http_client, + custom_headers=default_headers, + custom_query=default_query, + _strict_response_validation=_strict_response_validation, + ) - driver: Browser driver to use + @cached_property + def extract(self) -> AsyncExtractResource: + from .resources.extract import AsyncExtractResource - expected_status_codes: Expected HTTP status codes for successful requests + return AsyncExtractResource(self) - formats: List of acceptable response formats in order of preference + @cached_property + def agents(self) -> AsyncAgentsResource: + from .resources.agents import AsyncAgentsResource - headers: Custom HTTP headers to include in the request + return AsyncAgentsResource(self) - http2: Whether to use HTTP/2 protocol + @cached_property + def crawl(self) -> AsyncCrawlResource: + from .resources.crawl import AsyncCrawlResource - is_xhr: Whether to emulate XMLHttpRequest behavior + return AsyncCrawlResource(self) - locale: Locale for browser language and region settings + @cached_property + def tasks(self) -> AsyncTasksResource: + from .resources.tasks import AsyncTasksResource - markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the - entire HTML page. "main_content" uses Mozilla Readability to extract the main - article content before converting. + return AsyncTasksResource(self) - method: HTTP method for the request + @cached_property + def batches(self) -> AsyncBatchesResource: + from .resources.batches import AsyncBatchesResource - network_capture: Filters for capturing network traffic + return AsyncBatchesResource(self) - os: Operating system to emulate + @cached_property + def domain_knowledge(self) -> AsyncDomainKnowledgeResource: + from .resources.domain_knowledge import AsyncDomainKnowledgeResource - parse: Whether to parse the response content + return AsyncDomainKnowledgeResource(self) - parser: Custom parser configuration as a key-value map + @cached_property + def media(self) -> AsyncMediaResource: + from .resources.media import AsyncMediaResource - referrer_type: Referrer policy for the request + return AsyncMediaResource(self) - render: Whether to render JavaScript content using a browser + @cached_property + def serp(self) -> AsyncSerpResource: + from .resources.serp import AsyncSerpResource - request_timeout: Request timeout in milliseconds + return AsyncSerpResource(self) - skill: Skills or capabilities required for the request + @cached_property + def fast_serp(self) -> AsyncFastSerpResource: + from .resources.fast_serp import AsyncFastSerpResource - state: US state for geolocation (only valid when country is US) + return AsyncFastSerpResource(self) - storage_compress: Whether to compress stored data + @cached_property + def jobs(self) -> AsyncJobsResource: + from .resources.jobs import AsyncJobsResource - storage_object_name: Custom name for the stored object + return AsyncJobsResource(self) - storage_type: Type of storage to use for results + @cached_property + def with_raw_response(self) -> AsyncNimbleWithRawResponse: + return AsyncNimbleWithRawResponse(self) - storage_url: URL for storage location + @cached_property + def with_streaming_response(self) -> AsyncNimbleWithStreamedResponse: + return AsyncNimbleWithStreamedResponse(self) - tag: User-defined tag for request identification + @property + @override + def qs(self) -> Querystring: + return Querystring(array_format="comma") - extra_headers: Send extra headers + @property + @override + def auth_headers(self) -> dict[str, str]: + api_key = self.api_key + if api_key is None: + return {} + return {"Authorization": f"Bearer {api_key}"} - extra_query: Add additional query parameters to the request + @property + @override + def default_headers(self) -> dict[str, str | Omit]: + return { + **super().default_headers, + "X-Stainless-Async": f"async:{get_async_library()}", + "X-Client-Source": self.client_source if self.client_source is not None else Omit(), + **self._custom_headers, + } - extra_body: Add additional JSON properties to the request + @override + def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None: + if headers.get("Authorization") or isinstance(custom_headers.get("Authorization"), Omit): + return - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self.post( - "/v1/extract/async", - body=await async_maybe_transform( - { - "url": url, - "auto_driver_configuration": auto_driver_configuration, - "body": body, - "browser": browser, - "browser_actions": browser_actions, - "callback_url": callback_url, - "city": city, - "consent_header": consent_header, - "cookies": cookies, - "country": country, - "device": device, - "driver": driver, - "expected_status_codes": expected_status_codes, - "formats": formats, - "headers": headers, - "http2": http2, - "is_xhr": is_xhr, - "locale": locale, - "markdown_backend": markdown_backend, - "method": method, - "network_capture": network_capture, - "os": os, - "parse": parse, - "parser": parser, - "referrer_type": referrer_type, - "render": render, - "request_timeout": request_timeout, - "session": session, - "skill": skill, - "state": state, - "storage_compress": storage_compress, - "storage_object_name": storage_object_name, - "storage_type": storage_type, - "storage_url": storage_url, - "tag": tag, - }, - client_extract_async_params.ClientExtractAsyncParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ExtractAsyncResponse, + raise TypeError( + '"Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted"' ) - async def extract_batch( + def copy( self, *, - inputs: Iterable[client_extract_batch_params.Input], - shared_inputs: client_extract_batch_params.SharedInputs | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ExtractBatchResponse: - """Extract Batch Endpoint - - Args: - inputs: Array of extraction requests. - - Each object can include extraction parameters and - async/storage settings. - - shared_inputs: Shared parameters applied to the entire batch. Can include extraction parameters - and async/storage settings. + api_key: str | None = None, + client_source: str | None = None, + base_url: str | httpx.URL | None = None, + timeout: float | Timeout | None | NotGiven = not_given, + http_client: httpx.AsyncClient | None = None, + max_retries: int | NotGiven = not_given, + default_headers: Mapping[str, str] | None = None, + set_default_headers: Mapping[str, str] | None = None, + default_query: Mapping[str, object] | None = None, + set_default_query: Mapping[str, object] | None = None, + _extra_kwargs: Mapping[str, Any] = {}, + ) -> Self: + """ + Create a new client instance re-using the same options given to the current client with optional overriding. + """ + if default_headers is not None and set_default_headers is not None: + raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive") - extra_headers: Send extra headers + if default_query is not None and set_default_query is not None: + raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive") - extra_query: Add additional query parameters to the request + headers = self._custom_headers + if default_headers is not None: + headers = {**headers, **default_headers} + elif set_default_headers is not None: + headers = set_default_headers - extra_body: Add additional JSON properties to the request + params = self._custom_query + if default_query is not None: + params = {**params, **default_query} + elif set_default_query is not None: + params = set_default_query - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self.post( - "/v1/extract/batch", - body=await async_maybe_transform( - { - "inputs": inputs, - "shared_inputs": shared_inputs, - }, - client_extract_batch_params.ClientExtractBatchParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ExtractBatchResponse, + http_client = http_client or self._client + return self.__class__( + api_key=api_key or self.api_key, + client_source=client_source or self.client_source, + base_url=base_url or self.base_url, + timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, + http_client=http_client, + max_retries=max_retries if is_given(max_retries) else self.max_retries, + default_headers=headers, + default_query=params, + **_extra_kwargs, ) + # Alias for `copy` for nicer inline usage, e.g. + # client.with_options(timeout=10).foo.create(...) + with_options = copy + async def map( self, *, @@ -6507,7 +2326,7 @@ async def map( timeout: Override the client-level default timeout for this request, in seconds """ return await self.post( - "/v1/map", + "/v2/map", body=await async_maybe_transform( { "url": url, @@ -6606,7 +2425,7 @@ async def search( timeout: Override the client-level default timeout for this request, in seconds """ return await self.post( - "/v1/search", + "/v2/search", body=await async_maybe_transform( { "query": query, @@ -6674,15 +2493,6 @@ class NimbleWithRawResponse: def __init__(self, client: Nimble) -> None: self._client = client - self.extract = to_raw_response_wrapper( - client.extract, - ) - self.extract_async = to_raw_response_wrapper( - client.extract_async, - ) - self.extract_batch = to_raw_response_wrapper( - client.extract_batch, - ) self.map = to_raw_response_wrapper( client.map, ) @@ -6691,10 +2501,16 @@ def __init__(self, client: Nimble) -> None: ) @cached_property - def agent(self) -> agent.AgentResourceWithRawResponse: - from .resources.agent import AgentResourceWithRawResponse + def extract(self) -> extract.ExtractResourceWithRawResponse: + from .resources.extract import ExtractResourceWithRawResponse + + return ExtractResourceWithRawResponse(self._client.extract) + + @cached_property + def agents(self) -> agents.AgentsResourceWithRawResponse: + from .resources.agents import AgentsResourceWithRawResponse - return AgentResourceWithRawResponse(self._client.agent) + return AgentsResourceWithRawResponse(self._client.agents) @cached_property def crawl(self) -> crawl.CrawlResourceWithRawResponse: @@ -6738,12 +2554,6 @@ def fast_serp(self) -> fast_serp.FastSerpResourceWithRawResponse: return FastSerpResourceWithRawResponse(self._client.fast_serp) - @cached_property - def task_agent(self) -> task_agent.TaskAgentResourceWithRawResponse: - from .resources.task_agent import TaskAgentResourceWithRawResponse - - return TaskAgentResourceWithRawResponse(self._client.task_agent) - @cached_property def jobs(self) -> jobs.JobsResourceWithRawResponse: from .resources.jobs import JobsResourceWithRawResponse @@ -6757,15 +2567,6 @@ class AsyncNimbleWithRawResponse: def __init__(self, client: AsyncNimble) -> None: self._client = client - self.extract = async_to_raw_response_wrapper( - client.extract, - ) - self.extract_async = async_to_raw_response_wrapper( - client.extract_async, - ) - self.extract_batch = async_to_raw_response_wrapper( - client.extract_batch, - ) self.map = async_to_raw_response_wrapper( client.map, ) @@ -6774,10 +2575,16 @@ def __init__(self, client: AsyncNimble) -> None: ) @cached_property - def agent(self) -> agent.AsyncAgentResourceWithRawResponse: - from .resources.agent import AsyncAgentResourceWithRawResponse + def extract(self) -> extract.AsyncExtractResourceWithRawResponse: + from .resources.extract import AsyncExtractResourceWithRawResponse - return AsyncAgentResourceWithRawResponse(self._client.agent) + return AsyncExtractResourceWithRawResponse(self._client.extract) + + @cached_property + def agents(self) -> agents.AsyncAgentsResourceWithRawResponse: + from .resources.agents import AsyncAgentsResourceWithRawResponse + + return AsyncAgentsResourceWithRawResponse(self._client.agents) @cached_property def crawl(self) -> crawl.AsyncCrawlResourceWithRawResponse: @@ -6821,12 +2628,6 @@ def fast_serp(self) -> fast_serp.AsyncFastSerpResourceWithRawResponse: return AsyncFastSerpResourceWithRawResponse(self._client.fast_serp) - @cached_property - def task_agent(self) -> task_agent.AsyncTaskAgentResourceWithRawResponse: - from .resources.task_agent import AsyncTaskAgentResourceWithRawResponse - - return AsyncTaskAgentResourceWithRawResponse(self._client.task_agent) - @cached_property def jobs(self) -> jobs.AsyncJobsResourceWithRawResponse: from .resources.jobs import AsyncJobsResourceWithRawResponse @@ -6840,15 +2641,6 @@ class NimbleWithStreamedResponse: def __init__(self, client: Nimble) -> None: self._client = client - self.extract = to_streamed_response_wrapper( - client.extract, - ) - self.extract_async = to_streamed_response_wrapper( - client.extract_async, - ) - self.extract_batch = to_streamed_response_wrapper( - client.extract_batch, - ) self.map = to_streamed_response_wrapper( client.map, ) @@ -6857,10 +2649,16 @@ def __init__(self, client: Nimble) -> None: ) @cached_property - def agent(self) -> agent.AgentResourceWithStreamingResponse: - from .resources.agent import AgentResourceWithStreamingResponse + def extract(self) -> extract.ExtractResourceWithStreamingResponse: + from .resources.extract import ExtractResourceWithStreamingResponse + + return ExtractResourceWithStreamingResponse(self._client.extract) + + @cached_property + def agents(self) -> agents.AgentsResourceWithStreamingResponse: + from .resources.agents import AgentsResourceWithStreamingResponse - return AgentResourceWithStreamingResponse(self._client.agent) + return AgentsResourceWithStreamingResponse(self._client.agents) @cached_property def crawl(self) -> crawl.CrawlResourceWithStreamingResponse: @@ -6904,12 +2702,6 @@ def fast_serp(self) -> fast_serp.FastSerpResourceWithStreamingResponse: return FastSerpResourceWithStreamingResponse(self._client.fast_serp) - @cached_property - def task_agent(self) -> task_agent.TaskAgentResourceWithStreamingResponse: - from .resources.task_agent import TaskAgentResourceWithStreamingResponse - - return TaskAgentResourceWithStreamingResponse(self._client.task_agent) - @cached_property def jobs(self) -> jobs.JobsResourceWithStreamingResponse: from .resources.jobs import JobsResourceWithStreamingResponse @@ -6923,15 +2715,6 @@ class AsyncNimbleWithStreamedResponse: def __init__(self, client: AsyncNimble) -> None: self._client = client - self.extract = async_to_streamed_response_wrapper( - client.extract, - ) - self.extract_async = async_to_streamed_response_wrapper( - client.extract_async, - ) - self.extract_batch = async_to_streamed_response_wrapper( - client.extract_batch, - ) self.map = async_to_streamed_response_wrapper( client.map, ) @@ -6940,10 +2723,16 @@ def __init__(self, client: AsyncNimble) -> None: ) @cached_property - def agent(self) -> agent.AsyncAgentResourceWithStreamingResponse: - from .resources.agent import AsyncAgentResourceWithStreamingResponse + def extract(self) -> extract.AsyncExtractResourceWithStreamingResponse: + from .resources.extract import AsyncExtractResourceWithStreamingResponse + + return AsyncExtractResourceWithStreamingResponse(self._client.extract) + + @cached_property + def agents(self) -> agents.AsyncAgentsResourceWithStreamingResponse: + from .resources.agents import AsyncAgentsResourceWithStreamingResponse - return AsyncAgentResourceWithStreamingResponse(self._client.agent) + return AsyncAgentsResourceWithStreamingResponse(self._client.agents) @cached_property def crawl(self) -> crawl.AsyncCrawlResourceWithStreamingResponse: @@ -6987,12 +2776,6 @@ def fast_serp(self) -> fast_serp.AsyncFastSerpResourceWithStreamingResponse: return AsyncFastSerpResourceWithStreamingResponse(self._client.fast_serp) - @cached_property - def task_agent(self) -> task_agent.AsyncTaskAgentResourceWithStreamingResponse: - from .resources.task_agent import AsyncTaskAgentResourceWithStreamingResponse - - return AsyncTaskAgentResourceWithStreamingResponse(self._client.task_agent) - @cached_property def jobs(self) -> jobs.AsyncJobsResourceWithStreamingResponse: from .resources.jobs import AsyncJobsResourceWithStreamingResponse diff --git a/src/nimble_python/_version.py b/src/nimble_python/_version.py index d894720..e878efd 100644 --- a/src/nimble_python/_version.py +++ b/src/nimble_python/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "nimble_python" -__version__ = "0.24.0" # x-release-please-version +__version__ = "1.0.0" # x-release-please-version diff --git a/src/nimble_python/resources/__init__.py b/src/nimble_python/resources/__init__.py index d02196e..efc2645 100644 --- a/src/nimble_python/resources/__init__.py +++ b/src/nimble_python/resources/__init__.py @@ -16,14 +16,6 @@ SerpResourceWithStreamingResponse, AsyncSerpResourceWithStreamingResponse, ) -from .agent import ( - AgentResource, - AsyncAgentResource, - AgentResourceWithRawResponse, - AsyncAgentResourceWithRawResponse, - AgentResourceWithStreamingResponse, - AsyncAgentResourceWithStreamingResponse, -) from .crawl import ( CrawlResource, AsyncCrawlResource, @@ -48,6 +40,14 @@ TasksResourceWithStreamingResponse, AsyncTasksResourceWithStreamingResponse, ) +from .agents import ( + AgentsResource, + AsyncAgentsResource, + AgentsResourceWithRawResponse, + AsyncAgentsResourceWithRawResponse, + AgentsResourceWithStreamingResponse, + AsyncAgentsResourceWithStreamingResponse, +) from .batches import ( BatchesResource, AsyncBatchesResource, @@ -56,6 +56,14 @@ BatchesResourceWithStreamingResponse, AsyncBatchesResourceWithStreamingResponse, ) +from .extract import ( + ExtractResource, + AsyncExtractResource, + ExtractResourceWithRawResponse, + AsyncExtractResourceWithRawResponse, + ExtractResourceWithStreamingResponse, + AsyncExtractResourceWithStreamingResponse, +) from .fast_serp import ( FastSerpResource, AsyncFastSerpResource, @@ -64,14 +72,6 @@ FastSerpResourceWithStreamingResponse, AsyncFastSerpResourceWithStreamingResponse, ) -from .task_agent import ( - TaskAgentResource, - AsyncTaskAgentResource, - TaskAgentResourceWithRawResponse, - AsyncTaskAgentResourceWithRawResponse, - TaskAgentResourceWithStreamingResponse, - AsyncTaskAgentResourceWithStreamingResponse, -) from .domain_knowledge import ( DomainKnowledgeResource, AsyncDomainKnowledgeResource, @@ -82,12 +82,18 @@ ) __all__ = [ - "AgentResource", - "AsyncAgentResource", - "AgentResourceWithRawResponse", - "AsyncAgentResourceWithRawResponse", - "AgentResourceWithStreamingResponse", - "AsyncAgentResourceWithStreamingResponse", + "ExtractResource", + "AsyncExtractResource", + "ExtractResourceWithRawResponse", + "AsyncExtractResourceWithRawResponse", + "ExtractResourceWithStreamingResponse", + "AsyncExtractResourceWithStreamingResponse", + "AgentsResource", + "AsyncAgentsResource", + "AgentsResourceWithRawResponse", + "AsyncAgentsResourceWithRawResponse", + "AgentsResourceWithStreamingResponse", + "AsyncAgentsResourceWithStreamingResponse", "CrawlResource", "AsyncCrawlResource", "CrawlResourceWithRawResponse", @@ -130,12 +136,6 @@ "AsyncFastSerpResourceWithRawResponse", "FastSerpResourceWithStreamingResponse", "AsyncFastSerpResourceWithStreamingResponse", - "TaskAgentResource", - "AsyncTaskAgentResource", - "TaskAgentResourceWithRawResponse", - "AsyncTaskAgentResourceWithRawResponse", - "TaskAgentResourceWithStreamingResponse", - "AsyncTaskAgentResourceWithStreamingResponse", "JobsResource", "AsyncJobsResource", "JobsResourceWithRawResponse", diff --git a/src/nimble_python/resources/task_agent/__init__.py b/src/nimble_python/resources/agents/__init__.py similarity index 67% rename from src/nimble_python/resources/task_agent/__init__.py rename to src/nimble_python/resources/agents/__init__.py index 3d0c921..f89a446 100644 --- a/src/nimble_python/resources/task_agent/__init__.py +++ b/src/nimble_python/resources/agents/__init__.py @@ -8,6 +8,14 @@ RunsResourceWithStreamingResponse, AsyncRunsResourceWithStreamingResponse, ) +from .agents import ( + AgentsResource, + AsyncAgentsResource, + AgentsResourceWithRawResponse, + AsyncAgentsResourceWithRawResponse, + AgentsResourceWithStreamingResponse, + AsyncAgentsResourceWithStreamingResponse, +) from .templates import ( TemplatesResource, AsyncTemplatesResource, @@ -16,14 +24,6 @@ TemplatesResourceWithStreamingResponse, AsyncTemplatesResourceWithStreamingResponse, ) -from .task_agent import ( - TaskAgentResource, - AsyncTaskAgentResource, - TaskAgentResourceWithRawResponse, - AsyncTaskAgentResourceWithRawResponse, - TaskAgentResourceWithStreamingResponse, - AsyncTaskAgentResourceWithStreamingResponse, -) __all__ = [ "TemplatesResource", @@ -38,10 +38,10 @@ "AsyncRunsResourceWithRawResponse", "RunsResourceWithStreamingResponse", "AsyncRunsResourceWithStreamingResponse", - "TaskAgentResource", - "AsyncTaskAgentResource", - "TaskAgentResourceWithRawResponse", - "AsyncTaskAgentResourceWithRawResponse", - "TaskAgentResourceWithStreamingResponse", - "AsyncTaskAgentResourceWithStreamingResponse", + "AgentsResource", + "AsyncAgentsResource", + "AgentsResourceWithRawResponse", + "AsyncAgentsResourceWithRawResponse", + "AgentsResourceWithStreamingResponse", + "AsyncAgentsResourceWithStreamingResponse", ] diff --git a/src/nimble_python/resources/task_agent/task_agent.py b/src/nimble_python/resources/agents/agents.py similarity index 55% rename from src/nimble_python/resources/task_agent/task_agent.py rename to src/nimble_python/resources/agents/agents.py index 0a8db8a..4bbe463 100644 --- a/src/nimble_python/resources/task_agent/task_agent.py +++ b/src/nimble_python/resources/agents/agents.py @@ -2,8 +2,7 @@ from __future__ import annotations -import typing_extensions -from typing import Dict, Union, Iterable, Optional +from typing import Dict, Iterable, Optional from typing_extensions import Literal import httpx @@ -16,7 +15,7 @@ RunsResourceWithStreamingResponse, AsyncRunsResourceWithStreamingResponse, ) -from ...types import task_agent_run_params, task_agent_list_params, task_agent_create_params, task_agent_update_params +from ...types import agent_list_params, agent_create_params, agent_update_params from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property @@ -36,16 +35,15 @@ async_to_streamed_response_wrapper, ) from ..._base_client import make_request_options -from ...types.task_agent_get_response import TaskAgentGetResponse -from ...types.task_agent_run_response import TaskAgentRunResponse -from ...types.task_agent_list_response import TaskAgentListResponse -from ...types.task_agent_create_response import TaskAgentCreateResponse -from ...types.task_agent_update_response import TaskAgentUpdateResponse +from ...types.agent_get_response import AgentGetResponse +from ...types.agent_list_response import AgentListResponse +from ...types.agent_create_response import AgentCreateResponse +from ...types.agent_update_response import AgentUpdateResponse -__all__ = ["TaskAgentResource", "AsyncTaskAgentResource"] +__all__ = ["AgentsResource", "AsyncAgentsResource"] -class TaskAgentResource(SyncAPIResource): +class AgentsResource(SyncAPIResource): @cached_property def templates(self) -> TemplatesResource: return TemplatesResource(self._client) @@ -55,25 +53,24 @@ def runs(self) -> RunsResource: return RunsResource(self._client) @cached_property - def with_raw_response(self) -> TaskAgentResourceWithRawResponse: + def with_raw_response(self) -> AgentsResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers """ - return TaskAgentResourceWithRawResponse(self) + return AgentsResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> TaskAgentResourceWithStreamingResponse: + def with_streaming_response(self) -> AgentsResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response """ - return TaskAgentResourceWithStreamingResponse(self) + return AgentsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") def create( self, *, @@ -86,7 +83,7 @@ def create( icon: Optional[str] | Omit = omit, is_active: bool | Omit = omit, output_schema: Optional[Dict[str, object]] | Omit = omit, - sources: task_agent_create_params.Sources | Omit = omit, + sources: agent_create_params.Sources | Omit = omit, suggested_questions: SequenceNotStr[str] | Omit = omit, template: Optional[str] | Omit = omit, use_case: Optional[Literal["research", "enrichment", "dataset_building"]] | Omit = omit, @@ -96,11 +93,13 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentCreateResponse: - """ - Create a Web Search Agent instance. + ) -> AgentCreateResponse: + """Create a Web Search Agent. - `account_id` is JWT-derived and never read from the request body. + Either pass `template` to materialize a pre-built + template (its fields, goals, sources, and suggested questions are copied), or + define the agent from scratch with `display_name`, `goals`, `sources`, and an + optional `output_schema` for structured results. Args: agent_name: Stable agent name. @@ -139,7 +138,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/task-agents", + "/v2/agents", body=maybe_transform( { "agent_name": agent_name, @@ -156,29 +155,32 @@ def create( "template": template, "use_case": use_case, }, - task_agent_create_params.TaskAgentCreateParams, + agent_create_params.AgentCreateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=TaskAgentCreateResponse, + cast_to=AgentCreateResponse, ) - @typing_extensions.deprecated("deprecated") def update( self, agent_id: str, *, - body: Iterable[task_agent_update_params.Body], + body: Iterable[agent_update_params.Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentUpdateResponse: + ) -> AgentUpdateResponse: """ - Update Agent + Update an agent with a + [JSON Patch](https://datatracker.ietf.org/doc/html/rfc6902) document — an array + of `{op, path, value}` operations applied to the agent, e.g. + `[{"op": "replace", "path": "/display_name", "value": "My agent"}]`. Returns the + updated agent. Args: body: A JSON Patch document per RFC 6902 — a JSON array of patch operations. @@ -194,15 +196,14 @@ def update( if not agent_id: raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") return self._patch( - path_template("/v1/task-agents/{agent_id}", agent_id=agent_id), - body=maybe_transform(body, Iterable[task_agent_update_params.Body]), + path_template("/v2/agents/{agent_id}", agent_id=agent_id), + body=maybe_transform(body, Iterable[agent_update_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=TaskAgentUpdateResponse, + cast_to=AgentUpdateResponse, ) - @typing_extensions.deprecated("deprecated") def list( self, *, @@ -215,12 +216,12 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentListResponse: - """ - List Web Search Agent instances. + ) -> AgentListResponse: + """List the active Web Search Agents in your account. - Callers are strictly scoped to their (account, workspace). If `workspace_id` is - omitted, the user's default workspace is used. + Results are scoped to the + workspace resolved from your token (or the optional `workspace_id` query + parameter) and paginated with `offset`/`limit`. Args: extra_headers: Send extra headers @@ -232,7 +233,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/task-agents", + "/v2/agents", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -244,14 +245,13 @@ def list( "offset": offset, "workspace_id": workspace_id, }, - task_agent_list_params.TaskAgentListParams, + agent_list_params.AgentListParams, ), ), - cast_to=TaskAgentListResponse, + cast_to=AgentListResponse, ) - @typing_extensions.deprecated("deprecated") - def deactivate( + def delete( self, agent_id: str, *, @@ -262,8 +262,10 @@ def deactivate( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: - """ - Deactivate Agent + """Deactivate an agent. + + This is a soft delete: the agent can no longer start new + runs, but its existing runs and their results remain retrievable. Args: extra_headers: Send extra headers @@ -278,14 +280,13 @@ def deactivate( raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - path_template("/v1/task-agents/{agent_id}", agent_id=agent_id), + path_template("/v2/agents/{agent_id}", agent_id=agent_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) - @typing_extensions.deprecated("deprecated") def get( self, agent_id: str, @@ -296,9 +297,9 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentGetResponse: + ) -> AgentGetResponse: """ - Get Agent + Retrieve a single Web Search Agent by ID. Args: extra_headers: Send extra headers @@ -312,83 +313,15 @@ def get( if not agent_id: raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") return self._get( - path_template("/v1/task-agents/{agent_id}", agent_id=agent_id), + path_template("/v2/agents/{agent_id}", agent_id=agent_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=TaskAgentGetResponse, + cast_to=AgentGetResponse, ) - @typing_extensions.deprecated("deprecated") - def run( - self, - agent_id: str, - *, - input: str, - effort: Optional[Literal["low", "medium", "high", "x-high", "max"]] | Omit = omit, - enable_events: bool | Omit = omit, - input_data: Union[Iterable[Dict[str, object]], Dict[str, object], None] | Omit = omit, - output_schema: Optional[Dict[str, object]] | Omit = omit, - previous_interaction_id: Optional[str] | Omit = omit, - sources: Optional[task_agent_run_params.Sources] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentRunResponse: - """ - Create a research run for a Web Search Agent instance. - - Args: - input: User prompt or task instructions for the run. - - effort: Canonical effort tier names for the research graph. - - enable_events: Whether to stream run events when supported. - - input_data: Existing records to ENRICH: a list of partial rows, or a single object, - mirroring output_schema's shape. - - output_schema: JSON schema overriding the agent's default structured output for this run. - - previous_interaction_id: Previous interaction identifier used to continue a conversation. - - sources: Source guidance overriding the agent default. - - extra_headers: Send extra headers - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_id: - raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") - return self._post( - path_template("/v1/task-agents/{agent_id}/runs", agent_id=agent_id), - body=maybe_transform( - { - "input": input, - "effort": effort, - "enable_events": enable_events, - "input_data": input_data, - "output_schema": output_schema, - "previous_interaction_id": previous_interaction_id, - "sources": sources, - }, - task_agent_run_params.TaskAgentRunParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=TaskAgentRunResponse, - ) - - -class AsyncTaskAgentResource(AsyncAPIResource): +class AsyncAgentsResource(AsyncAPIResource): @cached_property def templates(self) -> AsyncTemplatesResource: return AsyncTemplatesResource(self._client) @@ -398,25 +331,24 @@ def runs(self) -> AsyncRunsResource: return AsyncRunsResource(self._client) @cached_property - def with_raw_response(self) -> AsyncTaskAgentResourceWithRawResponse: + def with_raw_response(self) -> AsyncAgentsResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers """ - return AsyncTaskAgentResourceWithRawResponse(self) + return AsyncAgentsResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncTaskAgentResourceWithStreamingResponse: + def with_streaming_response(self) -> AsyncAgentsResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response """ - return AsyncTaskAgentResourceWithStreamingResponse(self) + return AsyncAgentsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") async def create( self, *, @@ -429,7 +361,7 @@ async def create( icon: Optional[str] | Omit = omit, is_active: bool | Omit = omit, output_schema: Optional[Dict[str, object]] | Omit = omit, - sources: task_agent_create_params.Sources | Omit = omit, + sources: agent_create_params.Sources | Omit = omit, suggested_questions: SequenceNotStr[str] | Omit = omit, template: Optional[str] | Omit = omit, use_case: Optional[Literal["research", "enrichment", "dataset_building"]] | Omit = omit, @@ -439,11 +371,13 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentCreateResponse: - """ - Create a Web Search Agent instance. + ) -> AgentCreateResponse: + """Create a Web Search Agent. - `account_id` is JWT-derived and never read from the request body. + Either pass `template` to materialize a pre-built + template (its fields, goals, sources, and suggested questions are copied), or + define the agent from scratch with `display_name`, `goals`, `sources`, and an + optional `output_schema` for structured results. Args: agent_name: Stable agent name. @@ -482,7 +416,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/task-agents", + "/v2/agents", body=await async_maybe_transform( { "agent_name": agent_name, @@ -499,29 +433,32 @@ async def create( "template": template, "use_case": use_case, }, - task_agent_create_params.TaskAgentCreateParams, + agent_create_params.AgentCreateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=TaskAgentCreateResponse, + cast_to=AgentCreateResponse, ) - @typing_extensions.deprecated("deprecated") async def update( self, agent_id: str, *, - body: Iterable[task_agent_update_params.Body], + body: Iterable[agent_update_params.Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentUpdateResponse: + ) -> AgentUpdateResponse: """ - Update Agent + Update an agent with a + [JSON Patch](https://datatracker.ietf.org/doc/html/rfc6902) document — an array + of `{op, path, value}` operations applied to the agent, e.g. + `[{"op": "replace", "path": "/display_name", "value": "My agent"}]`. Returns the + updated agent. Args: body: A JSON Patch document per RFC 6902 — a JSON array of patch operations. @@ -537,15 +474,14 @@ async def update( if not agent_id: raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") return await self._patch( - path_template("/v1/task-agents/{agent_id}", agent_id=agent_id), - body=await async_maybe_transform(body, Iterable[task_agent_update_params.Body]), + path_template("/v2/agents/{agent_id}", agent_id=agent_id), + body=await async_maybe_transform(body, Iterable[agent_update_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=TaskAgentUpdateResponse, + cast_to=AgentUpdateResponse, ) - @typing_extensions.deprecated("deprecated") async def list( self, *, @@ -558,12 +494,12 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentListResponse: - """ - List Web Search Agent instances. + ) -> AgentListResponse: + """List the active Web Search Agents in your account. - Callers are strictly scoped to their (account, workspace). If `workspace_id` is - omitted, the user's default workspace is used. + Results are scoped to the + workspace resolved from your token (or the optional `workspace_id` query + parameter) and paginated with `offset`/`limit`. Args: extra_headers: Send extra headers @@ -575,7 +511,7 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/task-agents", + "/v2/agents", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -587,14 +523,13 @@ async def list( "offset": offset, "workspace_id": workspace_id, }, - task_agent_list_params.TaskAgentListParams, + agent_list_params.AgentListParams, ), ), - cast_to=TaskAgentListResponse, + cast_to=AgentListResponse, ) - @typing_extensions.deprecated("deprecated") - async def deactivate( + async def delete( self, agent_id: str, *, @@ -605,8 +540,10 @@ async def deactivate( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: - """ - Deactivate Agent + """Deactivate an agent. + + This is a soft delete: the agent can no longer start new + runs, but its existing runs and their results remain retrievable. Args: extra_headers: Send extra headers @@ -621,14 +558,13 @@ async def deactivate( raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - path_template("/v1/task-agents/{agent_id}", agent_id=agent_id), + path_template("/v2/agents/{agent_id}", agent_id=agent_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) - @typing_extensions.deprecated("deprecated") async def get( self, agent_id: str, @@ -639,9 +575,9 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentGetResponse: + ) -> AgentGetResponse: """ - Get Agent + Retrieve a single Web Search Agent by ID. Args: extra_headers: Send extra headers @@ -655,253 +591,125 @@ async def get( if not agent_id: raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") return await self._get( - path_template("/v1/task-agents/{agent_id}", agent_id=agent_id), + path_template("/v2/agents/{agent_id}", agent_id=agent_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=TaskAgentGetResponse, + cast_to=AgentGetResponse, ) - @typing_extensions.deprecated("deprecated") - async def run( - self, - agent_id: str, - *, - input: str, - effort: Optional[Literal["low", "medium", "high", "x-high", "max"]] | Omit = omit, - enable_events: bool | Omit = omit, - input_data: Union[Iterable[Dict[str, object]], Dict[str, object], None] | Omit = omit, - output_schema: Optional[Dict[str, object]] | Omit = omit, - previous_interaction_id: Optional[str] | Omit = omit, - sources: Optional[task_agent_run_params.Sources] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> TaskAgentRunResponse: - """ - Create a research run for a Web Search Agent instance. - Args: - input: User prompt or task instructions for the run. - - effort: Canonical effort tier names for the research graph. - - enable_events: Whether to stream run events when supported. - - input_data: Existing records to ENRICH: a list of partial rows, or a single object, - mirroring output_schema's shape. - - output_schema: JSON schema overriding the agent's default structured output for this run. - - previous_interaction_id: Previous interaction identifier used to continue a conversation. +class AgentsResourceWithRawResponse: + def __init__(self, agents: AgentsResource) -> None: + self._agents = agents - sources: Source guidance overriding the agent default. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_id: - raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") - return await self._post( - path_template("/v1/task-agents/{agent_id}/runs", agent_id=agent_id), - body=await async_maybe_transform( - { - "input": input, - "effort": effort, - "enable_events": enable_events, - "input_data": input_data, - "output_schema": output_schema, - "previous_interaction_id": previous_interaction_id, - "sources": sources, - }, - task_agent_run_params.TaskAgentRunParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=TaskAgentRunResponse, - ) - - -class TaskAgentResourceWithRawResponse: - def __init__(self, task_agent: TaskAgentResource) -> None: - self._task_agent = task_agent - - self.create = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - task_agent.create, # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - task_agent.update, # pyright: ignore[reportDeprecated], - ) + self.create = to_raw_response_wrapper( + agents.create, ) - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - task_agent.list, # pyright: ignore[reportDeprecated], - ) + self.update = to_raw_response_wrapper( + agents.update, ) - self.deactivate = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - task_agent.deactivate, # pyright: ignore[reportDeprecated], - ) + self.list = to_raw_response_wrapper( + agents.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - task_agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = to_raw_response_wrapper( + agents.delete, ) - self.run = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - task_agent.run, # pyright: ignore[reportDeprecated], - ) + self.get = to_raw_response_wrapper( + agents.get, ) @cached_property def templates(self) -> TemplatesResourceWithRawResponse: - return TemplatesResourceWithRawResponse(self._task_agent.templates) + return TemplatesResourceWithRawResponse(self._agents.templates) @cached_property def runs(self) -> RunsResourceWithRawResponse: - return RunsResourceWithRawResponse(self._task_agent.runs) + return RunsResourceWithRawResponse(self._agents.runs) -class AsyncTaskAgentResourceWithRawResponse: - def __init__(self, task_agent: AsyncTaskAgentResource) -> None: - self._task_agent = task_agent +class AsyncAgentsResourceWithRawResponse: + def __init__(self, agents: AsyncAgentsResource) -> None: + self._agents = agents - self.create = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - task_agent.create, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_raw_response_wrapper( + agents.create, ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - task_agent.update, # pyright: ignore[reportDeprecated], - ) + self.update = async_to_raw_response_wrapper( + agents.update, ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - task_agent.list, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_raw_response_wrapper( + agents.list, ) - self.deactivate = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - task_agent.deactivate, # pyright: ignore[reportDeprecated], - ) + self.delete = async_to_raw_response_wrapper( + agents.delete, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - task_agent.get, # pyright: ignore[reportDeprecated], - ) - ) - self.run = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - task_agent.run, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_raw_response_wrapper( + agents.get, ) @cached_property def templates(self) -> AsyncTemplatesResourceWithRawResponse: - return AsyncTemplatesResourceWithRawResponse(self._task_agent.templates) + return AsyncTemplatesResourceWithRawResponse(self._agents.templates) @cached_property def runs(self) -> AsyncRunsResourceWithRawResponse: - return AsyncRunsResourceWithRawResponse(self._task_agent.runs) + return AsyncRunsResourceWithRawResponse(self._agents.runs) -class TaskAgentResourceWithStreamingResponse: - def __init__(self, task_agent: TaskAgentResource) -> None: - self._task_agent = task_agent +class AgentsResourceWithStreamingResponse: + def __init__(self, agents: AgentsResource) -> None: + self._agents = agents - self.create = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - task_agent.create, # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - task_agent.update, # pyright: ignore[reportDeprecated], - ) + self.create = to_streamed_response_wrapper( + agents.create, ) - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - task_agent.list, # pyright: ignore[reportDeprecated], - ) + self.update = to_streamed_response_wrapper( + agents.update, ) - self.deactivate = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - task_agent.deactivate, # pyright: ignore[reportDeprecated], - ) + self.list = to_streamed_response_wrapper( + agents.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - task_agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = to_streamed_response_wrapper( + agents.delete, ) - self.run = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - task_agent.run, # pyright: ignore[reportDeprecated], - ) + self.get = to_streamed_response_wrapper( + agents.get, ) @cached_property def templates(self) -> TemplatesResourceWithStreamingResponse: - return TemplatesResourceWithStreamingResponse(self._task_agent.templates) + return TemplatesResourceWithStreamingResponse(self._agents.templates) @cached_property def runs(self) -> RunsResourceWithStreamingResponse: - return RunsResourceWithStreamingResponse(self._task_agent.runs) + return RunsResourceWithStreamingResponse(self._agents.runs) -class AsyncTaskAgentResourceWithStreamingResponse: - def __init__(self, task_agent: AsyncTaskAgentResource) -> None: - self._task_agent = task_agent +class AsyncAgentsResourceWithStreamingResponse: + def __init__(self, agents: AsyncAgentsResource) -> None: + self._agents = agents - self.create = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - task_agent.create, # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - task_agent.update, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_streamed_response_wrapper( + agents.create, ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - task_agent.list, # pyright: ignore[reportDeprecated], - ) + self.update = async_to_streamed_response_wrapper( + agents.update, ) - self.deactivate = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - task_agent.deactivate, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_streamed_response_wrapper( + agents.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - task_agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = async_to_streamed_response_wrapper( + agents.delete, ) - self.run = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - task_agent.run, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_streamed_response_wrapper( + agents.get, ) @cached_property def templates(self) -> AsyncTemplatesResourceWithStreamingResponse: - return AsyncTemplatesResourceWithStreamingResponse(self._task_agent.templates) + return AsyncTemplatesResourceWithStreamingResponse(self._agents.templates) @cached_property def runs(self) -> AsyncRunsResourceWithStreamingResponse: - return AsyncRunsResourceWithStreamingResponse(self._task_agent.runs) + return AsyncRunsResourceWithStreamingResponse(self._agents.runs) diff --git a/src/nimble_python/resources/task_agent/runs.py b/src/nimble_python/resources/agents/runs.py similarity index 54% rename from src/nimble_python/resources/task_agent/runs.py rename to src/nimble_python/resources/agents/runs.py index 0dd3ef0..9023f40 100644 --- a/src/nimble_python/resources/task_agent/runs.py +++ b/src/nimble_python/resources/agents/runs.py @@ -2,8 +2,8 @@ from __future__ import annotations -import typing_extensions -from typing import Any, cast +from typing import Any, Dict, Union, Iterable, Optional, cast +from typing_extensions import Literal import httpx @@ -18,10 +18,11 @@ async_to_streamed_response_wrapper, ) from ..._base_client import make_request_options -from ...types.task_agent import run_list_params -from ...types.task_agent.run_get_response import RunGetResponse -from ...types.task_agent.run_list_response import RunListResponse -from ...types.task_agent.run_get_result_response import RunGetResultResponse +from ...types.agents import run_list_params, run_create_params +from ...types.agents.run_get_response import RunGetResponse +from ...types.agents.run_list_response import RunListResponse +from ...types.agents.run_create_response import RunCreateResponse +from ...types.agents.run_result_response import RunResultResponse __all__ = ["RunsResource", "AsyncRunsResource"] @@ -46,7 +47,81 @@ def with_streaming_response(self) -> RunsResourceWithStreamingResponse: """ return RunsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") + def create( + self, + agent_id: str, + *, + input: str, + effort: Optional[Literal["low", "medium", "high", "x-high", "max"]] | Omit = omit, + enable_events: bool | Omit = omit, + input_data: Union[Iterable[Dict[str, object]], Dict[str, object], None] | Omit = omit, + output_schema: Optional[Dict[str, object]] | Omit = omit, + previous_interaction_id: Optional[str] | Omit = omit, + sources: Optional[run_create_params.Sources] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RunCreateResponse: + """Start an agent run. + + The run executes asynchronously: the response returns + immediately with status `queued`, then poll `GET .../runs/{run_id}` until + `completed` and fetch the output from `GET .../runs/{run_id}/result` — or set + `enable_events: true` and follow `GET .../runs/{run_id}/events` for live + progress. + + To enrich existing records instead of researching from scratch, pass them in + `input_data`; this requires an `output_schema` (on the request or the agent). + + Args: + input: User prompt or task instructions for the run. + + effort: Canonical effort tier names for the research graph. + + enable_events: Whether to stream run events when supported. + + input_data: Existing records to ENRICH: a list of partial rows, or a single object, + mirroring output_schema's shape. + + output_schema: JSON schema overriding the agent's default structured output for this run. + + previous_interaction_id: Previous interaction identifier used to continue a conversation. + + sources: Source guidance overriding the agent default. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_id: + raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") + return self._post( + path_template("/v2/agents/{agent_id}/runs", agent_id=agent_id), + body=maybe_transform( + { + "input": input, + "effort": effort, + "enable_events": enable_events, + "input_data": input_data, + "output_schema": output_schema, + "previous_interaction_id": previous_interaction_id, + "sources": sources, + }, + run_create_params.RunCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RunCreateResponse, + ) + def list( self, agent_id: str, @@ -61,10 +136,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunListResponse: """ - List runs for this instance. - - `status` accepts a lowercase `TaskRunStatusValue` (e.g. "completed") or a - comma-separated list of them (e.g. "queued,running"). + List the runs of an agent, newest first, paginated with `offset`/`limit`. Args: extra_headers: Send extra headers @@ -78,7 +150,7 @@ def list( if not agent_id: raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") return self._get( - path_template("/v1/task-agents/{agent_id}/runs", agent_id=agent_id), + path_template("/v2/agents/{agent_id}/runs", agent_id=agent_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -95,7 +167,6 @@ def list( cast_to=RunListResponse, ) - @typing_extensions.deprecated("deprecated") def get( self, run_id: str, @@ -108,12 +179,10 @@ def get( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunGetResponse: - """ - Fetch a run by id, scoped to the instance. + """Retrieve a run's current state. - A run resolves only when (run_id, agent_id) match — otherwise 404. This means a - stale URL with a swapped agent_id won't leak runs across instances even if the - run_id is real. + Poll this endpoint after creating a run: the run + is finished once `status` is `completed`, `failed`, or `cancelled`. Args: extra_headers: Send extra headers @@ -129,15 +198,14 @@ def get( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._get( - path_template("/v1/task-agents/{agent_id}/runs/{run_id}", agent_id=agent_id, run_id=run_id), + path_template("/v2/agents/{agent_id}/runs/{run_id}", agent_id=agent_id, run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=RunGetResponse, ) - @typing_extensions.deprecated("deprecated") - def get_result( + def result( self, run_id: str, *, @@ -148,16 +216,15 @@ def get_result( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> RunGetResultResponse: - """ - Fetch the result for a terminal run on this instance. + ) -> RunResultResponse: + """Fetch the output of a completed run. - Mirrors the previous flat `GET /tasks/runs/:run_id/result` semantics: + The `output` is `type: "text"` (a prose + answer) or `type: "json"` (structured data matching the output schema), plus + `trust` metadata with per-claim citations for the answer. - - 404 when the run doesn't belong to the agent. - - 408 when the run is still active. - - 422 (with TaskRunFailedResult body) when the run failed or was cancelled. - - 200 (with TaskRunResult body) on success. + While the run is still `queued` or `running` this endpoint returns `409`; if the + run `failed` or was `cancelled` it returns `422` with the run and error details. Args: extra_headers: Send extra headers @@ -173,19 +240,16 @@ def get_result( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return cast( - RunGetResultResponse, + RunResultResponse, self._get( - path_template("/v1/task-agents/{agent_id}/runs/{run_id}/result", agent_id=agent_id, run_id=run_id), + path_template("/v2/agents/{agent_id}/runs/{run_id}/result", agent_id=agent_id, run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast( - Any, RunGetResultResponse - ), # Union types cannot be passed in as arguments in the type system + cast_to=cast(Any, RunResultResponse), # Union types cannot be passed in as arguments in the type system ), ) - @typing_extensions.deprecated("deprecated") def stream_events( self, run_id: str, @@ -199,7 +263,10 @@ def stream_events( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ - SSE stream of real-time progress events for a run on this instance. + Stream a run's progress as + [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) + (`text/event-stream`). Create the run with `enable_events: true` to have events + published. A keep-alive comment is sent every 15 seconds. Args: extra_headers: Send extra headers @@ -216,7 +283,7 @@ def stream_events( raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( - path_template("/v1/task-agents/{agent_id}/runs/{run_id}/events", agent_id=agent_id, run_id=run_id), + path_template("/v2/agents/{agent_id}/runs/{run_id}/events", agent_id=agent_id, run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -244,7 +311,81 @@ def with_streaming_response(self) -> AsyncRunsResourceWithStreamingResponse: """ return AsyncRunsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") + async def create( + self, + agent_id: str, + *, + input: str, + effort: Optional[Literal["low", "medium", "high", "x-high", "max"]] | Omit = omit, + enable_events: bool | Omit = omit, + input_data: Union[Iterable[Dict[str, object]], Dict[str, object], None] | Omit = omit, + output_schema: Optional[Dict[str, object]] | Omit = omit, + previous_interaction_id: Optional[str] | Omit = omit, + sources: Optional[run_create_params.Sources] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RunCreateResponse: + """Start an agent run. + + The run executes asynchronously: the response returns + immediately with status `queued`, then poll `GET .../runs/{run_id}` until + `completed` and fetch the output from `GET .../runs/{run_id}/result` — or set + `enable_events: true` and follow `GET .../runs/{run_id}/events` for live + progress. + + To enrich existing records instead of researching from scratch, pass them in + `input_data`; this requires an `output_schema` (on the request or the agent). + + Args: + input: User prompt or task instructions for the run. + + effort: Canonical effort tier names for the research graph. + + enable_events: Whether to stream run events when supported. + + input_data: Existing records to ENRICH: a list of partial rows, or a single object, + mirroring output_schema's shape. + + output_schema: JSON schema overriding the agent's default structured output for this run. + + previous_interaction_id: Previous interaction identifier used to continue a conversation. + + sources: Source guidance overriding the agent default. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_id: + raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") + return await self._post( + path_template("/v2/agents/{agent_id}/runs", agent_id=agent_id), + body=await async_maybe_transform( + { + "input": input, + "effort": effort, + "enable_events": enable_events, + "input_data": input_data, + "output_schema": output_schema, + "previous_interaction_id": previous_interaction_id, + "sources": sources, + }, + run_create_params.RunCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RunCreateResponse, + ) + async def list( self, agent_id: str, @@ -259,10 +400,7 @@ async def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunListResponse: """ - List runs for this instance. - - `status` accepts a lowercase `TaskRunStatusValue` (e.g. "completed") or a - comma-separated list of them (e.g. "queued,running"). + List the runs of an agent, newest first, paginated with `offset`/`limit`. Args: extra_headers: Send extra headers @@ -276,7 +414,7 @@ async def list( if not agent_id: raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") return await self._get( - path_template("/v1/task-agents/{agent_id}/runs", agent_id=agent_id), + path_template("/v2/agents/{agent_id}/runs", agent_id=agent_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -293,7 +431,6 @@ async def list( cast_to=RunListResponse, ) - @typing_extensions.deprecated("deprecated") async def get( self, run_id: str, @@ -306,12 +443,10 @@ async def get( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunGetResponse: - """ - Fetch a run by id, scoped to the instance. + """Retrieve a run's current state. - A run resolves only when (run_id, agent_id) match — otherwise 404. This means a - stale URL with a swapped agent_id won't leak runs across instances even if the - run_id is real. + Poll this endpoint after creating a run: the run + is finished once `status` is `completed`, `failed`, or `cancelled`. Args: extra_headers: Send extra headers @@ -327,15 +462,14 @@ async def get( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._get( - path_template("/v1/task-agents/{agent_id}/runs/{run_id}", agent_id=agent_id, run_id=run_id), + path_template("/v2/agents/{agent_id}/runs/{run_id}", agent_id=agent_id, run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=RunGetResponse, ) - @typing_extensions.deprecated("deprecated") - async def get_result( + async def result( self, run_id: str, *, @@ -346,16 +480,15 @@ async def get_result( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> RunGetResultResponse: - """ - Fetch the result for a terminal run on this instance. + ) -> RunResultResponse: + """Fetch the output of a completed run. - Mirrors the previous flat `GET /tasks/runs/:run_id/result` semantics: + The `output` is `type: "text"` (a prose + answer) or `type: "json"` (structured data matching the output schema), plus + `trust` metadata with per-claim citations for the answer. - - 404 when the run doesn't belong to the agent. - - 408 when the run is still active. - - 422 (with TaskRunFailedResult body) when the run failed or was cancelled. - - 200 (with TaskRunResult body) on success. + While the run is still `queued` or `running` this endpoint returns `409`; if the + run `failed` or was `cancelled` it returns `422` with the run and error details. Args: extra_headers: Send extra headers @@ -371,19 +504,16 @@ async def get_result( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return cast( - RunGetResultResponse, + RunResultResponse, await self._get( - path_template("/v1/task-agents/{agent_id}/runs/{run_id}/result", agent_id=agent_id, run_id=run_id), + path_template("/v2/agents/{agent_id}/runs/{run_id}/result", agent_id=agent_id, run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast( - Any, RunGetResultResponse - ), # Union types cannot be passed in as arguments in the type system + cast_to=cast(Any, RunResultResponse), # Union types cannot be passed in as arguments in the type system ), ) - @typing_extensions.deprecated("deprecated") async def stream_events( self, run_id: str, @@ -397,7 +527,10 @@ async def stream_events( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ - SSE stream of real-time progress events for a run on this instance. + Stream a run's progress as + [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) + (`text/event-stream`). Create the run with `enable_events: true` to have events + published. A keep-alive comment is sent every 15 seconds. Args: extra_headers: Send extra headers @@ -414,7 +547,7 @@ async def stream_events( raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( - path_template("/v1/task-agents/{agent_id}/runs/{run_id}/events", agent_id=agent_id, run_id=run_id), + path_template("/v2/agents/{agent_id}/runs/{run_id}/events", agent_id=agent_id, run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -426,25 +559,20 @@ class RunsResourceWithRawResponse: def __init__(self, runs: RunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = to_raw_response_wrapper( + runs.create, + ) + self.list = to_raw_response_wrapper( + runs.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_raw_response_wrapper( + runs.get, ) - self.get_result = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.get_result, # pyright: ignore[reportDeprecated], - ) + self.result = to_raw_response_wrapper( + runs.result, ) - self.stream_events = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.stream_events, # pyright: ignore[reportDeprecated], - ) + self.stream_events = to_raw_response_wrapper( + runs.stream_events, ) @@ -452,25 +580,20 @@ class AsyncRunsResourceWithRawResponse: def __init__(self, runs: AsyncRunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_raw_response_wrapper( + runs.create, + ) + self.list = async_to_raw_response_wrapper( + runs.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_raw_response_wrapper( + runs.get, ) - self.get_result = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.get_result, # pyright: ignore[reportDeprecated], - ) + self.result = async_to_raw_response_wrapper( + runs.result, ) - self.stream_events = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.stream_events, # pyright: ignore[reportDeprecated], - ) + self.stream_events = async_to_raw_response_wrapper( + runs.stream_events, ) @@ -478,25 +601,20 @@ class RunsResourceWithStreamingResponse: def __init__(self, runs: RunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = to_streamed_response_wrapper( + runs.create, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.list = to_streamed_response_wrapper( + runs.list, ) - self.get_result = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.get_result, # pyright: ignore[reportDeprecated], - ) + self.get = to_streamed_response_wrapper( + runs.get, ) - self.stream_events = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.stream_events, # pyright: ignore[reportDeprecated], - ) + self.result = to_streamed_response_wrapper( + runs.result, + ) + self.stream_events = to_streamed_response_wrapper( + runs.stream_events, ) @@ -504,23 +622,18 @@ class AsyncRunsResourceWithStreamingResponse: def __init__(self, runs: AsyncRunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_streamed_response_wrapper( + runs.create, + ) + self.list = async_to_streamed_response_wrapper( + runs.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_streamed_response_wrapper( + runs.get, ) - self.get_result = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.get_result, # pyright: ignore[reportDeprecated], - ) + self.result = async_to_streamed_response_wrapper( + runs.result, ) - self.stream_events = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.stream_events, # pyright: ignore[reportDeprecated], - ) + self.stream_events = async_to_streamed_response_wrapper( + runs.stream_events, ) diff --git a/src/nimble_python/resources/task_agent/templates.py b/src/nimble_python/resources/agents/templates.py similarity index 78% rename from src/nimble_python/resources/task_agent/templates.py rename to src/nimble_python/resources/agents/templates.py index cca1383..80e7a59 100644 --- a/src/nimble_python/resources/task_agent/templates.py +++ b/src/nimble_python/resources/agents/templates.py @@ -2,8 +2,6 @@ from __future__ import annotations -import typing_extensions - import httpx from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given @@ -17,9 +15,9 @@ async_to_streamed_response_wrapper, ) from ..._base_client import make_request_options -from ...types.task_agent import template_list_params -from ...types.task_agent.template_get_response import TemplateGetResponse -from ...types.task_agent.template_list_response import TemplateListResponse +from ...types.agents import template_list_params +from ...types.agents.template_get_response import TemplateGetResponse +from ...types.agents.template_list_response import TemplateListResponse __all__ = ["TemplatesResource", "AsyncTemplatesResource"] @@ -44,7 +42,6 @@ def with_streaming_response(self) -> TemplatesResourceWithStreamingResponse: """ return TemplatesResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") def list( self, *, @@ -57,8 +54,10 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TemplateListResponse: - """ - List Templates + """List the pre-built agent templates available to your account. + + Use a template's + `template_name` with `POST /v2/agents` to create an agent instance from it. Args: extra_headers: Send extra headers @@ -70,7 +69,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/task-agents/templates", + "/v2/agents/templates", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -87,7 +86,6 @@ def list( cast_to=TemplateListResponse, ) - @typing_extensions.deprecated("deprecated") def get( self, template_name: str, @@ -100,7 +98,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TemplateGetResponse: """ - Get Template + Retrieve a single agent template by its stable `template_name`. Args: extra_headers: Send extra headers @@ -114,7 +112,7 @@ def get( if not template_name: raise ValueError(f"Expected a non-empty value for `template_name` but received {template_name!r}") return self._get( - path_template("/v1/task-agents/templates/{template_name}", template_name=template_name), + path_template("/v2/agents/templates/{template_name}", template_name=template_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -142,7 +140,6 @@ def with_streaming_response(self) -> AsyncTemplatesResourceWithStreamingResponse """ return AsyncTemplatesResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") async def list( self, *, @@ -155,8 +152,10 @@ async def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TemplateListResponse: - """ - List Templates + """List the pre-built agent templates available to your account. + + Use a template's + `template_name` with `POST /v2/agents` to create an agent instance from it. Args: extra_headers: Send extra headers @@ -168,7 +167,7 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/task-agents/templates", + "/v2/agents/templates", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -185,7 +184,6 @@ async def list( cast_to=TemplateListResponse, ) - @typing_extensions.deprecated("deprecated") async def get( self, template_name: str, @@ -198,7 +196,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TemplateGetResponse: """ - Get Template + Retrieve a single agent template by its stable `template_name`. Args: extra_headers: Send extra headers @@ -212,7 +210,7 @@ async def get( if not template_name: raise ValueError(f"Expected a non-empty value for `template_name` but received {template_name!r}") return await self._get( - path_template("/v1/task-agents/templates/{template_name}", template_name=template_name), + path_template("/v2/agents/templates/{template_name}", template_name=template_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -224,15 +222,11 @@ class TemplatesResourceWithRawResponse: def __init__(self, templates: TemplatesResource) -> None: self._templates = templates - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - templates.list, # pyright: ignore[reportDeprecated], - ) + self.list = to_raw_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - templates.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_raw_response_wrapper( + templates.get, ) @@ -240,15 +234,11 @@ class AsyncTemplatesResourceWithRawResponse: def __init__(self, templates: AsyncTemplatesResource) -> None: self._templates = templates - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - templates.list, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_raw_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - templates.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_raw_response_wrapper( + templates.get, ) @@ -256,15 +246,11 @@ class TemplatesResourceWithStreamingResponse: def __init__(self, templates: TemplatesResource) -> None: self._templates = templates - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - templates.list, # pyright: ignore[reportDeprecated], - ) + self.list = to_streamed_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - templates.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_streamed_response_wrapper( + templates.get, ) @@ -272,13 +258,9 @@ class AsyncTemplatesResourceWithStreamingResponse: def __init__(self, templates: AsyncTemplatesResource) -> None: self._templates = templates - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - templates.list, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_streamed_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - templates.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_streamed_response_wrapper( + templates.get, ) diff --git a/src/nimble_python/resources/batches.py b/src/nimble_python/resources/batches.py index 762410f..44a46fe 100644 --- a/src/nimble_python/resources/batches.py +++ b/src/nimble_python/resources/batches.py @@ -54,7 +54,7 @@ def list( """Retrieve a paginated list of batches for the authenticated account.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._get( - "/v1/batches", + "/v2/batches", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -89,7 +89,7 @@ def get( if not batch_id: raise ValueError(f"Expected a non-empty value for `batch_id` but received {batch_id!r}") return self._get( - path_template("/v1/batches/{batch_id}", batch_id=batch_id), + path_template("/v2/batches/{batch_id}", batch_id=batch_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -125,7 +125,7 @@ def progress( if not batch_id: raise ValueError(f"Expected a non-empty value for `batch_id` but received {batch_id!r}") return self._get( - path_template("/v1/batches/{batch_id}/progress", batch_id=batch_id), + path_template("/v2/batches/{batch_id}/progress", batch_id=batch_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -166,7 +166,7 @@ async def list( """Retrieve a paginated list of batches for the authenticated account.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._get( - "/v1/batches", + "/v2/batches", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -201,7 +201,7 @@ async def get( if not batch_id: raise ValueError(f"Expected a non-empty value for `batch_id` but received {batch_id!r}") return await self._get( - path_template("/v1/batches/{batch_id}", batch_id=batch_id), + path_template("/v2/batches/{batch_id}", batch_id=batch_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -237,7 +237,7 @@ async def progress( if not batch_id: raise ValueError(f"Expected a non-empty value for `batch_id` but received {batch_id!r}") return await self._get( - path_template("/v1/batches/{batch_id}/progress", batch_id=batch_id), + path_template("/v2/batches/{batch_id}/progress", batch_id=batch_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/nimble_python/resources/crawl.py b/src/nimble_python/resources/crawl.py index cc37139..84489dd 100644 --- a/src/nimble_python/resources/crawl.py +++ b/src/nimble_python/resources/crawl.py @@ -79,7 +79,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/crawl", + "/v2/crawl", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -158,7 +158,7 @@ def run( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/crawl", + "/v2/crawl", body=maybe_transform( { "url": url, @@ -211,7 +211,7 @@ def status( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return self._get( - path_template("/v1/crawl/{id}", id=id), + path_template("/v2/crawl/{id}", id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -246,7 +246,7 @@ def terminate( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return self._delete( - path_template("/v1/crawl/{id}", id=id), + path_template("/v2/crawl/{id}", id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -306,7 +306,7 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/crawl", + "/v2/crawl", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -385,7 +385,7 @@ async def run( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/crawl", + "/v2/crawl", body=await async_maybe_transform( { "url": url, @@ -438,7 +438,7 @@ async def status( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return await self._get( - path_template("/v1/crawl/{id}", id=id), + path_template("/v2/crawl/{id}", id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -473,7 +473,7 @@ async def terminate( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return await self._delete( - path_template("/v1/crawl/{id}", id=id), + path_template("/v2/crawl/{id}", id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/nimble_python/resources/domain_knowledge.py b/src/nimble_python/resources/domain_knowledge.py index accbf8c..0699bd6 100644 --- a/src/nimble_python/resources/domain_knowledge.py +++ b/src/nimble_python/resources/domain_knowledge.py @@ -72,7 +72,7 @@ def get_driver( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/domain-knowledge/driver", + "/v2/domain-knowledge/driver", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -141,7 +141,7 @@ async def get_driver( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/domain-knowledge/driver", + "/v2/domain-knowledge/driver", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/nimble_python/resources/extract/__init__.py b/src/nimble_python/resources/extract/__init__.py new file mode 100644 index 0000000..62893a2 --- /dev/null +++ b/src/nimble_python/resources/extract/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .extract import ( + ExtractResource, + AsyncExtractResource, + ExtractResourceWithRawResponse, + AsyncExtractResourceWithRawResponse, + ExtractResourceWithStreamingResponse, + AsyncExtractResourceWithStreamingResponse, +) +from .templates import ( + TemplatesResource, + AsyncTemplatesResource, + TemplatesResourceWithRawResponse, + AsyncTemplatesResourceWithRawResponse, + TemplatesResourceWithStreamingResponse, + AsyncTemplatesResourceWithStreamingResponse, +) + +__all__ = [ + "TemplatesResource", + "AsyncTemplatesResource", + "TemplatesResourceWithRawResponse", + "AsyncTemplatesResourceWithRawResponse", + "TemplatesResourceWithStreamingResponse", + "AsyncTemplatesResourceWithStreamingResponse", + "ExtractResource", + "AsyncExtractResource", + "ExtractResourceWithRawResponse", + "AsyncExtractResourceWithRawResponse", + "ExtractResourceWithStreamingResponse", + "AsyncExtractResourceWithStreamingResponse", +] diff --git a/src/nimble_python/resources/extract/extract.py b/src/nimble_python/resources/extract/extract.py new file mode 100644 index 0000000..e1a739b --- /dev/null +++ b/src/nimble_python/resources/extract/extract.py @@ -0,0 +1,4332 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Union, Iterable +from typing_extensions import Literal + +import httpx + +from ...types import extract_run_params, extract_async_params, extract_batch_params +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import make_request_options +from .templates.templates import ( + TemplatesResource, + AsyncTemplatesResource, + TemplatesResourceWithRawResponse, + AsyncTemplatesResourceWithRawResponse, + TemplatesResourceWithStreamingResponse, + AsyncTemplatesResourceWithStreamingResponse, +) +from ...types.extract_run_response import ExtractRunResponse +from ...types.extract_async_response import ExtractAsyncResponse +from ...types.extract_batch_response import ExtractBatchResponse + +__all__ = ["ExtractResource", "AsyncExtractResource"] + + +class ExtractResource(SyncAPIResource): + @cached_property + def templates(self) -> TemplatesResource: + return TemplatesResource(self._client) + + @cached_property + def with_raw_response(self) -> ExtractResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return ExtractResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ExtractResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response + """ + return ExtractResourceWithStreamingResponse(self) + + def async_( + self, + *, + url: str, + auto_driver_configuration: Dict[str, int] | Omit = omit, + body: object | Omit = omit, + browser: extract_async_params.Browser | Omit = omit, + browser_actions: Iterable[extract_async_params.BrowserAction] | Omit = omit, + callback_url: str | Omit = omit, + city: str | Omit = omit, + consent_header: bool | Omit = omit, + cookies: Union[Iterable[extract_async_params.CookiesUnionMember0], str] | Omit = omit, + country: Literal[ + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CR", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SV", + "SX", + "SY", + "SZ", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XK", + "YE", + "YT", + "ZA", + "ZM", + "ZW", + "ALL", + ] + | Omit = omit, + device: Literal["desktop", "mobile", "tablet"] | Omit = omit, + driver: Literal[ + "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" + ] + | Omit = omit, + expected_status_codes: Iterable[int] | Omit = omit, + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, + headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, + http2: bool | Omit = omit, + is_xhr: bool | Omit = omit, + locale: Literal[ + "aa-DJ", + "aa-ER", + "aa-ET", + "af", + "af-NA", + "af-ZA", + "ak", + "ak-GH", + "am", + "am-ET", + "an-ES", + "ar", + "ar-AE", + "ar-BH", + "ar-DZ", + "ar-EG", + "ar-IN", + "ar-IQ", + "ar-JO", + "ar-KW", + "ar-LB", + "ar-LY", + "ar-MA", + "ar-OM", + "ar-QA", + "ar-SA", + "ar-SD", + "ar-SY", + "ar-TN", + "ar-YE", + "as", + "as-IN", + "asa", + "asa-TZ", + "ast-ES", + "az", + "az-AZ", + "az-Cyrl", + "az-Cyrl-AZ", + "az-Latn", + "az-Latn-AZ", + "be", + "be-BY", + "bem", + "bem-ZM", + "ber-DZ", + "ber-MA", + "bez", + "bez-TZ", + "bg", + "bg-BG", + "bho-IN", + "bm", + "bm-ML", + "bn", + "bn-BD", + "bn-IN", + "bo", + "bo-CN", + "bo-IN", + "br-FR", + "brx-IN", + "bs", + "bs-BA", + "byn-ER", + "ca", + "ca-AD", + "ca-ES", + "ca-FR", + "ca-IT", + "cgg", + "cgg-UG", + "chr", + "chr-US", + "crh-UA", + "cs", + "cs-CZ", + "csb-PL", + "cv-RU", + "cy", + "cy-GB", + "da", + "da-DK", + "dav", + "dav-KE", + "de", + "de-AT", + "de-BE", + "de-CH", + "de-DE", + "de-LI", + "de-LU", + "dv-MV", + "dz-BT", + "ebu", + "ebu-KE", + "ee", + "ee-GH", + "ee-TG", + "el", + "el-CY", + "el-GR", + "en", + "en-AG", + "en-AS", + "en-AU", + "en-BE", + "en-BW", + "en-BZ", + "en-CA", + "en-DK", + "en-GB", + "en-GU", + "en-HK", + "en-IE", + "en-IN", + "en-JM", + "en-MH", + "en-MP", + "en-MT", + "en-MU", + "en-NA", + "en-NG", + "en-NZ", + "en-PH", + "en-PK", + "en-SG", + "en-TT", + "en-UM", + "en-US", + "en-VI", + "en-ZA", + "en-ZM", + "en-ZW", + "eo", + "es", + "es-419", + "es-AR", + "es-BO", + "es-CL", + "es-CO", + "es-CR", + "es-CU", + "es-DO", + "es-EC", + "es-ES", + "es-GQ", + "es-GT", + "es-HN", + "es-MX", + "es-NI", + "es-PA", + "es-PE", + "es-PR", + "es-PY", + "es-SV", + "es-US", + "es-UY", + "es-VE", + "et", + "et-EE", + "eu", + "eu-ES", + "fa", + "fa-AF", + "fa-IR", + "ff", + "ff-SN", + "fi", + "fi-FI", + "fil", + "fil-PH", + "fo", + "fo-FO", + "fr", + "fr-BE", + "fr-BF", + "fr-BI", + "fr-BJ", + "fr-BL", + "fr-CA", + "fr-CD", + "fr-CF", + "fr-CG", + "fr-CH", + "fr-CI", + "fr-CM", + "fr-DJ", + "fr-FR", + "fr-GA", + "fr-GN", + "fr-GP", + "fr-GQ", + "fr-KM", + "fr-LU", + "fr-MC", + "fr-MF", + "fr-MG", + "fr-ML", + "fr-MQ", + "fr-NE", + "fr-RE", + "fr-RW", + "fr-SN", + "fr-TD", + "fr-TG", + "fur-IT", + "fy-DE", + "fy-NL", + "ga", + "ga-IE", + "gd-GB", + "gez-ER", + "gez-ET", + "gl", + "gl-ES", + "gsw", + "gsw-CH", + "gu", + "gu-IN", + "guz", + "guz-KE", + "gv", + "gv-GB", + "ha", + "ha-Latn", + "ha-Latn-GH", + "ha-Latn-NE", + "ha-Latn-NG", + "ha-NG", + "haw", + "haw-US", + "he", + "he-IL", + "hi", + "hi-IN", + "hne-IN", + "hr", + "hr-HR", + "hsb-DE", + "ht-HT", + "hu", + "hu-HU", + "hy", + "hy-AM", + "id", + "id-ID", + "ig", + "ig-NG", + "ii", + "ii-CN", + "ik-CA", + "is", + "is-IS", + "it", + "it-CH", + "it-IT", + "iu-CA", + "iw-IL", + "ja", + "ja-JP", + "jmc", + "jmc-TZ", + "ka", + "ka-GE", + "kab", + "kab-DZ", + "kam", + "kam-KE", + "kde", + "kde-TZ", + "kea", + "kea-CV", + "khq", + "khq-ML", + "ki", + "ki-KE", + "kk", + "kk-Cyrl", + "kk-Cyrl-KZ", + "kk-KZ", + "kl", + "kl-GL", + "kln", + "kln-KE", + "km", + "km-KH", + "kn", + "kn-IN", + "ko", + "ko-KR", + "kok", + "kok-IN", + "ks-IN", + "ku-TR", + "kw", + "kw-GB", + "ky-KG", + "lag", + "lag-TZ", + "lb-LU", + "lg", + "lg-UG", + "li-BE", + "li-NL", + "lij-IT", + "lo-LA", + "lt", + "lt-LT", + "luo", + "luo-KE", + "luy", + "luy-KE", + "lv", + "lv-LV", + "mag-IN", + "mai-IN", + "mas", + "mas-KE", + "mas-TZ", + "mer", + "mer-KE", + "mfe", + "mfe-MU", + "mg", + "mg-MG", + "mhr-RU", + "mi-NZ", + "mk", + "mk-MK", + "ml", + "ml-IN", + "mn-MN", + "mr", + "mr-IN", + "ms", + "ms-BN", + "ms-MY", + "mt", + "mt-MT", + "my", + "my-MM", + "nan-TW", + "naq", + "naq-NA", + "nb", + "nb-NO", + "nd", + "nd-ZW", + "nds-DE", + "nds-NL", + "ne", + "ne-IN", + "ne-NP", + "nl", + "nl-AW", + "nl-BE", + "nl-NL", + "nn", + "nn-NO", + "nr-ZA", + "nso-ZA", + "nyn", + "nyn-UG", + "oc-FR", + "om", + "om-ET", + "om-KE", + "or", + "or-IN", + "os-RU", + "pa", + "pa-Arab", + "pa-Arab-PK", + "pa-Guru", + "pa-Guru-IN", + "pa-IN", + "pa-PK", + "pap-AN", + "pl", + "pl-PL", + "ps", + "ps-AF", + "pt", + "pt-BR", + "pt-GW", + "pt-MZ", + "pt-PT", + "rm", + "rm-CH", + "ro", + "ro-MD", + "ro-RO", + "rof", + "rof-TZ", + "ru", + "ru-MD", + "ru-RU", + "ru-UA", + "rw", + "rw-RW", + "rwk", + "rwk-TZ", + "sa-IN", + "saq", + "saq-KE", + "sc-IT", + "sd-IN", + "se-NO", + "seh", + "seh-MZ", + "ses", + "ses-ML", + "sg", + "sg-CF", + "shi", + "shi-Latn", + "shi-Latn-MA", + "shi-Tfng", + "shi-Tfng-MA", + "shs-CA", + "si", + "si-LK", + "sid-ET", + "sk", + "sk-SK", + "sl", + "sl-SI", + "sn", + "sn-ZW", + "so", + "so-DJ", + "so-ET", + "so-KE", + "so-SO", + "sq", + "sq-AL", + "sq-MK", + "sr", + "sr-Cyrl", + "sr-Cyrl-BA", + "sr-Cyrl-ME", + "sr-Cyrl-RS", + "sr-Latn", + "sr-Latn-BA", + "sr-Latn-ME", + "sr-Latn-RS", + "sr-ME", + "sr-RS", + "ss-ZA", + "st-ZA", + "sv", + "sv-FI", + "sv-SE", + "sw", + "sw-KE", + "sw-TZ", + "ta", + "ta-IN", + "ta-LK", + "te", + "te-IN", + "teo", + "teo-KE", + "teo-UG", + "tg-TJ", + "th", + "th-TH", + "ti", + "ti-ER", + "ti-ET", + "tig-ER", + "tk-TM", + "tl-PH", + "tn-ZA", + "to", + "to-TO", + "tr", + "tr-CY", + "tr-TR", + "ts-ZA", + "tt-RU", + "tzm", + "tzm-Latn", + "tzm-Latn-MA", + "ug-CN", + "uk", + "uk-UA", + "unm-US", + "ur", + "ur-IN", + "ur-PK", + "uz", + "uz-Arab", + "uz-Arab-AF", + "uz-Cyrl", + "uz-Cyrl-UZ", + "uz-Latn", + "uz-Latn-UZ", + "uz-UZ", + "ve-ZA", + "vi", + "vi-VN", + "vun", + "vun-TZ", + "wa-BE", + "wae-CH", + "wal-ET", + "wo-SN", + "xh-ZA", + "xog", + "xog-UG", + "yi-US", + "yo", + "yo-NG", + "yue-HK", + "zh", + "zh-CN", + "zh-HK", + "zh-Hans", + "zh-Hans-CN", + "zh-Hans-HK", + "zh-Hans-MO", + "zh-Hans-SG", + "zh-Hant", + "zh-Hant-HK", + "zh-Hant-MO", + "zh-Hant-TW", + "zh-SG", + "zh-TW", + "zu", + "zu-ZA", + "auto", + ] + | Omit = omit, + markdown_backend: Literal["full_page", "main_content"] | Omit = omit, + method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, + network_capture: Iterable[extract_async_params.NetworkCapture] | Omit = omit, + os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, + parse: bool | Omit = omit, + parser: Union[Dict[str, object], str] | Omit = omit, + referrer_type: Literal[ + "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" + ] + | Omit = omit, + render: Union[bool, Literal["auto"]] | Omit = omit, + request_timeout: float | Omit = omit, + session: extract_async_params.Session | Omit = omit, + skill: Union[str, SequenceNotStr[str]] | Omit = omit, + state: Literal[ + "AL", + "AK", + "AS", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "VI", + "WA", + "WV", + "WI", + "WY", + ] + | Omit = omit, + storage_compress: bool | Omit = omit, + storage_object_name: str | Omit = omit, + storage_type: str | Omit = omit, + storage_url: str | Omit = omit, + tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ExtractAsyncResponse: + """ + Extract Async Endpoint + + Args: + url: Target URL to scrape + + auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of + attempts to spend on each candidate before advancing (0 skips it). Key order + defines the flow order. Providing it opts the request into 'auto' driver + selection. + + body: Request body for POST, PUT, PATCH methods + + browser: Browser type to emulate + + browser_actions: Array of browser automation actions to execute sequentially + + callback_url: URL to call back when async operation completes + + city: City for geolocation + + consent_header: Whether to automatically handle cookie consent headers + + cookies: Browser cookies as array of cookie objects + + country: Country code for geolocation and proxy selection + + device: Device type for browser emulation + + driver: Browser driver to use + + expected_status_codes: Expected HTTP status codes for successful requests + + formats: List of acceptable response formats in order of preference + + headers: Custom HTTP headers to include in the request + + http2: Whether to use HTTP/2 protocol + + is_xhr: Whether to emulate XMLHttpRequest behavior + + locale: Locale for browser language and region settings + + markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the + entire HTML page. "main_content" uses Mozilla Readability to extract the main + article content before converting. + + method: HTTP method for the request + + network_capture: Filters for capturing network traffic + + os: Operating system to emulate + + parse: Whether to parse the response content + + parser: Custom parser configuration as a key-value map + + referrer_type: Referrer policy for the request + + render: Whether to render JavaScript content using a browser + + request_timeout: Request timeout in milliseconds + + skill: Skills or capabilities required for the request + + state: US state for geolocation (only valid when country is US) + + storage_compress: Whether to compress stored data + + storage_object_name: Custom name for the stored object + + storage_type: Type of storage to use for results + + storage_url: URL for storage location + + tag: User-defined tag for request identification + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v2/extract/async", + body=maybe_transform( + { + "url": url, + "auto_driver_configuration": auto_driver_configuration, + "body": body, + "browser": browser, + "browser_actions": browser_actions, + "callback_url": callback_url, + "city": city, + "consent_header": consent_header, + "cookies": cookies, + "country": country, + "device": device, + "driver": driver, + "expected_status_codes": expected_status_codes, + "formats": formats, + "headers": headers, + "http2": http2, + "is_xhr": is_xhr, + "locale": locale, + "markdown_backend": markdown_backend, + "method": method, + "network_capture": network_capture, + "os": os, + "parse": parse, + "parser": parser, + "referrer_type": referrer_type, + "render": render, + "request_timeout": request_timeout, + "session": session, + "skill": skill, + "state": state, + "storage_compress": storage_compress, + "storage_object_name": storage_object_name, + "storage_type": storage_type, + "storage_url": storage_url, + "tag": tag, + }, + extract_async_params.ExtractAsyncParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExtractAsyncResponse, + ) + + def batch( + self, + *, + inputs: Iterable[extract_batch_params.Input], + shared_inputs: extract_batch_params.SharedInputs | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ExtractBatchResponse: + """Extract Batch Endpoint + + Args: + inputs: Array of extraction requests. + + Each object can include extraction parameters and + async/storage settings. + + shared_inputs: Shared parameters applied to the entire batch. Can include extraction parameters + and async/storage settings. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v2/extract/batch", + body=maybe_transform( + { + "inputs": inputs, + "shared_inputs": shared_inputs, + }, + extract_batch_params.ExtractBatchParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExtractBatchResponse, + ) + + def run( + self, + *, + url: str, + auto_driver_configuration: Dict[str, int] | Omit = omit, + body: object | Omit = omit, + browser: extract_run_params.Browser | Omit = omit, + browser_actions: Iterable[extract_run_params.BrowserAction] | Omit = omit, + city: str | Omit = omit, + consent_header: bool | Omit = omit, + cookies: Union[Iterable[extract_run_params.CookiesUnionMember0], str] | Omit = omit, + country: Literal[ + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CR", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SV", + "SX", + "SY", + "SZ", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XK", + "YE", + "YT", + "ZA", + "ZM", + "ZW", + "ALL", + ] + | Omit = omit, + device: Literal["desktop", "mobile", "tablet"] | Omit = omit, + driver: Literal[ + "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" + ] + | Omit = omit, + expected_status_codes: Iterable[int] | Omit = omit, + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, + headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, + http2: bool | Omit = omit, + is_xhr: bool | Omit = omit, + locale: Literal[ + "aa-DJ", + "aa-ER", + "aa-ET", + "af", + "af-NA", + "af-ZA", + "ak", + "ak-GH", + "am", + "am-ET", + "an-ES", + "ar", + "ar-AE", + "ar-BH", + "ar-DZ", + "ar-EG", + "ar-IN", + "ar-IQ", + "ar-JO", + "ar-KW", + "ar-LB", + "ar-LY", + "ar-MA", + "ar-OM", + "ar-QA", + "ar-SA", + "ar-SD", + "ar-SY", + "ar-TN", + "ar-YE", + "as", + "as-IN", + "asa", + "asa-TZ", + "ast-ES", + "az", + "az-AZ", + "az-Cyrl", + "az-Cyrl-AZ", + "az-Latn", + "az-Latn-AZ", + "be", + "be-BY", + "bem", + "bem-ZM", + "ber-DZ", + "ber-MA", + "bez", + "bez-TZ", + "bg", + "bg-BG", + "bho-IN", + "bm", + "bm-ML", + "bn", + "bn-BD", + "bn-IN", + "bo", + "bo-CN", + "bo-IN", + "br-FR", + "brx-IN", + "bs", + "bs-BA", + "byn-ER", + "ca", + "ca-AD", + "ca-ES", + "ca-FR", + "ca-IT", + "cgg", + "cgg-UG", + "chr", + "chr-US", + "crh-UA", + "cs", + "cs-CZ", + "csb-PL", + "cv-RU", + "cy", + "cy-GB", + "da", + "da-DK", + "dav", + "dav-KE", + "de", + "de-AT", + "de-BE", + "de-CH", + "de-DE", + "de-LI", + "de-LU", + "dv-MV", + "dz-BT", + "ebu", + "ebu-KE", + "ee", + "ee-GH", + "ee-TG", + "el", + "el-CY", + "el-GR", + "en", + "en-AG", + "en-AS", + "en-AU", + "en-BE", + "en-BW", + "en-BZ", + "en-CA", + "en-DK", + "en-GB", + "en-GU", + "en-HK", + "en-IE", + "en-IN", + "en-JM", + "en-MH", + "en-MP", + "en-MT", + "en-MU", + "en-NA", + "en-NG", + "en-NZ", + "en-PH", + "en-PK", + "en-SG", + "en-TT", + "en-UM", + "en-US", + "en-VI", + "en-ZA", + "en-ZM", + "en-ZW", + "eo", + "es", + "es-419", + "es-AR", + "es-BO", + "es-CL", + "es-CO", + "es-CR", + "es-CU", + "es-DO", + "es-EC", + "es-ES", + "es-GQ", + "es-GT", + "es-HN", + "es-MX", + "es-NI", + "es-PA", + "es-PE", + "es-PR", + "es-PY", + "es-SV", + "es-US", + "es-UY", + "es-VE", + "et", + "et-EE", + "eu", + "eu-ES", + "fa", + "fa-AF", + "fa-IR", + "ff", + "ff-SN", + "fi", + "fi-FI", + "fil", + "fil-PH", + "fo", + "fo-FO", + "fr", + "fr-BE", + "fr-BF", + "fr-BI", + "fr-BJ", + "fr-BL", + "fr-CA", + "fr-CD", + "fr-CF", + "fr-CG", + "fr-CH", + "fr-CI", + "fr-CM", + "fr-DJ", + "fr-FR", + "fr-GA", + "fr-GN", + "fr-GP", + "fr-GQ", + "fr-KM", + "fr-LU", + "fr-MC", + "fr-MF", + "fr-MG", + "fr-ML", + "fr-MQ", + "fr-NE", + "fr-RE", + "fr-RW", + "fr-SN", + "fr-TD", + "fr-TG", + "fur-IT", + "fy-DE", + "fy-NL", + "ga", + "ga-IE", + "gd-GB", + "gez-ER", + "gez-ET", + "gl", + "gl-ES", + "gsw", + "gsw-CH", + "gu", + "gu-IN", + "guz", + "guz-KE", + "gv", + "gv-GB", + "ha", + "ha-Latn", + "ha-Latn-GH", + "ha-Latn-NE", + "ha-Latn-NG", + "ha-NG", + "haw", + "haw-US", + "he", + "he-IL", + "hi", + "hi-IN", + "hne-IN", + "hr", + "hr-HR", + "hsb-DE", + "ht-HT", + "hu", + "hu-HU", + "hy", + "hy-AM", + "id", + "id-ID", + "ig", + "ig-NG", + "ii", + "ii-CN", + "ik-CA", + "is", + "is-IS", + "it", + "it-CH", + "it-IT", + "iu-CA", + "iw-IL", + "ja", + "ja-JP", + "jmc", + "jmc-TZ", + "ka", + "ka-GE", + "kab", + "kab-DZ", + "kam", + "kam-KE", + "kde", + "kde-TZ", + "kea", + "kea-CV", + "khq", + "khq-ML", + "ki", + "ki-KE", + "kk", + "kk-Cyrl", + "kk-Cyrl-KZ", + "kk-KZ", + "kl", + "kl-GL", + "kln", + "kln-KE", + "km", + "km-KH", + "kn", + "kn-IN", + "ko", + "ko-KR", + "kok", + "kok-IN", + "ks-IN", + "ku-TR", + "kw", + "kw-GB", + "ky-KG", + "lag", + "lag-TZ", + "lb-LU", + "lg", + "lg-UG", + "li-BE", + "li-NL", + "lij-IT", + "lo-LA", + "lt", + "lt-LT", + "luo", + "luo-KE", + "luy", + "luy-KE", + "lv", + "lv-LV", + "mag-IN", + "mai-IN", + "mas", + "mas-KE", + "mas-TZ", + "mer", + "mer-KE", + "mfe", + "mfe-MU", + "mg", + "mg-MG", + "mhr-RU", + "mi-NZ", + "mk", + "mk-MK", + "ml", + "ml-IN", + "mn-MN", + "mr", + "mr-IN", + "ms", + "ms-BN", + "ms-MY", + "mt", + "mt-MT", + "my", + "my-MM", + "nan-TW", + "naq", + "naq-NA", + "nb", + "nb-NO", + "nd", + "nd-ZW", + "nds-DE", + "nds-NL", + "ne", + "ne-IN", + "ne-NP", + "nl", + "nl-AW", + "nl-BE", + "nl-NL", + "nn", + "nn-NO", + "nr-ZA", + "nso-ZA", + "nyn", + "nyn-UG", + "oc-FR", + "om", + "om-ET", + "om-KE", + "or", + "or-IN", + "os-RU", + "pa", + "pa-Arab", + "pa-Arab-PK", + "pa-Guru", + "pa-Guru-IN", + "pa-IN", + "pa-PK", + "pap-AN", + "pl", + "pl-PL", + "ps", + "ps-AF", + "pt", + "pt-BR", + "pt-GW", + "pt-MZ", + "pt-PT", + "rm", + "rm-CH", + "ro", + "ro-MD", + "ro-RO", + "rof", + "rof-TZ", + "ru", + "ru-MD", + "ru-RU", + "ru-UA", + "rw", + "rw-RW", + "rwk", + "rwk-TZ", + "sa-IN", + "saq", + "saq-KE", + "sc-IT", + "sd-IN", + "se-NO", + "seh", + "seh-MZ", + "ses", + "ses-ML", + "sg", + "sg-CF", + "shi", + "shi-Latn", + "shi-Latn-MA", + "shi-Tfng", + "shi-Tfng-MA", + "shs-CA", + "si", + "si-LK", + "sid-ET", + "sk", + "sk-SK", + "sl", + "sl-SI", + "sn", + "sn-ZW", + "so", + "so-DJ", + "so-ET", + "so-KE", + "so-SO", + "sq", + "sq-AL", + "sq-MK", + "sr", + "sr-Cyrl", + "sr-Cyrl-BA", + "sr-Cyrl-ME", + "sr-Cyrl-RS", + "sr-Latn", + "sr-Latn-BA", + "sr-Latn-ME", + "sr-Latn-RS", + "sr-ME", + "sr-RS", + "ss-ZA", + "st-ZA", + "sv", + "sv-FI", + "sv-SE", + "sw", + "sw-KE", + "sw-TZ", + "ta", + "ta-IN", + "ta-LK", + "te", + "te-IN", + "teo", + "teo-KE", + "teo-UG", + "tg-TJ", + "th", + "th-TH", + "ti", + "ti-ER", + "ti-ET", + "tig-ER", + "tk-TM", + "tl-PH", + "tn-ZA", + "to", + "to-TO", + "tr", + "tr-CY", + "tr-TR", + "ts-ZA", + "tt-RU", + "tzm", + "tzm-Latn", + "tzm-Latn-MA", + "ug-CN", + "uk", + "uk-UA", + "unm-US", + "ur", + "ur-IN", + "ur-PK", + "uz", + "uz-Arab", + "uz-Arab-AF", + "uz-Cyrl", + "uz-Cyrl-UZ", + "uz-Latn", + "uz-Latn-UZ", + "uz-UZ", + "ve-ZA", + "vi", + "vi-VN", + "vun", + "vun-TZ", + "wa-BE", + "wae-CH", + "wal-ET", + "wo-SN", + "xh-ZA", + "xog", + "xog-UG", + "yi-US", + "yo", + "yo-NG", + "yue-HK", + "zh", + "zh-CN", + "zh-HK", + "zh-Hans", + "zh-Hans-CN", + "zh-Hans-HK", + "zh-Hans-MO", + "zh-Hans-SG", + "zh-Hant", + "zh-Hant-HK", + "zh-Hant-MO", + "zh-Hant-TW", + "zh-SG", + "zh-TW", + "zu", + "zu-ZA", + "auto", + ] + | Omit = omit, + markdown_backend: Literal["full_page", "main_content"] | Omit = omit, + method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, + network_capture: Iterable[extract_run_params.NetworkCapture] | Omit = omit, + os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, + parse: bool | Omit = omit, + parser: Union[Dict[str, object], str] | Omit = omit, + referrer_type: Literal[ + "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" + ] + | Omit = omit, + render: Union[bool, Literal["auto"]] | Omit = omit, + request_timeout: float | Omit = omit, + session: extract_run_params.Session | Omit = omit, + skill: Union[str, SequenceNotStr[str]] | Omit = omit, + state: Literal[ + "AL", + "AK", + "AS", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "VI", + "WA", + "WV", + "WI", + "WY", + ] + | Omit = omit, + tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ExtractRunResponse: + """ + Extract + + Args: + url: Target URL to scrape + + auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of + attempts to spend on each candidate before advancing (0 skips it). Key order + defines the flow order. Providing it opts the request into 'auto' driver + selection. + + body: Request body for POST, PUT, PATCH methods + + browser: Browser type to emulate + + browser_actions: Array of browser automation actions to execute sequentially + + city: City for geolocation + + consent_header: Whether to automatically handle cookie consent headers + + cookies: Browser cookies as array of cookie objects + + country: Country code for geolocation and proxy selection + + device: Device type for browser emulation + + driver: Browser driver to use + + expected_status_codes: Expected HTTP status codes for successful requests + + formats: List of acceptable response formats in order of preference + + headers: Custom HTTP headers to include in the request + + http2: Whether to use HTTP/2 protocol + + is_xhr: Whether to emulate XMLHttpRequest behavior + + locale: Locale for browser language and region settings + + markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the + entire HTML page. "main_content" uses Mozilla Readability to extract the main + article content before converting. + + method: HTTP method for the request + + network_capture: Filters for capturing network traffic + + os: Operating system to emulate + + parse: Whether to parse the response content + + parser: Custom parser configuration as a key-value map + + referrer_type: Referrer policy for the request + + render: Whether to render JavaScript content using a browser + + request_timeout: Request timeout in milliseconds + + skill: Skills or capabilities required for the request + + state: US state for geolocation (only valid when country is US) + + tag: User-defined tag for request identification + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v2/extract", + body=maybe_transform( + { + "url": url, + "auto_driver_configuration": auto_driver_configuration, + "body": body, + "browser": browser, + "browser_actions": browser_actions, + "city": city, + "consent_header": consent_header, + "cookies": cookies, + "country": country, + "device": device, + "driver": driver, + "expected_status_codes": expected_status_codes, + "formats": formats, + "headers": headers, + "http2": http2, + "is_xhr": is_xhr, + "locale": locale, + "markdown_backend": markdown_backend, + "method": method, + "network_capture": network_capture, + "os": os, + "parse": parse, + "parser": parser, + "referrer_type": referrer_type, + "render": render, + "request_timeout": request_timeout, + "session": session, + "skill": skill, + "state": state, + "tag": tag, + }, + extract_run_params.ExtractRunParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExtractRunResponse, + ) + + +class AsyncExtractResource(AsyncAPIResource): + @cached_property + def templates(self) -> AsyncTemplatesResource: + return AsyncTemplatesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncExtractResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return AsyncExtractResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncExtractResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response + """ + return AsyncExtractResourceWithStreamingResponse(self) + + async def async_( + self, + *, + url: str, + auto_driver_configuration: Dict[str, int] | Omit = omit, + body: object | Omit = omit, + browser: extract_async_params.Browser | Omit = omit, + browser_actions: Iterable[extract_async_params.BrowserAction] | Omit = omit, + callback_url: str | Omit = omit, + city: str | Omit = omit, + consent_header: bool | Omit = omit, + cookies: Union[Iterable[extract_async_params.CookiesUnionMember0], str] | Omit = omit, + country: Literal[ + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CR", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SV", + "SX", + "SY", + "SZ", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XK", + "YE", + "YT", + "ZA", + "ZM", + "ZW", + "ALL", + ] + | Omit = omit, + device: Literal["desktop", "mobile", "tablet"] | Omit = omit, + driver: Literal[ + "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" + ] + | Omit = omit, + expected_status_codes: Iterable[int] | Omit = omit, + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, + headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, + http2: bool | Omit = omit, + is_xhr: bool | Omit = omit, + locale: Literal[ + "aa-DJ", + "aa-ER", + "aa-ET", + "af", + "af-NA", + "af-ZA", + "ak", + "ak-GH", + "am", + "am-ET", + "an-ES", + "ar", + "ar-AE", + "ar-BH", + "ar-DZ", + "ar-EG", + "ar-IN", + "ar-IQ", + "ar-JO", + "ar-KW", + "ar-LB", + "ar-LY", + "ar-MA", + "ar-OM", + "ar-QA", + "ar-SA", + "ar-SD", + "ar-SY", + "ar-TN", + "ar-YE", + "as", + "as-IN", + "asa", + "asa-TZ", + "ast-ES", + "az", + "az-AZ", + "az-Cyrl", + "az-Cyrl-AZ", + "az-Latn", + "az-Latn-AZ", + "be", + "be-BY", + "bem", + "bem-ZM", + "ber-DZ", + "ber-MA", + "bez", + "bez-TZ", + "bg", + "bg-BG", + "bho-IN", + "bm", + "bm-ML", + "bn", + "bn-BD", + "bn-IN", + "bo", + "bo-CN", + "bo-IN", + "br-FR", + "brx-IN", + "bs", + "bs-BA", + "byn-ER", + "ca", + "ca-AD", + "ca-ES", + "ca-FR", + "ca-IT", + "cgg", + "cgg-UG", + "chr", + "chr-US", + "crh-UA", + "cs", + "cs-CZ", + "csb-PL", + "cv-RU", + "cy", + "cy-GB", + "da", + "da-DK", + "dav", + "dav-KE", + "de", + "de-AT", + "de-BE", + "de-CH", + "de-DE", + "de-LI", + "de-LU", + "dv-MV", + "dz-BT", + "ebu", + "ebu-KE", + "ee", + "ee-GH", + "ee-TG", + "el", + "el-CY", + "el-GR", + "en", + "en-AG", + "en-AS", + "en-AU", + "en-BE", + "en-BW", + "en-BZ", + "en-CA", + "en-DK", + "en-GB", + "en-GU", + "en-HK", + "en-IE", + "en-IN", + "en-JM", + "en-MH", + "en-MP", + "en-MT", + "en-MU", + "en-NA", + "en-NG", + "en-NZ", + "en-PH", + "en-PK", + "en-SG", + "en-TT", + "en-UM", + "en-US", + "en-VI", + "en-ZA", + "en-ZM", + "en-ZW", + "eo", + "es", + "es-419", + "es-AR", + "es-BO", + "es-CL", + "es-CO", + "es-CR", + "es-CU", + "es-DO", + "es-EC", + "es-ES", + "es-GQ", + "es-GT", + "es-HN", + "es-MX", + "es-NI", + "es-PA", + "es-PE", + "es-PR", + "es-PY", + "es-SV", + "es-US", + "es-UY", + "es-VE", + "et", + "et-EE", + "eu", + "eu-ES", + "fa", + "fa-AF", + "fa-IR", + "ff", + "ff-SN", + "fi", + "fi-FI", + "fil", + "fil-PH", + "fo", + "fo-FO", + "fr", + "fr-BE", + "fr-BF", + "fr-BI", + "fr-BJ", + "fr-BL", + "fr-CA", + "fr-CD", + "fr-CF", + "fr-CG", + "fr-CH", + "fr-CI", + "fr-CM", + "fr-DJ", + "fr-FR", + "fr-GA", + "fr-GN", + "fr-GP", + "fr-GQ", + "fr-KM", + "fr-LU", + "fr-MC", + "fr-MF", + "fr-MG", + "fr-ML", + "fr-MQ", + "fr-NE", + "fr-RE", + "fr-RW", + "fr-SN", + "fr-TD", + "fr-TG", + "fur-IT", + "fy-DE", + "fy-NL", + "ga", + "ga-IE", + "gd-GB", + "gez-ER", + "gez-ET", + "gl", + "gl-ES", + "gsw", + "gsw-CH", + "gu", + "gu-IN", + "guz", + "guz-KE", + "gv", + "gv-GB", + "ha", + "ha-Latn", + "ha-Latn-GH", + "ha-Latn-NE", + "ha-Latn-NG", + "ha-NG", + "haw", + "haw-US", + "he", + "he-IL", + "hi", + "hi-IN", + "hne-IN", + "hr", + "hr-HR", + "hsb-DE", + "ht-HT", + "hu", + "hu-HU", + "hy", + "hy-AM", + "id", + "id-ID", + "ig", + "ig-NG", + "ii", + "ii-CN", + "ik-CA", + "is", + "is-IS", + "it", + "it-CH", + "it-IT", + "iu-CA", + "iw-IL", + "ja", + "ja-JP", + "jmc", + "jmc-TZ", + "ka", + "ka-GE", + "kab", + "kab-DZ", + "kam", + "kam-KE", + "kde", + "kde-TZ", + "kea", + "kea-CV", + "khq", + "khq-ML", + "ki", + "ki-KE", + "kk", + "kk-Cyrl", + "kk-Cyrl-KZ", + "kk-KZ", + "kl", + "kl-GL", + "kln", + "kln-KE", + "km", + "km-KH", + "kn", + "kn-IN", + "ko", + "ko-KR", + "kok", + "kok-IN", + "ks-IN", + "ku-TR", + "kw", + "kw-GB", + "ky-KG", + "lag", + "lag-TZ", + "lb-LU", + "lg", + "lg-UG", + "li-BE", + "li-NL", + "lij-IT", + "lo-LA", + "lt", + "lt-LT", + "luo", + "luo-KE", + "luy", + "luy-KE", + "lv", + "lv-LV", + "mag-IN", + "mai-IN", + "mas", + "mas-KE", + "mas-TZ", + "mer", + "mer-KE", + "mfe", + "mfe-MU", + "mg", + "mg-MG", + "mhr-RU", + "mi-NZ", + "mk", + "mk-MK", + "ml", + "ml-IN", + "mn-MN", + "mr", + "mr-IN", + "ms", + "ms-BN", + "ms-MY", + "mt", + "mt-MT", + "my", + "my-MM", + "nan-TW", + "naq", + "naq-NA", + "nb", + "nb-NO", + "nd", + "nd-ZW", + "nds-DE", + "nds-NL", + "ne", + "ne-IN", + "ne-NP", + "nl", + "nl-AW", + "nl-BE", + "nl-NL", + "nn", + "nn-NO", + "nr-ZA", + "nso-ZA", + "nyn", + "nyn-UG", + "oc-FR", + "om", + "om-ET", + "om-KE", + "or", + "or-IN", + "os-RU", + "pa", + "pa-Arab", + "pa-Arab-PK", + "pa-Guru", + "pa-Guru-IN", + "pa-IN", + "pa-PK", + "pap-AN", + "pl", + "pl-PL", + "ps", + "ps-AF", + "pt", + "pt-BR", + "pt-GW", + "pt-MZ", + "pt-PT", + "rm", + "rm-CH", + "ro", + "ro-MD", + "ro-RO", + "rof", + "rof-TZ", + "ru", + "ru-MD", + "ru-RU", + "ru-UA", + "rw", + "rw-RW", + "rwk", + "rwk-TZ", + "sa-IN", + "saq", + "saq-KE", + "sc-IT", + "sd-IN", + "se-NO", + "seh", + "seh-MZ", + "ses", + "ses-ML", + "sg", + "sg-CF", + "shi", + "shi-Latn", + "shi-Latn-MA", + "shi-Tfng", + "shi-Tfng-MA", + "shs-CA", + "si", + "si-LK", + "sid-ET", + "sk", + "sk-SK", + "sl", + "sl-SI", + "sn", + "sn-ZW", + "so", + "so-DJ", + "so-ET", + "so-KE", + "so-SO", + "sq", + "sq-AL", + "sq-MK", + "sr", + "sr-Cyrl", + "sr-Cyrl-BA", + "sr-Cyrl-ME", + "sr-Cyrl-RS", + "sr-Latn", + "sr-Latn-BA", + "sr-Latn-ME", + "sr-Latn-RS", + "sr-ME", + "sr-RS", + "ss-ZA", + "st-ZA", + "sv", + "sv-FI", + "sv-SE", + "sw", + "sw-KE", + "sw-TZ", + "ta", + "ta-IN", + "ta-LK", + "te", + "te-IN", + "teo", + "teo-KE", + "teo-UG", + "tg-TJ", + "th", + "th-TH", + "ti", + "ti-ER", + "ti-ET", + "tig-ER", + "tk-TM", + "tl-PH", + "tn-ZA", + "to", + "to-TO", + "tr", + "tr-CY", + "tr-TR", + "ts-ZA", + "tt-RU", + "tzm", + "tzm-Latn", + "tzm-Latn-MA", + "ug-CN", + "uk", + "uk-UA", + "unm-US", + "ur", + "ur-IN", + "ur-PK", + "uz", + "uz-Arab", + "uz-Arab-AF", + "uz-Cyrl", + "uz-Cyrl-UZ", + "uz-Latn", + "uz-Latn-UZ", + "uz-UZ", + "ve-ZA", + "vi", + "vi-VN", + "vun", + "vun-TZ", + "wa-BE", + "wae-CH", + "wal-ET", + "wo-SN", + "xh-ZA", + "xog", + "xog-UG", + "yi-US", + "yo", + "yo-NG", + "yue-HK", + "zh", + "zh-CN", + "zh-HK", + "zh-Hans", + "zh-Hans-CN", + "zh-Hans-HK", + "zh-Hans-MO", + "zh-Hans-SG", + "zh-Hant", + "zh-Hant-HK", + "zh-Hant-MO", + "zh-Hant-TW", + "zh-SG", + "zh-TW", + "zu", + "zu-ZA", + "auto", + ] + | Omit = omit, + markdown_backend: Literal["full_page", "main_content"] | Omit = omit, + method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, + network_capture: Iterable[extract_async_params.NetworkCapture] | Omit = omit, + os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, + parse: bool | Omit = omit, + parser: Union[Dict[str, object], str] | Omit = omit, + referrer_type: Literal[ + "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" + ] + | Omit = omit, + render: Union[bool, Literal["auto"]] | Omit = omit, + request_timeout: float | Omit = omit, + session: extract_async_params.Session | Omit = omit, + skill: Union[str, SequenceNotStr[str]] | Omit = omit, + state: Literal[ + "AL", + "AK", + "AS", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "VI", + "WA", + "WV", + "WI", + "WY", + ] + | Omit = omit, + storage_compress: bool | Omit = omit, + storage_object_name: str | Omit = omit, + storage_type: str | Omit = omit, + storage_url: str | Omit = omit, + tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ExtractAsyncResponse: + """ + Extract Async Endpoint + + Args: + url: Target URL to scrape + + auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of + attempts to spend on each candidate before advancing (0 skips it). Key order + defines the flow order. Providing it opts the request into 'auto' driver + selection. + + body: Request body for POST, PUT, PATCH methods + + browser: Browser type to emulate + + browser_actions: Array of browser automation actions to execute sequentially + + callback_url: URL to call back when async operation completes + + city: City for geolocation + + consent_header: Whether to automatically handle cookie consent headers + + cookies: Browser cookies as array of cookie objects + + country: Country code for geolocation and proxy selection + + device: Device type for browser emulation + + driver: Browser driver to use + + expected_status_codes: Expected HTTP status codes for successful requests + + formats: List of acceptable response formats in order of preference + + headers: Custom HTTP headers to include in the request + + http2: Whether to use HTTP/2 protocol + + is_xhr: Whether to emulate XMLHttpRequest behavior + + locale: Locale for browser language and region settings + + markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the + entire HTML page. "main_content" uses Mozilla Readability to extract the main + article content before converting. + + method: HTTP method for the request + + network_capture: Filters for capturing network traffic + + os: Operating system to emulate + + parse: Whether to parse the response content + + parser: Custom parser configuration as a key-value map + + referrer_type: Referrer policy for the request + + render: Whether to render JavaScript content using a browser + + request_timeout: Request timeout in milliseconds + + skill: Skills or capabilities required for the request + + state: US state for geolocation (only valid when country is US) + + storage_compress: Whether to compress stored data + + storage_object_name: Custom name for the stored object + + storage_type: Type of storage to use for results + + storage_url: URL for storage location + + tag: User-defined tag for request identification + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v2/extract/async", + body=await async_maybe_transform( + { + "url": url, + "auto_driver_configuration": auto_driver_configuration, + "body": body, + "browser": browser, + "browser_actions": browser_actions, + "callback_url": callback_url, + "city": city, + "consent_header": consent_header, + "cookies": cookies, + "country": country, + "device": device, + "driver": driver, + "expected_status_codes": expected_status_codes, + "formats": formats, + "headers": headers, + "http2": http2, + "is_xhr": is_xhr, + "locale": locale, + "markdown_backend": markdown_backend, + "method": method, + "network_capture": network_capture, + "os": os, + "parse": parse, + "parser": parser, + "referrer_type": referrer_type, + "render": render, + "request_timeout": request_timeout, + "session": session, + "skill": skill, + "state": state, + "storage_compress": storage_compress, + "storage_object_name": storage_object_name, + "storage_type": storage_type, + "storage_url": storage_url, + "tag": tag, + }, + extract_async_params.ExtractAsyncParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExtractAsyncResponse, + ) + + async def batch( + self, + *, + inputs: Iterable[extract_batch_params.Input], + shared_inputs: extract_batch_params.SharedInputs | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ExtractBatchResponse: + """Extract Batch Endpoint + + Args: + inputs: Array of extraction requests. + + Each object can include extraction parameters and + async/storage settings. + + shared_inputs: Shared parameters applied to the entire batch. Can include extraction parameters + and async/storage settings. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v2/extract/batch", + body=await async_maybe_transform( + { + "inputs": inputs, + "shared_inputs": shared_inputs, + }, + extract_batch_params.ExtractBatchParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExtractBatchResponse, + ) + + async def run( + self, + *, + url: str, + auto_driver_configuration: Dict[str, int] | Omit = omit, + body: object | Omit = omit, + browser: extract_run_params.Browser | Omit = omit, + browser_actions: Iterable[extract_run_params.BrowserAction] | Omit = omit, + city: str | Omit = omit, + consent_header: bool | Omit = omit, + cookies: Union[Iterable[extract_run_params.CookiesUnionMember0], str] | Omit = omit, + country: Literal[ + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CR", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SV", + "SX", + "SY", + "SZ", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XK", + "YE", + "YT", + "ZA", + "ZM", + "ZW", + "ALL", + ] + | Omit = omit, + device: Literal["desktop", "mobile", "tablet"] | Omit = omit, + driver: Literal[ + "auto", "vx6", "vx8", "vx8-pro", "vx10", "vx10-pro", "vx12", "vx12-pro", "media-vx6", "fast-vx6" + ] + | Omit = omit, + expected_status_codes: Iterable[int] | Omit = omit, + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, + headers: Dict[str, Union[str, SequenceNotStr[str], None]] | Omit = omit, + http2: bool | Omit = omit, + is_xhr: bool | Omit = omit, + locale: Literal[ + "aa-DJ", + "aa-ER", + "aa-ET", + "af", + "af-NA", + "af-ZA", + "ak", + "ak-GH", + "am", + "am-ET", + "an-ES", + "ar", + "ar-AE", + "ar-BH", + "ar-DZ", + "ar-EG", + "ar-IN", + "ar-IQ", + "ar-JO", + "ar-KW", + "ar-LB", + "ar-LY", + "ar-MA", + "ar-OM", + "ar-QA", + "ar-SA", + "ar-SD", + "ar-SY", + "ar-TN", + "ar-YE", + "as", + "as-IN", + "asa", + "asa-TZ", + "ast-ES", + "az", + "az-AZ", + "az-Cyrl", + "az-Cyrl-AZ", + "az-Latn", + "az-Latn-AZ", + "be", + "be-BY", + "bem", + "bem-ZM", + "ber-DZ", + "ber-MA", + "bez", + "bez-TZ", + "bg", + "bg-BG", + "bho-IN", + "bm", + "bm-ML", + "bn", + "bn-BD", + "bn-IN", + "bo", + "bo-CN", + "bo-IN", + "br-FR", + "brx-IN", + "bs", + "bs-BA", + "byn-ER", + "ca", + "ca-AD", + "ca-ES", + "ca-FR", + "ca-IT", + "cgg", + "cgg-UG", + "chr", + "chr-US", + "crh-UA", + "cs", + "cs-CZ", + "csb-PL", + "cv-RU", + "cy", + "cy-GB", + "da", + "da-DK", + "dav", + "dav-KE", + "de", + "de-AT", + "de-BE", + "de-CH", + "de-DE", + "de-LI", + "de-LU", + "dv-MV", + "dz-BT", + "ebu", + "ebu-KE", + "ee", + "ee-GH", + "ee-TG", + "el", + "el-CY", + "el-GR", + "en", + "en-AG", + "en-AS", + "en-AU", + "en-BE", + "en-BW", + "en-BZ", + "en-CA", + "en-DK", + "en-GB", + "en-GU", + "en-HK", + "en-IE", + "en-IN", + "en-JM", + "en-MH", + "en-MP", + "en-MT", + "en-MU", + "en-NA", + "en-NG", + "en-NZ", + "en-PH", + "en-PK", + "en-SG", + "en-TT", + "en-UM", + "en-US", + "en-VI", + "en-ZA", + "en-ZM", + "en-ZW", + "eo", + "es", + "es-419", + "es-AR", + "es-BO", + "es-CL", + "es-CO", + "es-CR", + "es-CU", + "es-DO", + "es-EC", + "es-ES", + "es-GQ", + "es-GT", + "es-HN", + "es-MX", + "es-NI", + "es-PA", + "es-PE", + "es-PR", + "es-PY", + "es-SV", + "es-US", + "es-UY", + "es-VE", + "et", + "et-EE", + "eu", + "eu-ES", + "fa", + "fa-AF", + "fa-IR", + "ff", + "ff-SN", + "fi", + "fi-FI", + "fil", + "fil-PH", + "fo", + "fo-FO", + "fr", + "fr-BE", + "fr-BF", + "fr-BI", + "fr-BJ", + "fr-BL", + "fr-CA", + "fr-CD", + "fr-CF", + "fr-CG", + "fr-CH", + "fr-CI", + "fr-CM", + "fr-DJ", + "fr-FR", + "fr-GA", + "fr-GN", + "fr-GP", + "fr-GQ", + "fr-KM", + "fr-LU", + "fr-MC", + "fr-MF", + "fr-MG", + "fr-ML", + "fr-MQ", + "fr-NE", + "fr-RE", + "fr-RW", + "fr-SN", + "fr-TD", + "fr-TG", + "fur-IT", + "fy-DE", + "fy-NL", + "ga", + "ga-IE", + "gd-GB", + "gez-ER", + "gez-ET", + "gl", + "gl-ES", + "gsw", + "gsw-CH", + "gu", + "gu-IN", + "guz", + "guz-KE", + "gv", + "gv-GB", + "ha", + "ha-Latn", + "ha-Latn-GH", + "ha-Latn-NE", + "ha-Latn-NG", + "ha-NG", + "haw", + "haw-US", + "he", + "he-IL", + "hi", + "hi-IN", + "hne-IN", + "hr", + "hr-HR", + "hsb-DE", + "ht-HT", + "hu", + "hu-HU", + "hy", + "hy-AM", + "id", + "id-ID", + "ig", + "ig-NG", + "ii", + "ii-CN", + "ik-CA", + "is", + "is-IS", + "it", + "it-CH", + "it-IT", + "iu-CA", + "iw-IL", + "ja", + "ja-JP", + "jmc", + "jmc-TZ", + "ka", + "ka-GE", + "kab", + "kab-DZ", + "kam", + "kam-KE", + "kde", + "kde-TZ", + "kea", + "kea-CV", + "khq", + "khq-ML", + "ki", + "ki-KE", + "kk", + "kk-Cyrl", + "kk-Cyrl-KZ", + "kk-KZ", + "kl", + "kl-GL", + "kln", + "kln-KE", + "km", + "km-KH", + "kn", + "kn-IN", + "ko", + "ko-KR", + "kok", + "kok-IN", + "ks-IN", + "ku-TR", + "kw", + "kw-GB", + "ky-KG", + "lag", + "lag-TZ", + "lb-LU", + "lg", + "lg-UG", + "li-BE", + "li-NL", + "lij-IT", + "lo-LA", + "lt", + "lt-LT", + "luo", + "luo-KE", + "luy", + "luy-KE", + "lv", + "lv-LV", + "mag-IN", + "mai-IN", + "mas", + "mas-KE", + "mas-TZ", + "mer", + "mer-KE", + "mfe", + "mfe-MU", + "mg", + "mg-MG", + "mhr-RU", + "mi-NZ", + "mk", + "mk-MK", + "ml", + "ml-IN", + "mn-MN", + "mr", + "mr-IN", + "ms", + "ms-BN", + "ms-MY", + "mt", + "mt-MT", + "my", + "my-MM", + "nan-TW", + "naq", + "naq-NA", + "nb", + "nb-NO", + "nd", + "nd-ZW", + "nds-DE", + "nds-NL", + "ne", + "ne-IN", + "ne-NP", + "nl", + "nl-AW", + "nl-BE", + "nl-NL", + "nn", + "nn-NO", + "nr-ZA", + "nso-ZA", + "nyn", + "nyn-UG", + "oc-FR", + "om", + "om-ET", + "om-KE", + "or", + "or-IN", + "os-RU", + "pa", + "pa-Arab", + "pa-Arab-PK", + "pa-Guru", + "pa-Guru-IN", + "pa-IN", + "pa-PK", + "pap-AN", + "pl", + "pl-PL", + "ps", + "ps-AF", + "pt", + "pt-BR", + "pt-GW", + "pt-MZ", + "pt-PT", + "rm", + "rm-CH", + "ro", + "ro-MD", + "ro-RO", + "rof", + "rof-TZ", + "ru", + "ru-MD", + "ru-RU", + "ru-UA", + "rw", + "rw-RW", + "rwk", + "rwk-TZ", + "sa-IN", + "saq", + "saq-KE", + "sc-IT", + "sd-IN", + "se-NO", + "seh", + "seh-MZ", + "ses", + "ses-ML", + "sg", + "sg-CF", + "shi", + "shi-Latn", + "shi-Latn-MA", + "shi-Tfng", + "shi-Tfng-MA", + "shs-CA", + "si", + "si-LK", + "sid-ET", + "sk", + "sk-SK", + "sl", + "sl-SI", + "sn", + "sn-ZW", + "so", + "so-DJ", + "so-ET", + "so-KE", + "so-SO", + "sq", + "sq-AL", + "sq-MK", + "sr", + "sr-Cyrl", + "sr-Cyrl-BA", + "sr-Cyrl-ME", + "sr-Cyrl-RS", + "sr-Latn", + "sr-Latn-BA", + "sr-Latn-ME", + "sr-Latn-RS", + "sr-ME", + "sr-RS", + "ss-ZA", + "st-ZA", + "sv", + "sv-FI", + "sv-SE", + "sw", + "sw-KE", + "sw-TZ", + "ta", + "ta-IN", + "ta-LK", + "te", + "te-IN", + "teo", + "teo-KE", + "teo-UG", + "tg-TJ", + "th", + "th-TH", + "ti", + "ti-ER", + "ti-ET", + "tig-ER", + "tk-TM", + "tl-PH", + "tn-ZA", + "to", + "to-TO", + "tr", + "tr-CY", + "tr-TR", + "ts-ZA", + "tt-RU", + "tzm", + "tzm-Latn", + "tzm-Latn-MA", + "ug-CN", + "uk", + "uk-UA", + "unm-US", + "ur", + "ur-IN", + "ur-PK", + "uz", + "uz-Arab", + "uz-Arab-AF", + "uz-Cyrl", + "uz-Cyrl-UZ", + "uz-Latn", + "uz-Latn-UZ", + "uz-UZ", + "ve-ZA", + "vi", + "vi-VN", + "vun", + "vun-TZ", + "wa-BE", + "wae-CH", + "wal-ET", + "wo-SN", + "xh-ZA", + "xog", + "xog-UG", + "yi-US", + "yo", + "yo-NG", + "yue-HK", + "zh", + "zh-CN", + "zh-HK", + "zh-Hans", + "zh-Hans-CN", + "zh-Hans-HK", + "zh-Hans-MO", + "zh-Hans-SG", + "zh-Hant", + "zh-Hant-HK", + "zh-Hant-MO", + "zh-Hant-TW", + "zh-SG", + "zh-TW", + "zu", + "zu-ZA", + "auto", + ] + | Omit = omit, + markdown_backend: Literal["full_page", "main_content"] | Omit = omit, + method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | Omit = omit, + network_capture: Iterable[extract_run_params.NetworkCapture] | Omit = omit, + os: Literal["windows", "mac os", "linux", "android", "ios"] | Omit = omit, + parse: bool | Omit = omit, + parser: Union[Dict[str, object], str] | Omit = omit, + referrer_type: Literal[ + "random", "no-referer", "same-origin", "google", "bing", "facebook", "twitter", "instagram" + ] + | Omit = omit, + render: Union[bool, Literal["auto"]] | Omit = omit, + request_timeout: float | Omit = omit, + session: extract_run_params.Session | Omit = omit, + skill: Union[str, SequenceNotStr[str]] | Omit = omit, + state: Literal[ + "AL", + "AK", + "AS", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MA", + "MI", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "VI", + "WA", + "WV", + "WI", + "WY", + ] + | Omit = omit, + tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ExtractRunResponse: + """ + Extract + + Args: + url: Target URL to scrape + + auto_driver_configuration: Custom flow for the optimization engine: maps candidate names to the number of + attempts to spend on each candidate before advancing (0 skips it). Key order + defines the flow order. Providing it opts the request into 'auto' driver + selection. + + body: Request body for POST, PUT, PATCH methods + + browser: Browser type to emulate + + browser_actions: Array of browser automation actions to execute sequentially + + city: City for geolocation + + consent_header: Whether to automatically handle cookie consent headers + + cookies: Browser cookies as array of cookie objects + + country: Country code for geolocation and proxy selection + + device: Device type for browser emulation + + driver: Browser driver to use + + expected_status_codes: Expected HTTP status codes for successful requests + + formats: List of acceptable response formats in order of preference + + headers: Custom HTTP headers to include in the request + + http2: Whether to use HTTP/2 protocol + + is_xhr: Whether to emulate XMLHttpRequest behavior + + locale: Locale for browser language and region settings + + markdown_backend: Selects which markdown conversion strategy to use. "full_page" converts the + entire HTML page. "main_content" uses Mozilla Readability to extract the main + article content before converting. + + method: HTTP method for the request + + network_capture: Filters for capturing network traffic + + os: Operating system to emulate + + parse: Whether to parse the response content + + parser: Custom parser configuration as a key-value map + + referrer_type: Referrer policy for the request + + render: Whether to render JavaScript content using a browser + + request_timeout: Request timeout in milliseconds + + skill: Skills or capabilities required for the request + + state: US state for geolocation (only valid when country is US) + + tag: User-defined tag for request identification + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v2/extract", + body=await async_maybe_transform( + { + "url": url, + "auto_driver_configuration": auto_driver_configuration, + "body": body, + "browser": browser, + "browser_actions": browser_actions, + "city": city, + "consent_header": consent_header, + "cookies": cookies, + "country": country, + "device": device, + "driver": driver, + "expected_status_codes": expected_status_codes, + "formats": formats, + "headers": headers, + "http2": http2, + "is_xhr": is_xhr, + "locale": locale, + "markdown_backend": markdown_backend, + "method": method, + "network_capture": network_capture, + "os": os, + "parse": parse, + "parser": parser, + "referrer_type": referrer_type, + "render": render, + "request_timeout": request_timeout, + "session": session, + "skill": skill, + "state": state, + "tag": tag, + }, + extract_run_params.ExtractRunParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ExtractRunResponse, + ) + + +class ExtractResourceWithRawResponse: + def __init__(self, extract: ExtractResource) -> None: + self._extract = extract + + self.async_ = to_raw_response_wrapper( + extract.async_, + ) + self.batch = to_raw_response_wrapper( + extract.batch, + ) + self.run = to_raw_response_wrapper( + extract.run, + ) + + @cached_property + def templates(self) -> TemplatesResourceWithRawResponse: + return TemplatesResourceWithRawResponse(self._extract.templates) + + +class AsyncExtractResourceWithRawResponse: + def __init__(self, extract: AsyncExtractResource) -> None: + self._extract = extract + + self.async_ = async_to_raw_response_wrapper( + extract.async_, + ) + self.batch = async_to_raw_response_wrapper( + extract.batch, + ) + self.run = async_to_raw_response_wrapper( + extract.run, + ) + + @cached_property + def templates(self) -> AsyncTemplatesResourceWithRawResponse: + return AsyncTemplatesResourceWithRawResponse(self._extract.templates) + + +class ExtractResourceWithStreamingResponse: + def __init__(self, extract: ExtractResource) -> None: + self._extract = extract + + self.async_ = to_streamed_response_wrapper( + extract.async_, + ) + self.batch = to_streamed_response_wrapper( + extract.batch, + ) + self.run = to_streamed_response_wrapper( + extract.run, + ) + + @cached_property + def templates(self) -> TemplatesResourceWithStreamingResponse: + return TemplatesResourceWithStreamingResponse(self._extract.templates) + + +class AsyncExtractResourceWithStreamingResponse: + def __init__(self, extract: AsyncExtractResource) -> None: + self._extract = extract + + self.async_ = async_to_streamed_response_wrapper( + extract.async_, + ) + self.batch = async_to_streamed_response_wrapper( + extract.batch, + ) + self.run = async_to_streamed_response_wrapper( + extract.run, + ) + + @cached_property + def templates(self) -> AsyncTemplatesResourceWithStreamingResponse: + return AsyncTemplatesResourceWithStreamingResponse(self._extract.templates) diff --git a/src/nimble_python/resources/extract/templates/__init__.py b/src/nimble_python/resources/extract/templates/__init__.py new file mode 100644 index 0000000..2631d83 --- /dev/null +++ b/src/nimble_python/resources/extract/templates/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .versions import ( + VersionsResource, + AsyncVersionsResource, + VersionsResourceWithRawResponse, + AsyncVersionsResourceWithRawResponse, + VersionsResourceWithStreamingResponse, + AsyncVersionsResourceWithStreamingResponse, +) +from .templates import ( + TemplatesResource, + AsyncTemplatesResource, + TemplatesResourceWithRawResponse, + AsyncTemplatesResourceWithRawResponse, + TemplatesResourceWithStreamingResponse, + AsyncTemplatesResourceWithStreamingResponse, +) +from .generations import ( + GenerationsResource, + AsyncGenerationsResource, + GenerationsResourceWithRawResponse, + AsyncGenerationsResourceWithRawResponse, + GenerationsResourceWithStreamingResponse, + AsyncGenerationsResourceWithStreamingResponse, +) + +__all__ = [ + "GenerationsResource", + "AsyncGenerationsResource", + "GenerationsResourceWithRawResponse", + "AsyncGenerationsResourceWithRawResponse", + "GenerationsResourceWithStreamingResponse", + "AsyncGenerationsResourceWithStreamingResponse", + "VersionsResource", + "AsyncVersionsResource", + "VersionsResourceWithRawResponse", + "AsyncVersionsResourceWithRawResponse", + "VersionsResourceWithStreamingResponse", + "AsyncVersionsResourceWithStreamingResponse", + "TemplatesResource", + "AsyncTemplatesResource", + "TemplatesResourceWithRawResponse", + "AsyncTemplatesResourceWithRawResponse", + "TemplatesResourceWithStreamingResponse", + "AsyncTemplatesResourceWithStreamingResponse", +] diff --git a/src/nimble_python/resources/extract/templates/generations.py b/src/nimble_python/resources/extract/templates/generations.py new file mode 100644 index 0000000..d51b3e9 --- /dev/null +++ b/src/nimble_python/resources/extract/templates/generations.py @@ -0,0 +1,409 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Optional +from typing_extensions import overload + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.extract.templates import generation_create_params +from ....types.extract.templates.generation_get_response import GenerationGetResponse +from ....types.extract.templates.generation_create_response import GenerationCreateResponse + +__all__ = ["GenerationsResource", "AsyncGenerationsResource"] + + +class GenerationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> GenerationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return GenerationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> GenerationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response + """ + return GenerationsResourceWithStreamingResponse(self) + + @overload + def create( + self, + *, + prompt: str, + url: str, + input_schema: Dict[str, object] | Omit = omit, + metadata: Optional[generation_create_params.CreateExtractTemplateGenerationRequestPublicV2Metadata] + | Omit = omit, + name: Optional[str] | Omit = omit, + output_schema: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationCreateResponse: + """ + Create Extract Template Generation Public V2 + + Args: + prompt: Instructions for generating the extract template. + + url: Example URL used to generate the extract template. + + input_schema: Optional JSON schema describing expected input parameters. + + metadata: Metadata to attach to the generated extract template. + + name: Optional stable name for the generated extract template. + + output_schema: Optional JSON schema describing desired extracted output. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + *, + from_extract_template: str, + prompt: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationCreateResponse: + """ + Create Extract Template Generation Public V2 + + Args: + from_extract_template: Name of the source extract template to refine. + + prompt: Instructions for refining the extract template. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["prompt", "url"], ["from_extract_template", "prompt"]) + def create( + self, + *, + prompt: str, + url: str | Omit = omit, + input_schema: Dict[str, object] | Omit = omit, + metadata: Optional[generation_create_params.CreateExtractTemplateGenerationRequestPublicV2Metadata] + | Omit = omit, + name: Optional[str] | Omit = omit, + output_schema: Dict[str, object] | Omit = omit, + from_extract_template: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationCreateResponse: + return self._post( + "/v2/extract/templates/generations", + body=maybe_transform( + { + "prompt": prompt, + "url": url, + "input_schema": input_schema, + "metadata": metadata, + "name": name, + "output_schema": output_schema, + "from_extract_template": from_extract_template, + }, + generation_create_params.GenerationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=GenerationCreateResponse, + ) + + def get( + self, + generation_id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationGetResponse: + """ + Get Extract Template Generation Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not generation_id: + raise ValueError(f"Expected a non-empty value for `generation_id` but received {generation_id!r}") + return self._get( + path_template("/v2/extract/templates/generations/{generation_id}", generation_id=generation_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=GenerationGetResponse, + ) + + +class AsyncGenerationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncGenerationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return AsyncGenerationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncGenerationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response + """ + return AsyncGenerationsResourceWithStreamingResponse(self) + + @overload + async def create( + self, + *, + prompt: str, + url: str, + input_schema: Dict[str, object] | Omit = omit, + metadata: Optional[generation_create_params.CreateExtractTemplateGenerationRequestPublicV2Metadata] + | Omit = omit, + name: Optional[str] | Omit = omit, + output_schema: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationCreateResponse: + """ + Create Extract Template Generation Public V2 + + Args: + prompt: Instructions for generating the extract template. + + url: Example URL used to generate the extract template. + + input_schema: Optional JSON schema describing expected input parameters. + + metadata: Metadata to attach to the generated extract template. + + name: Optional stable name for the generated extract template. + + output_schema: Optional JSON schema describing desired extracted output. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + *, + from_extract_template: str, + prompt: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationCreateResponse: + """ + Create Extract Template Generation Public V2 + + Args: + from_extract_template: Name of the source extract template to refine. + + prompt: Instructions for refining the extract template. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["prompt", "url"], ["from_extract_template", "prompt"]) + async def create( + self, + *, + prompt: str, + url: str | Omit = omit, + input_schema: Dict[str, object] | Omit = omit, + metadata: Optional[generation_create_params.CreateExtractTemplateGenerationRequestPublicV2Metadata] + | Omit = omit, + name: Optional[str] | Omit = omit, + output_schema: Dict[str, object] | Omit = omit, + from_extract_template: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationCreateResponse: + return await self._post( + "/v2/extract/templates/generations", + body=await async_maybe_transform( + { + "prompt": prompt, + "url": url, + "input_schema": input_schema, + "metadata": metadata, + "name": name, + "output_schema": output_schema, + "from_extract_template": from_extract_template, + }, + generation_create_params.GenerationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=GenerationCreateResponse, + ) + + async def get( + self, + generation_id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GenerationGetResponse: + """ + Get Extract Template Generation Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not generation_id: + raise ValueError(f"Expected a non-empty value for `generation_id` but received {generation_id!r}") + return await self._get( + path_template("/v2/extract/templates/generations/{generation_id}", generation_id=generation_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=GenerationGetResponse, + ) + + +class GenerationsResourceWithRawResponse: + def __init__(self, generations: GenerationsResource) -> None: + self._generations = generations + + self.create = to_raw_response_wrapper( + generations.create, + ) + self.get = to_raw_response_wrapper( + generations.get, + ) + + +class AsyncGenerationsResourceWithRawResponse: + def __init__(self, generations: AsyncGenerationsResource) -> None: + self._generations = generations + + self.create = async_to_raw_response_wrapper( + generations.create, + ) + self.get = async_to_raw_response_wrapper( + generations.get, + ) + + +class GenerationsResourceWithStreamingResponse: + def __init__(self, generations: GenerationsResource) -> None: + self._generations = generations + + self.create = to_streamed_response_wrapper( + generations.create, + ) + self.get = to_streamed_response_wrapper( + generations.get, + ) + + +class AsyncGenerationsResourceWithStreamingResponse: + def __init__(self, generations: AsyncGenerationsResource) -> None: + self._generations = generations + + self.create = async_to_streamed_response_wrapper( + generations.create, + ) + self.get = async_to_streamed_response_wrapper( + generations.get, + ) diff --git a/src/nimble_python/resources/agent.py b/src/nimble_python/resources/extract/templates/templates.py similarity index 53% rename from src/nimble_python/resources/agent.py rename to src/nimble_python/resources/extract/templates/templates.py index f80e4a4..3482bf4 100644 --- a/src/nimble_python/resources/agent.py +++ b/src/nimble_python/resources/extract/templates/templates.py @@ -2,91 +2,138 @@ from __future__ import annotations -import typing_extensions -from typing import Dict, List, Iterable, Optional -from typing_extensions import Literal, overload +from typing import Dict, List, Iterable +from typing_extensions import Literal import httpx -from ..types import ( - agent_run_params, - agent_list_params, - agent_generate_params, - agent_run_async_params, - agent_run_batch_params, +from .versions import ( + VersionsResource, + AsyncVersionsResource, + VersionsResourceWithRawResponse, + AsyncVersionsResourceWithRawResponse, + VersionsResourceWithStreamingResponse, + AsyncVersionsResourceWithStreamingResponse, ) -from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from .._utils import path_template, required_args, maybe_transform, async_maybe_transform -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( +from ...._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ...._utils import path_template, maybe_transform, async_maybe_transform +from ...._compat import cached_property +from .generations import ( + GenerationsResource, + AsyncGenerationsResource, + GenerationsResourceWithRawResponse, + AsyncGenerationsResourceWithRawResponse, + GenerationsResourceWithStreamingResponse, + AsyncGenerationsResourceWithStreamingResponse, +) +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from .._base_client import make_request_options -from ..types.agent_get_response import AgentGetResponse -from ..types.agent_run_response import AgentRunResponse -from ..types.agent_list_response import AgentListResponse -from ..types.agent_generate_response import AgentGenerateResponse -from ..types.agent_run_async_response import AgentRunAsyncResponse -from ..types.agent_run_batch_response import AgentRunBatchResponse -from ..types.agent_get_generation_response import AgentGetGenerationResponse +from ...._base_client import make_request_options +from ....types.extract import ( + template_run_params, + template_list_params, + template_async_params, + template_batch_params, + template_update_params, +) +from ....types.extract.template_get_response import TemplateGetResponse +from ....types.extract.template_run_response import TemplateRunResponse +from ....types.extract.template_list_response import TemplateListResponse +from ....types.extract.template_async_response import TemplateAsyncResponse +from ....types.extract.template_batch_response import TemplateBatchResponse +from ....types.extract.template_update_response import TemplateUpdateResponse + +__all__ = ["TemplatesResource", "AsyncTemplatesResource"] -__all__ = ["AgentResource", "AsyncAgentResource"] +class TemplatesResource(SyncAPIResource): + @cached_property + def generations(self) -> GenerationsResource: + return GenerationsResource(self._client) + + @cached_property + def versions(self) -> VersionsResource: + return VersionsResource(self._client) -class AgentResource(SyncAPIResource): @cached_property - def with_raw_response(self) -> AgentResourceWithRawResponse: + def with_raw_response(self) -> TemplatesResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers """ - return AgentResourceWithRawResponse(self) + return TemplatesResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AgentResourceWithStreamingResponse: + def with_streaming_response(self) -> TemplatesResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response """ - return AgentResourceWithStreamingResponse(self) + return TemplatesResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") - def list( + def update( self, + extract_template_name: str, *, - limit: int | Omit = omit, - managed_by: Optional[Literal["nimble", "community", "self_managed"]] | Omit = omit, - offset: int | Omit = omit, - privacy: Optional[Literal["public", "private", "all"]] | Omit = omit, - search: Optional[str] | Omit = omit, + body: Iterable[template_update_params.Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentListResponse: + ) -> TemplateUpdateResponse: """ - List Agent Templates + Patch Extract Template Public V2 Args: - limit: Number of results per page + body: A JSON Patch document per RFC 6902 — a JSON array of patch operations. - managed_by: Filter templates by attribution + extra_headers: Send extra headers - offset: Pagination offset + extra_query: Add additional query parameters to the request - privacy: Filter by privacy level + extra_body: Add additional JSON properties to the request - search: Search templates by name, domain, or vertical + timeout: Override the client-level default timeout for this request, in seconds + """ + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + return self._patch( + path_template("/v2/extract/templates/{extract_template_name}", extract_template_name=extract_template_name), + body=maybe_transform(body, Iterable[template_update_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TemplateUpdateResponse, + ) + def list( + self, + *, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TemplateListResponse: + """ + List Extract Templates Public V2 + + Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -96,7 +143,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/agents", + "/v2/extract/templates", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -105,37 +152,27 @@ def list( query=maybe_transform( { "limit": limit, - "managed_by": managed_by, "offset": offset, - "privacy": privacy, - "search": search, }, - agent_list_params.AgentListParams, + template_list_params.TemplateListParams, ), ), - cast_to=AgentListResponse, + cast_to=TemplateListResponse, ) - @typing_extensions.deprecated("deprecated") - @overload - def generate( + def delete( self, + extract_template_name: str, *, - prompt: str, - url: str, - input_schema: Dict[str, object] | Omit = omit, - metadata: Optional[agent_generate_params.CreateTemplateGenerationRequestPublicV1Metadata] | Omit = omit, - name: Optional[str] | Omit = omit, - output_schema: Dict[str, object] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGenerateResponse: + ) -> None: """ - Create Agent Generation + Delete Extract Template Public V2 Args: extra_headers: Send extra headers @@ -146,26 +183,54 @@ def generate( timeout: Override the client-level default timeout for this request, in seconds """ - ... + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + path_template("/v2/extract/templates/{extract_template_name}", extract_template_name=extract_template_name), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) - @typing_extensions.deprecated("deprecated") - @overload - def generate( + def async_( self, *, - from_agent: str, - prompt: str, + params: Dict[str, object], + template: str, + callback_url: str | Omit = omit, + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, + localization: bool | Omit = omit, + storage_compress: bool | Omit = omit, + storage_object_name: str | Omit = omit, + storage_type: str | Omit = omit, + storage_url: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGenerateResponse: + ) -> TemplateAsyncResponse: """ - Create Agent Generation + Execute Extraction Template Async Endpoint Args: + callback_url: URL to call back when async operation completes + + formats: Response formats to include. All disabled by default. + + storage_compress: Whether to compress stored data + + storage_object_name: Custom name for the stored object + + storage_type: Type of storage to use for results + + storage_url: URL for storage location + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -174,61 +239,42 @@ def generate( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @typing_extensions.deprecated("deprecated") - @required_args(["prompt", "url"], ["from_agent", "prompt"]) - def generate( - self, - *, - prompt: str, - url: str | Omit = omit, - input_schema: Dict[str, object] | Omit = omit, - metadata: Optional[agent_generate_params.CreateTemplateGenerationRequestPublicV1Metadata] | Omit = omit, - name: Optional[str] | Omit = omit, - output_schema: Dict[str, object] | Omit = omit, - from_agent: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGenerateResponse: return self._post( - "/v1/agents/generations", + "/v2/extract/templates/async", body=maybe_transform( { - "prompt": prompt, - "url": url, - "input_schema": input_schema, - "metadata": metadata, - "name": name, - "output_schema": output_schema, - "from_agent": from_agent, + "params": params, + "template": template, + "callback_url": callback_url, + "formats": formats, + "localization": localization, + "storage_compress": storage_compress, + "storage_object_name": storage_object_name, + "storage_type": storage_type, + "storage_url": storage_url, }, - agent_generate_params.AgentGenerateParams, + template_async_params.TemplateAsyncParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentGenerateResponse, + cast_to=TemplateAsyncResponse, ) - @typing_extensions.deprecated("deprecated") - def get( + def batch( self, - template_name: str, *, + inputs: Iterable[template_batch_params.Input], + shared_inputs: template_batch_params.SharedInputs, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGetResponse: + ) -> TemplateBatchResponse: """ - Get Agent Template + Execute Extraction Template Batch Endpoint Args: extra_headers: Send extra headers @@ -239,20 +285,24 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not template_name: - raise ValueError(f"Expected a non-empty value for `template_name` but received {template_name!r}") - return self._get( - path_template("/v1/agents/{template_name}", template_name=template_name), + return self._post( + "/v2/extract/templates/batch", + body=maybe_transform( + { + "inputs": inputs, + "shared_inputs": shared_inputs, + }, + template_batch_params.TemplateBatchParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentGetResponse, + cast_to=TemplateBatchResponse, ) - @typing_extensions.deprecated("deprecated") - def get_generation( + def get( self, - generation_id: str, + extract_template_name: str, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -260,9 +310,9 @@ def get_generation( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGetGenerationResponse: + ) -> TemplateGetResponse: """ - Get Agent Generation + Get Extract Template Public V2 Args: extra_headers: Send extra headers @@ -273,21 +323,23 @@ def get_generation( timeout: Override the client-level default timeout for this request, in seconds """ - if not generation_id: - raise ValueError(f"Expected a non-empty value for `generation_id` but received {generation_id!r}") + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) return self._get( - path_template("/v1/agents/generations/{generation_id}", generation_id=generation_id), + path_template("/v2/extract/templates/{extract_template_name}", extract_template_name=extract_template_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentGetGenerationResponse, + cast_to=TemplateGetResponse, ) def run( self, *, - agent: str, params: Dict[str, object], + template: str, formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, localization: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -296,13 +348,12 @@ def run( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentRunResponse: - """Execute WSA Realtime Endpoint + ) -> TemplateRunResponse: + """ + Execute Extraction Template Realtime Endpoint Args: - formats: Response formats to include. - - All disabled by default. + formats: Response formats to include. All disabled by default. extra_headers: Send extra headers @@ -313,103 +364,69 @@ def run( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/agents/run", + "/v2/extract/templates/run", body=maybe_transform( { - "agent": agent, "params": params, + "template": template, "formats": formats, "localization": localization, }, - agent_run_params.AgentRunParams, + template_run_params.TemplateRunParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentRunResponse, + cast_to=TemplateRunResponse, ) - def run_async( - self, - *, - agent: str, - params: Dict[str, object], - callback_url: str | Omit = omit, - formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, - localization: bool | Omit = omit, - storage_compress: bool | Omit = omit, - storage_object_name: str | Omit = omit, - storage_type: str | Omit = omit, - storage_url: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentRunAsyncResponse: - """ - Execute WSA Async Endpoint - - Args: - callback_url: URL to call back when async operation completes - - formats: Response formats to include. All disabled by default. - - storage_compress: Whether to compress stored data - storage_object_name: Custom name for the stored object - - storage_type: Type of storage to use for results +class AsyncTemplatesResource(AsyncAPIResource): + @cached_property + def generations(self) -> AsyncGenerationsResource: + return AsyncGenerationsResource(self._client) - storage_url: URL for storage location + @cached_property + def versions(self) -> AsyncVersionsResource: + return AsyncVersionsResource(self._client) - extra_headers: Send extra headers + @cached_property + def with_raw_response(self) -> AsyncTemplatesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. - extra_query: Add additional query parameters to the request + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return AsyncTemplatesResourceWithRawResponse(self) - extra_body: Add additional JSON properties to the request + @cached_property + def with_streaming_response(self) -> AsyncTemplatesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. - timeout: Override the client-level default timeout for this request, in seconds + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response """ - return self._post( - "/v1/agents/async", - body=maybe_transform( - { - "agent": agent, - "params": params, - "callback_url": callback_url, - "formats": formats, - "localization": localization, - "storage_compress": storage_compress, - "storage_object_name": storage_object_name, - "storage_type": storage_type, - "storage_url": storage_url, - }, - agent_run_async_params.AgentRunAsyncParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AgentRunAsyncResponse, - ) + return AsyncTemplatesResourceWithStreamingResponse(self) - def run_batch( + async def update( self, + extract_template_name: str, *, - inputs: Iterable[agent_run_batch_params.Input], - shared_inputs: agent_run_batch_params.SharedInputs, + body: Iterable[template_update_params.Body], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentRunBatchResponse: + ) -> TemplateUpdateResponse: """ - Execute WSA Batch Endpoint + Patch Extract Template Public V2 Args: + body: A JSON Patch document per RFC 6902 — a JSON array of patch operations. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -418,72 +435,35 @@ def run_batch( timeout: Override the client-level default timeout for this request, in seconds """ - return self._post( - "/v1/agents/batch", - body=maybe_transform( - { - "inputs": inputs, - "shared_inputs": shared_inputs, - }, - agent_run_batch_params.AgentRunBatchParams, - ), + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + return await self._patch( + path_template("/v2/extract/templates/{extract_template_name}", extract_template_name=extract_template_name), + body=await async_maybe_transform(body, Iterable[template_update_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentRunBatchResponse, + cast_to=TemplateUpdateResponse, ) - -class AsyncAgentResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncAgentResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers - """ - return AsyncAgentResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncAgentResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response - """ - return AsyncAgentResourceWithStreamingResponse(self) - - @typing_extensions.deprecated("deprecated") async def list( self, *, limit: int | Omit = omit, - managed_by: Optional[Literal["nimble", "community", "self_managed"]] | Omit = omit, offset: int | Omit = omit, - privacy: Optional[Literal["public", "private", "all"]] | Omit = omit, - search: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentListResponse: + ) -> TemplateListResponse: """ - List Agent Templates + List Extract Templates Public V2 Args: - limit: Number of results per page - - managed_by: Filter templates by attribution - - offset: Pagination offset - - privacy: Filter by privacy level - - search: Search templates by name, domain, or vertical - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -493,7 +473,7 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/agents", + "/v2/extract/templates", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -502,37 +482,27 @@ async def list( query=await async_maybe_transform( { "limit": limit, - "managed_by": managed_by, "offset": offset, - "privacy": privacy, - "search": search, }, - agent_list_params.AgentListParams, + template_list_params.TemplateListParams, ), ), - cast_to=AgentListResponse, + cast_to=TemplateListResponse, ) - @typing_extensions.deprecated("deprecated") - @overload - async def generate( + async def delete( self, + extract_template_name: str, *, - prompt: str, - url: str, - input_schema: Dict[str, object] | Omit = omit, - metadata: Optional[agent_generate_params.CreateTemplateGenerationRequestPublicV1Metadata] | Omit = omit, - name: Optional[str] | Omit = omit, - output_schema: Dict[str, object] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGenerateResponse: + ) -> None: """ - Create Agent Generation + Delete Extract Template Public V2 Args: extra_headers: Send extra headers @@ -543,26 +513,54 @@ async def generate( timeout: Override the client-level default timeout for this request, in seconds """ - ... + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + path_template("/v2/extract/templates/{extract_template_name}", extract_template_name=extract_template_name), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) - @typing_extensions.deprecated("deprecated") - @overload - async def generate( + async def async_( self, *, - from_agent: str, - prompt: str, + params: Dict[str, object], + template: str, + callback_url: str | Omit = omit, + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, + localization: bool | Omit = omit, + storage_compress: bool | Omit = omit, + storage_object_name: str | Omit = omit, + storage_type: str | Omit = omit, + storage_url: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGenerateResponse: + ) -> TemplateAsyncResponse: """ - Create Agent Generation + Execute Extraction Template Async Endpoint Args: + callback_url: URL to call back when async operation completes + + formats: Response formats to include. All disabled by default. + + storage_compress: Whether to compress stored data + + storage_object_name: Custom name for the stored object + + storage_type: Type of storage to use for results + + storage_url: URL for storage location + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -571,61 +569,42 @@ async def generate( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @typing_extensions.deprecated("deprecated") - @required_args(["prompt", "url"], ["from_agent", "prompt"]) - async def generate( - self, - *, - prompt: str, - url: str | Omit = omit, - input_schema: Dict[str, object] | Omit = omit, - metadata: Optional[agent_generate_params.CreateTemplateGenerationRequestPublicV1Metadata] | Omit = omit, - name: Optional[str] | Omit = omit, - output_schema: Dict[str, object] | Omit = omit, - from_agent: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGenerateResponse: return await self._post( - "/v1/agents/generations", + "/v2/extract/templates/async", body=await async_maybe_transform( { - "prompt": prompt, - "url": url, - "input_schema": input_schema, - "metadata": metadata, - "name": name, - "output_schema": output_schema, - "from_agent": from_agent, + "params": params, + "template": template, + "callback_url": callback_url, + "formats": formats, + "localization": localization, + "storage_compress": storage_compress, + "storage_object_name": storage_object_name, + "storage_type": storage_type, + "storage_url": storage_url, }, - agent_generate_params.AgentGenerateParams, + template_async_params.TemplateAsyncParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentGenerateResponse, + cast_to=TemplateAsyncResponse, ) - @typing_extensions.deprecated("deprecated") - async def get( + async def batch( self, - template_name: str, *, + inputs: Iterable[template_batch_params.Input], + shared_inputs: template_batch_params.SharedInputs, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGetResponse: + ) -> TemplateBatchResponse: """ - Get Agent Template + Execute Extraction Template Batch Endpoint Args: extra_headers: Send extra headers @@ -636,20 +615,24 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not template_name: - raise ValueError(f"Expected a non-empty value for `template_name` but received {template_name!r}") - return await self._get( - path_template("/v1/agents/{template_name}", template_name=template_name), + return await self._post( + "/v2/extract/templates/batch", + body=await async_maybe_transform( + { + "inputs": inputs, + "shared_inputs": shared_inputs, + }, + template_batch_params.TemplateBatchParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentGetResponse, + cast_to=TemplateBatchResponse, ) - @typing_extensions.deprecated("deprecated") - async def get_generation( + async def get( self, - generation_id: str, + extract_template_name: str, *, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -657,9 +640,9 @@ async def get_generation( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentGetGenerationResponse: + ) -> TemplateGetResponse: """ - Get Agent Generation + Get Extract Template Public V2 Args: extra_headers: Send extra headers @@ -670,21 +653,23 @@ async def get_generation( timeout: Override the client-level default timeout for this request, in seconds """ - if not generation_id: - raise ValueError(f"Expected a non-empty value for `generation_id` but received {generation_id!r}") + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) return await self._get( - path_template("/v1/agents/generations/{generation_id}", generation_id=generation_id), + path_template("/v2/extract/templates/{extract_template_name}", extract_template_name=extract_template_name), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentGetGenerationResponse, + cast_to=TemplateGetResponse, ) async def run( self, *, - agent: str, params: Dict[str, object], + template: str, formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, localization: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -693,74 +678,13 @@ async def run( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentRunResponse: - """Execute WSA Realtime Endpoint - - Args: - formats: Response formats to include. - - All disabled by default. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/v1/agents/run", - body=await async_maybe_transform( - { - "agent": agent, - "params": params, - "formats": formats, - "localization": localization, - }, - agent_run_params.AgentRunParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AgentRunResponse, - ) - - async def run_async( - self, - *, - agent: str, - params: Dict[str, object], - callback_url: str | Omit = omit, - formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] | Omit = omit, - localization: bool | Omit = omit, - storage_compress: bool | Omit = omit, - storage_object_name: str | Omit = omit, - storage_type: str | Omit = omit, - storage_url: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentRunAsyncResponse: + ) -> TemplateRunResponse: """ - Execute WSA Async Endpoint + Execute Extraction Template Realtime Endpoint Args: - callback_url: URL to call back when async operation completes - formats: Response formats to include. All disabled by default. - storage_compress: Whether to compress stored data - - storage_object_name: Custom name for the stored object - - storage_type: Type of storage to use for results - - storage_url: URL for storage location - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -770,202 +694,158 @@ async def run_async( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/agents/async", + "/v2/extract/templates/run", body=await async_maybe_transform( { - "agent": agent, "params": params, - "callback_url": callback_url, + "template": template, "formats": formats, "localization": localization, - "storage_compress": storage_compress, - "storage_object_name": storage_object_name, - "storage_type": storage_type, - "storage_url": storage_url, - }, - agent_run_async_params.AgentRunAsyncParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AgentRunAsyncResponse, - ) - - async def run_batch( - self, - *, - inputs: Iterable[agent_run_batch_params.Input], - shared_inputs: agent_run_batch_params.SharedInputs, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AgentRunBatchResponse: - """ - Execute WSA Batch Endpoint - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/v1/agents/batch", - body=await async_maybe_transform( - { - "inputs": inputs, - "shared_inputs": shared_inputs, }, - agent_run_batch_params.AgentRunBatchParams, + template_run_params.TemplateRunParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentRunBatchResponse, + cast_to=TemplateRunResponse, ) -class AgentResourceWithRawResponse: - def __init__(self, agent: AgentResource) -> None: - self._agent = agent +class TemplatesResourceWithRawResponse: + def __init__(self, templates: TemplatesResource) -> None: + self._templates = templates - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - agent.list, # pyright: ignore[reportDeprecated], - ) + self.update = to_raw_response_wrapper( + templates.update, ) - self.generate = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - agent.generate, # pyright: ignore[reportDeprecated], - ) + self.list = to_raw_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = to_raw_response_wrapper( + templates.delete, ) - self.get_generation = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - agent.get_generation, # pyright: ignore[reportDeprecated], - ) + self.async_ = to_raw_response_wrapper( + templates.async_, ) - self.run = to_raw_response_wrapper( - agent.run, + self.batch = to_raw_response_wrapper( + templates.batch, ) - self.run_async = to_raw_response_wrapper( - agent.run_async, + self.get = to_raw_response_wrapper( + templates.get, ) - self.run_batch = to_raw_response_wrapper( - agent.run_batch, + self.run = to_raw_response_wrapper( + templates.run, ) + @cached_property + def generations(self) -> GenerationsResourceWithRawResponse: + return GenerationsResourceWithRawResponse(self._templates.generations) -class AsyncAgentResourceWithRawResponse: - def __init__(self, agent: AsyncAgentResource) -> None: - self._agent = agent + @cached_property + def versions(self) -> VersionsResourceWithRawResponse: + return VersionsResourceWithRawResponse(self._templates.versions) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - agent.list, # pyright: ignore[reportDeprecated], - ) + +class AsyncTemplatesResourceWithRawResponse: + def __init__(self, templates: AsyncTemplatesResource) -> None: + self._templates = templates + + self.update = async_to_raw_response_wrapper( + templates.update, ) - self.generate = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - agent.generate, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_raw_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = async_to_raw_response_wrapper( + templates.delete, ) - self.get_generation = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - agent.get_generation, # pyright: ignore[reportDeprecated], - ) + self.async_ = async_to_raw_response_wrapper( + templates.async_, ) - self.run = async_to_raw_response_wrapper( - agent.run, + self.batch = async_to_raw_response_wrapper( + templates.batch, ) - self.run_async = async_to_raw_response_wrapper( - agent.run_async, + self.get = async_to_raw_response_wrapper( + templates.get, ) - self.run_batch = async_to_raw_response_wrapper( - agent.run_batch, + self.run = async_to_raw_response_wrapper( + templates.run, ) + @cached_property + def generations(self) -> AsyncGenerationsResourceWithRawResponse: + return AsyncGenerationsResourceWithRawResponse(self._templates.generations) -class AgentResourceWithStreamingResponse: - def __init__(self, agent: AgentResource) -> None: - self._agent = agent + @cached_property + def versions(self) -> AsyncVersionsResourceWithRawResponse: + return AsyncVersionsResourceWithRawResponse(self._templates.versions) - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - agent.list, # pyright: ignore[reportDeprecated], - ) + +class TemplatesResourceWithStreamingResponse: + def __init__(self, templates: TemplatesResource) -> None: + self._templates = templates + + self.update = to_streamed_response_wrapper( + templates.update, ) - self.generate = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - agent.generate, # pyright: ignore[reportDeprecated], - ) + self.list = to_streamed_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = to_streamed_response_wrapper( + templates.delete, ) - self.get_generation = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - agent.get_generation, # pyright: ignore[reportDeprecated], - ) + self.async_ = to_streamed_response_wrapper( + templates.async_, ) - self.run = to_streamed_response_wrapper( - agent.run, + self.batch = to_streamed_response_wrapper( + templates.batch, ) - self.run_async = to_streamed_response_wrapper( - agent.run_async, + self.get = to_streamed_response_wrapper( + templates.get, ) - self.run_batch = to_streamed_response_wrapper( - agent.run_batch, + self.run = to_streamed_response_wrapper( + templates.run, ) + @cached_property + def generations(self) -> GenerationsResourceWithStreamingResponse: + return GenerationsResourceWithStreamingResponse(self._templates.generations) -class AsyncAgentResourceWithStreamingResponse: - def __init__(self, agent: AsyncAgentResource) -> None: - self._agent = agent + @cached_property + def versions(self) -> VersionsResourceWithStreamingResponse: + return VersionsResourceWithStreamingResponse(self._templates.versions) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - agent.list, # pyright: ignore[reportDeprecated], - ) + +class AsyncTemplatesResourceWithStreamingResponse: + def __init__(self, templates: AsyncTemplatesResource) -> None: + self._templates = templates + + self.update = async_to_streamed_response_wrapper( + templates.update, ) - self.generate = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - agent.generate, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_streamed_response_wrapper( + templates.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - agent.get, # pyright: ignore[reportDeprecated], - ) + self.delete = async_to_streamed_response_wrapper( + templates.delete, ) - self.get_generation = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - agent.get_generation, # pyright: ignore[reportDeprecated], - ) + self.async_ = async_to_streamed_response_wrapper( + templates.async_, ) - self.run = async_to_streamed_response_wrapper( - agent.run, + self.batch = async_to_streamed_response_wrapper( + templates.batch, ) - self.run_async = async_to_streamed_response_wrapper( - agent.run_async, + self.get = async_to_streamed_response_wrapper( + templates.get, ) - self.run_batch = async_to_streamed_response_wrapper( - agent.run_batch, + self.run = async_to_streamed_response_wrapper( + templates.run, ) + + @cached_property + def generations(self) -> AsyncGenerationsResourceWithStreamingResponse: + return AsyncGenerationsResourceWithStreamingResponse(self._templates.generations) + + @cached_property + def versions(self) -> AsyncVersionsResourceWithStreamingResponse: + return AsyncVersionsResourceWithStreamingResponse(self._templates.versions) diff --git a/src/nimble_python/resources/extract/templates/versions.py b/src/nimble_python/resources/extract/templates/versions.py new file mode 100644 index 0000000..470db87 --- /dev/null +++ b/src/nimble_python/resources/extract/templates/versions.py @@ -0,0 +1,294 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.extract.templates import version_list_params +from ....types.extract.templates.version_get_response import VersionGetResponse +from ....types.extract.templates.version_list_response import VersionListResponse + +__all__ = ["VersionsResource", "AsyncVersionsResource"] + + +class VersionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VersionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return VersionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VersionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response + """ + return VersionsResourceWithStreamingResponse(self) + + def list( + self, + extract_template_name: str, + *, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionListResponse: + """ + List Extract Template Versions Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + return self._get( + path_template( + "/v2/extract/templates/{extract_template_name}/versions", extract_template_name=extract_template_name + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "offset": offset, + }, + version_list_params.VersionListParams, + ), + ), + cast_to=VersionListResponse, + ) + + def get( + self, + version_id: str, + *, + extract_template_name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionGetResponse: + """ + Get Extract Template Version Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + if not version_id: + raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") + return self._get( + path_template( + "/v2/extract/templates/{extract_template_name}/versions/{version_id}", + extract_template_name=extract_template_name, + version_id=version_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VersionGetResponse, + ) + + +class AsyncVersionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVersionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Nimbleway/nimble-python#accessing-raw-response-data-eg-headers + """ + return AsyncVersionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVersionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Nimbleway/nimble-python#with_streaming_response + """ + return AsyncVersionsResourceWithStreamingResponse(self) + + async def list( + self, + extract_template_name: str, + *, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionListResponse: + """ + List Extract Template Versions Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + return await self._get( + path_template( + "/v2/extract/templates/{extract_template_name}/versions", extract_template_name=extract_template_name + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "limit": limit, + "offset": offset, + }, + version_list_params.VersionListParams, + ), + ), + cast_to=VersionListResponse, + ) + + async def get( + self, + version_id: str, + *, + extract_template_name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VersionGetResponse: + """ + Get Extract Template Version Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not extract_template_name: + raise ValueError( + f"Expected a non-empty value for `extract_template_name` but received {extract_template_name!r}" + ) + if not version_id: + raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") + return await self._get( + path_template( + "/v2/extract/templates/{extract_template_name}/versions/{version_id}", + extract_template_name=extract_template_name, + version_id=version_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VersionGetResponse, + ) + + +class VersionsResourceWithRawResponse: + def __init__(self, versions: VersionsResource) -> None: + self._versions = versions + + self.list = to_raw_response_wrapper( + versions.list, + ) + self.get = to_raw_response_wrapper( + versions.get, + ) + + +class AsyncVersionsResourceWithRawResponse: + def __init__(self, versions: AsyncVersionsResource) -> None: + self._versions = versions + + self.list = async_to_raw_response_wrapper( + versions.list, + ) + self.get = async_to_raw_response_wrapper( + versions.get, + ) + + +class VersionsResourceWithStreamingResponse: + def __init__(self, versions: VersionsResource) -> None: + self._versions = versions + + self.list = to_streamed_response_wrapper( + versions.list, + ) + self.get = to_streamed_response_wrapper( + versions.get, + ) + + +class AsyncVersionsResourceWithStreamingResponse: + def __init__(self, versions: AsyncVersionsResource) -> None: + self._versions = versions + + self.list = async_to_streamed_response_wrapper( + versions.list, + ) + self.get = async_to_streamed_response_wrapper( + versions.get, + ) diff --git a/src/nimble_python/resources/fast_serp.py b/src/nimble_python/resources/fast_serp.py index 1ab5e28..da2b195 100644 --- a/src/nimble_python/resources/fast_serp.py +++ b/src/nimble_python/resources/fast_serp.py @@ -115,7 +115,7 @@ def run( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/fast-serp", + "/v2/fast-serp", body=maybe_transform( { "search_engine": search_engine, @@ -232,7 +232,7 @@ async def run( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/fast-serp", + "/v2/fast-serp", body=await async_maybe_transform( { "search_engine": search_engine, diff --git a/src/nimble_python/resources/jobs/jobs.py b/src/nimble_python/resources/jobs/jobs.py index 629ea37..cc291b7 100644 --- a/src/nimble_python/resources/jobs/jobs.py +++ b/src/nimble_python/resources/jobs/jobs.py @@ -2,7 +2,6 @@ from __future__ import annotations -import typing_extensions from typing import Optional import httpx @@ -28,7 +27,6 @@ ) from ..._base_client import make_request_options from ...types.job_get_response import JobGetResponse -from ...types.job_run_response import JobRunResponse from ...types.job_list_response import JobListResponse from ...types.job_create_response import JobCreateResponse from ...types.job_update_response import JobUpdateResponse @@ -60,11 +58,10 @@ def with_streaming_response(self) -> JobsResourceWithStreamingResponse: """ return JobsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") def create( self, *, - agent_name: str, + extract_template_name: str, name: str, description: Optional[str] | Omit = omit, destination: Optional[job_create_params.Destination] | Omit = omit, @@ -79,10 +76,10 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobCreateResponse: """ - Create Job + Create Job Public V2 Args: - agent_name: Name of the agent to run. + extract_template_name: Name of the extract template to run. name: Job name. @@ -105,10 +102,10 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/jobs", + "/v2/jobs", body=maybe_transform( { - "agent_name": agent_name, + "extract_template_name": extract_template_name, "name": name, "description": description, "destination": destination, @@ -124,7 +121,6 @@ def create( cast_to=JobCreateResponse, ) - @typing_extensions.deprecated("deprecated") def update( self, job_id: str, @@ -142,7 +138,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobUpdateResponse: """ - Update Job + Update Job Public V2 Args: description: New description. @@ -166,7 +162,7 @@ def update( if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._patch( - path_template("/v1/jobs/{job_id}", job_id=job_id), + path_template("/v2/jobs/{job_id}", job_id=job_id), body=maybe_transform( { "description": description, @@ -183,14 +179,11 @@ def update( cast_to=JobUpdateResponse, ) - @typing_extensions.deprecated("deprecated") def list( self, *, - agent_name: Optional[str] | Omit = omit, - page: int | Omit = omit, - per_page: int | Omit = omit, - q: Optional[str] | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -199,13 +192,9 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobListResponse: """ - List Jobs + List Jobs Public V2 Args: - agent_name: Filter by agent name - - q: Search by name or display name - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -215,7 +204,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/jobs", + "/v2/jobs", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -223,10 +212,8 @@ def list( timeout=timeout, query=maybe_transform( { - "agent_name": agent_name, - "page": page, - "per_page": per_page, - "q": q, + "limit": limit, + "offset": offset, }, job_list_params.JobListParams, ), @@ -234,7 +221,6 @@ def list( cast_to=JobListResponse, ) - @typing_extensions.deprecated("deprecated") def delete( self, job_id: str, @@ -247,7 +233,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ - Delete Job + Delete Job Public V2 Args: extra_headers: Send extra headers @@ -262,14 +248,13 @@ def delete( raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - path_template("/v1/jobs/{job_id}", job_id=job_id), + path_template("/v2/jobs/{job_id}", job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) - @typing_extensions.deprecated("deprecated") def get( self, job_id: str, @@ -282,7 +267,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobGetResponse: """ - Get Job + Get Job Public V2 Args: extra_headers: Send extra headers @@ -296,47 +281,13 @@ def get( if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._get( - path_template("/v1/jobs/{job_id}", job_id=job_id), + path_template("/v2/jobs/{job_id}", job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=JobGetResponse, ) - @typing_extensions.deprecated("deprecated") - def run( - self, - job_id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> JobRunResponse: - """ - Trigger Run - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not job_id: - raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") - return self._post( - path_template("/v1/jobs/{job_id}/runs", job_id=job_id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=JobRunResponse, - ) - class AsyncJobsResource(AsyncAPIResource): @cached_property @@ -362,11 +313,10 @@ def with_streaming_response(self) -> AsyncJobsResourceWithStreamingResponse: """ return AsyncJobsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") async def create( self, *, - agent_name: str, + extract_template_name: str, name: str, description: Optional[str] | Omit = omit, destination: Optional[job_create_params.Destination] | Omit = omit, @@ -381,10 +331,10 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobCreateResponse: """ - Create Job + Create Job Public V2 Args: - agent_name: Name of the agent to run. + extract_template_name: Name of the extract template to run. name: Job name. @@ -407,10 +357,10 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/jobs", + "/v2/jobs", body=await async_maybe_transform( { - "agent_name": agent_name, + "extract_template_name": extract_template_name, "name": name, "description": description, "destination": destination, @@ -426,7 +376,6 @@ async def create( cast_to=JobCreateResponse, ) - @typing_extensions.deprecated("deprecated") async def update( self, job_id: str, @@ -444,7 +393,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobUpdateResponse: """ - Update Job + Update Job Public V2 Args: description: New description. @@ -468,7 +417,7 @@ async def update( if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return await self._patch( - path_template("/v1/jobs/{job_id}", job_id=job_id), + path_template("/v2/jobs/{job_id}", job_id=job_id), body=await async_maybe_transform( { "description": description, @@ -485,14 +434,11 @@ async def update( cast_to=JobUpdateResponse, ) - @typing_extensions.deprecated("deprecated") async def list( self, *, - agent_name: Optional[str] | Omit = omit, - page: int | Omit = omit, - per_page: int | Omit = omit, - q: Optional[str] | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -501,13 +447,9 @@ async def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobListResponse: """ - List Jobs + List Jobs Public V2 Args: - agent_name: Filter by agent name - - q: Search by name or display name - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -517,7 +459,7 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/jobs", + "/v2/jobs", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -525,10 +467,8 @@ async def list( timeout=timeout, query=await async_maybe_transform( { - "agent_name": agent_name, - "page": page, - "per_page": per_page, - "q": q, + "limit": limit, + "offset": offset, }, job_list_params.JobListParams, ), @@ -536,7 +476,6 @@ async def list( cast_to=JobListResponse, ) - @typing_extensions.deprecated("deprecated") async def delete( self, job_id: str, @@ -549,7 +488,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ - Delete Job + Delete Job Public V2 Args: extra_headers: Send extra headers @@ -564,14 +503,13 @@ async def delete( raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - path_template("/v1/jobs/{job_id}", job_id=job_id), + path_template("/v2/jobs/{job_id}", job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=NoneType, ) - @typing_extensions.deprecated("deprecated") async def get( self, job_id: str, @@ -584,7 +522,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> JobGetResponse: """ - Get Job + Get Job Public V2 Args: extra_headers: Send extra headers @@ -598,81 +536,32 @@ async def get( if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return await self._get( - path_template("/v1/jobs/{job_id}", job_id=job_id), + path_template("/v2/jobs/{job_id}", job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=JobGetResponse, ) - @typing_extensions.deprecated("deprecated") - async def run( - self, - job_id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> JobRunResponse: - """ - Trigger Run - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not job_id: - raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") - return await self._post( - path_template("/v1/jobs/{job_id}/runs", job_id=job_id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=JobRunResponse, - ) - class JobsResourceWithRawResponse: def __init__(self, jobs: JobsResource) -> None: self._jobs = jobs - self.create = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - jobs.create, # pyright: ignore[reportDeprecated], - ) + self.create = to_raw_response_wrapper( + jobs.create, ) - self.update = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - jobs.update, # pyright: ignore[reportDeprecated], - ) + self.update = to_raw_response_wrapper( + jobs.update, ) - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - jobs.list, # pyright: ignore[reportDeprecated], - ) + self.list = to_raw_response_wrapper( + jobs.list, ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - jobs.delete, # pyright: ignore[reportDeprecated], - ) + self.delete = to_raw_response_wrapper( + jobs.delete, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - jobs.get, # pyright: ignore[reportDeprecated], - ) - ) - self.run = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - jobs.run, # pyright: ignore[reportDeprecated], - ) + self.get = to_raw_response_wrapper( + jobs.get, ) @cached_property @@ -684,35 +573,20 @@ class AsyncJobsResourceWithRawResponse: def __init__(self, jobs: AsyncJobsResource) -> None: self._jobs = jobs - self.create = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - jobs.create, # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - jobs.update, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_raw_response_wrapper( + jobs.create, ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - jobs.list, # pyright: ignore[reportDeprecated], - ) + self.update = async_to_raw_response_wrapper( + jobs.update, ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - jobs.delete, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_raw_response_wrapper( + jobs.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - jobs.get, # pyright: ignore[reportDeprecated], - ) + self.delete = async_to_raw_response_wrapper( + jobs.delete, ) - self.run = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - jobs.run, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_raw_response_wrapper( + jobs.get, ) @cached_property @@ -724,35 +598,20 @@ class JobsResourceWithStreamingResponse: def __init__(self, jobs: JobsResource) -> None: self._jobs = jobs - self.create = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - jobs.create, # pyright: ignore[reportDeprecated], - ) + self.create = to_streamed_response_wrapper( + jobs.create, ) - self.update = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - jobs.update, # pyright: ignore[reportDeprecated], - ) + self.update = to_streamed_response_wrapper( + jobs.update, ) - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - jobs.list, # pyright: ignore[reportDeprecated], - ) + self.list = to_streamed_response_wrapper( + jobs.list, ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - jobs.delete, # pyright: ignore[reportDeprecated], - ) + self.delete = to_streamed_response_wrapper( + jobs.delete, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - jobs.get, # pyright: ignore[reportDeprecated], - ) - ) - self.run = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - jobs.run, # pyright: ignore[reportDeprecated], - ) + self.get = to_streamed_response_wrapper( + jobs.get, ) @cached_property @@ -764,35 +623,20 @@ class AsyncJobsResourceWithStreamingResponse: def __init__(self, jobs: AsyncJobsResource) -> None: self._jobs = jobs - self.create = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - jobs.create, # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - jobs.update, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_streamed_response_wrapper( + jobs.create, ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - jobs.list, # pyright: ignore[reportDeprecated], - ) + self.update = async_to_streamed_response_wrapper( + jobs.update, ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - jobs.delete, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_streamed_response_wrapper( + jobs.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - jobs.get, # pyright: ignore[reportDeprecated], - ) + self.delete = async_to_streamed_response_wrapper( + jobs.delete, ) - self.run = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - jobs.run, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_streamed_response_wrapper( + jobs.get, ) @cached_property diff --git a/src/nimble_python/resources/jobs/runs/artifacts.py b/src/nimble_python/resources/jobs/runs/artifacts.py index 864e166..15dd098 100644 --- a/src/nimble_python/resources/jobs/runs/artifacts.py +++ b/src/nimble_python/resources/jobs/runs/artifacts.py @@ -2,8 +2,6 @@ from __future__ import annotations -import typing_extensions - import httpx from ...._types import Body, Query, Headers, NotGiven, not_given @@ -45,7 +43,6 @@ def with_streaming_response(self) -> ArtifactsResourceWithStreamingResponse: """ return ArtifactsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") def list( self, run_id: str, @@ -58,7 +55,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactListResponse: """ - List Run Artifacts + List Run Artifacts Public V2 Args: extra_headers: Send extra headers @@ -72,14 +69,13 @@ def list( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._get( - path_template("/v1/jobs/runs/{run_id}/artifacts", run_id=run_id), + path_template("/v2/jobs/runs/{run_id}/artifacts", run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=ArtifactListResponse, ) - @typing_extensions.deprecated("deprecated") def download_url( self, artifact_id: int, @@ -93,7 +89,7 @@ def download_url( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactDownloadURLResponse: """ - Get Run Artifact Download URL + Get Run Artifact Download Url Public V2 Args: extra_headers: Send extra headers @@ -108,7 +104,7 @@ def download_url( raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._get( path_template( - "/v1/jobs/runs/{run_id}/artifacts/{artifact_id}/download-url", run_id=run_id, artifact_id=artifact_id + "/v2/jobs/runs/{run_id}/artifacts/{artifact_id}/download-url", run_id=run_id, artifact_id=artifact_id ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -116,7 +112,6 @@ def download_url( cast_to=ArtifactDownloadURLResponse, ) - @typing_extensions.deprecated("deprecated") def get( self, artifact_id: int, @@ -130,7 +125,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactGetResponse: """ - Get Run Artifact + Get Run Artifact Public V2 Args: extra_headers: Send extra headers @@ -144,14 +139,13 @@ def get( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._get( - path_template("/v1/jobs/runs/{run_id}/artifacts/{artifact_id}", run_id=run_id, artifact_id=artifact_id), + path_template("/v2/jobs/runs/{run_id}/artifacts/{artifact_id}", run_id=run_id, artifact_id=artifact_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=ArtifactGetResponse, ) - @typing_extensions.deprecated("deprecated") def preview( self, artifact_id: int, @@ -165,7 +159,7 @@ def preview( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactPreviewResponse: """ - Preview Run Artifact + Preview Run Artifact Public V2 Args: extra_headers: Send extra headers @@ -180,7 +174,7 @@ def preview( raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._get( path_template( - "/v1/jobs/runs/{run_id}/artifacts/{artifact_id}/preview", run_id=run_id, artifact_id=artifact_id + "/v2/jobs/runs/{run_id}/artifacts/{artifact_id}/preview", run_id=run_id, artifact_id=artifact_id ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -209,7 +203,6 @@ def with_streaming_response(self) -> AsyncArtifactsResourceWithStreamingResponse """ return AsyncArtifactsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") async def list( self, run_id: str, @@ -222,7 +215,7 @@ async def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactListResponse: """ - List Run Artifacts + List Run Artifacts Public V2 Args: extra_headers: Send extra headers @@ -236,14 +229,13 @@ async def list( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._get( - path_template("/v1/jobs/runs/{run_id}/artifacts", run_id=run_id), + path_template("/v2/jobs/runs/{run_id}/artifacts", run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=ArtifactListResponse, ) - @typing_extensions.deprecated("deprecated") async def download_url( self, artifact_id: int, @@ -257,7 +249,7 @@ async def download_url( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactDownloadURLResponse: """ - Get Run Artifact Download URL + Get Run Artifact Download Url Public V2 Args: extra_headers: Send extra headers @@ -272,7 +264,7 @@ async def download_url( raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._get( path_template( - "/v1/jobs/runs/{run_id}/artifacts/{artifact_id}/download-url", run_id=run_id, artifact_id=artifact_id + "/v2/jobs/runs/{run_id}/artifacts/{artifact_id}/download-url", run_id=run_id, artifact_id=artifact_id ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -280,7 +272,6 @@ async def download_url( cast_to=ArtifactDownloadURLResponse, ) - @typing_extensions.deprecated("deprecated") async def get( self, artifact_id: int, @@ -294,7 +285,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactGetResponse: """ - Get Run Artifact + Get Run Artifact Public V2 Args: extra_headers: Send extra headers @@ -308,14 +299,13 @@ async def get( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._get( - path_template("/v1/jobs/runs/{run_id}/artifacts/{artifact_id}", run_id=run_id, artifact_id=artifact_id), + path_template("/v2/jobs/runs/{run_id}/artifacts/{artifact_id}", run_id=run_id, artifact_id=artifact_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=ArtifactGetResponse, ) - @typing_extensions.deprecated("deprecated") async def preview( self, artifact_id: int, @@ -329,7 +319,7 @@ async def preview( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ArtifactPreviewResponse: """ - Preview Run Artifact + Preview Run Artifact Public V2 Args: extra_headers: Send extra headers @@ -344,7 +334,7 @@ async def preview( raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._get( path_template( - "/v1/jobs/runs/{run_id}/artifacts/{artifact_id}/preview", run_id=run_id, artifact_id=artifact_id + "/v2/jobs/runs/{run_id}/artifacts/{artifact_id}/preview", run_id=run_id, artifact_id=artifact_id ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -357,25 +347,17 @@ class ArtifactsResourceWithRawResponse: def __init__(self, artifacts: ArtifactsResource) -> None: self._artifacts = artifacts - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - artifacts.list, # pyright: ignore[reportDeprecated], - ) + self.list = to_raw_response_wrapper( + artifacts.list, ) - self.download_url = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - artifacts.download_url, # pyright: ignore[reportDeprecated], - ) + self.download_url = to_raw_response_wrapper( + artifacts.download_url, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - artifacts.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_raw_response_wrapper( + artifacts.get, ) - self.preview = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - artifacts.preview, # pyright: ignore[reportDeprecated], - ) + self.preview = to_raw_response_wrapper( + artifacts.preview, ) @@ -383,25 +365,17 @@ class AsyncArtifactsResourceWithRawResponse: def __init__(self, artifacts: AsyncArtifactsResource) -> None: self._artifacts = artifacts - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - artifacts.list, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_raw_response_wrapper( + artifacts.list, ) - self.download_url = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - artifacts.download_url, # pyright: ignore[reportDeprecated], - ) + self.download_url = async_to_raw_response_wrapper( + artifacts.download_url, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - artifacts.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_raw_response_wrapper( + artifacts.get, ) - self.preview = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - artifacts.preview, # pyright: ignore[reportDeprecated], - ) + self.preview = async_to_raw_response_wrapper( + artifacts.preview, ) @@ -409,25 +383,17 @@ class ArtifactsResourceWithStreamingResponse: def __init__(self, artifacts: ArtifactsResource) -> None: self._artifacts = artifacts - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - artifacts.list, # pyright: ignore[reportDeprecated], - ) + self.list = to_streamed_response_wrapper( + artifacts.list, ) - self.download_url = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - artifacts.download_url, # pyright: ignore[reportDeprecated], - ) + self.download_url = to_streamed_response_wrapper( + artifacts.download_url, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - artifacts.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_streamed_response_wrapper( + artifacts.get, ) - self.preview = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - artifacts.preview, # pyright: ignore[reportDeprecated], - ) + self.preview = to_streamed_response_wrapper( + artifacts.preview, ) @@ -435,23 +401,15 @@ class AsyncArtifactsResourceWithStreamingResponse: def __init__(self, artifacts: AsyncArtifactsResource) -> None: self._artifacts = artifacts - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - artifacts.list, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_streamed_response_wrapper( + artifacts.list, ) - self.download_url = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - artifacts.download_url, # pyright: ignore[reportDeprecated], - ) + self.download_url = async_to_streamed_response_wrapper( + artifacts.download_url, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - artifacts.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_streamed_response_wrapper( + artifacts.get, ) - self.preview = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - artifacts.preview, # pyright: ignore[reportDeprecated], - ) + self.preview = async_to_streamed_response_wrapper( + artifacts.preview, ) diff --git a/src/nimble_python/resources/jobs/runs/runs.py b/src/nimble_python/resources/jobs/runs/runs.py index 3dbca84..09610b4 100644 --- a/src/nimble_python/resources/jobs/runs/runs.py +++ b/src/nimble_python/resources/jobs/runs/runs.py @@ -2,9 +2,6 @@ from __future__ import annotations -import typing_extensions -from typing import Optional - import httpx from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given @@ -30,6 +27,7 @@ from ....types.jobs.run_get_response import RunGetResponse from ....types.jobs.run_list_response import RunListResponse from ....types.jobs.run_cancel_response import RunCancelResponse +from ....types.jobs.run_create_response import RunCreateResponse __all__ = ["RunsResource", "AsyncRunsResource"] @@ -58,14 +56,45 @@ def with_streaming_response(self) -> RunsResourceWithStreamingResponse: """ return RunsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") + def create( + self, + job_id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RunCreateResponse: + """ + Trigger Job Run Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return self._post( + path_template("/v2/jobs/{job_id}/runs", job_id=job_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RunCreateResponse, + ) + def list( self, job_id: str, *, - page: int | Omit = omit, - per_page: int | Omit = omit, - status: Optional[str] | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -74,11 +103,9 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunListResponse: """ - List Runs for Job + List Job Runs Public V2 Args: - status: Filter by status - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -90,7 +117,7 @@ def list( if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return self._get( - path_template("/v1/jobs/{job_id}/runs", job_id=job_id), + path_template("/v2/jobs/{job_id}/runs", job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -98,9 +125,8 @@ def list( timeout=timeout, query=maybe_transform( { - "page": page, - "per_page": per_page, - "status": status, + "limit": limit, + "offset": offset, }, run_list_params.RunListParams, ), @@ -108,7 +134,6 @@ def list( cast_to=RunListResponse, ) - @typing_extensions.deprecated("deprecated") def cancel( self, run_id: str, @@ -121,7 +146,7 @@ def cancel( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunCancelResponse: """ - Cancel Run + Cancel Run Public V2 Args: extra_headers: Send extra headers @@ -135,14 +160,13 @@ def cancel( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._post( - path_template("/v1/jobs/runs/{run_id}/cancel", run_id=run_id), + path_template("/v2/jobs/runs/{run_id}/cancel", run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=RunCancelResponse, ) - @typing_extensions.deprecated("deprecated") def get( self, run_id: str, @@ -155,7 +179,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunGetResponse: """ - Get Run + Get Run Public V2 Args: extra_headers: Send extra headers @@ -169,7 +193,7 @@ def get( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return self._get( - path_template("/v1/jobs/runs/{run_id}", run_id=run_id), + path_template("/v2/jobs/runs/{run_id}", run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -201,14 +225,45 @@ def with_streaming_response(self) -> AsyncRunsResourceWithStreamingResponse: """ return AsyncRunsResourceWithStreamingResponse(self) - @typing_extensions.deprecated("deprecated") + async def create( + self, + job_id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> RunCreateResponse: + """ + Trigger Job Run Public V2 + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return await self._post( + path_template("/v2/jobs/{job_id}/runs", job_id=job_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RunCreateResponse, + ) + async def list( self, job_id: str, *, - page: int | Omit = omit, - per_page: int | Omit = omit, - status: Optional[str] | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -217,11 +272,9 @@ async def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunListResponse: """ - List Runs for Job + List Job Runs Public V2 Args: - status: Filter by status - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -233,7 +286,7 @@ async def list( if not job_id: raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") return await self._get( - path_template("/v1/jobs/{job_id}/runs", job_id=job_id), + path_template("/v2/jobs/{job_id}/runs", job_id=job_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -241,9 +294,8 @@ async def list( timeout=timeout, query=await async_maybe_transform( { - "page": page, - "per_page": per_page, - "status": status, + "limit": limit, + "offset": offset, }, run_list_params.RunListParams, ), @@ -251,7 +303,6 @@ async def list( cast_to=RunListResponse, ) - @typing_extensions.deprecated("deprecated") async def cancel( self, run_id: str, @@ -264,7 +315,7 @@ async def cancel( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunCancelResponse: """ - Cancel Run + Cancel Run Public V2 Args: extra_headers: Send extra headers @@ -278,14 +329,13 @@ async def cancel( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._post( - path_template("/v1/jobs/runs/{run_id}/cancel", run_id=run_id), + path_template("/v2/jobs/runs/{run_id}/cancel", run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=RunCancelResponse, ) - @typing_extensions.deprecated("deprecated") async def get( self, run_id: str, @@ -298,7 +348,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RunGetResponse: """ - Get Run + Get Run Public V2 Args: extra_headers: Send extra headers @@ -312,7 +362,7 @@ async def get( if not run_id: raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}") return await self._get( - path_template("/v1/jobs/runs/{run_id}", run_id=run_id), + path_template("/v2/jobs/runs/{run_id}", run_id=run_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -324,20 +374,17 @@ class RunsResourceWithRawResponse: def __init__(self, runs: RunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = to_raw_response_wrapper( + runs.create, + ) + self.list = to_raw_response_wrapper( + runs.list, ) - self.cancel = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.cancel, # pyright: ignore[reportDeprecated], - ) + self.cancel = to_raw_response_wrapper( + runs.cancel, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_raw_response_wrapper( + runs.get, ) @cached_property @@ -349,20 +396,17 @@ class AsyncRunsResourceWithRawResponse: def __init__(self, runs: AsyncRunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_raw_response_wrapper( + runs.create, ) - self.cancel = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.cancel, # pyright: ignore[reportDeprecated], - ) + self.list = async_to_raw_response_wrapper( + runs.list, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.cancel = async_to_raw_response_wrapper( + runs.cancel, + ) + self.get = async_to_raw_response_wrapper( + runs.get, ) @cached_property @@ -374,20 +418,17 @@ class RunsResourceWithStreamingResponse: def __init__(self, runs: RunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = to_streamed_response_wrapper( + runs.create, + ) + self.list = to_streamed_response_wrapper( + runs.list, ) - self.cancel = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.cancel, # pyright: ignore[reportDeprecated], - ) + self.cancel = to_streamed_response_wrapper( + runs.cancel, ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.get = to_streamed_response_wrapper( + runs.get, ) @cached_property @@ -399,20 +440,17 @@ class AsyncRunsResourceWithStreamingResponse: def __init__(self, runs: AsyncRunsResource) -> None: self._runs = runs - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.list, # pyright: ignore[reportDeprecated], - ) + self.create = async_to_streamed_response_wrapper( + runs.create, + ) + self.list = async_to_streamed_response_wrapper( + runs.list, ) - self.cancel = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.cancel, # pyright: ignore[reportDeprecated], - ) + self.cancel = async_to_streamed_response_wrapper( + runs.cancel, ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - runs.get, # pyright: ignore[reportDeprecated], - ) + self.get = async_to_streamed_response_wrapper( + runs.get, ) @cached_property diff --git a/src/nimble_python/resources/media.py b/src/nimble_python/resources/media.py index 81d2df8..1a23266 100644 --- a/src/nimble_python/resources/media.py +++ b/src/nimble_python/resources/media.py @@ -71,7 +71,7 @@ def run( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/media", + "/v2/media", body=maybe_transform( { "url": url, @@ -132,7 +132,7 @@ def run_async( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/media/async", + "/v2/media/async", body=maybe_transform( { "url": url, @@ -204,7 +204,7 @@ async def run( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/media", + "/v2/media", body=await async_maybe_transform( { "url": url, @@ -265,7 +265,7 @@ async def run_async( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/media/async", + "/v2/media/async", body=await async_maybe_transform( { "url": url, diff --git a/src/nimble_python/resources/serp.py b/src/nimble_python/resources/serp.py index b56a746..593a9e6 100644 --- a/src/nimble_python/resources/serp.py +++ b/src/nimble_python/resources/serp.py @@ -118,7 +118,7 @@ def run( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/serp", + "/v2/serp", body=maybe_transform( { "search_engine": search_engine, @@ -229,7 +229,7 @@ def run_async( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/serp/async", + "/v2/serp/async", body=maybe_transform( { "search_engine": search_engine, @@ -290,7 +290,7 @@ def run_batch( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/v1/serp/batch", + "/v2/serp/batch", body=maybe_transform( { "inputs": inputs, @@ -397,7 +397,7 @@ async def run( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/serp", + "/v2/serp", body=await async_maybe_transform( { "search_engine": search_engine, @@ -508,7 +508,7 @@ async def run_async( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/serp/async", + "/v2/serp/async", body=await async_maybe_transform( { "search_engine": search_engine, @@ -569,7 +569,7 @@ async def run_batch( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/v1/serp/batch", + "/v2/serp/batch", body=await async_maybe_transform( { "inputs": inputs, diff --git a/src/nimble_python/resources/tasks.py b/src/nimble_python/resources/tasks.py index d31ffe9..a345f63 100644 --- a/src/nimble_python/resources/tasks.py +++ b/src/nimble_python/resources/tasks.py @@ -72,7 +72,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/v1/tasks", + "/v2/tasks", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -117,7 +117,7 @@ def get( if not task_id: raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}") return self._get( - path_template("/v1/tasks/{task_id}", task_id=task_id), + path_template("/v2/tasks/{task_id}", task_id=task_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -152,7 +152,7 @@ def results( if not task_id: raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}") return self._get( - path_template("/v1/tasks/{task_id}/results", task_id=task_id), + path_template("/v2/tasks/{task_id}/results", task_id=task_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -209,7 +209,7 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/v1/tasks", + "/v2/tasks", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -254,7 +254,7 @@ async def get( if not task_id: raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}") return await self._get( - path_template("/v1/tasks/{task_id}", task_id=task_id), + path_template("/v2/tasks/{task_id}", task_id=task_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -289,7 +289,7 @@ async def results( if not task_id: raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}") return await self._get( - path_template("/v1/tasks/{task_id}/results", task_id=task_id), + path_template("/v2/tasks/{task_id}/results", task_id=task_id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/nimble_python/types/__init__.py b/src/nimble_python/types/__init__.py index 3376818..dee2d91 100644 --- a/src/nimble_python/types/__init__.py +++ b/src/nimble_python/types/__init__.py @@ -21,11 +21,8 @@ from .job_list_params import JobListParams as JobListParams from .search_response import SearchResponse as SearchResponse from .serp_run_params import SerpRunParams as SerpRunParams -from .agent_run_params import AgentRunParams as AgentRunParams from .crawl_run_params import CrawlRunParams as CrawlRunParams -from .extract_response import ExtractResponse as ExtractResponse from .job_get_response import JobGetResponse as JobGetResponse -from .job_run_response import JobRunResponse as JobRunResponse from .media_run_params import MediaRunParams as MediaRunParams from .task_list_params import TaskListParams as TaskListParams from .agent_list_params import AgentListParams as AgentListParams @@ -37,48 +34,36 @@ from .serp_run_response import SerpRunResponse as SerpRunResponse from .task_get_response import TaskGetResponse as TaskGetResponse from .agent_get_response import AgentGetResponse as AgentGetResponse -from .agent_run_response import AgentRunResponse as AgentRunResponse from .batch_get_response import BatchGetResponse as BatchGetResponse from .crawl_run_response import CrawlRunResponse as CrawlRunResponse +from .extract_run_params import ExtractRunParams as ExtractRunParams from .media_run_response import MediaRunResponse as MediaRunResponse from .task_list_response import TaskListResponse as TaskListResponse +from .agent_create_params import AgentCreateParams as AgentCreateParams from .agent_list_response import AgentListResponse as AgentListResponse +from .agent_update_params import AgentUpdateParams as AgentUpdateParams from .crawl_list_response import CrawlListResponse as CrawlListResponse from .job_create_response import JobCreateResponse as JobCreateResponse from .job_update_response import JobUpdateResponse as JobUpdateResponse from .client_search_params import ClientSearchParams as ClientSearchParams +from .extract_async_params import ExtractAsyncParams as ExtractAsyncParams +from .extract_batch_params import ExtractBatchParams as ExtractBatchParams +from .extract_run_response import ExtractRunResponse as ExtractRunResponse from .fast_serp_run_params import FastSerpRunParams as FastSerpRunParams -from .agent_generate_params import AgentGenerateParams as AgentGenerateParams -from .client_extract_params import ClientExtractParams as ClientExtractParams +from .agent_create_response import AgentCreateResponse as AgentCreateResponse +from .agent_update_response import AgentUpdateResponse as AgentUpdateResponse from .crawl_status_response import CrawlStatusResponse as CrawlStatusResponse from .serp_run_async_params import SerpRunAsyncParams as SerpRunAsyncParams from .serp_run_batch_params import SerpRunBatchParams as SerpRunBatchParams -from .task_agent_run_params import TaskAgentRunParams as TaskAgentRunParams from .task_results_response import TaskResultsResponse as TaskResultsResponse -from .agent_run_async_params import AgentRunAsyncParams as AgentRunAsyncParams -from .agent_run_batch_params import AgentRunBatchParams as AgentRunBatchParams from .extract_async_response import ExtractAsyncResponse as ExtractAsyncResponse from .extract_batch_response import ExtractBatchResponse as ExtractBatchResponse from .fast_serp_run_response import FastSerpRunResponse as FastSerpRunResponse from .media_run_async_params import MediaRunAsyncParams as MediaRunAsyncParams -from .task_agent_list_params import TaskAgentListParams as TaskAgentListParams -from .agent_generate_response import AgentGenerateResponse as AgentGenerateResponse from .batch_progress_response import BatchProgressResponse as BatchProgressResponse from .serp_run_async_response import SerpRunAsyncResponse as SerpRunAsyncResponse from .serp_run_batch_response import SerpRunBatchResponse as SerpRunBatchResponse -from .task_agent_get_response import TaskAgentGetResponse as TaskAgentGetResponse -from .task_agent_run_response import TaskAgentRunResponse as TaskAgentRunResponse -from .agent_run_async_response import AgentRunAsyncResponse as AgentRunAsyncResponse -from .agent_run_batch_response import AgentRunBatchResponse as AgentRunBatchResponse from .crawl_terminate_response import CrawlTerminateResponse as CrawlTerminateResponse from .media_run_async_response import MediaRunAsyncResponse as MediaRunAsyncResponse -from .task_agent_create_params import TaskAgentCreateParams as TaskAgentCreateParams -from .task_agent_list_response import TaskAgentListResponse as TaskAgentListResponse -from .task_agent_update_params import TaskAgentUpdateParams as TaskAgentUpdateParams -from .task_agent_create_response import TaskAgentCreateResponse as TaskAgentCreateResponse -from .task_agent_update_response import TaskAgentUpdateResponse as TaskAgentUpdateResponse -from .client_extract_async_params import ClientExtractAsyncParams as ClientExtractAsyncParams -from .client_extract_batch_params import ClientExtractBatchParams as ClientExtractBatchParams -from .agent_get_generation_response import AgentGetGenerationResponse as AgentGetGenerationResponse from .domain_knowledge_get_driver_params import DomainKnowledgeGetDriverParams as DomainKnowledgeGetDriverParams from .domain_knowledge_get_driver_response import DomainKnowledgeGetDriverResponse as DomainKnowledgeGetDriverResponse diff --git a/src/nimble_python/types/task_agent_create_params.py b/src/nimble_python/types/agent_create_params.py similarity index 95% rename from src/nimble_python/types/task_agent_create_params.py rename to src/nimble_python/types/agent_create_params.py index ea9ae1d..7e09867 100644 --- a/src/nimble_python/types/task_agent_create_params.py +++ b/src/nimble_python/types/agent_create_params.py @@ -7,10 +7,10 @@ from .._types import SequenceNotStr -__all__ = ["TaskAgentCreateParams", "Sources", "SourcesAllow", "SourcesBlock"] +__all__ = ["AgentCreateParams", "Sources", "SourcesAllow", "SourcesBlock"] -class TaskAgentCreateParams(TypedDict, total=False): +class AgentCreateParams(TypedDict, total=False): agent_name: Optional[str] """Stable agent name.""" diff --git a/src/nimble_python/types/task_agent_get_response.py b/src/nimble_python/types/agent_create_response.py similarity index 95% rename from src/nimble_python/types/task_agent_get_response.py rename to src/nimble_python/types/agent_create_response.py index 28ea657..e3ce350 100644 --- a/src/nimble_python/types/task_agent_get_response.py +++ b/src/nimble_python/types/agent_create_response.py @@ -6,7 +6,7 @@ from .._models import BaseModel -__all__ = ["TaskAgentGetResponse", "Goal", "Sources", "SourcesAllow", "SourcesBlock", "SuggestedQuestion"] +__all__ = ["AgentCreateResponse", "Goal", "Sources", "SourcesAllow", "SourcesBlock", "SuggestedQuestion"] class Goal(BaseModel): @@ -75,7 +75,7 @@ class SuggestedQuestion(BaseModel): """Suggested prompt text.""" -class TaskAgentGetResponse(BaseModel): +class AgentCreateResponse(BaseModel): id: str """Unique web search agent identifier (wsa\\__).""" diff --git a/src/nimble_python/types/agent_generate_params.py b/src/nimble_python/types/agent_generate_params.py deleted file mode 100644 index ac8f9cf..0000000 --- a/src/nimble_python/types/agent_generate_params.py +++ /dev/null @@ -1,46 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Union, Optional -from typing_extensions import Required, TypeAlias, TypedDict - -from .._types import SequenceNotStr - -__all__ = [ - "AgentGenerateParams", - "CreateTemplateGenerationRequestPublicV1", - "CreateTemplateGenerationRequestPublicV1Metadata", - "CreateTemplateRefinementRequestPublicV1", -] - - -class CreateTemplateGenerationRequestPublicV1(TypedDict, total=False): - prompt: Required[str] - - url: Required[str] - - input_schema: Dict[str, object] - - metadata: Optional[CreateTemplateGenerationRequestPublicV1Metadata] - - name: Optional[str] - - output_schema: Dict[str, object] - - -class CreateTemplateGenerationRequestPublicV1Metadata(TypedDict, total=False): - description: Optional[str] - - display_name: Optional[str] - - tags: SequenceNotStr[str] - - -class CreateTemplateRefinementRequestPublicV1(TypedDict, total=False): - from_agent: Required[str] - - prompt: Required[str] - - -AgentGenerateParams: TypeAlias = Union[CreateTemplateGenerationRequestPublicV1, CreateTemplateRefinementRequestPublicV1] diff --git a/src/nimble_python/types/agent_generate_response.py b/src/nimble_python/types/agent_generate_response.py deleted file mode 100644 index 0ad67ee..0000000 --- a/src/nimble_python/types/agent_generate_response.py +++ /dev/null @@ -1,72 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, List, Optional -from datetime import datetime - -from .._models import BaseModel - -__all__ = ["AgentGenerateResponse", "GeneratedVersion", "GeneratedVersionMetadata", "GeneratedVersionSample"] - - -class GeneratedVersionMetadata(BaseModel): - data_source: Optional[str] = None - - description: Optional[str] = None - - display_name: Optional[str] = None - - domain: Optional[str] = None - - entity_type: Optional[str] = None - - tags: Optional[List[str]] = None - - vertical: Optional[str] = None - - -class GeneratedVersionSample(BaseModel): - input: Optional[object] = None - - output: Optional[object] = None - - -class GeneratedVersion(BaseModel): - id: str - - agent_name: str - - created_at: datetime - - input_schema: Dict[str, object] - - metadata: GeneratedVersionMetadata - - output_schema: Dict[str, object] - - version_number: int - - samples: Optional[List[GeneratedVersionSample]] = None - - -class AgentGenerateResponse(BaseModel): - id: str - - status: str - - agent_name: Optional[str] = None - - completed_at: Optional[datetime] = None - - created_at: Optional[datetime] = None - - error: Optional[str] = None - - generated_version: Optional[GeneratedVersion] = None - - generated_version_id: Optional[str] = None - - source_version_id: Optional[str] = None - - started_at: Optional[datetime] = None - - summary: Optional[str] = None diff --git a/src/nimble_python/types/agent_get_generation_response.py b/src/nimble_python/types/agent_get_generation_response.py deleted file mode 100644 index 5de037f..0000000 --- a/src/nimble_python/types/agent_get_generation_response.py +++ /dev/null @@ -1,72 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, List, Optional -from datetime import datetime - -from .._models import BaseModel - -__all__ = ["AgentGetGenerationResponse", "GeneratedVersion", "GeneratedVersionMetadata", "GeneratedVersionSample"] - - -class GeneratedVersionMetadata(BaseModel): - data_source: Optional[str] = None - - description: Optional[str] = None - - display_name: Optional[str] = None - - domain: Optional[str] = None - - entity_type: Optional[str] = None - - tags: Optional[List[str]] = None - - vertical: Optional[str] = None - - -class GeneratedVersionSample(BaseModel): - input: Optional[object] = None - - output: Optional[object] = None - - -class GeneratedVersion(BaseModel): - id: str - - agent_name: str - - created_at: datetime - - input_schema: Dict[str, object] - - metadata: GeneratedVersionMetadata - - output_schema: Dict[str, object] - - version_number: int - - samples: Optional[List[GeneratedVersionSample]] = None - - -class AgentGetGenerationResponse(BaseModel): - id: str - - status: str - - agent_name: Optional[str] = None - - completed_at: Optional[datetime] = None - - created_at: Optional[datetime] = None - - error: Optional[str] = None - - generated_version: Optional[GeneratedVersion] = None - - generated_version_id: Optional[str] = None - - source_version_id: Optional[str] = None - - started_at: Optional[datetime] = None - - summary: Optional[str] = None diff --git a/src/nimble_python/types/agent_get_response.py b/src/nimble_python/types/agent_get_response.py index 4de99e1..1a42467 100644 --- a/src/nimble_python/types/agent_get_response.py +++ b/src/nimble_python/types/agent_get_response.py @@ -1,57 +1,122 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal from .._models import BaseModel -__all__ = ["AgentGetResponse", "FeatureFlags", "InputProperty"] +__all__ = ["AgentGetResponse", "Goal", "Sources", "SourcesAllow", "SourcesBlock", "SuggestedQuestion"] -class FeatureFlags(BaseModel): - is_localization_supported: Optional[bool] = None +class Goal(BaseModel): + id: str + """Unique goal identifier (wsag\\__).""" - is_pagination_supported: Optional[bool] = None + goal: str + """Goal text.""" + order: int + """Zero-based goal position.""" -class InputProperty(BaseModel): - default: Union[str, bool, float, None] = None - description: Optional[str] = None +class SourcesAllow(BaseModel): + id: str + """Unique source group identifier (wsas\\__).""" - examples: Optional[List[object]] = None + domains: List[str] + """Domains included in this source group.""" - is_localization_param: Optional[bool] = None + order: int + """Zero-based source group position.""" - is_pagination_param: Optional[bool] = None + title: str + """Source group title.""" - name: Optional[str] = None - required: Optional[bool] = None +class SourcesBlock(BaseModel): + id: str + """Unique source group identifier (wsas\\__).""" - rules: Optional[List[str]] = None + domains: List[str] + """Domains included in this source group.""" - type: Optional[str] = None + order: int + """Zero-based source group position.""" + + title: str + """Source group title.""" + + +class Sources(BaseModel): + """Source guidance for the agent.""" + + allow: Optional[List[SourcesAllow]] = None + """Source groups the agent is allowed to use.""" + + avoid: Optional[str] = None + """Free-text guidance describing sources or domains to avoid.""" + + block: Optional[List[SourcesBlock]] = None + """Source groups the agent should not use.""" + + prioritize: Optional[str] = None + """Free-text guidance describing sources or domains to prioritize.""" + + +class SuggestedQuestion(BaseModel): + id: str + """Unique suggested question identifier (wsasq\\__).""" + + order: int + """Zero-based suggested question position.""" + + question: str + """Suggested prompt text.""" class AgentGetResponse(BaseModel): - display_name: str + id: str + """Unique web search agent identifier (wsa\\__).""" - is_public: bool + created_at: datetime + """When the agent was created.""" - name: str + description: str + """Agent description shown to users.""" - description: Optional[str] = None + display_name: str + """Human-friendly agent name shown to users.""" - domain: Optional[str] = None + domain_expertise: str + """Domain expertise or operating context for the agent.""" - entity_type: Optional[str] = None + effort: Literal["low", "medium", "high", "x-high", "max"] + """Default effort level for this agent's runs.""" - feature_flags: Optional[FeatureFlags] = None + goals: List[Goal] + """Ordered goals for the agent to follow.""" - input_properties: Optional[List[InputProperty]] = None + icon: str + """Icon identifier used when presenting the agent.""" - managed_by: Optional[str] = None + is_active: bool + """Whether the agent can be used to start new runs.""" output_schema: Optional[Dict[str, object]] = None + """JSON schema describing the structured output the agent should produce.""" + + sources: Sources + """Source guidance for the agent.""" + + suggested_questions: List[SuggestedQuestion] + """Suggested prompts users can run with this agent.""" + + updated_at: datetime + """When the agent was last updated.""" + + use_case: Literal["research", "enrichment", "dataset_building"] + """Primary use case supported by the agent.""" - vertical: Optional[str] = None + agent_name: Optional[str] = None + """Stable agent name.""" diff --git a/src/nimble_python/types/agent_list_params.py b/src/nimble_python/types/agent_list_params.py index 8f0a94f..752e76a 100644 --- a/src/nimble_python/types/agent_list_params.py +++ b/src/nimble_python/types/agent_list_params.py @@ -3,23 +3,14 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, TypedDict +from typing_extensions import TypedDict __all__ = ["AgentListParams"] class AgentListParams(TypedDict, total=False): limit: int - """Number of results per page""" - - managed_by: Optional[Literal["nimble", "community", "self_managed"]] - """Filter templates by attribution""" offset: int - """Pagination offset""" - - privacy: Optional[Literal["public", "private", "all"]] - """Filter by privacy level""" - search: Optional[str] - """Search templates by name, domain, or vertical""" + workspace_id: Optional[str] diff --git a/src/nimble_python/types/agent_list_response.py b/src/nimble_python/types/agent_list_response.py index 1605f1d..67e9e98 100644 --- a/src/nimble_python/types/agent_list_response.py +++ b/src/nimble_python/types/agent_list_response.py @@ -1,29 +1,144 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional -from typing_extensions import TypeAlias +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal from .._models import BaseModel -__all__ = ["AgentListResponse", "AgentListResponseItem"] +__all__ = [ + "AgentListResponse", + "Item", + "ItemGoal", + "ItemSources", + "ItemSourcesAllow", + "ItemSourcesBlock", + "ItemSuggestedQuestion", +] -class AgentListResponseItem(BaseModel): +class ItemGoal(BaseModel): + id: str + """Unique goal identifier (wsag\\__).""" + + goal: str + """Goal text.""" + + order: int + """Zero-based goal position.""" + + +class ItemSourcesAllow(BaseModel): + id: str + """Unique source group identifier (wsas\\__).""" + + domains: List[str] + """Domains included in this source group.""" + + order: int + """Zero-based source group position.""" + + title: str + """Source group title.""" + + +class ItemSourcesBlock(BaseModel): + id: str + """Unique source group identifier (wsas\\__).""" + + domains: List[str] + """Domains included in this source group.""" + + order: int + """Zero-based source group position.""" + + title: str + """Source group title.""" + + +class ItemSources(BaseModel): + """Source guidance for the agent.""" + + allow: Optional[List[ItemSourcesAllow]] = None + """Source groups the agent is allowed to use.""" + + avoid: Optional[str] = None + """Free-text guidance describing sources or domains to avoid.""" + + block: Optional[List[ItemSourcesBlock]] = None + """Source groups the agent should not use.""" + + prioritize: Optional[str] = None + """Free-text guidance describing sources or domains to prioritize.""" + + +class ItemSuggestedQuestion(BaseModel): + id: str + """Unique suggested question identifier (wsasq\\__).""" + + order: int + """Zero-based suggested question position.""" + + question: str + """Suggested prompt text.""" + + +class Item(BaseModel): + id: str + """Unique web search agent identifier (wsa\\__).""" + + created_at: datetime + """When the agent was created.""" + + description: str + """Agent description shown to users.""" + display_name: str + """Human-friendly agent name shown to users.""" + + domain_expertise: str + """Domain expertise or operating context for the agent.""" + + effort: Literal["low", "medium", "high", "x-high", "max"] + """Default effort level for this agent's runs.""" + + goals: List[ItemGoal] + """Ordered goals for the agent to follow.""" + + icon: str + """Icon identifier used when presenting the agent.""" + + is_active: bool + """Whether the agent can be used to start new runs.""" + + output_schema: Optional[Dict[str, object]] = None + """JSON schema describing the structured output the agent should produce.""" + + sources: ItemSources + """Source guidance for the agent.""" - is_public: bool + suggested_questions: List[ItemSuggestedQuestion] + """Suggested prompts users can run with this agent.""" - name: str + updated_at: datetime + """When the agent was last updated.""" - description: Optional[str] = None + use_case: Literal["research", "enrichment", "dataset_building"] + """Primary use case supported by the agent.""" - domain: Optional[str] = None + agent_name: Optional[str] = None + """Stable agent name.""" - entity_type: Optional[str] = None - managed_by: Optional[str] = None +class AgentListResponse(BaseModel): + items: List[Item] + """Items returned in this page.""" - vertical: Optional[str] = None + limit: int + """Maximum number of items returned.""" + offset: int + """Number of items skipped before this page.""" -AgentListResponse: TypeAlias = List[AgentListResponseItem] + total: int + """Total number of items matching the query.""" diff --git a/src/nimble_python/types/task_agent_update_params.py b/src/nimble_python/types/agent_update_params.py similarity index 87% rename from src/nimble_python/types/task_agent_update_params.py rename to src/nimble_python/types/agent_update_params.py index b103815..cd0462a 100644 --- a/src/nimble_python/types/task_agent_update_params.py +++ b/src/nimble_python/types/agent_update_params.py @@ -5,10 +5,10 @@ from typing import Iterable, Optional from typing_extensions import Literal, Required, TypedDict -__all__ = ["TaskAgentUpdateParams", "Body"] +__all__ = ["AgentUpdateParams", "Body"] -class TaskAgentUpdateParams(TypedDict, total=False): +class AgentUpdateParams(TypedDict, total=False): body: Required[Iterable[Body]] """A JSON Patch document per RFC 6902 — a JSON array of patch operations.""" diff --git a/src/nimble_python/types/task_agent_update_response.py b/src/nimble_python/types/agent_update_response.py similarity index 95% rename from src/nimble_python/types/task_agent_update_response.py rename to src/nimble_python/types/agent_update_response.py index 3bfc3e2..f30f9ab 100644 --- a/src/nimble_python/types/task_agent_update_response.py +++ b/src/nimble_python/types/agent_update_response.py @@ -6,7 +6,7 @@ from .._models import BaseModel -__all__ = ["TaskAgentUpdateResponse", "Goal", "Sources", "SourcesAllow", "SourcesBlock", "SuggestedQuestion"] +__all__ = ["AgentUpdateResponse", "Goal", "Sources", "SourcesAllow", "SourcesBlock", "SuggestedQuestion"] class Goal(BaseModel): @@ -75,7 +75,7 @@ class SuggestedQuestion(BaseModel): """Suggested prompt text.""" -class TaskAgentUpdateResponse(BaseModel): +class AgentUpdateResponse(BaseModel): id: str """Unique web search agent identifier (wsa\\__).""" diff --git a/src/nimble_python/types/task_agent/__init__.py b/src/nimble_python/types/agents/__init__.py similarity index 72% rename from src/nimble_python/types/task_agent/__init__.py rename to src/nimble_python/types/agents/__init__.py index 137a858..181d484 100644 --- a/src/nimble_python/types/task_agent/__init__.py +++ b/src/nimble_python/types/agents/__init__.py @@ -4,8 +4,10 @@ from .run_list_params import RunListParams as RunListParams from .run_get_response import RunGetResponse as RunGetResponse +from .run_create_params import RunCreateParams as RunCreateParams from .run_list_response import RunListResponse as RunListResponse +from .run_create_response import RunCreateResponse as RunCreateResponse +from .run_result_response import RunResultResponse as RunResultResponse from .template_list_params import TemplateListParams as TemplateListParams from .template_get_response import TemplateGetResponse as TemplateGetResponse from .template_list_response import TemplateListResponse as TemplateListResponse -from .run_get_result_response import RunGetResultResponse as RunGetResultResponse diff --git a/src/nimble_python/types/task_agent_run_params.py b/src/nimble_python/types/agents/run_create_params.py similarity index 92% rename from src/nimble_python/types/task_agent_run_params.py rename to src/nimble_python/types/agents/run_create_params.py index b8d9790..ce8c280 100644 --- a/src/nimble_python/types/task_agent_run_params.py +++ b/src/nimble_python/types/agents/run_create_params.py @@ -5,12 +5,12 @@ from typing import Dict, Union, Iterable, Optional from typing_extensions import Literal, Required, TypedDict -from .._types import SequenceNotStr +from ..._types import SequenceNotStr -__all__ = ["TaskAgentRunParams", "Sources", "SourcesAllow", "SourcesBlock"] +__all__ = ["RunCreateParams", "Sources", "SourcesAllow", "SourcesBlock"] -class TaskAgentRunParams(TypedDict, total=False): +class RunCreateParams(TypedDict, total=False): input: Required[str] """User prompt or task instructions for the run.""" diff --git a/src/nimble_python/types/task_agent_run_response.py b/src/nimble_python/types/agents/run_create_response.py similarity index 91% rename from src/nimble_python/types/task_agent_run_response.py rename to src/nimble_python/types/agents/run_create_response.py index f98c6ef..83fe1b9 100644 --- a/src/nimble_python/types/task_agent_run_response.py +++ b/src/nimble_python/types/agents/run_create_response.py @@ -4,9 +4,9 @@ from datetime import datetime from typing_extensions import Literal -from .._models import BaseModel +from ..._models import BaseModel -__all__ = ["TaskAgentRunResponse", "Error"] +__all__ = ["RunCreateResponse", "Error"] class Error(BaseModel): @@ -19,7 +19,7 @@ class Error(BaseModel): """Reference ID (equals the run id).""" -class TaskAgentRunResponse(BaseModel): +class RunCreateResponse(BaseModel): id: str """Run identifier, format "task*run*{uuid}".""" diff --git a/src/nimble_python/types/task_agent/run_get_response.py b/src/nimble_python/types/agents/run_get_response.py similarity index 100% rename from src/nimble_python/types/task_agent/run_get_response.py rename to src/nimble_python/types/agents/run_get_response.py diff --git a/src/nimble_python/types/task_agent/run_list_params.py b/src/nimble_python/types/agents/run_list_params.py similarity index 100% rename from src/nimble_python/types/task_agent/run_list_params.py rename to src/nimble_python/types/agents/run_list_params.py diff --git a/src/nimble_python/types/task_agent/run_list_response.py b/src/nimble_python/types/agents/run_list_response.py similarity index 100% rename from src/nimble_python/types/task_agent/run_list_response.py rename to src/nimble_python/types/agents/run_list_response.py diff --git a/src/nimble_python/types/task_agent/run_get_result_response.py b/src/nimble_python/types/agents/run_result_response.py similarity index 79% rename from src/nimble_python/types/task_agent/run_get_result_response.py rename to src/nimble_python/types/agents/run_result_response.py index 2e2796a..295be65 100644 --- a/src/nimble_python/types/task_agent/run_get_result_response.py +++ b/src/nimble_python/types/agents/run_result_response.py @@ -7,29 +7,29 @@ from ..._models import BaseModel __all__ = [ - "RunGetResultResponse", - "TaskRunResultPublicV1", - "TaskRunResultPublicV1Output", - "TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1", - "TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1Trust", - "TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaim", - "TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaimCitation", - "TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustSource", - "TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1", - "TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1Trust", - "TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaim", - "TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaimCitation", - "TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustSource", - "TaskRunResultPublicV1Run", - "TaskRunResultPublicV1RunError", - "TaskRunFailedResultPublicV1", - "TaskRunFailedResultPublicV1Error", - "TaskRunFailedResultPublicV1Run", - "TaskRunFailedResultPublicV1RunError", + "RunResultResponse", + "TaskRunResultPublicV2", + "TaskRunResultPublicV2Output", + "TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2", + "TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2Trust", + "TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustClaim", + "TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustClaimCitation", + "TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustSource", + "TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2", + "TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2Trust", + "TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustClaim", + "TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustClaimCitation", + "TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustSource", + "TaskRunResultPublicV2Run", + "TaskRunResultPublicV2RunError", + "TaskRunFailedResultPublicV2", + "TaskRunFailedResultPublicV2Error", + "TaskRunFailedResultPublicV2Run", + "TaskRunFailedResultPublicV2RunError", ] -class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaimCitation(BaseModel): +class TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustClaimCitation(BaseModel): """A citation backing a specific claim in the answer.""" url: str @@ -72,13 +72,13 @@ class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaimCitation(Bas """Title of the cited page.""" -class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaim(BaseModel): +class TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustClaim(BaseModel): """Trust metadata for one claim in a prose answer, keyed by callout marker.""" callout: int """Callout marker number referencing this claim in the answer text.""" - citations: List[TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaimCitation] + citations: List[TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustClaimCitation] """Citations backing this claim.""" confidence: Literal["high", "medium", "low", "pre_existing"] @@ -88,7 +88,7 @@ class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaim(BaseModel): """Why this confidence level was assigned.""" -class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustSource(BaseModel): +class TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustSource(BaseModel): """A source consulted while producing the answer.""" type: Literal["primary", "secondary"] @@ -128,10 +128,10 @@ class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustSource(BaseModel) """Title of the source page.""" -class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1Trust(BaseModel): +class TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2Trust(BaseModel): """Trust and citation metadata for the output.""" - claims: List[TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustClaim] + claims: List[TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustClaim] """Per-claim trust, keyed by callout markers in the answer text.""" confidence: Literal["high", "medium", "low", "pre_existing"] @@ -140,22 +140,22 @@ class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1Trust(BaseModel): reasoning: str """Why this confidence level was assigned.""" - sources: List[TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1TrustSource] + sources: List[TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2TrustSource] """Sources consulted while producing the answer.""" -class TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1(BaseModel): +class TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2(BaseModel): content: str """The final prose answer.""" - trust: TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1Trust + trust: TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2Trust """Trust and citation metadata for the output.""" type: Optional[Literal["text"]] = None """Output content type.""" -class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaimCitation(BaseModel): +class TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustClaimCitation(BaseModel): """A citation backing a specific claim in the answer.""" url: str @@ -198,10 +198,10 @@ class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaimCitation(Bas """Title of the cited page.""" -class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaim(BaseModel): +class TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustClaim(BaseModel): """Trust metadata for one value in a structured (JSON) answer, keyed by JSON path.""" - citations: List[TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaimCitation] + citations: List[TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustClaimCitation] """Citations backing this value.""" confidence: Literal["high", "medium", "low", "pre_existing"] @@ -214,7 +214,7 @@ class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaim(BaseModel): """Why this confidence level was assigned.""" -class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustSource(BaseModel): +class TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustSource(BaseModel): """A source consulted while producing the answer.""" type: Literal["primary", "secondary"] @@ -254,10 +254,10 @@ class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustSource(BaseModel) """Title of the source page.""" -class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1Trust(BaseModel): +class TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2Trust(BaseModel): """Trust and citation metadata for the output.""" - claims: List[TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustClaim] + claims: List[TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustClaim] """Per-value trust, keyed by JSON path in the structured output.""" confidence: Literal["high", "medium", "low", "pre_existing"] @@ -266,27 +266,27 @@ class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1Trust(BaseModel): reasoning: str """Why this confidence level was assigned.""" - sources: List[TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1TrustSource] + sources: List[TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2TrustSource] """Sources consulted while producing the answer.""" -class TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1(BaseModel): +class TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2(BaseModel): content: Union[Dict[str, object], List[object]] """The final structured output.""" - trust: TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1Trust + trust: TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2Trust """Trust and citation metadata for the output.""" type: Optional[Literal["json"]] = None """Output content type.""" -TaskRunResultPublicV1Output: TypeAlias = Union[ - TaskRunResultPublicV1OutputTaskRunTextOutputPublicV1, TaskRunResultPublicV1OutputTaskRunJsonOutputPublicV1 +TaskRunResultPublicV2Output: TypeAlias = Union[ + TaskRunResultPublicV2OutputTaskRunTextOutputPublicV2, TaskRunResultPublicV2OutputTaskRunJsonOutputPublicV2 ] -class TaskRunResultPublicV1RunError(BaseModel): +class TaskRunResultPublicV2RunError(BaseModel): """Error details when the run failed.""" message: str @@ -296,7 +296,7 @@ class TaskRunResultPublicV1RunError(BaseModel): """Reference ID (equals the run id).""" -class TaskRunResultPublicV1Run(BaseModel): +class TaskRunResultPublicV2Run(BaseModel): """Task run object with status 'completed'.""" id: str @@ -323,7 +323,7 @@ class TaskRunResultPublicV1Run(BaseModel): completed_at: Optional[datetime] = None """When the run completed.""" - error: Optional[TaskRunResultPublicV1RunError] = None + error: Optional[TaskRunResultPublicV2RunError] = None """Error details when the run failed.""" prompt: Optional[str] = None @@ -333,15 +333,15 @@ class TaskRunResultPublicV1Run(BaseModel): """When the run started executing.""" -class TaskRunResultPublicV1(BaseModel): - output: TaskRunResultPublicV1Output +class TaskRunResultPublicV2(BaseModel): + output: TaskRunResultPublicV2Output """Output from the completed task.""" - run: TaskRunResultPublicV1Run + run: TaskRunResultPublicV2Run """Task run object with status 'completed'.""" -class TaskRunFailedResultPublicV1Error(BaseModel): +class TaskRunFailedResultPublicV2Error(BaseModel): """Structured error detail.""" message: str @@ -351,7 +351,7 @@ class TaskRunFailedResultPublicV1Error(BaseModel): """Reference ID (equals the run id).""" -class TaskRunFailedResultPublicV1RunError(BaseModel): +class TaskRunFailedResultPublicV2RunError(BaseModel): """Error details when the run failed.""" message: str @@ -361,7 +361,7 @@ class TaskRunFailedResultPublicV1RunError(BaseModel): """Reference ID (equals the run id).""" -class TaskRunFailedResultPublicV1Run(BaseModel): +class TaskRunFailedResultPublicV2Run(BaseModel): """Task run object with status 'failed'.""" id: str @@ -388,7 +388,7 @@ class TaskRunFailedResultPublicV1Run(BaseModel): completed_at: Optional[datetime] = None """When the run completed.""" - error: Optional[TaskRunFailedResultPublicV1RunError] = None + error: Optional[TaskRunFailedResultPublicV2RunError] = None """Error details when the run failed.""" prompt: Optional[str] = None @@ -398,12 +398,12 @@ class TaskRunFailedResultPublicV1Run(BaseModel): """When the run started executing.""" -class TaskRunFailedResultPublicV1(BaseModel): - error: TaskRunFailedResultPublicV1Error +class TaskRunFailedResultPublicV2(BaseModel): + error: TaskRunFailedResultPublicV2Error """Structured error detail.""" - run: TaskRunFailedResultPublicV1Run + run: TaskRunFailedResultPublicV2Run """Task run object with status 'failed'.""" -RunGetResultResponse: TypeAlias = Union[TaskRunResultPublicV1, TaskRunFailedResultPublicV1] +RunResultResponse: TypeAlias = Union[TaskRunResultPublicV2, TaskRunFailedResultPublicV2] diff --git a/src/nimble_python/types/task_agent/template_get_response.py b/src/nimble_python/types/agents/template_get_response.py similarity index 100% rename from src/nimble_python/types/task_agent/template_get_response.py rename to src/nimble_python/types/agents/template_get_response.py diff --git a/src/nimble_python/types/task_agent/template_list_params.py b/src/nimble_python/types/agents/template_list_params.py similarity index 100% rename from src/nimble_python/types/task_agent/template_list_params.py rename to src/nimble_python/types/agents/template_list_params.py diff --git a/src/nimble_python/types/task_agent/template_list_response.py b/src/nimble_python/types/agents/template_list_response.py similarity index 100% rename from src/nimble_python/types/task_agent/template_list_response.py rename to src/nimble_python/types/agents/template_list_response.py diff --git a/src/nimble_python/types/extract/__init__.py b/src/nimble_python/types/extract/__init__.py new file mode 100644 index 0000000..2f71f99 --- /dev/null +++ b/src/nimble_python/types/extract/__init__.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .template_run_params import TemplateRunParams as TemplateRunParams +from .template_list_params import TemplateListParams as TemplateListParams +from .template_async_params import TemplateAsyncParams as TemplateAsyncParams +from .template_batch_params import TemplateBatchParams as TemplateBatchParams +from .template_get_response import TemplateGetResponse as TemplateGetResponse +from .template_run_response import TemplateRunResponse as TemplateRunResponse +from .template_list_response import TemplateListResponse as TemplateListResponse +from .template_update_params import TemplateUpdateParams as TemplateUpdateParams +from .template_async_response import TemplateAsyncResponse as TemplateAsyncResponse +from .template_batch_response import TemplateBatchResponse as TemplateBatchResponse +from .template_update_response import TemplateUpdateResponse as TemplateUpdateResponse diff --git a/src/nimble_python/types/agent_run_async_params.py b/src/nimble_python/types/extract/template_async_params.py similarity index 87% rename from src/nimble_python/types/agent_run_async_params.py rename to src/nimble_python/types/extract/template_async_params.py index 189da52..d662e53 100644 --- a/src/nimble_python/types/agent_run_async_params.py +++ b/src/nimble_python/types/extract/template_async_params.py @@ -5,14 +5,14 @@ from typing import Dict, List from typing_extensions import Literal, Required, TypedDict -__all__ = ["AgentRunAsyncParams"] +__all__ = ["TemplateAsyncParams"] -class AgentRunAsyncParams(TypedDict, total=False): - agent: Required[str] - +class TemplateAsyncParams(TypedDict, total=False): params: Required[Dict[str, object]] + template: Required[str] + callback_url: str """URL to call back when async operation completes""" diff --git a/src/nimble_python/types/agent_run_async_response.py b/src/nimble_python/types/extract/template_async_response.py similarity index 66% rename from src/nimble_python/types/agent_run_async_response.py rename to src/nimble_python/types/extract/template_async_response.py index 567eef8..251d93f 100644 --- a/src/nimble_python/types/agent_run_async_response.py +++ b/src/nimble_python/types/extract/template_async_response.py @@ -3,12 +3,12 @@ from typing import Dict from typing_extensions import Literal -from .._models import BaseModel +from ..._models import BaseModel -__all__ = ["AgentRunAsyncResponse"] +__all__ = ["TemplateAsyncResponse"] -class AgentRunAsyncResponse(BaseModel): +class TemplateAsyncResponse(BaseModel): status: Literal["success"] task: Dict[str, object] diff --git a/src/nimble_python/types/agent_run_batch_params.py b/src/nimble_python/types/extract/template_batch_params.py similarity index 85% rename from src/nimble_python/types/agent_run_batch_params.py rename to src/nimble_python/types/extract/template_batch_params.py index 6d5d8f3..6b3547b 100644 --- a/src/nimble_python/types/agent_run_batch_params.py +++ b/src/nimble_python/types/extract/template_batch_params.py @@ -5,10 +5,10 @@ from typing import Dict, List, Iterable from typing_extensions import Literal, Required, TypedDict -__all__ = ["AgentRunBatchParams", "Input", "SharedInputs"] +__all__ = ["TemplateBatchParams", "Input", "SharedInputs"] -class AgentRunBatchParams(TypedDict, total=False): +class TemplateBatchParams(TypedDict, total=False): inputs: Required[Iterable[Input]] shared_inputs: Required[SharedInputs] @@ -24,7 +24,7 @@ class Input(TypedDict, total=False): class SharedInputs(TypedDict, total=False): - agent: Required[str] + template: Required[str] formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] """Response formats to include. All disabled by default.""" diff --git a/src/nimble_python/types/agent_run_batch_response.py b/src/nimble_python/types/extract/template_batch_response.py similarity index 93% rename from src/nimble_python/types/agent_run_batch_response.py rename to src/nimble_python/types/extract/template_batch_response.py index 7f3210e..9ce571d 100644 --- a/src/nimble_python/types/agent_run_batch_response.py +++ b/src/nimble_python/types/extract/template_batch_response.py @@ -5,9 +5,9 @@ from pydantic import Field as FieldInfo -from .._models import BaseModel +from ..._models import BaseModel -__all__ = ["AgentRunBatchResponse", "Task"] +__all__ = ["TemplateBatchResponse", "Task"] class Task(BaseModel): @@ -60,7 +60,7 @@ class Task(BaseModel): """HTTP status code from the task execution.""" -class AgentRunBatchResponse(BaseModel): +class TemplateBatchResponse(BaseModel): """Response when a batch of extract tasks is created successfully.""" batch_id: str diff --git a/src/nimble_python/types/extract/template_get_response.py b/src/nimble_python/types/extract/template_get_response.py new file mode 100644 index 0000000..29577e1 --- /dev/null +++ b/src/nimble_python/types/extract/template_get_response.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["TemplateGetResponse", "PublishedVersion", "PublishedVersionMetadata", "PublishedVersionSample"] + + +class PublishedVersionMetadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class PublishedVersionSample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class PublishedVersion(BaseModel): + """Published version details, when available.""" + + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: PublishedVersionMetadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[PublishedVersionSample]] = None + """Sample input and output pairs for the version.""" + + +class TemplateGetResponse(BaseModel): + id: str + """Unique extract template identifier.""" + + created_at: datetime + """When the extract template was created.""" + + name: str + """Stable extract template name.""" + + updated_at: datetime + """When the extract template was last updated.""" + + published_version: Optional[PublishedVersion] = None + """Published version details, when available.""" + + published_version_id: Optional[str] = None + """Identifier of the published version.""" diff --git a/src/nimble_python/types/task_agent_list_params.py b/src/nimble_python/types/extract/template_list_params.py similarity index 57% rename from src/nimble_python/types/task_agent_list_params.py rename to src/nimble_python/types/extract/template_list_params.py index 3c30f1c..7ce2147 100644 --- a/src/nimble_python/types/task_agent_list_params.py +++ b/src/nimble_python/types/extract/template_list_params.py @@ -2,15 +2,12 @@ from __future__ import annotations -from typing import Optional from typing_extensions import TypedDict -__all__ = ["TaskAgentListParams"] +__all__ = ["TemplateListParams"] -class TaskAgentListParams(TypedDict, total=False): +class TemplateListParams(TypedDict, total=False): limit: int offset: int - - workspace_id: Optional[str] diff --git a/src/nimble_python/types/extract/template_list_response.py b/src/nimble_python/types/extract/template_list_response.py new file mode 100644 index 0000000..a8e7096 --- /dev/null +++ b/src/nimble_python/types/extract/template_list_response.py @@ -0,0 +1,109 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = [ + "TemplateListResponse", + "Item", + "ItemPublishedVersion", + "ItemPublishedVersionMetadata", + "ItemPublishedVersionSample", +] + + +class ItemPublishedVersionMetadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class ItemPublishedVersionSample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class ItemPublishedVersion(BaseModel): + """Published version details, when available.""" + + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: ItemPublishedVersionMetadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[ItemPublishedVersionSample]] = None + """Sample input and output pairs for the version.""" + + +class Item(BaseModel): + id: str + """Unique extract template identifier.""" + + created_at: datetime + """When the extract template was created.""" + + name: str + """Stable extract template name.""" + + updated_at: datetime + """When the extract template was last updated.""" + + published_version: Optional[ItemPublishedVersion] = None + """Published version details, when available.""" + + published_version_id: Optional[str] = None + """Identifier of the published version.""" + + +class TemplateListResponse(BaseModel): + items: List[Item] + """Items returned in this page.""" + + limit: int + """Maximum number of items returned.""" + + offset: int + """Number of items skipped before this page.""" + + total: int + """Total number of items matching the query.""" diff --git a/src/nimble_python/types/agent_run_params.py b/src/nimble_python/types/extract/template_run_params.py similarity index 79% rename from src/nimble_python/types/agent_run_params.py rename to src/nimble_python/types/extract/template_run_params.py index d608389..3374bd5 100644 --- a/src/nimble_python/types/agent_run_params.py +++ b/src/nimble_python/types/extract/template_run_params.py @@ -5,14 +5,14 @@ from typing import Dict, List from typing_extensions import Literal, Required, TypedDict -__all__ = ["AgentRunParams"] +__all__ = ["TemplateRunParams"] -class AgentRunParams(TypedDict, total=False): - agent: Required[str] - +class TemplateRunParams(TypedDict, total=False): params: Required[Dict[str, object]] + template: Required[str] + formats: List[Literal["html", "markdown", "screenshot", "headers", "links"]] """Response formats to include. All disabled by default.""" diff --git a/src/nimble_python/types/extract_response.py b/src/nimble_python/types/extract/template_run_response.py similarity index 98% rename from src/nimble_python/types/extract_response.py rename to src/nimble_python/types/extract/template_run_response.py index d1fb0aa..61e5fd7 100644 --- a/src/nimble_python/types/extract_response.py +++ b/src/nimble_python/types/extract/template_run_response.py @@ -5,10 +5,10 @@ from pydantic import Field as FieldInfo -from .._models import BaseModel +from ..._models import BaseModel __all__ = [ - "ExtractResponse", + "TemplateRunResponse", "Data", "DataBrowserActions", "DataBrowserActionsResult", @@ -313,7 +313,7 @@ class PaginationUnionMember1(BaseModel): Pagination: TypeAlias = Union[PaginationNextPageParams, List[PaginationUnionMember1]] -class ExtractResponse(BaseModel): +class TemplateRunResponse(BaseModel): data: Data metadata: Metadata diff --git a/src/nimble_python/types/extract/template_update_params.py b/src/nimble_python/types/extract/template_update_params.py new file mode 100644 index 0000000..8e87f96 --- /dev/null +++ b/src/nimble_python/types/extract/template_update_params.py @@ -0,0 +1,32 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable, Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["TemplateUpdateParams", "Body"] + + +class TemplateUpdateParams(TypedDict, total=False): + body: Required[Iterable[Body]] + """A JSON Patch document per RFC 6902 — a JSON array of patch operations.""" + + +_BodyReservedKeywords = TypedDict( + "_BodyReservedKeywords", + { + "from": Optional[str], + }, + total=False, +) + + +class Body(_BodyReservedKeywords, total=False): + """A single JSON Patch operation per RFC 6902.""" + + op: Required[Literal["add", "remove", "replace", "move", "copy", "test"]] + + path: Required[str] + + value: object diff --git a/src/nimble_python/types/extract/template_update_response.py b/src/nimble_python/types/extract/template_update_response.py new file mode 100644 index 0000000..1f094a2 --- /dev/null +++ b/src/nimble_python/types/extract/template_update_response.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["TemplateUpdateResponse", "PublishedVersion", "PublishedVersionMetadata", "PublishedVersionSample"] + + +class PublishedVersionMetadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class PublishedVersionSample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class PublishedVersion(BaseModel): + """Published version details, when available.""" + + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: PublishedVersionMetadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[PublishedVersionSample]] = None + """Sample input and output pairs for the version.""" + + +class TemplateUpdateResponse(BaseModel): + id: str + """Unique extract template identifier.""" + + created_at: datetime + """When the extract template was created.""" + + name: str + """Stable extract template name.""" + + updated_at: datetime + """When the extract template was last updated.""" + + published_version: Optional[PublishedVersion] = None + """Published version details, when available.""" + + published_version_id: Optional[str] = None + """Identifier of the published version.""" diff --git a/src/nimble_python/types/extract/templates/__init__.py b/src/nimble_python/types/extract/templates/__init__.py new file mode 100644 index 0000000..6b00805 --- /dev/null +++ b/src/nimble_python/types/extract/templates/__init__.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .version_list_params import VersionListParams as VersionListParams +from .version_get_response import VersionGetResponse as VersionGetResponse +from .version_list_response import VersionListResponse as VersionListResponse +from .generation_get_response import GenerationGetResponse as GenerationGetResponse +from .generation_create_params import GenerationCreateParams as GenerationCreateParams +from .generation_create_response import GenerationCreateResponse as GenerationCreateResponse diff --git a/src/nimble_python/types/extract/templates/generation_create_params.py b/src/nimble_python/types/extract/templates/generation_create_params.py new file mode 100644 index 0000000..27cb728 --- /dev/null +++ b/src/nimble_python/types/extract/templates/generation_create_params.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Optional +from typing_extensions import Required, TypeAlias, TypedDict + +from ...._types import SequenceNotStr + +__all__ = [ + "GenerationCreateParams", + "CreateExtractTemplateGenerationRequestPublicV2", + "CreateExtractTemplateGenerationRequestPublicV2Metadata", + "CreateExtractTemplateRefinementRequestPublicV2", +] + + +class CreateExtractTemplateGenerationRequestPublicV2(TypedDict, total=False): + prompt: Required[str] + """Instructions for generating the extract template.""" + + url: Required[str] + """Example URL used to generate the extract template.""" + + input_schema: Dict[str, object] + """Optional JSON schema describing expected input parameters.""" + + metadata: Optional[CreateExtractTemplateGenerationRequestPublicV2Metadata] + """Metadata to attach to the generated extract template.""" + + name: Optional[str] + """Optional stable name for the generated extract template.""" + + output_schema: Dict[str, object] + """Optional JSON schema describing desired extracted output.""" + + +class CreateExtractTemplateGenerationRequestPublicV2Metadata(TypedDict, total=False): + """Metadata to attach to the generated extract template.""" + + description: Optional[str] + """Description for the generated template.""" + + display_name: Optional[str] + """Human-friendly display name for the generated template.""" + + tags: SequenceNotStr[str] + """Tags to associate with the generated template.""" + + +class CreateExtractTemplateRefinementRequestPublicV2(TypedDict, total=False): + from_extract_template: Required[str] + """Name of the source extract template to refine.""" + + prompt: Required[str] + """Instructions for refining the extract template.""" + + +GenerationCreateParams: TypeAlias = Union[ + CreateExtractTemplateGenerationRequestPublicV2, CreateExtractTemplateRefinementRequestPublicV2 +] diff --git a/src/nimble_python/types/extract/templates/generation_create_response.py b/src/nimble_python/types/extract/templates/generation_create_response.py new file mode 100644 index 0000000..76db5e6 --- /dev/null +++ b/src/nimble_python/types/extract/templates/generation_create_response.py @@ -0,0 +1,104 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["GenerationCreateResponse", "GeneratedVersion", "GeneratedVersionMetadata", "GeneratedVersionSample"] + + +class GeneratedVersionMetadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class GeneratedVersionSample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class GeneratedVersion(BaseModel): + """Generated version details, when available.""" + + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: GeneratedVersionMetadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[GeneratedVersionSample]] = None + """Sample input and output pairs for the version.""" + + +class GenerationCreateResponse(BaseModel): + id: str + """Unique extract template generation identifier.""" + + status: str + """Current generation status.""" + + completed_at: Optional[datetime] = None + """When the generation completed.""" + + created_at: Optional[datetime] = None + """When the generation was created.""" + + error: Optional[str] = None + """Error message when generation failed.""" + + generated_version: Optional[GeneratedVersion] = None + """Generated version details, when available.""" + + generated_version_id: Optional[str] = None + """Identifier of the generated version.""" + + name: Optional[str] = None + """Extract template name associated with the generation.""" + + source_version_id: Optional[str] = None + """Identifier of the version being refined.""" + + started_at: Optional[datetime] = None + """When the generation started executing.""" + + summary: Optional[str] = None + """Summary of the generation result.""" diff --git a/src/nimble_python/types/extract/templates/generation_get_response.py b/src/nimble_python/types/extract/templates/generation_get_response.py new file mode 100644 index 0000000..89c0fe2 --- /dev/null +++ b/src/nimble_python/types/extract/templates/generation_get_response.py @@ -0,0 +1,104 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["GenerationGetResponse", "GeneratedVersion", "GeneratedVersionMetadata", "GeneratedVersionSample"] + + +class GeneratedVersionMetadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class GeneratedVersionSample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class GeneratedVersion(BaseModel): + """Generated version details, when available.""" + + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: GeneratedVersionMetadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[GeneratedVersionSample]] = None + """Sample input and output pairs for the version.""" + + +class GenerationGetResponse(BaseModel): + id: str + """Unique extract template generation identifier.""" + + status: str + """Current generation status.""" + + completed_at: Optional[datetime] = None + """When the generation completed.""" + + created_at: Optional[datetime] = None + """When the generation was created.""" + + error: Optional[str] = None + """Error message when generation failed.""" + + generated_version: Optional[GeneratedVersion] = None + """Generated version details, when available.""" + + generated_version_id: Optional[str] = None + """Identifier of the generated version.""" + + name: Optional[str] = None + """Extract template name associated with the generation.""" + + source_version_id: Optional[str] = None + """Identifier of the version being refined.""" + + started_at: Optional[datetime] = None + """When the generation started executing.""" + + summary: Optional[str] = None + """Summary of the generation result.""" diff --git a/src/nimble_python/types/extract/templates/version_get_response.py b/src/nimble_python/types/extract/templates/version_get_response.py new file mode 100644 index 0000000..0bf16c0 --- /dev/null +++ b/src/nimble_python/types/extract/templates/version_get_response.py @@ -0,0 +1,67 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["VersionGetResponse", "Metadata", "Sample"] + + +class Metadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class Sample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class VersionGetResponse(BaseModel): + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: Metadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[Sample]] = None + """Sample input and output pairs for the version.""" diff --git a/src/nimble_python/types/extract/templates/version_list_params.py b/src/nimble_python/types/extract/templates/version_list_params.py new file mode 100644 index 0000000..72fdd59 --- /dev/null +++ b/src/nimble_python/types/extract/templates/version_list_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["VersionListParams"] + + +class VersionListParams(TypedDict, total=False): + limit: int + + offset: int diff --git a/src/nimble_python/types/extract/templates/version_list_response.py b/src/nimble_python/types/extract/templates/version_list_response.py new file mode 100644 index 0000000..219269e --- /dev/null +++ b/src/nimble_python/types/extract/templates/version_list_response.py @@ -0,0 +1,81 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["VersionListResponse", "Item", "ItemMetadata", "ItemSample"] + + +class ItemMetadata(BaseModel): + """Metadata associated with this version.""" + + data_source: Optional[str] = None + """Data source associated with the version.""" + + description: Optional[str] = None + """Version description shown to users.""" + + display_name: Optional[str] = None + """Human-friendly version display name.""" + + domain: Optional[str] = None + """Domain associated with the version.""" + + entity_type: Optional[str] = None + """Entity type produced by the version.""" + + tags: Optional[List[str]] = None + """Tags associated with the version.""" + + vertical: Optional[str] = None + """Business vertical associated with the version.""" + + +class ItemSample(BaseModel): + input: Optional[object] = None + """Sample input parameters for the version.""" + + output: Optional[object] = None + """Sample output produced by the version.""" + + +class Item(BaseModel): + id: str + """Unique extract template version identifier.""" + + created_at: datetime + """When the version was created.""" + + input_schema: Dict[str, object] + """JSON schema describing accepted input parameters.""" + + metadata: ItemMetadata + """Metadata associated with this version.""" + + name: str + """Extract template name this version belongs to.""" + + output_schema: Dict[str, object] + """JSON schema describing extracted output.""" + + version_number: int + """Monotonic version number for the extract template.""" + + samples: Optional[List[ItemSample]] = None + """Sample input and output pairs for the version.""" + + +class VersionListResponse(BaseModel): + items: List[Item] + """Items returned in this page.""" + + limit: int + """Maximum number of items returned.""" + + offset: int + """Number of items skipped before this page.""" + + total: int + """Total number of items matching the query.""" diff --git a/src/nimble_python/types/client_extract_async_params.py b/src/nimble_python/types/extract_async_params.py similarity index 99% rename from src/nimble_python/types/client_extract_async_params.py rename to src/nimble_python/types/extract_async_params.py index 8091527..160cd7b 100644 --- a/src/nimble_python/types/client_extract_async_params.py +++ b/src/nimble_python/types/extract_async_params.py @@ -22,7 +22,7 @@ from .shared_params.wait_for_navigation_action import WaitForNavigationAction __all__ = [ - "ClientExtractAsyncParams", + "ExtractAsyncParams", "Browser", "BrowserUnionMember1", "BrowserAction", @@ -33,7 +33,7 @@ ] -class ClientExtractAsyncParams(TypedDict, total=False): +class ExtractAsyncParams(TypedDict, total=False): url: Required[str] """Target URL to scrape""" diff --git a/src/nimble_python/types/client_extract_batch_params.py b/src/nimble_python/types/extract_batch_params.py similarity index 99% rename from src/nimble_python/types/client_extract_batch_params.py rename to src/nimble_python/types/extract_batch_params.py index b1de68a..4909484 100644 --- a/src/nimble_python/types/client_extract_batch_params.py +++ b/src/nimble_python/types/extract_batch_params.py @@ -22,7 +22,7 @@ from .shared_params.wait_for_navigation_action import WaitForNavigationAction __all__ = [ - "ClientExtractBatchParams", + "ExtractBatchParams", "Input", "InputBrowser", "InputBrowserUnionMember1", @@ -42,7 +42,7 @@ ] -class ClientExtractBatchParams(TypedDict, total=False): +class ExtractBatchParams(TypedDict, total=False): inputs: Required[Iterable[Input]] """Array of extraction requests. diff --git a/src/nimble_python/types/client_extract_params.py b/src/nimble_python/types/extract_run_params.py similarity index 99% rename from src/nimble_python/types/client_extract_params.py rename to src/nimble_python/types/extract_run_params.py index 0309a49..de18099 100644 --- a/src/nimble_python/types/client_extract_params.py +++ b/src/nimble_python/types/extract_run_params.py @@ -22,7 +22,7 @@ from .shared_params.wait_for_navigation_action import WaitForNavigationAction __all__ = [ - "ClientExtractParams", + "ExtractRunParams", "Browser", "BrowserUnionMember1", "BrowserAction", @@ -33,7 +33,7 @@ ] -class ClientExtractParams(TypedDict, total=False): +class ExtractRunParams(TypedDict, total=False): url: Required[str] """Target URL to scrape""" diff --git a/src/nimble_python/types/agent_run_response.py b/src/nimble_python/types/extract_run_response.py similarity index 99% rename from src/nimble_python/types/agent_run_response.py rename to src/nimble_python/types/extract_run_response.py index cdec809..a7d079f 100644 --- a/src/nimble_python/types/agent_run_response.py +++ b/src/nimble_python/types/extract_run_response.py @@ -8,7 +8,7 @@ from .._models import BaseModel __all__ = [ - "AgentRunResponse", + "ExtractRunResponse", "Data", "DataBrowserActions", "DataBrowserActionsResult", @@ -313,7 +313,7 @@ class PaginationUnionMember1(BaseModel): Pagination: TypeAlias = Union[PaginationNextPageParams, List[PaginationUnionMember1]] -class AgentRunResponse(BaseModel): +class ExtractRunResponse(BaseModel): data: Data metadata: Metadata diff --git a/src/nimble_python/types/job_create_params.py b/src/nimble_python/types/job_create_params.py index e907088..8014736 100644 --- a/src/nimble_python/types/job_create_params.py +++ b/src/nimble_python/types/job_create_params.py @@ -9,8 +9,8 @@ class JobCreateParams(TypedDict, total=False): - agent_name: Required[str] - """Name of the agent to run.""" + extract_template_name: Required[str] + """Name of the extract template to run.""" name: Required[str] """Job name.""" diff --git a/src/nimble_python/types/job_create_response.py b/src/nimble_python/types/job_create_response.py index 0431e91..f851be8 100644 --- a/src/nimble_python/types/job_create_response.py +++ b/src/nimble_python/types/job_create_response.py @@ -60,9 +60,6 @@ class JobCreateResponse(BaseModel): name: str """Job name.""" - agent_name: Optional[str] = None - """Name of the agent this job runs.""" - created_at: Optional[datetime] = None """When the job was created.""" @@ -75,6 +72,9 @@ class JobCreateResponse(BaseModel): display_name: Optional[str] = None """Human-friendly job name shown in the UI.""" + extract_template_name: Optional[str] = None + """Name of the extract template this job runs.""" + inputs: Optional[Inputs] = None """Configuration for the input data a job processes.""" diff --git a/src/nimble_python/types/job_get_response.py b/src/nimble_python/types/job_get_response.py index 378c9cf..50c512a 100644 --- a/src/nimble_python/types/job_get_response.py +++ b/src/nimble_python/types/job_get_response.py @@ -60,9 +60,6 @@ class JobGetResponse(BaseModel): name: str """Job name.""" - agent_name: Optional[str] = None - """Name of the agent this job runs.""" - created_at: Optional[datetime] = None """When the job was created.""" @@ -75,6 +72,9 @@ class JobGetResponse(BaseModel): display_name: Optional[str] = None """Human-friendly job name shown in the UI.""" + extract_template_name: Optional[str] = None + """Name of the extract template this job runs.""" + inputs: Optional[Inputs] = None """Configuration for the input data a job processes.""" diff --git a/src/nimble_python/types/job_list_params.py b/src/nimble_python/types/job_list_params.py index cfaaa90..51de879 100644 --- a/src/nimble_python/types/job_list_params.py +++ b/src/nimble_python/types/job_list_params.py @@ -2,19 +2,12 @@ from __future__ import annotations -from typing import Optional from typing_extensions import TypedDict __all__ = ["JobListParams"] class JobListParams(TypedDict, total=False): - agent_name: Optional[str] - """Filter by agent name""" + limit: int - page: int - - per_page: int - - q: Optional[str] - """Search by name or display name""" + offset: int diff --git a/src/nimble_python/types/job_list_response.py b/src/nimble_python/types/job_list_response.py index 90450e2..fab90b4 100644 --- a/src/nimble_python/types/job_list_response.py +++ b/src/nimble_python/types/job_list_response.py @@ -60,9 +60,6 @@ class Item(BaseModel): name: str """Job name.""" - agent_name: Optional[str] = None - """Name of the agent this job runs.""" - created_at: Optional[datetime] = None """When the job was created.""" @@ -75,6 +72,9 @@ class Item(BaseModel): display_name: Optional[str] = None """Human-friendly job name shown in the UI.""" + extract_template_name: Optional[str] = None + """Name of the extract template this job runs.""" + inputs: Optional[ItemInputs] = None """Configuration for the input data a job processes.""" @@ -94,16 +94,14 @@ class Item(BaseModel): class JobListResponse(BaseModel): - """A page of jobs.""" - items: List[Item] - """Jobs on this page.""" + """Items returned in this page.""" - total: int - """Total number of jobs matching the query.""" + limit: int + """Maximum number of items returned.""" - page: Optional[int] = None - """Current page number.""" + offset: int + """Number of items skipped before this page.""" - per_page: Optional[int] = None - """Number of items per page.""" + total: int + """Total number of items matching the query.""" diff --git a/src/nimble_python/types/job_update_response.py b/src/nimble_python/types/job_update_response.py index ca511c9..dbe6c3d 100644 --- a/src/nimble_python/types/job_update_response.py +++ b/src/nimble_python/types/job_update_response.py @@ -60,9 +60,6 @@ class JobUpdateResponse(BaseModel): name: str """Job name.""" - agent_name: Optional[str] = None - """Name of the agent this job runs.""" - created_at: Optional[datetime] = None """When the job was created.""" @@ -75,6 +72,9 @@ class JobUpdateResponse(BaseModel): display_name: Optional[str] = None """Human-friendly job name shown in the UI.""" + extract_template_name: Optional[str] = None + """Name of the extract template this job runs.""" + inputs: Optional[Inputs] = None """Configuration for the input data a job processes.""" diff --git a/src/nimble_python/types/jobs/__init__.py b/src/nimble_python/types/jobs/__init__.py index 60b3aea..fd83456 100644 --- a/src/nimble_python/types/jobs/__init__.py +++ b/src/nimble_python/types/jobs/__init__.py @@ -6,3 +6,4 @@ from .run_get_response import RunGetResponse as RunGetResponse from .run_list_response import RunListResponse as RunListResponse from .run_cancel_response import RunCancelResponse as RunCancelResponse +from .run_create_response import RunCreateResponse as RunCreateResponse diff --git a/src/nimble_python/types/job_run_response.py b/src/nimble_python/types/jobs/run_create_response.py similarity index 90% rename from src/nimble_python/types/job_run_response.py rename to src/nimble_python/types/jobs/run_create_response.py index 8c62589..a9961bd 100644 --- a/src/nimble_python/types/job_run_response.py +++ b/src/nimble_python/types/jobs/run_create_response.py @@ -4,12 +4,12 @@ from datetime import datetime from typing_extensions import Literal -from .._models import BaseModel +from ..._models import BaseModel -__all__ = ["JobRunResponse"] +__all__ = ["RunCreateResponse"] -class JobRunResponse(BaseModel): +class RunCreateResponse(BaseModel): """A single execution of a job.""" id: str diff --git a/src/nimble_python/types/jobs/run_get_response.py b/src/nimble_python/types/jobs/run_get_response.py index ff6b49d..be09b82 100644 --- a/src/nimble_python/types/jobs/run_get_response.py +++ b/src/nimble_python/types/jobs/run_get_response.py @@ -28,12 +28,12 @@ class Job(BaseModel): name: str """Internal job name.""" - agent_name: Optional[str] = None - """Name of the agent this job runs.""" - display_name: Optional[str] = None """Human-friendly job name shown in the UI.""" + extract_template_name: Optional[str] = None + """Name of the extract template this job runs.""" + schedule: Optional[JobSchedule] = None """Cron-based schedule controlling when a job runs automatically.""" diff --git a/src/nimble_python/types/jobs/run_list_params.py b/src/nimble_python/types/jobs/run_list_params.py index 28c39cb..345551e 100644 --- a/src/nimble_python/types/jobs/run_list_params.py +++ b/src/nimble_python/types/jobs/run_list_params.py @@ -2,16 +2,12 @@ from __future__ import annotations -from typing import Optional from typing_extensions import TypedDict __all__ = ["RunListParams"] class RunListParams(TypedDict, total=False): - page: int + limit: int - per_page: int - - status: Optional[str] - """Filter by status""" + offset: int diff --git a/src/nimble_python/types/jobs/run_list_response.py b/src/nimble_python/types/jobs/run_list_response.py index 175ec90..4a71ed7 100644 --- a/src/nimble_python/types/jobs/run_list_response.py +++ b/src/nimble_python/types/jobs/run_list_response.py @@ -41,16 +41,14 @@ class Item(BaseModel): class RunListResponse(BaseModel): - """A page of job runs.""" - items: List[Item] - """Runs on this page.""" + """Items returned in this page.""" - total: int - """Total number of runs matching the query.""" + limit: int + """Maximum number of items returned.""" - page: Optional[int] = None - """Current page number.""" + offset: int + """Number of items skipped before this page.""" - per_page: Optional[int] = None - """Number of items per page.""" + total: int + """Total number of items matching the query.""" diff --git a/src/nimble_python/types/task_agent_create_response.py b/src/nimble_python/types/task_agent_create_response.py deleted file mode 100644 index f8fc705..0000000 --- a/src/nimble_python/types/task_agent_create_response.py +++ /dev/null @@ -1,122 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, List, Optional -from datetime import datetime -from typing_extensions import Literal - -from .._models import BaseModel - -__all__ = ["TaskAgentCreateResponse", "Goal", "Sources", "SourcesAllow", "SourcesBlock", "SuggestedQuestion"] - - -class Goal(BaseModel): - id: str - """Unique goal identifier (wsag\\__).""" - - goal: str - """Goal text.""" - - order: int - """Zero-based goal position.""" - - -class SourcesAllow(BaseModel): - id: str - """Unique source group identifier (wsas\\__).""" - - domains: List[str] - """Domains included in this source group.""" - - order: int - """Zero-based source group position.""" - - title: str - """Source group title.""" - - -class SourcesBlock(BaseModel): - id: str - """Unique source group identifier (wsas\\__).""" - - domains: List[str] - """Domains included in this source group.""" - - order: int - """Zero-based source group position.""" - - title: str - """Source group title.""" - - -class Sources(BaseModel): - """Source guidance for the agent.""" - - allow: Optional[List[SourcesAllow]] = None - """Source groups the agent is allowed to use.""" - - avoid: Optional[str] = None - """Free-text guidance describing sources or domains to avoid.""" - - block: Optional[List[SourcesBlock]] = None - """Source groups the agent should not use.""" - - prioritize: Optional[str] = None - """Free-text guidance describing sources or domains to prioritize.""" - - -class SuggestedQuestion(BaseModel): - id: str - """Unique suggested question identifier (wsasq\\__).""" - - order: int - """Zero-based suggested question position.""" - - question: str - """Suggested prompt text.""" - - -class TaskAgentCreateResponse(BaseModel): - id: str - """Unique web search agent identifier (wsa\\__).""" - - created_at: datetime - """When the agent was created.""" - - description: str - """Agent description shown to users.""" - - display_name: str - """Human-friendly agent name shown to users.""" - - domain_expertise: str - """Domain expertise or operating context for the agent.""" - - effort: Literal["low", "medium", "high", "x-high", "max"] - """Default effort level for this agent's runs.""" - - goals: List[Goal] - """Ordered goals for the agent to follow.""" - - icon: str - """Icon identifier used when presenting the agent.""" - - is_active: bool - """Whether the agent can be used to start new runs.""" - - output_schema: Optional[Dict[str, object]] = None - """JSON schema describing the structured output the agent should produce.""" - - sources: Sources - """Source guidance for the agent.""" - - suggested_questions: List[SuggestedQuestion] - """Suggested prompts users can run with this agent.""" - - updated_at: datetime - """When the agent was last updated.""" - - use_case: Literal["research", "enrichment", "dataset_building"] - """Primary use case supported by the agent.""" - - agent_name: Optional[str] = None - """Stable agent name.""" diff --git a/src/nimble_python/types/task_agent_list_response.py b/src/nimble_python/types/task_agent_list_response.py deleted file mode 100644 index 330c62e..0000000 --- a/src/nimble_python/types/task_agent_list_response.py +++ /dev/null @@ -1,144 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, List, Optional -from datetime import datetime -from typing_extensions import Literal - -from .._models import BaseModel - -__all__ = [ - "TaskAgentListResponse", - "Item", - "ItemGoal", - "ItemSources", - "ItemSourcesAllow", - "ItemSourcesBlock", - "ItemSuggestedQuestion", -] - - -class ItemGoal(BaseModel): - id: str - """Unique goal identifier (wsag\\__).""" - - goal: str - """Goal text.""" - - order: int - """Zero-based goal position.""" - - -class ItemSourcesAllow(BaseModel): - id: str - """Unique source group identifier (wsas\\__).""" - - domains: List[str] - """Domains included in this source group.""" - - order: int - """Zero-based source group position.""" - - title: str - """Source group title.""" - - -class ItemSourcesBlock(BaseModel): - id: str - """Unique source group identifier (wsas\\__).""" - - domains: List[str] - """Domains included in this source group.""" - - order: int - """Zero-based source group position.""" - - title: str - """Source group title.""" - - -class ItemSources(BaseModel): - """Source guidance for the agent.""" - - allow: Optional[List[ItemSourcesAllow]] = None - """Source groups the agent is allowed to use.""" - - avoid: Optional[str] = None - """Free-text guidance describing sources or domains to avoid.""" - - block: Optional[List[ItemSourcesBlock]] = None - """Source groups the agent should not use.""" - - prioritize: Optional[str] = None - """Free-text guidance describing sources or domains to prioritize.""" - - -class ItemSuggestedQuestion(BaseModel): - id: str - """Unique suggested question identifier (wsasq\\__).""" - - order: int - """Zero-based suggested question position.""" - - question: str - """Suggested prompt text.""" - - -class Item(BaseModel): - id: str - """Unique web search agent identifier (wsa\\__).""" - - created_at: datetime - """When the agent was created.""" - - description: str - """Agent description shown to users.""" - - display_name: str - """Human-friendly agent name shown to users.""" - - domain_expertise: str - """Domain expertise or operating context for the agent.""" - - effort: Literal["low", "medium", "high", "x-high", "max"] - """Default effort level for this agent's runs.""" - - goals: List[ItemGoal] - """Ordered goals for the agent to follow.""" - - icon: str - """Icon identifier used when presenting the agent.""" - - is_active: bool - """Whether the agent can be used to start new runs.""" - - output_schema: Optional[Dict[str, object]] = None - """JSON schema describing the structured output the agent should produce.""" - - sources: ItemSources - """Source guidance for the agent.""" - - suggested_questions: List[ItemSuggestedQuestion] - """Suggested prompts users can run with this agent.""" - - updated_at: datetime - """When the agent was last updated.""" - - use_case: Literal["research", "enrichment", "dataset_building"] - """Primary use case supported by the agent.""" - - agent_name: Optional[str] = None - """Stable agent name.""" - - -class TaskAgentListResponse(BaseModel): - items: List[Item] - """Items returned in this page.""" - - limit: int - """Maximum number of items returned.""" - - offset: int - """Number of items skipped before this page.""" - - total: int - """Total number of items matching the query.""" diff --git a/tests/api_resources/task_agent/__init__.py b/tests/api_resources/agents/__init__.py similarity index 100% rename from tests/api_resources/task_agent/__init__.py rename to tests/api_resources/agents/__init__.py diff --git a/tests/api_resources/agents/test_runs.py b/tests/api_resources/agents/test_runs.py new file mode 100644 index 0000000..547ada8 --- /dev/null +++ b/tests/api_resources/agents/test_runs.py @@ -0,0 +1,601 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from nimble_python import Nimble, AsyncNimble +from nimble_python.types.agents import ( + RunGetResponse, + RunListResponse, + RunCreateResponse, + RunResultResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRuns: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: Nimble) -> None: + run = client.agents.runs.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + ) + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Nimble) -> None: + run = client.agents.runs.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + effort="low", + enable_events=True, + input_data=[{"foo": "bar"}], + output_schema={"foo": "bar"}, + previous_interaction_id="previous_interaction_id", + sources={ + "allow": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "avoid": "avoid", + "block": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "prioritize": "prioritize", + }, + ) + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Nimble) -> None: + response = client.agents.runs.with_raw_response.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Nimble) -> None: + with client.agents.runs.with_streaming_response.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_create(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.runs.with_raw_response.create( + agent_id="", + input="input", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Nimble) -> None: + run = client.agents.runs.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunListResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Nimble) -> None: + run = client.agents.runs.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + limit=1, + offset=0, + ) + assert_matches_type(RunListResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Nimble) -> None: + response = client.agents.runs.with_raw_response.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert_matches_type(RunListResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Nimble) -> None: + with client.agents.runs.with_streaming_response.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert_matches_type(RunListResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_list(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.runs.with_raw_response.list( + agent_id="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get(self, client: Nimble) -> None: + run = client.agents.runs.get( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunGetResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get(self, client: Nimble) -> None: + response = client.agents.runs.with_raw_response.get( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert_matches_type(RunGetResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Nimble) -> None: + with client.agents.runs.with_streaming_response.get( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert_matches_type(RunGetResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_get(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.runs.with_raw_response.get( + run_id="run_id", + agent_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.agents.runs.with_raw_response.get( + run_id="", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_result(self, client: Nimble) -> None: + run = client.agents.runs.result( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunResultResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_result(self, client: Nimble) -> None: + response = client.agents.runs.with_raw_response.result( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert_matches_type(RunResultResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_result(self, client: Nimble) -> None: + with client.agents.runs.with_streaming_response.result( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert_matches_type(RunResultResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_result(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.runs.with_raw_response.result( + run_id="run_id", + agent_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.agents.runs.with_raw_response.result( + run_id="", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_stream_events(self, client: Nimble) -> None: + run = client.agents.runs.stream_events( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert run is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_stream_events(self, client: Nimble) -> None: + response = client.agents.runs.with_raw_response.stream_events( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert run is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_stream_events(self, client: Nimble) -> None: + with client.agents.runs.with_streaming_response.stream_events( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert run is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_stream_events(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.runs.with_raw_response.stream_events( + run_id="run_id", + agent_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.agents.runs.with_raw_response.stream_events( + run_id="", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + +class TestAsyncRuns: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + ) + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + effort="low", + enable_events=True, + input_data=[{"foo": "bar"}], + output_schema={"foo": "bar"}, + previous_interaction_id="previous_interaction_id", + sources={ + "allow": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "avoid": "avoid", + "block": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "prioritize": "prioritize", + }, + ) + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.runs.with_raw_response.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncNimble) -> None: + async with async_client.agents.runs.with_streaming_response.create( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + input="input", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_create(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.runs.with_raw_response.create( + agent_id="", + input="input", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunListResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + limit=1, + offset=0, + ) + assert_matches_type(RunListResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.runs.with_raw_response.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert_matches_type(RunListResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: + async with async_client.agents.runs.with_streaming_response.list( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert_matches_type(RunListResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_list(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.runs.with_raw_response.list( + agent_id="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.get( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunGetResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.runs.with_raw_response.get( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert_matches_type(RunGetResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: + async with async_client.agents.runs.with_streaming_response.get( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert_matches_type(RunGetResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.runs.with_raw_response.get( + run_id="run_id", + agent_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.agents.runs.with_raw_response.get( + run_id="", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_result(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.result( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunResultResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_result(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.runs.with_raw_response.result( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert_matches_type(RunResultResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_result(self, async_client: AsyncNimble) -> None: + async with async_client.agents.runs.with_streaming_response.result( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert_matches_type(RunResultResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_result(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.runs.with_raw_response.result( + run_id="run_id", + agent_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.agents.runs.with_raw_response.result( + run_id="", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_stream_events(self, async_client: AsyncNimble) -> None: + run = await async_client.agents.runs.stream_events( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert run is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_stream_events(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.runs.with_raw_response.stream_events( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert run is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_stream_events(self, async_client: AsyncNimble) -> None: + async with async_client.agents.runs.with_streaming_response.stream_events( + run_id="run_id", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert run is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_stream_events(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.runs.with_raw_response.stream_events( + run_id="run_id", + agent_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.agents.runs.with_raw_response.stream_events( + run_id="", + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) diff --git a/tests/api_resources/task_agent/test_templates.py b/tests/api_resources/agents/test_templates.py similarity index 55% rename from tests/api_resources/task_agent/test_templates.py rename to tests/api_resources/agents/test_templates.py index bd06013..16d1207 100644 --- a/tests/api_resources/task_agent/test_templates.py +++ b/tests/api_resources/agents/test_templates.py @@ -9,9 +9,7 @@ from tests.utils import assert_matches_type from nimble_python import Nimble, AsyncNimble -from nimble_python.types.task_agent import TemplateGetResponse, TemplateListResponse - -# pyright: reportDeprecated=false +from nimble_python.types.agents import TemplateGetResponse, TemplateListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -22,27 +20,22 @@ class TestTemplates: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - template = client.task_agent.templates.list() - + template = client.agents.templates.list() assert_matches_type(TemplateListResponse, template, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - template = client.task_agent.templates.list( - limit=1, - offset=0, - ) - + template = client.agents.templates.list( + limit=1, + offset=0, + ) assert_matches_type(TemplateListResponse, template, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.templates.with_raw_response.list() + response = client.agents.templates.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -52,33 +45,29 @@ def test_raw_response_list(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.templates.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.agents.templates.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - template = response.parse() - assert_matches_type(TemplateListResponse, template, path=["response"]) + template = response.parse() + assert_matches_type(TemplateListResponse, template, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - template = client.task_agent.templates.get( - "template_name", - ) - + template = client.agents.templates.get( + "template_name", + ) assert_matches_type(TemplateGetResponse, template, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.templates.with_raw_response.get( - "template_name", - ) + response = client.agents.templates.with_raw_response.get( + "template_name", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -88,26 +77,24 @@ def test_raw_response_get(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.templates.with_streaming_response.get( - "template_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.agents.templates.with_streaming_response.get( + "template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - template = response.parse() - assert_matches_type(TemplateGetResponse, template, path=["response"]) + template = response.parse() + assert_matches_type(TemplateGetResponse, template, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_name` but received ''"): - client.task_agent.templates.with_raw_response.get( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_name` but received ''"): + client.agents.templates.with_raw_response.get( + "", + ) class TestAsyncTemplates: @@ -118,27 +105,22 @@ class TestAsyncTemplates: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - template = await async_client.task_agent.templates.list() - + template = await async_client.agents.templates.list() assert_matches_type(TemplateListResponse, template, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - template = await async_client.task_agent.templates.list( - limit=1, - offset=0, - ) - + template = await async_client.agents.templates.list( + limit=1, + offset=0, + ) assert_matches_type(TemplateListResponse, template, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.templates.with_raw_response.list() + response = await async_client.agents.templates.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -148,33 +130,29 @@ async def test_raw_response_list(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.templates.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.agents.templates.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - template = await response.parse() - assert_matches_type(TemplateListResponse, template, path=["response"]) + template = await response.parse() + assert_matches_type(TemplateListResponse, template, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - template = await async_client.task_agent.templates.get( - "template_name", - ) - + template = await async_client.agents.templates.get( + "template_name", + ) assert_matches_type(TemplateGetResponse, template, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.templates.with_raw_response.get( - "template_name", - ) + response = await async_client.agents.templates.with_raw_response.get( + "template_name", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -184,23 +162,21 @@ async def test_raw_response_get(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.templates.with_streaming_response.get( - "template_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.agents.templates.with_streaming_response.get( + "template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - template = await response.parse() - assert_matches_type(TemplateGetResponse, template, path=["response"]) + template = await response.parse() + assert_matches_type(TemplateGetResponse, template, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_name` but received ''"): - await async_client.task_agent.templates.with_raw_response.get( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_name` but received ''"): + await async_client.agents.templates.with_raw_response.get( + "", + ) diff --git a/tests/api_resources/extract/__init__.py b/tests/api_resources/extract/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/extract/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/extract/templates/__init__.py b/tests/api_resources/extract/templates/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/extract/templates/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/extract/templates/test_generations.py b/tests/api_resources/extract/templates/test_generations.py new file mode 100644 index 0000000..c7351b6 --- /dev/null +++ b/tests/api_resources/extract/templates/test_generations.py @@ -0,0 +1,293 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from nimble_python import Nimble, AsyncNimble +from nimble_python.types.extract.templates import ( + GenerationGetResponse, + GenerationCreateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestGenerations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_overload_1(self, client: Nimble) -> None: + generation = client.extract.templates.generations.create( + prompt="prompt", + url="url", + ) + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params_overload_1(self, client: Nimble) -> None: + generation = client.extract.templates.generations.create( + prompt="prompt", + url="url", + input_schema={"foo": "bar"}, + metadata={ + "description": "description", + "display_name": "display_name", + "tags": ["string"], + }, + name="name", + output_schema={"foo": "bar"}, + ) + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create_overload_1(self, client: Nimble) -> None: + response = client.extract.templates.generations.with_raw_response.create( + prompt="prompt", + url="url", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + generation = response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create_overload_1(self, client: Nimble) -> None: + with client.extract.templates.generations.with_streaming_response.create( + prompt="prompt", + url="url", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + generation = response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_overload_2(self, client: Nimble) -> None: + generation = client.extract.templates.generations.create( + from_extract_template="from_extract_template", + prompt="prompt", + ) + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create_overload_2(self, client: Nimble) -> None: + response = client.extract.templates.generations.with_raw_response.create( + from_extract_template="from_extract_template", + prompt="prompt", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + generation = response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create_overload_2(self, client: Nimble) -> None: + with client.extract.templates.generations.with_streaming_response.create( + from_extract_template="from_extract_template", + prompt="prompt", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + generation = response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get(self, client: Nimble) -> None: + generation = client.extract.templates.generations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(GenerationGetResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get(self, client: Nimble) -> None: + response = client.extract.templates.generations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + generation = response.parse() + assert_matches_type(GenerationGetResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Nimble) -> None: + with client.extract.templates.generations.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + generation = response.parse() + assert_matches_type(GenerationGetResponse, generation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_get(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `generation_id` but received ''"): + client.extract.templates.generations.with_raw_response.get( + "", + ) + + +class TestAsyncGenerations: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncNimble) -> None: + generation = await async_client.extract.templates.generations.create( + prompt="prompt", + url="url", + ) + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncNimble) -> None: + generation = await async_client.extract.templates.generations.create( + prompt="prompt", + url="url", + input_schema={"foo": "bar"}, + metadata={ + "description": "description", + "display_name": "display_name", + "tags": ["string"], + }, + name="name", + output_schema={"foo": "bar"}, + ) + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.generations.with_raw_response.create( + prompt="prompt", + url="url", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + generation = await response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.generations.with_streaming_response.create( + prompt="prompt", + url="url", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + generation = await response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncNimble) -> None: + generation = await async_client.extract.templates.generations.create( + from_extract_template="from_extract_template", + prompt="prompt", + ) + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.generations.with_raw_response.create( + from_extract_template="from_extract_template", + prompt="prompt", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + generation = await response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.generations.with_streaming_response.create( + from_extract_template="from_extract_template", + prompt="prompt", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + generation = await response.parse() + assert_matches_type(GenerationCreateResponse, generation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncNimble) -> None: + generation = await async_client.extract.templates.generations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(GenerationGetResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.generations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + generation = await response.parse() + assert_matches_type(GenerationGetResponse, generation, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.generations.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + generation = await response.parse() + assert_matches_type(GenerationGetResponse, generation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `generation_id` but received ''"): + await async_client.extract.templates.generations.with_raw_response.get( + "", + ) diff --git a/tests/api_resources/extract/templates/test_versions.py b/tests/api_resources/extract/templates/test_versions.py new file mode 100644 index 0000000..965f554 --- /dev/null +++ b/tests/api_resources/extract/templates/test_versions.py @@ -0,0 +1,232 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from nimble_python import Nimble, AsyncNimble +from nimble_python.types.extract.templates import VersionGetResponse, VersionListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVersions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Nimble) -> None: + version = client.extract.templates.versions.list( + extract_template_name="extract_template_name", + ) + assert_matches_type(VersionListResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Nimble) -> None: + version = client.extract.templates.versions.list( + extract_template_name="extract_template_name", + limit=1, + offset=0, + ) + assert_matches_type(VersionListResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Nimble) -> None: + response = client.extract.templates.versions.with_raw_response.list( + extract_template_name="extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(VersionListResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Nimble) -> None: + with client.extract.templates.versions.with_streaming_response.list( + extract_template_name="extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert_matches_type(VersionListResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_list(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + client.extract.templates.versions.with_raw_response.list( + extract_template_name="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get(self, client: Nimble) -> None: + version = client.extract.templates.versions.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="extract_template_name", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get(self, client: Nimble) -> None: + response = client.extract.templates.versions.with_raw_response.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Nimble) -> None: + with client.extract.templates.versions.with_streaming_response.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_get(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + client.extract.templates.versions.with_raw_response.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `version_id` but received ''"): + client.extract.templates.versions.with_raw_response.get( + version_id="", + extract_template_name="extract_template_name", + ) + + +class TestAsyncVersions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncNimble) -> None: + version = await async_client.extract.templates.versions.list( + extract_template_name="extract_template_name", + ) + assert_matches_type(VersionListResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: + version = await async_client.extract.templates.versions.list( + extract_template_name="extract_template_name", + limit=1, + offset=0, + ) + assert_matches_type(VersionListResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.versions.with_raw_response.list( + extract_template_name="extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert_matches_type(VersionListResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.versions.with_streaming_response.list( + extract_template_name="extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert_matches_type(VersionListResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_list(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + await async_client.extract.templates.versions.with_raw_response.list( + extract_template_name="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncNimble) -> None: + version = await async_client.extract.templates.versions.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="extract_template_name", + ) + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.versions.with_raw_response.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = await response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.versions.with_streaming_response.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + version = await response.parse() + assert_matches_type(VersionGetResponse, version, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + await async_client.extract.templates.versions.with_raw_response.get( + version_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + extract_template_name="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `version_id` but received ''"): + await async_client.extract.templates.versions.with_raw_response.get( + version_id="", + extract_template_name="extract_template_name", + ) diff --git a/tests/api_resources/extract/test_templates.py b/tests/api_resources/extract/test_templates.py new file mode 100644 index 0000000..e47c3cd --- /dev/null +++ b/tests/api_resources/extract/test_templates.py @@ -0,0 +1,721 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from nimble_python import Nimble, AsyncNimble +from nimble_python.types.extract import ( + TemplateGetResponse, + TemplateRunResponse, + TemplateListResponse, + TemplateAsyncResponse, + TemplateBatchResponse, + TemplateUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTemplates: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: Nimble) -> None: + template = client.extract.templates.update( + extract_template_name="extract_template_name", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + assert_matches_type(TemplateUpdateResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.update( + extract_template_name="extract_template_name", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(TemplateUpdateResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.update( + extract_template_name="extract_template_name", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(TemplateUpdateResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + client.extract.templates.with_raw_response.update( + extract_template_name="", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Nimble) -> None: + template = client.extract.templates.list() + assert_matches_type(TemplateListResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Nimble) -> None: + template = client.extract.templates.list( + limit=1, + offset=0, + ) + assert_matches_type(TemplateListResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(TemplateListResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(TemplateListResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: Nimble) -> None: + template = client.extract.templates.delete( + "extract_template_name", + ) + assert template is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.delete( + "extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert template is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.delete( + "extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert template is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + client.extract.templates.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_async(self, client: Nimble) -> None: + template = client.extract.templates.async_( + params={"foo": "bar"}, + template="template", + ) + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_async_with_all_params(self, client: Nimble) -> None: + template = client.extract.templates.async_( + params={"foo": "bar"}, + template="template", + callback_url="https://example.com/webhook/callback", + formats=["html", "markdown"], + localization=True, + storage_compress=True, + storage_object_name="result-2024-01-15.json", + storage_type="s3", + storage_url="s3://bucket-name/path/to/object", + ) + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_async(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.async_( + params={"foo": "bar"}, + template="template", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_async(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.async_( + params={"foo": "bar"}, + template="template", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch(self, client: Nimble) -> None: + template = client.extract.templates.batch( + inputs=[{}], + shared_inputs={"template": "template"}, + ) + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch_with_all_params(self, client: Nimble) -> None: + template = client.extract.templates.batch( + inputs=[ + { + "formats": ["html", "markdown"], + "localization": True, + "params": {"foo": "bar"}, + } + ], + shared_inputs={ + "template": "template", + "formats": ["html", "markdown"], + "localization": True, + "params": {"foo": "bar"}, + }, + ) + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_batch(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.batch( + inputs=[{}], + shared_inputs={"template": "template"}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_batch(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.batch( + inputs=[{}], + shared_inputs={"template": "template"}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get(self, client: Nimble) -> None: + template = client.extract.templates.get( + "extract_template_name", + ) + assert_matches_type(TemplateGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.get( + "extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(TemplateGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.get( + "extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(TemplateGetResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_get(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + client.extract.templates.with_raw_response.get( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_run(self, client: Nimble) -> None: + template = client.extract.templates.run( + params={"foo": "bar"}, + template="template", + ) + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_run_with_all_params(self, client: Nimble) -> None: + template = client.extract.templates.run( + params={"foo": "bar"}, + template="template", + formats=["html", "markdown"], + localization=True, + ) + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_run(self, client: Nimble) -> None: + response = client.extract.templates.with_raw_response.run( + params={"foo": "bar"}, + template="template", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_run(self, client: Nimble) -> None: + with client.extract.templates.with_streaming_response.run( + params={"foo": "bar"}, + template="template", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncTemplates: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.update( + extract_template_name="extract_template_name", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + assert_matches_type(TemplateUpdateResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.update( + extract_template_name="extract_template_name", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(TemplateUpdateResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.update( + extract_template_name="extract_template_name", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(TemplateUpdateResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + await async_client.extract.templates.with_raw_response.update( + extract_template_name="", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.list() + assert_matches_type(TemplateListResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.list( + limit=1, + offset=0, + ) + assert_matches_type(TemplateListResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(TemplateListResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(TemplateListResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.delete( + "extract_template_name", + ) + assert template is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.delete( + "extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert template is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.delete( + "extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert template is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + await async_client.extract.templates.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_async(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.async_( + params={"foo": "bar"}, + template="template", + ) + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_async_with_all_params(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.async_( + params={"foo": "bar"}, + template="template", + callback_url="https://example.com/webhook/callback", + formats=["html", "markdown"], + localization=True, + storage_compress=True, + storage_object_name="result-2024-01-15.json", + storage_type="s3", + storage_url="s3://bucket-name/path/to/object", + ) + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_async(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.async_( + params={"foo": "bar"}, + template="template", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_async(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.async_( + params={"foo": "bar"}, + template="template", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(TemplateAsyncResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.batch( + inputs=[{}], + shared_inputs={"template": "template"}, + ) + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch_with_all_params(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.batch( + inputs=[ + { + "formats": ["html", "markdown"], + "localization": True, + "params": {"foo": "bar"}, + } + ], + shared_inputs={ + "template": "template", + "formats": ["html", "markdown"], + "localization": True, + "params": {"foo": "bar"}, + }, + ) + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_batch(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.batch( + inputs=[{}], + shared_inputs={"template": "template"}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_batch(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.batch( + inputs=[{}], + shared_inputs={"template": "template"}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(TemplateBatchResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.get( + "extract_template_name", + ) + assert_matches_type(TemplateGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.get( + "extract_template_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(TemplateGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.get( + "extract_template_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(TemplateGetResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `extract_template_name` but received ''"): + await async_client.extract.templates.with_raw_response.get( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_run(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.run( + params={"foo": "bar"}, + template="template", + ) + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_run_with_all_params(self, async_client: AsyncNimble) -> None: + template = await async_client.extract.templates.run( + params={"foo": "bar"}, + template="template", + formats=["html", "markdown"], + localization=True, + ) + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_run(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.templates.with_raw_response.run( + params={"foo": "bar"}, + template="template", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_run(self, async_client: AsyncNimble) -> None: + async with async_client.extract.templates.with_streaming_response.run( + params={"foo": "bar"}, + template="template", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(TemplateRunResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/jobs/runs/test_artifacts.py b/tests/api_resources/jobs/runs/test_artifacts.py index eb464f9..75b6e79 100644 --- a/tests/api_resources/jobs/runs/test_artifacts.py +++ b/tests/api_resources/jobs/runs/test_artifacts.py @@ -16,8 +16,6 @@ ArtifactDownloadURLResponse, ) -# pyright: reportDeprecated=false - base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -27,20 +25,17 @@ class TestArtifacts: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = client.jobs.runs.artifacts.list( - "run_id", - ) - + artifact = client.jobs.runs.artifacts.list( + "run_id", + ) assert_matches_type(ArtifactListResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.artifacts.with_raw_response.list( - "run_id", - ) + response = client.jobs.runs.artifacts.with_raw_response.list( + "run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -50,46 +45,41 @@ def test_raw_response_list(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.artifacts.with_streaming_response.list( - "run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.artifacts.with_streaming_response.list( + "run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = response.parse() - assert_matches_type(ArtifactListResponse, artifact, path=["response"]) + artifact = response.parse() + assert_matches_type(ArtifactListResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.jobs.runs.artifacts.with_raw_response.list( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.jobs.runs.artifacts.with_raw_response.list( + "", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_download_url(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = client.jobs.runs.artifacts.download_url( - artifact_id=0, - run_id="run_id", - ) - + artifact = client.jobs.runs.artifacts.download_url( + artifact_id=0, + run_id="run_id", + ) assert_matches_type(ArtifactDownloadURLResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_download_url(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.artifacts.with_raw_response.download_url( - artifact_id=0, - run_id="run_id", - ) + response = client.jobs.runs.artifacts.with_raw_response.download_url( + artifact_id=0, + run_id="run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -99,48 +89,43 @@ def test_raw_response_download_url(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_download_url(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.artifacts.with_streaming_response.download_url( - artifact_id=0, - run_id="run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.artifacts.with_streaming_response.download_url( + artifact_id=0, + run_id="run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = response.parse() - assert_matches_type(ArtifactDownloadURLResponse, artifact, path=["response"]) + artifact = response.parse() + assert_matches_type(ArtifactDownloadURLResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_download_url(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.jobs.runs.artifacts.with_raw_response.download_url( - artifact_id=0, - run_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.jobs.runs.artifacts.with_raw_response.download_url( + artifact_id=0, + run_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = client.jobs.runs.artifacts.get( - artifact_id=0, - run_id="run_id", - ) - + artifact = client.jobs.runs.artifacts.get( + artifact_id=0, + run_id="run_id", + ) assert_matches_type(ArtifactGetResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.artifacts.with_raw_response.get( - artifact_id=0, - run_id="run_id", - ) + response = client.jobs.runs.artifacts.with_raw_response.get( + artifact_id=0, + run_id="run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -150,48 +135,43 @@ def test_raw_response_get(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.artifacts.with_streaming_response.get( - artifact_id=0, - run_id="run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.artifacts.with_streaming_response.get( + artifact_id=0, + run_id="run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = response.parse() - assert_matches_type(ArtifactGetResponse, artifact, path=["response"]) + artifact = response.parse() + assert_matches_type(ArtifactGetResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.jobs.runs.artifacts.with_raw_response.get( - artifact_id=0, - run_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.jobs.runs.artifacts.with_raw_response.get( + artifact_id=0, + run_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_preview(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = client.jobs.runs.artifacts.preview( - artifact_id=0, - run_id="run_id", - ) - + artifact = client.jobs.runs.artifacts.preview( + artifact_id=0, + run_id="run_id", + ) assert_matches_type(ArtifactPreviewResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_preview(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.artifacts.with_raw_response.preview( - artifact_id=0, - run_id="run_id", - ) + response = client.jobs.runs.artifacts.with_raw_response.preview( + artifact_id=0, + run_id="run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -201,28 +181,26 @@ def test_raw_response_preview(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_preview(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.artifacts.with_streaming_response.preview( - artifact_id=0, - run_id="run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.artifacts.with_streaming_response.preview( + artifact_id=0, + run_id="run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = response.parse() - assert_matches_type(ArtifactPreviewResponse, artifact, path=["response"]) + artifact = response.parse() + assert_matches_type(ArtifactPreviewResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_preview(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.jobs.runs.artifacts.with_raw_response.preview( - artifact_id=0, - run_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.jobs.runs.artifacts.with_raw_response.preview( + artifact_id=0, + run_id="", + ) class TestAsyncArtifacts: @@ -233,20 +211,17 @@ class TestAsyncArtifacts: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = await async_client.jobs.runs.artifacts.list( - "run_id", - ) - + artifact = await async_client.jobs.runs.artifacts.list( + "run_id", + ) assert_matches_type(ArtifactListResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.artifacts.with_raw_response.list( - "run_id", - ) + response = await async_client.jobs.runs.artifacts.with_raw_response.list( + "run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -256,46 +231,41 @@ async def test_raw_response_list(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.artifacts.with_streaming_response.list( - "run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.artifacts.with_streaming_response.list( + "run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = await response.parse() - assert_matches_type(ArtifactListResponse, artifact, path=["response"]) + artifact = await response.parse() + assert_matches_type(ArtifactListResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.jobs.runs.artifacts.with_raw_response.list( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.jobs.runs.artifacts.with_raw_response.list( + "", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_download_url(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = await async_client.jobs.runs.artifacts.download_url( - artifact_id=0, - run_id="run_id", - ) - + artifact = await async_client.jobs.runs.artifacts.download_url( + artifact_id=0, + run_id="run_id", + ) assert_matches_type(ArtifactDownloadURLResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_download_url(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.artifacts.with_raw_response.download_url( - artifact_id=0, - run_id="run_id", - ) + response = await async_client.jobs.runs.artifacts.with_raw_response.download_url( + artifact_id=0, + run_id="run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -305,48 +275,43 @@ async def test_raw_response_download_url(self, async_client: AsyncNimble) -> Non @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_download_url(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.artifacts.with_streaming_response.download_url( - artifact_id=0, - run_id="run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.artifacts.with_streaming_response.download_url( + artifact_id=0, + run_id="run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = await response.parse() - assert_matches_type(ArtifactDownloadURLResponse, artifact, path=["response"]) + artifact = await response.parse() + assert_matches_type(ArtifactDownloadURLResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_download_url(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.jobs.runs.artifacts.with_raw_response.download_url( - artifact_id=0, - run_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.jobs.runs.artifacts.with_raw_response.download_url( + artifact_id=0, + run_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = await async_client.jobs.runs.artifacts.get( - artifact_id=0, - run_id="run_id", - ) - + artifact = await async_client.jobs.runs.artifacts.get( + artifact_id=0, + run_id="run_id", + ) assert_matches_type(ArtifactGetResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.artifacts.with_raw_response.get( - artifact_id=0, - run_id="run_id", - ) + response = await async_client.jobs.runs.artifacts.with_raw_response.get( + artifact_id=0, + run_id="run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -356,48 +321,43 @@ async def test_raw_response_get(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.artifacts.with_streaming_response.get( - artifact_id=0, - run_id="run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.artifacts.with_streaming_response.get( + artifact_id=0, + run_id="run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = await response.parse() - assert_matches_type(ArtifactGetResponse, artifact, path=["response"]) + artifact = await response.parse() + assert_matches_type(ArtifactGetResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.jobs.runs.artifacts.with_raw_response.get( - artifact_id=0, - run_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.jobs.runs.artifacts.with_raw_response.get( + artifact_id=0, + run_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_preview(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - artifact = await async_client.jobs.runs.artifacts.preview( - artifact_id=0, - run_id="run_id", - ) - + artifact = await async_client.jobs.runs.artifacts.preview( + artifact_id=0, + run_id="run_id", + ) assert_matches_type(ArtifactPreviewResponse, artifact, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_preview(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.artifacts.with_raw_response.preview( - artifact_id=0, - run_id="run_id", - ) + response = await async_client.jobs.runs.artifacts.with_raw_response.preview( + artifact_id=0, + run_id="run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -407,25 +367,23 @@ async def test_raw_response_preview(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_preview(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.artifacts.with_streaming_response.preview( - artifact_id=0, - run_id="run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.artifacts.with_streaming_response.preview( + artifact_id=0, + run_id="run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - artifact = await response.parse() - assert_matches_type(ArtifactPreviewResponse, artifact, path=["response"]) + artifact = await response.parse() + assert_matches_type(ArtifactPreviewResponse, artifact, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_preview(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.jobs.runs.artifacts.with_raw_response.preview( - artifact_id=0, - run_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.jobs.runs.artifacts.with_raw_response.preview( + artifact_id=0, + run_id="", + ) diff --git a/tests/api_resources/jobs/test_runs.py b/tests/api_resources/jobs/test_runs.py index e714f8d..815e409 100644 --- a/tests/api_resources/jobs/test_runs.py +++ b/tests/api_resources/jobs/test_runs.py @@ -9,9 +9,12 @@ from tests.utils import assert_matches_type from nimble_python import Nimble, AsyncNimble -from nimble_python.types.jobs import RunGetResponse, RunListResponse, RunCancelResponse - -# pyright: reportDeprecated=false +from nimble_python.types.jobs import ( + RunGetResponse, + RunListResponse, + RunCancelResponse, + RunCreateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -21,34 +24,70 @@ class TestRuns: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.jobs.runs.list( - job_id="job_id", + def test_method_create(self, client: Nimble) -> None: + run = client.jobs.runs.create( + "job_id", + ) + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Nimble) -> None: + response = client.jobs.runs.with_raw_response.create( + "job_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Nimble) -> None: + with client.jobs.runs.with_streaming_response.create( + "job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_create(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.jobs.runs.with_raw_response.create( + "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Nimble) -> None: + run = client.jobs.runs.list( + job_id="job_id", + ) assert_matches_type(RunListResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.jobs.runs.list( - job_id="job_id", - page=1, - per_page=1, - status="status", - ) - + run = client.jobs.runs.list( + job_id="job_id", + limit=1, + offset=0, + ) assert_matches_type(RunListResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.with_raw_response.list( - job_id="job_id", - ) + response = client.jobs.runs.with_raw_response.list( + job_id="job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -58,44 +97,39 @@ def test_raw_response_list(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.with_streaming_response.list( - job_id="job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.with_streaming_response.list( + job_id="job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert_matches_type(RunListResponse, run, path=["response"]) + run = response.parse() + assert_matches_type(RunListResponse, run, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - client.jobs.runs.with_raw_response.list( - job_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.jobs.runs.with_raw_response.list( + job_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_cancel(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.jobs.runs.cancel( - "run_id", - ) - + run = client.jobs.runs.cancel( + "run_id", + ) assert_matches_type(RunCancelResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_cancel(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.with_raw_response.cancel( - "run_id", - ) + response = client.jobs.runs.with_raw_response.cancel( + "run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -105,44 +139,39 @@ def test_raw_response_cancel(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_cancel(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.with_streaming_response.cancel( - "run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.with_streaming_response.cancel( + "run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert_matches_type(RunCancelResponse, run, path=["response"]) + run = response.parse() + assert_matches_type(RunCancelResponse, run, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_cancel(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.jobs.runs.with_raw_response.cancel( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.jobs.runs.with_raw_response.cancel( + "", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.jobs.runs.get( - "run_id", - ) - + run = client.jobs.runs.get( + "run_id", + ) assert_matches_type(RunGetResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.runs.with_raw_response.get( - "run_id", - ) + response = client.jobs.runs.with_raw_response.get( + "run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -152,26 +181,24 @@ def test_raw_response_get(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.runs.with_streaming_response.get( - "run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.runs.with_streaming_response.get( + "run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert_matches_type(RunGetResponse, run, path=["response"]) + run = response.parse() + assert_matches_type(RunGetResponse, run, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.jobs.runs.with_raw_response.get( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + client.jobs.runs.with_raw_response.get( + "", + ) class TestAsyncRuns: @@ -181,34 +208,70 @@ class TestAsyncRuns: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.jobs.runs.list( - job_id="job_id", + async def test_method_create(self, async_client: AsyncNimble) -> None: + run = await async_client.jobs.runs.create( + "job_id", + ) + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncNimble) -> None: + response = await async_client.jobs.runs.with_raw_response.create( + "job_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncNimble) -> None: + async with async_client.jobs.runs.with_streaming_response.create( + "job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert_matches_type(RunCreateResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_create(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.jobs.runs.with_raw_response.create( + "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncNimble) -> None: + run = await async_client.jobs.runs.list( + job_id="job_id", + ) assert_matches_type(RunListResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.jobs.runs.list( - job_id="job_id", - page=1, - per_page=1, - status="status", - ) - + run = await async_client.jobs.runs.list( + job_id="job_id", + limit=1, + offset=0, + ) assert_matches_type(RunListResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.with_raw_response.list( - job_id="job_id", - ) + response = await async_client.jobs.runs.with_raw_response.list( + job_id="job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -218,44 +281,39 @@ async def test_raw_response_list(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.with_streaming_response.list( - job_id="job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.with_streaming_response.list( + job_id="job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert_matches_type(RunListResponse, run, path=["response"]) + run = await response.parse() + assert_matches_type(RunListResponse, run, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await async_client.jobs.runs.with_raw_response.list( - job_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.jobs.runs.with_raw_response.list( + job_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_cancel(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.jobs.runs.cancel( - "run_id", - ) - + run = await async_client.jobs.runs.cancel( + "run_id", + ) assert_matches_type(RunCancelResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_cancel(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.with_raw_response.cancel( - "run_id", - ) + response = await async_client.jobs.runs.with_raw_response.cancel( + "run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -265,44 +323,39 @@ async def test_raw_response_cancel(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_cancel(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.with_streaming_response.cancel( - "run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.with_streaming_response.cancel( + "run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert_matches_type(RunCancelResponse, run, path=["response"]) + run = await response.parse() + assert_matches_type(RunCancelResponse, run, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_cancel(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.jobs.runs.with_raw_response.cancel( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.jobs.runs.with_raw_response.cancel( + "", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.jobs.runs.get( - "run_id", - ) - + run = await async_client.jobs.runs.get( + "run_id", + ) assert_matches_type(RunGetResponse, run, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.runs.with_raw_response.get( - "run_id", - ) + response = await async_client.jobs.runs.with_raw_response.get( + "run_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -312,23 +365,21 @@ async def test_raw_response_get(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.runs.with_streaming_response.get( - "run_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.runs.with_streaming_response.get( + "run_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert_matches_type(RunGetResponse, run, path=["response"]) + run = await response.parse() + assert_matches_type(RunGetResponse, run, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.jobs.runs.with_raw_response.get( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): + await async_client.jobs.runs.with_raw_response.get( + "", + ) diff --git a/tests/api_resources/task_agent/test_runs.py b/tests/api_resources/task_agent/test_runs.py deleted file mode 100644 index 22231d0..0000000 --- a/tests/api_resources/task_agent/test_runs.py +++ /dev/null @@ -1,486 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from tests.utils import assert_matches_type -from nimble_python import Nimble, AsyncNimble -from nimble_python.types.task_agent import RunGetResponse, RunListResponse, RunGetResultResponse - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestRuns: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.task_agent.runs.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(RunListResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.task_agent.runs.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - limit=1, - offset=0, - ) - - assert_matches_type(RunListResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.runs.with_raw_response.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert_matches_type(RunListResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.runs.with_streaming_response.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = response.parse() - assert_matches_type(RunListResponse, run, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.runs.with_raw_response.list( - agent_id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.task_agent.runs.get( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(RunGetResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.runs.with_raw_response.get( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert_matches_type(RunGetResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.runs.with_streaming_response.get( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = response.parse() - assert_matches_type(RunGetResponse, run, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.runs.with_raw_response.get( - run_id="run_id", - agent_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.task_agent.runs.with_raw_response.get( - run_id="", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_get_result(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.task_agent.runs.get_result( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(RunGetResultResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_get_result(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.runs.with_raw_response.get_result( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert_matches_type(RunGetResultResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_get_result(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.runs.with_streaming_response.get_result( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = response.parse() - assert_matches_type(RunGetResultResponse, run, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_get_result(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.runs.with_raw_response.get_result( - run_id="run_id", - agent_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.task_agent.runs.with_raw_response.get_result( - run_id="", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_stream_events(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - run = client.task_agent.runs.stream_events( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert run is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_stream_events(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.runs.with_raw_response.stream_events( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = response.parse() - assert run is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_stream_events(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.runs.with_streaming_response.stream_events( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = response.parse() - assert run is None - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_stream_events(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.runs.with_raw_response.stream_events( - run_id="run_id", - agent_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - client.task_agent.runs.with_raw_response.stream_events( - run_id="", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - -class TestAsyncRuns: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.task_agent.runs.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(RunListResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.task_agent.runs.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - limit=1, - offset=0, - ) - - assert_matches_type(RunListResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.runs.with_raw_response.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert_matches_type(RunListResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.runs.with_streaming_response.list( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = await response.parse() - assert_matches_type(RunListResponse, run, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.list( - agent_id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.task_agent.runs.get( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(RunGetResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.runs.with_raw_response.get( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert_matches_type(RunGetResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.runs.with_streaming_response.get( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = await response.parse() - assert_matches_type(RunGetResponse, run, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.get( - run_id="run_id", - agent_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.get( - run_id="", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_get_result(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.task_agent.runs.get_result( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(RunGetResultResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_get_result(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.runs.with_raw_response.get_result( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert_matches_type(RunGetResultResponse, run, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_get_result(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.runs.with_streaming_response.get_result( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = await response.parse() - assert_matches_type(RunGetResultResponse, run, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_get_result(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.get_result( - run_id="run_id", - agent_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.get_result( - run_id="", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_stream_events(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - run = await async_client.task_agent.runs.stream_events( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert run is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_stream_events(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.runs.with_raw_response.stream_events( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - run = await response.parse() - assert run is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_stream_events(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.runs.with_streaming_response.stream_events( - run_id="run_id", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - run = await response.parse() - assert run is None - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_stream_events(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.stream_events( - run_id="run_id", - agent_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): - await async_client.task_agent.runs.with_raw_response.stream_events( - run_id="", - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) diff --git a/tests/api_resources/test_agent.py b/tests/api_resources/test_agent.py deleted file mode 100644 index a724dfe..0000000 --- a/tests/api_resources/test_agent.py +++ /dev/null @@ -1,832 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from tests.utils import assert_matches_type -from nimble_python import Nimble, AsyncNimble -from nimble_python.types import ( - AgentGetResponse, - AgentRunResponse, - AgentListResponse, - AgentGenerateResponse, - AgentRunAsyncResponse, - AgentRunBatchResponse, - AgentGetGenerationResponse, -) - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestAgent: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.list() - - assert_matches_type(AgentListResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.list( - limit=1, - managed_by="nimble", - offset=0, - privacy="public", - search="search", - ) - - assert_matches_type(AgentListResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.agent.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentListResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.agent.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentListResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_generate_overload_1(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.generate( - prompt="prompt", - url="url", - ) - - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_generate_with_all_params_overload_1(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.generate( - prompt="prompt", - url="url", - input_schema={"foo": "bar"}, - metadata={ - "description": "description", - "display_name": "display_name", - "tags": ["string"], - }, - name="name", - output_schema={"foo": "bar"}, - ) - - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_generate_overload_1(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.agent.with_raw_response.generate( - prompt="prompt", - url="url", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_generate_overload_1(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.agent.with_streaming_response.generate( - prompt="prompt", - url="url", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_generate_overload_2(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.generate( - from_agent="from_agent", - prompt="prompt", - ) - - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_generate_overload_2(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.agent.with_raw_response.generate( - from_agent="from_agent", - prompt="prompt", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_generate_overload_2(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.agent.with_streaming_response.generate( - from_agent="from_agent", - prompt="prompt", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.get( - "template_name", - ) - - assert_matches_type(AgentGetResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.agent.with_raw_response.get( - "template_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentGetResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.agent.with_streaming_response.get( - "template_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentGetResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_name` but received ''"): - client.agent.with_raw_response.get( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_get_generation(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - agent = client.agent.get_generation( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(AgentGetGenerationResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_get_generation(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.agent.with_raw_response.get_generation( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentGetGenerationResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_get_generation(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.agent.with_streaming_response.get_generation( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentGetGenerationResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_get_generation(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `generation_id` but received ''"): - client.agent.with_raw_response.get_generation( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run(self, client: Nimble) -> None: - agent = client.agent.run( - agent="agent", - params={"foo": "bar"}, - ) - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run_with_all_params(self, client: Nimble) -> None: - agent = client.agent.run( - agent="agent", - params={"foo": "bar"}, - formats=["html", "markdown"], - localization=True, - ) - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_run(self, client: Nimble) -> None: - response = client.agent.with_raw_response.run( - agent="agent", - params={"foo": "bar"}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_run(self, client: Nimble) -> None: - with client.agent.with_streaming_response.run( - agent="agent", - params={"foo": "bar"}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run_async(self, client: Nimble) -> None: - agent = client.agent.run_async( - agent="agent", - params={"foo": "bar"}, - ) - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run_async_with_all_params(self, client: Nimble) -> None: - agent = client.agent.run_async( - agent="agent", - params={"foo": "bar"}, - callback_url="https://example.com/webhook/callback", - formats=["html", "markdown"], - localization=True, - storage_compress=True, - storage_object_name="result-2024-01-15.json", - storage_type="s3", - storage_url="s3://bucket-name/path/to/object", - ) - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_run_async(self, client: Nimble) -> None: - response = client.agent.with_raw_response.run_async( - agent="agent", - params={"foo": "bar"}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_run_async(self, client: Nimble) -> None: - with client.agent.with_streaming_response.run_async( - agent="agent", - params={"foo": "bar"}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run_batch(self, client: Nimble) -> None: - agent = client.agent.run_batch( - inputs=[{}], - shared_inputs={"agent": "agent"}, - ) - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run_batch_with_all_params(self, client: Nimble) -> None: - agent = client.agent.run_batch( - inputs=[ - { - "formats": ["html", "markdown"], - "localization": True, - "params": {"foo": "bar"}, - } - ], - shared_inputs={ - "agent": "agent", - "formats": ["html", "markdown"], - "localization": True, - "params": {"foo": "bar"}, - }, - ) - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_run_batch(self, client: Nimble) -> None: - response = client.agent.with_raw_response.run_batch( - inputs=[{}], - shared_inputs={"agent": "agent"}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = response.parse() - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_run_batch(self, client: Nimble) -> None: - with client.agent.with_streaming_response.run_batch( - inputs=[{}], - shared_inputs={"agent": "agent"}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = response.parse() - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - -class TestAsyncAgent: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.list() - - assert_matches_type(AgentListResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.list( - limit=1, - managed_by="nimble", - offset=0, - privacy="public", - search="search", - ) - - assert_matches_type(AgentListResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.agent.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentListResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.agent.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentListResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_generate_overload_1(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.generate( - prompt="prompt", - url="url", - ) - - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_generate_with_all_params_overload_1(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.generate( - prompt="prompt", - url="url", - input_schema={"foo": "bar"}, - metadata={ - "description": "description", - "display_name": "display_name", - "tags": ["string"], - }, - name="name", - output_schema={"foo": "bar"}, - ) - - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_generate_overload_1(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.agent.with_raw_response.generate( - prompt="prompt", - url="url", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_generate_overload_1(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.agent.with_streaming_response.generate( - prompt="prompt", - url="url", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_generate_overload_2(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.generate( - from_agent="from_agent", - prompt="prompt", - ) - - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_generate_overload_2(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.agent.with_raw_response.generate( - from_agent="from_agent", - prompt="prompt", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_generate_overload_2(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.agent.with_streaming_response.generate( - from_agent="from_agent", - prompt="prompt", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentGenerateResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.get( - "template_name", - ) - - assert_matches_type(AgentGetResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.agent.with_raw_response.get( - "template_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentGetResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.agent.with_streaming_response.get( - "template_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentGetResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_name` but received ''"): - await async_client.agent.with_raw_response.get( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_get_generation(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - agent = await async_client.agent.get_generation( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(AgentGetGenerationResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_get_generation(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.agent.with_raw_response.get_generation( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentGetGenerationResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_get_generation(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.agent.with_streaming_response.get_generation( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentGetGenerationResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_get_generation(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `generation_id` but received ''"): - await async_client.agent.with_raw_response.get_generation( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run(self, async_client: AsyncNimble) -> None: - agent = await async_client.agent.run( - agent="agent", - params={"foo": "bar"}, - ) - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run_with_all_params(self, async_client: AsyncNimble) -> None: - agent = await async_client.agent.run( - agent="agent", - params={"foo": "bar"}, - formats=["html", "markdown"], - localization=True, - ) - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_run(self, async_client: AsyncNimble) -> None: - response = await async_client.agent.with_raw_response.run( - agent="agent", - params={"foo": "bar"}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_run(self, async_client: AsyncNimble) -> None: - async with async_client.agent.with_streaming_response.run( - agent="agent", - params={"foo": "bar"}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentRunResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run_async(self, async_client: AsyncNimble) -> None: - agent = await async_client.agent.run_async( - agent="agent", - params={"foo": "bar"}, - ) - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run_async_with_all_params(self, async_client: AsyncNimble) -> None: - agent = await async_client.agent.run_async( - agent="agent", - params={"foo": "bar"}, - callback_url="https://example.com/webhook/callback", - formats=["html", "markdown"], - localization=True, - storage_compress=True, - storage_object_name="result-2024-01-15.json", - storage_type="s3", - storage_url="s3://bucket-name/path/to/object", - ) - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_run_async(self, async_client: AsyncNimble) -> None: - response = await async_client.agent.with_raw_response.run_async( - agent="agent", - params={"foo": "bar"}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_run_async(self, async_client: AsyncNimble) -> None: - async with async_client.agent.with_streaming_response.run_async( - agent="agent", - params={"foo": "bar"}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentRunAsyncResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run_batch(self, async_client: AsyncNimble) -> None: - agent = await async_client.agent.run_batch( - inputs=[{}], - shared_inputs={"agent": "agent"}, - ) - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run_batch_with_all_params(self, async_client: AsyncNimble) -> None: - agent = await async_client.agent.run_batch( - inputs=[ - { - "formats": ["html", "markdown"], - "localization": True, - "params": {"foo": "bar"}, - } - ], - shared_inputs={ - "agent": "agent", - "formats": ["html", "markdown"], - "localization": True, - "params": {"foo": "bar"}, - }, - ) - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_run_batch(self, async_client: AsyncNimble) -> None: - response = await async_client.agent.with_raw_response.run_batch( - inputs=[{}], - shared_inputs={"agent": "agent"}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - agent = await response.parse() - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_run_batch(self, async_client: AsyncNimble) -> None: - async with async_client.agent.with_streaming_response.run_batch( - inputs=[{}], - shared_inputs={"agent": "agent"}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - agent = await response.parse() - assert_matches_type(AgentRunBatchResponse, agent, path=["response"]) - - assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_agents.py b/tests/api_resources/test_agents.py new file mode 100644 index 0000000..d13a61d --- /dev/null +++ b/tests/api_resources/test_agents.py @@ -0,0 +1,535 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from nimble_python import Nimble, AsyncNimble +from nimble_python.types import ( + AgentGetResponse, + AgentListResponse, + AgentCreateResponse, + AgentUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAgents: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: Nimble) -> None: + agent = client.agents.create() + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Nimble) -> None: + agent = client.agents.create( + agent_name="agent_name", + description="description", + display_name="display_name", + domain_expertise="domain_expertise", + effort="low", + goals=["string"], + icon="icon", + is_active=True, + output_schema={"foo": "bar"}, + sources={ + "allow": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "avoid": "avoid", + "block": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "prioritize": "prioritize", + }, + suggested_questions=["string"], + template="template", + use_case="research", + ) + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Nimble) -> None: + response = client.agents.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = response.parse() + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Nimble) -> None: + with client.agents.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = response.parse() + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: Nimble) -> None: + agent = client.agents.update( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + assert_matches_type(AgentUpdateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: Nimble) -> None: + response = client.agents.with_raw_response.update( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = response.parse() + assert_matches_type(AgentUpdateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: Nimble) -> None: + with client.agents.with_streaming_response.update( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = response.parse() + assert_matches_type(AgentUpdateResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.with_raw_response.update( + agent_id="", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: Nimble) -> None: + agent = client.agents.list() + assert_matches_type(AgentListResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: Nimble) -> None: + agent = client.agents.list( + limit=1, + offset=0, + workspace_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(AgentListResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: Nimble) -> None: + response = client.agents.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = response.parse() + assert_matches_type(AgentListResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: Nimble) -> None: + with client.agents.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = response.parse() + assert_matches_type(AgentListResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: Nimble) -> None: + agent = client.agents.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert agent is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: Nimble) -> None: + response = client.agents.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = response.parse() + assert agent is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: Nimble) -> None: + with client.agents.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = response.parse() + assert agent is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get(self, client: Nimble) -> None: + agent = client.agents.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(AgentGetResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get(self, client: Nimble) -> None: + response = client.agents.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = response.parse() + assert_matches_type(AgentGetResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get(self, client: Nimble) -> None: + with client.agents.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = response.parse() + assert_matches_type(AgentGetResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_get(self, client: Nimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + client.agents.with_raw_response.get( + "", + ) + + +class TestAsyncAgents: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.create() + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.create( + agent_name="agent_name", + description="description", + display_name="display_name", + domain_expertise="domain_expertise", + effort="low", + goals=["string"], + icon="icon", + is_active=True, + output_schema={"foo": "bar"}, + sources={ + "allow": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "avoid": "avoid", + "block": [ + { + "domains": ["string"], + "title": "title", + "order": 0, + } + ], + "prioritize": "prioritize", + }, + suggested_questions=["string"], + template="template", + use_case="research", + ) + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = await response.parse() + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncNimble) -> None: + async with async_client.agents.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = await response.parse() + assert_matches_type(AgentCreateResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.update( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + assert_matches_type(AgentUpdateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.with_raw_response.update( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = await response.parse() + assert_matches_type(AgentUpdateResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncNimble) -> None: + async with async_client.agents.with_streaming_response.update( + agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = await response.parse() + assert_matches_type(AgentUpdateResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.with_raw_response.update( + agent_id="", + body=[ + { + "op": "add", + "path": "path", + } + ], + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.list() + assert_matches_type(AgentListResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.list( + limit=1, + offset=0, + workspace_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(AgentListResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = await response.parse() + assert_matches_type(AgentListResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: + async with async_client.agents.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = await response.parse() + assert_matches_type(AgentListResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert agent is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = await response.parse() + assert agent is None + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncNimble) -> None: + async with async_client.agents.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = await response.parse() + assert agent is None + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get(self, async_client: AsyncNimble) -> None: + agent = await async_client.agents.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(AgentGetResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get(self, async_client: AsyncNimble) -> None: + response = await async_client.agents.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + agent = await response.parse() + assert_matches_type(AgentGetResponse, agent, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: + async with async_client.agents.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + agent = await response.parse() + assert_matches_type(AgentGetResponse, agent, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_get(self, async_client: AsyncNimble) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): + await async_client.agents.with_raw_response.get( + "", + ) diff --git a/tests/api_resources/test_client.py b/tests/api_resources/test_client.py index f160972..6ca6036 100644 --- a/tests/api_resources/test_client.py +++ b/tests/api_resources/test_client.py @@ -9,13 +9,7 @@ from tests.utils import assert_matches_type from nimble_python import Nimble, AsyncNimble -from nimble_python.types import ( - MapResponse, - SearchResponse, - ExtractResponse, - ExtractAsyncResponse, - ExtractBatchResponse, -) +from nimble_python.types import MapResponse, SearchResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,574 +17,6 @@ class TestClient: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_extract(self, client: Nimble) -> None: - client_ = client.extract( - url="url", - ) - assert_matches_type(ExtractResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_extract_with_all_params(self, client: Nimble) -> None: - client_ = client.extract( - url="url", - auto_driver_configuration={ - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - body={"key": "value"}, - browser="chrome", - browser_actions=[ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - city="Los Angeles", - consent_header=True, - cookies="sessionId=abc123; userId=user456", - country="US", - device="desktop", - driver="vx8", - expected_status_codes=[200, 201], - formats=["html"], - headers={ - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - http2=True, - is_xhr=True, - locale="en-US", - markdown_backend="full_page", - method="GET", - network_capture=[ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - os="windows", - parse=True, - parser={"myParser": "bar"}, - referrer_type="random", - render=True, - request_timeout=30000, - session={ - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - skill="dynamic-content", - state="CA", - tag="campaign-2024-q1", - ) - assert_matches_type(ExtractResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_extract(self, client: Nimble) -> None: - response = client.with_raw_response.extract( - url="url", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - client_ = response.parse() - assert_matches_type(ExtractResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_extract(self, client: Nimble) -> None: - with client.with_streaming_response.extract( - url="url", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - client_ = response.parse() - assert_matches_type(ExtractResponse, client_, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_extract_async(self, client: Nimble) -> None: - client_ = client.extract_async( - url="url", - ) - assert_matches_type(ExtractAsyncResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_extract_async_with_all_params(self, client: Nimble) -> None: - client_ = client.extract_async( - url="url", - auto_driver_configuration={ - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - body={"key": "value"}, - browser="chrome", - browser_actions=[ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - callback_url="https://example.com/webhook/callback", - city="Los Angeles", - consent_header=True, - cookies="sessionId=abc123; userId=user456", - country="US", - device="desktop", - driver="vx8", - expected_status_codes=[200, 201], - formats=["html"], - headers={ - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - http2=True, - is_xhr=True, - locale="en-US", - markdown_backend="full_page", - method="GET", - network_capture=[ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - os="windows", - parse=True, - parser={"myParser": "bar"}, - referrer_type="random", - render=True, - request_timeout=30000, - session={ - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - skill="dynamic-content", - state="CA", - storage_compress=True, - storage_object_name="result-2024-01-15.json", - storage_type="s3", - storage_url="s3://bucket-name/path/to/object", - tag="campaign-2024-q1", - ) - assert_matches_type(ExtractAsyncResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_extract_async(self, client: Nimble) -> None: - response = client.with_raw_response.extract_async( - url="url", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - client_ = response.parse() - assert_matches_type(ExtractAsyncResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_extract_async(self, client: Nimble) -> None: - with client.with_streaming_response.extract_async( - url="url", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - client_ = response.parse() - assert_matches_type(ExtractAsyncResponse, client_, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_extract_batch(self, client: Nimble) -> None: - client_ = client.extract_batch( - inputs=[{}], - ) - assert_matches_type(ExtractBatchResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_extract_batch_with_all_params(self, client: Nimble) -> None: - client_ = client.extract_batch( - inputs=[ - { - "auto_driver_configuration": { - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - "body": {"key": "value"}, - "browser": "chrome", - "browser_actions": [ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - "callback_url": "https://example.com/webhook/callback", - "city": "Los Angeles", - "consent_header": True, - "cookies": "sessionId=abc123; userId=user456", - "country": "US", - "device": "desktop", - "driver": "vx8", - "expected_status_codes": [200, 201], - "formats": ["html"], - "headers": { - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - "http2": True, - "is_xhr": True, - "locale": "en-US", - "markdown_backend": "full_page", - "method": "GET", - "network_capture": [ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - "os": "windows", - "parse": True, - "parser": {"myParser": "bar"}, - "referrer_type": "random", - "render": False, - "request_timeout": 30000, - "session": { - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - "skill": "dynamic-content", - "state": "CA", - "storage_compress": True, - "storage_object_name": "result-2024-01-15.json", - "storage_type": "s3", - "storage_url": "s3://bucket-name/path/to/object", - "tag": "campaign-2024-q1", - "url": "url", - } - ], - shared_inputs={ - "auto_driver_configuration": { - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - "body": {"key": "value"}, - "browser": "chrome", - "browser_actions": [ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - "callback_url": "https://example.com/webhook/callback", - "city": "Los Angeles", - "consent_header": True, - "cookies": "sessionId=abc123; userId=user456", - "country": "US", - "device": "desktop", - "driver": "vx8", - "expected_status_codes": [200, 201], - "formats": ["html"], - "headers": { - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - "http2": True, - "is_xhr": True, - "locale": "en-US", - "markdown_backend": "full_page", - "method": "GET", - "network_capture": [ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - "os": "windows", - "parse": True, - "parser": {"myParser": "bar"}, - "referrer_type": "random", - "render": False, - "request_timeout": 30000, - "session": { - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - "skill": "dynamic-content", - "state": "CA", - "storage_compress": True, - "storage_object_name": "result-2024-01-15.json", - "storage_type": "s3", - "storage_url": "s3://bucket-name/path/to/object", - "tag": "campaign-2024-q1", - "url": "url", - }, - ) - assert_matches_type(ExtractBatchResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_extract_batch(self, client: Nimble) -> None: - response = client.with_raw_response.extract_batch( - inputs=[{}], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - client_ = response.parse() - assert_matches_type(ExtractBatchResponse, client_, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_extract_batch(self, client: Nimble) -> None: - with client.with_streaming_response.extract_batch( - inputs=[{}], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - client_ = response.parse() - assert_matches_type(ExtractBatchResponse, client_, path=["response"]) - - assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_map(self, client: Nimble) -> None: @@ -701,574 +127,6 @@ class TestAsyncClient: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_extract(self, async_client: AsyncNimble) -> None: - client = await async_client.extract( - url="url", - ) - assert_matches_type(ExtractResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_extract_with_all_params(self, async_client: AsyncNimble) -> None: - client = await async_client.extract( - url="url", - auto_driver_configuration={ - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - body={"key": "value"}, - browser="chrome", - browser_actions=[ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - city="Los Angeles", - consent_header=True, - cookies="sessionId=abc123; userId=user456", - country="US", - device="desktop", - driver="vx8", - expected_status_codes=[200, 201], - formats=["html"], - headers={ - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - http2=True, - is_xhr=True, - locale="en-US", - markdown_backend="full_page", - method="GET", - network_capture=[ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - os="windows", - parse=True, - parser={"myParser": "bar"}, - referrer_type="random", - render=True, - request_timeout=30000, - session={ - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - skill="dynamic-content", - state="CA", - tag="campaign-2024-q1", - ) - assert_matches_type(ExtractResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_extract(self, async_client: AsyncNimble) -> None: - response = await async_client.with_raw_response.extract( - url="url", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - client = await response.parse() - assert_matches_type(ExtractResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_extract(self, async_client: AsyncNimble) -> None: - async with async_client.with_streaming_response.extract( - url="url", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - client = await response.parse() - assert_matches_type(ExtractResponse, client, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_extract_async(self, async_client: AsyncNimble) -> None: - client = await async_client.extract_async( - url="url", - ) - assert_matches_type(ExtractAsyncResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_extract_async_with_all_params(self, async_client: AsyncNimble) -> None: - client = await async_client.extract_async( - url="url", - auto_driver_configuration={ - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - body={"key": "value"}, - browser="chrome", - browser_actions=[ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - callback_url="https://example.com/webhook/callback", - city="Los Angeles", - consent_header=True, - cookies="sessionId=abc123; userId=user456", - country="US", - device="desktop", - driver="vx8", - expected_status_codes=[200, 201], - formats=["html"], - headers={ - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - http2=True, - is_xhr=True, - locale="en-US", - markdown_backend="full_page", - method="GET", - network_capture=[ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - os="windows", - parse=True, - parser={"myParser": "bar"}, - referrer_type="random", - render=True, - request_timeout=30000, - session={ - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - skill="dynamic-content", - state="CA", - storage_compress=True, - storage_object_name="result-2024-01-15.json", - storage_type="s3", - storage_url="s3://bucket-name/path/to/object", - tag="campaign-2024-q1", - ) - assert_matches_type(ExtractAsyncResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_extract_async(self, async_client: AsyncNimble) -> None: - response = await async_client.with_raw_response.extract_async( - url="url", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - client = await response.parse() - assert_matches_type(ExtractAsyncResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_extract_async(self, async_client: AsyncNimble) -> None: - async with async_client.with_streaming_response.extract_async( - url="url", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - client = await response.parse() - assert_matches_type(ExtractAsyncResponse, client, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_extract_batch(self, async_client: AsyncNimble) -> None: - client = await async_client.extract_batch( - inputs=[{}], - ) - assert_matches_type(ExtractBatchResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_extract_batch_with_all_params(self, async_client: AsyncNimble) -> None: - client = await async_client.extract_batch( - inputs=[ - { - "auto_driver_configuration": { - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - "body": {"key": "value"}, - "browser": "chrome", - "browser_actions": [ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - "callback_url": "https://example.com/webhook/callback", - "city": "Los Angeles", - "consent_header": True, - "cookies": "sessionId=abc123; userId=user456", - "country": "US", - "device": "desktop", - "driver": "vx8", - "expected_status_codes": [200, 201], - "formats": ["html"], - "headers": { - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - "http2": True, - "is_xhr": True, - "locale": "en-US", - "markdown_backend": "full_page", - "method": "GET", - "network_capture": [ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - "os": "windows", - "parse": True, - "parser": {"myParser": "bar"}, - "referrer_type": "random", - "render": False, - "request_timeout": 30000, - "session": { - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - "skill": "dynamic-content", - "state": "CA", - "storage_compress": True, - "storage_object_name": "result-2024-01-15.json", - "storage_type": "s3", - "storage_url": "s3://bucket-name/path/to/object", - "tag": "campaign-2024-q1", - "url": "url", - } - ], - shared_inputs={ - "auto_driver_configuration": { - "vx10": 2, - "vx10-pro": 0, - "vx6-fast": 1, - "vx6-stealth": 1, - "vx8": 5, - "vx8-pro": 5, - }, - "body": {"key": "value"}, - "browser": "chrome", - "browser_actions": [ - {"goto": "https://example.com/login"}, - {"wait_for_element": "#login-form"}, - { - "fill": { - "selector": "#username", - "value": "user@example.com", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - { - "fill": { - "selector": "#password", - "value": "password123", - "click_on_element": True, - "delay": 1000, - "mode": "type", - "mouse_movement_strategy": "linear", - "required": "true", - "scroll": True, - "skip": "true", - "timeout": 0, - "typing_interval": 1000, - "typing_strategy": "simple", - "visible": True, - } - }, - {"click": "#submit"}, - { - "screenshot": { - "format": "png", - "full_page": True, - "quality": 0, - "required": "true", - "skip": "true", - } - }, - ], - "callback_url": "https://example.com/webhook/callback", - "city": "Los Angeles", - "consent_header": True, - "cookies": "sessionId=abc123; userId=user456", - "country": "US", - "device": "desktop", - "driver": "vx8", - "expected_status_codes": [200, 201], - "formats": ["html"], - "headers": { - "Accept-Language": "en-US", - "User-Agent": "CustomBot/1.0", - }, - "http2": True, - "is_xhr": True, - "locale": "en-US", - "markdown_backend": "full_page", - "method": "GET", - "network_capture": [ - { - "method": "GET", - "resource_type": "document", - "status_code": 100, - "url": { - "value": "value", - "type": "exact", - }, - "validation": True, - "wait_for_requests_count": 0, - "wait_for_requests_count_timeout": 1, - } - ], - "os": "windows", - "parse": True, - "parser": {"myParser": "bar"}, - "referrer_type": "random", - "render": False, - "request_timeout": 30000, - "session": { - "id": "id", - "prefetch_userbrowser": True, - "renew_on_blocked": True, - "retry": True, - "timeout": 1, - }, - "skill": "dynamic-content", - "state": "CA", - "storage_compress": True, - "storage_object_name": "result-2024-01-15.json", - "storage_type": "s3", - "storage_url": "s3://bucket-name/path/to/object", - "tag": "campaign-2024-q1", - "url": "url", - }, - ) - assert_matches_type(ExtractBatchResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_extract_batch(self, async_client: AsyncNimble) -> None: - response = await async_client.with_raw_response.extract_batch( - inputs=[{}], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - client = await response.parse() - assert_matches_type(ExtractBatchResponse, client, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_extract_batch(self, async_client: AsyncNimble) -> None: - async with async_client.with_streaming_response.extract_batch( - inputs=[{}], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - client = await response.parse() - assert_matches_type(ExtractBatchResponse, client, path=["response"]) - - assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_map(self, async_client: AsyncNimble) -> None: diff --git a/tests/api_resources/test_extract.py b/tests/api_resources/test_extract.py new file mode 100644 index 0000000..ea71357 --- /dev/null +++ b/tests/api_resources/test_extract.py @@ -0,0 +1,1164 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from nimble_python import Nimble, AsyncNimble +from nimble_python.types import ( + ExtractRunResponse, + ExtractAsyncResponse, + ExtractBatchResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestExtract: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_async(self, client: Nimble) -> None: + extract = client.extract.async_( + url="url", + ) + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_async_with_all_params(self, client: Nimble) -> None: + extract = client.extract.async_( + url="url", + auto_driver_configuration={ + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + body={"key": "value"}, + browser="chrome", + browser_actions=[ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + callback_url="https://example.com/webhook/callback", + city="Los Angeles", + consent_header=True, + cookies="sessionId=abc123; userId=user456", + country="US", + device="desktop", + driver="vx8", + expected_status_codes=[200, 201], + formats=["html"], + headers={ + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + http2=True, + is_xhr=True, + locale="en-US", + markdown_backend="full_page", + method="GET", + network_capture=[ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + os="windows", + parse=True, + parser={"myParser": "bar"}, + referrer_type="random", + render=True, + request_timeout=30000, + session={ + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + skill="dynamic-content", + state="CA", + storage_compress=True, + storage_object_name="result-2024-01-15.json", + storage_type="s3", + storage_url="s3://bucket-name/path/to/object", + tag="campaign-2024-q1", + ) + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_async(self, client: Nimble) -> None: + response = client.extract.with_raw_response.async_( + url="url", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + extract = response.parse() + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_async(self, client: Nimble) -> None: + with client.extract.with_streaming_response.async_( + url="url", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + extract = response.parse() + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch(self, client: Nimble) -> None: + extract = client.extract.batch( + inputs=[{}], + ) + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch_with_all_params(self, client: Nimble) -> None: + extract = client.extract.batch( + inputs=[ + { + "auto_driver_configuration": { + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + "body": {"key": "value"}, + "browser": "chrome", + "browser_actions": [ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + "callback_url": "https://example.com/webhook/callback", + "city": "Los Angeles", + "consent_header": True, + "cookies": "sessionId=abc123; userId=user456", + "country": "US", + "device": "desktop", + "driver": "vx8", + "expected_status_codes": [200, 201], + "formats": ["html"], + "headers": { + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + "http2": True, + "is_xhr": True, + "locale": "en-US", + "markdown_backend": "full_page", + "method": "GET", + "network_capture": [ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + "os": "windows", + "parse": True, + "parser": {"myParser": "bar"}, + "referrer_type": "random", + "render": False, + "request_timeout": 30000, + "session": { + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + "skill": "dynamic-content", + "state": "CA", + "storage_compress": True, + "storage_object_name": "result-2024-01-15.json", + "storage_type": "s3", + "storage_url": "s3://bucket-name/path/to/object", + "tag": "campaign-2024-q1", + "url": "url", + } + ], + shared_inputs={ + "auto_driver_configuration": { + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + "body": {"key": "value"}, + "browser": "chrome", + "browser_actions": [ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + "callback_url": "https://example.com/webhook/callback", + "city": "Los Angeles", + "consent_header": True, + "cookies": "sessionId=abc123; userId=user456", + "country": "US", + "device": "desktop", + "driver": "vx8", + "expected_status_codes": [200, 201], + "formats": ["html"], + "headers": { + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + "http2": True, + "is_xhr": True, + "locale": "en-US", + "markdown_backend": "full_page", + "method": "GET", + "network_capture": [ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + "os": "windows", + "parse": True, + "parser": {"myParser": "bar"}, + "referrer_type": "random", + "render": False, + "request_timeout": 30000, + "session": { + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + "skill": "dynamic-content", + "state": "CA", + "storage_compress": True, + "storage_object_name": "result-2024-01-15.json", + "storage_type": "s3", + "storage_url": "s3://bucket-name/path/to/object", + "tag": "campaign-2024-q1", + "url": "url", + }, + ) + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_batch(self, client: Nimble) -> None: + response = client.extract.with_raw_response.batch( + inputs=[{}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + extract = response.parse() + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_batch(self, client: Nimble) -> None: + with client.extract.with_streaming_response.batch( + inputs=[{}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + extract = response.parse() + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_run(self, client: Nimble) -> None: + extract = client.extract.run( + url="url", + ) + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_run_with_all_params(self, client: Nimble) -> None: + extract = client.extract.run( + url="url", + auto_driver_configuration={ + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + body={"key": "value"}, + browser="chrome", + browser_actions=[ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + city="Los Angeles", + consent_header=True, + cookies="sessionId=abc123; userId=user456", + country="US", + device="desktop", + driver="vx8", + expected_status_codes=[200, 201], + formats=["html"], + headers={ + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + http2=True, + is_xhr=True, + locale="en-US", + markdown_backend="full_page", + method="GET", + network_capture=[ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + os="windows", + parse=True, + parser={"myParser": "bar"}, + referrer_type="random", + render=True, + request_timeout=30000, + session={ + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + skill="dynamic-content", + state="CA", + tag="campaign-2024-q1", + ) + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_run(self, client: Nimble) -> None: + response = client.extract.with_raw_response.run( + url="url", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + extract = response.parse() + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_run(self, client: Nimble) -> None: + with client.extract.with_streaming_response.run( + url="url", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + extract = response.parse() + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncExtract: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_async(self, async_client: AsyncNimble) -> None: + extract = await async_client.extract.async_( + url="url", + ) + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_async_with_all_params(self, async_client: AsyncNimble) -> None: + extract = await async_client.extract.async_( + url="url", + auto_driver_configuration={ + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + body={"key": "value"}, + browser="chrome", + browser_actions=[ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + callback_url="https://example.com/webhook/callback", + city="Los Angeles", + consent_header=True, + cookies="sessionId=abc123; userId=user456", + country="US", + device="desktop", + driver="vx8", + expected_status_codes=[200, 201], + formats=["html"], + headers={ + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + http2=True, + is_xhr=True, + locale="en-US", + markdown_backend="full_page", + method="GET", + network_capture=[ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + os="windows", + parse=True, + parser={"myParser": "bar"}, + referrer_type="random", + render=True, + request_timeout=30000, + session={ + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + skill="dynamic-content", + state="CA", + storage_compress=True, + storage_object_name="result-2024-01-15.json", + storage_type="s3", + storage_url="s3://bucket-name/path/to/object", + tag="campaign-2024-q1", + ) + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_async(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.with_raw_response.async_( + url="url", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + extract = await response.parse() + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_async(self, async_client: AsyncNimble) -> None: + async with async_client.extract.with_streaming_response.async_( + url="url", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + extract = await response.parse() + assert_matches_type(ExtractAsyncResponse, extract, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch(self, async_client: AsyncNimble) -> None: + extract = await async_client.extract.batch( + inputs=[{}], + ) + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch_with_all_params(self, async_client: AsyncNimble) -> None: + extract = await async_client.extract.batch( + inputs=[ + { + "auto_driver_configuration": { + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + "body": {"key": "value"}, + "browser": "chrome", + "browser_actions": [ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + "callback_url": "https://example.com/webhook/callback", + "city": "Los Angeles", + "consent_header": True, + "cookies": "sessionId=abc123; userId=user456", + "country": "US", + "device": "desktop", + "driver": "vx8", + "expected_status_codes": [200, 201], + "formats": ["html"], + "headers": { + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + "http2": True, + "is_xhr": True, + "locale": "en-US", + "markdown_backend": "full_page", + "method": "GET", + "network_capture": [ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + "os": "windows", + "parse": True, + "parser": {"myParser": "bar"}, + "referrer_type": "random", + "render": False, + "request_timeout": 30000, + "session": { + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + "skill": "dynamic-content", + "state": "CA", + "storage_compress": True, + "storage_object_name": "result-2024-01-15.json", + "storage_type": "s3", + "storage_url": "s3://bucket-name/path/to/object", + "tag": "campaign-2024-q1", + "url": "url", + } + ], + shared_inputs={ + "auto_driver_configuration": { + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + "body": {"key": "value"}, + "browser": "chrome", + "browser_actions": [ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + "callback_url": "https://example.com/webhook/callback", + "city": "Los Angeles", + "consent_header": True, + "cookies": "sessionId=abc123; userId=user456", + "country": "US", + "device": "desktop", + "driver": "vx8", + "expected_status_codes": [200, 201], + "formats": ["html"], + "headers": { + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + "http2": True, + "is_xhr": True, + "locale": "en-US", + "markdown_backend": "full_page", + "method": "GET", + "network_capture": [ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + "os": "windows", + "parse": True, + "parser": {"myParser": "bar"}, + "referrer_type": "random", + "render": False, + "request_timeout": 30000, + "session": { + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + "skill": "dynamic-content", + "state": "CA", + "storage_compress": True, + "storage_object_name": "result-2024-01-15.json", + "storage_type": "s3", + "storage_url": "s3://bucket-name/path/to/object", + "tag": "campaign-2024-q1", + "url": "url", + }, + ) + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_batch(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.with_raw_response.batch( + inputs=[{}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + extract = await response.parse() + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_batch(self, async_client: AsyncNimble) -> None: + async with async_client.extract.with_streaming_response.batch( + inputs=[{}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + extract = await response.parse() + assert_matches_type(ExtractBatchResponse, extract, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_run(self, async_client: AsyncNimble) -> None: + extract = await async_client.extract.run( + url="url", + ) + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_run_with_all_params(self, async_client: AsyncNimble) -> None: + extract = await async_client.extract.run( + url="url", + auto_driver_configuration={ + "vx10": 2, + "vx10-pro": 0, + "vx6-fast": 1, + "vx6-stealth": 1, + "vx8": 5, + "vx8-pro": 5, + }, + body={"key": "value"}, + browser="chrome", + browser_actions=[ + {"goto": "https://example.com/login"}, + {"wait_for_element": "#login-form"}, + { + "fill": { + "selector": "#username", + "value": "user@example.com", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + { + "fill": { + "selector": "#password", + "value": "password123", + "click_on_element": True, + "delay": 1000, + "mode": "type", + "mouse_movement_strategy": "linear", + "required": "true", + "scroll": True, + "skip": "true", + "timeout": 0, + "typing_interval": 1000, + "typing_strategy": "simple", + "visible": True, + } + }, + {"click": "#submit"}, + { + "screenshot": { + "format": "png", + "full_page": True, + "quality": 0, + "required": "true", + "skip": "true", + } + }, + ], + city="Los Angeles", + consent_header=True, + cookies="sessionId=abc123; userId=user456", + country="US", + device="desktop", + driver="vx8", + expected_status_codes=[200, 201], + formats=["html"], + headers={ + "Accept-Language": "en-US", + "User-Agent": "CustomBot/1.0", + }, + http2=True, + is_xhr=True, + locale="en-US", + markdown_backend="full_page", + method="GET", + network_capture=[ + { + "method": "GET", + "resource_type": "document", + "status_code": 100, + "url": { + "value": "value", + "type": "exact", + }, + "validation": True, + "wait_for_requests_count": 0, + "wait_for_requests_count_timeout": 1, + } + ], + os="windows", + parse=True, + parser={"myParser": "bar"}, + referrer_type="random", + render=True, + request_timeout=30000, + session={ + "id": "id", + "prefetch_userbrowser": True, + "renew_on_blocked": True, + "retry": True, + "timeout": 1, + }, + skill="dynamic-content", + state="CA", + tag="campaign-2024-q1", + ) + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_run(self, async_client: AsyncNimble) -> None: + response = await async_client.extract.with_raw_response.run( + url="url", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + extract = await response.parse() + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_run(self, async_client: AsyncNimble) -> None: + async with async_client.extract.with_streaming_response.run( + url="url", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + extract = await response.parse() + assert_matches_type(ExtractRunResponse, extract, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_jobs.py b/tests/api_resources/test_jobs.py index dd67509..aa26819 100644 --- a/tests/api_resources/test_jobs.py +++ b/tests/api_resources/test_jobs.py @@ -11,14 +11,11 @@ from nimble_python import Nimble, AsyncNimble from nimble_python.types import ( JobGetResponse, - JobRunResponse, JobListResponse, JobCreateResponse, JobUpdateResponse, ) -# pyright: reportDeprecated=false - base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -28,49 +25,44 @@ class TestJobs: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_create(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.create( - agent_name="agent_name", - name="name", - ) - + job = client.jobs.create( + extract_template_name="extract_template_name", + name="name", + ) assert_matches_type(JobCreateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_create_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.create( - agent_name="agent_name", - name="name", - description="description", - destination={ - "path": "path", - "type": "file", - "format": "jsonl", - }, - display_name="display_name", - inputs={ - "type": "s3", - "data": [{"foo": "bar"}], - "file_path": "file_path", - }, - schedule={ - "cron": "cron", - "enabled": True, - }, - ) - + job = client.jobs.create( + extract_template_name="extract_template_name", + name="name", + description="description", + destination={ + "path": "path", + "type": "file", + "format": "jsonl", + }, + display_name="display_name", + inputs={ + "type": "s3", + "data": [{"foo": "bar"}], + "file_path": "file_path", + }, + schedule={ + "cron": "cron", + "enabled": True, + }, + ) assert_matches_type(JobCreateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_create(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.with_raw_response.create( - agent_name="agent_name", - name="name", - ) + response = client.jobs.with_raw_response.create( + extract_template_name="extract_template_name", + name="name", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -80,62 +72,56 @@ def test_raw_response_create(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_create(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.with_streaming_response.create( - agent_name="agent_name", - name="name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.with_streaming_response.create( + extract_template_name="extract_template_name", + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = response.parse() - assert_matches_type(JobCreateResponse, job, path=["response"]) + job = response.parse() + assert_matches_type(JobCreateResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.update( - job_id="job_id", - ) - + job = client.jobs.update( + job_id="job_id", + ) assert_matches_type(JobUpdateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_update_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.update( - job_id="job_id", - description="description", - destination={ - "path": "path", - "type": "file", - "format": "jsonl", - }, - display_name="display_name", - inputs={ - "type": "s3", - "data": [{"foo": "bar"}], - "file_path": "file_path", - }, - schedule={ - "cron": "cron", - "enabled": True, - }, - ) - + job = client.jobs.update( + job_id="job_id", + description="description", + destination={ + "path": "path", + "type": "file", + "format": "jsonl", + }, + display_name="display_name", + inputs={ + "type": "s3", + "data": [{"foo": "bar"}], + "file_path": "file_path", + }, + schedule={ + "cron": "cron", + "enabled": True, + }, + ) assert_matches_type(JobUpdateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.with_raw_response.update( - job_id="job_id", - ) + response = client.jobs.with_raw_response.update( + job_id="job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -145,53 +131,44 @@ def test_raw_response_update(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.with_streaming_response.update( - job_id="job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.with_streaming_response.update( + job_id="job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = response.parse() - assert_matches_type(JobUpdateResponse, job, path=["response"]) + job = response.parse() + assert_matches_type(JobUpdateResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - client.jobs.with_raw_response.update( - job_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.jobs.with_raw_response.update( + job_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.list() - + job = client.jobs.list() assert_matches_type(JobListResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.list( - agent_name="agent_name", - page=1, - per_page=1, - q="q", - ) - + job = client.jobs.list( + limit=1, + offset=0, + ) assert_matches_type(JobListResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.with_raw_response.list() + response = client.jobs.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -201,33 +178,29 @@ def test_raw_response_list(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = response.parse() - assert_matches_type(JobListResponse, job, path=["response"]) + job = response.parse() + assert_matches_type(JobListResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_delete(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.delete( - "job_id", - ) - + job = client.jobs.delete( + "job_id", + ) assert job is None @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_delete(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.with_raw_response.delete( - "job_id", - ) + response = client.jobs.with_raw_response.delete( + "job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -237,44 +210,39 @@ def test_raw_response_delete(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_delete(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.with_streaming_response.delete( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.with_streaming_response.delete( + "job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = response.parse() - assert job is None + job = response.parse() + assert job is None assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_delete(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - client.jobs.with_raw_response.delete( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.jobs.with_raw_response.delete( + "", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.get( - "job_id", - ) - + job = client.jobs.get( + "job_id", + ) assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.with_raw_response.get( - "job_id", - ) + response = client.jobs.with_raw_response.get( + "job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -284,74 +252,25 @@ def test_raw_response_get(self, client: Nimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.with_streaming_response.get( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with client.jobs.with_streaming_response.get( + "job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = response.parse() - assert_matches_type(JobGetResponse, job, path=["response"]) + job = response.parse() + assert_matches_type(JobGetResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - client.jobs.with_raw_response.get( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - job = client.jobs.run( - "job_id", + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.jobs.with_raw_response.get( + "", ) - assert_matches_type(JobRunResponse, job, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.jobs.with_raw_response.run( - "job_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = response.parse() - assert_matches_type(JobRunResponse, job, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.jobs.with_streaming_response.run( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - job = response.parse() - assert_matches_type(JobRunResponse, job, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - client.jobs.with_raw_response.run( - "", - ) - class TestAsyncJobs: parametrize = pytest.mark.parametrize( @@ -361,49 +280,44 @@ class TestAsyncJobs: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_create(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.create( - agent_name="agent_name", - name="name", - ) - + job = await async_client.jobs.create( + extract_template_name="extract_template_name", + name="name", + ) assert_matches_type(JobCreateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.create( - agent_name="agent_name", - name="name", - description="description", - destination={ - "path": "path", - "type": "file", - "format": "jsonl", - }, - display_name="display_name", - inputs={ - "type": "s3", - "data": [{"foo": "bar"}], - "file_path": "file_path", - }, - schedule={ - "cron": "cron", - "enabled": True, - }, - ) - + job = await async_client.jobs.create( + extract_template_name="extract_template_name", + name="name", + description="description", + destination={ + "path": "path", + "type": "file", + "format": "jsonl", + }, + display_name="display_name", + inputs={ + "type": "s3", + "data": [{"foo": "bar"}], + "file_path": "file_path", + }, + schedule={ + "cron": "cron", + "enabled": True, + }, + ) assert_matches_type(JobCreateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_create(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.with_raw_response.create( - agent_name="agent_name", - name="name", - ) + response = await async_client.jobs.with_raw_response.create( + extract_template_name="extract_template_name", + name="name", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -413,62 +327,56 @@ async def test_raw_response_create(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_create(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.with_streaming_response.create( - agent_name="agent_name", - name="name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.with_streaming_response.create( + extract_template_name="extract_template_name", + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = await response.parse() - assert_matches_type(JobCreateResponse, job, path=["response"]) + job = await response.parse() + assert_matches_type(JobCreateResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.update( - job_id="job_id", - ) - + job = await async_client.jobs.update( + job_id="job_id", + ) assert_matches_type(JobUpdateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_update_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.update( - job_id="job_id", - description="description", - destination={ - "path": "path", - "type": "file", - "format": "jsonl", - }, - display_name="display_name", - inputs={ - "type": "s3", - "data": [{"foo": "bar"}], - "file_path": "file_path", - }, - schedule={ - "cron": "cron", - "enabled": True, - }, - ) - + job = await async_client.jobs.update( + job_id="job_id", + description="description", + destination={ + "path": "path", + "type": "file", + "format": "jsonl", + }, + display_name="display_name", + inputs={ + "type": "s3", + "data": [{"foo": "bar"}], + "file_path": "file_path", + }, + schedule={ + "cron": "cron", + "enabled": True, + }, + ) assert_matches_type(JobUpdateResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.with_raw_response.update( - job_id="job_id", - ) + response = await async_client.jobs.with_raw_response.update( + job_id="job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -478,53 +386,44 @@ async def test_raw_response_update(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.with_streaming_response.update( - job_id="job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.with_streaming_response.update( + job_id="job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = await response.parse() - assert_matches_type(JobUpdateResponse, job, path=["response"]) + job = await response.parse() + assert_matches_type(JobUpdateResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await async_client.jobs.with_raw_response.update( - job_id="", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.jobs.with_raw_response.update( + job_id="", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.list() - + job = await async_client.jobs.list() assert_matches_type(JobListResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.list( - agent_name="agent_name", - page=1, - per_page=1, - q="q", - ) - + job = await async_client.jobs.list( + limit=1, + offset=0, + ) assert_matches_type(JobListResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.with_raw_response.list() + response = await async_client.jobs.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -534,33 +433,29 @@ async def test_raw_response_list(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = await response.parse() - assert_matches_type(JobListResponse, job, path=["response"]) + job = await response.parse() + assert_matches_type(JobListResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_delete(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.delete( - "job_id", - ) - + job = await async_client.jobs.delete( + "job_id", + ) assert job is None @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_delete(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.with_raw_response.delete( - "job_id", - ) + response = await async_client.jobs.with_raw_response.delete( + "job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -570,44 +465,39 @@ async def test_raw_response_delete(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_delete(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.with_streaming_response.delete( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.with_streaming_response.delete( + "job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = await response.parse() - assert job is None + job = await response.parse() + assert job is None assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_delete(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await async_client.jobs.with_raw_response.delete( - "", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.jobs.with_raw_response.delete( + "", + ) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.get( - "job_id", - ) - + job = await async_client.jobs.get( + "job_id", + ) assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.with_raw_response.get( - "job_id", - ) + response = await async_client.jobs.with_raw_response.get( + "job_id", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -617,70 +507,21 @@ async def test_raw_response_get(self, async_client: AsyncNimble) -> None: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.with_streaming_response.get( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + async with async_client.jobs.with_streaming_response.get( + "job_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = await response.parse() - assert_matches_type(JobGetResponse, job, path=["response"]) + job = await response.parse() + assert_matches_type(JobGetResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await async_client.jobs.with_raw_response.get( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - job = await async_client.jobs.run( - "job_id", + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.jobs.with_raw_response.get( + "", ) - - assert_matches_type(JobRunResponse, job, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.jobs.with_raw_response.run( - "job_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - job = await response.parse() - assert_matches_type(JobRunResponse, job, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.jobs.with_streaming_response.run( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - job = await response.parse() - assert_matches_type(JobRunResponse, job, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await async_client.jobs.with_raw_response.run( - "", - ) diff --git a/tests/api_resources/test_task_agent.py b/tests/api_resources/test_task_agent.py deleted file mode 100644 index bc9d89e..0000000 --- a/tests/api_resources/test_task_agent.py +++ /dev/null @@ -1,762 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from tests.utils import assert_matches_type -from nimble_python import Nimble, AsyncNimble -from nimble_python.types import ( - TaskAgentGetResponse, - TaskAgentRunResponse, - TaskAgentListResponse, - TaskAgentCreateResponse, - TaskAgentUpdateResponse, -) - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestTaskAgent: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.create() - - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.create( - agent_name="agent_name", - description="description", - display_name="display_name", - domain_expertise="domain_expertise", - effort="low", - goals=["string"], - icon="icon", - is_active=True, - output_schema={"foo": "bar"}, - sources={ - "allow": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "avoid": "avoid", - "block": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "prioritize": "prioritize", - }, - suggested_questions=["string"], - template="template", - use_case="research", - ) - - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_create(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.with_raw_response.create() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = response.parse() - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_create(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.with_streaming_response.create() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = response.parse() - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.update( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) - - assert_matches_type(TaskAgentUpdateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.with_raw_response.update( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = response.parse() - assert_matches_type(TaskAgentUpdateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.with_streaming_response.update( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = response.parse() - assert_matches_type(TaskAgentUpdateResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_update(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.with_raw_response.update( - agent_id="", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.list() - - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.list( - limit=1, - offset=0, - workspace_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = response.parse() - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = response.parse() - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_deactivate(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.deactivate( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert task_agent is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_deactivate(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.with_raw_response.deactivate( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = response.parse() - assert task_agent is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_deactivate(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.with_streaming_response.deactivate( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = response.parse() - assert task_agent is None - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_deactivate(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.with_raw_response.deactivate( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(TaskAgentGetResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = response.parse() - assert_matches_type(TaskAgentGetResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.with_streaming_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = response.parse() - assert_matches_type(TaskAgentGetResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_get(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.with_raw_response.get( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - ) - - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_run_with_all_params(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = client.task_agent.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - effort="low", - enable_events=True, - input_data=[{"foo": "bar"}], - output_schema={"foo": "bar"}, - previous_interaction_id="previous_interaction_id", - sources={ - "allow": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "avoid": "avoid", - "block": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "prioritize": "prioritize", - }, - ) - - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - response = client.task_agent.with_raw_response.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = response.parse() - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with client.task_agent.with_streaming_response.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = response.parse() - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_run(self, client: Nimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - client.task_agent.with_raw_response.run( - agent_id="", - input="input", - ) - - -class TestAsyncTaskAgent: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.create() - - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.create( - agent_name="agent_name", - description="description", - display_name="display_name", - domain_expertise="domain_expertise", - effort="low", - goals=["string"], - icon="icon", - is_active=True, - output_schema={"foo": "bar"}, - sources={ - "allow": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "avoid": "avoid", - "block": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "prioritize": "prioritize", - }, - suggested_questions=["string"], - template="template", - use_case="research", - ) - - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_create(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.with_raw_response.create() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = await response.parse() - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.with_streaming_response.create() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = await response.parse() - assert_matches_type(TaskAgentCreateResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.update( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) - - assert_matches_type(TaskAgentUpdateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.with_raw_response.update( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = await response.parse() - assert_matches_type(TaskAgentUpdateResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.with_streaming_response.update( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = await response.parse() - assert_matches_type(TaskAgentUpdateResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_update(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.with_raw_response.update( - agent_id="", - body=[ - { - "op": "add", - "path": "path", - } - ], - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.list() - - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.list( - limit=1, - offset=0, - workspace_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = await response.parse() - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = await response.parse() - assert_matches_type(TaskAgentListResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_deactivate(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.deactivate( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert task_agent is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_deactivate(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.with_raw_response.deactivate( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = await response.parse() - assert task_agent is None - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_deactivate(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.with_streaming_response.deactivate( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = await response.parse() - assert task_agent is None - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_deactivate(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.with_raw_response.deactivate( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert_matches_type(TaskAgentGetResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = await response.parse() - assert_matches_type(TaskAgentGetResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.with_streaming_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = await response.parse() - assert_matches_type(TaskAgentGetResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_get(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.with_raw_response.get( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - ) - - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_run_with_all_params(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - task_agent = await async_client.task_agent.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - effort="low", - enable_events=True, - input_data=[{"foo": "bar"}], - output_schema={"foo": "bar"}, - previous_interaction_id="previous_interaction_id", - sources={ - "allow": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "avoid": "avoid", - "block": [ - { - "domains": ["string"], - "title": "title", - "order": 0, - } - ], - "prioritize": "prioritize", - }, - ) - - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.task_agent.with_raw_response.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - task_agent = await response.parse() - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.task_agent.with_streaming_response.run( - agent_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - input="input", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - task_agent = await response.parse() - assert_matches_type(TaskAgentRunResponse, task_agent, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_run(self, async_client: AsyncNimble) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_id` but received ''"): - await async_client.task_agent.with_raw_response.run( - agent_id="", - input="input", - ) diff --git a/tests/test_client.py b/tests/test_client.py index ed3ba77..becde6c 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -882,20 +882,20 @@ def test_parse_retry_after_header( @mock.patch("nimble_python._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Nimble) -> None: - respx_mock.post("/v1/extract").mock(side_effect=httpx.TimeoutException("Test timeout error")) + respx_mock.post("/v2/extract").mock(side_effect=httpx.TimeoutException("Test timeout error")) with pytest.raises(APITimeoutError): - client.with_streaming_response.extract(url="url").__enter__() + client.extract.with_streaming_response.run(url="url").__enter__() assert _get_open_connections(client) == 0 @mock.patch("nimble_python._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Nimble) -> None: - respx_mock.post("/v1/extract").mock(return_value=httpx.Response(500)) + respx_mock.post("/v2/extract").mock(return_value=httpx.Response(500)) with pytest.raises(APIStatusError): - client.with_streaming_response.extract(url="url").__enter__() + client.extract.with_streaming_response.run(url="url").__enter__() assert _get_open_connections(client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @@ -922,9 +922,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/v1/extract").mock(side_effect=retry_handler) + respx_mock.post("/v2/extract").mock(side_effect=retry_handler) - response = client.with_raw_response.extract(url="url") + response = client.extract.with_raw_response.run(url="url") assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -946,9 +946,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/v1/extract").mock(side_effect=retry_handler) + respx_mock.post("/v2/extract").mock(side_effect=retry_handler) - response = client.with_raw_response.extract(url="url", extra_headers={"x-stainless-retry-count": Omit()}) + response = client.extract.with_raw_response.run(url="url", extra_headers={"x-stainless-retry-count": Omit()}) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -969,9 +969,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/v1/extract").mock(side_effect=retry_handler) + respx_mock.post("/v2/extract").mock(side_effect=retry_handler) - response = client.with_raw_response.extract(url="url", extra_headers={"x-stainless-retry-count": "42"}) + response = client.extract.with_raw_response.run(url="url", extra_headers={"x-stainless-retry-count": "42"}) assert response.http_request.headers.get("x-stainless-retry-count") == "42" @@ -1821,20 +1821,20 @@ async def test_parse_retry_after_header( @mock.patch("nimble_python._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncNimble) -> None: - respx_mock.post("/v1/extract").mock(side_effect=httpx.TimeoutException("Test timeout error")) + respx_mock.post("/v2/extract").mock(side_effect=httpx.TimeoutException("Test timeout error")) with pytest.raises(APITimeoutError): - await async_client.with_streaming_response.extract(url="url").__aenter__() + await async_client.extract.with_streaming_response.run(url="url").__aenter__() assert _get_open_connections(async_client) == 0 @mock.patch("nimble_python._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncNimble) -> None: - respx_mock.post("/v1/extract").mock(return_value=httpx.Response(500)) + respx_mock.post("/v2/extract").mock(return_value=httpx.Response(500)) with pytest.raises(APIStatusError): - await async_client.with_streaming_response.extract(url="url").__aenter__() + await async_client.extract.with_streaming_response.run(url="url").__aenter__() assert _get_open_connections(async_client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @@ -1861,9 +1861,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/v1/extract").mock(side_effect=retry_handler) + respx_mock.post("/v2/extract").mock(side_effect=retry_handler) - response = await client.with_raw_response.extract(url="url") + response = await client.extract.with_raw_response.run(url="url") assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -1885,9 +1885,11 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/v1/extract").mock(side_effect=retry_handler) + respx_mock.post("/v2/extract").mock(side_effect=retry_handler) - response = await client.with_raw_response.extract(url="url", extra_headers={"x-stainless-retry-count": Omit()}) + response = await client.extract.with_raw_response.run( + url="url", extra_headers={"x-stainless-retry-count": Omit()} + ) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -1908,9 +1910,11 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/v1/extract").mock(side_effect=retry_handler) + respx_mock.post("/v2/extract").mock(side_effect=retry_handler) - response = await client.with_raw_response.extract(url="url", extra_headers={"x-stainless-retry-count": "42"}) + response = await client.extract.with_raw_response.run( + url="url", extra_headers={"x-stainless-retry-count": "42"} + ) assert response.http_request.headers.get("x-stainless-retry-count") == "42"