use of com.google.cloud.logging.v2.MetricsClient in project gapic-generator-java by googleapis.
the class SyncDeleteLogMetricString method syncDeleteLogMetricString.
public static void syncDeleteLogMetricString() throws Exception {
// It may require modifications to work in your environment.
try (MetricsClient metricsClient = MetricsClient.create()) {
String metricName = LogMetricName.of("[PROJECT]", "[METRIC]").toString();
metricsClient.deleteLogMetric(metricName);
}
}
use of com.google.cloud.logging.v2.MetricsClient in project gapic-generator-java by googleapis.
the class SyncGetLogMetricString method syncGetLogMetricString.
public static void syncGetLogMetricString() throws Exception {
// It may require modifications to work in your environment.
try (MetricsClient metricsClient = MetricsClient.create()) {
String metricName = LogMetricName.of("[PROJECT]", "[METRIC]").toString();
LogMetric response = metricsClient.getLogMetric(metricName);
}
}
use of com.google.cloud.logging.v2.MetricsClient in project gapic-generator-java by googleapis.
the class AsyncListLogMetrics method asyncListLogMetrics.
public static void asyncListLogMetrics() throws Exception {
// It may require modifications to work in your environment.
try (MetricsClient metricsClient = MetricsClient.create()) {
ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageToken("pageToken873572522").setPageSize(883849137).build();
ApiFuture<LogMetric> future = metricsClient.listLogMetricsPagedCallable().futureCall(request);
// Do something.
for (LogMetric element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
}
use of com.google.cloud.logging.v2.MetricsClient in project gapic-generator-java by googleapis.
the class AsyncListLogMetricsPaged method asyncListLogMetricsPaged.
public static void asyncListLogMetricsPaged() throws Exception {
// It may require modifications to work in your environment.
try (MetricsClient metricsClient = MetricsClient.create()) {
ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageToken("pageToken873572522").setPageSize(883849137).build();
while (true) {
ListLogMetricsResponse response = metricsClient.listLogMetricsCallable().call(request);
for (LogMetric element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
}
Aggregations