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);
}
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());
}
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));
}
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));
}
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());
}
Aggregations