Skip to content

Commit 102e966

Browse files
feat(boxsdkgen): Support query APIs (box/box-openapi#610) (#1937)
1 parent 6a88eaf commit 102e966

32 files changed

Lines changed: 2451 additions & 10 deletions

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "7601181", "specHash": "54953fe", "version": "5.14.1" }
1+
{ "engineHash": "2cee311", "specHash": "cc375ad", "version": "5.14.1" }

docs/sdkgen/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ the SDK are available by topic:
6262
* [Metadatataxonomies](metadatataxonomies.md)
6363
* [Metadatatemplates](metadatatemplates.md)
6464
* [Notes](notes.md)
65+
* [Query](query.md)
6566
* [Recentitems](recentitems.md)
6667
* [Retentionpolicies](retentionpolicies.md)
6768
* [Retentionpolicyassignments](retentionpolicyassignments.md)

docs/sdkgen/query.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# QueryManager
2+
3+
4+
- [Query for Box items](#query-for-box-items)
5+
- [Create insights for Box items](#create-insights-for-box-items)
6+
7+
## Query for Box items
8+
9+
Runs a query to discover Box items using a logical predicate that can filter
10+
across item fields and metadata templates. Results can be sorted, paginated,
11+
and shaped to include additional item or metadata fields.
12+
13+
This operation is performed by calling function `createQueryV2026R0`.
14+
15+
See the endpoint docs at
16+
[API Reference](https://developer.box.com/reference/v2026.0/post-query/).
17+
18+
*Currently we don't have an example for calling `createQueryV2026R0` in integration tests*
19+
20+
### Arguments
21+
22+
- requestBody `QueryRequestBodyV2026R0`
23+
- Request body of createQueryV2026R0 method
24+
- headers `CreateQueryV2026R0Headers`
25+
- Headers of createQueryV2026R0 method
26+
27+
28+
### Returns
29+
30+
This function returns a value of type `QueryResultsV2026R0`.
31+
32+
Returns a paginated list of items matching the query.
33+
34+
35+
## Create insights for Box items
36+
37+
Computes aggregated metrics over Box items matching a query predicate.
38+
Filters are applied first, followed by optional grouping, after which the
39+
requested metrics (such as `sum`, `avg`, `min`, `max`, and `count`) are
40+
computed for each resulting group or over the entire filtered dataset.
41+
42+
This operation is performed by calling function `createQueryInsightV2026R0`.
43+
44+
See the endpoint docs at
45+
[API Reference](https://developer.box.com/reference/v2026.0/post-query-insights/).
46+
47+
*Currently we don't have an example for calling `createQueryInsightV2026R0` in integration tests*
48+
49+
### Arguments
50+
51+
- requestBody `QueryInsightsRequestBodyV2026R0`
52+
- Request body of createQueryInsightV2026R0 method
53+
- headers `CreateQueryInsightV2026R0Headers`
54+
- Headers of createQueryInsightV2026R0 method
55+
56+
57+
### Returns
58+
59+
This function returns a value of type `QueryInsightsV2026R0`.
60+
61+
Returns the computed insight entries.
62+
63+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.box.sdkgen.managers.metadatataxonomies.MetadataTaxonomiesManager;
5353
import com.box.sdkgen.managers.metadatatemplates.MetadataTemplatesManager;
5454
import com.box.sdkgen.managers.notes.NotesManager;
55+
import com.box.sdkgen.managers.query.QueryManager;
5556
import com.box.sdkgen.managers.recentitems.RecentItemsManager;
5657
import com.box.sdkgen.managers.retentionpolicies.RetentionPoliciesManager;
5758
import com.box.sdkgen.managers.retentionpolicyassignments.RetentionPolicyAssignmentsManager;
@@ -276,6 +277,8 @@ public class BoxClient {
276277

277278
public final NotesManager notes;
278279

280+
public final QueryManager query;
281+
279282
public BoxClient(Authentication auth) {
280283
this.auth = auth;
281284
this.networkSession = new NetworkSession.Builder().baseUrls(new BaseUrls()).build();
@@ -631,6 +634,8 @@ public BoxClient(Authentication auth) {
631634
.build();
632635
this.notes =
633636
new NotesManager.Builder().auth(this.auth).networkSession(this.networkSession).build();
637+
this.query =
638+
new QueryManager.Builder().auth(this.auth).networkSession(this.networkSession).build();
634639
}
635640

636641
protected BoxClient(Builder builder) {
@@ -988,6 +993,8 @@ protected BoxClient(Builder builder) {
988993
.build();
989994
this.notes =
990995
new NotesManager.Builder().auth(this.auth).networkSession(this.networkSession).build();
996+
this.query =
997+
new QueryManager.Builder().auth(this.auth).networkSession(this.networkSession).build();
991998
}
992999

9931000
/**
@@ -1451,6 +1458,10 @@ public NotesManager getNotes() {
14511458
return notes;
14521459
}
14531460

1461+
public QueryManager getQuery() {
1462+
return query;
1463+
}
1464+
14541465
public static class Builder {
14551466

14561467
protected final Authentication auth;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.box.sdkgen.managers.query;
2+
3+
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
4+
5+
import com.box.sdkgen.parameters.v2026r0.boxversionheaderv2026r0.BoxVersionHeaderV2026R0;
6+
import com.box.sdkgen.serialization.json.EnumWrapper;
7+
import java.util.Map;
8+
9+
public class CreateQueryInsightV2026R0Headers {
10+
11+
/** Version header. */
12+
public EnumWrapper<BoxVersionHeaderV2026R0> boxVersion;
13+
14+
/** Extra headers that will be included in the HTTP request. */
15+
public Map<String, String> extraHeaders;
16+
17+
public CreateQueryInsightV2026R0Headers() {
18+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(BoxVersionHeaderV2026R0._2026_0);
19+
this.extraHeaders = mapOf();
20+
}
21+
22+
protected CreateQueryInsightV2026R0Headers(Builder builder) {
23+
this.boxVersion = builder.boxVersion;
24+
this.extraHeaders = builder.extraHeaders;
25+
}
26+
27+
public EnumWrapper<BoxVersionHeaderV2026R0> 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<BoxVersionHeaderV2026R0> boxVersion;
38+
39+
protected Map<String, String> extraHeaders;
40+
41+
public Builder() {}
42+
43+
public Builder boxVersion(BoxVersionHeaderV2026R0 boxVersion) {
44+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(boxVersion);
45+
return this;
46+
}
47+
48+
public Builder boxVersion(EnumWrapper<BoxVersionHeaderV2026R0> 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 CreateQueryInsightV2026R0Headers build() {
59+
if (this.boxVersion == null) {
60+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(BoxVersionHeaderV2026R0._2026_0);
61+
}
62+
if (this.extraHeaders == null) {
63+
this.extraHeaders = mapOf();
64+
}
65+
return new CreateQueryInsightV2026R0Headers(this);
66+
}
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.box.sdkgen.managers.query;
2+
3+
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
4+
5+
import com.box.sdkgen.parameters.v2026r0.boxversionheaderv2026r0.BoxVersionHeaderV2026R0;
6+
import com.box.sdkgen.serialization.json.EnumWrapper;
7+
import java.util.Map;
8+
9+
public class CreateQueryV2026R0Headers {
10+
11+
/** Version header. */
12+
public EnumWrapper<BoxVersionHeaderV2026R0> boxVersion;
13+
14+
/** Extra headers that will be included in the HTTP request. */
15+
public Map<String, String> extraHeaders;
16+
17+
public CreateQueryV2026R0Headers() {
18+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(BoxVersionHeaderV2026R0._2026_0);
19+
this.extraHeaders = mapOf();
20+
}
21+
22+
protected CreateQueryV2026R0Headers(Builder builder) {
23+
this.boxVersion = builder.boxVersion;
24+
this.extraHeaders = builder.extraHeaders;
25+
}
26+
27+
public EnumWrapper<BoxVersionHeaderV2026R0> 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<BoxVersionHeaderV2026R0> boxVersion;
38+
39+
protected Map<String, String> extraHeaders;
40+
41+
public Builder() {}
42+
43+
public Builder boxVersion(BoxVersionHeaderV2026R0 boxVersion) {
44+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(boxVersion);
45+
return this;
46+
}
47+
48+
public Builder boxVersion(EnumWrapper<BoxVersionHeaderV2026R0> 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 CreateQueryV2026R0Headers build() {
59+
if (this.boxVersion == null) {
60+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(BoxVersionHeaderV2026R0._2026_0);
61+
}
62+
if (this.extraHeaders == null) {
63+
this.extraHeaders = mapOf();
64+
}
65+
return new CreateQueryV2026R0Headers(this);
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)