Search in sources :

Example 16 with MetricsClient

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);
    }
}
Also used : MetricsClient(com.google.cloud.logging.v2.MetricsClient)

Example 17 with MetricsClient

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);
    }
}
Also used : MetricsClient(com.google.cloud.logging.v2.MetricsClient) LogMetric(com.google.logging.v2.LogMetric)

Example 18 with MetricsClient

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);
        }
    }
}
Also used : MetricsClient(com.google.cloud.logging.v2.MetricsClient) LogMetric(com.google.logging.v2.LogMetric) ListLogMetricsRequest(com.google.logging.v2.ListLogMetricsRequest)

Example 19 with MetricsClient

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;
            }
        }
    }
}
Also used : MetricsClient(com.google.cloud.logging.v2.MetricsClient) LogMetric(com.google.logging.v2.LogMetric) ListLogMetricsResponse(com.google.logging.v2.ListLogMetricsResponse) ListLogMetricsRequest(com.google.logging.v2.ListLogMetricsRequest)

Aggregations

MetricsClient (com.google.cloud.logging.v2.MetricsClient)19 LogMetric (com.google.logging.v2.LogMetric)13 LogMetricName (com.google.logging.v2.LogMetricName)3 MetricsSettings (com.google.cloud.logging.v2.MetricsSettings)2 CreateLogMetricRequest (com.google.logging.v2.CreateLogMetricRequest)2 DeleteLogMetricRequest (com.google.logging.v2.DeleteLogMetricRequest)2 ListLogMetricsRequest (com.google.logging.v2.ListLogMetricsRequest)2 UpdateLogMetricRequest (com.google.logging.v2.UpdateLogMetricRequest)2 GetLogMetricRequest (com.google.logging.v2.GetLogMetricRequest)1 ListLogMetricsResponse (com.google.logging.v2.ListLogMetricsResponse)1 ProjectName (com.google.logging.v2.ProjectName)1 Empty (com.google.protobuf.Empty)1