• 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

91.25
/src/main/java/com/box/sdkgen/managers/folderclassifications/FolderClassificationsManager.java
1
package com.box.sdkgen.managers.folderclassifications;
2

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

8
import com.box.sdkgen.networking.auth.Authentication;
9
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
10
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
11
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
12
import com.box.sdkgen.networking.network.NetworkSession;
13
import com.box.sdkgen.schemas.classification.Classification;
14
import com.box.sdkgen.serialization.json.JsonManager;
15
import java.util.List;
16
import java.util.Map;
17

18
public class FolderClassificationsManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Retrieves the classification metadata instance that has been applied to a folder.
35
   *
36
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
37
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
38
   *
39
   * @param folderId The unique identifier that represent a folder.
40
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
41
   *     and copying the ID from the URL. For example, for the URL
42
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
43
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
44
   */
45
  public Classification getClassificationOnFolder(String folderId) {
46
    return getClassificationOnFolder(folderId, new GetClassificationOnFolderHeaders());
1✔
47
  }
48

49
  /**
50
   * Retrieves the classification metadata instance that has been applied to a folder.
51
   *
52
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
53
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
54
   *
55
   * @param folderId The unique identifier that represent a folder.
56
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
57
   *     and copying the ID from the URL. For example, for the URL
58
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
59
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
60
   * @param headers Headers of getClassificationOnFolder method
61
   */
62
  public Classification getClassificationOnFolder(
63
      String folderId, GetClassificationOnFolderHeaders headers) {
64
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
65
    FetchResponse response =
1✔
66
        this.networkSession
67
            .getNetworkClient()
1✔
68
            .fetch(
1✔
69
                new FetchOptions.Builder(
70
                        String.join(
1✔
71
                            "",
72
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
73
                            "/2.0/folders/",
74
                            convertToString(folderId),
1✔
75
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
76
                        "GET")
77
                    .headers(headersMap)
1✔
78
                    .responseFormat(ResponseFormat.JSON)
1✔
79
                    .auth(this.auth)
1✔
80
                    .networkSession(this.networkSession)
1✔
81
                    .build());
1✔
82
    return JsonManager.deserialize(response.getData(), Classification.class);
1✔
83
  }
84

85
  /**
86
   * Adds a classification to a folder by specifying the label of the classification to add.
87
   *
88
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
89
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
90
   *
91
   * @param folderId The unique identifier that represent a folder.
92
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
93
   *     and copying the ID from the URL. For example, for the URL
94
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
95
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
96
   */
97
  public Classification addClassificationToFolder(String folderId) {
98
    return addClassificationToFolder(
×
99
        folderId,
100
        new AddClassificationToFolderRequestBody(),
101
        new AddClassificationToFolderHeaders());
102
  }
103

104
  /**
105
   * Adds a classification to a folder by specifying the label of the classification to add.
106
   *
107
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
108
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
109
   *
110
   * @param folderId The unique identifier that represent a folder.
111
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
112
   *     and copying the ID from the URL. For example, for the URL
113
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
114
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
115
   * @param requestBody Request body of addClassificationToFolder method
116
   */
117
  public Classification addClassificationToFolder(
118
      String folderId, AddClassificationToFolderRequestBody requestBody) {
119
    return addClassificationToFolder(folderId, requestBody, new AddClassificationToFolderHeaders());
1✔
120
  }
121

122
  /**
123
   * Adds a classification to a folder by specifying the label of the classification to add.
124
   *
125
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
126
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
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 headers Headers of addClassificationToFolder method
134
   */
135
  public Classification addClassificationToFolder(
136
      String folderId, AddClassificationToFolderHeaders headers) {
137
    return addClassificationToFolder(folderId, new AddClassificationToFolderRequestBody(), headers);
×
138
  }
139

140
  /**
141
   * Adds a classification to a folder by specifying the label of the classification to add.
142
   *
143
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
144
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
145
   *
146
   * @param folderId The unique identifier that represent a folder.
147
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
148
   *     and copying the ID from the URL. For example, for the URL
149
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
150
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
151
   * @param requestBody Request body of addClassificationToFolder method
152
   * @param headers Headers of addClassificationToFolder method
153
   */
154
  public Classification addClassificationToFolder(
155
      String folderId,
156
      AddClassificationToFolderRequestBody requestBody,
157
      AddClassificationToFolderHeaders headers) {
158
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
159
    FetchResponse response =
1✔
160
        this.networkSession
161
            .getNetworkClient()
1✔
162
            .fetch(
1✔
163
                new FetchOptions.Builder(
164
                        String.join(
1✔
165
                            "",
166
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
167
                            "/2.0/folders/",
168
                            convertToString(folderId),
1✔
169
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
170
                        "POST")
171
                    .headers(headersMap)
1✔
172
                    .data(JsonManager.serialize(requestBody))
1✔
173
                    .contentType("application/json")
1✔
174
                    .responseFormat(ResponseFormat.JSON)
1✔
175
                    .auth(this.auth)
1✔
176
                    .networkSession(this.networkSession)
1✔
177
                    .build());
1✔
178
    return JsonManager.deserialize(response.getData(), Classification.class);
1✔
179
  }
180

181
  /**
182
   * Updates a classification on a folder.
183
   *
184
   * <p>The classification can only be updated if a classification has already been applied to the
185
   * folder before. When editing classifications, only values are defined for the enterprise will be
186
   * accepted.
187
   *
188
   * @param folderId The unique identifier that represent a folder.
189
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
190
   *     and copying the ID from the URL. For example, for the URL
191
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
192
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
193
   * @param requestBody Request body of updateClassificationOnFolder method
194
   */
195
  public Classification updateClassificationOnFolder(
196
      String folderId, List<UpdateClassificationOnFolderRequestBody> requestBody) {
197
    return updateClassificationOnFolder(
1✔
198
        folderId, requestBody, new UpdateClassificationOnFolderHeaders());
199
  }
200

201
  /**
202
   * Updates a classification on a folder.
203
   *
204
   * <p>The classification can only be updated if a classification has already been applied to the
205
   * folder before. When editing classifications, only values are defined for the enterprise will be
206
   * accepted.
207
   *
208
   * @param folderId The unique identifier that represent a folder.
209
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
210
   *     and copying the ID from the URL. For example, for the URL
211
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
212
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
213
   * @param requestBody Request body of updateClassificationOnFolder method
214
   * @param headers Headers of updateClassificationOnFolder method
215
   */
216
  public Classification updateClassificationOnFolder(
217
      String folderId,
218
      List<UpdateClassificationOnFolderRequestBody> requestBody,
219
      UpdateClassificationOnFolderHeaders headers) {
220
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
221
    FetchResponse response =
1✔
222
        this.networkSession
223
            .getNetworkClient()
1✔
224
            .fetch(
1✔
225
                new FetchOptions.Builder(
226
                        String.join(
1✔
227
                            "",
228
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
229
                            "/2.0/folders/",
230
                            convertToString(folderId),
1✔
231
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
232
                        "PUT")
233
                    .headers(headersMap)
1✔
234
                    .data(JsonManager.serialize(requestBody))
1✔
235
                    .contentType("application/json-patch+json")
1✔
236
                    .responseFormat(ResponseFormat.JSON)
1✔
237
                    .auth(this.auth)
1✔
238
                    .networkSession(this.networkSession)
1✔
239
                    .build());
1✔
240
    return JsonManager.deserialize(response.getData(), Classification.class);
1✔
241
  }
242

243
  /**
244
   * Removes any classifications from a folder.
245
   *
246
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
247
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
248
   *
249
   * @param folderId The unique identifier that represent a folder.
250
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
251
   *     and copying the ID from the URL. For example, for the URL
252
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
253
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
254
   */
255
  public void deleteClassificationFromFolder(String folderId) {
256
    deleteClassificationFromFolder(folderId, new DeleteClassificationFromFolderHeaders());
1✔
257
  }
1✔
258

259
  /**
260
   * Removes any classifications from a folder.
261
   *
262
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
263
   * example `/folders/:id/enterprise_12345/securityClassification-6VMVochwUWo`.
264
   *
265
   * @param folderId The unique identifier that represent a folder.
266
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
267
   *     and copying the ID from the URL. For example, for the URL
268
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
269
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
270
   * @param headers Headers of deleteClassificationFromFolder method
271
   */
272
  public void deleteClassificationFromFolder(
273
      String folderId, DeleteClassificationFromFolderHeaders headers) {
274
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
275
    FetchResponse response =
1✔
276
        this.networkSession
277
            .getNetworkClient()
1✔
278
            .fetch(
1✔
279
                new FetchOptions.Builder(
280
                        String.join(
1✔
281
                            "",
282
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
283
                            "/2.0/folders/",
284
                            convertToString(folderId),
1✔
285
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
286
                        "DELETE")
287
                    .headers(headersMap)
1✔
288
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
289
                    .auth(this.auth)
1✔
290
                    .networkSession(this.networkSession)
1✔
291
                    .build());
1✔
292
  }
1✔
293

294
  public Authentication getAuth() {
295
    return auth;
×
296
  }
297

298
  public NetworkSession getNetworkSession() {
299
    return networkSession;
×
300
  }
301

302
  public static class Builder {
303

304
    protected Authentication auth;
305

306
    protected NetworkSession networkSession;
307

308
    public Builder() {
1✔
309
      this.networkSession = new NetworkSession();
1✔
310
    }
1✔
311

312
    public Builder auth(Authentication auth) {
313
      this.auth = auth;
1✔
314
      return this;
1✔
315
    }
316

317
    public Builder networkSession(NetworkSession networkSession) {
318
      this.networkSession = networkSession;
1✔
319
      return this;
1✔
320
    }
321

322
    public FolderClassificationsManager build() {
323
      return new FolderClassificationsManager(this);
1✔
324
    }
325
  }
326
}
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