Skip to content

Commit

Permalink
feat(visual-recognition): generated code
Browse files Browse the repository at this point in the history
chore(visual-recognition): manual changes

chore(visual-recognition): manual changes

chore(visual-recognition): manual changes
  • Loading branch information
germanattanasio committed Feb 24, 2020
1 parent a753857 commit 8d16bf3
Show file tree
Hide file tree
Showing 69 changed files with 940 additions and 93 deletions.
6 changes: 4 additions & 2 deletions visual-recognition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Installation

##### Maven

```xml
<dependency>
<groupId>com.ibm.watson</groupId>
Expand All @@ -12,11 +13,13 @@
```

##### Gradle

```gradle
'com.ibm.watson:visual-recognition:8.2.1'
```

## Usage

Use the [Visual Recognition][visual_recognition] service to analyze image data. Use either v3 or v4 to analyze the following image:

![Dog](https://visual-recognition-demo.ng.bluemix.net/images/samples/5.jpg)
Expand Down Expand Up @@ -102,5 +105,4 @@ AnalyzeResponse response = service.analyze(options).execute().getResult();
System.out.println(response);
```


[visual_recognition]: https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-getting-started-tutorial
[visual_recognition]: https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-getting-started-tutorial
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2016, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -43,7 +43,7 @@
* your needs.
*
* @version v3
* @see <a href="https://cloud.ibm.com/docs/services/visual-recognition/">Visual Recognition</a>
* @see <a href="https://cloud.ibm.com/docs/visual-recognition/">Visual Recognition</a>
*/
public class VisualRecognition extends BaseService {

Expand Down Expand Up @@ -290,7 +290,7 @@ public ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierO
* Update a custom classifier by adding new positive or negative classes or by adding new images to existing classes.
* You must supply at least one set of positive or negative examples. For details, see [Updating custom
* classifiers]
* (https://cloud.ibm.com/docs/services/visual-recognition
* (https://cloud.ibm.com/docs/visual-recognition
* ?topic=visual-recognition-customizing#updating-custom-classifiers).
*
* Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class
Expand Down Expand Up @@ -406,7 +406,7 @@ public ServiceCall<InputStream> getCoreMlModel(GetCoreMlModelOptions getCoreMlMo
*
* You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes data.
* For more information about personal data and customer IDs, see [Information
* security](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-information-security).
* security](https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-information-security).
*
* @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
Expand All @@ -426,5 +426,4 @@ public ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOpti
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -32,20 +32,27 @@
import com.ibm.watson.visual_recognition.v4.model.CreateCollectionOptions;
import com.ibm.watson.visual_recognition.v4.model.DeleteCollectionOptions;
import com.ibm.watson.visual_recognition.v4.model.DeleteImageOptions;
import com.ibm.watson.visual_recognition.v4.model.DeleteObjectOptions;
import com.ibm.watson.visual_recognition.v4.model.DeleteUserDataOptions;
import com.ibm.watson.visual_recognition.v4.model.GetCollectionOptions;
import com.ibm.watson.visual_recognition.v4.model.GetImageDetailsOptions;
import com.ibm.watson.visual_recognition.v4.model.GetJpegImageOptions;
import com.ibm.watson.visual_recognition.v4.model.GetObjectMetadataOptions;
import com.ibm.watson.visual_recognition.v4.model.GetTrainingUsageOptions;
import com.ibm.watson.visual_recognition.v4.model.ImageDetails;
import com.ibm.watson.visual_recognition.v4.model.ImageDetailsList;
import com.ibm.watson.visual_recognition.v4.model.ImageSummaryList;
import com.ibm.watson.visual_recognition.v4.model.ListCollectionsOptions;
import com.ibm.watson.visual_recognition.v4.model.ListImagesOptions;
import com.ibm.watson.visual_recognition.v4.model.ListObjectMetadataOptions;
import com.ibm.watson.visual_recognition.v4.model.ObjectMetadata;
import com.ibm.watson.visual_recognition.v4.model.ObjectMetadataList;
import com.ibm.watson.visual_recognition.v4.model.TrainOptions;
import com.ibm.watson.visual_recognition.v4.model.TrainingDataObjects;
import com.ibm.watson.visual_recognition.v4.model.TrainingEvents;
import com.ibm.watson.visual_recognition.v4.model.UpdateCollectionOptions;
import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadata;
import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadataOptions;
import java.io.InputStream;
import java.util.Map;
import java.util.Map.Entry;
Expand All @@ -57,8 +64,7 @@
*
* @version v4
* @see <a href=
* "https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-object-detection-overview">
* Visual
* "https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-object-detection-overview">Visual
* Recognition</a>
*/
public class VisualRecognition extends BaseService {
Expand Down Expand Up @@ -147,6 +153,7 @@ public ServiceCall<AnalyzeResponse> analyze(AnalyzeOptions analyzeOptions) {
multipartBuilder.setType(MultipartBody.FORM);
multipartBuilder.addFormDataPart("collection_ids", RequestUtils.join(analyzeOptions.collectionIds(), ","));
multipartBuilder.addFormDataPart("features", RequestUtils.join(analyzeOptions.features(), ","));

if (analyzeOptions.imagesFile() != null) {
for (FileWithMetadata item : analyzeOptions.imagesFile()) {
okhttp3.RequestBody itemBody = RequestUtils.inputStreamBody(item.data(), item.contentType());
Expand Down Expand Up @@ -182,6 +189,8 @@ public ServiceCall<AnalyzeResponse> analyze(AnalyzeOptions analyzeOptions) {
* @return a {@link ServiceCall} with a response type of {@link Collection}
*/
public ServiceCall<Collection> createCollection(CreateCollectionOptions createCollectionOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createCollectionOptions,
"createCollectionOptions cannot be null");
String[] pathSegments = { "v4/collections" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments));
builder.query("version", versionDate);
Expand Down Expand Up @@ -511,6 +520,120 @@ public ServiceCall<InputStream> getJpegImage(GetJpegImageOptions getJpegImageOpt
return createServiceCall(builder.build(), responseConverter);
}

/**
* List object metadata.
*
* Retrieves a list of object names in a collection.
*
* @param listObjectMetadataOptions the {@link ListObjectMetadataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link ObjectMetadataList}
*/
public ServiceCall<ObjectMetadataList> listObjectMetadata(ListObjectMetadataOptions listObjectMetadataOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listObjectMetadataOptions,
"listObjectMetadataOptions cannot be null");
String[] pathSegments = { "v4/collections", "objects" };
String[] pathParameters = { listObjectMetadataOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listObjectMetadata");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");

ResponseConverter<ObjectMetadataList> responseConverter = ResponseConverterUtils.getValue(
new com.google.gson.reflect.TypeToken<ObjectMetadataList>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}

/**
* Update an object name.
*
* Update the name of an object. A successful request updates the training data for all images that use the object.
*
* @param updateObjectMetadataOptions the {@link UpdateObjectMetadataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link UpdateObjectMetadata}
*/
public ServiceCall<UpdateObjectMetadata> updateObjectMetadata(
UpdateObjectMetadataOptions updateObjectMetadataOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateObjectMetadataOptions,
"updateObjectMetadataOptions cannot be null");
String[] pathSegments = { "v4/collections", "objects" };
String[] pathParameters = { updateObjectMetadataOptions.collectionId(), updateObjectMetadataOptions.object() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "updateObjectMetadata");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("object", updateObjectMetadataOptions.newObject());
builder.bodyJson(contentJson);
ResponseConverter<UpdateObjectMetadata> responseConverter = ResponseConverterUtils.getValue(
new com.google.gson.reflect.TypeToken<UpdateObjectMetadata>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}

/**
* Get object metadata.
*
* Get the number of bounding boxes for a single object in a collection.
*
* @param getObjectMetadataOptions the {@link GetObjectMetadataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link ObjectMetadata}
*/
public ServiceCall<ObjectMetadata> getObjectMetadata(GetObjectMetadataOptions getObjectMetadataOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getObjectMetadataOptions,
"getObjectMetadataOptions cannot be null");
String[] pathSegments = { "v4/collections", "objects" };
String[] pathParameters = { getObjectMetadataOptions.collectionId(), getObjectMetadataOptions.object() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getObjectMetadata");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");

ResponseConverter<ObjectMetadata> responseConverter = ResponseConverterUtils.getValue(
new com.google.gson.reflect.TypeToken<ObjectMetadata>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}

/**
* Delete an object.
*
* Delete one object from a collection. A successful request deletes the training data from all images that use the
* object.
*
* @param deleteObjectOptions the {@link DeleteObjectOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteObject(DeleteObjectOptions deleteObjectOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteObjectOptions,
"deleteObjectOptions cannot be null");
String[] pathSegments = { "v4/collections", "objects" };
String[] pathParameters = { deleteObjectOptions.collectionId(), deleteObjectOptions.object() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteObject");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");

ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}

/**
* Train a collection.
*
Expand Down Expand Up @@ -634,7 +757,7 @@ public ServiceCall<TrainingEvents> getTrainingUsage() {
*
* You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes data.
* For more information about personal data and customer IDs, see [Information
* security](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-information-security).
* security](https://cloud.ibm.com/docs/visual-recognition?topic=visual-recognition-information-security).
*
* @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Loading

0 comments on commit 8d16bf3

Please sign in to comment.