Search in sources :

Example 46 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.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);
}
Also used : AxisFault(org.apache.axis2.AxisFault) Service(org.apache.woden.wsdl20.Service) Endpoint(org.apache.woden.wsdl20.Endpoint) Interface(org.apache.woden.wsdl20.Interface)

Example 47 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.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);
    }
}
Also used : ListWithHref(org.ovirt.api.metamodel.runtime.util.ListWithHref) MalformedURLException(java.net.MalformedURLException) Error(org.ovirt.engine.sdk4.Error) SystemService(org.ovirt.engine.sdk4.services.SystemService) Service(org.ovirt.engine.sdk4.Service) Method(java.lang.reflect.Method) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 48 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.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());
    }
}
Also used : NamespaceName(com.google.cloud.servicedirectory.v1.NamespaceName) Service(com.google.cloud.servicedirectory.v1.Service) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient)

Example 49 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project openstack4j by ContainX.

the class KeystoneToken method getAggregatedCatalog.

/**
 * {@inheritDoc}
 */
@Override
@JsonIgnore
public SortedSetMultimap<String, Service> getAggregatedCatalog() {
    if (aggregatedCatalog == null) {
        synchronized (this) {
            if (aggregatedCatalog == null) {
                aggregatedCatalog = TreeMultimap.create();
                for (Service sc : catalog) {
                    String nameKey = TYPE_WITHOUT_VERSION.apply(sc.getName());
                    String typeKey = TYPE_WITHOUT_VERSION.apply(sc.getType());
                    aggregatedCatalog.put(nameKey, sc);
                    aggregatedCatalog.put(typeKey, sc);
                }
            }
        }
    }
    return aggregatedCatalog;
}
Also used : Service(org.openstack4j.model.identity.v3.Service) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 50 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project cloudbreak by hortonworks.

the class OpenStackClient method getRegion.

public Set<String> getRegion(CloudCredential cloudCredential) {
    Access access = createAccess(cloudCredential);
    Token token = createToken(cloudCredential);
    Set<String> regions = new HashSet<>();
    if (token == null && access == null) {
        throw new CloudConnectorException("Unsupported keystone version");
    } else if (token != null) {
        for (Service service : token.getCatalog()) {
            for (Endpoint endpoint : service.getEndpoints()) {
                regions.add(endpoint.getRegion());
            }
        }
    } else {
        for (Access.Service service : access.getServiceCatalog()) {
            for (org.openstack4j.model.identity.v2.Endpoint endpoint : service.getEndpoints()) {
                regions.add(endpoint.getRegion());
            }
        }
    }
    LOGGER.info("regions from openstack: {}", regions);
    return regions;
}
Also used : Endpoint(org.openstack4j.model.identity.v3.Endpoint) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) Access(org.openstack4j.model.identity.v2.Access) Service(org.openstack4j.model.identity.v3.Service) Token(org.openstack4j.model.identity.v3.Token) HashSet(java.util.HashSet)

Aggregations

Test (org.junit.jupiter.api.Test)34 Service (io.fabric8.knative.serving.v1.Service)28 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 CoreException (org.eclipse.core.runtime.CoreException)18 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)16 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)16 Test (org.junit.Test)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 AbstractMessage (com.google.protobuf.AbstractMessage)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)11 ProdBuildResults (io.quarkus.test.ProdBuildResults)11 ProdModeTestResults (io.quarkus.test.ProdModeTestResults)11 QuarkusProdModeTest (io.quarkus.test.QuarkusProdModeTest)11 Path (java.nio.file.Path)11 ArrayList (java.util.ArrayList)11 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)11 List (java.util.List)10 DisplayName (org.junit.jupiter.api.DisplayName)10