Skip to content

Commit

Permalink
docs: Improve code samples in docs (box/box-codegen#661) (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build authored Feb 7, 2025
1 parent d83bc97 commit d7954ad
Show file tree
Hide file tree
Showing 32 changed files with 139 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "cb61d82", "specHash": "59747aa", "version": "1.11.0" }
{ "engineHash": "2c730de", "specHash": "59747aa", "version": "1.11.0" }
65 changes: 49 additions & 16 deletions docs/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ See the endpoint docs at

```python
client.ai.create_ai_ask(
CreateAiAskMode.MULTIPLE_ITEM_QA,
"Which direction sun rises?",
CreateAiAskMode.SINGLE_ITEM_QA,
"which direction sun rises",
[
AiItemAsk(
id=file_to_ask_1.id,
type=AiItemAskTypeField.FILE,
content="Earth goes around the sun",
),
AiItemAsk(
id=file_to_ask_2.id,
id=file_to_ask.id,
type=AiItemAskTypeField.FILE,
content="Sun rises in the East in the morning",
),
content="Sun rises in the East",
)
],
ai_agent=ai_ask_agent_config,
)
```

Expand Down Expand Up @@ -127,9 +123,7 @@ See the endpoint docs at
<!-- sample get_ai_agent_default -->

```python
client.ai.get_ai_agent_default_config(
GetAiAgentDefaultConfigMode.EXTRACT_STRUCTURED, language="en-US"
)
client.ai.get_ai_agent_default_config(GetAiAgentDefaultConfigMode.ASK, language="en-US")
```

### Arguments
Expand Down Expand Up @@ -212,9 +206,48 @@ See the endpoint docs at
```python
client.ai.create_ai_extract_structured(
[AiItemBase(id=file.id)],
metadata_template=CreateAiExtractStructuredMetadataTemplate(
template_key=template_key, scope="enterprise"
),
fields=[
CreateAiExtractStructuredFields(
key="firstName",
display_name="First name",
description="Person first name",
prompt="What is the your first name?",
type="string",
),
CreateAiExtractStructuredFields(
key="lastName",
display_name="Last name",
description="Person last name",
prompt="What is the your last name?",
type="string",
),
CreateAiExtractStructuredFields(
key="dateOfBirth",
display_name="Birth date",
description="Person date of birth",
prompt="What is the date of your birth?",
type="date",
),
CreateAiExtractStructuredFields(
key="age",
display_name="Age",
description="Person age",
prompt="How old are you?",
type="float",
),
CreateAiExtractStructuredFields(
key="hobby",
display_name="Hobby",
description="Person hobby",
prompt="What is your hobby?",
type="multiSelect",
options=[
CreateAiExtractStructuredFieldsOptionsField(key="guitar"),
CreateAiExtractStructuredFieldsOptionsField(key="books"),
],
),
],
ai_agent=agent_ignoring_overriding_embeddings_model,
)
```

Expand Down
4 changes: 3 additions & 1 deletion docs/collaboration_allowlist_entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ See the endpoint docs at
<!-- sample get_collaboration_whitelist_entries_id -->

```python
client.collaboration_allowlist_entries.get_collaboration_whitelist_entry_by_id(entry.id)
client.collaboration_allowlist_entries.get_collaboration_whitelist_entry_by_id(
new_entry.id
)
```

### Arguments
Expand Down
2 changes: 1 addition & 1 deletion docs/collaboration_allowlist_exempt_targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ See the endpoint docs at

```python
client.collaboration_allowlist_exempt_targets.get_collaboration_whitelist_exempt_target_by_id(
exempt_target.id
new_exempt_target.id
)
```

Expand Down
3 changes: 1 addition & 2 deletions docs/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ See the endpoint docs at

```python
client.comments.create_comment(
message,
CreateCommentItem(id=new_comment.id, type=CreateCommentItemTypeField.COMMENT),
message, CreateCommentItem(id=file_id, type=CreateCommentItemTypeField.FILE)
)
```

Expand Down
4 changes: 1 addition & 3 deletions docs/device_pinners.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ See the endpoint docs at
<!-- sample get_enterprises_id_device_pinners -->

```python
client.device_pinners.get_enterprise_device_pinners(
enterprise_id, direction=GetEnterpriseDevicePinnersDirection.DESC
)
client.device_pinners.get_enterprise_device_pinners(enterprise_id)
```

### Arguments
Expand Down
4 changes: 1 addition & 3 deletions docs/docgen_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ See the endpoint docs at
<!-- sample post_docgen_templates_v2025.0 -->

```python
client.docgen_template.create_docgen_template_v2025_r0(
FileReferenceV2025R0(id=uploaded_file.id)
)
client.docgen_template.create_docgen_template_v2025_r0(FileReferenceV2025R0(id=file.id))
```

### Arguments
Expand Down
7 changes: 1 addition & 6 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,7 @@ See the endpoint docs at
<!-- sample get_events -->

```python
client.events.get_events(
stream_type=GetEventsStreamType.ADMIN_LOGS,
limit=1,
created_after=created_after_date,
created_before=created_before_date,
)
client.events.get_events()
```

### Arguments
Expand Down
13 changes: 2 additions & 11 deletions docs/file_metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,7 @@ See the endpoint docs at

```python
client.file_metadata.create_file_metadata_by_id(
file.id,
CreateFileMetadataByIdScope.ENTERPRISE,
template_key,
{
"name": "John",
"age": 23,
"birthDate": "2001-01-03T02:20:50.520Z",
"countryCode": "US",
"sports": ["basketball", "tennis"],
},
file.id, CreateFileMetadataByIdScope.GLOBAL, "properties", {"abc": "xyz"}
)
```

Expand Down Expand Up @@ -190,7 +181,7 @@ See the endpoint docs at

```python
client.file_metadata.delete_file_metadata_by_id(
file.id, DeleteFileMetadataByIdScope.ENTERPRISE, template_key
file.id, DeleteFileMetadataByIdScope.GLOBAL, "properties"
)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/file_requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See the endpoint docs at
<!-- sample get_file_requests_id -->

```python
client.file_requests.get_file_request_by_id(updated_file_request.id)
client.file_requests.get_file_request_by_id(file_request_id)
```

### Arguments
Expand Down
6 changes: 1 addition & 5 deletions docs/file_versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ See the endpoint docs at
<!-- sample get_files_id_versions_id -->

```python
client.file_versions.get_file_version_by_id(
file.id,
file_versions.entries[0].id,
fields=["trashed_at", "trashed_by", "restored_at", "restored_by"],
)
client.file_versions.get_file_version_by_id(file.id, file_versions.entries[0].id)
```

### Arguments
Expand Down
10 changes: 7 additions & 3 deletions docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ See the endpoint docs at
<!-- sample get_files_id -->

```python
client.files.get_file_by_id(file_id, fields=["is_associated_with_app_item"])
client.files.get_file_by_id(
uploaded_file.id, fields=["is_externally_owned", "has_collaborations"]
)
```

### Arguments
Expand Down Expand Up @@ -60,7 +62,9 @@ See the endpoint docs at
<!-- sample put_files_id -->

```python
downscoped_client.files.update_file_by_id(file.id, name=get_uuid())
client.files.update_file_by_id(
file_to_update.id, name=updated_name, description="Updated description"
)
```

### Arguments
Expand Down Expand Up @@ -118,7 +122,7 @@ See the endpoint docs at
<!-- sample delete_files_id -->

```python
parent_client.files.delete_file_by_id(file.id)
client.files.delete_file_by_id(thumbnail_file.id)
```

### Arguments
Expand Down
13 changes: 2 additions & 11 deletions docs/folder_metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,7 @@ See the endpoint docs at

```python
client.folder_metadata.create_folder_metadata_by_id(
folder.id,
CreateFolderMetadataByIdScope.ENTERPRISE,
template_key,
{
"name": "John",
"age": 23,
"birthDate": "2001-01-03T02:20:50.520Z",
"countryCode": "US",
"sports": ["basketball", "tennis"],
},
folder.id, CreateFolderMetadataByIdScope.GLOBAL, "properties", {"abc": "xyz"}
)
```

Expand Down Expand Up @@ -195,7 +186,7 @@ See the endpoint docs at

```python
client.folder_metadata.delete_folder_metadata_by_id(
folder.id, DeleteFolderMetadataByIdScope.ENTERPRISE, template_key
folder.id, DeleteFolderMetadataByIdScope.GLOBAL, "properties"
)
```

Expand Down
10 changes: 6 additions & 4 deletions docs/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See the endpoint docs at
<!-- sample get_folders_id -->

```python
client.folders.get_folder_by_id(folder_id, fields=["is_associated_with_app_item"])
client.folders.get_folder_by_id("0")
```

### Arguments
Expand Down Expand Up @@ -81,7 +81,9 @@ See the endpoint docs at
<!-- sample put_folders_id -->

```python
downscoped_client.folders.update_folder_by_id(folder.id, name=get_uuid())
client.folders.update_folder_by_id(
folder_to_update.id, name=updated_name, description="Updated description"
)
```

### Arguments
Expand Down Expand Up @@ -145,7 +147,7 @@ See the endpoint docs at
<!-- sample delete_folders_id -->

```python
parent_client.folders.delete_folder_by_id(folder.id)
client.folders.delete_folder_by_id(new_folder.id)
```

### Arguments
Expand Down Expand Up @@ -226,7 +228,7 @@ See the endpoint docs at
<!-- sample post_folders -->

```python
parent_client.folders.create_folder(get_uuid(), CreateFolderParent(id="0"))
client.folders.create_folder(new_folder_name, CreateFolderParent(id="0"))
```

### Arguments
Expand Down
4 changes: 3 additions & 1 deletion docs/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ See the endpoint docs at
<!-- sample get_groups_id -->

```python
client.groups.get_group_by_id(group.id)
client.groups.get_group_by_id(
group.id, fields=["id", "name", "description", "group_type"]
)
```

### Arguments
Expand Down
8 changes: 2 additions & 6 deletions docs/legal_hold_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ See the endpoint docs at

```python
client.legal_hold_policies.create_legal_hold_policy(
legal_hold_policy_name,
description=legal_hold_description,
filter_started_at=filter_started_at,
filter_ended_at=filter_ended_at,
is_ongoing=False,
legal_hold_policy_name, description=legal_hold_description, is_ongoing=True
)
```

Expand Down Expand Up @@ -162,7 +158,7 @@ See the endpoint docs at
<!-- sample delete_legal_hold_policies_id -->

```python
client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy.id)
client.legal_hold_policies.delete_legal_hold_policy_by_id(legal_hold_policy_id)
```

### Arguments
Expand Down
35 changes: 3 additions & 32 deletions docs/metadata_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,39 +275,10 @@ client.metadata_templates.create_metadata_template(
template_key=template_key,
fields=[
CreateMetadataTemplateFields(
key="firstName",
display_name="First name",
description="Person first name",
type=CreateMetadataTemplateFieldsTypeField.STRING,
),
CreateMetadataTemplateFields(
key="lastName",
display_name="Last name",
description="Person last name",
type=CreateMetadataTemplateFieldsTypeField.STRING,
),
CreateMetadataTemplateFields(
key="dateOfBirth",
display_name="Birth date",
description="Person date of birth",
type=CreateMetadataTemplateFieldsTypeField.DATE,
),
CreateMetadataTemplateFields(
key="age",
display_name="Age",
description="Person age",
type=CreateMetadataTemplateFieldsTypeField.FLOAT,
),
CreateMetadataTemplateFields(
key="hobby",
display_name="Hobby",
description="Person hobby",
type=CreateMetadataTemplateFieldsTypeField.MULTISELECT,
options=[
CreateMetadataTemplateFieldsOptionsField(key="guitar"),
CreateMetadataTemplateFieldsOptionsField(key="books"),
],
),
key="testName",
display_name="testName",
)
],
)
```
Expand Down
7 changes: 4 additions & 3 deletions docs/retention_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ See the endpoint docs at

```python
client.retention_policies.create_retention_policy(
get_uuid(),
retention_policy_name,
CreateRetentionPolicyPolicyType.FINITE,
CreateRetentionPolicyDispositionAction.REMOVE_RETENTION,
description=description,
description=retention_description,
retention_length="1",
retention_type=CreateRetentionPolicyRetentionType.MODIFIABLE,
can_owner_extend_retention=False,
can_owner_extend_retention=True,
are_owners_notified=True,
)
```

Expand Down
Loading

0 comments on commit d7954ad

Please sign in to comment.