Skip to content

Commit b45f902

Browse files
author
stlc-bot
committed
fix(openapi): keep legacy batch inputs in the spec as deprecated (#2225)
feat(access-policies): limit which websites API requests can reach (#2213) Stainless-Generated-From: 195b4c6a401e049bad28b662b4953794f01e8513
1 parent a436c52 commit b45f902

12 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎pkg/cmd/batch.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ var batchSubmit = requestflag.WithInnerFlags(cli.Command{
147147
Required: true,
148148
BodyPath: "input",
149149
},
150+
&requestflag.Flag[[]string]{
151+
Name: "policy",
152+
Usage: "Access policy IDs to apply to every page. A URL must pass every policy.",
153+
BodyPath: "policies",
154+
},
150155
&requestflag.Flag[[]string]{
151156
Name: "tag",
152157
Usage: "Tags stored on the batch. Filter the batch list by them later.",

‎pkg/cmd/batch_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func TestBatchSubmit(t *testing.T) {
8585
"--api-key", "string",
8686
"batch", "submit",
8787
"--input", "{data: {formats: {bytes: true, highlights: true, html: true, images: true, json: true, markdown: true, parse: true, product: true, screenshot: true}, urls: [{url: https://example.com/products/anvil, itemId: sku-1, meta: {category: bar}}, {url: https://example.com/products/hammer, itemId: sku-2, meta: {foo: bar}}], highlightsParams: {query: x, maxCharacters: 100}, imageParams: {dedupe: none, enrich: [dimensions]}, jsonParams: {schema: {type: bar, properties: bar, required: bar, additionalProperties: bar}, instructions: instructions}, markdownParams: {includeImages: true, includeLinks: true, inlineImages: placeholder, sourcePreference: [html-conversion]}, maxAgeMs: 0, parseParams: {rules: {title: h1, links: {selector: a, output: '@href', type: list}}, type: custom}, productParams: {dedupeImages: true}, screenshotParams: {area: viewport, format: png}, sharedParams: {actions: [{action: Click the product details tab, type: perform}], country: US, dismissCookies: true, dismissPopups: true, excludeSelectors: [P], headers: {Accept-Language: en-US}, includeFrames: true, includeSelectors: [P], mainContentOnly: true, parsers: {pdf: {endPage: 1, includeNumberedPages: true, ocr: 'off', startPage: 1}}, profile: {profileId: prof_210b9798eb53baa4e69d31c1071cf03d, type: existing}, settleAnimations: true, theme: light, viewport: {height: 240, width: 240}, waitFor: 500}, tags: [production, team-alpha], timeoutOpts: {milliseconds: 1, behavior: fail}, zdr: disabled}, mode: scrape}",
88+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
8889
"--tag", "docs",
8990
"--tag", "competitor",
9091
"--webhook", "{url: https://example.com, retry: {delays_seconds: [10, 60, 300, 1800, 7200, 21600, 57600]}}",
@@ -103,6 +104,7 @@ func TestBatchSubmit(t *testing.T) {
103104
"--api-key", "string",
104105
"batch", "submit",
105106
"--input", "{data: {formats: {bytes: true, highlights: true, html: true, images: true, json: true, markdown: true, parse: true, product: true, screenshot: true}, urls: [{url: https://example.com/products/anvil, itemId: sku-1, meta: {category: bar}}, {url: https://example.com/products/hammer, itemId: sku-2, meta: {foo: bar}}], highlightsParams: {query: x, maxCharacters: 100}, imageParams: {dedupe: none, enrich: [dimensions]}, jsonParams: {schema: {type: bar, properties: bar, required: bar, additionalProperties: bar}, instructions: instructions}, markdownParams: {includeImages: true, includeLinks: true, inlineImages: placeholder, sourcePreference: [html-conversion]}, maxAgeMs: 0, parseParams: {rules: {title: h1, links: {selector: a, output: '@href', type: list}}, type: custom}, productParams: {dedupeImages: true}, screenshotParams: {area: viewport, format: png}, sharedParams: {actions: [{action: Click the product details tab, type: perform}], country: US, dismissCookies: true, dismissPopups: true, excludeSelectors: [P], headers: {Accept-Language: en-US}, includeFrames: true, includeSelectors: [P], mainContentOnly: true, parsers: {pdf: {endPage: 1, includeNumberedPages: true, ocr: 'off', startPage: 1}}, profile: {profileId: prof_210b9798eb53baa4e69d31c1071cf03d, type: existing}, settleAnimations: true, theme: light, viewport: {height: 240, width: 240}, waitFor: 500}, tags: [production, team-alpha], timeoutOpts: {milliseconds: 1, behavior: fail}, zdr: disabled}, mode: scrape}",
107+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
106108
"--tag", "docs",
107109
"--tag", "competitor",
108110
"--webhook.url", "https://example.com",
@@ -208,6 +210,8 @@ func TestBatchSubmit(t *testing.T) {
208210
" behavior: fail\n" +
209211
" zdr: disabled\n" +
210212
" mode: scrape\n" +
213+
"policies:\n" +
214+
" - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" +
211215
"tags:\n" +
212216
" - docs\n" +
213217
" - competitor\n" +

‎pkg/cmd/brand.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ var brandRetrieve = requestflag.WithInnerFlags(cli.Command{
4545
Usage: "Optional parameter to optimize the API call for maximum speed. When set to true, the API will skip time-consuming operations for faster response at the cost of less comprehensive data.",
4646
BodyPath: "maxSpeed",
4747
},
48+
&requestflag.Flag[[]string]{
49+
Name: "policy",
50+
Usage: "Access policy IDs to apply. A URL must pass every policy.",
51+
BodyPath: "policies",
52+
},
4853
&requestflag.Flag[[]string]{
4954
Name: "tag",
5055
Usage: "Labels for filtering usage in the dashboard.",

‎pkg/cmd/brand_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestBrandRetrieve(t *testing.T) {
2121
"--force-language", "afrikaans",
2222
"--max-age-ms", "0",
2323
"--max-speed=true",
24+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
2425
"--tag", "production",
2526
"--tag", "team-alpha",
2627
"--timeout-opts", "{milliseconds: 1000, behavior: fail}",
@@ -41,6 +42,7 @@ func TestBrandRetrieve(t *testing.T) {
4142
"--force-language", "afrikaans",
4243
"--max-age-ms", "0",
4344
"--max-speed=true",
45+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
4446
"--tag", "production",
4547
"--tag", "team-alpha",
4648
"--timeout-opts.milliseconds", "1000",
@@ -56,6 +58,8 @@ func TestBrandRetrieve(t *testing.T) {
5658
"force_language: afrikaans\n" +
5759
"maxAgeMs: 0\n" +
5860
"maxSpeed: true\n" +
61+
"policies:\n" +
62+
" - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" +
5963
"tags:\n" +
6064
" - production\n" +
6165
" - team-alpha\n" +

‎pkg/cmd/monitor.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ var monitorsCreate = requestflag.WithInnerFlags(cli.Command{
4141
Usage: "Always `web`. Optional.",
4242
BodyPath: "mode",
4343
},
44+
&requestflag.Flag[[]string]{
45+
Name: "policy",
46+
Usage: "Access policy IDs to apply to every run.",
47+
BodyPath: "policies",
48+
},
4449
&requestflag.Flag[map[string]any]{
4550
Name: "schedule",
4651
Usage: "Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.",
@@ -138,6 +143,11 @@ var monitorsUpdate = requestflag.WithInnerFlags(cli.Command{
138143
Usage: "Display name for the monitor.",
139144
BodyPath: "name",
140145
},
146+
&requestflag.Flag[[]string]{
147+
Name: "policy",
148+
Usage: "Access policy IDs to apply to every run. Send an empty list to remove them.",
149+
BodyPath: "policies",
150+
},
141151
&requestflag.Flag[map[string]any]{
142152
Name: "schedule",
143153
Usage: "Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.",

‎pkg/cmd/monitor_test.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func TestMonitorsCreate(t *testing.T) {
2020
"--target", `{type: page, url: https://acme.com/pricing, actions: [{do: wait, timeMs: 0}], exclude_selectors: [.carousel, '[id^="TA_"]'], include_selectors: ['#attraction-details'], instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}`,
2121
"--change-detection", "{type: exact}",
2222
"--mode", "web",
23+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
2324
"--schedule", "{frequency: 6, type: interval, unit: hours}",
2425
"--tag", "pricing",
2526
"--tag", "competitor",
@@ -40,6 +41,7 @@ func TestMonitorsCreate(t *testing.T) {
4041
"--target", `{type: page, url: https://acme.com/pricing, actions: [{do: wait, timeMs: 0}], exclude_selectors: [.carousel, '[id^="TA_"]'], include_selectors: ['#attraction-details'], instructions: 'Report pricing or plan availability changes. Ignore counters, timestamps, testimonials, and navigation.', normalize_whitespace: true}`,
4142
"--change-detection", "{type: exact}",
4243
"--mode", "web",
44+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
4345
"--schedule.frequency", "6",
4446
"--schedule.type", "interval",
4547
"--schedule.unit", "hours",
@@ -73,6 +75,8 @@ func TestMonitorsCreate(t *testing.T) {
7375
"change_detection:\n" +
7476
" type: exact\n" +
7577
"mode: web\n" +
78+
"policies:\n" +
79+
" - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" +
7680
"schedule:\n" +
7781
" frequency: 6\n" +
7882
" type: interval\n" +
@@ -124,6 +128,7 @@ func TestMonitorsUpdate(t *testing.T) {
124128
"--monitor-id", "mon_123",
125129
"--change-detection", "{type: exact}",
126130
"--name", "Acme pricing monitor",
131+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
127132
"--schedule", "{frequency: 1, type: interval, unit: hours}",
128133
"--status", "active",
129134
"--tag", "pricing",
@@ -145,6 +150,7 @@ func TestMonitorsUpdate(t *testing.T) {
145150
"--monitor-id", "mon_123",
146151
"--change-detection", "{type: exact}",
147152
"--name", "Acme pricing monitor",
153+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
148154
"--schedule.frequency", "1",
149155
"--schedule.type", "interval",
150156
"--schedule.unit", "hours",
@@ -164,6 +170,8 @@ func TestMonitorsUpdate(t *testing.T) {
164170
"change_detection:\n" +
165171
" type: exact\n" +
166172
"name: Acme pricing monitor\n" +
173+
"policies:\n" +
174+
" - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" +
167175
"schedule:\n" +
168176
" frequency: 1\n" +
169177
" type: interval\n" +

‎pkg/cmd/news.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ var newsSearch = requestflag.WithInnerFlags(cli.Command{
4141
Default: 10,
4242
BodyPath: "limit",
4343
},
44+
&requestflag.Flag[[]string]{
45+
Name: "policy",
46+
Usage: "Access policy IDs to apply. A URL must pass every policy.",
47+
BodyPath: "policies",
48+
},
4449
&requestflag.Flag[map[string]any]{
4550
Name: "sort-by",
4651
Usage: "Result ordering. Defaults to newest for entity searches. Natural-language searches are always ordered by relevance.",

‎pkg/cmd/news_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func TestNewsSearch(t *testing.T) {
2020
"--cursor", "cursor",
2121
"--filter-by", "{articleLanguage: [am], articleType: [editorial], date: {from: 0, to: 0}, sourceCountry: [ae], sourceDomain: [x]}",
2222
"--limit", "1",
23+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
2324
"--sort-by", "{type: relevance}",
2425
"--tag", "production",
2526
"--tag", "team-alpha",
@@ -43,6 +44,7 @@ func TestNewsSearch(t *testing.T) {
4344
"--filter-by.source-country", "[ae]",
4445
"--filter-by.source-domain", "[x]",
4546
"--limit", "1",
47+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
4648
"--sort-by.type", "relevance",
4749
"--tag", "production",
4850
"--tag", "team-alpha",
@@ -71,6 +73,8 @@ func TestNewsSearch(t *testing.T) {
7173
" sourceDomain:\n" +
7274
" - x\n" +
7375
"limit: 1\n" +
76+
"policies:\n" +
77+
" - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" +
7478
"sortBy:\n" +
7579
" type: relevance\n" +
7680
"tags:\n" +

‎pkg/cmd/utility.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ var utilityPrefetch = requestflag.WithInnerFlags(cli.Command{
3131
Required: true,
3232
BodyPath: "type",
3333
},
34+
&requestflag.Flag[[]string]{
35+
Name: "policy",
36+
Usage: "Access policy IDs to apply. A URL must pass every policy.",
37+
BodyPath: "policies",
38+
},
3439
&requestflag.Flag[[]string]{
3540
Name: "tag",
3641
Usage: "Labels for filtering usage in the dashboard.",

‎pkg/cmd/utility_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestUtilityPrefetch(t *testing.T) {
1818
"utility", "prefetch",
1919
"--identifier", "{domain: stripe.com}",
2020
"--type", "brand",
21+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
2122
"--tag", "production",
2223
"--tag", "team-alpha",
2324
"--timeout-opts", "{milliseconds: 1000, behavior: fail}",
@@ -35,6 +36,7 @@ func TestUtilityPrefetch(t *testing.T) {
3536
"utility", "prefetch",
3637
"--identifier", "{domain: stripe.com}",
3738
"--type", "brand",
39+
"--policy", "pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e",
3840
"--tag", "production",
3941
"--tag", "team-alpha",
4042
"--timeout-opts.milliseconds", "1000",
@@ -48,6 +50,8 @@ func TestUtilityPrefetch(t *testing.T) {
4850
"identifier:\n" +
4951
" domain: stripe.com\n" +
5052
"type: brand\n" +
53+
"policies:\n" +
54+
" - pol_3f9c2a7e5b8d4c1f9a6e0b2d7c4f8a1e\n" +
5155
"tags:\n" +
5256
" - production\n" +
5357
" - team-alpha\n" +

0 commit comments

Comments
 (0)