Skip to content

Commit bc13e46

Browse files
garrettjonesgooglemziccard
authored andcommitted
Initial auto-generated gcloud-java-vision (#1174)
1 parent 14c7711 commit bc13e46

9 files changed

Lines changed: 886 additions & 1 deletion

File tree

gcloud-java-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<dependency>
107107
<groupId>com.google.api</groupId>
108108
<artifactId>gax</artifactId>
109-
<version>0.0.14</version>
109+
<version>0.0.16</version>
110110
</dependency>
111111
<dependency>
112112
<groupId>com.google.api.grpc</groupId>

gcloud-java-vision/pom.xml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>gcloud-java-vision</artifactId>
5+
<packaging>jar</packaging>
6+
<name>GCloud Java Vision</name>
7+
<url>https://github.com/GoogleCloudPlatform/gcloud-java/tree/master/gcloud-java-vision</url>
8+
<description>
9+
Java idiomatic client for Google Cloud Vision API.
10+
</description>
11+
<parent>
12+
<groupId>com.google.cloud</groupId>
13+
<artifactId>gcloud-java-pom</artifactId>
14+
<version>0.2.9-SNAPSHOT</version>
15+
</parent>
16+
<properties>
17+
<site.installationModule>gcloud-java-vision</site.installationModule>
18+
</properties>
19+
<dependencies>
20+
<dependency>
21+
<groupId>io.netty</groupId>
22+
<artifactId>netty-tcnative-boringssl-static</artifactId>
23+
<version>1.1.33.Fork17</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>${project.groupId}</groupId>
27+
<artifactId>gcloud-java-core</artifactId>
28+
<version>${project.version}</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>com.google.api.grpc</groupId>
32+
<artifactId>grpc-google-cloud-vision-v1</artifactId>
33+
<version>0.0.7</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>io.grpc</groupId>
37+
<artifactId>grpc-all</artifactId>
38+
<version>0.15.0</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.google.auto.value</groupId>
42+
<artifactId>auto-value</artifactId>
43+
<version>1.1</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>${project.groupId}</groupId>
47+
<artifactId>gcloud-java-core</artifactId>
48+
<version>${project.version}</version>
49+
<type>test-jar</type>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>junit</groupId>
54+
<artifactId>junit</artifactId>
55+
<version>4.12</version>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.easymock</groupId>
60+
<artifactId>easymock</artifactId>
61+
<version>3.4</version>
62+
<scope>test</scope>
63+
</dependency>
64+
</dependencies>
65+
<profiles>
66+
<profile>
67+
<id>doclint-java8-disable</id>
68+
<activation>
69+
<jdk>[1.8,)</jdk>
70+
</activation>
71+
<properties>
72+
<!-- add this to disable checking -->
73+
<javadoc.opts>-Xdoclint:none</javadoc.opts>
74+
</properties>
75+
</profile>
76+
</profiles>
77+
<build>
78+
<plugins>
79+
<plugin>
80+
<groupId>org.codehaus.mojo</groupId>
81+
<artifactId>build-helper-maven-plugin</artifactId>
82+
<version>1.9.1</version>
83+
<executions>
84+
<execution>
85+
<phase>generate-sources</phase>
86+
<goals><goal>add-source</goal></goals>
87+
<configuration>
88+
<sources>
89+
<source>generated/src/main/java</source>
90+
</sources>
91+
</configuration>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-javadoc-plugin</artifactId>
98+
<version>2.10.3</version>
99+
<executions>
100+
<execution>
101+
<id>attach-javadocs</id>
102+
<goals>
103+
<goal>jar</goal>
104+
</goals>
105+
<configuration>
106+
<additionalparam>${javadoc.opts}</additionalparam>
107+
</configuration>
108+
</execution>
109+
</executions>
110+
</plugin>
111+
<plugin>
112+
<artifactId>maven-compiler-plugin</artifactId>
113+
<!-- Downgrading to 3.1 because of https://issues.apache.org/jira/browse/MCOMPILER-236 -->
114+
<!-- Upgrade to 3.5.1 which fixes the problem when available -->
115+
<!-- <version>3.5.1</version> -->
116+
<version>3.1</version>
117+
<configuration>
118+
<source>1.7</source>
119+
<target>1.7</target>
120+
<encoding>UTF-8</encoding>
121+
<compilerArgument>-Xlint:unchecked</compilerArgument>
122+
</configuration>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
</project>
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/*
2+
* Copyright 2016 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.google.cloud.vision.spi.v1;
15+
16+
import com.google.api.gax.grpc.ApiCallable;
17+
import com.google.api.gax.protobuf.PathTemplate;
18+
import com.google.cloud.vision.v1.AnnotateImageRequest;
19+
import com.google.cloud.vision.v1.BatchAnnotateImagesRequest;
20+
import com.google.cloud.vision.v1.BatchAnnotateImagesResponse;
21+
import io.grpc.ManagedChannel;
22+
import java.io.Closeable;
23+
import java.io.IOException;
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
import java.util.concurrent.ScheduledExecutorService;
27+
28+
// AUTO-GENERATED DOCUMENTATION AND SERVICE
29+
/**
30+
* Service Description: Service that performs Google Cloud Vision API detection tasks, such as face,
31+
* landmark, logo, label, and text detection, over client images, and returns
32+
* detected entities from the images.
33+
*
34+
* <p>This class provides the ability to make remote calls to the backing service through method
35+
* calls that map to API methods. Sample code to get started:
36+
*
37+
* <pre>
38+
* <code>
39+
* try (ImageAnnotatorApi imageAnnotatorApi = ImageAnnotatorApi.create()) {
40+
* List&lt;AnnotateImageRequest&gt; requests = new ArrayList&lt;&gt;();
41+
* BatchAnnotateImagesResponse response = imageAnnotatorApi.batchAnnotateImages(requests);
42+
* }
43+
* </code>
44+
* </pre>
45+
*
46+
* <p>Note: close() needs to be called on the imageAnnotatorApi object to clean up resources such
47+
* as threads. In the example above, try-with-resources is used, which automatically calls
48+
* close().
49+
*
50+
* <p>The surface of this class includes several types of Java methods for each of the API's methods:
51+
*
52+
* <ol>
53+
* <li> A "flattened" method. With this type of method, the fields of the request type have been
54+
* converted into function parameters. It may be the case that not all fields are available
55+
* as parameters, and not every API method will have a flattened method entry point.
56+
* <li> A "request object" method. This type of method only takes one parameter, a request
57+
* object, which must be constructed before the call. Not every API method will have a request
58+
* object method.
59+
* <li> A "callable" method. This type of method takes no parameters and returns an immutable
60+
* ApiCallable object, which can be used to initiate calls to the service.
61+
* </ol>
62+
*
63+
* <p>See the individual methods for example code.
64+
*
65+
* <p>Many parameters require resource names to be formatted in a particular way. To assist
66+
* with these names, this class includes a format method for each type of name, and additionally
67+
* a parse method to extract the individual identifiers contained within names that are
68+
* returned.
69+
*
70+
* <p>This class can be customized by passing in a custom instance of ImageAnnotatorSettings to
71+
* create(). For example:
72+
*
73+
* <pre>
74+
* <code>
75+
* ImageAnnotatorSettings imageAnnotatorSettings = ImageAnnotatorSettings.defaultBuilder()
76+
* .provideChannelWith(myCredentials)
77+
* .build();
78+
* ImageAnnotatorApi imageAnnotatorApi = ImageAnnotatorApi.create(imageAnnotatorSettings);
79+
* </code>
80+
* </pre>
81+
*/
82+
@javax.annotation.Generated("by GAPIC")
83+
public class ImageAnnotatorApi implements AutoCloseable {
84+
private final ImageAnnotatorSettings settings;
85+
private final ManagedChannel channel;
86+
private final ScheduledExecutorService executor;
87+
private final List<AutoCloseable> closeables = new ArrayList<>();
88+
89+
private final ApiCallable<BatchAnnotateImagesRequest, BatchAnnotateImagesResponse>
90+
batchAnnotateImagesCallable;
91+
92+
public final ImageAnnotatorSettings getSettings() {
93+
return settings;
94+
}
95+
96+
/**
97+
* Constructs an instance of ImageAnnotatorApi with default settings.
98+
*/
99+
public static final ImageAnnotatorApi create() throws IOException {
100+
return create(ImageAnnotatorSettings.defaultBuilder().build());
101+
}
102+
103+
/**
104+
* Constructs an instance of ImageAnnotatorApi, using the given settings.
105+
* The channels are created based on the settings passed in, or defaults for any
106+
* settings that are not set.
107+
*/
108+
public static final ImageAnnotatorApi create(ImageAnnotatorSettings settings) throws IOException {
109+
return new ImageAnnotatorApi(settings);
110+
}
111+
112+
/**
113+
* Constructs an instance of ImageAnnotatorApi, using the given settings.
114+
* This is protected so that it easy to make a subclass, but otherwise, the static
115+
* factory methods should be preferred.
116+
*/
117+
protected ImageAnnotatorApi(ImageAnnotatorSettings settings) throws IOException {
118+
this.settings = settings;
119+
this.executor = settings.getExecutorProvider().getOrBuildExecutor();
120+
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
121+
122+
this.batchAnnotateImagesCallable =
123+
ApiCallable.create(settings.batchAnnotateImagesSettings(), this.channel, this.executor);
124+
125+
if (settings.getChannelProvider().shouldAutoClose()) {
126+
closeables.add(
127+
new Closeable() {
128+
@Override
129+
public void close() throws IOException {
130+
channel.shutdown();
131+
}
132+
});
133+
}
134+
if (settings.getExecutorProvider().shouldAutoClose()) {
135+
closeables.add(
136+
new Closeable() {
137+
@Override
138+
public void close() throws IOException {
139+
executor.shutdown();
140+
}
141+
});
142+
}
143+
}
144+
145+
// AUTO-GENERATED DOCUMENTATION AND METHOD
146+
/**
147+
* Run image detection and annotation for a batch of images.
148+
*
149+
* Sample code:
150+
* <pre><code>
151+
* try (ImageAnnotatorApi imageAnnotatorApi = ImageAnnotatorApi.create()) {
152+
* List&lt;AnnotateImageRequest&gt; requests = new ArrayList&lt;&gt;();
153+
* BatchAnnotateImagesResponse response = imageAnnotatorApi.batchAnnotateImages(requests);
154+
* }
155+
* </code></pre>
156+
*
157+
* @param requests Individual image annotation requests for this batch.
158+
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
159+
*/
160+
public final BatchAnnotateImagesResponse batchAnnotateImages(
161+
List<AnnotateImageRequest> requests) {
162+
BatchAnnotateImagesRequest request =
163+
BatchAnnotateImagesRequest.newBuilder().addAllRequests(requests).build();
164+
return batchAnnotateImages(request);
165+
}
166+
167+
// AUTO-GENERATED DOCUMENTATION AND METHOD
168+
/**
169+
* Run image detection and annotation for a batch of images.
170+
*
171+
* Sample code:
172+
* <pre><code>
173+
* try (ImageAnnotatorApi imageAnnotatorApi = ImageAnnotatorApi.create()) {
174+
* List&lt;AnnotateImageRequest&gt; requests = new ArrayList&lt;&gt;();
175+
* BatchAnnotateImagesRequest request = BatchAnnotateImagesRequest.newBuilder()
176+
* .addAllRequests(requests)
177+
* .build();
178+
* BatchAnnotateImagesResponse response = imageAnnotatorApi.batchAnnotateImages(request);
179+
* }
180+
* </code></pre>
181+
*
182+
* @param request The request object containing all of the parameters for the API call.
183+
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
184+
*/
185+
private final BatchAnnotateImagesResponse batchAnnotateImages(
186+
BatchAnnotateImagesRequest request) {
187+
return batchAnnotateImagesCallable().call(request);
188+
}
189+
190+
// AUTO-GENERATED DOCUMENTATION AND METHOD
191+
/**
192+
* Run image detection and annotation for a batch of images.
193+
*
194+
* Sample code:
195+
* <pre><code>
196+
* try (ImageAnnotatorApi imageAnnotatorApi = ImageAnnotatorApi.create()) {
197+
* List&lt;AnnotateImageRequest&gt; requests = new ArrayList&lt;&gt;();
198+
* BatchAnnotateImagesRequest request = BatchAnnotateImagesRequest.newBuilder()
199+
* .addAllRequests(requests)
200+
* .build();
201+
* ListenableFuture&lt;BatchAnnotateImagesResponse&gt; future = imageAnnotatorApi.batchAnnotateImagesCallable().futureCall(request);
202+
* // Do something
203+
* BatchAnnotateImagesResponse response = future.get();
204+
* }
205+
* </code></pre>
206+
*/
207+
public final ApiCallable<BatchAnnotateImagesRequest, BatchAnnotateImagesResponse>
208+
batchAnnotateImagesCallable() {
209+
return batchAnnotateImagesCallable;
210+
}
211+
212+
/**
213+
* Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
214+
* cancelled.
215+
*/
216+
@Override
217+
public final void close() throws Exception {
218+
for (AutoCloseable closeable : closeables) {
219+
closeable.close();
220+
}
221+
}
222+
}

0 commit comments

Comments
 (0)