use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceTest3.
@Test
public void createServiceTest3() throws Exception {
Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Service service = Service.newBuilder().build();
Service actualResponse = client.createService(parent, service);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(service, actualRequest.getService());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method updateServiceTest.
@Test
public void updateServiceTest() throws Exception {
Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
Service service = Service.newBuilder().build();
Service actualResponse = client.updateService(service);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateServiceRequest actualRequest = ((UpdateServiceRequest) actualRequests.get(0));
Assert.assertEquals(service, actualRequest.getService());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method getServiceLevelObjectiveTest2.
@Test
public void getServiceLevelObjectiveTest2() 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);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method listServiceLevelObjectivesTest.
@Test
public void listServiceLevelObjectivesTest() throws Exception {
ServiceLevelObjective responsesElement = ServiceLevelObjective.newBuilder().build();
ListServiceLevelObjectivesResponse expectedResponse = ListServiceLevelObjectivesResponse.newBuilder().setNextPageToken("").addAllServiceLevelObjectives(Arrays.asList(responsesElement)).build();
mockServiceMonitoringService.addResponse(expectedResponse);
ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
ListServiceLevelObjectivesPagedResponse pagedListResponse = client.listServiceLevelObjectives(parent);
List<ServiceLevelObjective> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServiceLevelObjectivesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServiceLevelObjectivesRequest actualRequest = ((ListServiceLevelObjectivesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service 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()) {
* String name =
* ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
* "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
* .toString();
* 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(String name) {
DeleteServiceLevelObjectiveRequest request = DeleteServiceLevelObjectiveRequest.newBuilder().setName(name).build();
deleteServiceLevelObjective(request);
}
Aggregations