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

box / box-java-sdk / #4746

19 Aug 2025 10:21AM UTC coverage: 38.831% (+0.7%) from 38.166%
#4746

push

github

web-flow
feat: Support external user deletion API

20 of 167 new or added lines in 8 files covered. (11.98%)

145 existing lines in 18 files now uncovered.

19109 of 49211 relevant lines covered (38.83%)

0.39 hits per line

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

93.94
/src/main/java/com/box/sdkgen/managers/ai/AiManager.java
1
package com.box.sdkgen.managers.ai;
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.aiagent.AiAgent;
15
import com.box.sdkgen.schemas.aiask.AiAsk;
16
import com.box.sdkgen.schemas.aiextract.AiExtract;
17
import com.box.sdkgen.schemas.aiextractstructured.AiExtractStructured;
18
import com.box.sdkgen.schemas.aiextractstructuredresponse.AiExtractStructuredResponse;
19
import com.box.sdkgen.schemas.airesponse.AiResponse;
20
import com.box.sdkgen.schemas.airesponsefull.AiResponseFull;
21
import com.box.sdkgen.schemas.aitextgen.AiTextGen;
22
import com.box.sdkgen.serialization.json.JsonManager;
23
import java.util.Map;
24

25
public class AiManager {
26

27
  public Authentication auth;
28

29
  public NetworkSession networkSession;
30

31
  public AiManager() {
×
32
    this.networkSession = new NetworkSession();
×
33
  }
×
34

35
  protected AiManager(Builder builder) {
1✔
36
    this.auth = builder.auth;
1✔
37
    this.networkSession = builder.networkSession;
1✔
38
  }
1✔
39

40
  public AiResponseFull createAiAsk(AiAsk requestBody) {
41
    return createAiAsk(requestBody, new CreateAiAskHeaders());
1✔
42
  }
43

44
  public AiResponseFull createAiAsk(AiAsk requestBody, CreateAiAskHeaders headers) {
45
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
46
    FetchResponse response =
1✔
47
        this.networkSession
48
            .getNetworkClient()
1✔
49
            .fetch(
1✔
50
                new FetchOptions.Builder(
51
                        String.join(
1✔
52
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/ai/ask"),
1✔
53
                        "POST")
54
                    .headers(headersMap)
1✔
55
                    .data(JsonManager.serialize(requestBody))
1✔
56
                    .contentType("application/json")
1✔
57
                    .responseFormat(ResponseFormat.JSON)
1✔
58
                    .auth(this.auth)
1✔
59
                    .networkSession(this.networkSession)
1✔
60
                    .build());
1✔
61
    if (convertToString(response.getStatus()).equals("204")) {
1✔
62
      return null;
×
63
    }
64
    return JsonManager.deserialize(response.getData(), AiResponseFull.class);
1✔
65
  }
66

67
  public AiResponse createAiTextGen(AiTextGen requestBody) {
68
    return createAiTextGen(requestBody, new CreateAiTextGenHeaders());
1✔
69
  }
70

71
  public AiResponse createAiTextGen(AiTextGen requestBody, CreateAiTextGenHeaders headers) {
72
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
73
    FetchResponse response =
1✔
74
        this.networkSession
75
            .getNetworkClient()
1✔
76
            .fetch(
1✔
77
                new FetchOptions.Builder(
78
                        String.join(
1✔
79
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/ai/text_gen"),
1✔
80
                        "POST")
81
                    .headers(headersMap)
1✔
82
                    .data(JsonManager.serialize(requestBody))
1✔
83
                    .contentType("application/json")
1✔
84
                    .responseFormat(ResponseFormat.JSON)
1✔
85
                    .auth(this.auth)
1✔
86
                    .networkSession(this.networkSession)
1✔
87
                    .build());
1✔
88
    return JsonManager.deserialize(response.getData(), AiResponse.class);
1✔
89
  }
90

91
  public AiAgent getAiAgentDefaultConfig(GetAiAgentDefaultConfigQueryParams queryParams) {
92
    return getAiAgentDefaultConfig(queryParams, new GetAiAgentDefaultConfigHeaders());
1✔
93
  }
94

95
  public AiAgent getAiAgentDefaultConfig(
96
      GetAiAgentDefaultConfigQueryParams queryParams, GetAiAgentDefaultConfigHeaders headers) {
97
    Map<String, String> queryParamsMap =
1✔
98
        prepareParams(
1✔
99
            mapOf(
1✔
100
                entryOf("mode", convertToString(queryParams.getMode())),
1✔
101
                entryOf("language", convertToString(queryParams.getLanguage())),
1✔
102
                entryOf("model", convertToString(queryParams.getModel()))));
1✔
103
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
104
    FetchResponse response =
1✔
105
        this.networkSession
106
            .getNetworkClient()
1✔
107
            .fetch(
1✔
108
                new FetchOptions.Builder(
109
                        String.join(
1✔
110
                            "",
111
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
112
                            "/2.0/ai_agent_default"),
113
                        "GET")
114
                    .params(queryParamsMap)
1✔
115
                    .headers(headersMap)
1✔
116
                    .responseFormat(ResponseFormat.JSON)
1✔
117
                    .auth(this.auth)
1✔
118
                    .networkSession(this.networkSession)
1✔
119
                    .build());
1✔
120
    return JsonManager.deserialize(response.getData(), AiAgent.class);
1✔
121
  }
122

123
  public AiResponse createAiExtract(AiExtract requestBody) {
124
    return createAiExtract(requestBody, new CreateAiExtractHeaders());
1✔
125
  }
126

127
  public AiResponse createAiExtract(AiExtract requestBody, CreateAiExtractHeaders headers) {
128
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
129
    FetchResponse response =
1✔
130
        this.networkSession
131
            .getNetworkClient()
1✔
132
            .fetch(
1✔
133
                new FetchOptions.Builder(
134
                        String.join(
1✔
135
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/ai/extract"),
1✔
136
                        "POST")
137
                    .headers(headersMap)
1✔
138
                    .data(JsonManager.serialize(requestBody))
1✔
139
                    .contentType("application/json")
1✔
140
                    .responseFormat(ResponseFormat.JSON)
1✔
141
                    .auth(this.auth)
1✔
142
                    .networkSession(this.networkSession)
1✔
143
                    .build());
1✔
144
    return JsonManager.deserialize(response.getData(), AiResponse.class);
1✔
145
  }
146

147
  public AiExtractStructuredResponse createAiExtractStructured(AiExtractStructured requestBody) {
148
    return createAiExtractStructured(requestBody, new CreateAiExtractStructuredHeaders());
1✔
149
  }
150

151
  public AiExtractStructuredResponse createAiExtractStructured(
152
      AiExtractStructured requestBody, CreateAiExtractStructuredHeaders headers) {
153
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
154
    FetchResponse response =
1✔
155
        this.networkSession
156
            .getNetworkClient()
1✔
157
            .fetch(
1✔
158
                new FetchOptions.Builder(
159
                        String.join(
1✔
160
                            "",
161
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
162
                            "/2.0/ai/extract_structured"),
163
                        "POST")
164
                    .headers(headersMap)
1✔
165
                    .data(JsonManager.serialize(requestBody))
1✔
166
                    .contentType("application/json")
1✔
167
                    .responseFormat(ResponseFormat.JSON)
1✔
168
                    .auth(this.auth)
1✔
169
                    .networkSession(this.networkSession)
1✔
170
                    .build());
1✔
171
    return JsonManager.deserialize(response.getData(), AiExtractStructuredResponse.class);
1✔
172
  }
173

174
  public Authentication getAuth() {
UNCOV
175
    return auth;
×
176
  }
177

178
  public NetworkSession getNetworkSession() {
179
    return networkSession;
×
180
  }
181

182
  public static class Builder {
183

184
    protected Authentication auth;
185

186
    protected NetworkSession networkSession;
187

188
    public Builder() {
1✔
189
      this.networkSession = new NetworkSession();
1✔
190
    }
1✔
191

192
    public Builder auth(Authentication auth) {
193
      this.auth = auth;
1✔
194
      return this;
1✔
195
    }
196

197
    public Builder networkSession(NetworkSession networkSession) {
198
      this.networkSession = networkSession;
1✔
199
      return this;
1✔
200
    }
201

202
    public AiManager build() {
203
      return new AiManager(this);
1✔
204
    }
205
  }
206
}
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