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

com.openshift.internal.client.AbstractOpenShiftConnectionFactory Maven / Gradle / Ivy

/******************************************************************************* 
 * Copyright (c) 2012-2014 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.client;

import java.io.IOException;
import java.util.Collections;
import java.util.Map;

import com.openshift.client.HttpMethod;
import com.openshift.client.IHttpClient;
import com.openshift.client.IOpenShiftConnection;
import com.openshift.client.OpenShiftException;
import com.openshift.internal.client.httpclient.request.Parameter;
import com.openshift.internal.client.response.Link;
import com.openshift.internal.client.response.RestResponse;

/**
 * Connection Factory, used to establish a connection and retrieve a user.
 * 
 * @author Xavier Coulon
 * @author Andre Dietisheim
 * @author Sean Kavanagh
 * 
 */
public abstract class AbstractOpenShiftConnectionFactory {
	
	@SuppressWarnings("unchecked")
	protected IOpenShiftConnection getConnection(IRestService service, final String login, final String password, final String token) throws IOException, OpenShiftException {
		RestResponse response =
				(RestResponse) service.request(
						new Link("Get API", "/api", HttpMethod.GET), 
						IHttpClient.NO_TIMEOUT,
						Collections. emptyList(), 
						Collections. emptyList());
		return new APIResource(login, password, token, service, (Map) response.getData());
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy