• 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/trashedfiles/TrashedFilesManager.java
1
package com.box.sdkgen.managers.trashedfiles;
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.trashfile.TrashFile;
15
import com.box.sdkgen.schemas.trashfilerestored.TrashFileRestored;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class TrashedFilesManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

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

34
  /**
35
   * Restores a file that has been moved to the trash.
36
   *
37
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
38
   * has been deleted.
39
   *
40
   * @param fileId The unique identifier that represents a file.
41
   *     <p>The ID for any file can be determined by visiting a file in the web application and
42
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
43
   *     `file_id` is `123`. Example: "12345"
44
   */
45
  public TrashFileRestored restoreFileFromTrash(String fileId) {
46
    return restoreFileFromTrash(
1✔
47
        fileId,
48
        new RestoreFileFromTrashRequestBody(),
49
        new RestoreFileFromTrashQueryParams(),
50
        new RestoreFileFromTrashHeaders());
51
  }
52

53
  /**
54
   * Restores a file that has been moved to the trash.
55
   *
56
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
57
   * has been deleted.
58
   *
59
   * @param fileId The unique identifier that represents a file.
60
   *     <p>The ID for any file can be determined by visiting a file in the web application and
61
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
62
   *     `file_id` is `123`. Example: "12345"
63
   * @param requestBody Request body of restoreFileFromTrash method
64
   */
65
  public TrashFileRestored restoreFileFromTrash(
66
      String fileId, RestoreFileFromTrashRequestBody requestBody) {
67
    return restoreFileFromTrash(
×
68
        fileId,
69
        requestBody,
70
        new RestoreFileFromTrashQueryParams(),
71
        new RestoreFileFromTrashHeaders());
72
  }
73

74
  /**
75
   * Restores a file that has been moved to the trash.
76
   *
77
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
78
   * has been deleted.
79
   *
80
   * @param fileId The unique identifier that represents a file.
81
   *     <p>The ID for any file can be determined by visiting a file in the web application and
82
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
83
   *     `file_id` is `123`. Example: "12345"
84
   * @param queryParams Query parameters of restoreFileFromTrash method
85
   */
86
  public TrashFileRestored restoreFileFromTrash(
87
      String fileId, RestoreFileFromTrashQueryParams queryParams) {
88
    return restoreFileFromTrash(
×
89
        fileId,
90
        new RestoreFileFromTrashRequestBody(),
91
        queryParams,
92
        new RestoreFileFromTrashHeaders());
93
  }
94

95
  /**
96
   * Restores a file that has been moved to the trash.
97
   *
98
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
99
   * has been deleted.
100
   *
101
   * @param fileId The unique identifier that represents a file.
102
   *     <p>The ID for any file can be determined by visiting a file in the web application and
103
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
104
   *     `file_id` is `123`. Example: "12345"
105
   * @param requestBody Request body of restoreFileFromTrash method
106
   * @param queryParams Query parameters of restoreFileFromTrash method
107
   */
108
  public TrashFileRestored restoreFileFromTrash(
109
      String fileId,
110
      RestoreFileFromTrashRequestBody requestBody,
111
      RestoreFileFromTrashQueryParams queryParams) {
112
    return restoreFileFromTrash(
×
113
        fileId, requestBody, queryParams, new RestoreFileFromTrashHeaders());
114
  }
115

116
  /**
117
   * Restores a file that has been moved to the trash.
118
   *
119
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
120
   * has been deleted.
121
   *
122
   * @param fileId The unique identifier that represents a file.
123
   *     <p>The ID for any file can be determined by visiting a file in the web application and
124
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
125
   *     `file_id` is `123`. Example: "12345"
126
   * @param headers Headers of restoreFileFromTrash method
127
   */
128
  public TrashFileRestored restoreFileFromTrash(
129
      String fileId, RestoreFileFromTrashHeaders headers) {
130
    return restoreFileFromTrash(
×
131
        fileId,
132
        new RestoreFileFromTrashRequestBody(),
133
        new RestoreFileFromTrashQueryParams(),
134
        headers);
135
  }
136

137
  /**
138
   * Restores a file that has been moved to the trash.
139
   *
140
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
141
   * has been deleted.
142
   *
143
   * @param fileId The unique identifier that represents a file.
144
   *     <p>The ID for any file can be determined by visiting a file in the web application and
145
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
146
   *     `file_id` is `123`. Example: "12345"
147
   * @param requestBody Request body of restoreFileFromTrash method
148
   * @param headers Headers of restoreFileFromTrash method
149
   */
150
  public TrashFileRestored restoreFileFromTrash(
151
      String fileId,
152
      RestoreFileFromTrashRequestBody requestBody,
153
      RestoreFileFromTrashHeaders headers) {
154
    return restoreFileFromTrash(
×
155
        fileId, requestBody, new RestoreFileFromTrashQueryParams(), headers);
156
  }
157

158
  /**
159
   * Restores a file that has been moved to the trash.
160
   *
161
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
162
   * has been deleted.
163
   *
164
   * @param fileId The unique identifier that represents a file.
165
   *     <p>The ID for any file can be determined by visiting a file in the web application and
166
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
167
   *     `file_id` is `123`. Example: "12345"
168
   * @param queryParams Query parameters of restoreFileFromTrash method
169
   * @param headers Headers of restoreFileFromTrash method
170
   */
171
  public TrashFileRestored restoreFileFromTrash(
172
      String fileId,
173
      RestoreFileFromTrashQueryParams queryParams,
174
      RestoreFileFromTrashHeaders headers) {
175
    return restoreFileFromTrash(
×
176
        fileId, new RestoreFileFromTrashRequestBody(), queryParams, headers);
177
  }
178

179
  /**
180
   * Restores a file that has been moved to the trash.
181
   *
182
   * <p>An optional new parent ID can be provided to restore the file to in case the original folder
183
   * has been deleted.
184
   *
185
   * @param fileId The unique identifier that represents a file.
186
   *     <p>The ID for any file can be determined by visiting a file in the web application and
187
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
188
   *     `file_id` is `123`. Example: "12345"
189
   * @param requestBody Request body of restoreFileFromTrash method
190
   * @param queryParams Query parameters of restoreFileFromTrash method
191
   * @param headers Headers of restoreFileFromTrash method
192
   */
193
  public TrashFileRestored restoreFileFromTrash(
194
      String fileId,
195
      RestoreFileFromTrashRequestBody requestBody,
196
      RestoreFileFromTrashQueryParams queryParams,
197
      RestoreFileFromTrashHeaders headers) {
198
    Map<String, String> queryParamsMap =
1✔
199
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
200
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
201
    FetchResponse response =
1✔
202
        this.networkSession
203
            .getNetworkClient()
1✔
204
            .fetch(
1✔
205
                new FetchOptions.Builder(
206
                        String.join(
1✔
207
                            "",
208
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
209
                            "/2.0/files/",
210
                            convertToString(fileId)),
1✔
211
                        "POST")
212
                    .params(queryParamsMap)
1✔
213
                    .headers(headersMap)
1✔
214
                    .data(JsonManager.serialize(requestBody))
1✔
215
                    .contentType("application/json")
1✔
216
                    .responseFormat(ResponseFormat.JSON)
1✔
217
                    .auth(this.auth)
1✔
218
                    .networkSession(this.networkSession)
1✔
219
                    .build());
1✔
220
    return JsonManager.deserialize(response.getData(), TrashFileRestored.class);
1✔
221
  }
222

223
  /**
224
   * Retrieves a file that has been moved to the trash.
225
   *
226
   * <p>Please note that only if the file itself has been moved to the trash can it be retrieved
227
   * with this API call. If instead one of its parent folders was moved to the trash, only that
228
   * folder can be inspected using the [`GET
229
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
230
   *
231
   * <p>To list all items that have been moved to the trash, please use the [`GET
232
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
233
   *
234
   * @param fileId The unique identifier that represents a file.
235
   *     <p>The ID for any file can be determined by visiting a file in the web application and
236
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
237
   *     `file_id` is `123`. Example: "12345"
238
   */
239
  public TrashFile getTrashedFileById(String fileId) {
240
    return getTrashedFileById(
1✔
241
        fileId, new GetTrashedFileByIdQueryParams(), new GetTrashedFileByIdHeaders());
242
  }
243

244
  /**
245
   * Retrieves a file that has been moved to the trash.
246
   *
247
   * <p>Please note that only if the file itself has been moved to the trash can it be retrieved
248
   * with this API call. If instead one of its parent folders was moved to the trash, only that
249
   * folder can be inspected using the [`GET
250
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
251
   *
252
   * <p>To list all items that have been moved to the trash, please use the [`GET
253
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
254
   *
255
   * @param fileId The unique identifier that represents a file.
256
   *     <p>The ID for any file can be determined by visiting a file in the web application and
257
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
258
   *     `file_id` is `123`. Example: "12345"
259
   * @param queryParams Query parameters of getTrashedFileById method
260
   */
261
  public TrashFile getTrashedFileById(String fileId, GetTrashedFileByIdQueryParams queryParams) {
UNCOV
262
    return getTrashedFileById(fileId, queryParams, new GetTrashedFileByIdHeaders());
×
263
  }
264

265
  /**
266
   * Retrieves a file that has been moved to the trash.
267
   *
268
   * <p>Please note that only if the file itself has been moved to the trash can it be retrieved
269
   * with this API call. If instead one of its parent folders was moved to the trash, only that
270
   * folder can be inspected using the [`GET
271
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
272
   *
273
   * <p>To list all items that have been moved to the trash, please use the [`GET
274
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
275
   *
276
   * @param fileId The unique identifier that represents a file.
277
   *     <p>The ID for any file can be determined by visiting a file in the web application and
278
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
279
   *     `file_id` is `123`. Example: "12345"
280
   * @param headers Headers of getTrashedFileById method
281
   */
282
  public TrashFile getTrashedFileById(String fileId, GetTrashedFileByIdHeaders headers) {
UNCOV
283
    return getTrashedFileById(fileId, new GetTrashedFileByIdQueryParams(), headers);
×
284
  }
285

286
  /**
287
   * Retrieves a file that has been moved to the trash.
288
   *
289
   * <p>Please note that only if the file itself has been moved to the trash can it be retrieved
290
   * with this API call. If instead one of its parent folders was moved to the trash, only that
291
   * folder can be inspected using the [`GET
292
   * /folders/:id/trash`](https://developer.box.com/reference/get-folders-id-trash) API.
293
   *
294
   * <p>To list all items that have been moved to the trash, please use the [`GET
295
   * /folders/trash/items`](https://developer.box.com/reference/get-folders-trash-items/) API.
296
   *
297
   * @param fileId The unique identifier that represents a file.
298
   *     <p>The ID for any file can be determined by visiting a file in the web application and
299
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
300
   *     `file_id` is `123`. Example: "12345"
301
   * @param queryParams Query parameters of getTrashedFileById method
302
   * @param headers Headers of getTrashedFileById method
303
   */
304
  public TrashFile getTrashedFileById(
305
      String fileId, GetTrashedFileByIdQueryParams queryParams, GetTrashedFileByIdHeaders headers) {
306
    Map<String, String> queryParamsMap =
1✔
307
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
308
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
309
    FetchResponse response =
1✔
310
        this.networkSession
311
            .getNetworkClient()
1✔
312
            .fetch(
1✔
313
                new FetchOptions.Builder(
314
                        String.join(
1✔
315
                            "",
316
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
317
                            "/2.0/files/",
318
                            convertToString(fileId),
1✔
319
                            "/trash"),
320
                        "GET")
321
                    .params(queryParamsMap)
1✔
322
                    .headers(headersMap)
1✔
323
                    .responseFormat(ResponseFormat.JSON)
1✔
324
                    .auth(this.auth)
1✔
325
                    .networkSession(this.networkSession)
1✔
326
                    .build());
1✔
327
    return JsonManager.deserialize(response.getData(), TrashFile.class);
1✔
328
  }
329

330
  /**
331
   * Permanently deletes a file that is in the trash. This action cannot be undone.
332
   *
333
   * @param fileId The unique identifier that represents a file.
334
   *     <p>The ID for any file can be determined by visiting a file in the web application and
335
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
336
   *     `file_id` is `123`. Example: "12345"
337
   */
338
  public void deleteTrashedFileById(String fileId) {
339
    deleteTrashedFileById(fileId, new DeleteTrashedFileByIdHeaders());
1✔
340
  }
1✔
341

342
  /**
343
   * Permanently deletes a file that is in the trash. This action cannot be undone.
344
   *
345
   * @param fileId The unique identifier that represents a file.
346
   *     <p>The ID for any file can be determined by visiting a file in the web application and
347
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
348
   *     `file_id` is `123`. Example: "12345"
349
   * @param headers Headers of deleteTrashedFileById method
350
   */
351
  public void deleteTrashedFileById(String fileId, DeleteTrashedFileByIdHeaders headers) {
352
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
353
    FetchResponse response =
1✔
354
        this.networkSession
355
            .getNetworkClient()
1✔
356
            .fetch(
1✔
357
                new FetchOptions.Builder(
358
                        String.join(
1✔
359
                            "",
360
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
361
                            "/2.0/files/",
362
                            convertToString(fileId),
1✔
363
                            "/trash"),
364
                        "DELETE")
365
                    .headers(headersMap)
1✔
366
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
367
                    .auth(this.auth)
1✔
368
                    .networkSession(this.networkSession)
1✔
369
                    .build());
1✔
370
  }
1✔
371

372
  public Authentication getAuth() {
373
    return auth;
×
374
  }
375

376
  public NetworkSession getNetworkSession() {
UNCOV
377
    return networkSession;
×
378
  }
379

380
  public static class Builder {
381

382
    protected Authentication auth;
383

384
    protected NetworkSession networkSession;
385

386
    public Builder() {
1✔
387
      this.networkSession = new NetworkSession();
1✔
388
    }
1✔
389

390
    public Builder auth(Authentication auth) {
391
      this.auth = auth;
1✔
392
      return this;
1✔
393
    }
394

395
    public Builder networkSession(NetworkSession networkSession) {
396
      this.networkSession = networkSession;
1✔
397
      return this;
1✔
398
    }
399

400
    public TrashedFilesManager build() {
401
      return new TrashedFilesManager(this);
1✔
402
    }
403
  }
404
}
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