Status initialStatus,
long start,
long end) {
final FutureData<PushSubscription> future = new FutureData<>();
URI uri = newParams().forURL(config.newAPIEndpointURI(CREATE));
POST request = config.http()
.POST(uri, new PageReader(newRequestCallback(future, new PushSubscription(), config)))
.form("output_type", "pull")
.form("output_params.acl", "private")
.form("name", name);
if (type != null) {
request.form("output_params.format", type.asString());
}
if (historics != null && stream != null) {
throw new IllegalStateException("Historics and Stream cannot both be specified");
}
if (historics == null && stream == null) {
throw new IllegalArgumentException("At least one of Historics OR Stream must be specified");
}
if (historics != null) {
request.form("historics_id", historics.getId());
}
if (stream != null) {
request.form("hash", stream.hash());
}
if (initialStatus != null) {
request.form("initial_status", initialStatus.val());
}
if (start > 0) {
request.form("start", start);
}
if (end > 0) {
request.form("end", end);
}
applyConfig(request).execute();
return future;
}