import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.apim.poseidon.request.PoseidonRequest;
import com.google.common.net.HttpHeaders;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
public class Sample {
private static String accessKey = "AccessKey of your APP";
private static String secretKey = "SecretKey of your APP";
private static String orgId = "yourOrgId";
private static String chId = "yourChannelId";
private static String action = "start";
private static String url = "https://{domain_url}";
private static class Request extends PoseidonRequest {
public void setQueryParam(String key, Object value) {
queryEncodeParams().put(key, value);
}
public void setMethod(String method) {
this.method = method;
}
public void setBodyParams(String key, Object value) {
bodyParams().put(key, value);
}
private String method;
@Override
public String baseUri() {
return "";
}
@Override
public String method() {
return method;
}
}
@Test
public void operateChannel() {
Request request = new Request();
request.setQueryParam("orgId", orgId);
request.setQueryParam("action", action);
Map<String, Object> resource = new HashMap<>();
resource.put("resourceId", "federation_2n6nb7");
resource.put("resourceConfig", "2");
resource.put("ifMultiResourceAnalysis", false);
request.setQueryParam("resource", resource);
request.setMethod("POST");
try {
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey))
.url(url + "/data-federation/v2.0/channels/" + chId)
.getResponse(request, JSONObject.class);
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
}
}