use of com.google.cloud.servicedirectory.v1.Service in project dekorate by dekorateio.
the class Issue586ScaleBoundsTest method shouldContainMinAndMaxBounds.
@Test
public void shouldContainMinAndMaxBounds() {
KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
assertNotNull(list);
Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException());
String minScale = s.getMetadata().getAnnotations().get("autoscaling.knative.dev/minScale");
String maxScale = s.getMetadata().getAnnotations().get("autoscaling.knative.dev/maxScale");
assertEquals("3", minScale);
assertEquals("5", maxScale);
}
use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listServicesTest.
@Test
public void listServicesTest() throws Exception {
Service responsesElement = Service.newBuilder().build();
ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]");
ListServicesPagedResponse pagedListResponse = client.listServices(parent);
List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.
the class ServicesDelete method deleteService.
// Delete a service.
public static void deleteService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The service to delete.
ServiceName serviceName = ServiceName.of(projectId, locationId, namespaceId, serviceId);
// Send the request to delete the service.
client.deleteService(serviceName);
// Log the action.
System.out.println("Deleted Service: " + serviceName.toString());
}
}
use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.
the class ServicesResolve method resolveService.
// Resolve a service.
public static void resolveService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (LookupServiceClient client = LookupServiceClient.create()) {
// The service to resolve.
ServiceName name = ServiceName.of(projectId, locationId, namespaceId, serviceId);
// Construct the resolve request to be sent to the client.
ResolveServiceRequest request = ResolveServiceRequest.newBuilder().setName(name.toString()).build();
// Send the request to resolve the service.
ResolveServiceResponse resolveResponse = client.resolveService(request);
// Process the response.
System.out.println("Resolved Service: " + resolveResponse.getService().getName());
System.out.println("Endpoints found:");
for (Endpoint endpoint : resolveResponse.getService().getEndpointsList()) {
System.out.println(endpoint.getName() + " -- " + endpoint.getAddress() + ":" + endpoint.getPort());
}
}
}
Aggregations