Skip to content

Commit d26f4e8

Browse files
feat(api): manual updates
1 parent bee9743 commit d26f4e8

7 files changed

Lines changed: 292 additions & 5 deletions

File tree

‎.stats.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 37
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-eac90d0a78d6166dc64c49ad4cd44883ab0bd357063ff09e60ed78085e2bde3c.yml
1+
configured_endpoints: 38
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-155e4761d62255841349c0f8a01b0a9c463ea1d1f2d6c4fd8d1a75c8bef6f226.yml
33
openapi_spec_hash: ab91f77e7c9d992400cbc7fc8a9e76c1
4-
config_hash: 2bea1743c84d63bd61f8501a6ea63065
4+
config_hash: bff282047fafdad771fb7ec685f56944

‎api.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@ Methods:
6262
Types:
6363

6464
```python
65-
from context.dev.types import BrandRetrieveResponse, BrandRetrieveSimplifiedResponse
65+
from context.dev.types import (
66+
BrandRetrieveResponse,
67+
BrandRetrieveSimplifiedResponse,
68+
BrandSearchResponse,
69+
)
6670
```
6771

6872
Methods:
6973

7074
- <code title="post /brand/retrieve">client.brand.<a href="./src/context/dev/resources/brand.py">retrieve</a>(\*\*<a href="src/context/dev/types/brand_retrieve_params.py">params</a>) -> <a href="./src/context/dev/types/brand_retrieve_response.py">BrandRetrieveResponse</a></code>
7175
- <code title="get /brand/retrieve-simplified">client.brand.<a href="./src/context/dev/resources/brand.py">retrieve_simplified</a>(\*\*<a href="src/context/dev/types/brand_retrieve_simplified_params.py">params</a>) -> <a href="./src/context/dev/types/brand_retrieve_simplified_response.py">BrandRetrieveSimplifiedResponse</a></code>
76+
- <code title="get /brand/search">client.brand.<a href="./src/context/dev/resources/brand.py">search</a>(\*\*<a href="src/context/dev/types/brand_search_params.py">params</a>) -> <a href="./src/context/dev/types/brand_search_response.py">BrandSearchResponse</a></code>
7277

7378
# Industry
7479

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

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..types import brand_retrieve_params, brand_retrieve_simplified_params
10+
from ..types import brand_search_params, brand_retrieve_params, brand_retrieve_simplified_params
1111
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
1212
from .._utils import required_args, maybe_transform, async_maybe_transform
1313
from .._compat import cached_property
@@ -19,6 +19,7 @@
1919
async_to_streamed_response_wrapper,
2020
)
2121
from .._base_client import make_request_options
22+
from ..types.brand_search_response import BrandSearchResponse
2223
from ..types.brand_retrieve_response import BrandRetrieveResponse
2324
from ..types.brand_retrieve_simplified_response import BrandRetrieveSimplifiedResponse
2425

@@ -1273,6 +1274,61 @@ def retrieve_simplified(
12731274
cast_to=BrandRetrieveSimplifiedResponse,
12741275
)
12751276

1277+
def search(
1278+
self,
1279+
*,
1280+
query: str,
1281+
tags: SequenceNotStr[str] | Omit = omit,
1282+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1283+
# The extra values given here take precedence over values defined on the client or passed to this method.
1284+
extra_headers: Headers | None = None,
1285+
extra_query: Query | None = None,
1286+
extra_body: Body | None = None,
1287+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1288+
) -> BrandSearchResponse:
1289+
"""
1290+
Search brands by name or domain and get back up to 10 lightweight matches
1291+
(domain, name, logo), most popular first: by Tranco rank, then market cap for
1292+
brands outside the Tranco list, with text relevance breaking ties. Matching is
1293+
prefix-based with no typo tolerance, so it is suited to autocomplete. Only
1294+
brands already in the Context.dev index are returned — use /brand/retrieve to
1295+
fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
1296+
per request on the Free and Starter plans.
1297+
1298+
Args:
1299+
query: Search term, matched against brand names and domains by prefix (e.g. 'nike',
1300+
'nike.com', 'nik').
1301+
1302+
tags: Optional comma-separated caller-defined tags for tracking this request. Tags are
1303+
recorded on the request's usage log and can be used to filter usage on the
1304+
dashboard usage page. Up to 20 tags, each 1-50 characters.
1305+
1306+
extra_headers: Send extra headers
1307+
1308+
extra_query: Add additional query parameters to the request
1309+
1310+
extra_body: Add additional JSON properties to the request
1311+
1312+
timeout: Override the client-level default timeout for this request, in seconds
1313+
"""
1314+
return self._get(
1315+
"/brand/search",
1316+
options=make_request_options(
1317+
extra_headers=extra_headers,
1318+
extra_query=extra_query,
1319+
extra_body=extra_body,
1320+
timeout=timeout,
1321+
query=maybe_transform(
1322+
{
1323+
"query": query,
1324+
"tags": tags,
1325+
},
1326+
brand_search_params.BrandSearchParams,
1327+
),
1328+
),
1329+
cast_to=BrandSearchResponse,
1330+
)
1331+
12761332

12771333
class AsyncBrandResource(AsyncAPIResource):
12781334
@cached_property
@@ -2522,6 +2578,61 @@ async def retrieve_simplified(
25222578
cast_to=BrandRetrieveSimplifiedResponse,
25232579
)
25242580

2581+
async def search(
2582+
self,
2583+
*,
2584+
query: str,
2585+
tags: SequenceNotStr[str] | Omit = omit,
2586+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2587+
# The extra values given here take precedence over values defined on the client or passed to this method.
2588+
extra_headers: Headers | None = None,
2589+
extra_query: Query | None = None,
2590+
extra_body: Body | None = None,
2591+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
2592+
) -> BrandSearchResponse:
2593+
"""
2594+
Search brands by name or domain and get back up to 10 lightweight matches
2595+
(domain, name, logo), most popular first: by Tranco rank, then market cap for
2596+
brands outside the Tranco list, with text relevance breaking ties. Matching is
2597+
prefix-based with no typo tolerance, so it is suited to autocomplete. Only
2598+
brands already in the Context.dev index are returned — use /brand/retrieve to
2599+
fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
2600+
per request on the Free and Starter plans.
2601+
2602+
Args:
2603+
query: Search term, matched against brand names and domains by prefix (e.g. 'nike',
2604+
'nike.com', 'nik').
2605+
2606+
tags: Optional comma-separated caller-defined tags for tracking this request. Tags are
2607+
recorded on the request's usage log and can be used to filter usage on the
2608+
dashboard usage page. Up to 20 tags, each 1-50 characters.
2609+
2610+
extra_headers: Send extra headers
2611+
2612+
extra_query: Add additional query parameters to the request
2613+
2614+
extra_body: Add additional JSON properties to the request
2615+
2616+
timeout: Override the client-level default timeout for this request, in seconds
2617+
"""
2618+
return await self._get(
2619+
"/brand/search",
2620+
options=make_request_options(
2621+
extra_headers=extra_headers,
2622+
extra_query=extra_query,
2623+
extra_body=extra_body,
2624+
timeout=timeout,
2625+
query=await async_maybe_transform(
2626+
{
2627+
"query": query,
2628+
"tags": tags,
2629+
},
2630+
brand_search_params.BrandSearchParams,
2631+
),
2632+
),
2633+
cast_to=BrandSearchResponse,
2634+
)
2635+
25252636

25262637
class BrandResourceWithRawResponse:
25272638
def __init__(self, brand: BrandResource) -> None:
@@ -2533,6 +2644,9 @@ def __init__(self, brand: BrandResource) -> None:
25332644
self.retrieve_simplified = to_raw_response_wrapper(
25342645
brand.retrieve_simplified,
25352646
)
2647+
self.search = to_raw_response_wrapper(
2648+
brand.search,
2649+
)
25362650

25372651

25382652
class AsyncBrandResourceWithRawResponse:
@@ -2545,6 +2659,9 @@ def __init__(self, brand: AsyncBrandResource) -> None:
25452659
self.retrieve_simplified = async_to_raw_response_wrapper(
25462660
brand.retrieve_simplified,
25472661
)
2662+
self.search = async_to_raw_response_wrapper(
2663+
brand.search,
2664+
)
25482665

25492666

25502667
class BrandResourceWithStreamingResponse:
@@ -2557,6 +2674,9 @@ def __init__(self, brand: BrandResource) -> None:
25572674
self.retrieve_simplified = to_streamed_response_wrapper(
25582675
brand.retrieve_simplified,
25592676
)
2677+
self.search = to_streamed_response_wrapper(
2678+
brand.search,
2679+
)
25602680

25612681

25622682
class AsyncBrandResourceWithStreamingResponse:
@@ -2569,3 +2689,6 @@ def __init__(self, brand: AsyncBrandResource) -> None:
25692689
self.retrieve_simplified = async_to_streamed_response_wrapper(
25702690
brand.retrieve_simplified,
25712691
)
2692+
self.search = async_to_streamed_response_wrapper(
2693+
brand.search,
2694+
)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .web_extract_params import WebExtractParams as WebExtractParams
1313
from .batch_list_response import BatchListResponse as BatchListResponse
1414
from .batch_submit_params import BatchSubmitParams as BatchSubmitParams
15+
from .brand_search_params import BrandSearchParams as BrandSearchParams
1516
from .monitor_list_params import MonitorListParams as MonitorListParams
1617
from .parse_handle_params import ParseHandleParams as ParseHandleParams
1718
from .web_search_response import WebSearchResponse as WebSearchResponse
@@ -20,6 +21,7 @@
2021
from .batch_cancel_response import BatchCancelResponse as BatchCancelResponse
2122
from .batch_submit_response import BatchSubmitResponse as BatchSubmitResponse
2223
from .brand_retrieve_params import BrandRetrieveParams as BrandRetrieveParams
24+
from .brand_search_response import BrandSearchResponse as BrandSearchResponse
2325
from .monitor_create_params import MonitorCreateParams as MonitorCreateParams
2426
from .monitor_list_response import MonitorListResponse as MonitorListResponse
2527
from .monitor_update_params import MonitorUpdateParams as MonitorUpdateParams
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 Required, TypedDict
6+
7+
from .._types import SequenceNotStr
8+
9+
__all__ = ["BrandSearchParams"]
10+
11+
12+
class BrandSearchParams(TypedDict, total=False):
13+
query: Required[str]
14+
"""Search term, matched against brand names and domains by prefix (e.g.
15+
16+
'nike', 'nike.com', 'nik').
17+
"""
18+
19+
tags: SequenceNotStr[str]
20+
"""Optional comma-separated caller-defined tags for tracking this request.
21+
22+
Tags are recorded on the request's usage log and can be used to filter usage on
23+
the dashboard usage page. Up to 20 tags, each 1-50 characters.
24+
"""
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
5+
from .._models import BaseModel
6+
7+
__all__ = ["BrandSearchResponse", "Result", "KeyMetadata"]
8+
9+
10+
class Result(BaseModel):
11+
domain: str
12+
"""The brand's domain."""
13+
14+
logo: str
15+
"""
16+
Logo link URL that serves the brand's logo, generated per request for the
17+
calling organization.
18+
"""
19+
20+
name: str
21+
"""The brand's name. Empty string when unknown."""
22+
23+
24+
class KeyMetadata(BaseModel):
25+
"""Metadata about the API key used for the request.
26+
27+
Included in every response whenever a valid API key is provided, even when the response status is not 200.
28+
"""
29+
30+
credits_consumed: int
31+
"""The number of credits consumed by this request."""
32+
33+
credits_remaining: int
34+
"""The number of credits remaining for your organization after this request."""
35+
36+
37+
class BrandSearchResponse(BaseModel):
38+
results: List[Result]
39+
"""Up to 10 matching brands, most popular first. Empty when nothing matches."""
40+
41+
key_metadata: Optional[KeyMetadata] = None
42+
"""Metadata about the API key used for the request.
43+
44+
Included in every response whenever a valid API key is provided, even when the
45+
response status is not 200.
46+
"""

‎tests/api_resources/test_brand.py‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from context.dev import ContextDev, AsyncContextDev
1111
from tests.utils import assert_matches_type
1212
from context.dev.types import (
13+
BrandSearchResponse,
1314
BrandRetrieveResponse,
1415
BrandRetrieveSimplifiedResponse,
1516
)
@@ -375,6 +376,49 @@ def test_streaming_response_retrieve_simplified(self, client: ContextDev) -> Non
375376

376377
assert cast(Any, response.is_closed) is True
377378

379+
@pytest.mark.skip(reason="Mock server tests are disabled")
380+
@parametrize
381+
def test_method_search(self, client: ContextDev) -> None:
382+
brand = client.brand.search(
383+
query="x",
384+
)
385+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
386+
387+
@pytest.mark.skip(reason="Mock server tests are disabled")
388+
@parametrize
389+
def test_method_search_with_all_params(self, client: ContextDev) -> None:
390+
brand = client.brand.search(
391+
query="x",
392+
tags=["production", "team-alpha"],
393+
)
394+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
395+
396+
@pytest.mark.skip(reason="Mock server tests are disabled")
397+
@parametrize
398+
def test_raw_response_search(self, client: ContextDev) -> None:
399+
response = client.brand.with_raw_response.search(
400+
query="x",
401+
)
402+
403+
assert response.is_closed is True
404+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
405+
brand = response.parse()
406+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
407+
408+
@pytest.mark.skip(reason="Mock server tests are disabled")
409+
@parametrize
410+
def test_streaming_response_search(self, client: ContextDev) -> None:
411+
with client.brand.with_streaming_response.search(
412+
query="x",
413+
) as response:
414+
assert not response.is_closed
415+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
416+
417+
brand = response.parse()
418+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
419+
420+
assert cast(Any, response.is_closed) is True
421+
378422

379423
class TestAsyncBrand:
380424
parametrize = pytest.mark.parametrize(
@@ -735,3 +779,46 @@ async def test_streaming_response_retrieve_simplified(self, async_client: AsyncC
735779
assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"])
736780

737781
assert cast(Any, response.is_closed) is True
782+
783+
@pytest.mark.skip(reason="Mock server tests are disabled")
784+
@parametrize
785+
async def test_method_search(self, async_client: AsyncContextDev) -> None:
786+
brand = await async_client.brand.search(
787+
query="x",
788+
)
789+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
790+
791+
@pytest.mark.skip(reason="Mock server tests are disabled")
792+
@parametrize
793+
async def test_method_search_with_all_params(self, async_client: AsyncContextDev) -> None:
794+
brand = await async_client.brand.search(
795+
query="x",
796+
tags=["production", "team-alpha"],
797+
)
798+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
799+
800+
@pytest.mark.skip(reason="Mock server tests are disabled")
801+
@parametrize
802+
async def test_raw_response_search(self, async_client: AsyncContextDev) -> None:
803+
response = await async_client.brand.with_raw_response.search(
804+
query="x",
805+
)
806+
807+
assert response.is_closed is True
808+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
809+
brand = await response.parse()
810+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
811+
812+
@pytest.mark.skip(reason="Mock server tests are disabled")
813+
@parametrize
814+
async def test_streaming_response_search(self, async_client: AsyncContextDev) -> None:
815+
async with async_client.brand.with_streaming_response.search(
816+
query="x",
817+
) as response:
818+
assert not response.is_closed
819+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
820+
821+
brand = await response.parse()
822+
assert_matches_type(BrandSearchResponse, brand, path=["response"])
823+
824+
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)