use of com.google.monitoring.v3.DeleteAlertPolicyRequest in project java-monitoring by googleapis.
the class AlertPolicyServiceClient method deleteAlertPolicy.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes an alerting policy.
*
* <p>Sample code:
*
* <pre>{@code
* try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
* AlertPolicyName name =
* AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]");
* alertPolicyServiceClient.deleteAlertPolicy(name);
* }
* }</pre>
*
* @param name Required. The alerting policy to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
* <p>For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy].
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteAlertPolicy(AlertPolicyName name) {
DeleteAlertPolicyRequest request = DeleteAlertPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteAlertPolicy(request);
}
use of com.google.monitoring.v3.DeleteAlertPolicyRequest in project java-monitoring by googleapis.
the class AlertPolicyServiceClient method deleteAlertPolicy.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes an alerting policy.
*
* <p>Sample code:
*
* <pre>{@code
* try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
* String name =
* AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString();
* alertPolicyServiceClient.deleteAlertPolicy(name);
* }
* }</pre>
*
* @param name Required. The alerting policy to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
* <p>For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy].
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteAlertPolicy(String name) {
DeleteAlertPolicyRequest request = DeleteAlertPolicyRequest.newBuilder().setName(name).build();
deleteAlertPolicy(request);
}
use of com.google.monitoring.v3.DeleteAlertPolicyRequest in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method deleteAlertPolicyTest.
@Test
public void deleteAlertPolicyTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockAlertPolicyService.addResponse(expectedResponse);
AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]");
client.deleteAlertPolicy(name);
List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteAlertPolicyRequest actualRequest = ((DeleteAlertPolicyRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.DeleteAlertPolicyRequest in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method deleteAlertPolicyTest2.
@Test
public void deleteAlertPolicyTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockAlertPolicyService.addResponse(expectedResponse);
String name = "name3373707";
client.deleteAlertPolicy(name);
List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteAlertPolicyRequest actualRequest = ((DeleteAlertPolicyRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations