use of com.google.monitoring.v3.ServiceLevelObjectiveName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method getServiceLevelObjectiveTest.
@Test
public void getServiceLevelObjectiveTest() throws Exception {
ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder().setName(ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]").toString()).setDisplayName("displayName1714148973").setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()).setGoal(3178259).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
ServiceLevelObjective actualResponse = client.getServiceLevelObjective(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetServiceLevelObjectiveRequest actualRequest = ((GetServiceLevelObjectiveRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.ServiceLevelObjectiveName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method deleteServiceLevelObjectiveTest.
@Test
public void deleteServiceLevelObjectiveTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockServiceMonitoringService.addResponse(expectedResponse);
ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
client.deleteServiceLevelObjective(name);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteServiceLevelObjectiveRequest actualRequest = ((DeleteServiceLevelObjectiveRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.ServiceLevelObjectiveName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method deleteServiceLevelObjectiveExceptionTest.
@Test
public void deleteServiceLevelObjectiveExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
client.deleteServiceLevelObjective(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.ServiceLevelObjectiveName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClient method deleteServiceLevelObjective.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Delete the given `ServiceLevelObjective`.
*
* <p>Sample code:
*
* <pre>{@code
* try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
* ServiceMonitoringServiceClient.create()) {
* ServiceLevelObjectiveName name =
* ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
* "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
* serviceMonitoringServiceClient.deleteServiceLevelObjective(name);
* }
* }</pre>
*
* @param name Required. Resource name of the `ServiceLevelObjective` to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteServiceLevelObjective(ServiceLevelObjectiveName name) {
DeleteServiceLevelObjectiveRequest request = DeleteServiceLevelObjectiveRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteServiceLevelObjective(request);
}
use of com.google.monitoring.v3.ServiceLevelObjectiveName in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method getServiceLevelObjectiveExceptionTest.
@Test
public void getServiceLevelObjectiveExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
client.getServiceLevelObjective(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations