• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #7654

15 Oct 2026 02:16PM UTC coverage: 35.096% (+0.03%) from 35.067%
#7654

push

github

web-flow
chore: release version 10.20.0

1 of 1 new or added line in 1 file covered. (100.0%)

198 existing lines in 19 files now uncovered.

19981 of 56932 relevant lines covered (35.1%)

0.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.09
/src/main/java/com/box/sdkgen/managers/query/QueryManager.java
1
package com.box.sdkgen.managers.query;
2

3
import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
4
import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
5
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
6
import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
7
import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
8

9
import com.box.sdkgen.networking.auth.Authentication;
10
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
11
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
12
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
13
import com.box.sdkgen.networking.network.NetworkSession;
14
import com.box.sdkgen.schemas.v2026r0.queryinsightsrequestbodyv2026r0.QueryInsightsRequestBodyV2026R0;
15
import com.box.sdkgen.schemas.v2026r0.queryinsightsv2026r0.QueryInsightsV2026R0;
16
import com.box.sdkgen.schemas.v2026r0.queryrequestbodyv2026r0.QueryRequestBodyV2026R0;
17
import com.box.sdkgen.schemas.v2026r0.queryresultsv2026r0.QueryResultsV2026R0;
18
import com.box.sdkgen.serialization.json.JsonManager;
19
import java.util.Map;
20

21
public class QueryManager {
22

23
  public Authentication auth;
24

25
  public NetworkSession networkSession;
26

27
  public QueryManager() {
×
28
    this.networkSession = new NetworkSession();
×
29
  }
×
30

31
  protected QueryManager(Builder builder) {
1 ✔
32
    this.auth = builder.auth;
1 ✔
33
    this.networkSession = builder.networkSession;
1 ✔
34
  }
1 ✔
35

36
  /**
37
   * Runs a query to discover Box items using a logical predicate, similar to a SQL WHERE clause.
38
   * The predicate can filter across multiple metadata templates and item fields in a single
39
   * request. Results can be sorted, paginated with markers, and shaped with fields so each entry
40
   * includes additional item or metadata attributes.
41
   *
42
   * <p>This is the item-retrieval endpoint in the Query API (version 2026.0). Unlike the [Metadata
43
   * Query API](https://developer.box.com/reference/post-metadata-queries-execute-read), it is not
44
   * limited to a single metadata template or to files and folders. For totals and grouped metrics
45
   * over the same predicates, use [Query
46
   * Insights](https://developer.box.com/reference/v2026.0/post-query-insights) instead of paging
47
   * through every matching item.
48
   *
49
   * <p>For predicate syntax, parameters, examples, pagination behavior, and error codes, see the
50
   * [Box Query guide](https://developer.box.com/guides/query/box-query). For shared response
51
   * schemas, including Query results and result entries, see [Query
52
   * resources](https://developer.box.com/reference/v2026.0/query-resources).
53
   *
54
   * @param requestBody Request body of createQueryV2026R0 method
55
   */
56
  public QueryResultsV2026R0 createQueryV2026R0(QueryRequestBodyV2026R0 requestBody) {
57
    return createQueryV2026R0(requestBody, new CreateQueryV2026R0Headers());
1 ✔
58
  }
59

60
  /**
61
   * Runs a query to discover Box items using a logical predicate, similar to a SQL WHERE clause.
62
   * The predicate can filter across multiple metadata templates and item fields in a single
63
   * request. Results can be sorted, paginated with markers, and shaped with fields so each entry
64
   * includes additional item or metadata attributes.
65
   *
66
   * <p>This is the item-retrieval endpoint in the Query API (version 2026.0). Unlike the [Metadata
67
   * Query API](https://developer.box.com/reference/post-metadata-queries-execute-read), it is not
68
   * limited to a single metadata template or to files and folders. For totals and grouped metrics
69
   * over the same predicates, use [Query
70
   * Insights](https://developer.box.com/reference/v2026.0/post-query-insights) instead of paging
71
   * through every matching item.
72
   *
73
   * <p>For predicate syntax, parameters, examples, pagination behavior, and error codes, see the
74
   * [Box Query guide](https://developer.box.com/guides/query/box-query). For shared response
75
   * schemas, including Query results and result entries, see [Query
76
   * resources](https://developer.box.com/reference/v2026.0/query-resources).
77
   *
78
   * @param requestBody Request body of createQueryV2026R0 method
79
   * @param headers Headers of createQueryV2026R0 method
80
   */
81
  public QueryResultsV2026R0 createQueryV2026R0(
82
      QueryRequestBodyV2026R0 requestBody, CreateQueryV2026R0Headers headers) {
83
    Map<String, String> headersMap =
1 ✔
84
        prepareParams(
1 ✔
85
            mergeMaps(
1 ✔
86
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
1 ✔
87
                headers.getExtraHeaders()));
1 ✔
88
    FetchResponse response =
1 ✔
89
        this.networkSession
90
            .getNetworkClient()
1 ✔
91
            .fetch(
1 ✔
92
                new FetchOptions.Builder(
93
                        String.join(
1 ✔
94
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/query"),
1 ✔
95
                        "POST")
96
                    .headers(headersMap)
1 ✔
97
                    .data(JsonManager.serialize(requestBody))
1 ✔
98
                    .contentType("application/json")
1 ✔
99
                    .responseFormat(ResponseFormat.JSON)
1 ✔
100
                    .auth(this.auth)
1 ✔
101
                    .networkSession(this.networkSession)
1 ✔
102
                    .build());
1 ✔
103
    return JsonManager.deserialize(response.getData(), QueryResultsV2026R0.class);
1 ✔
104
  }
105

106
  /**
107
   * Computes aggregated metrics over Box items matching a query predicate. Filters are applied
108
   * first, followed by optional grouping, after which the requested metrics (such as `sum`, `avg`,
109
   * `min`, `max`, and `count`) are computed for each resulting group or over the entire filtered
110
   * dataset.
111
   *
112
   * @param requestBody Request body of createQueryInsightV2026R0 method
113
   */
114
  public QueryInsightsV2026R0 createQueryInsightV2026R0(
115
      QueryInsightsRequestBodyV2026R0 requestBody) {
116
    return createQueryInsightV2026R0(requestBody, new CreateQueryInsightV2026R0Headers());
1 ✔
117
  }
118

119
  /**
120
   * Computes aggregated metrics over Box items matching a query predicate. Filters are applied
121
   * first, followed by optional grouping, after which the requested metrics (such as `sum`, `avg`,
122
   * `min`, `max`, and `count`) are computed for each resulting group or over the entire filtered
123
   * dataset.
124
   *
125
   * @param requestBody Request body of createQueryInsightV2026R0 method
126
   * @param headers Headers of createQueryInsightV2026R0 method
127
   */
128
  public QueryInsightsV2026R0 createQueryInsightV2026R0(
129
      QueryInsightsRequestBodyV2026R0 requestBody, CreateQueryInsightV2026R0Headers headers) {
130
    Map<String, String> headersMap =
1 ✔
131
        prepareParams(
1 ✔
132
            mergeMaps(
1 ✔
133
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
1 ✔
134
                headers.getExtraHeaders()));
1 ✔
135
    FetchResponse response =
1 ✔
136
        this.networkSession
137
            .getNetworkClient()
1 ✔
138
            .fetch(
1 ✔
139
                new FetchOptions.Builder(
140
                        String.join(
1 ✔
141
                            "",
142
                            this.networkSession.getBaseUrls().getBaseUrl(),
1 ✔
143
                            "/2.0/query_insights"),
144
                        "POST")
145
                    .headers(headersMap)
1 ✔
146
                    .data(JsonManager.serialize(requestBody))
1 ✔
147
                    .contentType("application/json")
1 ✔
148
                    .responseFormat(ResponseFormat.JSON)
1 ✔
149
                    .auth(this.auth)
1 ✔
150
                    .networkSession(this.networkSession)
1 ✔
151
                    .build());
1 ✔
152
    return JsonManager.deserialize(response.getData(), QueryInsightsV2026R0.class);
1 ✔
153
  }
154

155
  public Authentication getAuth() {
UNCOV
156
    return auth;
×
157
  }
158

159
  public NetworkSession getNetworkSession() {
UNCOV
160
    return networkSession;
×
161
  }
162

163
  public static class Builder {
164

165
    protected Authentication auth;
166

167
    protected NetworkSession networkSession;
168

169
    public Builder() {}
1 ✔
170

171
    public Builder auth(Authentication auth) {
172
      this.auth = auth;
1 ✔
173
      return this;
1 ✔
174
    }
175

176
    public Builder networkSession(NetworkSession networkSession) {
177
      this.networkSession = networkSession;
1 ✔
178
      return this;
1 ✔
179
    }
180

181
    public QueryManager build() {
182
      if (this.networkSession == null) {
1 ✔
UNCOV
183
        this.networkSession = new NetworkSession();
×
184
      }
185
      return new QueryManager(this);
1 ✔
186
    }
187
  }
188
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc