use of com.google.monitoring.v3.UptimeCheckConfigName in project java-monitoring by googleapis.
the class UptimeCheckServiceClient method deleteUptimeCheckConfig.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes an Uptime check configuration. Note that this method will fail if the Uptime check
* configuration is referenced by an alert policy or other dependent configs that would be
* rendered invalid by the deletion.
*
* <p>Sample code:
*
* <pre>{@code
* try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
* UptimeCheckConfigName name =
* UptimeCheckConfigName.ofProjectUptimeCheckConfigName(
* "[PROJECT]", "[UPTIME_CHECK_CONFIG]");
* uptimeCheckServiceClient.deleteUptimeCheckConfig(name);
* }
* }</pre>
*
* @param name Required. The Uptime check configuration to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteUptimeCheckConfig(UptimeCheckConfigName name) {
DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteUptimeCheckConfig(request);
}
use of com.google.monitoring.v3.UptimeCheckConfigName in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method deleteUptimeCheckConfigTest.
@Test
public void deleteUptimeCheckConfigTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockUptimeCheckService.addResponse(expectedResponse);
UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
client.deleteUptimeCheckConfig(name);
List<AbstractMessage> actualRequests = mockUptimeCheckService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteUptimeCheckConfigRequest actualRequest = ((DeleteUptimeCheckConfigRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.UptimeCheckConfigName in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method getUptimeCheckConfigExceptionTest.
@Test
public void getUptimeCheckConfigExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockUptimeCheckService.addException(exception);
try {
UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
client.getUptimeCheckConfig(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.UptimeCheckConfigName in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method getUptimeCheckConfigTest.
@Test
public void getUptimeCheckConfigTest() throws Exception {
UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder().setName(UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]").toString()).setDisplayName("displayName1714148973").setPeriod(Duration.newBuilder().build()).setTimeout(Duration.newBuilder().build()).addAllContentMatchers(new ArrayList<UptimeCheckConfig.ContentMatcher>()).addAllSelectedRegions(new ArrayList<UptimeCheckRegion>()).setIsInternal(true).addAllInternalCheckers(new ArrayList<InternalChecker>()).build();
mockUptimeCheckService.addResponse(expectedResponse);
UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockUptimeCheckService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetUptimeCheckConfigRequest actualRequest = ((GetUptimeCheckConfigRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.UptimeCheckConfigName in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method deleteUptimeCheckConfigExceptionTest.
@Test
public void deleteUptimeCheckConfigExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockUptimeCheckService.addException(exception);
try {
UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
client.deleteUptimeCheckConfig(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations