Search in sources :

Example 1 with DeleteServiceRequest

use of com.google.monitoring.v3.DeleteServiceRequest in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClient method deleteService.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Soft delete this `Service`.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
 *     ServiceMonitoringServiceClient.create()) {
 *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
 *   serviceMonitoringServiceClient.deleteService(name);
 * }
 * }</pre>
 *
 * @param name Required. Resource name of the `Service` to delete. The format is:
 *     <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteService(ServiceName name) {
    DeleteServiceRequest request = DeleteServiceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteService(request);
}
Also used : DeleteServiceRequest(com.google.monitoring.v3.DeleteServiceRequest)

Example 2 with DeleteServiceRequest

use of com.google.monitoring.v3.DeleteServiceRequest in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClient method deleteService.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Soft delete this `Service`.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
 *     ServiceMonitoringServiceClient.create()) {
 *   String name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString();
 *   serviceMonitoringServiceClient.deleteService(name);
 * }
 * }</pre>
 *
 * @param name Required. Resource name of the `Service` to delete. The format is:
 *     <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteService(String name) {
    DeleteServiceRequest request = DeleteServiceRequest.newBuilder().setName(name).build();
    deleteService(request);
}
Also used : DeleteServiceRequest(com.google.monitoring.v3.DeleteServiceRequest)

Example 3 with DeleteServiceRequest

use of com.google.monitoring.v3.DeleteServiceRequest in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method deleteServiceTest.

@Test
public void deleteServiceTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
    client.deleteService(name);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteServiceRequest actualRequest = ((DeleteServiceRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) ServiceName(com.google.monitoring.v3.ServiceName) DeleteServiceRequest(com.google.monitoring.v3.DeleteServiceRequest) Test(org.junit.Test)

Example 4 with DeleteServiceRequest

use of com.google.monitoring.v3.DeleteServiceRequest in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method deleteServiceTest2.

@Test
public void deleteServiceTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    String name = "name3373707";
    client.deleteService(name);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteServiceRequest actualRequest = ((DeleteServiceRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteServiceRequest(com.google.monitoring.v3.DeleteServiceRequest) Test(org.junit.Test)

Aggregations

DeleteServiceRequest (com.google.monitoring.v3.DeleteServiceRequest)4 AbstractMessage (com.google.protobuf.AbstractMessage)2 Empty (com.google.protobuf.Empty)2 Test (org.junit.Test)2 ServiceName (com.google.monitoring.v3.ServiceName)1