Skip to content

Commit cd708ca

Browse files
author
stlc-bot
committed
feat(api): enable ZDR on remaining AI endpoints via OpenAI (#1099)
Stainless-Generated-From: 03f378782a8fc17b633ef91c00aa314c9184e016
1 parent 7312544 commit cd708ca

9 files changed

Lines changed: 95 additions & 12 deletions

File tree

‎pkg/cmd/ai.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ var aiExtractProduct = requestflag.WithInnerFlags(cli.Command{
4141
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
4242
BodyPath: "timeoutOpts",
4343
},
44+
&requestflag.Flag[string]{
45+
Name: "zdr",
46+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
47+
Default: "disabled",
48+
BodyPath: "zdr",
49+
},
4450
},
4551
Action: handleAIExtractProduct,
4652
HideHelpCommand: true,

‎pkg/cmd/ai_test.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestAIExtractProduct(t *testing.T) {
2121
"--tag", "production",
2222
"--tag", "team-alpha",
2323
"--timeout-opts", "{milliseconds: 1000, behavior: fail}",
24+
"--zdr", "enabled",
2425
)
2526
})
2627

@@ -39,6 +40,7 @@ func TestAIExtractProduct(t *testing.T) {
3940
"--tag", "team-alpha",
4041
"--timeout-opts.milliseconds", "1000",
4142
"--timeout-opts.behavior", "fail",
43+
"--zdr", "enabled",
4244
)
4345
})
4446

@@ -52,7 +54,8 @@ func TestAIExtractProduct(t *testing.T) {
5254
" - team-alpha\n" +
5355
"timeoutOpts:\n" +
5456
" milliseconds: 1000\n" +
55-
" behavior: fail\n")
57+
" behavior: fail\n" +
58+
"zdr: enabled\n")
5659
mocktest.TestRunMockTestWithPipeAndFlags(
5760
t, pipeData,
5861
"--api-key", "string",

‎pkg/cmd/industry.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ var industryRetrieveNaics = requestflag.WithInnerFlags(cli.Command{
4747
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
4848
QueryPath: "timeoutOpts",
4949
},
50+
&requestflag.Flag[string]{
51+
Name: "zdr",
52+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
53+
Default: "disabled",
54+
QueryPath: "zdr",
55+
},
5056
},
5157
Action: handleIndustryRetrieveNaics,
5258
HideHelpCommand: true,
@@ -104,6 +110,12 @@ var industryRetrieveSic = requestflag.WithInnerFlags(cli.Command{
104110
Default: "original_sic",
105111
QueryPath: "type",
106112
},
113+
&requestflag.Flag[string]{
114+
Name: "zdr",
115+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
116+
Default: "disabled",
117+
QueryPath: "zdr",
118+
},
107119
},
108120
Action: handleIndustryRetrieveSic,
109121
HideHelpCommand: true,

‎pkg/cmd/industry_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestIndustryRetrieveNaics(t *testing.T) {
2222
"--tag", "production",
2323
"--tag", "team-alpha",
2424
"--timeout-opts", "{milliseconds: 1000, behavior: fail}",
25+
"--zdr", "enabled",
2526
)
2627
})
2728

@@ -41,6 +42,7 @@ func TestIndustryRetrieveNaics(t *testing.T) {
4142
"--tag", "team-alpha",
4243
"--timeout-opts.milliseconds", "1000",
4344
"--timeout-opts.behavior", "fail",
45+
"--zdr", "enabled",
4446
)
4547
})
4648
}
@@ -59,6 +61,7 @@ func TestIndustryRetrieveSic(t *testing.T) {
5961
"--tag", "team-alpha",
6062
"--timeout-opts", "{milliseconds: 1000, behavior: fail}",
6163
"--type", "original_sic",
64+
"--zdr", "enabled",
6265
)
6366
})
6467

@@ -79,6 +82,7 @@ func TestIndustryRetrieveSic(t *testing.T) {
7982
"--timeout-opts.milliseconds", "1000",
8083
"--timeout-opts.behavior", "fail",
8184
"--type", "original_sic",
85+
"--zdr", "enabled",
8286
)
8387
})
8488
}

‎pkg/cmd/parse.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var parseHandle = requestflag.WithInnerFlags(cli.Command{
7979
},
8080
&requestflag.Flag[string]{
8181
Name: "zdr",
82-
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
82+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
8383
Default: "disabled",
8484
QueryPath: "zdr",
8585
},

‎pkg/cmd/person.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ var peopleEnrich = requestflag.WithInnerFlags(cli.Command{
5353
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
5454
BodyPath: "timeoutOpts",
5555
},
56+
&requestflag.Flag[string]{
57+
Name: "zdr",
58+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
59+
BodyPath: "zdr",
60+
},
5661
},
5762
Action: handlePeopleEnrich,
5863
HideHelpCommand: true,

‎pkg/cmd/person_test.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestPeopleEnrich(t *testing.T) {
2525
"--tag", "production",
2626
"--tag", "team-alpha",
2727
"--timeout-opts", "{milliseconds: 1000, behavior: fail}",
28+
"--zdr", "enabled",
2829
)
2930
})
3031

@@ -54,6 +55,7 @@ func TestPeopleEnrich(t *testing.T) {
5455
"--tag", "team-alpha",
5556
"--timeout-opts.milliseconds", "1000",
5657
"--timeout-opts.behavior", "fail",
58+
"--zdr", "enabled",
5759
)
5860
})
5961

@@ -85,7 +87,8 @@ func TestPeopleEnrich(t *testing.T) {
8587
" - team-alpha\n" +
8688
"timeoutOpts:\n" +
8789
" milliseconds: 1000\n" +
88-
" behavior: fail\n")
90+
" behavior: fail\n" +
91+
"zdr: enabled\n")
8992
mocktest.TestRunMockTestWithPipeAndFlags(
9093
t, pipeData,
9194
"--api-key", "string",

‎pkg/cmd/web.go‎

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ var webAnswers = requestflag.WithInnerFlags(cli.Command{
4545
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
4646
BodyPath: "timeoutOpts",
4747
},
48+
&requestflag.Flag[string]{
49+
Name: "zdr",
50+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
51+
BodyPath: "zdr",
52+
},
4853
},
4954
Action: handleWebAnswers,
5055
HideHelpCommand: true,
@@ -157,6 +162,12 @@ var webExtract = requestflag.WithInnerFlags(cli.Command{
157162
Usage: "Optional browser wait time in milliseconds after initial page load for each crawled page.",
158163
BodyPath: "waitForMs",
159164
},
165+
&requestflag.Flag[string]{
166+
Name: "zdr",
167+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
168+
Default: "disabled",
169+
BodyPath: "zdr",
170+
},
160171
},
161172
Action: handleWebExtract,
162173
HideHelpCommand: true,
@@ -219,6 +230,12 @@ var webExtractCompetitors = requestflag.WithInnerFlags(cli.Command{
219230
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
220231
QueryPath: "timeoutOpts",
221232
},
233+
&requestflag.Flag[string]{
234+
Name: "zdr",
235+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
236+
Default: "disabled",
237+
QueryPath: "zdr",
238+
},
222239
},
223240
Action: handleWebExtractCompetitors,
224241
HideHelpCommand: true,
@@ -322,6 +339,12 @@ var webExtractStyleguide = requestflag.WithInnerFlags(cli.Command{
322339
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
323340
QueryPath: "timeoutOpts",
324341
},
342+
&requestflag.Flag[string]{
343+
Name: "zdr",
344+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
345+
Default: "disabled",
346+
QueryPath: "zdr",
347+
},
325348
},
326349
Action: handleWebExtractStyleguide,
327350
HideHelpCommand: true,
@@ -422,7 +445,7 @@ var webScreenshot = requestflag.WithInnerFlags(cli.Command{
422445
},
423446
&requestflag.Flag[string]{
424447
Name: "zdr",
425-
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
448+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
426449
Default: "disabled",
427450
QueryPath: "zdr",
428451
},
@@ -513,6 +536,12 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{
513536
Usage: "Optional request deadline and behavior on timeout. For GET requests, use timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded timeoutOpts object.",
514537
BodyPath: "timeoutOpts",
515538
},
539+
&requestflag.Flag[string]{
540+
Name: "zdr",
541+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
542+
Default: "disabled",
543+
BodyPath: "zdr",
544+
},
516545
},
517546
Action: handleWebSearch,
518547
HideHelpCommand: true,
@@ -780,7 +809,7 @@ var webWebScrapeBytes = requestflag.WithInnerFlags(cli.Command{
780809
},
781810
&requestflag.Flag[string]{
782811
Name: "zdr",
783-
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
812+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
784813
Default: "disabled",
785814
QueryPath: "zdr",
786815
},
@@ -890,7 +919,7 @@ var webWebScrapeHTML = requestflag.WithInnerFlags(cli.Command{
890919
},
891920
&requestflag.Flag[string]{
892921
Name: "zdr",
893-
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
922+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
894923
Default: "disabled",
895924
QueryPath: "zdr",
896925
},
@@ -987,6 +1016,12 @@ var webWebScrapeImages = requestflag.WithInnerFlags(cli.Command{
9871016
Usage: "Optional browser wait time in milliseconds after initial page load before collecting images. Min: 0. Max: 30000 (30 seconds). When combined with timeoutOpts, timeoutOpts.milliseconds must be at least waitForMs + 10000 ms; a shorter deadline is rejected with 400 TIMEOUT_TOO_SHORT_FOR_WAIT.",
9881017
QueryPath: "waitForMs",
9891018
},
1019+
&requestflag.Flag[string]{
1020+
Name: "zdr",
1021+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
1022+
Default: "disabled",
1023+
QueryPath: "zdr",
1024+
},
9901025
},
9911026
Action: handleWebWebScrapeImages,
9921027
HideHelpCommand: true,
@@ -999,7 +1034,7 @@ var webWebScrapeImages = requestflag.WithInnerFlags(cli.Command{
9991034
},
10001035
&requestflag.InnerFlag[bool]{
10011036
Name: "enrichment.hosted-url",
1002-
Usage: "Host materializable images on the Brand.dev CDN and return their URL and MIME type.",
1037+
Usage: "Host materializable images on the Brand.dev CDN and return their URL and MIME type. Ignored when zero data retention is enabled.",
10031038
InnerField: "hostedUrl",
10041039
},
10051040
&requestflag.InnerFlag[int64]{
@@ -1134,7 +1169,7 @@ var webWebScrapeMd = requestflag.WithInnerFlags(cli.Command{
11341169
},
11351170
&requestflag.Flag[string]{
11361171
Name: "zdr",
1137-
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
1172+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
11381173
Default: "disabled",
11391174
QueryPath: "zdr",
11401175
},
@@ -1233,7 +1268,7 @@ var webWebScrapeSitemap = requestflag.WithInnerFlags(cli.Command{
12331268
},
12341269
&requestflag.Flag[string]{
12351270
Name: "zdr",
1236-
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
1271+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Asset uploads are skipped, so hosted image URLs are omitted. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
12371272
Default: "disabled",
12381273
QueryPath: "zdr",
12391274
},

0 commit comments

Comments
 (0)