diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java index b13cee07f15..22aba69a853 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java @@ -36,6 +36,7 @@ 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.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; @@ -43,6 +44,7 @@ import com.ibm.watson.visual_recognition.v4.model.ListImagesOptions; 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 java.io.InputStream; import java.util.Map; @@ -53,11 +55,6 @@ * Provide images to the IBM Watson™ Visual Recognition service for analysis. The service detects objects based on * a set of images with training data. * - * **Beta:** The Visual Recognition v4 API and Object Detection model are beta features. For more information about beta - * features, see the [Release - * notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-release-notes#beta). - * {: important}. - * * @version v4 * @see @@ -560,6 +557,50 @@ public ServiceCall addImageTrainingData( return createServiceCall(builder.build(), responseConverter); } + /** + * Get training usage. + * + * Information about the completed training events. You can use this information to determine how close you are to the + * training limits for the month. + * + * @param getTrainingUsageOptions the {@link GetTrainingUsageOptions} containing the options for the call + * @return a {@link ServiceCall} with a response type of {@link TrainingEvents} + */ + public ServiceCall getTrainingUsage(GetTrainingUsageOptions getTrainingUsageOptions) { + String[] pathSegments = { "v4/training_usage" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + builder.query("version", versionDate); + Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getTrainingUsage"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (getTrainingUsageOptions != null) { + if (getTrainingUsageOptions.startTime() != null) { + builder.query("start_time", String.valueOf(getTrainingUsageOptions.startTime())); + } + if (getTrainingUsageOptions.endTime() != null) { + builder.query("end_time", String.valueOf(getTrainingUsageOptions.endTime())); + } + } + ResponseConverter responseConverter = ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() { + }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get training usage. + * + * Information about the completed training events. You can use this information to determine how close you are to the + * training limits for the month. + * + * @return a {@link ServiceCall} with a response type of {@link TrainingEvents} + */ + public ServiceCall getTrainingUsage() { + return getTrainingUsage(null); + } + /** * Delete labeled data. * diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java new file mode 100644 index 00000000000..e34d47ee033 --- /dev/null +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java @@ -0,0 +1,113 @@ +/* + * (C) Copyright IBM Corp. 2019. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.visual_recognition.v4.model; + +import java.util.Date; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getTrainingUsage options. + */ +public class GetTrainingUsageOptions extends GenericModel { + + private Date startTime; + private Date endTime; + + /** + * Builder. + */ + public static class Builder { + private Date startTime; + private Date endTime; + + private Builder(GetTrainingUsageOptions getTrainingUsageOptions) { + this.startTime = getTrainingUsageOptions.startTime; + this.endTime = getTrainingUsageOptions.endTime; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetTrainingUsageOptions. + * + * @return the getTrainingUsageOptions + */ + public GetTrainingUsageOptions build() { + return new GetTrainingUsageOptions(this); + } + + /** + * Set the startTime. + * + * @param startTime the startTime + * @return the GetTrainingUsageOptions builder + */ + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Set the endTime. + * + * @param endTime the endTime + * @return the GetTrainingUsageOptions builder + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + } + + private GetTrainingUsageOptions(Builder builder) { + startTime = builder.startTime; + endTime = builder.endTime; + } + + /** + * New builder. + * + * @return a GetTrainingUsageOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the startTime. + * + * The earliest day to include training events. If empty or not specified, the earliest training event is included. + * + * @return the startTime + */ + public Date startTime() { + return startTime; + } + + /** + * Gets the endTime. + * + * The most recent day to include training events. All events for the day are included. If empty or not specified, the + * current day is used. Specify the same value as `start_time` to request events for a single day. + * + * @return the endTime + */ + public Date endTime() { + return endTime; + } +} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java new file mode 100644 index 00000000000..30175a5cdce --- /dev/null +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java @@ -0,0 +1,106 @@ +/* + * (C) Copyright IBM Corp. 2019. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.visual_recognition.v4.model; + +import java.util.Date; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Details about the training event. + */ +public class TrainingEvent extends GenericModel { + + /** + * Trained object type. Only `objects` is currently supported. + */ + public interface Type { + /** objects. */ + String OBJECTS = "objects"; + } + + /** + * Training status of the training event. + */ + public interface Status { + /** failed. */ + String FAILED = "failed"; + /** succeeded. */ + String SUCCEEDED = "succeeded"; + } + + private String type; + @SerializedName("collection_id") + private String collectionId; + @SerializedName("completion_time") + private Date completionTime; + private String status; + @SerializedName("image_count") + private Long imageCount; + + /** + * Gets the type. + * + * Trained object type. Only `objects` is currently supported. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the collectionId. + * + * Identifier of the trained collection. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * Gets the completionTime. + * + * Date and time in Coordinated Universal Time (UTC) that training on the collection finished. + * + * @return the completionTime + */ + public Date getCompletionTime() { + return completionTime; + } + + /** + * Gets the status. + * + * Training status of the training event. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the imageCount. + * + * The total number of images that were used in training for this training event. + * + * @return the imageCount + */ + public Long getImageCount() { + return imageCount; + } +} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java new file mode 100644 index 00000000000..627fd7fa703 --- /dev/null +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java @@ -0,0 +1,92 @@ +/* + * (C) Copyright IBM Corp. 2019. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.visual_recognition.v4.model; + +import java.util.Date; +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Details about the training events. + */ +public class TrainingEvents extends GenericModel { + + @SerializedName("start_time") + private Date startTime; + @SerializedName("end_time") + private Date endTime; + @SerializedName("completed_events") + private Long completedEvents; + @SerializedName("trained_images") + private Long trainedImages; + private List events; + + /** + * Gets the startTime. + * + * The starting day for the returned training events in Coordinated Universal Time (UTC). If not specified in the + * request, it identifies the earliest training event. + * + * @return the startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * Gets the endTime. + * + * The ending day for the returned training events in Coordinated Universal Time (UTC). If not specified in the + * request, it lists the current time. + * + * @return the endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * Gets the completedEvents. + * + * The total number of training events in the response for the start and end times. + * + * @return the completedEvents + */ + public Long getCompletedEvents() { + return completedEvents; + } + + /** + * Gets the trainedImages. + * + * The total number of images that were used in training for the start and end times. + * + * @return the trainedImages + */ + public Long getTrainedImages() { + return trainedImages; + } + + /** + * Gets the events. + * + * The completed training events for the start and end time. + * + * @return the events + */ + public List getEvents() { + return events; + } +}