Search in sources :

Example 1 with DeleteLogMetricRequest

use of com.google.logging.v2.DeleteLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClient method deleteLogMetric.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Deletes a logs-based metric.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (MetricsClient metricsClient = MetricsClient.create()) {
   *   MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
   *   metricsClient.deleteLogMetric(metricName);
   * }
   * </code></pre>
   *
   * @param metricName The resource name of the metric to delete:
   *     <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]"
   * @throws com.google.api.gax.grpc.ApiException if the remote call fails
   */
public final void deleteLogMetric(MetricNameOneof metricName) {
    DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder().setMetricNameWithMetricNameOneof(metricName).build();
    deleteLogMetric(request);
}
Also used : DeleteLogMetricRequest(com.google.logging.v2.DeleteLogMetricRequest)

Example 2 with DeleteLogMetricRequest

use of com.google.logging.v2.DeleteLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClientTest method deleteLogMetricTest.

@Test
@SuppressWarnings("all")
public void deleteLogMetricTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockMetricsServiceV2.addResponse(expectedResponse);
    MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
    client.deleteLogMetric(metricName);
    List<GeneratedMessageV3> actualRequests = mockMetricsServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteLogMetricRequest actualRequest = (DeleteLogMetricRequest) actualRequests.get(0);
    Assert.assertEquals(metricName, actualRequest.getMetricNameAsMetricNameOneof());
}
Also used : Empty(com.google.protobuf.Empty) MetricNameOneof(com.google.logging.v2.MetricNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) DeleteLogMetricRequest(com.google.logging.v2.DeleteLogMetricRequest) Test(org.junit.Test)

Example 3 with DeleteLogMetricRequest

use of com.google.logging.v2.DeleteLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.

the class LoggingImplTest method testDeleteMetric.

@Test
public void testDeleteMetric() {
    DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
    ApiFuture<Empty> response = ApiFutures.immediateFuture(Empty.getDefaultInstance());
    EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertTrue(logging.deleteMetric(METRIC_NAME));
}
Also used : Empty(com.google.protobuf.Empty) DeleteLogMetricRequest(com.google.logging.v2.DeleteLogMetricRequest) Test(org.junit.Test)

Example 4 with DeleteLogMetricRequest

use of com.google.logging.v2.DeleteLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.

the class LoggingImplTest method testDeleteMetric_Null.

@Test
public void testDeleteMetric_Null() {
    DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
    ApiFuture<Empty> response = ApiFutures.immediateFuture(null);
    EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertFalse(logging.deleteMetric(METRIC_NAME));
}
Also used : Empty(com.google.protobuf.Empty) DeleteLogMetricRequest(com.google.logging.v2.DeleteLogMetricRequest) Test(org.junit.Test)

Example 5 with DeleteLogMetricRequest

use of com.google.logging.v2.DeleteLogMetricRequest in project google-cloud-java by GoogleCloudPlatform.

the class LoggingImplTest method testDeleteMetricAsync_Null.

@Test
public void testDeleteMetricAsync_Null() throws ExecutionException, InterruptedException {
    DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build();
    ApiFuture<Empty> response = ApiFutures.immediateFuture(null);
    EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertFalse(logging.deleteMetricAsync(METRIC_NAME).get());
}
Also used : Empty(com.google.protobuf.Empty) DeleteLogMetricRequest(com.google.logging.v2.DeleteLogMetricRequest) Test(org.junit.Test)

Aggregations

DeleteLogMetricRequest (com.google.logging.v2.DeleteLogMetricRequest)6 Empty (com.google.protobuf.Empty)5 Test (org.junit.Test)5 MetricNameOneof (com.google.logging.v2.MetricNameOneof)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1