GithubHelp home page GithubHelp logo

global19-atlassian-net / openshift-restclient-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openshift/openshift-restclient-java

0.0 2.0 0.0 4.19 MB

License: Other

HTML 1.01% Java 98.94% Shell 0.06%

openshift-restclient-java's Introduction

OpenShift Java REST Client

Travis Maven Central

The project is now in the maintenance mode. Only critical bugs will be fixed, and there won’t be any more feature development. Please consider moving to the OpenShift client library that's developed by the great team at fabric8.

This is the Java REST client for the version 3 architecture of OpenShift based on Kubernetes. The implementation is a work in progress to provide similar functionality and features of the command-line interface and is used by JBoss Tools for OpenShift. For compatibility with OpenShift 2.x see https://github.com/openshift/openshift-java-client/.

For questions or feedback, reach us on IRC on #openshift-client on Freenode or post to our mailing list

Download

You may either build from source using maven (mvn clean package) which, using the master branch, will generate a snapshot build of the latest updates. You may also retrieve final released jars from Maven Central.

Compatibility

Versions of this client known to be compatible with OpenShift

Client Version OpenShift Origin Server
5.4.0-SNAPSHOT v1.3.0
5.0.0-SNAPSHOT latest, v1.3.0-alpha.2
v1.3.0-alpha.3

Usage

Creating a client:

IClient client = new ClientBuilder("https://api.preview.openshift.com")
	.withUserName("openshiftdev")
	.withPassword("wouldntUlik3T0kn0w")
	.build();

This will authorize the client if the cluster is configured for basic authorization. The alternative is to retrieve your OAUTH token and provide it to the client. The token can be set with the builder or later by accessing the authorization context:

client.getAuthorizationContext().setToken("asfdsfd8a70a3qrfafdsadsf786324");

Create a project to associate with your application by submitting a project request:

IResource request = client.getResourceFactory().stub(ResourceKind.PROJECT_REQUEST, "myfirstproject");
IProject project =  (IProject)client.create(request);

Resources can be created by stubbing which will instantiate and instance of the resource but not create it on the server:

IService service = client.getResourceFactory().stub(ResourceKind.SERVICE, "myfirstservice", project.getName());
service.setSelector(labelSelectors);
service = client.create(service);

The client as well as resources supported by OpenShift may have certain capabilities that are instantiated when the resource is initialized. The capabilities are implemented using an adapter pattern and used like the following to create a BuildConfig:

IBuildConfig buildConfig = client.accept(new CapabilityVisitor<IBuildConfigBuilder, IBuildConfig>() {

		@Override
		public IBuildConfig visit(IBuildConfigBuilder builder) {
			return builder
					.named("mybuildconfig")
					.inNamespace(project.getName())
					.fromGitSource()
						.fromGitUrl("https://github.com/openshift/rails-example")
						.usingGitReference("master")
					.end()
					.usingSourceStrategy()
						.fromImageStreamTag("ruby:latest")
						.inNamespace("openshift")
						.withEnvVars(envVars)
					.end()
					.buildOnSourceChange(true)
					.buildOnConfigChange(true)
					.buildOnImageChange(true)
					.toImageStreamTag("mybuildconfig:latest")
				.build();
		}
	}, null);

Various examples of using the capabilities may be found in the integration tests.

Testing

To run the integration tests:

  1. Define a user with cluster admin privilege
  2. Download the oc binary
  3. Run the tests: mvn integration-test -Pintegration-tests -DserverURL=https://localhost:8443 -Ddefault.cluster.admin=foo -Ddefault.cluster.password=bar -Ddefault.openshift.location=/tmp/oc

openshift-restclient-java's People

Contributors

adietish avatar aleksigold avatar alfonzjanfrithz avatar apupier avatar aslakknutsen avatar bdecoste avatar bdshadow avatar brenton avatar coreydaley avatar dilation avatar dsimansk avatar fbricon avatar gabemontero avatar grdryn avatar ironcladlou avatar jcantrill avatar jeffmaury avatar jupierce avatar klenkes74 avatar lulf avatar opensas avatar openshift-bot avatar openshift-merge-robot avatar scabanovich avatar skavanagh avatar smarterclayton avatar stealth-ip avatar syediqbal avatar transamericamoon avatar xcoulon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.