use of com.google.cloud.servicedirectory.v1.Service in project axis-axis2-java-core by apache.
the class WSDL20ToAxisServiceBuilder method processService.
private void processService() throws AxisFault {
Service[] services = description.getServices();
if (services.length == 0) {
throw new AxisFault("No wsdlService found in the WSDL");
}
if (serviceName != null) {
for (int i = 0; i < services.length; i++) {
if (serviceName.equals(services[i].getName())) {
wsdlService = services[i];
// found it. Stop looking.
break;
}
}
if (wsdlService == null) {
throw new AxisFault("Service with the specified name not found in the WSDL : " + serviceName.getLocalPart());
}
} else {
wsdlService = services[0];
}
axisService.setName(wsdlService.getName().getLocalPart());
Interface serviceInterface = wsdlService.getInterface();
axisService.addParameter(new Parameter(WSDL2Constants.INTERFACE_LOCAL_NAME, serviceInterface.getName().getLocalPart()));
processInterface(serviceInterface);
if (isCodegen) {
axisService.setOperationsNameList(operationNames);
}
processEndpoints(serviceInterface);
}
use of com.google.cloud.servicedirectory.v1.Service in project ovirt-engine-sdk-java by oVirt.
the class HttpConnection method followLink.
@Override
public <TYPE> TYPE followLink(TYPE object) {
if (!isLink(object)) {
throw new Error("Can't follow link because object don't have any");
}
String href = getHref(object);
if (href == null) {
throw new Error("Can't follow link because the 'href' attribute does't have a value");
}
try {
URL url = new URL(getUrl());
String prefix = url.getPath();
if (!prefix.endsWith("/")) {
prefix += "/";
}
if (!href.startsWith(prefix)) {
throw new Error("The URL '" + href + "' isn't compatible with the base URL of the connection");
}
// Get service based on path
String path = href.substring(prefix.length());
Service service = systemService().service(path);
// Obtain method which provides result object and invoke it:
Method get;
if (object instanceof ListWithHref) {
get = service.getClass().getMethod("list");
} else {
get = service.getClass().getMethod("get");
}
Object getRequest = get.invoke(service);
Method send = getRequest.getClass().getMethod("send");
send.setAccessible(true);
Object getResponse = send.invoke(getRequest);
for (Method obtainObject : getResponse.getClass().getDeclaredMethods()) {
if (obtainObject.getParameterCount() == 0) {
obtainObject.setAccessible(true);
return (TYPE) obtainObject.invoke(getResponse);
}
}
throw new NoSuchMethodException("No obtain method found");
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
throw new Error(String.format("Unexpected error while following link \"%1$s\"", href), ex);
} catch (MalformedURLException ex) {
throw new Error(String.format("Error while creating URL \"%1$s\"", getUrl()), ex);
}
}
use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.
the class ServicesCreate method createService.
// Create a new service.
public static void createService(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 namespace to create the service in.
NamespaceName parent = NamespaceName.of(projectId, locationId, namespaceId);
// The service object to create.
// Optionally add some annotations for the service.
Service service = Service.newBuilder().putAnnotations("protocol", "tcp").build();
// Send the request to create the namespace.
Service createdService = client.createService(parent, service, serviceId);
// Process the response.
System.out.println("Created Service: " + createdService.getName());
System.out.println("Annotations: " + createdService.getAnnotations());
}
}
use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.
the class EndpointsCreate method createEndpoint.
// Create a new endpoint.
public static void createEndpoint(String projectId, String locationId, String namespaceId, String serviceId, String endpointId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The service to create the endpoint in.
ServiceName parent = ServiceName.of(projectId, locationId, namespaceId, serviceId);
// The endpoint to create, with fields filled in.
// Optionally set an IP address and port for the endpoint.
Endpoint endpoint = Endpoint.newBuilder().setAddress("10.0.0.1").setPort(443).build();
// Send the request to create the endpoint.
Endpoint createdEndpoint = client.createEndpoint(parent, endpoint, endpointId);
// Process the response.
System.out.println("Created Endpoint: " + createdEndpoint.getName());
System.out.println("IP Address: " + createdEndpoint.getAddress());
System.out.println("Port: " + createdEndpoint.getPort());
}
}
use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.
the class RegistrationServiceClientTest method listEndpointsTest.
@Test
public void listEndpointsTest() throws Exception {
Endpoint responsesElement = Endpoint.newBuilder().build();
ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
mockRegistrationService.addResponse(expectedResponse);
ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations