Skip to content

Commit 7d3e630

Browse files
feat(api): api update
1 parent 8a39a9f commit 7d3e630

17 files changed

Lines changed: 367 additions & 14 deletions

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 41
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-8be9b7cfe70702af909241420da1c61ba6b248345c5faec3b472df540bc6a553.yml
3-
openapi_spec_hash: f98fb82a9ad562fc04d32f7063182de8
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-dc61df29e1b6282f9df685fadd65f3683afe352deccae94d0c080092e0eae4b3.yml
3+
openapi_spec_hash: 258caa98cd0de5f7149f6937d071c912
44
config_hash: 0fb0ceca5946298c416cec0cca5260c7

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ brand = client.brand.retrieve(
4545
domain="REPLACE_ME",
4646
type="by_domain",
4747
)
48-
print(brand.brand)
48+
print(brand.cache_metadata)
4949
```
5050

5151
While you can provide an `api_key` keyword argument,
@@ -72,7 +72,7 @@ async def main() -> None:
7272
domain="REPLACE_ME",
7373
type="by_domain",
7474
)
75-
print(brand.brand)
75+
print(brand.cache_metadata)
7676

7777

7878
asyncio.run(main())
@@ -109,7 +109,7 @@ async def main() -> None:
109109
domain="REPLACE_ME",
110110
type="by_domain",
111111
)
112-
print(brand.brand)
112+
print(brand.cache_metadata)
113113

114114

115115
asyncio.run(main())
@@ -279,7 +279,7 @@ response = client.brand.with_raw_response.retrieve(
279279
print(response.headers.get('X-My-Header'))
280280

281281
brand = response.parse() # get the object that `brand.retrieve()` would have returned
282-
print(brand.brand)
282+
print(brand.cache_metadata)
283283
```
284284

285285
These methods return an [`APIResponse`](https://github.com/context-dot-dev/context-python-sdk/tree/main/src/context/dev/_response.py) object.

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55

66
from .._models import BaseModel
77

8-
__all__ = ["AIExtractProductResponse", "KeyMetadata", "Product"]
8+
__all__ = ["AIExtractProductResponse", "CacheMetadata", "KeyMetadata", "Product"]
9+
10+
11+
class CacheMetadata(BaseModel):
12+
"""Cache outcome for this response.
13+
14+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
15+
"""
16+
17+
age_ms: int
18+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
19+
20+
status: Literal["hit", "miss", "zdr"]
21+
"""
22+
Whether the response was served from cache, required fresh work, or honored
23+
zero-data-retention cache bypass.
24+
"""
925

1026

1127
class KeyMetadata(BaseModel):
@@ -83,6 +99,13 @@ class Product(BaseModel):
8399

84100

85101
class AIExtractProductResponse(BaseModel):
102+
cache_metadata: CacheMetadata
103+
"""Cache outcome for this response.
104+
105+
Composite responses are hits only when every cache-controlled fetch contributing
106+
to the output was a hit; age_ms is the oldest contributing hit.
107+
"""
108+
86109
is_product_page: Optional[bool] = None
87110
"""Whether the given URL is a product detail page"""
88111

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55

66
from .._models import BaseModel
77

8-
__all__ = ["AIExtractProductsResponse", "KeyMetadata", "Product"]
8+
__all__ = ["AIExtractProductsResponse", "CacheMetadata", "KeyMetadata", "Product"]
9+
10+
11+
class CacheMetadata(BaseModel):
12+
"""Cache outcome for this response.
13+
14+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
15+
"""
16+
17+
age_ms: int
18+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
19+
20+
status: Literal["hit", "miss", "zdr"]
21+
"""
22+
Whether the response was served from cache, required fresh work, or honored
23+
zero-data-retention cache bypass.
24+
"""
925

1026

1127
class KeyMetadata(BaseModel):
@@ -81,6 +97,13 @@ class Product(BaseModel):
8197

8298

8399
class AIExtractProductsResponse(BaseModel):
100+
cache_metadata: CacheMetadata
101+
"""Cache outcome for this response.
102+
103+
Composite responses are hits only when every cache-controlled fetch contributing
104+
to the output was a hit; age_ms is the oldest contributing hit.
105+
"""
106+
84107
key_metadata: Optional[KeyMetadata] = None
85108
"""Metadata about the API key used for the request.
86109

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"BatchGetResultsResponse",
1313
"Data",
1414
"DataOk",
15+
"DataOkCacheMetadata",
1516
"DataOkMetadata",
1617
"DataOkMetadataAlternate",
1718
"DataOkMetadataHeading",
@@ -20,6 +21,22 @@
2021
]
2122

2223

24+
class DataOkCacheMetadata(BaseModel):
25+
"""Cache outcome for this response.
26+
27+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
28+
"""
29+
30+
age_ms: int
31+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
32+
33+
status: Literal["hit", "miss", "zdr"]
34+
"""
35+
Whether the response was served from cache, required fresh work, or honored
36+
zero-data-retention cache bypass.
37+
"""
38+
39+
2340
class DataOkMetadataAlternate(BaseModel):
2441
href: str
2542
"""Resolved alternate URL."""
@@ -115,6 +132,13 @@ class DataOkMetadata(BaseModel):
115132
class DataOk(BaseModel):
116133
"""A page the batch fetched successfully."""
117134

135+
cache_metadata: DataOkCacheMetadata
136+
"""Cache outcome for this response.
137+
138+
Composite responses are hits only when every cache-controlled fetch contributing
139+
to the output was a hit; age_ms is the oldest contributing hit.
140+
"""
141+
118142
final_url: str
119143
"""URL the content was read from, after redirects."""
120144

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@
77
from .._models import BaseModel
88
from .crawl_controls import CrawlControls
99

10-
__all__ = ["BatchSubmitResponse", "Credits", "InvalidURL", "KeyMetadata"]
10+
__all__ = ["BatchSubmitResponse", "CacheMetadata", "Credits", "InvalidURL", "KeyMetadata"]
11+
12+
13+
class CacheMetadata(BaseModel):
14+
"""Cache outcome for this response.
15+
16+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
17+
"""
18+
19+
age_ms: int
20+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
21+
22+
status: Literal["hit", "miss", "zdr"]
23+
"""
24+
Whether the response was served from cache, required fresh work, or honored
25+
zero-data-retention cache bypass.
26+
"""
1127

1228

1329
class Credits(BaseModel):
@@ -42,6 +58,13 @@ class BatchSubmitResponse(BaseModel):
4258
id: str
4359
"""Batch ID. Poll GET /batch/{batch_id} with it."""
4460

61+
cache_metadata: CacheMetadata
62+
"""Cache outcome for this response.
63+
64+
Composite responses are hits only when every cache-controlled fetch contributing
65+
to the output was a hit; age_ms is the oldest contributing hit.
66+
"""
67+
4568
crawl: Optional[CrawlControls] = None
4669
"""
4770
The crawl controls as submitted, so the limits requested can be compared against

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
__all__ = [
99
"BrandRetrieveResponse",
10+
"CacheMetadata",
1011
"Brand",
1112
"BrandAddress",
1213
"BrandBackdrop",
@@ -26,6 +27,22 @@
2627
]
2728

2829

30+
class CacheMetadata(BaseModel):
31+
"""Cache outcome for this response.
32+
33+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
34+
"""
35+
36+
age_ms: int
37+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
38+
39+
status: Literal["hit", "miss", "zdr"]
40+
"""
41+
Whether the response was served from cache, required fresh work, or honored
42+
zero-data-retention cache bypass.
43+
"""
44+
45+
2946
class BrandAddress(BaseModel):
3047
"""Physical address of the brand"""
3148

@@ -690,6 +707,13 @@ class KeyMetadata(BaseModel):
690707

691708

692709
class BrandRetrieveResponse(BaseModel):
710+
cache_metadata: CacheMetadata
711+
"""Cache outcome for this response.
712+
713+
Composite responses are hits only when every cache-controlled fetch contributing
714+
to the output was a hit; age_ms is the oldest contributing hit.
715+
"""
716+
693717
brand: Optional[Brand] = None
694718
"""Detailed brand information"""
695719

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
__all__ = [
99
"BrandRetrieveSimplifiedResponse",
10+
"CacheMetadata",
1011
"Brand",
1112
"BrandBackdrop",
1213
"BrandBackdropColor",
@@ -19,6 +20,22 @@
1920
]
2021

2122

23+
class CacheMetadata(BaseModel):
24+
"""Cache outcome for this response.
25+
26+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
27+
"""
28+
29+
age_ms: int
30+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
31+
32+
status: Literal["hit", "miss", "zdr"]
33+
"""
34+
Whether the response was served from cache, required fresh work, or honored
35+
zero-data-retention cache bypass.
36+
"""
37+
38+
2239
class BrandBackdropColor(BaseModel):
2340
hex: Optional[str] = None
2441
"""Color in hexadecimal format"""
@@ -141,6 +158,13 @@ class KeyMetadata(BaseModel):
141158

142159

143160
class BrandRetrieveSimplifiedResponse(BaseModel):
161+
cache_metadata: CacheMetadata
162+
"""Cache outcome for this response.
163+
164+
Composite responses are hits only when every cache-controlled fetch contributing
165+
to the output was a hit; age_ms is the oldest contributing hit.
166+
"""
167+
144168
brand: Optional[Brand] = None
145169
"""Simplified brand information"""
146170

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

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

88
from .._models import BaseModel
99

10-
__all__ = ["WebExtractFontsResponse", "Font", "FontLinks", "KeyMetadata"]
10+
__all__ = ["WebExtractFontsResponse", "CacheMetadata", "Font", "FontLinks", "KeyMetadata"]
11+
12+
13+
class CacheMetadata(BaseModel):
14+
"""Cache outcome for this response.
15+
16+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
17+
"""
18+
19+
age_ms: int
20+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
21+
22+
status: Literal["hit", "miss", "zdr"]
23+
"""
24+
Whether the response was served from cache, required fresh work, or honored
25+
zero-data-retention cache bypass.
26+
"""
1127

1228

1329
class Font(BaseModel):
@@ -71,6 +87,13 @@ class KeyMetadata(BaseModel):
7187

7288

7389
class WebExtractFontsResponse(BaseModel):
90+
cache_metadata: CacheMetadata
91+
"""Cache outcome for this response.
92+
93+
Composite responses are hits only when every cache-controlled fetch contributing
94+
to the output was a hit; age_ms is the oldest contributing hit.
95+
"""
96+
7497
code: int
7598
"""HTTP status code, e.g., 200"""
7699

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

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

88
from .._models import BaseModel
99

10-
__all__ = ["WebExtractResponse", "Metadata", "MetadataActionsApplied", "KeyMetadata"]
10+
__all__ = ["WebExtractResponse", "CacheMetadata", "Metadata", "MetadataActionsApplied", "KeyMetadata"]
11+
12+
13+
class CacheMetadata(BaseModel):
14+
"""Cache outcome for this response.
15+
16+
Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
17+
"""
18+
19+
age_ms: int
20+
"""Age of the cached data in milliseconds. Zero for miss and zdr responses."""
21+
22+
status: Literal["hit", "miss", "zdr"]
23+
"""
24+
Whether the response was served from cache, required fresh work, or honored
25+
zero-data-retention cache bypass.
26+
"""
1127

1228

1329
class MetadataActionsApplied(BaseModel):
@@ -66,6 +82,13 @@ class KeyMetadata(BaseModel):
6682

6783

6884
class WebExtractResponse(BaseModel):
85+
cache_metadata: CacheMetadata
86+
"""Cache outcome for this response.
87+
88+
Composite responses are hits only when every cache-controlled fetch contributing
89+
to the output was a hit; age_ms is the oldest contributing hit.
90+
"""
91+
6992
data: Dict[str, object]
7093
"""Extracted data matching the request schema"""
7194

0 commit comments

Comments
 (0)