use of com.google.monitoring.v3.DeleteNotificationChannelRequest in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method deleteNotificationChannelTest.
@Test
public void deleteNotificationChannelTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockNotificationChannelService.addResponse(expectedResponse);
NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
boolean force = true;
client.deleteNotificationChannel(name, force);
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteNotificationChannelRequest actualRequest = ((DeleteNotificationChannelRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(force, actualRequest.getForce());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.DeleteNotificationChannelRequest in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method deleteNotificationChannelTest2.
@Test
public void deleteNotificationChannelTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockNotificationChannelService.addResponse(expectedResponse);
String name = "name3373707";
boolean force = true;
client.deleteNotificationChannel(name, force);
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteNotificationChannelRequest actualRequest = ((DeleteNotificationChannelRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertEquals(force, actualRequest.getForce());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.DeleteNotificationChannelRequest in project java-monitoring by googleapis.
the class NotificationChannelServiceClient method deleteNotificationChannel.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a notification channel.
*
* <p>Sample code:
*
* <pre>{@code
* try (NotificationChannelServiceClient notificationChannelServiceClient =
* NotificationChannelServiceClient.create()) {
* String name =
* NotificationChannelName.ofProjectNotificationChannelName(
* "[PROJECT]", "[NOTIFICATION_CHANNEL]")
* .toString();
* boolean force = true;
* notificationChannelServiceClient.deleteNotificationChannel(name, force);
* }
* }</pre>
*
* @param name Required. The channel for which to execute the request. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
* @param force If true, the notification channel will be deleted regardless of its use in alert
* policies (the policies will be updated to remove the channel). If false, channels that are
* still referenced by an existing alerting policy will fail to be deleted in a delete
* operation.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteNotificationChannel(String name, boolean force) {
DeleteNotificationChannelRequest request = DeleteNotificationChannelRequest.newBuilder().setName(name).setForce(force).build();
deleteNotificationChannel(request);
}
use of com.google.monitoring.v3.DeleteNotificationChannelRequest in project java-monitoring by googleapis.
the class NotificationChannelServiceClient method deleteNotificationChannel.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a notification channel.
*
* <p>Sample code:
*
* <pre>{@code
* try (NotificationChannelServiceClient notificationChannelServiceClient =
* NotificationChannelServiceClient.create()) {
* NotificationChannelName name =
* NotificationChannelName.ofProjectNotificationChannelName(
* "[PROJECT]", "[NOTIFICATION_CHANNEL]");
* boolean force = true;
* notificationChannelServiceClient.deleteNotificationChannel(name, force);
* }
* }</pre>
*
* @param name Required. The channel for which to execute the request. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
* @param force If true, the notification channel will be deleted regardless of its use in alert
* policies (the policies will be updated to remove the channel). If false, channels that are
* still referenced by an existing alerting policy will fail to be deleted in a delete
* operation.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteNotificationChannel(NotificationChannelName name, boolean force) {
DeleteNotificationChannelRequest request = DeleteNotificationChannelRequest.newBuilder().setName(name == null ? null : name.toString()).setForce(force).build();
deleteNotificationChannel(request);
}
Aggregations