com.google.cloud.monitoring.v3.stub.GrpcGroupServiceStub Maven / Gradle / Ivy
Show all versions of google-cloud-monitoring Show documentation
/*
* Copyright 2024 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.monitoring.v3.stub;
import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupMembersPagedResponse;
import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse;
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.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.monitoring.v3.CreateGroupRequest;
import com.google.monitoring.v3.DeleteGroupRequest;
import com.google.monitoring.v3.GetGroupRequest;
import com.google.monitoring.v3.Group;
import com.google.monitoring.v3.ListGroupMembersRequest;
import com.google.monitoring.v3.ListGroupMembersResponse;
import com.google.monitoring.v3.ListGroupsRequest;
import com.google.monitoring.v3.ListGroupsResponse;
import com.google.monitoring.v3.UpdateGroupRequest;
import com.google.protobuf.Empty;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* gRPC stub implementation for the GroupService service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class GrpcGroupServiceStub extends GroupServiceStub {
private static final MethodDescriptor
listGroupsMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.GroupService/ListGroups")
.setRequestMarshaller(ProtoUtils.marshaller(ListGroupsRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListGroupsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor getGroupMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.GroupService/GetGroup")
.setRequestMarshaller(ProtoUtils.marshaller(GetGroupRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance()))
.build();
private static final MethodDescriptor createGroupMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.GroupService/CreateGroup")
.setRequestMarshaller(ProtoUtils.marshaller(CreateGroupRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance()))
.build();
private static final MethodDescriptor updateGroupMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.GroupService/UpdateGroup")
.setRequestMarshaller(ProtoUtils.marshaller(UpdateGroupRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance()))
.build();
private static final MethodDescriptor deleteGroupMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.GroupService/DeleteGroup")
.setRequestMarshaller(ProtoUtils.marshaller(DeleteGroupRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.build();
private static final MethodDescriptor
listGroupMembersMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.GroupService/ListGroupMembers")
.setRequestMarshaller(
ProtoUtils.marshaller(ListGroupMembersRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListGroupMembersResponse.getDefaultInstance()))
.build();
private final UnaryCallable listGroupsCallable;
private final UnaryCallable listGroupsPagedCallable;
private final UnaryCallable getGroupCallable;
private final UnaryCallable createGroupCallable;
private final UnaryCallable updateGroupCallable;
private final UnaryCallable deleteGroupCallable;
private final UnaryCallable
listGroupMembersCallable;
private final UnaryCallable
listGroupMembersPagedCallable;
private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
private final GrpcStubCallableFactory callableFactory;
public static final GrpcGroupServiceStub create(GroupServiceStubSettings settings)
throws IOException {
return new GrpcGroupServiceStub(settings, ClientContext.create(settings));
}
public static final GrpcGroupServiceStub create(ClientContext clientContext) throws IOException {
return new GrpcGroupServiceStub(GroupServiceStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcGroupServiceStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcGroupServiceStub(
GroupServiceStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcGroupServiceStub, 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 GrpcGroupServiceStub(GroupServiceStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new GrpcGroupServiceCallableFactory());
}
/**
* Constructs an instance of GrpcGroupServiceStub, 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 GrpcGroupServiceStub(
GroupServiceStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings listGroupsTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listGroupsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings getGroupTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getGroupMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings createGroupTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createGroupMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings updateGroupTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(updateGroupMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("group.name", String.valueOf(request.getGroup().getName()));
return builder.build();
})
.build();
GrpcCallSettings deleteGroupTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteGroupMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
listGroupMembersTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listGroupMembersMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
this.listGroupsCallable =
callableFactory.createUnaryCallable(
listGroupsTransportSettings, settings.listGroupsSettings(), clientContext);
this.listGroupsPagedCallable =
callableFactory.createPagedCallable(
listGroupsTransportSettings, settings.listGroupsSettings(), clientContext);
this.getGroupCallable =
callableFactory.createUnaryCallable(
getGroupTransportSettings, settings.getGroupSettings(), clientContext);
this.createGroupCallable =
callableFactory.createUnaryCallable(
createGroupTransportSettings, settings.createGroupSettings(), clientContext);
this.updateGroupCallable =
callableFactory.createUnaryCallable(
updateGroupTransportSettings, settings.updateGroupSettings(), clientContext);
this.deleteGroupCallable =
callableFactory.createUnaryCallable(
deleteGroupTransportSettings, settings.deleteGroupSettings(), clientContext);
this.listGroupMembersCallable =
callableFactory.createUnaryCallable(
listGroupMembersTransportSettings, settings.listGroupMembersSettings(), clientContext);
this.listGroupMembersPagedCallable =
callableFactory.createPagedCallable(
listGroupMembersTransportSettings, settings.listGroupMembersSettings(), clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}
@Override
public UnaryCallable listGroupsCallable() {
return listGroupsCallable;
}
@Override
public UnaryCallable listGroupsPagedCallable() {
return listGroupsPagedCallable;
}
@Override
public UnaryCallable getGroupCallable() {
return getGroupCallable;
}
@Override
public UnaryCallable createGroupCallable() {
return createGroupCallable;
}
@Override
public UnaryCallable updateGroupCallable() {
return updateGroupCallable;
}
@Override
public UnaryCallable deleteGroupCallable() {
return deleteGroupCallable;
}
@Override
public UnaryCallable
listGroupMembersCallable() {
return listGroupMembersCallable;
}
@Override
public UnaryCallable
listGroupMembersPagedCallable() {
return listGroupMembersPagedCallable;
}
@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);
}
}