retryJitterFactor() {
return this.retryJitterFactor;
}
+ /**
+ * Releases resources owned by this client. Only shuts down the underlying OkHttpClient's
+ * dispatcher executor and evicts its connection pool when this client created that
+ * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the
+ * caller owns its lifecycle.
+ *
+ * In-flight calls are not cancelled or awaited, and any request issued after this method
+ * returns fails with a {@code RejectedExecutionException}. Options derived from this one via
+ * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either
+ * releases them for both. Calling this method more than once has no further effect.
+ *
+ * WebSocket clients created from this client that are still connected are disconnected
+ * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the
+ * dispatcher goes away. Any WebSocket connect or reconnect attempted afterwards fails with
+ * an {@code IllegalStateException} explaining that the client has been closed.
+ */
+ public void close() {
+ if (!this.closed.compareAndSet(false, true)) {
+ return;
+ }
+ for (AutoCloseable webSocket : new ArrayList<>(this.openWebSockets)) {
+ try {
+ webSocket.close();
+ } catch (Exception e) {
+ // best effort; keep closing the remaining sockets and the HTTP client
+ }
+ }
+ this.openWebSockets.clear();
+ if (!this.ownsHttpClient) {
+ return;
+ }
+ this.httpClient.dispatcher().executorService().shutdown();
+ this.httpClient.connectionPool().evictAll();
+ }
+
+ /**
+ * Returns whether {@link #close()} has been called on this client.
+ */
+ public boolean isClosed() {
+ return this.closed.get();
+ }
+
+ /**
+ * Tracks a connected WebSocket client so that {@link #close()} disconnects it.
+ *
+ * @throws IllegalStateException if this client has already been closed
+ */
+ public void registerWebSocket(AutoCloseable webSocket) {
+ this.openWebSockets.add(webSocket);
+ if (this.closed.get()) {
+ this.openWebSockets.remove(webSocket);
+ throw new IllegalStateException("root client has been closed");
+ }
+ }
+
+ /**
+ * Stops tracking a WebSocket client that has been disconnected.
+ */
+ public void unregisterWebSocket(AutoCloseable webSocket) {
+ this.openWebSockets.remove(webSocket);
+ }
+
public Optional logging() {
return this.logging;
}
@@ -145,6 +223,12 @@ public static class Builder {
private OkHttpClient httpClient = null;
+ private boolean ownsHttpClient = true;
+
+ private AtomicBoolean closed;
+
+ private Set openWebSockets;
+
private Optional logging = Optional.empty();
public Builder environment(Environment environment) {
@@ -212,8 +296,13 @@ public Builder retryJitterFactor(double retryJitterFactor) {
return this;
}
+ /**
+ * Sets the underlying OkHttp client. The caller retains ownership of its lifecycle:
+ * close() will not shut down its dispatcher executor or evict its connection pool.
+ */
public Builder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
+ this.ownsHttpClient = httpClient == null;
return this;
}
@@ -255,11 +344,18 @@ public ClientOptions build() {
this.httpClient = httpClientBuilder.build();
this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000);
+ AtomicBoolean closedToUse = this.closed != null ? this.closed : new AtomicBoolean(false);
+ Set openWebSocketsToUse =
+ this.openWebSockets != null ? this.openWebSockets : ConcurrentHashMap.newKeySet();
+
return new ClientOptions(
environment,
headers,
headerSuppliers,
httpClient,
+ this.ownsHttpClient,
+ closedToUse,
+ openWebSocketsToUse,
this.timeout.get(),
this.maxRetries,
this.initialRetryDelayMillis,
@@ -276,6 +372,9 @@ public static Builder from(ClientOptions clientOptions) {
builder.environment = clientOptions.environment();
builder.timeout = Optional.of(clientOptions.timeout(null));
builder.httpClient = clientOptions.httpClient();
+ builder.ownsHttpClient = clientOptions.ownsHttpClient;
+ builder.closed = clientOptions.closed;
+ builder.openWebSockets = clientOptions.openWebSockets;
builder.headers.putAll(clientOptions.headers);
builder.headerSuppliers.putAll(clientOptions.headerSuppliers);
builder.maxRetries = clientOptions.maxRetries();
diff --git a/src/main/java/com/newscatcher/catchall/core/RetryInterceptor.java b/src/main/java/com/newscatcher/catchall/core/RetryInterceptor.java
index 966ddca..783accd 100644
--- a/src/main/java/com/newscatcher/catchall/core/RetryInterceptor.java
+++ b/src/main/java/com/newscatcher/catchall/core/RetryInterceptor.java
@@ -10,9 +10,13 @@
import java.time.format.DateTimeParseException;
import java.util.Optional;
import java.util.Random;
+import okhttp3.Call;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
+import okhttp3.ResponseBody;
+import okio.AsyncTimeout;
+import okio.Timeout;
public class RetryInterceptor implements Interceptor {
@@ -78,13 +82,28 @@ private Response retryChain(Response response, Chain chain, int maxRetries) thro
ExponentialBackoff backoff = new ExponentialBackoff(maxRetries);
Optional nextBackoff = backoff.nextBackoff(response);
while (nextBackoff.isPresent()) {
+ response = bufferResponse(response);
+ Optional callTimeout = suspendCallTimeout(chain);
try {
Thread.sleep(nextBackoff.get().toMillis());
} catch (InterruptedException e) {
+ response.close();
throw new IOException("Interrupted while trying request", e);
+ } finally {
+ callTimeout.ifPresent(AsyncTimeout::enter);
+ }
+ Response nextResponse;
+ try {
+ nextResponse = chain.proceed(chain.request());
+ } catch (IOException e) {
+ // A retry attempt failed with a transport error (connection reset, unreachable host, ...). The
+ // error is intentionally dropped: the response already received from the API is more actionable.
+ // Note that a call-timeout expiry or an explicit cancel() also ends up here, but OkHttp then
+ // discards whatever the interceptor chain returns and reports the cancellation itself.
+ return response;
}
response.close();
- response = chain.proceed(chain.request());
+ response = nextResponse;
if (shouldRetry(response.code())) {
nextBackoff = backoff.nextBackoff(response);
} else {
@@ -95,6 +114,51 @@ private Response retryChain(Response response, Chain chain, int maxRetries) thro
return response;
}
+ /**
+ * Pauses the OkHttp call timeout so that it applies to each attempt individually rather than to the whole
+ * retry loop: the backoff wait (e.g. a {@code Retry-After} the size of the call timeout) does not consume the
+ * budget of the next attempt, and each attempt starts with a fresh budget once {@link AsyncTimeout#enter()}
+ * is called again.
+ *
+ * {@link AsyncTimeout#exit()} and {@link AsyncTimeout#enter()} must stay strictly paired: {@code exit()} on
+ * a timeout that is not armed is a no-op, but {@code enter()} on one that is already armed throws
+ * {@code IllegalStateException}. Every caller must re-enter the returned timeout exactly once, on all paths.
+ */
+ private static Optional suspendCallTimeout(Chain chain) {
+ Call call = chain.call();
+ if (call == null) {
+ return Optional.empty();
+ }
+ Timeout timeout = call.timeout();
+ if (!(timeout instanceof AsyncTimeout)) {
+ return Optional.empty();
+ }
+ AsyncTimeout callTimeout = (AsyncTimeout) timeout;
+ callTimeout.exit();
+ return Optional.of(callTimeout);
+ }
+
+ /**
+ * Reads the body into memory so the response stays usable after the underlying connection
+ * is released or cancelled by a later attempt.
+ */
+ private static Response bufferResponse(Response response) {
+ ResponseBody body = response.body();
+ if (body == null) {
+ return response;
+ }
+ try {
+ byte[] bytes = body.bytes();
+ Response buffered = response.newBuilder()
+ .body(ResponseBody.create(bytes, body.contentType()))
+ .build();
+ response.close();
+ return buffered;
+ } catch (IOException e) {
+ return response;
+ }
+ }
+
/**
* Calculates the retry delay from response headers, with fallback to exponential backoff.
* Priority: Retry-After > X-RateLimit-Reset > Exponential Backoff
diff --git a/src/main/java/com/newscatcher/catchall/resources/datasets/AsyncRawDatasetsClient.java b/src/main/java/com/newscatcher/catchall/resources/datasets/AsyncRawDatasetsClient.java
index 36bd41e..3b726e8 100644
--- a/src/main/java/com/newscatcher/catchall/resources/datasets/AsyncRawDatasetsClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/datasets/AsyncRawDatasetsClient.java
@@ -17,6 +17,7 @@
import com.newscatcher.catchall.errors.BadRequestError;
import com.newscatcher.catchall.errors.ForbiddenError;
import com.newscatcher.catchall.errors.NotFoundError;
+import com.newscatcher.catchall.errors.UnauthorizedError;
import com.newscatcher.catchall.errors.UnprocessableEntityError;
import com.newscatcher.catchall.resources.datasets.requests.AddEntitiesToDatasetRequest;
import com.newscatcher.catchall.resources.datasets.requests.CreateDatasetFromCsvRequest;
@@ -161,10 +162,17 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
return;
}
try {
- if (response.code() == 403) {
- future.completeExceptionally(new ForbiddenError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response));
- return;
+ switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
+ case 403:
+ future.completeExceptionally(new ForbiddenError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
@@ -267,6 +275,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -384,6 +397,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -448,6 +466,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -512,6 +535,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -593,6 +621,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -674,6 +707,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -779,6 +817,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -889,6 +932,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1001,6 +1049,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1105,6 +1158,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1209,6 +1267,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1333,6 +1396,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1448,6 +1516,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1550,6 +1623,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1622,6 +1700,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1694,6 +1777,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1783,6 +1871,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -1872,6 +1965,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
diff --git a/src/main/java/com/newscatcher/catchall/resources/datasets/RawDatasetsClient.java b/src/main/java/com/newscatcher/catchall/resources/datasets/RawDatasetsClient.java
index b20460c..84b787f 100644
--- a/src/main/java/com/newscatcher/catchall/resources/datasets/RawDatasetsClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/datasets/RawDatasetsClient.java
@@ -17,6 +17,7 @@
import com.newscatcher.catchall.errors.BadRequestError;
import com.newscatcher.catchall.errors.ForbiddenError;
import com.newscatcher.catchall.errors.NotFoundError;
+import com.newscatcher.catchall.errors.UnauthorizedError;
import com.newscatcher.catchall.errors.UnprocessableEntityError;
import com.newscatcher.catchall.resources.datasets.requests.AddEntitiesToDatasetRequest;
import com.newscatcher.catchall.resources.datasets.requests.CreateDatasetFromCsvRequest;
@@ -152,9 +153,13 @@ public CatchAllApiHttpResponse listDatasets(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DatasetListResponse.class), response);
}
try {
- if (response.code() == 403) {
- throw new ForbiddenError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ case 403:
+ throw new ForbiddenError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
@@ -240,6 +245,9 @@ public CatchAllApiHttpResponse createDataset(
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -339,6 +347,9 @@ public CatchAllApiHttpResponse createDatasetFromCsv(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -384,6 +395,9 @@ public CatchAllApiHttpResponse createDatasetFromCsv(In
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -430,6 +444,9 @@ public CatchAllApiHttpResponse createDatasetFromCsv(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -493,6 +510,9 @@ public CatchAllApiHttpResponse createDatasetFromCsv(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -556,6 +576,9 @@ public CatchAllApiHttpResponse createDatasetFromCsv(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -640,6 +663,9 @@ public CatchAllApiHttpResponse getDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -730,6 +756,9 @@ public CatchAllApiHttpResponse deleteDataset(
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -821,6 +850,9 @@ public CatchAllApiHttpResponse updateDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -905,6 +937,9 @@ public CatchAllApiHttpResponse addEntitiesToDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -989,6 +1024,9 @@ public CatchAllApiHttpResponse removeEntitiesFromDataset
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1091,6 +1129,9 @@ public CatchAllApiHttpResponse listEntitiesInDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1184,6 +1225,9 @@ public CatchAllApiHttpResponse getDatasetStatusHis
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1267,6 +1311,9 @@ public CatchAllApiHttpResponse uploadCsvToDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1318,6 +1365,9 @@ public CatchAllApiHttpResponse uploadCsvToDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1369,6 +1419,9 @@ public CatchAllApiHttpResponse uploadCsvToDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1437,6 +1490,9 @@ public CatchAllApiHttpResponse uploadCsvToDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -1505,6 +1561,9 @@ public CatchAllApiHttpResponse uploadCsvToDataset(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
diff --git a/src/main/java/com/newscatcher/catchall/resources/entities/AsyncRawEntitiesClient.java b/src/main/java/com/newscatcher/catchall/resources/entities/AsyncRawEntitiesClient.java
index ac18ac4..c5ffd13 100644
--- a/src/main/java/com/newscatcher/catchall/resources/entities/AsyncRawEntitiesClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/entities/AsyncRawEntitiesClient.java
@@ -16,6 +16,8 @@
import com.newscatcher.catchall.errors.BadRequestError;
import com.newscatcher.catchall.errors.ForbiddenError;
import com.newscatcher.catchall.errors.NotFoundError;
+import com.newscatcher.catchall.errors.UnauthorizedError;
+import com.newscatcher.catchall.errors.UnprocessableEntityError;
import com.newscatcher.catchall.resources.entities.requests.CreateEntitiesBatchRequest;
import com.newscatcher.catchall.resources.entities.requests.DeleteEntityRequest;
import com.newscatcher.catchall.resources.entities.requests.GetEntityRequest;
@@ -27,6 +29,7 @@
import com.newscatcher.catchall.types.EntityListResponse;
import com.newscatcher.catchall.types.EntityResponse;
import com.newscatcher.catchall.types.Error;
+import com.newscatcher.catchall.types.ValidationErrorResponse;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
@@ -104,6 +107,10 @@ public CompletableFuture> listEntiti
QueryStringMapper.addQueryParameter(
httpUrl, "sort_order", request.getSortOrder().get(), false);
}
+ if (request.getProjectId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "project_id", request.getProjectId().get(), false);
+ }
if (requestOptions != null) {
requestOptions.getQueryParameters().forEach((_key, _value) -> {
httpUrl.addQueryParameter(_key, _value);
@@ -141,10 +148,28 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
return;
}
try {
- if (response.code() == 403) {
- future.completeExceptionally(new ForbiddenError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response));
- return;
+ switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
+ case 403:
+ future.completeExceptionally(new ForbiddenError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
+ case 404:
+ future.completeExceptionally(new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
+ case 422:
+ future.completeExceptionally(new UnprocessableEntityError(
+ ObjectMappers.JSON_MAPPER.readValue(
+ responseBodyString, ValidationErrorResponse.class),
+ response));
+ return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
@@ -241,6 +266,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -342,6 +372,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -441,6 +476,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -546,6 +586,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -663,6 +708,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
diff --git a/src/main/java/com/newscatcher/catchall/resources/entities/RawEntitiesClient.java b/src/main/java/com/newscatcher/catchall/resources/entities/RawEntitiesClient.java
index 8529a13..9a9657b 100644
--- a/src/main/java/com/newscatcher/catchall/resources/entities/RawEntitiesClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/entities/RawEntitiesClient.java
@@ -16,6 +16,8 @@
import com.newscatcher.catchall.errors.BadRequestError;
import com.newscatcher.catchall.errors.ForbiddenError;
import com.newscatcher.catchall.errors.NotFoundError;
+import com.newscatcher.catchall.errors.UnauthorizedError;
+import com.newscatcher.catchall.errors.UnprocessableEntityError;
import com.newscatcher.catchall.resources.entities.requests.CreateEntitiesBatchRequest;
import com.newscatcher.catchall.resources.entities.requests.DeleteEntityRequest;
import com.newscatcher.catchall.resources.entities.requests.GetEntityRequest;
@@ -27,6 +29,7 @@
import com.newscatcher.catchall.types.EntityListResponse;
import com.newscatcher.catchall.types.EntityResponse;
import com.newscatcher.catchall.types.Error;
+import com.newscatcher.catchall.types.ValidationErrorResponse;
import java.io.IOException;
import okhttp3.Headers;
import okhttp3.HttpUrl;
@@ -100,6 +103,10 @@ public CatchAllApiHttpResponse listEntities(
QueryStringMapper.addQueryParameter(
httpUrl, "sort_order", request.getSortOrder().get(), false);
}
+ if (request.getProjectId().isPresent()) {
+ QueryStringMapper.addQueryParameter(
+ httpUrl, "project_id", request.getProjectId().get(), false);
+ }
if (requestOptions != null) {
requestOptions.getQueryParameters().forEach((_key, _value) -> {
httpUrl.addQueryParameter(_key, _value);
@@ -132,9 +139,20 @@ public CatchAllApiHttpResponse listEntities(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, EntityListResponse.class), response);
}
try {
- if (response.code() == 403) {
- throw new ForbiddenError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ case 403:
+ throw new ForbiddenError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ case 404:
+ throw new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ case 422:
+ throw new UnprocessableEntityError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidationErrorResponse.class),
+ response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
@@ -214,6 +232,9 @@ public CatchAllApiHttpResponse createEntity(
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -296,6 +317,9 @@ public CatchAllApiHttpResponse createEntitiesBatch(
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -376,6 +400,9 @@ public CatchAllApiHttpResponse getEntity(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -462,6 +489,9 @@ public CatchAllApiHttpResponse deleteEntity(
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -556,6 +586,9 @@ public CatchAllApiHttpResponse updateEntity(
case 400:
throw new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
diff --git a/src/main/java/com/newscatcher/catchall/resources/entities/requests/ListEntitiesRequest.java b/src/main/java/com/newscatcher/catchall/resources/entities/requests/ListEntitiesRequest.java
index 95caf83..78917ba 100644
--- a/src/main/java/com/newscatcher/catchall/resources/entities/requests/ListEntitiesRequest.java
+++ b/src/main/java/com/newscatcher/catchall/resources/entities/requests/ListEntitiesRequest.java
@@ -38,6 +38,8 @@ public final class ListEntitiesRequest {
private final Optional sortOrder;
+ private final Optional projectId;
+
private final Map additionalProperties;
private ListEntitiesRequest(
@@ -48,6 +50,7 @@ private ListEntitiesRequest(
Optional entityType,
Optional sortBy,
Optional sortOrder,
+ Optional projectId,
Map additionalProperties) {
this.page = page;
this.pageSize = pageSize;
@@ -56,6 +59,7 @@ private ListEntitiesRequest(
this.entityType = entityType;
this.sortBy = sortBy;
this.sortOrder = sortOrder;
+ this.projectId = projectId;
this.additionalProperties = additionalProperties;
}
@@ -103,6 +107,14 @@ public Optional getSortOrder() {
return sortOrder;
}
+ /**
+ * @return Filter results to resources belonging to this project.
+ */
+ @JsonProperty("project_id")
+ public Optional getProjectId() {
+ return projectId;
+ }
+
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
@@ -121,13 +133,21 @@ private boolean equalTo(ListEntitiesRequest other) {
&& status.equals(other.status)
&& entityType.equals(other.entityType)
&& sortBy.equals(other.sortBy)
- && sortOrder.equals(other.sortOrder);
+ && sortOrder.equals(other.sortOrder)
+ && projectId.equals(other.projectId);
}
@java.lang.Override
public int hashCode() {
return Objects.hash(
- this.page, this.pageSize, this.search, this.status, this.entityType, this.sortBy, this.sortOrder);
+ this.page,
+ this.pageSize,
+ this.search,
+ this.status,
+ this.entityType,
+ this.sortBy,
+ this.sortOrder,
+ this.projectId);
}
@java.lang.Override
@@ -155,6 +175,8 @@ public static final class Builder {
private Optional sortOrder = Optional.empty();
+ private Optional projectId = Optional.empty();
+
@JsonAnySetter
private Map additionalProperties = new HashMap<>();
@@ -168,6 +190,7 @@ public Builder from(ListEntitiesRequest other) {
entityType(other.getEntityType());
sortBy(other.getSortBy());
sortOrder(other.getSortOrder());
+ projectId(other.getProjectId());
return this;
}
@@ -257,9 +280,23 @@ public Builder sortOrder(SortOrder sortOrder) {
return this;
}
+ /**
+ * Filter results to resources belonging to this project.
+ */
+ @JsonSetter(value = "project_id", nulls = Nulls.SKIP)
+ public Builder projectId(Optional projectId) {
+ this.projectId = projectId;
+ return this;
+ }
+
+ public Builder projectId(String projectId) {
+ this.projectId = Optional.ofNullable(projectId);
+ return this;
+ }
+
public ListEntitiesRequest build() {
return new ListEntitiesRequest(
- page, pageSize, search, status, entityType, sortBy, sortOrder, additionalProperties);
+ page, pageSize, search, status, entityType, sortBy, sortOrder, projectId, additionalProperties);
}
public Builder additionalProperty(String key, Object value) {
diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncMonitorsClient.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/AsyncEventMonitorsClient.java
similarity index 60%
rename from src/main/java/com/newscatcher/catchall/resources/monitors/AsyncMonitorsClient.java
rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/AsyncEventMonitorsClient.java
index 3ecfa94..23f4a45 100644
--- a/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncMonitorsClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/AsyncEventMonitorsClient.java
@@ -1,23 +1,23 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.newscatcher.catchall.resources.monitors;
+package com.newscatcher.catchall.resources.eventmonitors;
import com.newscatcher.catchall.core.ClientOptions;
import com.newscatcher.catchall.core.RequestOptions;
-import com.newscatcher.catchall.resources.monitors.requests.CreateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.DeleteMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.DisableMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.EnableMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.GetMonitorStatusHistoryRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorJobsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsCsvRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.UpdateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.types.DisableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.EnableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.ListMonitorJobsResponse;
+import com.newscatcher.catchall.resources.eventmonitors.requests.CreateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DeleteMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DisableMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.EnableMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.GetMonitorStatusHistoryRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorJobsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsCsvRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.UpdateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.types.DisableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.EnableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.ListMonitorJobsResponse;
import com.newscatcher.catchall.types.CreateMonitorResponseDto;
import com.newscatcher.catchall.types.DeleteMonitorResponseDto;
import com.newscatcher.catchall.types.ListMonitorsResponseDto;
@@ -26,46 +26,46 @@
import com.newscatcher.catchall.types.UpdateMonitorResponseDto;
import java.util.concurrent.CompletableFuture;
-public class AsyncMonitorsClient {
+public class AsyncEventMonitorsClient {
protected final ClientOptions clientOptions;
- private final AsyncRawMonitorsClient rawClient;
+ private final AsyncRawEventMonitorsClient rawClient;
- public AsyncMonitorsClient(ClientOptions clientOptions) {
+ public AsyncEventMonitorsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
- this.rawClient = new AsyncRawMonitorsClient(clientOptions);
+ this.rawClient = new AsyncRawEventMonitorsClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
- public AsyncRawMonitorsClient withRawResponse() {
+ public AsyncRawEventMonitorsClient withRawResponse() {
return this.rawClient;
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture listMonitors() {
return this.rawClient.listMonitors().thenApply(response -> response.body());
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture listMonitors(RequestOptions requestOptions) {
return this.rawClient.listMonitors(requestOptions).thenApply(response -> response.body());
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture listMonitors(ListMonitorsRequest request) {
return this.rawClient.listMonitors(request).thenApply(response -> response.body());
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture listMonitors(
ListMonitorsRequest request, RequestOptions requestOptions) {
@@ -73,14 +73,14 @@ public CompletableFuture listMonitors(
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CompletableFuture createMonitor(CreateMonitorRequestDto request) {
return this.rawClient.createMonitor(request).thenApply(response -> response.body());
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CompletableFuture createMonitor(
CreateMonitorRequestDto request, RequestOptions requestOptions) {
@@ -88,14 +88,14 @@ public CompletableFuture createMonitor(
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture pullMonitorResults(String monitorId) {
return this.rawClient.pullMonitorResults(monitorId).thenApply(response -> response.body());
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture pullMonitorResults(
String monitorId, RequestOptions requestOptions) {
@@ -103,7 +103,7 @@ public CompletableFuture pullMonitorResults(
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture pullMonitorResults(
String monitorId, PullMonitorResultsRequest request) {
@@ -111,7 +111,7 @@ public CompletableFuture pullMonitorResults(
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture pullMonitorResults(
String monitorId, PullMonitorResultsRequest request, RequestOptions requestOptions) {
@@ -122,7 +122,7 @@ public CompletableFuture pullMonitorResults(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture pullMonitorResultsCsv(String monitorId) {
return this.rawClient.pullMonitorResultsCsv(monitorId).thenApply(response -> response.body());
@@ -130,7 +130,7 @@ public CompletableFuture pullMonitorResultsCsv(String monitorId) {
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture pullMonitorResultsCsv(String monitorId, RequestOptions requestOptions) {
return this.rawClient.pullMonitorResultsCsv(monitorId, requestOptions).thenApply(response -> response.body());
@@ -138,7 +138,7 @@ public CompletableFuture pullMonitorResultsCsv(String monitorId, Request
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture pullMonitorResultsCsv(String monitorId, PullMonitorResultsCsvRequest request) {
return this.rawClient.pullMonitorResultsCsv(monitorId, request).thenApply(response -> response.body());
@@ -146,7 +146,7 @@ public CompletableFuture pullMonitorResultsCsv(String monitorId, PullMon
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture pullMonitorResultsCsv(
String monitorId, PullMonitorResultsCsvRequest request, RequestOptions requestOptions) {
@@ -156,21 +156,21 @@ public CompletableFuture pullMonitorResultsCsv(
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture listMonitorJobs(String monitorId) {
return this.rawClient.listMonitorJobs(monitorId).thenApply(response -> response.body());
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture listMonitorJobs(String monitorId, RequestOptions requestOptions) {
return this.rawClient.listMonitorJobs(monitorId, requestOptions).thenApply(response -> response.body());
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture listMonitorJobs(
String monitorId, ListMonitorJobsRequest request) {
@@ -178,7 +178,7 @@ public CompletableFuture listMonitorJobs(
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture listMonitorJobs(
String monitorId, ListMonitorJobsRequest request, RequestOptions requestOptions) {
@@ -188,14 +188,14 @@ public CompletableFuture listMonitorJobs(
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CompletableFuture getMonitorStatusHistory(String monitorId) {
return this.rawClient.getMonitorStatusHistory(monitorId).thenApply(response -> response.body());
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CompletableFuture getMonitorStatusHistory(
String monitorId, RequestOptions requestOptions) {
@@ -203,7 +203,7 @@ public CompletableFuture getMonitorStatusHistor
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CompletableFuture getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request) {
@@ -211,7 +211,7 @@ public CompletableFuture getMonitorStatusHistor
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CompletableFuture getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request, RequestOptions requestOptions) {
@@ -221,28 +221,28 @@ public CompletableFuture getMonitorStatusHistor
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture enableMonitor(String monitorId) {
return this.rawClient.enableMonitor(monitorId).thenApply(response -> response.body());
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture enableMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.enableMonitor(monitorId, requestOptions).thenApply(response -> response.body());
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture enableMonitor(String monitorId, EnableMonitorRequestDto request) {
return this.rawClient.enableMonitor(monitorId, request).thenApply(response -> response.body());
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture enableMonitor(
String monitorId, EnableMonitorRequestDto request, RequestOptions requestOptions) {
@@ -250,28 +250,28 @@ public CompletableFuture enableMonitor(
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture disableMonitor(String monitorId) {
return this.rawClient.disableMonitor(monitorId).thenApply(response -> response.body());
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture disableMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.disableMonitor(monitorId, requestOptions).thenApply(response -> response.body());
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture disableMonitor(String monitorId, DisableMonitorRequest request) {
return this.rawClient.disableMonitor(monitorId, request).thenApply(response -> response.body());
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture disableMonitor(
String monitorId, DisableMonitorRequest request, RequestOptions requestOptions) {
@@ -279,48 +279,48 @@ public CompletableFuture disableMonitor(
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture deleteMonitor(String monitorId) {
return this.rawClient.deleteMonitor(monitorId).thenApply(response -> response.body());
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture deleteMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.deleteMonitor(monitorId, requestOptions).thenApply(response -> response.body());
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture deleteMonitor(String monitorId, DeleteMonitorRequest request) {
return this.rawClient.deleteMonitor(monitorId, request).thenApply(response -> response.body());
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture deleteMonitor(
String monitorId, DeleteMonitorRequest request, RequestOptions requestOptions) {
@@ -328,21 +328,33 @@ public CompletableFuture deleteMonitor(
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture updateMonitor(String monitorId) {
return this.rawClient.updateMonitor(monitorId).thenApply(response -> response.body());
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture updateMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.updateMonitor(monitorId, requestOptions).thenApply(response -> response.body());
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture updateMonitor(
String monitorId, UpdateMonitorRequestDto request) {
@@ -350,7 +362,11 @@ public CompletableFuture updateMonitor(
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture updateMonitor(
String monitorId, UpdateMonitorRequestDto request, RequestOptions requestOptions) {
diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncRawMonitorsClient.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/AsyncRawEventMonitorsClient.java
similarity index 84%
rename from src/main/java/com/newscatcher/catchall/resources/monitors/AsyncRawMonitorsClient.java
rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/AsyncRawEventMonitorsClient.java
index 4270db0..43fa108 100644
--- a/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncRawMonitorsClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/AsyncRawEventMonitorsClient.java
@@ -1,7 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.newscatcher.catchall.resources.monitors;
+package com.newscatcher.catchall.resources.eventmonitors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.newscatcher.catchall.core.CatchAllApiApiException;
@@ -17,19 +17,19 @@
import com.newscatcher.catchall.errors.NotFoundError;
import com.newscatcher.catchall.errors.UnauthorizedError;
import com.newscatcher.catchall.errors.UnprocessableEntityError;
-import com.newscatcher.catchall.resources.monitors.requests.CreateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.DeleteMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.DisableMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.EnableMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.GetMonitorStatusHistoryRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorJobsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsCsvRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.UpdateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.types.DisableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.EnableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.ListMonitorJobsResponse;
+import com.newscatcher.catchall.resources.eventmonitors.requests.CreateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DeleteMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DisableMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.EnableMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.GetMonitorStatusHistoryRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorJobsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsCsvRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.UpdateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.types.DisableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.EnableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.ListMonitorJobsResponse;
import com.newscatcher.catchall.types.CreateMonitorResponseDto;
import com.newscatcher.catchall.types.DeleteMonitorResponseDto;
import com.newscatcher.catchall.types.Error;
@@ -51,22 +51,22 @@
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;
-public class AsyncRawMonitorsClient {
+public class AsyncRawEventMonitorsClient {
protected final ClientOptions clientOptions;
- public AsyncRawMonitorsClient(ClientOptions clientOptions) {
+ public AsyncRawEventMonitorsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture> listMonitors() {
return listMonitors(ListMonitorsRequest.builder().build());
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture> listMonitors(
RequestOptions requestOptions) {
@@ -74,7 +74,7 @@ public CompletableFuture> listM
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture> listMonitors(
ListMonitorsRequest request) {
@@ -82,7 +82,7 @@ public CompletableFuture> listM
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CompletableFuture> listMonitors(
ListMonitorsRequest request, RequestOptions requestOptions) {
@@ -147,6 +147,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -183,7 +188,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CompletableFuture> createMonitor(
CreateMonitorRequestDto request) {
@@ -191,7 +196,7 @@ public CompletableFuture> crea
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CompletableFuture> createMonitor(
CreateMonitorRequestDto request, RequestOptions requestOptions) {
@@ -243,12 +248,18 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
return;
}
try {
- if (response.code() == 422) {
- future.completeExceptionally(new UnprocessableEntityError(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, ValidationErrorResponse.class),
- response));
- return;
+ switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
+ case 422:
+ future.completeExceptionally(new UnprocessableEntityError(
+ ObjectMappers.JSON_MAPPER.readValue(
+ responseBodyString, ValidationErrorResponse.class),
+ response));
+ return;
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
@@ -274,14 +285,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture> pullMonitorResults(String monitorId) {
return pullMonitorResults(monitorId, PullMonitorResultsRequest.builder().build());
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture> pullMonitorResults(
String monitorId, RequestOptions requestOptions) {
@@ -289,7 +300,7 @@ public CompletableFuture> pullMo
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture> pullMonitorResults(
String monitorId, PullMonitorResultsRequest request) {
@@ -297,7 +308,7 @@ public CompletableFuture> pullMo
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CompletableFuture> pullMonitorResults(
String monitorId, PullMonitorResultsRequest request, RequestOptions requestOptions) {
@@ -343,6 +354,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -380,7 +396,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture> pullMonitorResultsCsv(String monitorId) {
return pullMonitorResultsCsv(
@@ -389,7 +405,7 @@ public CompletableFuture> pullMonitorResultsCsv(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture> pullMonitorResultsCsv(
String monitorId, RequestOptions requestOptions) {
@@ -399,7 +415,7 @@ public CompletableFuture> pullMonitorResultsCsv(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture> pullMonitorResultsCsv(
String monitorId, PullMonitorResultsCsvRequest request) {
@@ -408,7 +424,7 @@ public CompletableFuture> pullMonitorResultsCsv(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CompletableFuture> pullMonitorResultsCsv(
String monitorId, PullMonitorResultsCsvRequest request, RequestOptions requestOptions) {
@@ -453,6 +469,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -488,14 +509,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture> listMonitorJobs(String monitorId) {
return listMonitorJobs(monitorId, ListMonitorJobsRequest.builder().build());
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture> listMonitorJobs(
String monitorId, RequestOptions requestOptions) {
@@ -503,7 +524,7 @@ public CompletableFuture> listM
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture> listMonitorJobs(
String monitorId, ListMonitorJobsRequest request) {
@@ -511,7 +532,7 @@ public CompletableFuture> listM
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CompletableFuture> listMonitorJobs(
String monitorId, ListMonitorJobsRequest request, RequestOptions requestOptions) {
@@ -562,6 +583,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 404:
future.completeExceptionally(new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -598,7 +624,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CompletableFuture> getMonitorStatusHistory(
String monitorId) {
@@ -607,7 +633,7 @@ public CompletableFuture> getMonitorStatusHistory(
String monitorId, RequestOptions requestOptions) {
@@ -616,7 +642,7 @@ public CompletableFuture> getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request) {
@@ -624,7 +650,7 @@ public CompletableFuture> getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request, RequestOptions requestOptions) {
@@ -707,14 +733,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture> enableMonitor(String monitorId) {
return enableMonitor(monitorId, EnableMonitorRequestDto.builder().build());
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture> enableMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -722,7 +748,7 @@ public CompletableFuture> enableM
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture> enableMonitor(
String monitorId, EnableMonitorRequestDto request) {
@@ -730,7 +756,7 @@ public CompletableFuture> enableM
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CompletableFuture> enableMonitor(
String monitorId, EnableMonitorRequestDto request, RequestOptions requestOptions) {
@@ -785,6 +811,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -826,14 +857,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture> disableMonitor(String monitorId) {
return disableMonitor(monitorId, DisableMonitorRequest.builder().build());
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture> disableMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -841,7 +872,7 @@ public CompletableFuture> disabl
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture> disableMonitor(
String monitorId, DisableMonitorRequest request) {
@@ -849,7 +880,7 @@ public CompletableFuture> disabl
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CompletableFuture> disableMonitor(
String monitorId, DisableMonitorRequest request, RequestOptions requestOptions) {
@@ -896,6 +927,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
@@ -937,24 +973,24 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture> deleteMonitor(String monitorId) {
return deleteMonitor(monitorId, DeleteMonitorRequest.builder().build());
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture> deleteMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -962,12 +998,12 @@ public CompletableFuture> dele
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture> deleteMonitor(
String monitorId, DeleteMonitorRequest request) {
@@ -975,12 +1011,12 @@ public CompletableFuture> dele
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CompletableFuture> deleteMonitor(
String monitorId, DeleteMonitorRequest request, RequestOptions requestOptions) {
@@ -1061,14 +1097,22 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture> updateMonitor(String monitorId) {
return updateMonitor(monitorId, UpdateMonitorRequestDto.builder().build());
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture> updateMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -1076,7 +1120,11 @@ public CompletableFuture> upda
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture> updateMonitor(
String monitorId, UpdateMonitorRequestDto request) {
@@ -1084,7 +1132,11 @@ public CompletableFuture> upda
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public CompletableFuture> updateMonitor(
String monitorId, UpdateMonitorRequestDto request, RequestOptions requestOptions) {
@@ -1138,6 +1190,11 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
}
try {
switch (response.code()) {
+ case 401:
+ future.completeExceptionally(new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
+ response));
+ return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class),
diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/MonitorsClient.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/EventMonitorsClient.java
similarity index 56%
rename from src/main/java/com/newscatcher/catchall/resources/monitors/MonitorsClient.java
rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/EventMonitorsClient.java
index 597569f..5ba7584 100644
--- a/src/main/java/com/newscatcher/catchall/resources/monitors/MonitorsClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/EventMonitorsClient.java
@@ -1,23 +1,23 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.newscatcher.catchall.resources.monitors;
+package com.newscatcher.catchall.resources.eventmonitors;
import com.newscatcher.catchall.core.ClientOptions;
import com.newscatcher.catchall.core.RequestOptions;
-import com.newscatcher.catchall.resources.monitors.requests.CreateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.DeleteMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.DisableMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.EnableMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.GetMonitorStatusHistoryRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorJobsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsCsvRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.UpdateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.types.DisableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.EnableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.ListMonitorJobsResponse;
+import com.newscatcher.catchall.resources.eventmonitors.requests.CreateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DeleteMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DisableMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.EnableMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.GetMonitorStatusHistoryRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorJobsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsCsvRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.UpdateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.types.DisableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.EnableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.ListMonitorJobsResponse;
import com.newscatcher.catchall.types.CreateMonitorResponseDto;
import com.newscatcher.catchall.types.DeleteMonitorResponseDto;
import com.newscatcher.catchall.types.ListMonitorsResponseDto;
@@ -25,88 +25,88 @@
import com.newscatcher.catchall.types.PullMonitorResponseDto;
import com.newscatcher.catchall.types.UpdateMonitorResponseDto;
-public class MonitorsClient {
+public class EventMonitorsClient {
protected final ClientOptions clientOptions;
- private final RawMonitorsClient rawClient;
+ private final RawEventMonitorsClient rawClient;
- public MonitorsClient(ClientOptions clientOptions) {
+ public EventMonitorsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
- this.rawClient = new RawMonitorsClient(clientOptions);
+ this.rawClient = new RawEventMonitorsClient(clientOptions);
}
/**
* Get responses with HTTP metadata like headers
*/
- public RawMonitorsClient withRawResponse() {
+ public RawEventMonitorsClient withRawResponse() {
return this.rawClient;
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public ListMonitorsResponseDto listMonitors() {
return this.rawClient.listMonitors().body();
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public ListMonitorsResponseDto listMonitors(RequestOptions requestOptions) {
return this.rawClient.listMonitors(requestOptions).body();
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public ListMonitorsResponseDto listMonitors(ListMonitorsRequest request) {
return this.rawClient.listMonitors(request).body();
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public ListMonitorsResponseDto listMonitors(ListMonitorsRequest request, RequestOptions requestOptions) {
return this.rawClient.listMonitors(request, requestOptions).body();
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CreateMonitorResponseDto createMonitor(CreateMonitorRequestDto request) {
return this.rawClient.createMonitor(request).body();
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CreateMonitorResponseDto createMonitor(CreateMonitorRequestDto request, RequestOptions requestOptions) {
return this.rawClient.createMonitor(request, requestOptions).body();
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public PullMonitorResponseDto pullMonitorResults(String monitorId) {
return this.rawClient.pullMonitorResults(monitorId).body();
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public PullMonitorResponseDto pullMonitorResults(String monitorId, RequestOptions requestOptions) {
return this.rawClient.pullMonitorResults(monitorId, requestOptions).body();
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public PullMonitorResponseDto pullMonitorResults(String monitorId, PullMonitorResultsRequest request) {
return this.rawClient.pullMonitorResults(monitorId, request).body();
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public PullMonitorResponseDto pullMonitorResults(
String monitorId, PullMonitorResultsRequest request, RequestOptions requestOptions) {
@@ -117,7 +117,7 @@ public PullMonitorResponseDto pullMonitorResults(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public String pullMonitorResultsCsv(String monitorId) {
return this.rawClient.pullMonitorResultsCsv(monitorId).body();
@@ -125,7 +125,7 @@ public String pullMonitorResultsCsv(String monitorId) {
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public String pullMonitorResultsCsv(String monitorId, RequestOptions requestOptions) {
return this.rawClient.pullMonitorResultsCsv(monitorId, requestOptions).body();
@@ -133,7 +133,7 @@ public String pullMonitorResultsCsv(String monitorId, RequestOptions requestOpti
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public String pullMonitorResultsCsv(String monitorId, PullMonitorResultsCsvRequest request) {
return this.rawClient.pullMonitorResultsCsv(monitorId, request).body();
@@ -141,7 +141,7 @@ public String pullMonitorResultsCsv(String monitorId, PullMonitorResultsCsvReque
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public String pullMonitorResultsCsv(
String monitorId, PullMonitorResultsCsvRequest request, RequestOptions requestOptions) {
@@ -151,28 +151,28 @@ public String pullMonitorResultsCsv(
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public ListMonitorJobsResponse listMonitorJobs(String monitorId) {
return this.rawClient.listMonitorJobs(monitorId).body();
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public ListMonitorJobsResponse listMonitorJobs(String monitorId, RequestOptions requestOptions) {
return this.rawClient.listMonitorJobs(monitorId, requestOptions).body();
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public ListMonitorJobsResponse listMonitorJobs(String monitorId, ListMonitorJobsRequest request) {
return this.rawClient.listMonitorJobs(monitorId, request).body();
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public ListMonitorJobsResponse listMonitorJobs(
String monitorId, ListMonitorJobsRequest request, RequestOptions requestOptions) {
@@ -182,21 +182,21 @@ public ListMonitorJobsResponse listMonitorJobs(
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public MonitorStatusHistoryResponseDto getMonitorStatusHistory(String monitorId) {
return this.rawClient.getMonitorStatusHistory(monitorId).body();
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public MonitorStatusHistoryResponseDto getMonitorStatusHistory(String monitorId, RequestOptions requestOptions) {
return this.rawClient.getMonitorStatusHistory(monitorId, requestOptions).body();
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public MonitorStatusHistoryResponseDto getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request) {
@@ -204,7 +204,7 @@ public MonitorStatusHistoryResponseDto getMonitorStatusHistory(
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public MonitorStatusHistoryResponseDto getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request, RequestOptions requestOptions) {
@@ -214,28 +214,28 @@ public MonitorStatusHistoryResponseDto getMonitorStatusHistory(
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public EnableMonitorResponse enableMonitor(String monitorId) {
return this.rawClient.enableMonitor(monitorId).body();
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public EnableMonitorResponse enableMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.enableMonitor(monitorId, requestOptions).body();
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public EnableMonitorResponse enableMonitor(String monitorId, EnableMonitorRequestDto request) {
return this.rawClient.enableMonitor(monitorId, request).body();
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public EnableMonitorResponse enableMonitor(
String monitorId, EnableMonitorRequestDto request, RequestOptions requestOptions) {
@@ -243,28 +243,28 @@ public EnableMonitorResponse enableMonitor(
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public DisableMonitorResponse disableMonitor(String monitorId) {
return this.rawClient.disableMonitor(monitorId).body();
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public DisableMonitorResponse disableMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.disableMonitor(monitorId, requestOptions).body();
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public DisableMonitorResponse disableMonitor(String monitorId, DisableMonitorRequest request) {
return this.rawClient.disableMonitor(monitorId, request).body();
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public DisableMonitorResponse disableMonitor(
String monitorId, DisableMonitorRequest request, RequestOptions requestOptions) {
@@ -272,48 +272,48 @@ public DisableMonitorResponse disableMonitor(
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public DeleteMonitorResponseDto deleteMonitor(String monitorId) {
return this.rawClient.deleteMonitor(monitorId).body();
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public DeleteMonitorResponseDto deleteMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.deleteMonitor(monitorId, requestOptions).body();
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public DeleteMonitorResponseDto deleteMonitor(String monitorId, DeleteMonitorRequest request) {
return this.rawClient.deleteMonitor(monitorId, request).body();
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public DeleteMonitorResponseDto deleteMonitor(
String monitorId, DeleteMonitorRequest request, RequestOptions requestOptions) {
@@ -321,28 +321,44 @@ public DeleteMonitorResponseDto deleteMonitor(
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public UpdateMonitorResponseDto updateMonitor(String monitorId) {
return this.rawClient.updateMonitor(monitorId).body();
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public UpdateMonitorResponseDto updateMonitor(String monitorId, RequestOptions requestOptions) {
return this.rawClient.updateMonitor(monitorId, requestOptions).body();
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public UpdateMonitorResponseDto updateMonitor(String monitorId, UpdateMonitorRequestDto request) {
return this.rawClient.updateMonitor(monitorId, request).body();
}
/**
- * Update the webhook configuration for an existing monitor.
+ * Update the webhook assignments, record limit, or schedule of an existing
+ * event monitor. Omitted fields are left unchanged.
+ * Passing schedule replaces the event monitor's current schedule. The new
+ * schedule takes effect from the next scheduler reload, and the old schedule
+ * stops firing. The reference job cannot be changed.
*/
public UpdateMonitorResponseDto updateMonitor(
String monitorId, UpdateMonitorRequestDto request, RequestOptions requestOptions) {
diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/RawEventMonitorsClient.java
similarity index 82%
rename from src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java
rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/RawEventMonitorsClient.java
index c57ddec..010048d 100644
--- a/src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java
+++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/RawEventMonitorsClient.java
@@ -1,7 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.newscatcher.catchall.resources.monitors;
+package com.newscatcher.catchall.resources.eventmonitors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.newscatcher.catchall.core.CatchAllApiApiException;
@@ -17,19 +17,19 @@
import com.newscatcher.catchall.errors.NotFoundError;
import com.newscatcher.catchall.errors.UnauthorizedError;
import com.newscatcher.catchall.errors.UnprocessableEntityError;
-import com.newscatcher.catchall.resources.monitors.requests.CreateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.DeleteMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.DisableMonitorRequest;
-import com.newscatcher.catchall.resources.monitors.requests.EnableMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.requests.GetMonitorStatusHistoryRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorJobsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.ListMonitorsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsCsvRequest;
-import com.newscatcher.catchall.resources.monitors.requests.PullMonitorResultsRequest;
-import com.newscatcher.catchall.resources.monitors.requests.UpdateMonitorRequestDto;
-import com.newscatcher.catchall.resources.monitors.types.DisableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.EnableMonitorResponse;
-import com.newscatcher.catchall.resources.monitors.types.ListMonitorJobsResponse;
+import com.newscatcher.catchall.resources.eventmonitors.requests.CreateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DeleteMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.DisableMonitorRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.EnableMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.requests.GetMonitorStatusHistoryRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorJobsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.ListMonitorsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsCsvRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.PullMonitorResultsRequest;
+import com.newscatcher.catchall.resources.eventmonitors.requests.UpdateMonitorRequestDto;
+import com.newscatcher.catchall.resources.eventmonitors.types.DisableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.EnableMonitorResponse;
+import com.newscatcher.catchall.resources.eventmonitors.types.ListMonitorJobsResponse;
import com.newscatcher.catchall.types.CreateMonitorResponseDto;
import com.newscatcher.catchall.types.DeleteMonitorResponseDto;
import com.newscatcher.catchall.types.Error;
@@ -47,36 +47,36 @@
import okhttp3.Response;
import okhttp3.ResponseBody;
-public class RawMonitorsClient {
+public class RawEventMonitorsClient {
protected final ClientOptions clientOptions;
- public RawMonitorsClient(ClientOptions clientOptions) {
+ public RawEventMonitorsClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CatchAllApiHttpResponse listMonitors() {
return listMonitors(ListMonitorsRequest.builder().build());
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CatchAllApiHttpResponse listMonitors(RequestOptions requestOptions) {
return listMonitors(ListMonitorsRequest.builder().build(), requestOptions);
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CatchAllApiHttpResponse listMonitors(ListMonitorsRequest request) {
return listMonitors(request, null);
}
/**
- * Returns all monitors created by the authenticated user.
+ * Returns all event monitors created by the authenticated user.
*/
public CatchAllApiHttpResponse listMonitors(
ListMonitorsRequest request, RequestOptions requestOptions) {
@@ -137,6 +137,9 @@ public CatchAllApiHttpResponse listMonitors(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -159,14 +162,14 @@ public CatchAllApiHttpResponse listMonitors(
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CatchAllApiHttpResponse createMonitor(CreateMonitorRequestDto request) {
return createMonitor(request, null);
}
/**
- * Create a scheduled monitor based on a reference job.
+ * Create a scheduled event monitor based on a reference job.
*/
public CatchAllApiHttpResponse createMonitor(
CreateMonitorRequestDto request, RequestOptions requestOptions) {
@@ -214,10 +217,14 @@ public CatchAllApiHttpResponse createMonitor(
response);
}
try {
- if (response.code() == 422) {
- throw new UnprocessableEntityError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidationErrorResponse.class),
- response);
+ switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
+ case 422:
+ throw new UnprocessableEntityError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ValidationErrorResponse.class),
+ response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
@@ -233,14 +240,14 @@ public CatchAllApiHttpResponse createMonitor(
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse pullMonitorResults(String monitorId) {
return pullMonitorResults(monitorId, PullMonitorResultsRequest.builder().build());
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse pullMonitorResults(
String monitorId, RequestOptions requestOptions) {
@@ -248,7 +255,7 @@ public CatchAllApiHttpResponse pullMonitorResults(
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse pullMonitorResults(
String monitorId, PullMonitorResultsRequest request) {
@@ -256,7 +263,7 @@ public CatchAllApiHttpResponse pullMonitorResults(
}
/**
- * Retrieve aggregated results from all jobs executed by a monitor.
+ * Retrieve aggregated results from all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse pullMonitorResults(
String monitorId, PullMonitorResultsRequest request, RequestOptions requestOptions) {
@@ -298,6 +305,9 @@ public CatchAllApiHttpResponse pullMonitorResults(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -321,7 +331,7 @@ public CatchAllApiHttpResponse pullMonitorResults(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CatchAllApiHttpResponse pullMonitorResultsCsv(String monitorId) {
return pullMonitorResultsCsv(
@@ -330,7 +340,7 @@ public CatchAllApiHttpResponse pullMonitorResultsCsv(String monitorId) {
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CatchAllApiHttpResponse pullMonitorResultsCsv(String monitorId, RequestOptions requestOptions) {
return pullMonitorResultsCsv(
@@ -339,7 +349,7 @@ public CatchAllApiHttpResponse pullMonitorResultsCsv(String monitorId, R
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CatchAllApiHttpResponse pullMonitorResultsCsv(
String monitorId, PullMonitorResultsCsvRequest request) {
@@ -348,7 +358,7 @@ public CatchAllApiHttpResponse pullMonitorResultsCsv(
/**
* Returns the most recent run's records as a CSV download. One row per record, with enrichment fields as columns and citations as a JSON column.
- * If the monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
+ * If the event monitor's reference job used connected entity datasets, connected entities are split into event_associated_entities and mention_entities JSON columns. When no entity dataset was used, those two columns are omitted from the export entirely.
*/
public CatchAllApiHttpResponse pullMonitorResultsCsv(
String monitorId, PullMonitorResultsCsvRequest request, RequestOptions requestOptions) {
@@ -389,6 +399,9 @@ public CatchAllApiHttpResponse pullMonitorResultsCsv(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -410,14 +423,14 @@ public CatchAllApiHttpResponse pullMonitorResultsCsv(
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse listMonitorJobs(String monitorId) {
return listMonitorJobs(monitorId, ListMonitorJobsRequest.builder().build());
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse listMonitorJobs(
String monitorId, RequestOptions requestOptions) {
@@ -425,7 +438,7 @@ public CatchAllApiHttpResponse listMonitorJobs(
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse listMonitorJobs(
String monitorId, ListMonitorJobsRequest request) {
@@ -433,7 +446,7 @@ public CatchAllApiHttpResponse listMonitorJobs(
}
/**
- * Return all jobs executed by a monitor.
+ * Return all jobs executed by an event monitor.
*/
public CatchAllApiHttpResponse listMonitorJobs(
String monitorId, ListMonitorJobsRequest request, RequestOptions requestOptions) {
@@ -480,6 +493,9 @@ public CatchAllApiHttpResponse listMonitorJobs(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 404:
throw new NotFoundError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -502,7 +518,7 @@ public CatchAllApiHttpResponse listMonitorJobs(
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CatchAllApiHttpResponse getMonitorStatusHistory(String monitorId) {
return getMonitorStatusHistory(
@@ -510,7 +526,7 @@ public CatchAllApiHttpResponse getMonitorStatus
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CatchAllApiHttpResponse getMonitorStatusHistory(
String monitorId, RequestOptions requestOptions) {
@@ -519,7 +535,7 @@ public CatchAllApiHttpResponse getMonitorStatus
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CatchAllApiHttpResponse getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request) {
@@ -527,7 +543,7 @@ public CatchAllApiHttpResponse getMonitorStatus
}
/**
- * Returns the full execution history of a monitor as a list of status entries, ordered from newest to oldest.
+ * Returns the full execution history of an event monitor as a list of status entries, ordered from newest to oldest.
*/
public CatchAllApiHttpResponse getMonitorStatusHistory(
String monitorId, GetMonitorStatusHistoryRequest request, RequestOptions requestOptions) {
@@ -591,14 +607,14 @@ public CatchAllApiHttpResponse getMonitorStatus
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse enableMonitor(String monitorId) {
return enableMonitor(monitorId, EnableMonitorRequestDto.builder().build());
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse enableMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -606,7 +622,7 @@ public CatchAllApiHttpResponse enableMonitor(
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse enableMonitor(
String monitorId, EnableMonitorRequestDto request) {
@@ -614,7 +630,7 @@ public CatchAllApiHttpResponse enableMonitor(
}
/**
- * Resume scheduled job execution for a monitor.
+ * Resume scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse enableMonitor(
String monitorId, EnableMonitorRequestDto request, RequestOptions requestOptions) {
@@ -664,6 +680,9 @@ public CatchAllApiHttpResponse enableMonitor(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -689,14 +708,14 @@ public CatchAllApiHttpResponse enableMonitor(
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse disableMonitor(String monitorId) {
return disableMonitor(monitorId, DisableMonitorRequest.builder().build());
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse disableMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -704,7 +723,7 @@ public CatchAllApiHttpResponse disableMonitor(
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse disableMonitor(
String monitorId, DisableMonitorRequest request) {
@@ -712,7 +731,7 @@ public CatchAllApiHttpResponse disableMonitor(
}
/**
- * Stop scheduled job execution for a monitor.
+ * Stop scheduled job execution for an event monitor.
*/
public CatchAllApiHttpResponse disableMonitor(
String monitorId, DisableMonitorRequest request, RequestOptions requestOptions) {
@@ -755,6 +774,9 @@ public CatchAllApiHttpResponse disableMonitor(
}
try {
switch (response.code()) {
+ case 401:
+ throw new UnauthorizedError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
case 403:
throw new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response);
@@ -780,24 +802,24 @@ public CatchAllApiHttpResponse disableMonitor(
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CatchAllApiHttpResponse deleteMonitor(String monitorId) {
return deleteMonitor(monitorId, DeleteMonitorRequest.builder().build());
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns 404 if the
- * monitor is not found or does not belong to the authenticated user.
- * Deleting an already-deleted monitor returns 200.
+ * Only the event monitor owner can delete an event monitor. Returns 404 if the
+ * event monitor is not found or does not belong to the authenticated user.
+ * Deleting an already-deleted event monitor returns 200.
*/
public CatchAllApiHttpResponse deleteMonitor(
String monitorId, RequestOptions requestOptions) {
@@ -805,12 +827,12 @@ public CatchAllApiHttpResponse deleteMonitor(
}
/**
- * Soft-deletes a monitor. The monitor is flagged as deleted, stops
+ * Soft-deletes an event monitor. The event monitor is flagged as deleted, stops
* executing scheduled jobs immediately, and no longer appears in list
* results.
- * Only the monitor owner can delete a monitor. Returns