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

box / box-java-sdk / #5076

07 Oct 2025 12:35PM UTC coverage: 37.132% (+0.007%) from 37.125%
#5076

push

github

web-flow
test: Change `Event.additionalDetails` field assertion in events test (box/box-codegen#858) (#1491)

18454 of 49699 relevant lines covered (37.13%)

0.37 hits per line

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

7.06
/src/main/java/com/box/sdkgen/managers/hubs/HubsManager.java
1
package com.box.sdkgen.managers.hubs;
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.v2025r0.hubcopyrequestv2025r0.HubCopyRequestV2025R0;
15
import com.box.sdkgen.schemas.v2025r0.hubcreaterequestv2025r0.HubCreateRequestV2025R0;
16
import com.box.sdkgen.schemas.v2025r0.hubsv2025r0.HubsV2025R0;
17
import com.box.sdkgen.schemas.v2025r0.hubupdaterequestv2025r0.HubUpdateRequestV2025R0;
18
import com.box.sdkgen.schemas.v2025r0.hubv2025r0.HubV2025R0;
19
import com.box.sdkgen.serialization.json.JsonManager;
20
import java.util.Map;
21

22
public class HubsManager {
23

24
  public Authentication auth;
25

26
  public NetworkSession networkSession;
27

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

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

37
  /** Retrieves all Box Hubs for requesting user. */
38
  public HubsV2025R0 getHubsV2025R0() {
39
    return getHubsV2025R0(new GetHubsV2025R0QueryParams(), new GetHubsV2025R0Headers());
×
40
  }
41

42
  /**
43
   * Retrieves all Box Hubs for requesting user.
44
   *
45
   * @param queryParams Query parameters of getHubsV2025R0 method
46
   */
47
  public HubsV2025R0 getHubsV2025R0(GetHubsV2025R0QueryParams queryParams) {
48
    return getHubsV2025R0(queryParams, new GetHubsV2025R0Headers());
×
49
  }
50

51
  /**
52
   * Retrieves all Box Hubs for requesting user.
53
   *
54
   * @param headers Headers of getHubsV2025R0 method
55
   */
56
  public HubsV2025R0 getHubsV2025R0(GetHubsV2025R0Headers headers) {
57
    return getHubsV2025R0(new GetHubsV2025R0QueryParams(), headers);
×
58
  }
59

60
  /**
61
   * Retrieves all Box Hubs for requesting user.
62
   *
63
   * @param queryParams Query parameters of getHubsV2025R0 method
64
   * @param headers Headers of getHubsV2025R0 method
65
   */
66
  public HubsV2025R0 getHubsV2025R0(
67
      GetHubsV2025R0QueryParams queryParams, GetHubsV2025R0Headers headers) {
68
    Map<String, String> queryParamsMap =
×
69
        prepareParams(
×
70
            mapOf(
×
71
                entryOf("query", convertToString(queryParams.getQuery())),
×
72
                entryOf("scope", convertToString(queryParams.getScope())),
×
73
                entryOf("sort", convertToString(queryParams.getSort())),
×
74
                entryOf("direction", convertToString(queryParams.getDirection())),
×
75
                entryOf("marker", convertToString(queryParams.getMarker())),
×
76
                entryOf("limit", convertToString(queryParams.getLimit()))));
×
77
    Map<String, String> headersMap =
×
78
        prepareParams(
×
79
            mergeMaps(
×
80
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
81
                headers.getExtraHeaders()));
×
82
    FetchResponse response =
×
83
        this.networkSession
84
            .getNetworkClient()
×
85
            .fetch(
×
86
                new FetchOptions.Builder(
87
                        String.join(
×
88
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/hubs"),
×
89
                        "GET")
90
                    .params(queryParamsMap)
×
91
                    .headers(headersMap)
×
92
                    .responseFormat(ResponseFormat.JSON)
×
93
                    .auth(this.auth)
×
94
                    .networkSession(this.networkSession)
×
95
                    .build());
×
96
    return JsonManager.deserialize(response.getData(), HubsV2025R0.class);
×
97
  }
98

99
  /**
100
   * Creates a new Box Hub.
101
   *
102
   * @param requestBody Request body of createHubV2025R0 method
103
   */
104
  public HubV2025R0 createHubV2025R0(HubCreateRequestV2025R0 requestBody) {
105
    return createHubV2025R0(requestBody, new CreateHubV2025R0Headers());
×
106
  }
107

108
  /**
109
   * Creates a new Box Hub.
110
   *
111
   * @param requestBody Request body of createHubV2025R0 method
112
   * @param headers Headers of createHubV2025R0 method
113
   */
114
  public HubV2025R0 createHubV2025R0(
115
      HubCreateRequestV2025R0 requestBody, CreateHubV2025R0Headers headers) {
116
    Map<String, String> headersMap =
×
117
        prepareParams(
×
118
            mergeMaps(
×
119
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
120
                headers.getExtraHeaders()));
×
121
    FetchResponse response =
×
122
        this.networkSession
123
            .getNetworkClient()
×
124
            .fetch(
×
125
                new FetchOptions.Builder(
126
                        String.join(
×
127
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/hubs"),
×
128
                        "POST")
129
                    .headers(headersMap)
×
130
                    .data(JsonManager.serialize(requestBody))
×
131
                    .contentType("application/json")
×
132
                    .responseFormat(ResponseFormat.JSON)
×
133
                    .auth(this.auth)
×
134
                    .networkSession(this.networkSession)
×
135
                    .build());
×
136
    return JsonManager.deserialize(response.getData(), HubV2025R0.class);
×
137
  }
138

139
  /**
140
   * Retrieves all Box Hubs for a given enterprise.
141
   *
142
   * <p>Admins or Hub Co-admins of an enterprise with GCM scope can make this call.
143
   */
144
  public HubsV2025R0 getEnterpriseHubsV2025R0() {
145
    return getEnterpriseHubsV2025R0(
×
146
        new GetEnterpriseHubsV2025R0QueryParams(), new GetEnterpriseHubsV2025R0Headers());
147
  }
148

149
  /**
150
   * Retrieves all Box Hubs for a given enterprise.
151
   *
152
   * <p>Admins or Hub Co-admins of an enterprise with GCM scope can make this call.
153
   *
154
   * @param queryParams Query parameters of getEnterpriseHubsV2025R0 method
155
   */
156
  public HubsV2025R0 getEnterpriseHubsV2025R0(GetEnterpriseHubsV2025R0QueryParams queryParams) {
157
    return getEnterpriseHubsV2025R0(queryParams, new GetEnterpriseHubsV2025R0Headers());
×
158
  }
159

160
  /**
161
   * Retrieves all Box Hubs for a given enterprise.
162
   *
163
   * <p>Admins or Hub Co-admins of an enterprise with GCM scope can make this call.
164
   *
165
   * @param headers Headers of getEnterpriseHubsV2025R0 method
166
   */
167
  public HubsV2025R0 getEnterpriseHubsV2025R0(GetEnterpriseHubsV2025R0Headers headers) {
168
    return getEnterpriseHubsV2025R0(new GetEnterpriseHubsV2025R0QueryParams(), headers);
×
169
  }
170

171
  /**
172
   * Retrieves all Box Hubs for a given enterprise.
173
   *
174
   * <p>Admins or Hub Co-admins of an enterprise with GCM scope can make this call.
175
   *
176
   * @param queryParams Query parameters of getEnterpriseHubsV2025R0 method
177
   * @param headers Headers of getEnterpriseHubsV2025R0 method
178
   */
179
  public HubsV2025R0 getEnterpriseHubsV2025R0(
180
      GetEnterpriseHubsV2025R0QueryParams queryParams, GetEnterpriseHubsV2025R0Headers headers) {
181
    Map<String, String> queryParamsMap =
×
182
        prepareParams(
×
183
            mapOf(
×
184
                entryOf("query", convertToString(queryParams.getQuery())),
×
185
                entryOf("sort", convertToString(queryParams.getSort())),
×
186
                entryOf("direction", convertToString(queryParams.getDirection())),
×
187
                entryOf("marker", convertToString(queryParams.getMarker())),
×
188
                entryOf("limit", convertToString(queryParams.getLimit()))));
×
189
    Map<String, String> headersMap =
×
190
        prepareParams(
×
191
            mergeMaps(
×
192
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
193
                headers.getExtraHeaders()));
×
194
    FetchResponse response =
×
195
        this.networkSession
196
            .getNetworkClient()
×
197
            .fetch(
×
198
                new FetchOptions.Builder(
199
                        String.join(
×
200
                            "",
201
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
202
                            "/2.0/enterprise_hubs"),
203
                        "GET")
204
                    .params(queryParamsMap)
×
205
                    .headers(headersMap)
×
206
                    .responseFormat(ResponseFormat.JSON)
×
207
                    .auth(this.auth)
×
208
                    .networkSession(this.networkSession)
×
209
                    .build());
×
210
    return JsonManager.deserialize(response.getData(), HubsV2025R0.class);
×
211
  }
212

213
  /**
214
   * Retrieves details for a Box Hub by its ID.
215
   *
216
   * @param hubId The unique identifier that represent a hub.
217
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
218
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
219
   *     `hub_id` is `123`. Example: "12345"
220
   */
221
  public HubV2025R0 getHubByIdV2025R0(String hubId) {
222
    return getHubByIdV2025R0(hubId, new GetHubByIdV2025R0Headers());
×
223
  }
224

225
  /**
226
   * Retrieves details for a Box Hub by its ID.
227
   *
228
   * @param hubId The unique identifier that represent a hub.
229
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
230
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
231
   *     `hub_id` is `123`. Example: "12345"
232
   * @param headers Headers of getHubByIdV2025R0 method
233
   */
234
  public HubV2025R0 getHubByIdV2025R0(String hubId, GetHubByIdV2025R0Headers headers) {
235
    Map<String, String> headersMap =
×
236
        prepareParams(
×
237
            mergeMaps(
×
238
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
239
                headers.getExtraHeaders()));
×
240
    FetchResponse response =
×
241
        this.networkSession
242
            .getNetworkClient()
×
243
            .fetch(
×
244
                new FetchOptions.Builder(
245
                        String.join(
×
246
                            "",
247
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
248
                            "/2.0/hubs/",
249
                            convertToString(hubId)),
×
250
                        "GET")
251
                    .headers(headersMap)
×
252
                    .responseFormat(ResponseFormat.JSON)
×
253
                    .auth(this.auth)
×
254
                    .networkSession(this.networkSession)
×
255
                    .build());
×
256
    return JsonManager.deserialize(response.getData(), HubV2025R0.class);
×
257
  }
258

259
  /**
260
   * Updates a Box Hub. Can be used to change title, description, or Box Hub settings.
261
   *
262
   * @param hubId The unique identifier that represent a hub.
263
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
264
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
265
   *     `hub_id` is `123`. Example: "12345"
266
   * @param requestBody Request body of updateHubByIdV2025R0 method
267
   */
268
  public HubV2025R0 updateHubByIdV2025R0(String hubId, HubUpdateRequestV2025R0 requestBody) {
269
    return updateHubByIdV2025R0(hubId, requestBody, new UpdateHubByIdV2025R0Headers());
×
270
  }
271

272
  /**
273
   * Updates a Box Hub. Can be used to change title, description, or Box Hub settings.
274
   *
275
   * @param hubId The unique identifier that represent a hub.
276
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
277
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
278
   *     `hub_id` is `123`. Example: "12345"
279
   * @param requestBody Request body of updateHubByIdV2025R0 method
280
   * @param headers Headers of updateHubByIdV2025R0 method
281
   */
282
  public HubV2025R0 updateHubByIdV2025R0(
283
      String hubId, HubUpdateRequestV2025R0 requestBody, UpdateHubByIdV2025R0Headers headers) {
284
    Map<String, String> headersMap =
×
285
        prepareParams(
×
286
            mergeMaps(
×
287
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
288
                headers.getExtraHeaders()));
×
289
    FetchResponse response =
×
290
        this.networkSession
291
            .getNetworkClient()
×
292
            .fetch(
×
293
                new FetchOptions.Builder(
294
                        String.join(
×
295
                            "",
296
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
297
                            "/2.0/hubs/",
298
                            convertToString(hubId)),
×
299
                        "PUT")
300
                    .headers(headersMap)
×
301
                    .data(JsonManager.serialize(requestBody))
×
302
                    .contentType("application/json")
×
303
                    .responseFormat(ResponseFormat.JSON)
×
304
                    .auth(this.auth)
×
305
                    .networkSession(this.networkSession)
×
306
                    .build());
×
307
    return JsonManager.deserialize(response.getData(), HubV2025R0.class);
×
308
  }
309

310
  /**
311
   * Deletes a single Box Hub.
312
   *
313
   * @param hubId The unique identifier that represent a hub.
314
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
315
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
316
   *     `hub_id` is `123`. Example: "12345"
317
   */
318
  public void deleteHubByIdV2025R0(String hubId) {
319
    deleteHubByIdV2025R0(hubId, new DeleteHubByIdV2025R0Headers());
×
320
  }
×
321

322
  /**
323
   * Deletes a single Box Hub.
324
   *
325
   * @param hubId The unique identifier that represent a hub.
326
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
327
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
328
   *     `hub_id` is `123`. Example: "12345"
329
   * @param headers Headers of deleteHubByIdV2025R0 method
330
   */
331
  public void deleteHubByIdV2025R0(String hubId, DeleteHubByIdV2025R0Headers headers) {
332
    Map<String, String> headersMap =
×
333
        prepareParams(
×
334
            mergeMaps(
×
335
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
336
                headers.getExtraHeaders()));
×
337
    FetchResponse response =
×
338
        this.networkSession
339
            .getNetworkClient()
×
340
            .fetch(
×
341
                new FetchOptions.Builder(
342
                        String.join(
×
343
                            "",
344
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
345
                            "/2.0/hubs/",
346
                            convertToString(hubId)),
×
347
                        "DELETE")
348
                    .headers(headersMap)
×
349
                    .responseFormat(ResponseFormat.NO_CONTENT)
×
350
                    .auth(this.auth)
×
351
                    .networkSession(this.networkSession)
×
352
                    .build());
×
353
  }
×
354

355
  /**
356
   * Creates a copy of a Box Hub.
357
   *
358
   * <p>The original Box Hub will not be modified.
359
   *
360
   * @param hubId The unique identifier that represent a hub.
361
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
362
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
363
   *     `hub_id` is `123`. Example: "12345"
364
   * @param requestBody Request body of copyHubV2025R0 method
365
   */
366
  public HubV2025R0 copyHubV2025R0(String hubId, HubCopyRequestV2025R0 requestBody) {
367
    return copyHubV2025R0(hubId, requestBody, new CopyHubV2025R0Headers());
×
368
  }
369

370
  /**
371
   * Creates a copy of a Box Hub.
372
   *
373
   * <p>The original Box Hub will not be modified.
374
   *
375
   * @param hubId The unique identifier that represent a hub.
376
   *     <p>The ID for any hub can be determined by visiting this hub in the web application and
377
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
378
   *     `hub_id` is `123`. Example: "12345"
379
   * @param requestBody Request body of copyHubV2025R0 method
380
   * @param headers Headers of copyHubV2025R0 method
381
   */
382
  public HubV2025R0 copyHubV2025R0(
383
      String hubId, HubCopyRequestV2025R0 requestBody, CopyHubV2025R0Headers headers) {
384
    Map<String, String> headersMap =
×
385
        prepareParams(
×
386
            mergeMaps(
×
387
                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
×
388
                headers.getExtraHeaders()));
×
389
    FetchResponse response =
×
390
        this.networkSession
391
            .getNetworkClient()
×
392
            .fetch(
×
393
                new FetchOptions.Builder(
394
                        String.join(
×
395
                            "",
396
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
397
                            "/2.0/hubs/",
398
                            convertToString(hubId),
×
399
                            "/copy"),
400
                        "POST")
401
                    .headers(headersMap)
×
402
                    .data(JsonManager.serialize(requestBody))
×
403
                    .contentType("application/json")
×
404
                    .responseFormat(ResponseFormat.JSON)
×
405
                    .auth(this.auth)
×
406
                    .networkSession(this.networkSession)
×
407
                    .build());
×
408
    return JsonManager.deserialize(response.getData(), HubV2025R0.class);
×
409
  }
410

411
  public Authentication getAuth() {
412
    return auth;
×
413
  }
414

415
  public NetworkSession getNetworkSession() {
416
    return networkSession;
×
417
  }
418

419
  public static class Builder {
420

421
    protected Authentication auth;
422

423
    protected NetworkSession networkSession;
424

425
    public Builder() {
1✔
426
      this.networkSession = new NetworkSession();
1✔
427
    }
1✔
428

429
    public Builder auth(Authentication auth) {
430
      this.auth = auth;
1✔
431
      return this;
1✔
432
    }
433

434
    public Builder networkSession(NetworkSession networkSession) {
435
      this.networkSession = networkSession;
1✔
436
      return this;
1✔
437
    }
438

439
    public HubsManager build() {
440
      return new HubsManager(this);
1✔
441
    }
442
  }
443
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc