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

box / box-java-sdk / #5922

17 Dec 2025 05:03PM UTC coverage: 35.498% (-0.4%) from 35.917%
#5922

push

github

web-flow
fix: add taxonomy to Metadata Field (read) definition (box/box-openapi#572) (#1644)

Co-authored-by: box-sdk-build <box-sdk-build@box.com>

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

535 existing lines in 31 files now uncovered.

18926 of 53316 relevant lines covered (35.5%)

0.35 hits per line

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

82.89
/src/main/java/com/box/sdkgen/managers/trashedfolders/TrashedFoldersManager.java
1
package com.box.sdkgen.managers.trashedfolders;
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.trashfolder.TrashFolder;
15
import com.box.sdkgen.schemas.trashfolderrestored.TrashFolderRestored;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class TrashedFoldersManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

29
  protected TrashedFoldersManager(Builder builder) {
1✔
30
    this.auth = builder.auth;
1✔
31
    this.networkSession = builder.networkSession;
1✔
32
  }
1✔
33

34
  /**
35
   * Restores a folder that has been moved to the trash.
36
   *
37
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
38
   * folder has been deleted.
39
   *
40
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
41
   * all of its descendants, as well as the destination folder.
42
   *
43
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
44
   * performed on any of the locked folders.
45
   *
46
   * @param folderId The unique identifier that represent a folder.
47
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
48
   *     and copying the ID from the URL. For example, for the URL
49
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
50
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
51
   */
52
  public TrashFolderRestored restoreFolderFromTrash(String folderId) {
53
    return restoreFolderFromTrash(
1✔
54
        folderId,
55
        new RestoreFolderFromTrashRequestBody(),
56
        new RestoreFolderFromTrashQueryParams(),
57
        new RestoreFolderFromTrashHeaders());
58
  }
59

60
  /**
61
   * Restores a folder that has been moved to the trash.
62
   *
63
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
64
   * folder has been deleted.
65
   *
66
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
67
   * all of its descendants, as well as the destination folder.
68
   *
69
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
70
   * performed on any of the locked folders.
71
   *
72
   * @param folderId The unique identifier that represent a folder.
73
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
74
   *     and copying the ID from the URL. For example, for the URL
75
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
76
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
77
   * @param requestBody Request body of restoreFolderFromTrash method
78
   */
79
  public TrashFolderRestored restoreFolderFromTrash(
80
      String folderId, RestoreFolderFromTrashRequestBody requestBody) {
81
    return restoreFolderFromTrash(
×
82
        folderId,
83
        requestBody,
84
        new RestoreFolderFromTrashQueryParams(),
85
        new RestoreFolderFromTrashHeaders());
86
  }
87

88
  /**
89
   * Restores a folder that has been moved to the trash.
90
   *
91
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
92
   * folder has been deleted.
93
   *
94
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
95
   * all of its descendants, as well as the destination folder.
96
   *
97
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
98
   * performed on any of the locked folders.
99
   *
100
   * @param folderId The unique identifier that represent a folder.
101
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
102
   *     and copying the ID from the URL. For example, for the URL
103
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
104
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
105
   * @param queryParams Query parameters of restoreFolderFromTrash method
106
   */
107
  public TrashFolderRestored restoreFolderFromTrash(
108
      String folderId, RestoreFolderFromTrashQueryParams queryParams) {
109
    return restoreFolderFromTrash(
×
110
        folderId,
111
        new RestoreFolderFromTrashRequestBody(),
112
        queryParams,
113
        new RestoreFolderFromTrashHeaders());
114
  }
115

116
  /**
117
   * Restores a folder that has been moved to the trash.
118
   *
119
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
120
   * folder has been deleted.
121
   *
122
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
123
   * all of its descendants, as well as the destination folder.
124
   *
125
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
126
   * performed on any of the locked folders.
127
   *
128
   * @param folderId The unique identifier that represent a folder.
129
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
130
   *     and copying the ID from the URL. For example, for the URL
131
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
132
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
133
   * @param requestBody Request body of restoreFolderFromTrash method
134
   * @param queryParams Query parameters of restoreFolderFromTrash method
135
   */
136
  public TrashFolderRestored restoreFolderFromTrash(
137
      String folderId,
138
      RestoreFolderFromTrashRequestBody requestBody,
139
      RestoreFolderFromTrashQueryParams queryParams) {
140
    return restoreFolderFromTrash(
×
141
        folderId, requestBody, queryParams, new RestoreFolderFromTrashHeaders());
142
  }
143

144
  /**
145
   * Restores a folder that has been moved to the trash.
146
   *
147
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
148
   * folder has been deleted.
149
   *
150
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
151
   * all of its descendants, as well as the destination folder.
152
   *
153
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
154
   * performed on any of the locked folders.
155
   *
156
   * @param folderId The unique identifier that represent a folder.
157
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
158
   *     and copying the ID from the URL. For example, for the URL
159
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
160
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
161
   * @param headers Headers of restoreFolderFromTrash method
162
   */
163
  public TrashFolderRestored restoreFolderFromTrash(
164
      String folderId, RestoreFolderFromTrashHeaders headers) {
165
    return restoreFolderFromTrash(
×
166
        folderId,
167
        new RestoreFolderFromTrashRequestBody(),
168
        new RestoreFolderFromTrashQueryParams(),
169
        headers);
170
  }
171

172
  /**
173
   * Restores a folder that has been moved to the trash.
174
   *
175
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
176
   * folder has been deleted.
177
   *
178
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
179
   * all of its descendants, as well as the destination folder.
180
   *
181
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
182
   * performed on any of the locked folders.
183
   *
184
   * @param folderId The unique identifier that represent a folder.
185
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
186
   *     and copying the ID from the URL. For example, for the URL
187
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
188
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
189
   * @param requestBody Request body of restoreFolderFromTrash method
190
   * @param headers Headers of restoreFolderFromTrash method
191
   */
192
  public TrashFolderRestored restoreFolderFromTrash(
193
      String folderId,
194
      RestoreFolderFromTrashRequestBody requestBody,
195
      RestoreFolderFromTrashHeaders headers) {
196
    return restoreFolderFromTrash(
×
197
        folderId, requestBody, new RestoreFolderFromTrashQueryParams(), headers);
198
  }
199

200
  /**
201
   * Restores a folder that has been moved to the trash.
202
   *
203
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
204
   * folder has been deleted.
205
   *
206
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
207
   * all of its descendants, as well as the destination folder.
208
   *
209
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
210
   * performed on any of the locked folders.
211
   *
212
   * @param folderId The unique identifier that represent a folder.
213
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
214
   *     and copying the ID from the URL. For example, for the URL
215
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
216
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
217
   * @param queryParams Query parameters of restoreFolderFromTrash method
218
   * @param headers Headers of restoreFolderFromTrash method
219
   */
220
  public TrashFolderRestored restoreFolderFromTrash(
221
      String folderId,
222
      RestoreFolderFromTrashQueryParams queryParams,
223
      RestoreFolderFromTrashHeaders headers) {
224
    return restoreFolderFromTrash(
×
225
        folderId, new RestoreFolderFromTrashRequestBody(), queryParams, headers);
226
  }
227

228
  /**
229
   * Restores a folder that has been moved to the trash.
230
   *
231
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
232
   * folder has been deleted.
233
   *
234
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
235
   * all of its descendants, as well as the destination folder.
236
   *
237
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
238
   * performed on any of the locked folders.
239
   *
240
   * @param folderId The unique identifier that represent a folder.
241
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
242
   *     and copying the ID from the URL. For example, for the URL
243
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
244
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
245
   * @param requestBody Request body of restoreFolderFromTrash method
246
   * @param queryParams Query parameters of restoreFolderFromTrash method
247
   * @param headers Headers of restoreFolderFromTrash method
248
   */
249
  public TrashFolderRestored restoreFolderFromTrash(
250
      String folderId,
251
      RestoreFolderFromTrashRequestBody requestBody,
252
      RestoreFolderFromTrashQueryParams queryParams,
253
      RestoreFolderFromTrashHeaders headers) {
254
    Map<String, String> queryParamsMap =
1✔
255
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
256
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
257
    FetchResponse response =
1✔
258
        this.networkSession
259
            .getNetworkClient()
1✔
260
            .fetch(
1✔
261
                new FetchOptions.Builder(
262
                        String.join(
1✔
263
                            "",
264
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
265
                            "/2.0/folders/",
266
                            convertToString(folderId)),
1✔
267
                        "POST")
268
                    .params(queryParamsMap)
1✔
269
                    .headers(headersMap)
1✔
270
                    .data(JsonManager.serialize(requestBody))
1✔
271
                    .contentType("application/json")
1✔
272
                    .responseFormat(ResponseFormat.JSON)
1✔
273
                    .auth(this.auth)
1✔
274
                    .networkSession(this.networkSession)
1✔
275
                    .build());
1✔
276
    return JsonManager.deserialize(response.getData(), TrashFolderRestored.class);
1✔
277
  }
278

279
  /**
280
   * Retrieves a folder that has been moved to the trash.
281
   *
282
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
283
   * with this API call. If instead one of its parent folders was moved to the trash, only that
284
   * folder can be inspected using the [`GET
285
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
286
   *
287
   * <p>To list all items that have been moved to the trash, please use the [`GET
288
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
289
   *
290
   * @param folderId The unique identifier that represent a folder.
291
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
292
   *     and copying the ID from the URL. For example, for the URL
293
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
294
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
295
   */
296
  public TrashFolder getTrashedFolderById(String folderId) {
297
    return getTrashedFolderById(
1✔
298
        folderId, new GetTrashedFolderByIdQueryParams(), new GetTrashedFolderByIdHeaders());
299
  }
300

301
  /**
302
   * Retrieves a folder that has been moved to the trash.
303
   *
304
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
305
   * with this API call. If instead one of its parent folders was moved to the trash, only that
306
   * folder can be inspected using the [`GET
307
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
308
   *
309
   * <p>To list all items that have been moved to the trash, please use the [`GET
310
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
311
   *
312
   * @param folderId The unique identifier that represent a folder.
313
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
314
   *     and copying the ID from the URL. For example, for the URL
315
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
316
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
317
   * @param queryParams Query parameters of getTrashedFolderById method
318
   */
319
  public TrashFolder getTrashedFolderById(
320
      String folderId, GetTrashedFolderByIdQueryParams queryParams) {
UNCOV
321
    return getTrashedFolderById(folderId, queryParams, new GetTrashedFolderByIdHeaders());
×
322
  }
323

324
  /**
325
   * Retrieves a folder that has been moved to the trash.
326
   *
327
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
328
   * with this API call. If instead one of its parent folders was moved to the trash, only that
329
   * folder can be inspected using the [`GET
330
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
331
   *
332
   * <p>To list all items that have been moved to the trash, please use the [`GET
333
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
334
   *
335
   * @param folderId The unique identifier that represent a folder.
336
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
337
   *     and copying the ID from the URL. For example, for the URL
338
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
339
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
340
   * @param headers Headers of getTrashedFolderById method
341
   */
342
  public TrashFolder getTrashedFolderById(String folderId, GetTrashedFolderByIdHeaders headers) {
UNCOV
343
    return getTrashedFolderById(folderId, new GetTrashedFolderByIdQueryParams(), headers);
×
344
  }
345

346
  /**
347
   * Retrieves a folder that has been moved to the trash.
348
   *
349
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
350
   * with this API call. If instead one of its parent folders was moved to the trash, only that
351
   * folder can be inspected using the [`GET
352
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
353
   *
354
   * <p>To list all items that have been moved to the trash, please use the [`GET
355
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
356
   *
357
   * @param folderId The unique identifier that represent a folder.
358
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
359
   *     and copying the ID from the URL. For example, for the URL
360
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
361
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
362
   * @param queryParams Query parameters of getTrashedFolderById method
363
   * @param headers Headers of getTrashedFolderById method
364
   */
365
  public TrashFolder getTrashedFolderById(
366
      String folderId,
367
      GetTrashedFolderByIdQueryParams queryParams,
368
      GetTrashedFolderByIdHeaders headers) {
369
    Map<String, String> queryParamsMap =
1✔
370
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
371
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
372
    FetchResponse response =
1✔
373
        this.networkSession
374
            .getNetworkClient()
1✔
375
            .fetch(
1✔
376
                new FetchOptions.Builder(
377
                        String.join(
1✔
378
                            "",
379
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
380
                            "/2.0/folders/",
381
                            convertToString(folderId),
1✔
382
                            "/trash"),
383
                        "GET")
384
                    .params(queryParamsMap)
1✔
385
                    .headers(headersMap)
1✔
386
                    .responseFormat(ResponseFormat.JSON)
1✔
387
                    .auth(this.auth)
1✔
388
                    .networkSession(this.networkSession)
1✔
389
                    .build());
1✔
390
    return JsonManager.deserialize(response.getData(), TrashFolder.class);
1✔
391
  }
392

393
  /**
394
   * Permanently deletes a folder that is in the trash. This action cannot be undone.
395
   *
396
   * @param folderId The unique identifier that represent a folder.
397
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
398
   *     and copying the ID from the URL. For example, for the URL
399
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
400
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
401
   */
402
  public void deleteTrashedFolderById(String folderId) {
403
    deleteTrashedFolderById(folderId, new DeleteTrashedFolderByIdHeaders());
1✔
404
  }
1✔
405

406
  /**
407
   * Permanently deletes a folder that is in the trash. This action cannot be undone.
408
   *
409
   * @param folderId The unique identifier that represent a folder.
410
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
411
   *     and copying the ID from the URL. For example, for the URL
412
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
413
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
414
   * @param headers Headers of deleteTrashedFolderById method
415
   */
416
  public void deleteTrashedFolderById(String folderId, DeleteTrashedFolderByIdHeaders headers) {
417
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
418
    FetchResponse response =
1✔
419
        this.networkSession
420
            .getNetworkClient()
1✔
421
            .fetch(
1✔
422
                new FetchOptions.Builder(
423
                        String.join(
1✔
424
                            "",
425
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
426
                            "/2.0/folders/",
427
                            convertToString(folderId),
1✔
428
                            "/trash"),
429
                        "DELETE")
430
                    .headers(headersMap)
1✔
431
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
432
                    .auth(this.auth)
1✔
433
                    .networkSession(this.networkSession)
1✔
434
                    .build());
1✔
435
  }
1✔
436

437
  public Authentication getAuth() {
438
    return auth;
×
439
  }
440

441
  public NetworkSession getNetworkSession() {
UNCOV
442
    return networkSession;
×
443
  }
444

445
  public static class Builder {
446

447
    protected Authentication auth;
448

449
    protected NetworkSession networkSession;
450

451
    public Builder() {
1✔
452
      this.networkSession = new NetworkSession();
1✔
453
    }
1✔
454

455
    public Builder auth(Authentication auth) {
456
      this.auth = auth;
1✔
457
      return this;
1✔
458
    }
459

460
    public Builder networkSession(NetworkSession networkSession) {
461
      this.networkSession = networkSession;
1✔
462
      return this;
1✔
463
    }
464

465
    public TrashedFoldersManager build() {
466
      return new TrashedFoldersManager(this);
1✔
467
    }
468
  }
469
}
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