Search in sources :

Example 1 with DeleteMetricDescriptorRequest

use of com.google.monitoring.v3.DeleteMetricDescriptorRequest in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method deleteMetricDescriptorTest.

@Test
@SuppressWarnings("all")
public void deleteMetricDescriptorTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockMetricService.addResponse(expectedResponse);
    MetricDescriptorName name = MetricDescriptorName.create("[PROJECT]", "[METRIC_DESCRIPTOR]");
    client.deleteMetricDescriptor(name);
    List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteMetricDescriptorRequest actualRequest = (DeleteMetricDescriptorRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsMetricDescriptorName());
}
Also used : Empty(com.google.protobuf.Empty) MetricDescriptorName(com.google.monitoring.v3.MetricDescriptorName) DeleteMetricDescriptorRequest(com.google.monitoring.v3.DeleteMetricDescriptorRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 2 with DeleteMetricDescriptorRequest

use of com.google.monitoring.v3.DeleteMetricDescriptorRequest in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClient method deleteMetricDescriptor.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can
   * be deleted.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
   *   MetricDescriptorName name = MetricDescriptorName.create("[PROJECT]", "[METRIC_DESCRIPTOR]");
   *   metricServiceClient.deleteMetricDescriptor(name);
   * }
   * </code></pre>
   *
   * @param name The metric descriptor on which to execute the request. The format is
   *     `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example of
   *     `{metric_id}` is: `"custom.googleapis.com/my_test_metric"`.
   * @throws com.google.api.gax.grpc.ApiException if the remote call fails
   */
public final void deleteMetricDescriptor(MetricDescriptorName name) {
    DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder().setNameWithMetricDescriptorName(name).build();
    deleteMetricDescriptor(request);
}
Also used : DeleteMetricDescriptorRequest(com.google.monitoring.v3.DeleteMetricDescriptorRequest)

Aggregations

DeleteMetricDescriptorRequest (com.google.monitoring.v3.DeleteMetricDescriptorRequest)2 MetricDescriptorName (com.google.monitoring.v3.MetricDescriptorName)1 Empty (com.google.protobuf.Empty)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1