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

box / box-java-sdk / #5530

06 Nov 2025 12:17PM UTC coverage: 13.315% (-0.008%) from 13.323%
#5530

push

github

web-flow
fix(boxsdkgen): update descriptions of the user deletion endpoint (box/box-openapi#562) (#1551)

8368 of 62848 relevant lines covered (13.31%)

0.13 hits per line

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

0.0
/src/main/java/com/box/sdkgen/managers/users/UsersManager.java
1
package com.box.sdkgen.managers.users;
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.userfull.UserFull;
15
import com.box.sdkgen.schemas.users.Users;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class UsersManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

25
  public UsersManager() {
×
26
    this.networkSession = new NetworkSession();
×
27
  }
×
28

29
  protected UsersManager(Builder builder) {
×
30
    this.auth = builder.auth;
×
31
    this.networkSession = builder.networkSession;
×
32
  }
×
33

34
  /**
35
   * Returns a list of all users for the Enterprise along with their `user_id`, `public_name`, and
36
   * `login`.
37
   *
38
   * <p>The application and the authenticated user need to have the permission to look up users in
39
   * the entire enterprise.
40
   */
41
  public Users getUsers() {
42
    return getUsers(new GetUsersQueryParams(), new GetUsersHeaders());
×
43
  }
44

45
  /**
46
   * Returns a list of all users for the Enterprise along with their `user_id`, `public_name`, and
47
   * `login`.
48
   *
49
   * <p>The application and the authenticated user need to have the permission to look up users in
50
   * the entire enterprise.
51
   *
52
   * @param queryParams Query parameters of getUsers method
53
   */
54
  public Users getUsers(GetUsersQueryParams queryParams) {
55
    return getUsers(queryParams, new GetUsersHeaders());
×
56
  }
57

58
  /**
59
   * Returns a list of all users for the Enterprise along with their `user_id`, `public_name`, and
60
   * `login`.
61
   *
62
   * <p>The application and the authenticated user need to have the permission to look up users in
63
   * the entire enterprise.
64
   *
65
   * @param headers Headers of getUsers method
66
   */
67
  public Users getUsers(GetUsersHeaders headers) {
68
    return getUsers(new GetUsersQueryParams(), headers);
×
69
  }
70

71
  /**
72
   * Returns a list of all users for the Enterprise along with their `user_id`, `public_name`, and
73
   * `login`.
74
   *
75
   * <p>The application and the authenticated user need to have the permission to look up users in
76
   * the entire enterprise.
77
   *
78
   * @param queryParams Query parameters of getUsers method
79
   * @param headers Headers of getUsers method
80
   */
81
  public Users getUsers(GetUsersQueryParams queryParams, GetUsersHeaders headers) {
82
    Map<String, String> queryParamsMap =
×
83
        prepareParams(
×
84
            mapOf(
×
85
                entryOf("filter_term", convertToString(queryParams.getFilterTerm())),
×
86
                entryOf("user_type", convertToString(queryParams.getUserType())),
×
87
                entryOf(
×
88
                    "external_app_user_id", convertToString(queryParams.getExternalAppUserId())),
×
89
                entryOf("fields", convertToString(queryParams.getFields())),
×
90
                entryOf("offset", convertToString(queryParams.getOffset())),
×
91
                entryOf("limit", convertToString(queryParams.getLimit())),
×
92
                entryOf("usemarker", convertToString(queryParams.getUsemarker())),
×
93
                entryOf("marker", convertToString(queryParams.getMarker()))));
×
94
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
95
    FetchResponse response =
×
96
        this.networkSession
97
            .getNetworkClient()
×
98
            .fetch(
×
99
                new FetchOptions.Builder(
100
                        String.join(
×
101
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/users"),
×
102
                        "GET")
103
                    .params(queryParamsMap)
×
104
                    .headers(headersMap)
×
105
                    .responseFormat(ResponseFormat.JSON)
×
106
                    .auth(this.auth)
×
107
                    .networkSession(this.networkSession)
×
108
                    .build());
×
109
    return JsonManager.deserialize(response.getData(), Users.class);
×
110
  }
111

112
  /**
113
   * Creates a new managed user in an enterprise. This endpoint is only available to users and
114
   * applications with the right admin permissions.
115
   *
116
   * @param requestBody Request body of createUser method
117
   */
118
  public UserFull createUser(CreateUserRequestBody requestBody) {
119
    return createUser(requestBody, new CreateUserQueryParams(), new CreateUserHeaders());
×
120
  }
121

122
  /**
123
   * Creates a new managed user in an enterprise. This endpoint is only available to users and
124
   * applications with the right admin permissions.
125
   *
126
   * @param requestBody Request body of createUser method
127
   * @param queryParams Query parameters of createUser method
128
   */
129
  public UserFull createUser(CreateUserRequestBody requestBody, CreateUserQueryParams queryParams) {
130
    return createUser(requestBody, queryParams, new CreateUserHeaders());
×
131
  }
132

133
  /**
134
   * Creates a new managed user in an enterprise. This endpoint is only available to users and
135
   * applications with the right admin permissions.
136
   *
137
   * @param requestBody Request body of createUser method
138
   * @param headers Headers of createUser method
139
   */
140
  public UserFull createUser(CreateUserRequestBody requestBody, CreateUserHeaders headers) {
141
    return createUser(requestBody, new CreateUserQueryParams(), headers);
×
142
  }
143

144
  /**
145
   * Creates a new managed user in an enterprise. This endpoint is only available to users and
146
   * applications with the right admin permissions.
147
   *
148
   * @param requestBody Request body of createUser method
149
   * @param queryParams Query parameters of createUser method
150
   * @param headers Headers of createUser method
151
   */
152
  public UserFull createUser(
153
      CreateUserRequestBody requestBody,
154
      CreateUserQueryParams queryParams,
155
      CreateUserHeaders headers) {
156
    Map<String, String> queryParamsMap =
×
157
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
158
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
159
    FetchResponse response =
×
160
        this.networkSession
161
            .getNetworkClient()
×
162
            .fetch(
×
163
                new FetchOptions.Builder(
164
                        String.join(
×
165
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/users"),
×
166
                        "POST")
167
                    .params(queryParamsMap)
×
168
                    .headers(headersMap)
×
169
                    .data(JsonManager.serialize(requestBody))
×
170
                    .contentType("application/json")
×
171
                    .responseFormat(ResponseFormat.JSON)
×
172
                    .auth(this.auth)
×
173
                    .networkSession(this.networkSession)
×
174
                    .build());
×
175
    return JsonManager.deserialize(response.getData(), UserFull.class);
×
176
  }
177

178
  /**
179
   * Retrieves information about the user who is currently authenticated.
180
   *
181
   * <p>In the case of a client-side authenticated OAuth 2.0 application this will be the user who
182
   * authorized the app.
183
   *
184
   * <p>In the case of a JWT, server-side authenticated application this will be the service account
185
   * that belongs to the application by default.
186
   *
187
   * <p>Use the `As-User` header to change who this API call is made on behalf of.
188
   */
189
  public UserFull getUserMe() {
190
    return getUserMe(new GetUserMeQueryParams(), new GetUserMeHeaders());
×
191
  }
192

193
  /**
194
   * Retrieves information about the user who is currently authenticated.
195
   *
196
   * <p>In the case of a client-side authenticated OAuth 2.0 application this will be the user who
197
   * authorized the app.
198
   *
199
   * <p>In the case of a JWT, server-side authenticated application this will be the service account
200
   * that belongs to the application by default.
201
   *
202
   * <p>Use the `As-User` header to change who this API call is made on behalf of.
203
   *
204
   * @param queryParams Query parameters of getUserMe method
205
   */
206
  public UserFull getUserMe(GetUserMeQueryParams queryParams) {
207
    return getUserMe(queryParams, new GetUserMeHeaders());
×
208
  }
209

210
  /**
211
   * Retrieves information about the user who is currently authenticated.
212
   *
213
   * <p>In the case of a client-side authenticated OAuth 2.0 application this will be the user who
214
   * authorized the app.
215
   *
216
   * <p>In the case of a JWT, server-side authenticated application this will be the service account
217
   * that belongs to the application by default.
218
   *
219
   * <p>Use the `As-User` header to change who this API call is made on behalf of.
220
   *
221
   * @param headers Headers of getUserMe method
222
   */
223
  public UserFull getUserMe(GetUserMeHeaders headers) {
224
    return getUserMe(new GetUserMeQueryParams(), headers);
×
225
  }
226

227
  /**
228
   * Retrieves information about the user who is currently authenticated.
229
   *
230
   * <p>In the case of a client-side authenticated OAuth 2.0 application this will be the user who
231
   * authorized the app.
232
   *
233
   * <p>In the case of a JWT, server-side authenticated application this will be the service account
234
   * that belongs to the application by default.
235
   *
236
   * <p>Use the `As-User` header to change who this API call is made on behalf of.
237
   *
238
   * @param queryParams Query parameters of getUserMe method
239
   * @param headers Headers of getUserMe method
240
   */
241
  public UserFull getUserMe(GetUserMeQueryParams queryParams, GetUserMeHeaders headers) {
242
    Map<String, String> queryParamsMap =
×
243
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
244
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
245
    FetchResponse response =
×
246
        this.networkSession
247
            .getNetworkClient()
×
248
            .fetch(
×
249
                new FetchOptions.Builder(
250
                        String.join(
×
251
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/users/me"),
×
252
                        "GET")
253
                    .params(queryParamsMap)
×
254
                    .headers(headersMap)
×
255
                    .responseFormat(ResponseFormat.JSON)
×
256
                    .auth(this.auth)
×
257
                    .networkSession(this.networkSession)
×
258
                    .build());
×
259
    return JsonManager.deserialize(response.getData(), UserFull.class);
×
260
  }
261

262
  /**
263
   * Retrieves information about a user in the enterprise.
264
   *
265
   * <p>The application and the authenticated user need to have the permission to look up users in
266
   * the entire enterprise.
267
   *
268
   * <p>This endpoint also returns a limited set of information for external users who are
269
   * collaborated on content owned by the enterprise for authenticated users with the right scopes.
270
   * In this case, disallowed fields will return null instead.
271
   *
272
   * @param userId The ID of the user. Example: "12345"
273
   */
274
  public UserFull getUserById(String userId) {
275
    return getUserById(userId, new GetUserByIdQueryParams(), new GetUserByIdHeaders());
×
276
  }
277

278
  /**
279
   * Retrieves information about a user in the enterprise.
280
   *
281
   * <p>The application and the authenticated user need to have the permission to look up users in
282
   * the entire enterprise.
283
   *
284
   * <p>This endpoint also returns a limited set of information for external users who are
285
   * collaborated on content owned by the enterprise for authenticated users with the right scopes.
286
   * In this case, disallowed fields will return null instead.
287
   *
288
   * @param userId The ID of the user. Example: "12345"
289
   * @param queryParams Query parameters of getUserById method
290
   */
291
  public UserFull getUserById(String userId, GetUserByIdQueryParams queryParams) {
292
    return getUserById(userId, queryParams, new GetUserByIdHeaders());
×
293
  }
294

295
  /**
296
   * Retrieves information about a user in the enterprise.
297
   *
298
   * <p>The application and the authenticated user need to have the permission to look up users in
299
   * the entire enterprise.
300
   *
301
   * <p>This endpoint also returns a limited set of information for external users who are
302
   * collaborated on content owned by the enterprise for authenticated users with the right scopes.
303
   * In this case, disallowed fields will return null instead.
304
   *
305
   * @param userId The ID of the user. Example: "12345"
306
   * @param headers Headers of getUserById method
307
   */
308
  public UserFull getUserById(String userId, GetUserByIdHeaders headers) {
309
    return getUserById(userId, new GetUserByIdQueryParams(), headers);
×
310
  }
311

312
  /**
313
   * Retrieves information about a user in the enterprise.
314
   *
315
   * <p>The application and the authenticated user need to have the permission to look up users in
316
   * the entire enterprise.
317
   *
318
   * <p>This endpoint also returns a limited set of information for external users who are
319
   * collaborated on content owned by the enterprise for authenticated users with the right scopes.
320
   * In this case, disallowed fields will return null instead.
321
   *
322
   * @param userId The ID of the user. Example: "12345"
323
   * @param queryParams Query parameters of getUserById method
324
   * @param headers Headers of getUserById method
325
   */
326
  public UserFull getUserById(
327
      String userId, GetUserByIdQueryParams queryParams, GetUserByIdHeaders headers) {
328
    Map<String, String> queryParamsMap =
×
329
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
330
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
331
    FetchResponse response =
×
332
        this.networkSession
333
            .getNetworkClient()
×
334
            .fetch(
×
335
                new FetchOptions.Builder(
336
                        String.join(
×
337
                            "",
338
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
339
                            "/2.0/users/",
340
                            convertToString(userId)),
×
341
                        "GET")
342
                    .params(queryParamsMap)
×
343
                    .headers(headersMap)
×
344
                    .responseFormat(ResponseFormat.JSON)
×
345
                    .auth(this.auth)
×
346
                    .networkSession(this.networkSession)
×
347
                    .build());
×
348
    return JsonManager.deserialize(response.getData(), UserFull.class);
×
349
  }
350

351
  /**
352
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
353
   * applications with the right admin permissions.
354
   *
355
   * @param userId The ID of the user. Example: "12345"
356
   */
357
  public UserFull updateUserById(String userId) {
358
    return updateUserById(
×
359
        userId,
360
        new UpdateUserByIdRequestBody(),
361
        new UpdateUserByIdQueryParams(),
362
        new UpdateUserByIdHeaders());
363
  }
364

365
  /**
366
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
367
   * applications with the right admin permissions.
368
   *
369
   * @param userId The ID of the user. Example: "12345"
370
   * @param requestBody Request body of updateUserById method
371
   */
372
  public UserFull updateUserById(String userId, UpdateUserByIdRequestBody requestBody) {
373
    return updateUserById(
×
374
        userId, requestBody, new UpdateUserByIdQueryParams(), new UpdateUserByIdHeaders());
375
  }
376

377
  /**
378
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
379
   * applications with the right admin permissions.
380
   *
381
   * @param userId The ID of the user. Example: "12345"
382
   * @param queryParams Query parameters of updateUserById method
383
   */
384
  public UserFull updateUserById(String userId, UpdateUserByIdQueryParams queryParams) {
385
    return updateUserById(
×
386
        userId, new UpdateUserByIdRequestBody(), queryParams, new UpdateUserByIdHeaders());
387
  }
388

389
  /**
390
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
391
   * applications with the right admin permissions.
392
   *
393
   * @param userId The ID of the user. Example: "12345"
394
   * @param requestBody Request body of updateUserById method
395
   * @param queryParams Query parameters of updateUserById method
396
   */
397
  public UserFull updateUserById(
398
      String userId, UpdateUserByIdRequestBody requestBody, UpdateUserByIdQueryParams queryParams) {
399
    return updateUserById(userId, requestBody, queryParams, new UpdateUserByIdHeaders());
×
400
  }
401

402
  /**
403
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
404
   * applications with the right admin permissions.
405
   *
406
   * @param userId The ID of the user. Example: "12345"
407
   * @param headers Headers of updateUserById method
408
   */
409
  public UserFull updateUserById(String userId, UpdateUserByIdHeaders headers) {
410
    return updateUserById(
×
411
        userId, new UpdateUserByIdRequestBody(), new UpdateUserByIdQueryParams(), headers);
412
  }
413

414
  /**
415
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
416
   * applications with the right admin permissions.
417
   *
418
   * @param userId The ID of the user. Example: "12345"
419
   * @param requestBody Request body of updateUserById method
420
   * @param headers Headers of updateUserById method
421
   */
422
  public UserFull updateUserById(
423
      String userId, UpdateUserByIdRequestBody requestBody, UpdateUserByIdHeaders headers) {
424
    return updateUserById(userId, requestBody, new UpdateUserByIdQueryParams(), headers);
×
425
  }
426

427
  /**
428
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
429
   * applications with the right admin permissions.
430
   *
431
   * @param userId The ID of the user. Example: "12345"
432
   * @param queryParams Query parameters of updateUserById method
433
   * @param headers Headers of updateUserById method
434
   */
435
  public UserFull updateUserById(
436
      String userId, UpdateUserByIdQueryParams queryParams, UpdateUserByIdHeaders headers) {
437
    return updateUserById(userId, new UpdateUserByIdRequestBody(), queryParams, headers);
×
438
  }
439

440
  /**
441
   * Updates a managed or app user in an enterprise. This endpoint is only available to users and
442
   * applications with the right admin permissions.
443
   *
444
   * @param userId The ID of the user. Example: "12345"
445
   * @param requestBody Request body of updateUserById method
446
   * @param queryParams Query parameters of updateUserById method
447
   * @param headers Headers of updateUserById method
448
   */
449
  public UserFull updateUserById(
450
      String userId,
451
      UpdateUserByIdRequestBody requestBody,
452
      UpdateUserByIdQueryParams queryParams,
453
      UpdateUserByIdHeaders headers) {
454
    Map<String, String> queryParamsMap =
×
455
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
456
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
457
    FetchResponse response =
×
458
        this.networkSession
459
            .getNetworkClient()
×
460
            .fetch(
×
461
                new FetchOptions.Builder(
462
                        String.join(
×
463
                            "",
464
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
465
                            "/2.0/users/",
466
                            convertToString(userId)),
×
467
                        "PUT")
468
                    .params(queryParamsMap)
×
469
                    .headers(headersMap)
×
470
                    .data(JsonManager.serialize(requestBody))
×
471
                    .contentType("application/json")
×
472
                    .responseFormat(ResponseFormat.JSON)
×
473
                    .auth(this.auth)
×
474
                    .networkSession(this.networkSession)
×
475
                    .build());
×
476
    return JsonManager.deserialize(response.getData(), UserFull.class);
×
477
  }
478

479
  /**
480
   * Deletes a user. By default, this operation fails if the user still owns any content, was
481
   * recently active, or recently joined the enterprise from a free account. To proceed, move their
482
   * owned content first, or use the `force` parameter to delete the user and their files.
483
   *
484
   * @param userId The ID of the user. Example: "12345"
485
   */
486
  public void deleteUserById(String userId) {
487
    deleteUserById(userId, new DeleteUserByIdQueryParams(), new DeleteUserByIdHeaders());
×
488
  }
×
489

490
  /**
491
   * Deletes a user. By default, this operation fails if the user still owns any content, was
492
   * recently active, or recently joined the enterprise from a free account. To proceed, move their
493
   * owned content first, or use the `force` parameter to delete the user and their files.
494
   *
495
   * @param userId The ID of the user. Example: "12345"
496
   * @param queryParams Query parameters of deleteUserById method
497
   */
498
  public void deleteUserById(String userId, DeleteUserByIdQueryParams queryParams) {
499
    deleteUserById(userId, queryParams, new DeleteUserByIdHeaders());
×
500
  }
×
501

502
  /**
503
   * Deletes a user. By default, this operation fails if the user still owns any content, was
504
   * recently active, or recently joined the enterprise from a free account. To proceed, move their
505
   * owned content first, or use the `force` parameter to delete the user and their files.
506
   *
507
   * @param userId The ID of the user. Example: "12345"
508
   * @param headers Headers of deleteUserById method
509
   */
510
  public void deleteUserById(String userId, DeleteUserByIdHeaders headers) {
511
    deleteUserById(userId, new DeleteUserByIdQueryParams(), headers);
×
512
  }
×
513

514
  /**
515
   * Deletes a user. By default, this operation fails if the user still owns any content, was
516
   * recently active, or recently joined the enterprise from a free account. To proceed, move their
517
   * owned content first, or use the `force` parameter to delete the user and their files.
518
   *
519
   * @param userId The ID of the user. Example: "12345"
520
   * @param queryParams Query parameters of deleteUserById method
521
   * @param headers Headers of deleteUserById method
522
   */
523
  public void deleteUserById(
524
      String userId, DeleteUserByIdQueryParams queryParams, DeleteUserByIdHeaders headers) {
525
    Map<String, String> queryParamsMap =
×
526
        prepareParams(
×
527
            mapOf(
×
528
                entryOf("notify", convertToString(queryParams.getNotify())),
×
529
                entryOf("force", convertToString(queryParams.getForce()))));
×
530
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
531
    FetchResponse response =
×
532
        this.networkSession
533
            .getNetworkClient()
×
534
            .fetch(
×
535
                new FetchOptions.Builder(
536
                        String.join(
×
537
                            "",
538
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
539
                            "/2.0/users/",
540
                            convertToString(userId)),
×
541
                        "DELETE")
542
                    .params(queryParamsMap)
×
543
                    .headers(headersMap)
×
544
                    .responseFormat(ResponseFormat.NO_CONTENT)
×
545
                    .auth(this.auth)
×
546
                    .networkSession(this.networkSession)
×
547
                    .build());
×
548
  }
×
549

550
  public Authentication getAuth() {
551
    return auth;
×
552
  }
553

554
  public NetworkSession getNetworkSession() {
555
    return networkSession;
×
556
  }
557

558
  public static class Builder {
559

560
    protected Authentication auth;
561

562
    protected NetworkSession networkSession;
563

564
    public Builder() {
×
565
      this.networkSession = new NetworkSession();
×
566
    }
×
567

568
    public Builder auth(Authentication auth) {
569
      this.auth = auth;
×
570
      return this;
×
571
    }
572

573
    public Builder networkSession(NetworkSession networkSession) {
574
      this.networkSession = networkSession;
×
575
      return this;
×
576
    }
577

578
    public UsersManager build() {
579
      return new UsersManager(this);
×
580
    }
581
  }
582
}
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

© 2025 Coveralls, Inc