Bug in OpenShift

The parameter “id” of the “Create Domain” operation is actually called “name”.

https://bugzilla.redhat.com/show_bug.cgi?id=998275

Advertisements

How to Delete a SSH Key in OpenShift

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    client.target("https://host/broker/rest/user/keys/sampleKey").request().delete();

    client.close();
  }

}

How to Update a SSH Key in OpenShift

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    client.target("https://host/broker/rest/user/keys/sampleKey").queryParam("type", "sampleType").queryParam("content", "sampleContent").request().put(Entity.json(""));

    client.close();
  }

}

How to Retrieve a SSH Key in OpenShift

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    final Response res = client.target("https://host/broker/rest/user/keys/sampleKey").request().get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

How to List SSH Keys in OpenShift

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    final Response res = client.target("https://host/broker/rest/user/keys").request().get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

How to Add a SSH Key in OpenShift

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    client.target("https://host/broker/rest/user/keys").queryParam("name", "sampleKey").queryParam("type", "sampleType").queryParam("content", "sampleContent").request().post(Entity.json(""));

    client.close();
  }

}

How to Delete an User in OpenShift

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    client.target("https://host/broker/rest/user").request().delete();

    client.close();
  }

}

How to Retrieve an User in OpenShift

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    final Response res = client.target("https://host/broker/rest/user").request().get();

    out.println(res.readEntity(String.class));

    client.close();
  }

}

How to Reload a Cartridge of an Application in OpenShift

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    client.target("https://host/broker/rest/domains/sampleDomain/applications/sampleApplication/cartridges/sampleCartridge/events").queryParam("event", "reload").request().post(Entity.json(""));

    client.close();
  }

}

How to Restart a Cartridge of an Application in OpenShift

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public final class OpenShiftSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.register(HttpAuthenticationFeature.basic("sampleUsername", "samplePassword"));

    client.target("https://host/broker/rest/domains/sampleDomain/applications/sampleApplication/cartridges/sampleCartridge/events").queryParam("event", "restart").request().post(Entity.json(""));

    client.close();
  }

}