Skip to content

Commit 9f14f1a

Browse files
feat(boxsdkgen): Support new Hub Document API (box/box-codegen#930) (#1756)
1 parent a219f77 commit 9f14f1a

27 files changed

Lines changed: 2349 additions & 1 deletion

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "02fdae4", "specHash": "c8e3a85", "version": "5.5.0" }
1+
{ "engineHash": "e77f966", "specHash": "c8e3a85", "version": "5.5.0" }

docs/sdkgen/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ the SDK are available by topic:
4848
* [Folderwatermarks](folderwatermarks.md)
4949
* [Groups](groups.md)
5050
* [Hubcollaborations](hubcollaborations.md)
51+
* [Hubdocument](hubdocument.md)
5152
* [Hubitems](hubitems.md)
5253
* [Hubs](hubs.md)
5354
* [Integrationmappings](integrationmappings.md)

docs/sdkgen/hubdocument.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# HubDocumentManager
2+
3+
4+
- [List Hub Document Pages](#list-hub-document-pages)
5+
- [List Hub Document blocks for page](#list-hub-document-blocks-for-page)
6+
7+
## List Hub Document Pages
8+
9+
Retrieves a list of Hub Document Pages for the specified hub.
10+
Includes both root-level pages and sub pages.
11+
12+
This operation is performed by calling function `getHubDocumentPagesV2025R0`.
13+
14+
See the endpoint docs at
15+
[API Reference](https://developer.box.com/reference/v2025.0/get-hub-document-pages/).
16+
17+
<!-- sample get_hub_document_pages_v2025.0 -->
18+
```
19+
client.getHubDocument().getHubDocumentPagesV2025R0(new GetHubDocumentPagesV2025R0QueryParams(hubId))
20+
```
21+
22+
### Arguments
23+
24+
- queryParams `GetHubDocumentPagesV2025R0QueryParams`
25+
- Query parameters of getHubDocumentPagesV2025R0 method
26+
- headers `GetHubDocumentPagesV2025R0Headers`
27+
- Headers of getHubDocumentPagesV2025R0 method
28+
29+
30+
### Returns
31+
32+
This function returns a value of type `HubDocumentPagesV2025R0`.
33+
34+
Returns a Hub Document Pages response whose `entries` array contains root-level pages and sub pages. Includes pagination when more results are available.
35+
36+
37+
## List Hub Document blocks for page
38+
39+
Retrieves a sorted list of all Hub Document Blocks on a specified page in the hub document, excluding items.
40+
Blocks are hierarchically organized by their `parent_id`.
41+
Blocks are sorted in order based on user specification in the user interface.
42+
The response will only include content blocks that belong to the specified page. This will not include sub pages or sub page content blocks.
43+
44+
This operation is performed by calling function `getHubDocumentBlocksV2025R0`.
45+
46+
See the endpoint docs at
47+
[API Reference](https://developer.box.com/reference/v2025.0/get-hub-document-blocks/).
48+
49+
<!-- sample get_hub_document_blocks_v2025.0 -->
50+
```
51+
client.getHubDocument().getHubDocumentBlocksV2025R0(new GetHubDocumentBlocksV2025R0QueryParams(hubId, pageId))
52+
```
53+
54+
### Arguments
55+
56+
- queryParams `GetHubDocumentBlocksV2025R0QueryParams`
57+
- Query parameters of getHubDocumentBlocksV2025R0 method
58+
- headers `GetHubDocumentBlocksV2025R0Headers`
59+
- Headers of getHubDocumentBlocksV2025R0 method
60+
61+
62+
### Returns
63+
64+
This function returns a value of type `HubDocumentBlocksV2025R0`.
65+
66+
Returns a Hub Document Blocks response whose `entries` array contains all content blocks of the specified page, except for items.
67+
To retrieve items, use the `GET /hub_items` endpoint.
68+
69+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.box.sdkgen.hubdocument;
2+
3+
import static com.box.sdkgen.commons.CommonsManager.getDefaultClientWithUserSubject;
4+
import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
5+
import static com.box.sdkgen.internal.utils.UtilsManager.getEnvVar;
6+
import static com.box.sdkgen.internal.utils.UtilsManager.getUuid;
7+
8+
import com.box.sdkgen.client.BoxClient;
9+
import com.box.sdkgen.managers.hubdocument.GetHubDocumentBlocksV2025R0QueryParams;
10+
import com.box.sdkgen.managers.hubdocument.GetHubDocumentPagesV2025R0QueryParams;
11+
import com.box.sdkgen.schemas.v2025r0.hubcreaterequestv2025r0.HubCreateRequestV2025R0;
12+
import com.box.sdkgen.schemas.v2025r0.hubdocumentblockentryv2025r0.HubDocumentBlockEntryV2025R0;
13+
import com.box.sdkgen.schemas.v2025r0.hubdocumentblocksv2025r0.HubDocumentBlocksV2025R0;
14+
import com.box.sdkgen.schemas.v2025r0.hubdocumentpagesv2025r0.HubDocumentPagesV2025R0;
15+
import com.box.sdkgen.schemas.v2025r0.hubdocumentpagev2025r0.HubDocumentPageV2025R0;
16+
import com.box.sdkgen.schemas.v2025r0.hubv2025r0.HubV2025R0;
17+
import org.junit.jupiter.api.Test;
18+
19+
public class HubDocumentITest {
20+
21+
private static final BoxClient client = getDefaultClientWithUserSubject(getEnvVar("USER_ID"));
22+
23+
@Test
24+
public void testGetHubDocumentPagesAndBlocks() {
25+
String hubTitle = getUuid();
26+
HubV2025R0 createdHub =
27+
client.getHubs().createHubV2025R0(new HubCreateRequestV2025R0(hubTitle));
28+
String hubId = createdHub.getId();
29+
HubDocumentPagesV2025R0 pages =
30+
client
31+
.getHubDocument()
32+
.getHubDocumentPagesV2025R0(new GetHubDocumentPagesV2025R0QueryParams(hubId));
33+
assert pages.getEntries().size() > 0;
34+
assert convertToString(pages.getType()).equals("document_pages");
35+
HubDocumentPageV2025R0 firstPage = pages.getEntries().get(0);
36+
assert convertToString(firstPage.getType()).equals("page");
37+
String pageId = firstPage.getId();
38+
HubDocumentBlocksV2025R0 blocks =
39+
client
40+
.getHubDocument()
41+
.getHubDocumentBlocksV2025R0(new GetHubDocumentBlocksV2025R0QueryParams(hubId, pageId));
42+
assert convertToString(blocks.getType()).equals("document_blocks");
43+
assert blocks.getEntries().size() > 0;
44+
HubDocumentBlockEntryV2025R0 firstBlock = blocks.getEntries().get(0);
45+
assert convertToString(firstBlock.getType()).equals("item_list");
46+
client.getHubs().deleteHubByIdV2025R0(hubId);
47+
}
48+
}

src/main/java/com/box/sdkgen/client/BoxClient.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.box.sdkgen.managers.folderwatermarks.FolderWatermarksManager;
3939
import com.box.sdkgen.managers.groups.GroupsManager;
4040
import com.box.sdkgen.managers.hubcollaborations.HubCollaborationsManager;
41+
import com.box.sdkgen.managers.hubdocument.HubDocumentManager;
4142
import com.box.sdkgen.managers.hubitems.HubItemsManager;
4243
import com.box.sdkgen.managers.hubs.HubsManager;
4344
import com.box.sdkgen.managers.integrationmappings.IntegrationMappingsManager;
@@ -261,6 +262,8 @@ public class BoxClient {
261262

262263
public final HubItemsManager hubItems;
263264

265+
public final HubDocumentManager hubDocument;
266+
264267
public final ShieldListsManager shieldLists;
265268

266269
public final ArchivesManager archives;
@@ -598,6 +601,11 @@ public BoxClient(Authentication auth) {
598601
.build();
599602
this.hubItems =
600603
new HubItemsManager.Builder().auth(this.auth).networkSession(this.networkSession).build();
604+
this.hubDocument =
605+
new HubDocumentManager.Builder()
606+
.auth(this.auth)
607+
.networkSession(this.networkSession)
608+
.build();
601609
this.shieldLists =
602610
new ShieldListsManager.Builder()
603611
.auth(this.auth)
@@ -943,6 +951,11 @@ protected BoxClient(Builder builder) {
943951
.build();
944952
this.hubItems =
945953
new HubItemsManager.Builder().auth(this.auth).networkSession(this.networkSession).build();
954+
this.hubDocument =
955+
new HubDocumentManager.Builder()
956+
.auth(this.auth)
957+
.networkSession(this.networkSession)
958+
.build();
946959
this.shieldLists =
947960
new ShieldListsManager.Builder()
948961
.auth(this.auth)
@@ -1394,6 +1407,10 @@ public HubItemsManager getHubItems() {
13941407
return hubItems;
13951408
}
13961409

1410+
public HubDocumentManager getHubDocument() {
1411+
return hubDocument;
1412+
}
1413+
13971414
public ShieldListsManager getShieldLists() {
13981415
return shieldLists;
13991416
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.box.sdkgen.managers.hubdocument;
2+
3+
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
4+
5+
import com.box.sdkgen.parameters.v2025r0.boxversionheaderv2025r0.BoxVersionHeaderV2025R0;
6+
import com.box.sdkgen.serialization.json.EnumWrapper;
7+
import java.util.Map;
8+
9+
public class GetHubDocumentBlocksV2025R0Headers {
10+
11+
/** Version header. */
12+
public EnumWrapper<BoxVersionHeaderV2025R0> boxVersion;
13+
14+
/** Extra headers that will be included in the HTTP request. */
15+
public Map<String, String> extraHeaders;
16+
17+
public GetHubDocumentBlocksV2025R0Headers() {
18+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2025R0>(BoxVersionHeaderV2025R0._2025_0);
19+
this.extraHeaders = mapOf();
20+
}
21+
22+
protected GetHubDocumentBlocksV2025R0Headers(Builder builder) {
23+
this.boxVersion = builder.boxVersion;
24+
this.extraHeaders = builder.extraHeaders;
25+
}
26+
27+
public EnumWrapper<BoxVersionHeaderV2025R0> getBoxVersion() {
28+
return boxVersion;
29+
}
30+
31+
public Map<String, String> getExtraHeaders() {
32+
return extraHeaders;
33+
}
34+
35+
public static class Builder {
36+
37+
protected EnumWrapper<BoxVersionHeaderV2025R0> boxVersion;
38+
39+
protected Map<String, String> extraHeaders;
40+
41+
public Builder() {}
42+
43+
public Builder boxVersion(BoxVersionHeaderV2025R0 boxVersion) {
44+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2025R0>(boxVersion);
45+
return this;
46+
}
47+
48+
public Builder boxVersion(EnumWrapper<BoxVersionHeaderV2025R0> boxVersion) {
49+
this.boxVersion = boxVersion;
50+
return this;
51+
}
52+
53+
public Builder extraHeaders(Map<String, String> extraHeaders) {
54+
this.extraHeaders = extraHeaders;
55+
return this;
56+
}
57+
58+
public GetHubDocumentBlocksV2025R0Headers build() {
59+
if (this.boxVersion == null) {
60+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2025R0>(BoxVersionHeaderV2025R0._2025_0);
61+
}
62+
if (this.extraHeaders == null) {
63+
this.extraHeaders = mapOf();
64+
}
65+
return new GetHubDocumentBlocksV2025R0Headers(this);
66+
}
67+
}
68+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.box.sdkgen.managers.hubdocument;
2+
3+
public class GetHubDocumentBlocksV2025R0QueryParams {
4+
5+
/**
6+
* The unique identifier that represent a hub.
7+
*
8+
* <p>The ID for any hub can be determined by visiting this hub in the web application and copying
9+
* the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is
10+
* `123`.
11+
*/
12+
public final String hubId;
13+
14+
/** The unique identifier of a page within the Box Hub. */
15+
public final String pageId;
16+
17+
/**
18+
* Defines the position marker at which to begin returning results. This is used when paginating
19+
* using marker-based pagination.
20+
*/
21+
public String marker;
22+
23+
/** The maximum number of items to return per page. */
24+
public Long limit;
25+
26+
public GetHubDocumentBlocksV2025R0QueryParams(String hubId, String pageId) {
27+
this.hubId = hubId;
28+
this.pageId = pageId;
29+
}
30+
31+
protected GetHubDocumentBlocksV2025R0QueryParams(Builder builder) {
32+
this.hubId = builder.hubId;
33+
this.pageId = builder.pageId;
34+
this.marker = builder.marker;
35+
this.limit = builder.limit;
36+
}
37+
38+
public String getHubId() {
39+
return hubId;
40+
}
41+
42+
public String getPageId() {
43+
return pageId;
44+
}
45+
46+
public String getMarker() {
47+
return marker;
48+
}
49+
50+
public Long getLimit() {
51+
return limit;
52+
}
53+
54+
public static class Builder {
55+
56+
protected final String hubId;
57+
58+
protected final String pageId;
59+
60+
protected String marker;
61+
62+
protected Long limit;
63+
64+
public Builder(String hubId, String pageId) {
65+
this.hubId = hubId;
66+
this.pageId = pageId;
67+
}
68+
69+
public Builder marker(String marker) {
70+
this.marker = marker;
71+
return this;
72+
}
73+
74+
public Builder limit(Long limit) {
75+
this.limit = limit;
76+
return this;
77+
}
78+
79+
public GetHubDocumentBlocksV2025R0QueryParams build() {
80+
return new GetHubDocumentBlocksV2025R0QueryParams(this);
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)