Skip to content

Commit eccdfe2

Browse files
committed
refactor(Visual Recognition v4): Regenerate with latest API definition
1 parent 259ae17 commit eccdfe2

17 files changed

Lines changed: 123 additions & 533 deletions

‎visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@
3232
import com.ibm.watson.visual_recognition.v3.model.GetCoreMlModelOptions;
3333
import com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions;
3434
import com.ibm.watson.visual_recognition.v3.model.UpdateClassifierOptions;
35-
import okhttp3.MultipartBody;
36-
3735
import java.io.InputStream;
3836
import java.util.Map;
3937
import java.util.Map.Entry;
38+
import okhttp3.MultipartBody;
4039

4140
/**
4241
* The IBM Watson™ Visual Recognition service uses deep learning algorithms to identify scenes and objects in
@@ -120,10 +119,14 @@ public ServiceCall<ClassifiedImages> classify(ClassifyOptions classifyOptions) {
120119
multipartBuilder.addFormDataPart("threshold", String.valueOf(classifyOptions.threshold()));
121120
}
122121
if (classifyOptions.owners() != null) {
123-
multipartBuilder.addFormDataPart("owners", RequestUtils.join(classifyOptions.owners(), ","));
122+
for (String item : classifyOptions.owners()) {
123+
multipartBuilder.addFormDataPart("owners", item);
124+
}
124125
}
125126
if (classifyOptions.classifierIds() != null) {
126-
multipartBuilder.addFormDataPart("classifier_ids", RequestUtils.join(classifyOptions.classifierIds(), ","));
127+
for (String item : classifyOptions.classifierIds()) {
128+
multipartBuilder.addFormDataPart("classifier_ids", item);
129+
}
127130
}
128131
builder.body(multipartBuilder.build());
129132
ResponseConverter<ClassifiedImages> responseConverter = ResponseConverterUtils.getValue(
@@ -262,9 +265,7 @@ public ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierO
262265
*
263266
* Update a custom classifier by adding new positive or negative classes or by adding new images to existing classes.
264267
* You must supply at least one set of positive or negative examples. For details, see [Updating custom
265-
* classifiers]
266-
* (https://cloud.ibm.com/docs/services/visual-recognition
267-
* ?topic=visual-recognition-customizing#updating-custom-classifiers).
268+
* classifiers](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-customizing#updating-custom-classifiers).
268269
*
269270
* Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class
270271
* names). The service assumes UTF-8 encoding if it encounters non-ASCII characters.

‎visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@
5656
* **Beta:** The Visual Recognition v4 API and Object Detection model are beta features. For more information about beta
5757
* features, see the [Release
5858
* notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-release-notes#beta).
59-
* {: important}
59+
* {: important}.
6060
*
6161
* @version v4
6262
* @see <a href=
63-
* "https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-object-detection-overview">
64-
* Visual
63+
* "https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-object-detection-overview">Visual
6564
* Recognition</a>
6665
*/
6766
public class VisualRecognition extends BaseService {
@@ -123,8 +122,12 @@ public ServiceCall<AnalyzeResponse> analyze(AnalyzeOptions analyzeOptions) {
123122
builder.header("Accept", "application/json");
124123
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
125124
multipartBuilder.setType(MultipartBody.FORM);
126-
multipartBuilder.addFormDataPart("collection_ids", RequestUtils.join(analyzeOptions.collectionIds(), ","));
127-
multipartBuilder.addFormDataPart("features", RequestUtils.join(analyzeOptions.features(), ","));
125+
for (String item : analyzeOptions.collectionIds()) {
126+
multipartBuilder.addFormDataPart("collection_ids", item);
127+
}
128+
for (String item : analyzeOptions.features()) {
129+
multipartBuilder.addFormDataPart("features", item);
130+
}
128131
if (analyzeOptions.imagesFile() != null) {
129132
for (FileWithMetadata item : analyzeOptions.imagesFile()) {
130133
okhttp3.RequestBody itemBody = RequestUtils.inputStreamBody(item.data(), item.contentType());
@@ -160,6 +163,8 @@ public ServiceCall<AnalyzeResponse> analyze(AnalyzeOptions analyzeOptions) {
160163
* @return a {@link ServiceCall} with a response type of {@link Collection}
161164
*/
162165
public ServiceCall<Collection> createCollection(CreateCollectionOptions createCollectionOptions) {
166+
com.ibm.cloud.sdk.core.util.Validator.notNull(createCollectionOptions,
167+
"createCollectionOptions cannot be null");
163168
String[] pathSegments = { "v4/collections" };
164169
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments));
165170
builder.query("version", versionDate);
@@ -169,13 +174,11 @@ public ServiceCall<Collection> createCollection(CreateCollectionOptions createCo
169174
}
170175
builder.header("Accept", "application/json");
171176
final JsonObject contentJson = new JsonObject();
172-
if (createCollectionOptions != null) {
173-
if (createCollectionOptions.name() != null) {
174-
contentJson.addProperty("name", createCollectionOptions.name());
175-
}
176-
if (createCollectionOptions.description() != null) {
177-
contentJson.addProperty("description", createCollectionOptions.description());
178-
}
177+
if (createCollectionOptions.name() != null) {
178+
contentJson.addProperty("name", createCollectionOptions.name());
179+
}
180+
if (createCollectionOptions.description() != null) {
181+
contentJson.addProperty("description", createCollectionOptions.description());
179182
}
180183
builder.bodyJson(contentJson);
181184
ResponseConverter<Collection> responseConverter = ResponseConverterUtils.getValue(

‎visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public class AddImageTrainingDataOptions extends GenericModel {
2424

2525
private String collectionId;
2626
private String imageId;
27-
private List<BaseObject> objects;
27+
private List<TrainingDataObject> objects;
2828

2929
/**
3030
* Builder.
3131
*/
3232
public static class Builder {
3333
private String collectionId;
3434
private String imageId;
35-
private List<BaseObject> objects;
35+
private List<TrainingDataObject> objects;
3636

3737
private Builder(AddImageTrainingDataOptions addImageTrainingDataOptions) {
3838
this.collectionId = addImageTrainingDataOptions.collectionId;
@@ -72,11 +72,11 @@ public AddImageTrainingDataOptions build() {
7272
* @param objects the new objects
7373
* @return the AddImageTrainingDataOptions builder
7474
*/
75-
public Builder addObjects(BaseObject objects) {
75+
public Builder addObjects(TrainingDataObject objects) {
7676
com.ibm.cloud.sdk.core.util.Validator.notNull(objects,
7777
"objects cannot be null");
7878
if (this.objects == null) {
79-
this.objects = new ArrayList<BaseObject>();
79+
this.objects = new ArrayList<TrainingDataObject>();
8080
}
8181
this.objects.add(objects);
8282
return this;
@@ -111,7 +111,7 @@ public Builder imageId(String imageId) {
111111
* @param objects the objects
112112
* @return the AddImageTrainingDataOptions builder
113113
*/
114-
public Builder objects(List<BaseObject> objects) {
114+
public Builder objects(List<TrainingDataObject> objects) {
115115
this.objects = objects;
116116
return this;
117117
}
@@ -165,7 +165,7 @@ public String imageId() {
165165
*
166166
* @return the objects
167167
*/
168-
public List<BaseObject> objects() {
168+
public List<TrainingDataObject> objects() {
169169
return objects;
170170
}
171171
}

‎visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
*/
2424
public class AnalyzeOptions extends GenericModel {
2525

26-
/**
27-
* The features to analyze. Separate multiple values with commas.
28-
*/
2926
public interface Features {
3027
/** objects. */
3128
String OBJECTS = "objects";
@@ -82,34 +79,34 @@ public AnalyzeOptions build() {
8279
}
8380

8481
/**
85-
* Adds a collectionId to collectionIds.
82+
* Adds an collectionIds to collectionIds.
8683
*
87-
* @param collectionId the new collectionId
84+
* @param collectionIds the new collectionIds
8885
* @return the AnalyzeOptions builder
8986
*/
90-
public Builder addCollectionId(String collectionId) {
91-
com.ibm.cloud.sdk.core.util.Validator.notNull(collectionId,
92-
"collectionId cannot be null");
87+
public Builder addCollectionIds(String collectionIds) {
88+
com.ibm.cloud.sdk.core.util.Validator.notNull(collectionIds,
89+
"collectionIds cannot be null");
9390
if (this.collectionIds == null) {
94-
this.collectionIds = new ArrayList<>();
91+
this.collectionIds = new ArrayList<String>();
9592
}
96-
this.collectionIds.add(collectionId);
93+
this.collectionIds.add(collectionIds);
9794
return this;
9895
}
9996

10097
/**
101-
* Adds a feature to features.
98+
* Adds an features to features.
10299
*
103-
* @param feature the new feature
100+
* @param features the new features
104101
* @return the AnalyzeOptions builder
105102
*/
106-
public Builder addFeature(String feature) {
107-
com.ibm.cloud.sdk.core.util.Validator.notNull(feature,
108-
"feature cannot be null");
103+
public Builder addFeatures(String features) {
104+
com.ibm.cloud.sdk.core.util.Validator.notNull(features,
105+
"features cannot be null");
109106
if (this.features == null) {
110-
this.features = new ArrayList<>();
107+
this.features = new ArrayList<String>();
111108
}
112-
this.features.add(feature);
109+
this.features.add(features);
113110
return this;
114111
}
115112

@@ -147,6 +144,7 @@ public Builder addImageUrl(String imageUrl) {
147144

148145
/**
149146
* Set the collectionIds.
147+
* Existing collectionIds will be replaced.
150148
*
151149
* @param collectionIds the collectionIds
152150
* @return the AnalyzeOptions builder
@@ -158,6 +156,7 @@ public Builder collectionIds(List<String> collectionIds) {
158156

159157
/**
160158
* Set the features.
159+
* Existing features will be replaced.
161160
*
162161
* @param features the features
163162
* @return the AnalyzeOptions builder
@@ -227,7 +226,7 @@ public Builder newBuilder() {
227226
/**
228227
* Gets the collectionIds.
229228
*
230-
* The IDs of the collections to analyze. Separate multiple values with commas.
229+
* The IDs of the collections to analyze.
231230
*
232231
* @return the collectionIds
233232
*/
@@ -238,7 +237,7 @@ public List<String> collectionIds() {
238237
/**
239238
* Gets the features.
240239
*
241-
* The features to analyze. Separate multiple values with commas.
240+
* The features to analyze.
242241
*
243242
* @return the features
244243
*/

‎visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class AnalyzeResponse extends GenericModel {
2323

2424
private List<Image> images;
25-
private List<BaseError> warnings;
25+
private List<Warning> warnings;
2626
private String trace;
2727

2828
/**
@@ -43,7 +43,7 @@ public List<Image> getImages() {
4343
*
4444
* @return the warnings
4545
*/
46-
public List<BaseError> getWarnings() {
46+
public List<Warning> getWarnings() {
4747
return warnings;
4848
}
4949

0 commit comments

Comments
 (0)