Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit c06a272

Browse files
authored
feat: add v1 client (#227)
1 parent 2926c88 commit c06a272

91 files changed

Lines changed: 39872 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google-cloud-servicedirectory-bom/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,21 @@
7171
<artifactId>grpc-google-cloud-servicedirectory-v1beta1</artifactId>
7272
<version>0.2.9-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-servicedirectory-v1beta1:current} -->
7373
</dependency>
74+
<dependency>
75+
<groupId>com.google.api.grpc</groupId>
76+
<artifactId>grpc-google-cloud-servicedirectory-v1</artifactId>
77+
<version>0.2.9-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-servicedirectory-v1:current} -->
78+
</dependency>
7479
<dependency>
7580
<groupId>com.google.api.grpc</groupId>
7681
<artifactId>proto-google-cloud-servicedirectory-v1beta1</artifactId>
7782
<version>0.2.9-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-servicedirectory-v1beta1:current} -->
7883
</dependency>
84+
<dependency>
85+
<groupId>com.google.api.grpc</groupId>
86+
<artifactId>proto-google-cloud-servicedirectory-v1</artifactId>
87+
<version>0.2.9-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-servicedirectory-v1:current} -->
88+
</dependency>
7989
</dependencies>
8090
</dependencyManagement>
8191

google-cloud-servicedirectory/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<groupId>com.google.api.grpc</groupId>
5151
<artifactId>proto-google-cloud-servicedirectory-v1beta1</artifactId>
5252
</dependency>
53+
<dependency>
54+
<groupId>com.google.api.grpc</groupId>
55+
<artifactId>proto-google-cloud-servicedirectory-v1</artifactId>
56+
</dependency>
5357
<dependency>
5458
<groupId>com.google.guava</groupId>
5559
<artifactId>guava</artifactId>
@@ -79,6 +83,11 @@
7983
<artifactId>grpc-google-cloud-servicedirectory-v1beta1</artifactId>
8084
<scope>test</scope>
8185
</dependency>
86+
<dependency>
87+
<groupId>com.google.api.grpc</groupId>
88+
<artifactId>grpc-google-cloud-servicedirectory-v1</artifactId>
89+
<scope>test</scope>
90+
</dependency>
8291
<!-- Need testing utility classes for generated gRPC clients tests -->
8392
<dependency>
8493
<groupId>com.google.api</groupId>
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.servicedirectory.v1;
17+
18+
import com.google.api.core.BetaApi;
19+
import com.google.api.gax.core.BackgroundResource;
20+
import com.google.api.gax.rpc.UnaryCallable;
21+
import com.google.cloud.servicedirectory.v1.stub.LookupServiceStub;
22+
import com.google.cloud.servicedirectory.v1.stub.LookupServiceStubSettings;
23+
import java.io.IOException;
24+
import java.util.concurrent.TimeUnit;
25+
import javax.annotation.Generated;
26+
27+
// AUTO-GENERATED DOCUMENTATION AND SERVICE
28+
/**
29+
* Service Description: Service Directory API for looking up service data at runtime.
30+
*
31+
* <p>This class provides the ability to make remote calls to the backing service through method
32+
* calls that map to API methods. Sample code to get started:
33+
*
34+
* <pre>
35+
* <code>
36+
* try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) {
37+
* ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
38+
* ResolveServiceRequest request = ResolveServiceRequest.newBuilder()
39+
* .setName(name.toString())
40+
* .build();
41+
* ResolveServiceResponse response = lookupServiceClient.resolveService(request);
42+
* }
43+
* </code>
44+
* </pre>
45+
*
46+
* <p>Note: close() needs to be called on the lookupServiceClient object to clean up resources such
47+
* as threads. In the example above, try-with-resources is used, which automatically calls close().
48+
*
49+
* <p>The surface of this class includes several types of Java methods for each of the API's
50+
* 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 as
55+
* 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 object,
57+
* which must be constructed before the call. Not every API method will have a request object
58+
* method.
59+
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
60+
* callable 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 with
66+
* these names, this class includes a format method for each type of name, and additionally a parse
67+
* method to extract the individual identifiers contained within names that are returned.
68+
*
69+
* <p>This class can be customized by passing in a custom instance of LookupServiceSettings to
70+
* create(). For example:
71+
*
72+
* <p>To customize credentials:
73+
*
74+
* <pre>
75+
* <code>
76+
* LookupServiceSettings lookupServiceSettings =
77+
* LookupServiceSettings.newBuilder()
78+
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
79+
* .build();
80+
* LookupServiceClient lookupServiceClient =
81+
* LookupServiceClient.create(lookupServiceSettings);
82+
* </code>
83+
* </pre>
84+
*
85+
* To customize the endpoint:
86+
*
87+
* <pre>
88+
* <code>
89+
* LookupServiceSettings lookupServiceSettings =
90+
* LookupServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
91+
* LookupServiceClient lookupServiceClient =
92+
* LookupServiceClient.create(lookupServiceSettings);
93+
* </code>
94+
* </pre>
95+
*/
96+
@Generated("by gapic-generator")
97+
@BetaApi
98+
public class LookupServiceClient implements BackgroundResource {
99+
private final LookupServiceSettings settings;
100+
private final LookupServiceStub stub;
101+
102+
/** Constructs an instance of LookupServiceClient with default settings. */
103+
public static final LookupServiceClient create() throws IOException {
104+
return create(LookupServiceSettings.newBuilder().build());
105+
}
106+
107+
/**
108+
* Constructs an instance of LookupServiceClient, using the given settings. The channels are
109+
* created based on the settings passed in, or defaults for any settings that are not set.
110+
*/
111+
public static final LookupServiceClient create(LookupServiceSettings settings)
112+
throws IOException {
113+
return new LookupServiceClient(settings);
114+
}
115+
116+
/**
117+
* Constructs an instance of LookupServiceClient, using the given stub for making calls. This is
118+
* for advanced usage - prefer to use LookupServiceSettings}.
119+
*/
120+
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
121+
public static final LookupServiceClient create(LookupServiceStub stub) {
122+
return new LookupServiceClient(stub);
123+
}
124+
125+
/**
126+
* Constructs an instance of LookupServiceClient, using the given settings. This is protected so
127+
* that it is easy to make a subclass, but otherwise, the static factory methods should be
128+
* preferred.
129+
*/
130+
protected LookupServiceClient(LookupServiceSettings settings) throws IOException {
131+
this.settings = settings;
132+
this.stub = ((LookupServiceStubSettings) settings.getStubSettings()).createStub();
133+
}
134+
135+
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
136+
protected LookupServiceClient(LookupServiceStub stub) {
137+
this.settings = null;
138+
this.stub = stub;
139+
}
140+
141+
public final LookupServiceSettings getSettings() {
142+
return settings;
143+
}
144+
145+
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
146+
public LookupServiceStub getStub() {
147+
return stub;
148+
}
149+
150+
// AUTO-GENERATED DOCUMENTATION AND METHOD
151+
/**
152+
* Returns a [service][google.cloud.servicedirectory.v1.Service] and its associated endpoints.
153+
* Resolving a service is not considered an active developer method.
154+
*
155+
* <p>Sample code:
156+
*
157+
* <pre><code>
158+
* try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) {
159+
* ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
160+
* ResolveServiceRequest request = ResolveServiceRequest.newBuilder()
161+
* .setName(name.toString())
162+
* .build();
163+
* ResolveServiceResponse response = lookupServiceClient.resolveService(request);
164+
* }
165+
* </code></pre>
166+
*
167+
* @param request The request object containing all of the parameters for the API call.
168+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
169+
*/
170+
public final ResolveServiceResponse resolveService(ResolveServiceRequest request) {
171+
return resolveServiceCallable().call(request);
172+
}
173+
174+
// AUTO-GENERATED DOCUMENTATION AND METHOD
175+
/**
176+
* Returns a [service][google.cloud.servicedirectory.v1.Service] and its associated endpoints.
177+
* Resolving a service is not considered an active developer method.
178+
*
179+
* <p>Sample code:
180+
*
181+
* <pre><code>
182+
* try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) {
183+
* ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
184+
* ResolveServiceRequest request = ResolveServiceRequest.newBuilder()
185+
* .setName(name.toString())
186+
* .build();
187+
* ApiFuture&lt;ResolveServiceResponse&gt; future = lookupServiceClient.resolveServiceCallable().futureCall(request);
188+
* // Do something
189+
* ResolveServiceResponse response = future.get();
190+
* }
191+
* </code></pre>
192+
*/
193+
public final UnaryCallable<ResolveServiceRequest, ResolveServiceResponse>
194+
resolveServiceCallable() {
195+
return stub.resolveServiceCallable();
196+
}
197+
198+
@Override
199+
public final void close() {
200+
stub.close();
201+
}
202+
203+
@Override
204+
public void shutdown() {
205+
stub.shutdown();
206+
}
207+
208+
@Override
209+
public boolean isShutdown() {
210+
return stub.isShutdown();
211+
}
212+
213+
@Override
214+
public boolean isTerminated() {
215+
return stub.isTerminated();
216+
}
217+
218+
@Override
219+
public void shutdownNow() {
220+
stub.shutdownNow();
221+
}
222+
223+
@Override
224+
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
225+
return stub.awaitTermination(duration, unit);
226+
}
227+
}

0 commit comments

Comments
 (0)