This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
/
GrpcTagValuesStub.java
441 lines (401 loc) · 19.8 KB
/
GrpcTagValuesStub.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/*
* Copyright 2021 Google LLC
*
* 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
*
* https://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.google.cloud.resourcemanager.v3.stub;
import static com.google.cloud.resourcemanager.v3.TagValuesClient.ListTagValuesPagedResponse;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.resourcemanager.v3.CreateTagValueMetadata;
import com.google.cloud.resourcemanager.v3.CreateTagValueRequest;
import com.google.cloud.resourcemanager.v3.DeleteTagValueMetadata;
import com.google.cloud.resourcemanager.v3.DeleteTagValueRequest;
import com.google.cloud.resourcemanager.v3.GetTagValueRequest;
import com.google.cloud.resourcemanager.v3.ListTagValuesRequest;
import com.google.cloud.resourcemanager.v3.ListTagValuesResponse;
import com.google.cloud.resourcemanager.v3.TagValue;
import com.google.cloud.resourcemanager.v3.UpdateTagValueMetadata;
import com.google.cloud.resourcemanager.v3.UpdateTagValueRequest;
import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* gRPC stub implementation for the TagValues service API.
*
* <p>This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class GrpcTagValuesStub extends TagValuesStub {
private static final MethodDescriptor<ListTagValuesRequest, ListTagValuesResponse>
listTagValuesMethodDescriptor =
MethodDescriptor.<ListTagValuesRequest, ListTagValuesResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/ListTagValues")
.setRequestMarshaller(
ProtoUtils.marshaller(ListTagValuesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListTagValuesResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor<GetTagValueRequest, TagValue> getTagValueMethodDescriptor =
MethodDescriptor.<GetTagValueRequest, TagValue>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/GetTagValue")
.setRequestMarshaller(ProtoUtils.marshaller(GetTagValueRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(TagValue.getDefaultInstance()))
.build();
private static final MethodDescriptor<CreateTagValueRequest, Operation>
createTagValueMethodDescriptor =
MethodDescriptor.<CreateTagValueRequest, Operation>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/CreateTagValue")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateTagValueRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor<UpdateTagValueRequest, Operation>
updateTagValueMethodDescriptor =
MethodDescriptor.<UpdateTagValueRequest, Operation>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/UpdateTagValue")
.setRequestMarshaller(
ProtoUtils.marshaller(UpdateTagValueRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor<DeleteTagValueRequest, Operation>
deleteTagValueMethodDescriptor =
MethodDescriptor.<DeleteTagValueRequest, Operation>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/DeleteTagValue")
.setRequestMarshaller(
ProtoUtils.marshaller(DeleteTagValueRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor<GetIamPolicyRequest, Policy> getIamPolicyMethodDescriptor =
MethodDescriptor.<GetIamPolicyRequest, Policy>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/GetIamPolicy")
.setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance()))
.build();
private static final MethodDescriptor<SetIamPolicyRequest, Policy> setIamPolicyMethodDescriptor =
MethodDescriptor.<SetIamPolicyRequest, Policy>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/SetIamPolicy")
.setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance()))
.build();
private static final MethodDescriptor<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsMethodDescriptor =
MethodDescriptor.<TestIamPermissionsRequest, TestIamPermissionsResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.resourcemanager.v3.TagValues/TestIamPermissions")
.setRequestMarshaller(
ProtoUtils.marshaller(TestIamPermissionsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance()))
.build();
private final UnaryCallable<ListTagValuesRequest, ListTagValuesResponse> listTagValuesCallable;
private final UnaryCallable<ListTagValuesRequest, ListTagValuesPagedResponse>
listTagValuesPagedCallable;
private final UnaryCallable<GetTagValueRequest, TagValue> getTagValueCallable;
private final UnaryCallable<CreateTagValueRequest, Operation> createTagValueCallable;
private final OperationCallable<CreateTagValueRequest, TagValue, CreateTagValueMetadata>
createTagValueOperationCallable;
private final UnaryCallable<UpdateTagValueRequest, Operation> updateTagValueCallable;
private final OperationCallable<UpdateTagValueRequest, TagValue, UpdateTagValueMetadata>
updateTagValueOperationCallable;
private final UnaryCallable<DeleteTagValueRequest, Operation> deleteTagValueCallable;
private final OperationCallable<DeleteTagValueRequest, TagValue, DeleteTagValueMetadata>
deleteTagValueOperationCallable;
private final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable;
private final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable;
private final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable;
private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
private final GrpcStubCallableFactory callableFactory;
public static final GrpcTagValuesStub create(TagValuesStubSettings settings) throws IOException {
return new GrpcTagValuesStub(settings, ClientContext.create(settings));
}
public static final GrpcTagValuesStub create(ClientContext clientContext) throws IOException {
return new GrpcTagValuesStub(TagValuesStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcTagValuesStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcTagValuesStub(
TagValuesStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcTagValuesStub, using the given settings. This is protected so
* that it is easy to make a subclass, but otherwise, the static factory methods should be
* preferred.
*/
protected GrpcTagValuesStub(TagValuesStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new GrpcTagValuesCallableFactory());
}
/**
* Constructs an instance of GrpcTagValuesStub, using the given settings. This is protected so
* that it is easy to make a subclass, but otherwise, the static factory methods should be
* preferred.
*/
protected GrpcTagValuesStub(
TagValuesStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings<ListTagValuesRequest, ListTagValuesResponse> listTagValuesTransportSettings =
GrpcCallSettings.<ListTagValuesRequest, ListTagValuesResponse>newBuilder()
.setMethodDescriptor(listTagValuesMethodDescriptor)
.build();
GrpcCallSettings<GetTagValueRequest, TagValue> getTagValueTransportSettings =
GrpcCallSettings.<GetTagValueRequest, TagValue>newBuilder()
.setMethodDescriptor(getTagValueMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<GetTagValueRequest>() {
@Override
public Map<String, String> extract(GetTagValueRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<CreateTagValueRequest, Operation> createTagValueTransportSettings =
GrpcCallSettings.<CreateTagValueRequest, Operation>newBuilder()
.setMethodDescriptor(createTagValueMethodDescriptor)
.build();
GrpcCallSettings<UpdateTagValueRequest, Operation> updateTagValueTransportSettings =
GrpcCallSettings.<UpdateTagValueRequest, Operation>newBuilder()
.setMethodDescriptor(updateTagValueMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<UpdateTagValueRequest>() {
@Override
public Map<String, String> extract(UpdateTagValueRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("tag_value.name", String.valueOf(request.getTagValue().getName()));
return params.build();
}
})
.build();
GrpcCallSettings<DeleteTagValueRequest, Operation> deleteTagValueTransportSettings =
GrpcCallSettings.<DeleteTagValueRequest, Operation>newBuilder()
.setMethodDescriptor(deleteTagValueMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<DeleteTagValueRequest>() {
@Override
public Map<String, String> extract(DeleteTagValueRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<GetIamPolicyRequest, Policy> getIamPolicyTransportSettings =
GrpcCallSettings.<GetIamPolicyRequest, Policy>newBuilder()
.setMethodDescriptor(getIamPolicyMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<GetIamPolicyRequest>() {
@Override
public Map<String, String> extract(GetIamPolicyRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("resource", String.valueOf(request.getResource()));
return params.build();
}
})
.build();
GrpcCallSettings<SetIamPolicyRequest, Policy> setIamPolicyTransportSettings =
GrpcCallSettings.<SetIamPolicyRequest, Policy>newBuilder()
.setMethodDescriptor(setIamPolicyMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<SetIamPolicyRequest>() {
@Override
public Map<String, String> extract(SetIamPolicyRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("resource", String.valueOf(request.getResource()));
return params.build();
}
})
.build();
GrpcCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsTransportSettings =
GrpcCallSettings.<TestIamPermissionsRequest, TestIamPermissionsResponse>newBuilder()
.setMethodDescriptor(testIamPermissionsMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<TestIamPermissionsRequest>() {
@Override
public Map<String, String> extract(TestIamPermissionsRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("resource", String.valueOf(request.getResource()));
return params.build();
}
})
.build();
this.listTagValuesCallable =
callableFactory.createUnaryCallable(
listTagValuesTransportSettings, settings.listTagValuesSettings(), clientContext);
this.listTagValuesPagedCallable =
callableFactory.createPagedCallable(
listTagValuesTransportSettings, settings.listTagValuesSettings(), clientContext);
this.getTagValueCallable =
callableFactory.createUnaryCallable(
getTagValueTransportSettings, settings.getTagValueSettings(), clientContext);
this.createTagValueCallable =
callableFactory.createUnaryCallable(
createTagValueTransportSettings, settings.createTagValueSettings(), clientContext);
this.createTagValueOperationCallable =
callableFactory.createOperationCallable(
createTagValueTransportSettings,
settings.createTagValueOperationSettings(),
clientContext,
operationsStub);
this.updateTagValueCallable =
callableFactory.createUnaryCallable(
updateTagValueTransportSettings, settings.updateTagValueSettings(), clientContext);
this.updateTagValueOperationCallable =
callableFactory.createOperationCallable(
updateTagValueTransportSettings,
settings.updateTagValueOperationSettings(),
clientContext,
operationsStub);
this.deleteTagValueCallable =
callableFactory.createUnaryCallable(
deleteTagValueTransportSettings, settings.deleteTagValueSettings(), clientContext);
this.deleteTagValueOperationCallable =
callableFactory.createOperationCallable(
deleteTagValueTransportSettings,
settings.deleteTagValueOperationSettings(),
clientContext,
operationsStub);
this.getIamPolicyCallable =
callableFactory.createUnaryCallable(
getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext);
this.setIamPolicyCallable =
callableFactory.createUnaryCallable(
setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext);
this.testIamPermissionsCallable =
callableFactory.createUnaryCallable(
testIamPermissionsTransportSettings,
settings.testIamPermissionsSettings(),
clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}
@Override
public UnaryCallable<ListTagValuesRequest, ListTagValuesResponse> listTagValuesCallable() {
return listTagValuesCallable;
}
@Override
public UnaryCallable<ListTagValuesRequest, ListTagValuesPagedResponse>
listTagValuesPagedCallable() {
return listTagValuesPagedCallable;
}
@Override
public UnaryCallable<GetTagValueRequest, TagValue> getTagValueCallable() {
return getTagValueCallable;
}
@Override
public UnaryCallable<CreateTagValueRequest, Operation> createTagValueCallable() {
return createTagValueCallable;
}
@Override
public OperationCallable<CreateTagValueRequest, TagValue, CreateTagValueMetadata>
createTagValueOperationCallable() {
return createTagValueOperationCallable;
}
@Override
public UnaryCallable<UpdateTagValueRequest, Operation> updateTagValueCallable() {
return updateTagValueCallable;
}
@Override
public OperationCallable<UpdateTagValueRequest, TagValue, UpdateTagValueMetadata>
updateTagValueOperationCallable() {
return updateTagValueOperationCallable;
}
@Override
public UnaryCallable<DeleteTagValueRequest, Operation> deleteTagValueCallable() {
return deleteTagValueCallable;
}
@Override
public OperationCallable<DeleteTagValueRequest, TagValue, DeleteTagValueMetadata>
deleteTagValueOperationCallable() {
return deleteTagValueOperationCallable;
}
@Override
public UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
return getIamPolicyCallable;
}
@Override
public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
return setIamPolicyCallable;
}
@Override
public UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable() {
return testIamPermissionsCallable;
}
@Override
public final void close() {
try {
backgroundResources.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException("Failed to close resource", e);
}
}
@Override
public void shutdown() {
backgroundResources.shutdown();
}
@Override
public boolean isShutdown() {
return backgroundResources.isShutdown();
}
@Override
public boolean isTerminated() {
return backgroundResources.isTerminated();
}
@Override
public void shutdownNow() {
backgroundResources.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return backgroundResources.awaitTermination(duration, unit);
}
}