All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.openshift.internal.restclient.capability.resources.ProjectTemplateListCapability Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc.
 * All rights reserved. This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: Red Hat, Inc. - initial API and implementation
 ******************************************************************************/

package com.openshift.internal.restclient.capability.resources;

import java.util.Collection;

import com.openshift.restclient.IClient;
import com.openshift.restclient.ResourceKind;
import com.openshift.restclient.capability.resources.IProjectTemplateList;
import com.openshift.restclient.model.IProject;
import com.openshift.restclient.model.template.ITemplate;

public class ProjectTemplateListCapability implements IProjectTemplateList {

    private static final String COMMON_NAMESPACE = "openshift"; // eventually configurable
    private IProject project;
    private IClient client;

    public ProjectTemplateListCapability(IProject project, IClient client) {
        this.project = project;
        this.client = client;
    }

    @Override
    public boolean isSupported() {
        return client != null && project != null;
    }

    @Override
    public String getName() {
        return this.getClass().getSimpleName();
    }

    @Override
    public Collection getTemplates() {
        return client.list(ResourceKind.TEMPLATE, project.getNamespaceName());
    }

    @Override
    public Collection getCommonTemplates() {
        return getCommonTemplates(COMMON_NAMESPACE);
    }

    @Override
    public Collection getCommonTemplates(String clusterNamespace) {
        return client.list(ResourceKind.TEMPLATE,
                clusterNamespace == null ? COMMON_NAMESPACE : clusterNamespace);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy