Skip to content

Commit d7954ad

Browse files
docs: Improve code samples in docs (box/box-codegen#661) (#475)
1 parent d83bc97 commit d7954ad

32 files changed

+139
-147
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "cb61d82", "specHash": "59747aa", "version": "1.11.0" }
1+
{ "engineHash": "2c730de", "specHash": "59747aa", "version": "1.11.0" }

docs/ai.md

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ See the endpoint docs at
1919

2020
```python
2121
client.ai.create_ai_ask(
22-
CreateAiAskMode.MULTIPLE_ITEM_QA,
23-
"Which direction sun rises?",
22+
CreateAiAskMode.SINGLE_ITEM_QA,
23+
"which direction sun rises",
2424
[
2525
AiItemAsk(
26-
id=file_to_ask_1.id,
27-
type=AiItemAskTypeField.FILE,
28-
content="Earth goes around the sun",
29-
),
30-
AiItemAsk(
31-
id=file_to_ask_2.id,
26+
id=file_to_ask.id,
3227
type=AiItemAskTypeField.FILE,
33-
content="Sun rises in the East in the morning",
34-
),
28+
content="Sun rises in the East",
29+
)
3530
],
31+
ai_agent=ai_ask_agent_config,
3632
)
3733
```
3834

@@ -127,9 +123,7 @@ See the endpoint docs at
127123
<!-- sample get_ai_agent_default -->
128124

129125
```python
130-
client.ai.get_ai_agent_default_config(
131-
GetAiAgentDefaultConfigMode.EXTRACT_STRUCTURED, language="en-US"
132-
)
126+
client.ai.get_ai_agent_default_config(GetAiAgentDefaultConfigMode.ASK, language="en-US")
133127
```
134128

135129
### Arguments
@@ -212,9 +206,48 @@ See the endpoint docs at
212206
```python
213207
client.ai.create_ai_extract_structured(
214208
[AiItemBase(id=file.id)],
215-
metadata_template=CreateAiExtractStructuredMetadataTemplate(
216-
template_key=template_key, scope="enterprise"
217-
),
209+
fields=[
210+
CreateAiExtractStructuredFields(
211+
key="firstName",
212+
display_name="First name",
213+
description="Person first name",
214+
prompt="What is the your first name?",
215+
type="string",
216+
),
217+
CreateAiExtractStructuredFields(
218+
key="lastName",
219+
display_name="Last name",
220+
description="Person last name",
221+
prompt="What is the your last name?",
222+
type="string",
223+
),
224+
CreateAiExtractStructuredFields(
225+
key="dateOfBirth",
226+
display_name="Birth date",
227+
description="Person date of birth",
228+
prompt="What is the date of your birth?",
229+
type="date",
230+
),
231+
CreateAiExtractStructuredFields(
232+
key="age",
233+
display_name="Age",
234+
description="Person age",
235+
prompt="How old are you?",
236+
type="float",
237+
),
238+
CreateAiExtractStructuredFields(
239+
key="hobby",
240+
display_name="Hobby",
241+
description="Person hobby",
242+
prompt="What is your hobby?",
243+
type="multiSelect",
244+
options=[
245+
CreateAiExtractStructuredFieldsOptionsField(key="guitar"),
246+
CreateAiExtractStructuredFieldsOptionsField(key="books"),
247+
],
248+
),
249+
],
250+
ai_agent=agent_ignoring_overriding_embeddings_model,
218251
)
219252
```
220253

docs/collaboration_allowlist_entries.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ See the endpoint docs at
8282
<!-- sample get_collaboration_whitelist_entries_id -->
8383

8484
```python
85-
client.collaboration_allowlist_entries.get_collaboration_whitelist_entry_by_id(entry.id)
85+
client.collaboration_allowlist_entries.get_collaboration_whitelist_entry_by_id(
86+
new_entry.id
87+
)
8688
```
8789

8890
### Arguments

docs/collaboration_allowlist_exempt_targets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ See the endpoint docs at
8181

8282
```python
8383
client.collaboration_allowlist_exempt_targets.get_collaboration_whitelist_exempt_target_by_id(
84-
exempt_target.id
84+
new_exempt_target.id
8585
)
8686
```
8787

docs/comments.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ See the endpoint docs at
146146

147147
```python
148148
client.comments.create_comment(
149-
message,
150-
CreateCommentItem(id=new_comment.id, type=CreateCommentItemTypeField.COMMENT),
149+
message, CreateCommentItem(id=file_id, type=CreateCommentItemTypeField.FILE)
151150
)
152151
```
153152

docs/device_pinners.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ See the endpoint docs at
7575
<!-- sample get_enterprises_id_device_pinners -->
7676

7777
```python
78-
client.device_pinners.get_enterprise_device_pinners(
79-
enterprise_id, direction=GetEnterpriseDevicePinnersDirection.DESC
80-
)
78+
client.device_pinners.get_enterprise_device_pinners(enterprise_id)
8179
```
8280

8381
### Arguments

docs/docgen_template.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ See the endpoint docs at
1919
<!-- sample post_docgen_templates_v2025.0 -->
2020

2121
```python
22-
client.docgen_template.create_docgen_template_v2025_r0(
23-
FileReferenceV2025R0(id=uploaded_file.id)
24-
)
22+
client.docgen_template.create_docgen_template_v2025_r0(FileReferenceV2025R0(id=file.id))
2523
```
2624

2725
### Arguments

docs/events.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,7 @@ See the endpoint docs at
8282
<!-- sample get_events -->
8383

8484
```python
85-
client.events.get_events(
86-
stream_type=GetEventsStreamType.ADMIN_LOGS,
87-
limit=1,
88-
created_after=created_after_date,
89-
created_before=created_before_date,
90-
)
85+
client.events.get_events()
9186
```
9287

9388
### Arguments

docs/file_metadata.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,7 @@ See the endpoint docs at
9191

9292
```python
9393
client.file_metadata.create_file_metadata_by_id(
94-
file.id,
95-
CreateFileMetadataByIdScope.ENTERPRISE,
96-
template_key,
97-
{
98-
"name": "John",
99-
"age": 23,
100-
"birthDate": "2001-01-03T02:20:50.520Z",
101-
"countryCode": "US",
102-
"sports": ["basketball", "tennis"],
103-
},
94+
file.id, CreateFileMetadataByIdScope.GLOBAL, "properties", {"abc": "xyz"}
10495
)
10596
```
10697

@@ -190,7 +181,7 @@ See the endpoint docs at
190181

191182
```python
192183
client.file_metadata.delete_file_metadata_by_id(
193-
file.id, DeleteFileMetadataByIdScope.ENTERPRISE, template_key
184+
file.id, DeleteFileMetadataByIdScope.GLOBAL, "properties"
194185
)
195186
```
196187

docs/file_requests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ See the endpoint docs at
1717
<!-- sample get_file_requests_id -->
1818

1919
```python
20-
client.file_requests.get_file_request_by_id(updated_file_request.id)
20+
client.file_requests.get_file_request_by_id(file_request_id)
2121
```
2222

2323
### Arguments

0 commit comments

Comments
 (0)