Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Mission statement: automate everything, experiment often, drive POC

...

Exercise ONAP programmatically via M2M (Rest client) calls.  See the existing VID and proposed VID project and the associated vm1-robot VM.

Experimental

Spring Boot REST Endpoint for

...

JAX-RS 2.0 Client

Purpose: Experiment with JAX-RS 2.0 clients as OSS demonstrations.

Client

package org.onap.demo.oss;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;

public class OSSRestClient {
private static final String IP = "104.239.99.99";
private static final String HTTP_PORT = "88";

private void robotHealthCheck() {
Client client = ClientBuilder.newClient();
client.register(new Authenticator("test","test"));
WebTarget rootTarget = client.target("http://" + IP + ":" + HTTP_PORT);
WebTarget latestTarget = rootTarget.path("/");
try {
System.out.println(latestTarget.request().get(String.class));
} catch (Exception e) { e.printStackTrace();
} finally { client.close(); }
}

public static void main(String[] args) {
OSSRestClient client = new OSSRestClient();
client.robotHealthCheck();
}
}
package org.onap.demo.oss;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;

import javax.xml.bind.DatatypeConverter;

public class Authenticator implements ClientRequestFilter {
private final String user;
private final String pass;

public Authenticator(String user, String password) {
this.user = user; this.pass = password;
}

public void filter(ClientRequestContext requestContext) throws IOException {
MultivaluedMap<String, Object> headMap = requestContext.getHeaders();
String basicAuth = null;
try {
String aToken = user + ":" + pass;
basicAuth = "BASIC " + DatatypeConverter.printBase64Binary(aToken.getBytes("UTF-8"));
} catch (UnsupportedEncodingException uee) { throw new IllegalStateException("Encoding with UTF-8 failed", uee);}
headMap.add("Authorization", basicAuth);
}
}



Backend


References

https://spring.io/guides/gs/actuator-service/

...