Here is some sample code to help you get going using this library in your own projects.
IOpenShiftConnection connection = new OpenShiftConnectionFactory().getConnection("my_user_application", "user", "password");
IUser user = connection.getUser(); System.out.println("RHLogin:\t" + user.getRhlogin());
IUser user = connection.getUser(); IDomain domain = user.createDomain("myDomain");
IDomain domain = user.getDefaultDomain(); System.out.println("Namespace:\t" + domain.getId());
IApplication as7Application = domain.createApplication("myApplication", LatestVersionOf.jbossAs().get(user));
for (IApplication application : domain.getApplications()) { System.out.println(application.getName()); System.out.println("\tFramework:\t" + application.getCartridge().getName()); System.out.println("\tCreation:\t" + application.getCreationTime()); System.out.println("\tUUID:\t\t" + application.getUUID()); System.out.println("\tGit URL:\t" + application.getGitUrl()); System.out.println("\tPublic URL:\t" + application.getApplicationUrl() + "\n"); }
IEmbeddedCartridge mySqlCartridge = as7Application.addEmbeddableCartridge(LatestVersionOf.mySQL().get(user));
for(IEmbeddedCartridge cartridge : application.getEmbeddedCartridges()) { System.out.println("\t" + cartridge.getName() + " - URL:" + cartridge.getUrl()); }
String mySqlConnectionUrl = mySqlCartridge.getUrl();
ISSHPublicKey key = new SSHPublicKey(SSH_PUBLIC_KEY); IOpenShiftSSHKey addedKey = user.getSSHKeyByPublicKey(key.getPublicKey()); if (addedKey == null) { user.putSSHKey(String.valueOf(System.currentTimeMillis()), key); }
enable-openshift-ci: full example using openshift-java-client