com.google.cloud.monitoring.v3.stub.GrpcMetricServiceStub 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.MetricServiceClient.ListMetricDescriptorsPagedResponse;
import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse;
import static com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse;
import com.google.api.MetricDescriptor;
import com.google.api.MonitoredResourceDescriptor;
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.CreateMetricDescriptorRequest;
import com.google.monitoring.v3.CreateTimeSeriesRequest;
import com.google.monitoring.v3.DeleteMetricDescriptorRequest;
import com.google.monitoring.v3.GetMetricDescriptorRequest;
import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest;
import com.google.monitoring.v3.ListMetricDescriptorsRequest;
import com.google.monitoring.v3.ListMetricDescriptorsResponse;
import com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest;
import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse;
import com.google.monitoring.v3.ListTimeSeriesRequest;
import com.google.monitoring.v3.ListTimeSeriesResponse;
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 MetricService service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class GrpcMetricServiceStub extends MetricServiceStub {
private static final MethodDescriptor<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
listMonitoredResourceDescriptorsMethodDescriptor =
MethodDescriptor
.
newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.monitoring.v3.MetricService/ListMonitoredResourceDescriptors")
.setRequestMarshaller(
ProtoUtils.marshaller(
ListMonitoredResourceDescriptorsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(
ListMonitoredResourceDescriptorsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor<
GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor>
getMonitoredResourceDescriptorMethodDescriptor =
MethodDescriptor
.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
"google.monitoring.v3.MetricService/GetMonitoredResourceDescriptor")
.setRequestMarshaller(
ProtoUtils.marshaller(GetMonitoredResourceDescriptorRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(MonitoredResourceDescriptor.getDefaultInstance()))
.build();
private static final MethodDescriptor
listMetricDescriptorsMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/ListMetricDescriptors")
.setRequestMarshaller(
ProtoUtils.marshaller(ListMetricDescriptorsRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListMetricDescriptorsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor
getMetricDescriptorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/GetMetricDescriptor")
.setRequestMarshaller(
ProtoUtils.marshaller(GetMetricDescriptorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(MetricDescriptor.getDefaultInstance()))
.build();
private static final MethodDescriptor
createMetricDescriptorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/CreateMetricDescriptor")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateMetricDescriptorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(MetricDescriptor.getDefaultInstance()))
.build();
private static final MethodDescriptor
deleteMetricDescriptorMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/DeleteMetricDescriptor")
.setRequestMarshaller(
ProtoUtils.marshaller(DeleteMetricDescriptorRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.build();
private static final MethodDescriptor
listTimeSeriesMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/ListTimeSeries")
.setRequestMarshaller(
ProtoUtils.marshaller(ListTimeSeriesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListTimeSeriesResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor
createTimeSeriesMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/CreateTimeSeries")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateTimeSeriesRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.build();
private static final MethodDescriptor
createServiceTimeSeriesMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.monitoring.v3.MetricService/CreateServiceTimeSeries")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateTimeSeriesRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.build();
private final UnaryCallable<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
listMonitoredResourceDescriptorsCallable;
private final UnaryCallable<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse>
listMonitoredResourceDescriptorsPagedCallable;
private final UnaryCallable
getMonitoredResourceDescriptorCallable;
private final UnaryCallable
listMetricDescriptorsCallable;
private final UnaryCallable
listMetricDescriptorsPagedCallable;
private final UnaryCallable
getMetricDescriptorCallable;
private final UnaryCallable
createMetricDescriptorCallable;
private final UnaryCallable deleteMetricDescriptorCallable;
private final UnaryCallable listTimeSeriesCallable;
private final UnaryCallable
listTimeSeriesPagedCallable;
private final UnaryCallable createTimeSeriesCallable;
private final UnaryCallable createServiceTimeSeriesCallable;
private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
private final GrpcStubCallableFactory callableFactory;
public static final GrpcMetricServiceStub create(MetricServiceStubSettings settings)
throws IOException {
return new GrpcMetricServiceStub(settings, ClientContext.create(settings));
}
public static final GrpcMetricServiceStub create(ClientContext clientContext) throws IOException {
return new GrpcMetricServiceStub(MetricServiceStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcMetricServiceStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcMetricServiceStub(
MetricServiceStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcMetricServiceStub, 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 GrpcMetricServiceStub(MetricServiceStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new GrpcMetricServiceCallableFactory());
}
/**
* Constructs an instance of GrpcMetricServiceStub, 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 GrpcMetricServiceStub(
MetricServiceStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
listMonitoredResourceDescriptorsTransportSettings =
GrpcCallSettings
.
newBuilder()
.setMethodDescriptor(listMonitoredResourceDescriptorsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
getMonitoredResourceDescriptorTransportSettings =
GrpcCallSettings
.newBuilder()
.setMethodDescriptor(getMonitoredResourceDescriptorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
listMetricDescriptorsTransportSettings =
GrpcCallSettings
.newBuilder()
.setMethodDescriptor(listMetricDescriptorsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
getMetricDescriptorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getMetricDescriptorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
createMetricDescriptorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createMetricDescriptorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings deleteMetricDescriptorTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteMetricDescriptorMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings
listTimeSeriesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listTimeSeriesMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings createTimeSeriesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createTimeSeriesMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
GrpcCallSettings createServiceTimeSeriesTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createServiceTimeSeriesMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
this.listMonitoredResourceDescriptorsCallable =
callableFactory.createUnaryCallable(
listMonitoredResourceDescriptorsTransportSettings,
settings.listMonitoredResourceDescriptorsSettings(),
clientContext);
this.listMonitoredResourceDescriptorsPagedCallable =
callableFactory.createPagedCallable(
listMonitoredResourceDescriptorsTransportSettings,
settings.listMonitoredResourceDescriptorsSettings(),
clientContext);
this.getMonitoredResourceDescriptorCallable =
callableFactory.createUnaryCallable(
getMonitoredResourceDescriptorTransportSettings,
settings.getMonitoredResourceDescriptorSettings(),
clientContext);
this.listMetricDescriptorsCallable =
callableFactory.createUnaryCallable(
listMetricDescriptorsTransportSettings,
settings.listMetricDescriptorsSettings(),
clientContext);
this.listMetricDescriptorsPagedCallable =
callableFactory.createPagedCallable(
listMetricDescriptorsTransportSettings,
settings.listMetricDescriptorsSettings(),
clientContext);
this.getMetricDescriptorCallable =
callableFactory.createUnaryCallable(
getMetricDescriptorTransportSettings,
settings.getMetricDescriptorSettings(),
clientContext);
this.createMetricDescriptorCallable =
callableFactory.createUnaryCallable(
createMetricDescriptorTransportSettings,
settings.createMetricDescriptorSettings(),
clientContext);
this.deleteMetricDescriptorCallable =
callableFactory.createUnaryCallable(
deleteMetricDescriptorTransportSettings,
settings.deleteMetricDescriptorSettings(),
clientContext);
this.listTimeSeriesCallable =
callableFactory.createUnaryCallable(
listTimeSeriesTransportSettings, settings.listTimeSeriesSettings(), clientContext);
this.listTimeSeriesPagedCallable =
callableFactory.createPagedCallable(
listTimeSeriesTransportSettings, settings.listTimeSeriesSettings(), clientContext);
this.createTimeSeriesCallable =
callableFactory.createUnaryCallable(
createTimeSeriesTransportSettings, settings.createTimeSeriesSettings(), clientContext);
this.createServiceTimeSeriesCallable =
callableFactory.createUnaryCallable(
createServiceTimeSeriesTransportSettings,
settings.createServiceTimeSeriesSettings(),
clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}
@Override
public UnaryCallable<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
listMonitoredResourceDescriptorsCallable() {
return listMonitoredResourceDescriptorsCallable;
}
@Override
public UnaryCallable<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse>
listMonitoredResourceDescriptorsPagedCallable() {
return listMonitoredResourceDescriptorsPagedCallable;
}
@Override
public UnaryCallable
getMonitoredResourceDescriptorCallable() {
return getMonitoredResourceDescriptorCallable;
}
@Override
public UnaryCallable
listMetricDescriptorsCallable() {
return listMetricDescriptorsCallable;
}
@Override
public UnaryCallable
listMetricDescriptorsPagedCallable() {
return listMetricDescriptorsPagedCallable;
}
@Override
public UnaryCallable getMetricDescriptorCallable() {
return getMetricDescriptorCallable;
}
@Override
public UnaryCallable
createMetricDescriptorCallable() {
return createMetricDescriptorCallable;
}
@Override
public UnaryCallable deleteMetricDescriptorCallable() {
return deleteMetricDescriptorCallable;
}
@Override
public UnaryCallable listTimeSeriesCallable() {
return listTimeSeriesCallable;
}
@Override
public UnaryCallable
listTimeSeriesPagedCallable() {
return listTimeSeriesPagedCallable;
}
@Override
public UnaryCallable createTimeSeriesCallable() {
return createTimeSeriesCallable;
}
@Override
public UnaryCallable createServiceTimeSeriesCallable() {
return createServiceTimeSeriesCallable;
}
@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);
}
}