Skip to content

Commit ec8ff2d

Browse files
feat(api): manual updates
1 parent 707a6c3 commit ec8ff2d

7 files changed

Lines changed: 283 additions & 2 deletions

File tree

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 20
1+
configured_endpoints: 21
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-fabb017ff3666dbd9571166423c32c9567f9c09448fd7189d147c06666bf0f39.yml
33
openapi_spec_hash: 2175516001dec1c8c45a1c8416c6fe53
4-
config_hash: 682b89b02a20f5d1c13e2c91ecbcf5ce
4+
config_hash: 859455bbffc8a009cd9b5eed9b3ba2d7

‎api.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Types:
44

55
```python
66
from context.dev.types import (
7+
WebExtractFontsResponse,
78
WebScreenshotResponse,
89
WebWebCrawlMdResponse,
910
WebWebScrapeHTMLResponse,
@@ -15,6 +16,7 @@ from context.dev.types import (
1516

1617
Methods:
1718

19+
- <code title="get /web/fonts">client.web.<a href="./src/context/dev/resources/web.py">extract_fonts</a>(\*\*<a href="src/context/dev/types/web_extract_fonts_params.py">params</a>) -> <a href="./src/context/dev/types/web_extract_fonts_response.py">WebExtractFontsResponse</a></code>
1820
- <code title="get /brand/screenshot">client.web.<a href="./src/context/dev/resources/web.py">screenshot</a>(\*\*<a href="src/context/dev/types/web_screenshot_params.py">params</a>) -> <a href="./src/context/dev/types/web_screenshot_response.py">WebScreenshotResponse</a></code>
1921
- <code title="post /web/crawl">client.web.<a href="./src/context/dev/resources/web.py">web_crawl_md</a>(\*\*<a href="src/context/dev/types/web_web_crawl_md_params.py">params</a>) -> <a href="./src/context/dev/types/web_web_crawl_md_response.py">WebWebCrawlMdResponse</a></code>
2022
- <code title="get /web/scrape/html">client.web.<a href="./src/context/dev/resources/web.py">web_scrape_html</a>(\*\*<a href="src/context/dev/types/web_web_scrape_html_params.py">params</a>) -> <a href="./src/context/dev/types/web_web_scrape_html_response.py">WebWebScrapeHTMLResponse</a></code>

‎src/context/dev/resources/web.py‎

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ..types import (
1010
web_screenshot_params,
1111
web_web_crawl_md_params,
12+
web_extract_fonts_params,
1213
web_web_scrape_md_params,
1314
web_web_scrape_html_params,
1415
web_web_scrape_images_params,
@@ -27,6 +28,7 @@
2728
from .._base_client import make_request_options
2829
from ..types.web_screenshot_response import WebScreenshotResponse
2930
from ..types.web_web_crawl_md_response import WebWebCrawlMdResponse
31+
from ..types.web_extract_fonts_response import WebExtractFontsResponse
3032
from ..types.web_web_scrape_md_response import WebWebScrapeMdResponse
3133
from ..types.web_web_scrape_html_response import WebWebScrapeHTMLResponse
3234
from ..types.web_web_scrape_images_response import WebWebScrapeImagesResponse
@@ -55,6 +57,62 @@ def with_streaming_response(self) -> WebResourceWithStreamingResponse:
5557
"""
5658
return WebResourceWithStreamingResponse(self)
5759

60+
def extract_fonts(
61+
self,
62+
*,
63+
direct_url: str | Omit = omit,
64+
domain: str | Omit = omit,
65+
timeout_ms: int | Omit = omit,
66+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
67+
# The extra values given here take precedence over values defined on the client or passed to this method.
68+
extra_headers: Headers | None = None,
69+
extra_query: Query | None = None,
70+
extra_body: Body | None = None,
71+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
72+
) -> WebExtractFontsResponse:
73+
"""
74+
Scrape font information from a website including font families, usage
75+
statistics, fallbacks, and element/word counts. Either 'domain' or 'directUrl'
76+
must be provided as a query parameter, but not both.
77+
78+
Args:
79+
direct_url: A specific URL to fetch fonts from directly, bypassing domain resolution (e.g.,
80+
'https://example.com/design-system').
81+
82+
domain: Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The
83+
domain will be automatically normalized and validated.
84+
85+
timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer
86+
than this value, it will be aborted with a 408 status code. Maximum allowed
87+
value is 300000ms (5 minutes).
88+
89+
extra_headers: Send extra headers
90+
91+
extra_query: Add additional query parameters to the request
92+
93+
extra_body: Add additional JSON properties to the request
94+
95+
timeout: Override the client-level default timeout for this request, in seconds
96+
"""
97+
return self._get(
98+
"/web/fonts",
99+
options=make_request_options(
100+
extra_headers=extra_headers,
101+
extra_query=extra_query,
102+
extra_body=extra_body,
103+
timeout=timeout,
104+
query=maybe_transform(
105+
{
106+
"direct_url": direct_url,
107+
"domain": domain,
108+
"timeout_ms": timeout_ms,
109+
},
110+
web_extract_fonts_params.WebExtractFontsParams,
111+
),
112+
),
113+
cast_to=WebExtractFontsResponse,
114+
)
115+
58116
def screenshot(
59117
self,
60118
*,
@@ -426,6 +484,62 @@ def with_streaming_response(self) -> AsyncWebResourceWithStreamingResponse:
426484
"""
427485
return AsyncWebResourceWithStreamingResponse(self)
428486

487+
async def extract_fonts(
488+
self,
489+
*,
490+
direct_url: str | Omit = omit,
491+
domain: str | Omit = omit,
492+
timeout_ms: int | Omit = omit,
493+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
494+
# The extra values given here take precedence over values defined on the client or passed to this method.
495+
extra_headers: Headers | None = None,
496+
extra_query: Query | None = None,
497+
extra_body: Body | None = None,
498+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
499+
) -> WebExtractFontsResponse:
500+
"""
501+
Scrape font information from a website including font families, usage
502+
statistics, fallbacks, and element/word counts. Either 'domain' or 'directUrl'
503+
must be provided as a query parameter, but not both.
504+
505+
Args:
506+
direct_url: A specific URL to fetch fonts from directly, bypassing domain resolution (e.g.,
507+
'https://example.com/design-system').
508+
509+
domain: Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The
510+
domain will be automatically normalized and validated.
511+
512+
timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer
513+
than this value, it will be aborted with a 408 status code. Maximum allowed
514+
value is 300000ms (5 minutes).
515+
516+
extra_headers: Send extra headers
517+
518+
extra_query: Add additional query parameters to the request
519+
520+
extra_body: Add additional JSON properties to the request
521+
522+
timeout: Override the client-level default timeout for this request, in seconds
523+
"""
524+
return await self._get(
525+
"/web/fonts",
526+
options=make_request_options(
527+
extra_headers=extra_headers,
528+
extra_query=extra_query,
529+
extra_body=extra_body,
530+
timeout=timeout,
531+
query=await async_maybe_transform(
532+
{
533+
"direct_url": direct_url,
534+
"domain": domain,
535+
"timeout_ms": timeout_ms,
536+
},
537+
web_extract_fonts_params.WebExtractFontsParams,
538+
),
539+
),
540+
cast_to=WebExtractFontsResponse,
541+
)
542+
429543
async def screenshot(
430544
self,
431545
*,
@@ -781,6 +895,9 @@ class WebResourceWithRawResponse:
781895
def __init__(self, web: WebResource) -> None:
782896
self._web = web
783897

898+
self.extract_fonts = to_raw_response_wrapper(
899+
web.extract_fonts,
900+
)
784901
self.screenshot = to_raw_response_wrapper(
785902
web.screenshot,
786903
)
@@ -805,6 +922,9 @@ class AsyncWebResourceWithRawResponse:
805922
def __init__(self, web: AsyncWebResource) -> None:
806923
self._web = web
807924

925+
self.extract_fonts = async_to_raw_response_wrapper(
926+
web.extract_fonts,
927+
)
808928
self.screenshot = async_to_raw_response_wrapper(
809929
web.screenshot,
810930
)
@@ -829,6 +949,9 @@ class WebResourceWithStreamingResponse:
829949
def __init__(self, web: WebResource) -> None:
830950
self._web = web
831951

952+
self.extract_fonts = to_streamed_response_wrapper(
953+
web.extract_fonts,
954+
)
832955
self.screenshot = to_streamed_response_wrapper(
833956
web.screenshot,
834957
)
@@ -853,6 +976,9 @@ class AsyncWebResourceWithStreamingResponse:
853976
def __init__(self, web: AsyncWebResource) -> None:
854977
self._web = web
855978

979+
self.extract_fonts = async_to_streamed_response_wrapper(
980+
web.extract_fonts,
981+
)
856982
self.screenshot = async_to_streamed_response_wrapper(
857983
web.screenshot,
858984
)

‎src/context/dev/types/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
from .utility_prefetch_params import UtilityPrefetchParams as UtilityPrefetchParams
1111
from .web_screenshot_response import WebScreenshotResponse as WebScreenshotResponse
1212
from .web_web_crawl_md_params import WebWebCrawlMdParams as WebWebCrawlMdParams
13+
from .web_extract_fonts_params import WebExtractFontsParams as WebExtractFontsParams
1314
from .web_web_scrape_md_params import WebWebScrapeMdParams as WebWebScrapeMdParams
1415
from .ai_extract_product_params import AIExtractProductParams as AIExtractProductParams
1516
from .utility_prefetch_response import UtilityPrefetchResponse as UtilityPrefetchResponse
1617
from .web_web_crawl_md_response import WebWebCrawlMdResponse as WebWebCrawlMdResponse
1718
from .ai_extract_products_params import AIExtractProductsParams as AIExtractProductsParams
19+
from .web_extract_fonts_response import WebExtractFontsResponse as WebExtractFontsResponse
1820
from .web_web_scrape_html_params import WebWebScrapeHTMLParams as WebWebScrapeHTMLParams
1921
from .web_web_scrape_md_response import WebWebScrapeMdResponse as WebWebScrapeMdResponse
2022
from .ai_extract_product_response import AIExtractProductResponse as AIExtractProductResponse
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Annotated, TypedDict
6+
7+
from .._utils import PropertyInfo
8+
9+
__all__ = ["WebExtractFontsParams"]
10+
11+
12+
class WebExtractFontsParams(TypedDict, total=False):
13+
direct_url: Annotated[str, PropertyInfo(alias="directUrl")]
14+
"""
15+
A specific URL to fetch fonts from directly, bypassing domain resolution (e.g.,
16+
'https://example.com/design-system').
17+
"""
18+
19+
domain: str
20+
"""Domain name to extract fonts from (e.g., 'example.com', 'google.com').
21+
22+
The domain will be automatically normalized and validated.
23+
"""
24+
25+
timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")]
26+
"""Optional timeout in milliseconds for the request.
27+
28+
If the request takes longer than this value, it will be aborted with a 408
29+
status code. Maximum allowed value is 300000ms (5 minutes).
30+
"""
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List
4+
5+
from .._models import BaseModel
6+
7+
__all__ = ["WebExtractFontsResponse", "Font"]
8+
9+
10+
class Font(BaseModel):
11+
fallbacks: List[str]
12+
"""Array of fallback font families"""
13+
14+
font: str
15+
"""Font family name"""
16+
17+
num_elements: float
18+
"""Number of elements using this font"""
19+
20+
num_words: float
21+
"""Number of words using this font"""
22+
23+
percent_elements: float
24+
"""Percentage of elements using this font"""
25+
26+
percent_words: float
27+
"""Percentage of words using this font"""
28+
29+
uses: List[str]
30+
"""Array of CSS selectors or element types where this font is used"""
31+
32+
33+
class WebExtractFontsResponse(BaseModel):
34+
code: int
35+
"""HTTP status code, e.g., 200"""
36+
37+
domain: str
38+
"""The normalized domain that was processed"""
39+
40+
fonts: List[Font]
41+
"""Array of font usage information"""
42+
43+
status: str
44+
"""Status of the response, e.g., 'ok'"""

‎tests/api_resources/test_web.py‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
WebScreenshotResponse,
1414
WebWebCrawlMdResponse,
1515
WebWebScrapeMdResponse,
16+
WebExtractFontsResponse,
1617
WebWebScrapeHTMLResponse,
1718
WebWebScrapeImagesResponse,
1819
WebWebScrapeSitemapResponse,
@@ -24,6 +25,44 @@
2425
class TestWeb:
2526
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
2627

28+
@pytest.mark.skip(reason="Mock server tests are disabled")
29+
@parametrize
30+
def test_method_extract_fonts(self, client: ContextDev) -> None:
31+
web = client.web.extract_fonts()
32+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
33+
34+
@pytest.mark.skip(reason="Mock server tests are disabled")
35+
@parametrize
36+
def test_method_extract_fonts_with_all_params(self, client: ContextDev) -> None:
37+
web = client.web.extract_fonts(
38+
direct_url="https://example.com",
39+
domain="domain",
40+
timeout_ms=1000,
41+
)
42+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
43+
44+
@pytest.mark.skip(reason="Mock server tests are disabled")
45+
@parametrize
46+
def test_raw_response_extract_fonts(self, client: ContextDev) -> None:
47+
response = client.web.with_raw_response.extract_fonts()
48+
49+
assert response.is_closed is True
50+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
51+
web = response.parse()
52+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
53+
54+
@pytest.mark.skip(reason="Mock server tests are disabled")
55+
@parametrize
56+
def test_streaming_response_extract_fonts(self, client: ContextDev) -> None:
57+
with client.web.with_streaming_response.extract_fonts() as response:
58+
assert not response.is_closed
59+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
60+
61+
web = response.parse()
62+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
63+
64+
assert cast(Any, response.is_closed) is True
65+
2766
@pytest.mark.skip(reason="Mock server tests are disabled")
2867
@parametrize
2968
def test_method_screenshot(self, client: ContextDev) -> None:
@@ -287,6 +326,44 @@ class TestAsyncWeb:
287326
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
288327
)
289328

329+
@pytest.mark.skip(reason="Mock server tests are disabled")
330+
@parametrize
331+
async def test_method_extract_fonts(self, async_client: AsyncContextDev) -> None:
332+
web = await async_client.web.extract_fonts()
333+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
334+
335+
@pytest.mark.skip(reason="Mock server tests are disabled")
336+
@parametrize
337+
async def test_method_extract_fonts_with_all_params(self, async_client: AsyncContextDev) -> None:
338+
web = await async_client.web.extract_fonts(
339+
direct_url="https://example.com",
340+
domain="domain",
341+
timeout_ms=1000,
342+
)
343+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
344+
345+
@pytest.mark.skip(reason="Mock server tests are disabled")
346+
@parametrize
347+
async def test_raw_response_extract_fonts(self, async_client: AsyncContextDev) -> None:
348+
response = await async_client.web.with_raw_response.extract_fonts()
349+
350+
assert response.is_closed is True
351+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
352+
web = await response.parse()
353+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
354+
355+
@pytest.mark.skip(reason="Mock server tests are disabled")
356+
@parametrize
357+
async def test_streaming_response_extract_fonts(self, async_client: AsyncContextDev) -> None:
358+
async with async_client.web.with_streaming_response.extract_fonts() as response:
359+
assert not response.is_closed
360+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
361+
362+
web = await response.parse()
363+
assert_matches_type(WebExtractFontsResponse, web, path=["response"])
364+
365+
assert cast(Any, response.is_closed) is True
366+
290367
@pytest.mark.skip(reason="Mock server tests are disabled")
291368
@parametrize
292369
async def test_method_screenshot(self, async_client: AsyncContextDev) -> None:

0 commit comments

Comments
 (0)