Search in sources :

Example 1 with DeleteAlertPolicyRequest

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);
}
Also used : DeleteAlertPolicyRequest(com.google.monitoring.v3.DeleteAlertPolicyRequest)

Example 2 with DeleteAlertPolicyRequest

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);
}
Also used : DeleteAlertPolicyRequest(com.google.monitoring.v3.DeleteAlertPolicyRequest)

Example 3 with DeleteAlertPolicyRequest

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()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) AlertPolicyName(com.google.monitoring.v3.AlertPolicyName) DeleteAlertPolicyRequest(com.google.monitoring.v3.DeleteAlertPolicyRequest) Test(org.junit.Test)

Example 4 with DeleteAlertPolicyRequest

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()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteAlertPolicyRequest(com.google.monitoring.v3.DeleteAlertPolicyRequest) Test(org.junit.Test)

Aggregations

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