Skip to content

Commit 2853d30

Browse files
committed
feat(Personality Insights): Add generated code from newest version of service
1 parent 38eb9a2 commit 2853d30

File tree

4 files changed

+100
-65
lines changed

4 files changed

+100
-65
lines changed

personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@
1212
*/
1313
package com.ibm.watson.personality_insights.v3;
1414

15-
import com.ibm.cloud.sdk.core.http.HttpHeaders;
16-
import com.ibm.cloud.sdk.core.http.HttpMediaType;
1715
import com.ibm.cloud.sdk.core.http.RequestBuilder;
1816
import com.ibm.cloud.sdk.core.http.ServiceCall;
1917
import com.ibm.cloud.sdk.core.service.BaseService;
2018
import com.ibm.cloud.sdk.core.service.security.IamOptions;
19+
import com.ibm.cloud.sdk.core.util.GsonSingleton;
2120
import com.ibm.cloud.sdk.core.util.ResponseConverterUtils;
21+
import com.ibm.cloud.sdk.core.util.Validator;
22+
import com.ibm.watson.common.SdkCommon;
2223
import com.ibm.watson.personality_insights.v3.model.Profile;
2324
import com.ibm.watson.personality_insights.v3.model.ProfileOptions;
24-
import com.ibm.cloud.sdk.core.util.Validator;
25-
2625
import java.io.InputStream;
26+
import java.util.Map;
27+
import java.util.Map.Entry;
2728

2829
/**
2930
* The IBM Watson™ Personality Insights service enables applications to derive insights from social media,
@@ -141,20 +142,26 @@ public ServiceCall<Profile> profile(ProfileOptions profileOptions) {
141142
String[] pathSegments = { "v3/profile" };
142143
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
143144
builder.query("version", versionDate);
144-
builder.header("X-IBMCloud-SDK-Analytics",
145-
"service_name=personality_insights;service_version=v3;operation_id=profile");
146-
if (profileOptions.contentType() != null) {
147-
builder.header("Content-Type", profileOptions.contentType());
145+
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profile");
146+
for (Entry<String, String> header : sdkHeaders.entrySet()) {
147+
builder.header(header.getKey(), header.getValue());
148148
}
149+
builder.header("Accept", "application/json");
149150
if (profileOptions.contentLanguage() != null) {
150151
builder.header("Content-Language", profileOptions.contentLanguage());
151152
}
152153
if (profileOptions.acceptLanguage() != null) {
153154
builder.header("Accept-Language", profileOptions.acceptLanguage());
154155
}
156+
if (profileOptions.contentType() != null) {
157+
builder.header("Content-Type", profileOptions.contentType());
158+
}
155159
if (profileOptions.rawScores() != null) {
156160
builder.query("raw_scores", String.valueOf(profileOptions.rawScores()));
157161
}
162+
if (profileOptions.csvHeaders() != null) {
163+
builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders()));
164+
}
158165
if (profileOptions.consumptionPreferences() != null) {
159166
builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences()));
160167
}
@@ -198,35 +205,36 @@ public ServiceCall<Profile> profile(ProfileOptions profileOptions) {
198205
* * [Understanding a CSV profile](https://cloud.ibm.com/docs/services/personality-insights/output-csv.html).
199206
*
200207
* @param profileOptions the {@link ProfileOptions} containing the options for the call
201-
* @param includeHeaders the boolean saying whether or not to include headers in the response
202208
* @return a {@link ServiceCall} with a response type of {@link InputStream}
203209
*/
204-
public ServiceCall<InputStream> profileAsCsv(ProfileOptions profileOptions, boolean includeHeaders) {
210+
public ServiceCall<InputStream> profileAsCsv(ProfileOptions profileOptions) {
205211
Validator.notNull(profileOptions, "profileOptions cannot be null");
206212
String[] pathSegments = { "v3/profile" };
207213
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
208214
builder.query("version", versionDate);
209-
builder.header("X-IBMCloud-SDK-Analytics",
210-
"service_name=personality_insights;service_version=v3;operation_id=profileAsCsv");
211-
if (profileOptions.contentType() != null) {
212-
builder.header("Content-Type", profileOptions.contentType());
215+
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profileAsCsv");
216+
for (Entry<String, String> header : sdkHeaders.entrySet()) {
217+
builder.header(header.getKey(), header.getValue());
213218
}
219+
builder.header("Accept", "text/csv");
214220
if (profileOptions.contentLanguage() != null) {
215221
builder.header("Content-Language", profileOptions.contentLanguage());
216222
}
217223
if (profileOptions.acceptLanguage() != null) {
218224
builder.header("Accept-Language", profileOptions.acceptLanguage());
219225
}
226+
if (profileOptions.contentType() != null) {
227+
builder.header("Content-Type", profileOptions.contentType());
228+
}
220229
if (profileOptions.rawScores() != null) {
221230
builder.query("raw_scores", String.valueOf(profileOptions.rawScores()));
222231
}
232+
if (profileOptions.csvHeaders() != null) {
233+
builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders()));
234+
}
223235
if (profileOptions.consumptionPreferences() != null) {
224236
builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences()));
225237
}
226-
227-
builder.header(HttpHeaders.ACCEPT, HttpMediaType.TEXT_CSV);
228-
builder.query("csv_headers", includeHeaders);
229-
230238
builder.bodyContent(profileOptions.contentType(), profileOptions.content(), null, profileOptions.body());
231239
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
232240
}

personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static class Builder {
3232
private List<ContentItem> contentItems;
3333

3434
private Builder(Content content) {
35-
contentItems = content.contentItems;
35+
this.contentItems = content.contentItems;
3636
}
3737

3838
/**

personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ public static class Builder {
7777
private Boolean forward;
7878

7979
private Builder(ContentItem contentItem) {
80-
content = contentItem.content;
81-
id = contentItem.id;
82-
created = contentItem.created;
83-
updated = contentItem.updated;
84-
contenttype = contentItem.contenttype;
85-
language = contentItem.language;
86-
parentid = contentItem.parentid;
87-
reply = contentItem.reply;
88-
forward = contentItem.forward;
80+
this.content = contentItem.content;
81+
this.id = contentItem.id;
82+
this.created = contentItem.created;
83+
this.updated = contentItem.updated;
84+
this.contenttype = contentItem.contenttype;
85+
this.language = contentItem.language;
86+
this.parentid = contentItem.parentid;
87+
this.reply = contentItem.reply;
88+
this.forward = contentItem.forward;
8989
}
9090

9191
/**

personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@
1919
*/
2020
public class ProfileOptions extends GenericModel {
2121

22-
/**
23-
* The type of the input. For more information, see **Content types** in the method description.
24-
*
25-
* Default: `text/plain`.
26-
*/
27-
public interface ContentType {
28-
/** application/json. */
29-
String APPLICATION_JSON = "application/json";
30-
/** text/html. */
31-
String TEXT_HTML = "text/html";
32-
/** text/plain. */
33-
String TEXT_PLAIN = "text/plain";
34-
}
35-
3622
/**
3723
* The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants
3824
* are treated as their parent language; for example, `en-US` is interpreted as `en`.
@@ -87,34 +73,51 @@ public interface AcceptLanguage {
8773
String ZH_TW = "zh-tw";
8874
}
8975

76+
/**
77+
* The type of the input. For more information, see **Content types** in the method description.
78+
*
79+
* Default: `text/plain`.
80+
*/
81+
public interface ContentType {
82+
/** application/json. */
83+
String APPLICATION_JSON = "application/json";
84+
/** text/html. */
85+
String TEXT_HTML = "text/html";
86+
/** text/plain. */
87+
String TEXT_PLAIN = "text/plain";
88+
}
89+
9090
private Content content;
9191
private String body;
92-
private String contentType;
9392
private String contentLanguage;
9493
private String acceptLanguage;
9594
private Boolean rawScores;
95+
private Boolean csvHeaders;
9696
private Boolean consumptionPreferences;
97+
private String contentType;
9798

9899
/**
99100
* Builder.
100101
*/
101102
public static class Builder {
102103
private Content content;
103104
private String body;
104-
private String contentType;
105105
private String contentLanguage;
106106
private String acceptLanguage;
107107
private Boolean rawScores;
108+
private Boolean csvHeaders;
108109
private Boolean consumptionPreferences;
110+
private String contentType;
109111

110112
private Builder(ProfileOptions profileOptions) {
111-
content = profileOptions.content;
112-
body = profileOptions.body;
113-
contentType = profileOptions.contentType;
114-
contentLanguage = profileOptions.contentLanguage;
115-
acceptLanguage = profileOptions.acceptLanguage;
116-
rawScores = profileOptions.rawScores;
117-
consumptionPreferences = profileOptions.consumptionPreferences;
113+
this.content = profileOptions.content;
114+
this.body = profileOptions.body;
115+
this.contentLanguage = profileOptions.contentLanguage;
116+
this.acceptLanguage = profileOptions.acceptLanguage;
117+
this.rawScores = profileOptions.rawScores;
118+
this.csvHeaders = profileOptions.csvHeaders;
119+
this.consumptionPreferences = profileOptions.consumptionPreferences;
120+
this.contentType = profileOptions.contentType;
118121
}
119122

120123
/**
@@ -165,6 +168,17 @@ public Builder rawScores(Boolean rawScores) {
165168
return this;
166169
}
167170

171+
/**
172+
* Set the csvHeaders.
173+
*
174+
* @param csvHeaders the csvHeaders
175+
* @return the ProfileOptions builder
176+
*/
177+
public Builder csvHeaders(Boolean csvHeaders) {
178+
this.csvHeaders = csvHeaders;
179+
return this;
180+
}
181+
168182
/**
169183
* Set the consumptionPreferences.
170184
*
@@ -216,11 +230,12 @@ public Builder text(String text) {
216230
private ProfileOptions(Builder builder) {
217231
content = builder.content;
218232
body = builder.body;
219-
contentType = builder.contentType;
220233
contentLanguage = builder.contentLanguage;
221234
acceptLanguage = builder.acceptLanguage;
222235
rawScores = builder.rawScores;
236+
csvHeaders = builder.csvHeaders;
223237
consumptionPreferences = builder.consumptionPreferences;
238+
contentType = builder.contentType;
224239
}
225240

226241
/**
@@ -258,19 +273,6 @@ public String body() {
258273
return body;
259274
}
260275

261-
/**
262-
* Gets the contentType.
263-
*
264-
* The type of the input. For more information, see **Content types** in the method description.
265-
*
266-
* Default: `text/plain`.
267-
*
268-
* @return the contentType
269-
*/
270-
public String contentType() {
271-
return contentType;
272-
}
273-
274276
/**
275277
* Gets the contentLanguage.
276278
*
@@ -315,6 +317,18 @@ public Boolean rawScores() {
315317
return rawScores;
316318
}
317319

320+
/**
321+
* Gets the csvHeaders.
322+
*
323+
* Indicates whether column labels are returned with a CSV response. By default, no column labels are returned.
324+
* Applies only when the response type is CSV (`text/csv`).
325+
*
326+
* @return the csvHeaders
327+
*/
328+
public Boolean csvHeaders() {
329+
return csvHeaders;
330+
}
331+
318332
/**
319333
* Gets the consumptionPreferences.
320334
*
@@ -326,4 +340,17 @@ public Boolean rawScores() {
326340
public Boolean consumptionPreferences() {
327341
return consumptionPreferences;
328342
}
343+
344+
/**
345+
* Gets the contentType.
346+
*
347+
* The type of the input. For more information, see **Content types** in the method description.
348+
*
349+
* Default: `text/plain`.
350+
*
351+
* @return the contentType
352+
*/
353+
public String contentType() {
354+
return contentType;
355+
}
329356
}

0 commit comments

Comments
 (0)