com.openshift.restclient.model.IResource Java Examples

The following examples show how to use com.openshift.restclient.model.IResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenshiftClientStorageProvider.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public ClientModel getClientByClientId(String clientId, RealmModel realm) {
    Matcher matcher = OpenshiftClientStorageProviderFactory.SERVICE_ACCOUNT_PATTERN.matcher(clientId);
    IResource resource = null;

    if (matcher.matches()) {
        resource = getServiceAccount(matcher.group(2), matcher.group(1));
    } else {
        String defaultNamespace = providerModel.get(OpenshiftClientStorageProviderFactory.CONFIG_PROPERTY_DEFAULT_NAMESPACE);

        if (defaultNamespace != null) {
            resource = getServiceAccount(clientId, defaultNamespace);
        }
    }

    if (resource == null) {
        return null;
    }

    return new OpenshiftSAClientAdapter(clientId, resource, client, session, realm, providerModel);
}
 
Example #2
Source File: ServiceWatcher.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void received(IResource resource, ChangeType change) {
    if (change.equals(ChangeType.ADDED)) {
        // Add new Service to topology
        IService service = (IService) resource;

        registrationsForService(service)
                .forEach(topologyManagerInjector.getValue()::register);
    } else if (change.equals(ChangeType.DELETED)) {
        // Remove Service from topology
        topologyManagerInjector.getValue().unregisterAll(TOPOLOGY_SOURCE_KEY, resource.getName());
    }
}
 
Example #3
Source File: ServiceWatcher.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void connected(List<IResource> resources) {
    this.listenerState.set(ListenerState.CONNECTED);

    resources.stream()
            .filter(p -> p.getKind().equals(ResourceKind.SERVICE))
            .forEach(r -> {
                Set<Registration> regs = registrationsForService((IService) r);
                regs.forEach(topologyManagerInjector.getValue()::register);
            });
}
 
Example #4
Source File: OpenshiftClientStorageProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private IResource getServiceAccount(String name, String namespace) {
    try {
        return client.get("ServiceAccount", name, namespace);
    } catch (NotFoundException nfe) {
        return null;
    }
}
 
Example #5
Source File: OpenshiftStartedEnvironment.java    From pnc with Apache License 2.0 5 votes vote down vote up
/**
 * Try to delete an openshift resource. If it doesn't exist, it's fine
 *
 * @param resource Openshift resource to delete
 * @param <T>
 */
private <T extends IResource> void tryOpenshiftDeleteResource(T resource) {
    try {
        client.delete(resource);
    } catch (NotFoundException e) {
        logger.warn("Couldn't delete the Openshift resource since it does not exist", e);
    }
}
 
Example #6
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends IResource> T execute(String httpMethod, String kind,
        String namespace, String name, String subresource,
        IResource payload, String subcontext) {
    return (T) retry(() -> client.execute(httpMethod, kind, namespace,
            name, subresource, payload, subcontext));
}
 
Example #7
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends IResource> T execute(String httpMethod, String kind,
        String namespace, String name, String subresource,
        IResource payload, Map<String, String> params) {
    return (T) retry(() -> client.execute(httpMethod, kind, namespace,
            name, subresource, payload, params));
}
 
Example #8
Source File: OpenshiftSAClientAdapter.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public OpenshiftSAClientAdapter(String clientId, IResource resource, IClient client, KeycloakSession session, RealmModel realm, ClientStorageProviderModel component) {
    super(session, realm, component);
    this.resource = resource;
    this.clientId = clientId;
    this.client = client;
}
 
Example #9
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public String getResourceURI(IResource resource) {
    return client.getResourceURI(resource);
}
 
Example #10
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> T execute(String httpMethod, String kind,
        String namespace, String name, String subresource, IResource payload) {
    return (T) retry(() -> client.execute(httpMethod, kind, namespace,
            name, subresource, payload));
}
 
Example #11
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> void delete(T resource) {
    retry(() -> client.delete(resource));
}
 
Example #12
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> T update(T resource) {
    return (T) retry(() -> client.update(resource));
}
 
Example #13
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<IResource> create(IList list, String namespace) {
    return (Collection<IResource>) retry(() -> client.create(list,
            namespace));
}
 
Example #14
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> T create(String kind, String namespace,
        String name, String subresource, IResource payload) {
    return (T) retry(() -> client.create(kind, namespace, name,
            subresource, payload));
}
 
Example #15
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> T create(T resource, String namespace) {
    return (T) retry(() -> client.create(resource, namespace));
}
 
Example #16
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> T create(T resource) {
    return (T) retry(() -> client.create(resource));
}
 
Example #17
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> T get(String kind, String name,
        String namespace) {
    return (T) retry(() -> client.get(kind, name, namespace));
}
 
Example #18
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> List<T> list(String kind, String namespace,
        String labelQuery) {
    return (List<T>) retry(() -> client.list(kind, namespace, labelQuery));
}
 
Example #19
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> List<T> list(String kind, String namespace,
        Map<String, String> labels) {
    return (List<T>) retry(() -> client.list(kind, namespace, labels));
}
 
Example #20
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> List<T> list(String kind, String namespace) {
    return (List<T>) retry(() -> client.list(kind, namespace));
}
 
Example #21
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> List<T> list(String kind,
        Map<String, String> labels) {
    return (List<T>) retry(() -> client.list(kind, labels));
}
 
Example #22
Source File: RetryIClient.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends IResource> List<T> list(String kind) {
    return (List<T>) retry(() -> client.list(kind));
}